PreviousUpNext

15.4.1384  src/lib/x-kit/tut/widget/simple.pkg

## simple.pkg

# Compiled by:
#     src/lib/x-kit/tut/widget/widgets.lib

stipulate
    include package   threadkit;                # threadkit             is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
    package fil =  file__premicrothread;        # file__premicrothread  is from   src/lib/std/src/posix/file--premicrothread.pkg
    package rx  =  run_in_x_window_old;         # run_in_x_window_old   is from   src/lib/x-kit/widget/old/lib/run-in-x-window-old.pkg
    package top =  hostwindow;                  # hostwindow            is from   src/lib/x-kit/widget/old/basic/hostwindow.pkg
    package wg  =  widget;                      # widget                is from   src/lib/x-kit/widget/old/basic/widget.pkg
    package wa  =  widget_attribute_old;        # widget_attribute_old  is from   src/lib/x-kit/widget/old/lib/widget-attribute-old.pkg
    package wy  =  widget_style_old;            # widget_style_old      is from   src/lib/x-kit/widget/old/lib/widget-style-old.pkg
    #
    package low =  line_of_widgets;             # line_of_widgets       is from   src/lib/x-kit/widget/old/layout/line-of-widgets.pkg
    package pb  =  pushbuttons;                 # pushbuttons           is from   src/lib/x-kit/widget/old/leaf/pushbuttons.pkg
herein

    package simple: api {
                        do_it':  (List(String), String) -> Void;
                        do_it:    Void -> Void;
                        main:    (List(String), X) -> Void;
                    }
    {

        resources = [
            "*background: forestgreen"
          ];

        fun goodbye root
            =
            {   top::start_widgettree_running_in_hostwindow  hostwindow;
                loop ();
            }
            where
                fun quit ()
                    =
                    {   wg::delete_root_window root;
                        shut_down_thread_scheduler  winix__premicrothread::process::success;
                    };

                style = wg::style_from_strings (root, resources);

                name = wy::make_view
                         { name    =>    wy::style_name [],
                           aliases =>  [ wy::style_name [] ]
                         };

                view = (name, style);

                args = [ (wa::label, wa::STRING_VAL "Goodbye, Cruel World!") ];

                bttn = pb::make_text_pushbutton_with_click_callback' (root, view, args) quit;

                layout
                    =
                    low::line_of_widgets
                        (root, view,[])
                        (low::VT_CENTER
                          [
                            low::SPACER { min_size=>0,  best_size=>30, max_size=>NULL },
                            low::WIDGET (pb::as_widget bttn),
                            low::SPACER { min_size=>0,  best_size=>30, max_size=>NULL }
                          ]
                        );

                hostwindow = top::hostwindow
                            (root, view,[])
                            (low::as_widget  layout);

                fun loop ()
                    =
                    case (fil::read_line  fil::stdin)
                        #
                        THE string
                            =>
                            string == "quit\n"   ??   quit ()
                                                 ::   loop ();

                        NULL
                            =>
                            quit ();
                    esac;

            end;                                        # fun goodbye

        fun do_it' (debug_flags, server)
            =
            {   xlogger::init  debug_flags;
                #
                rx::run_in_x_window_old'  goodbye  [ rx::DISPLAY server ];
            };

        fun do_it ()
            =
            rx::run_in_x_window_old  goodbye;

        fun main (program ! server ! _, _) =>  do_it'([], server);
            main _                         =>  do_it ();
        end;

    };                                                  # package simple 
end;

## COPYRIGHT (c) 1991, 1995 by AT&T Bell Laboratories.  See SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext