PreviousUpNext

15.4.1578  src/lib/x-kit/widget/xkit/theme/widget/default/look/widget-imp-types.pkg

# widget-imp-types.pkg
#
# Here we define the hook functions which a client may supply
# in order to customize the behavior of a widget.  This is the
# interface used by specialized widgets to define their behavior
# layered on top of the basic services supplied by widget-imp.pkg.

# Compiled by:
#     src/lib/x-kit/widget/xkit-widget.sublib


stipulate
    include package   threadkit;                                # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg

    package gtg =  guiboss_to_guishim;                          # guiboss_to_guishim            is from   src/lib/x-kit/widget/theme/guiboss-to-guishim.pkg

    package gd  =  gui_displaylist;                             # gui_displaylist               is from   src/lib/x-kit/widget/theme/gui-displaylist.pkg

    package pp  =  standard_prettyprinter;                      # standard_prettyprinter        is from   src/lib/prettyprint/big/src/standard-prettyprinter.pkg
    package r8  =  rgb8;                                        # rgb8                          is from   src/lib/x-kit/xclient/src/color/rgb8.pkg
    #
    package g2d =  geometry2d;                                  # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    package g2j =  geometry2d_junk;                             # geometry2d_junk               is from   src/lib/std/2d/geometry2d-junk.pkg

    package evt =  gui_event_types;                             # gui_event_types               is from   src/lib/x-kit/widget/gui/gui-event-types.pkg
    package gts =  gui_event_to_string;                         # gui_event_to_string           is from   src/lib/x-kit/widget/gui/gui-event-to-string.pkg

    package gt  =  guiboss_types;                               # guiboss_types                 is from   src/lib/x-kit/widget/gui/guiboss-types.pkg
    package wt  =  widget_theme;                                # widget_theme                  is from   src/lib/x-kit/widget/theme/widget/widget-theme.pkg

    package g2p =  gadget_to_pixmap;                            # gadget_to_pixmap              is from   src/lib/x-kit/widget/theme/gadget-to-pixmap.pkg

    #
    tracefile   =  "widget-unit-test.trace.log";

    nb = log::note_on_stderr;                                   # log                           is from   src/lib/std/src/log.pkg
