PreviousUpNext

15.4.1302  src/lib/tk/src/toolkit/tests+examples/uw_ex.pkg

## uw_ex.pkg
## (C) 1996, Bremen Institute for Safe Systems, Universitaet Bremen
## Author: cxl

# Compiled by:
#     src/lib/tk/src/toolkit/tests+examples/sources.sublib



# **************************************************************************
# Small demo for the utility windows.
# **************************************************************************



###              "Any fool can make things bigger, more complex, and more violent.
###
###              "It takes a touch of genius -- and a lot of courage -- to move
###               in the opposite direction."
###
###                                               -- Albert Einstein 



package uw_ex: (weak)  api {                                                            
                     go:  Void -> Void;
                 }
    = 

    package {

        include tk;
                                                                                my
        mwi = make_window_id ();

        # Because of SML's linear visibility, we have to declare windows the opposite 
        # way they are going to appear. 

        fun confq ()
            =
            uw::confirm("Do you want to quit now?", fn()=> close_window mwi; end );

        # Information window. Note there are no modal information windows -- you'd
        # have to write them yourself using info_cc to bind the closing function
        # returned by info_cc to a button.

        fun testi ()
            = 
            { uw::info("All files have been deleted."); confq();};

        # Confirm. No fate for the Cancel option-- it just closes the window

        fun testc ()
            = 
            uw::confirm("Do you really want to delete all your files?", testi);

        # Modal warning window

        fun testw ()
            =
            uw::warning_cc("Your printer is on fire", testc);

        # Modal error window

        fun teste ()
            =
            { go_on = fn x=> { print("The close button has been \
                                                     \clicked.\n"); testw x;}; end ;
            
                uw::error_cc("File \"/home/cxl/rubbish\" \
                                  \not found or not readable.", go_on);
                      print "The window has just been opened.\n";
            };

        # Start button, and main window:
                                                                                my
        start_button
            =
            BUTTON {
                widget_id => make_widget_id(),
                packing_hints => [PACK_AT TOP],
                traits => [TEXT "Start", CALLBACK teste],
                event_callbacks => []
            }; 
                                                                                my
        w = make_window {
                window_id    => mwi,
                traits   => [WINDOW_TITLE "Utility Window Test"], 
                subwidgets  => PACKED [start_button],
                event_callbacks => [],
                init     => null_callback
            };


        # ... and go!

        fun go ()
            =
            start_tcl [w];

    };






Comments and suggestions to: bugs@mythryl.org

PreviousUpNext