herein
    # This package is referenced in:
    #
    #     src/lib/x-kit/widget/xkit/theme/widget/default/look/widget-imp.api
    #     src/lib/x-kit/widget/xkit/theme/widget/default/look/widget-imp.pkg
    #
    package widget_imp_types {
        #
        Widget                                                                                          # This turns out not to get used in practice, and probably should be dropped if no use turns up for it.
          =
          { id:                                 Id,                                                     # Unique id to facilitate storing node_state instances in indexed datastructures like red-black trees.
            pass_something:                     Replyqueue -> (Int -> Void) -> Void,
            do_something:                       Int -> Void,
            do:                                 (Void -> Void) -> Void                                  # Used by widget subthreads to run code in main widget microthread.
          };

        Startup_Fn_Arg
          =
          { id:                                 Id,                                                     # Unique id of this widget.
            doc:                                String,                                                 # Text description of this widget for debug/display purposes.
            widget_to_guiboss:                  gt::Widget_To_Guiboss,
            do:                                 (Void -> Void) -> Void,                                 # Used by widget subthreads to run code in main widget microthread.
            to:                                 Replyqueue
          };
        Startup_Fn = Startup_Fn_Arg -> Void;

        Shutdown_Fn_Arg =  Void;
        Shutdown_Fn     =  Shutdown_Fn_Arg -> Void;

        Initialize_Gadget_Fn_Arg
          =
          {
            id:                                 Id,                                                     # Unique id of this widget.
            doc:                                String,                                                 # Text description of this widget for debug/display purposes.
            site:                               g2d::Box,                                               # Window rectangle in which to draw.
            widget_to_guiboss:                  gt::Widget_To_Guiboss,
            theme:                              wt::Widget_Theme,
            pass_font:                          List(String) -> Replyqueue
                                                             -> (evt::Font -> Void) -> Void,            # Nonblocking version of next, for use in imps.
             get_font:                          List(String) ->  evt::Font,                             # Accepts a list of font names which are tried in order.
            make_rw_pixmap:                     g2d::Size -> g2p::Gadget_To_Rw_Pixmap,                  # Make an Xserver-side rw_pixmap for scratch use by widget.  In general there is no need for the widget to explicitly free these -- guiboss_imp will do this automatically when the gui is killed.
            #
            do:                                 (Void -> Void) -> Void,                                 # Used by widget subthreads to run code in main widget microthread.
            to:                                 Replyqueue                                              # Used to call 'pass_*' methods in other imps.
          };
        Initialize_Gadget_Fn =  Initialize_Gadget_Fn_Arg -> Void;

        Redraw_Request_Fn_Arg
          =
          {
            id:                                 Id,                                                     # Unique id of this widget.
            doc:                                String,                                                 # Text description of this widget for debug/display purposes.
            frame_number:                       Int,                                                    # 1,2,3,... Purely for convenience of widget, guiboss-imp makes no use of this.
            site:                               g2d::Box,                                               # Window rectangle in which to draw.
            frame_indent_hint:                  gt::Frame_Indent_Hint,
            duration_in_seconds:                Float,                                                  # If state has changed look-imp should call note_changed_gadget_foreground() before this time is up. Also useful for motionblur.
            widget_to_guiboss:                  gt::Widget_To_Guiboss,
            gadget_mode:                        gt::Gadget_Mode,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void,                                 # Used by widget subthreads to run code in main widget microthread.
            to:                                 Replyqueue,                                             # Used to call 'pass_*' methods in other imps.
            popup_nesting_depth:                Int                                                     # 0 for gadgets on basewindow, 1 for gadgets on popup on basewindow, 2 for gadgets on popup on popup, etc.
          };
        Redraw_Request_Fn = Redraw_Request_Fn_Arg -> Void;

        Mouse_Click_Fn_Arg
          =
          {
            id:                                 Id,                                                     # Unique id of this widget.
            doc:                                String,                                                 # Text description of this widget for debug/display purposes.
            button:                             evt::Mousebutton,
            event:                              gt::Mousebutton_Event,                                  # MOUSEBUTTON_PRESS or MOUSEBUTTON_RELEASE.
            point:                              g2d::Point,
            widget_layout_hint:                 gt::Widget_Layout_Hint,
            frame_indent_hint:                  gt::Frame_Indent_Hint,
            site:                               g2d::Box,                                               # Widget's assigned area in window coordinates.
            modifier_keys_state:                evt::Modifier_Keys_State,                               # State of the modifier keys (shift, ctrl...).
            mousebuttons_state:                 evt::Mousebuttons_State,                                # State of mouse buttons as a bool record.
            widget_to_guiboss:                  gt::Widget_To_Guiboss,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void,                                 # Used by widget subthreads to run code in main widget microthread.
            to:                                 Replyqueue                                              # Used to call 'pass_*' methods in other imps.
          };
        Mouse_Click_Fn = Mouse_Click_Fn_Arg -> Void;

        Mouse_Drag_Fn_Arg
          =
          {
            id:                                 Id,                                                     # Unique id of this widget.
            doc:                                String,                                                 # Text description of this widget for debug/display purposes.
            button:                             evt::Mousebutton,
            event_point:                        g2d::Point,
            start_point:                        g2d::Point,
            last_point:                         g2d::Point,
            phase:                              gt::Drag_Phase, 
            widget_layout_hint:                 gt::Widget_Layout_Hint,
            frame_indent_hint:                  gt::Frame_Indent_Hint,
            site:                               g2d::Box,                                               # Widget's assigned area in window coordinates.
            modifier_keys_state:                evt::Modifier_Keys_State,                               # State of the modifier keys (shift, ctrl...).
            mousebuttons_state:                 evt::Mousebuttons_State,                                # State of mouse buttons as a bool record.
            widget_to_guiboss:                  gt::Widget_To_Guiboss,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void,                                 # Used by widget subthreads to run code in main widget microthread.
            to:                                 Replyqueue                                              # Used to call 'pass_*' methods in other imps.
          };
        Mouse_Drag_Fn = Mouse_Drag_Fn_Arg -> Void;

        Mouse_Transit_Fn_Arg                                                                            # Note that buttons are always all up in a mouse-transit event -- otherwise it is a mouse-drag event.
          =
          {
            id:                                 Id,                                                     # Unique id of this widget.
            doc:                                String,                                                 # Text description of this widget for debug/display purposes.
            transit:                            gt::Gadget_Transit,                                     # Mouse is entering (CAME) or leaving (LEFT) widget, or moving (MOVE) across it.
            event_point:                        g2d::Point,
            widget_layout_hint:                 gt::Widget_Layout_Hint,
            frame_indent_hint:                  gt::Frame_Indent_Hint,
            site:                               g2d::Box,                                               # Widget's assigned area in window coordinates.
            modifier_keys_state:                evt::Modifier_Keys_State,                               # State of the modifier keys (shift, ctrl...).
            widget_to_guiboss:                  gt::Widget_To_Guiboss,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void,                                 # Used by widget subthreads to run code in main widget microthread.
            to:                                 Replyqueue                                              # Used to call 'pass_*' methods in other imps.
          };
        Mouse_Transit_Fn = Mouse_Transit_Fn_Arg -> Void;                                                # Note that buttons are always all up in a mouse-transit event -- otherwise it is a mouse-drag event.

        Key_Event_Fn_Arg
          =
          {
            id:                                 Id,                                                     # Unique id of this widget.
            doc:                                String,                                                 # Text description of this widget for debug/display purposes.
            keystroke:                          gt::Keystroke_Info,                                     # Keystring etc for event.
            widget_layout_hint:                 gt::Widget_Layout_Hint,
            frame_indent_hint:                  gt::Frame_Indent_Hint,
            site:                               g2d::Box,                                               # Widget's assigned area in window coordinates.
            widget_to_guiboss:                  gt::Widget_To_Guiboss,
            guiboss_to_widget:                  gt::Guiboss_To_Widget,                                  # Used by textpane.pkg keystroke-macro stuff to synthesize fake keystroke events to widget.
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void,                                 # Used by widget subthreads to run code in main widget microthread.
            to:                                 Replyqueue                                              # Used to call 'pass_*' methods in other imps.
          };
        Key_Event_Fn = Key_Event_Fn_Arg -> Void;

        Note_Keyboard_Focus_Fn_Arg
          =
          {
            id:                                 Id,                                                     # Unique id of this widget.
            doc:                                String,                                                 # Text description of this widget for debug/display purposes.
            have_keyboard_focus:                Bool,                                                   # 
            widget_to_guiboss:                  gt::Widget_To_Guiboss,
            theme:                              wt::Widget_Theme,
            do:                                 (Void -> Void) -> Void,                                 # Used by widget subthreads to run code in main widget microthread.
            to:                                 Replyqueue                                              # Used to call 'pass_*' methods in other imps.
          };
        Note_Keyboard_Focus_Fn = Note_Keyboard_Focus_Fn_Arg -> Void;

        Widget_Option
            #
            = MICROTHREAD_NAME                  String                                                  # 
            | ID                                Id                                                      # Unique ID for imp, issued by issue_unique_id::issue_unique_id().
            | DOC                               String                                                  # Documentation string for widget, for debugging purposes.
            #
            | WIDGET_CONTROL_CALLBACK           ( gt::Guiboss_To_Widget -> Void )                       # Gui boss registers this maildrop to get a port to us once we start up.
            | WIDGET_CALLBACK                   (       Null_Or(Widget) -> Void )                       # App      registers this maildrop to get (THE widget_port) from us once we start up, and NULL when we shut down.
            #
            | STARTUP_FN                        Startup_Fn                                              # Args include various values of possible use to gadget code.  No required response.
            | SHUTDOWN_FN                       Shutdown_Fn                                             # Application-specific handler for widget-imp shutdown -- mainly saving state for possible later widget restart.
            #                                                                                           # 
            | INITIALIZE_GADGET_FN              Initialize_Gadget_Fn                                    # Args include various values of possible use to widget code.  No required response.
            | REDRAW_REQUEST_FN                 Redraw_Request_Fn                                       # Guiboss request for widget to redraw itself.          Fn should always respond by calling gadget_to_guiboss.redraw_gadget().
            #
            | MOUSE_CLICK_FN                    Mouse_Click_Fn                                          # Application-specific handler for mousebutton clicks.  Fn should call gadget_to_guiboss.needs_redraw_gadget_request() if widget needs to redraw in response to user input.
            #
            | MOUSE_DRAG_FN                     Mouse_Drag_Fn                                           # Application-specific handler for mouse motions.       Fn should call gadget_to_guiboss.needs_redraw_gadget_request() if widget needs to redraw in response to user input.
            | MOUSE_TRANSIT_FN                  Mouse_Transit_Fn                                        # Application-specific handler for mouse motions.       Fn should call gadget_to_guiboss.needs_redraw_gadget_request() if widget needs to redraw in response to user input.
            #
            | KEY_EVENT_FN                      Key_Event_Fn                                            # Application-specific handler for keyboard input.      Fn should call gadget_to_guiboss.needs_redraw_gadget_request() if widget needs to redraw in response to user input.
            | NOTE_KEYBOARD_FOCUS_FN            Note_Keyboard_Focus_Fn
            #
            | PIXELS_HIGH_MIN                   Int                                                     # Widget is guaranteed this many vertical   pixels (but may get pushed out of sight on bottom of the COL it is in).
            | PIXELS_WIDE_MIN                   Int                                                     # Widget is guaranteed this many horizontal pixels (but may get pushed out of sight on right  of the ROW it is in).
            #
            | PIXELS_HIGH_CUT                   Float                                                   # This value determines our share of pixels remaining after guaranteed pixels are alloted.
            | PIXELS_WIDE_CUT                   Float                                                   # This value determines our share of pixels remaining after guaranteed pixels are alloted.
            #
            | FRAME_INDENT_HINT                 gt::Frame_Indent_Hint                                   # This value determines pixel thickness of frame.  Ignored unless except in FRAME_WIDGET.
            ;

        Widget_Arg        =  List(Widget_Option);                                                       # No required components at present.

    };

end;




Comments and suggestions to: bugs@mythryl.org

PreviousUpNext