PreviousUpNext

15.3.664  src/lib/x-kit/widget/leaf/vertical-int-slider.api

## vertical-int-slider.api
#

# 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
    include package   geometry2d;                                                       # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    #
    package gd  =  gui_displaylist;                                                     # gui_displaylist               is from   src/lib/x-kit/widget/theme/gui-displaylist.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 wi  =  widget_imp;                                                          # widget_imp                    is from   src/lib/x-kit/widget/xkit/theme/widget/default/look/widget-imp.pkg
    package g2d =  geometry2d;                                                          # geometry2d                    is from   src/lib/std/2d/geometry2d.pkg
    package evt =  gui_event_types;                                                     # gui_event_types               is from   src/lib/x-kit/widget/gui/gui-event-types.pkg
    package mtx =  rw_matrix;                                                           # rw_matrix                     is from   src/lib/std/src/rw-matrix.pkg
    package r8  =  rgb8;                                                                # rgb8                          is from   src/lib/x-kit/xclient/src/color/rgb8.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/x-kit/widget/leaf/vertical-int-slider.pkg
    #
    api Vertical_Int_Slider {
        #
        App_To_Vertical_Int_Slider
          =
          { id:                         Id,
            #
            get_active:                 Void -> Bool,
            get_value:                  Void -> Int,
            #
            get_lower_limit:            Void -> Int,
            get_upper_limit:            Void -> Int,
            get_coverage:               Void -> Float,
            #
            get_slider_text:            Void -> Null_Or(String),

            set_slider_text:            Null_Or(String) -> Void,
            #
            set_active_to:              Bool -> Void,
            set_value_to:               Int  -> Void,                                   # Also calls gadget_to_guiboss.needs_redraw_gadget_request(id);
            #
            set_lower_limit_to:         Int   -> Void,
            set_upper_limit_to:         Int   -> Void,
            set_coverage_to:            Float -> Void
          };



        Redraw_Fn_Arg
            =
            REDRAW_FN_ARG
              {
                id:                             Id,                                     # Unique Id for widget.
                doc:                            String,                                 # Human-readable description of this widget, for debug and inspection.
                frame_number:                   Int,                                    # 1,2,3,... Purely for convenience of widget, guiboss-imp makes no use of this.
                frame_indent_hint:              gt::Frame_Indent_Hint,
                site:                           g2d::Box,                               # Window rectangle in which to draw.
                popup_nesting_depth:            Int,                                    # 0 for gadgets on basewindow, 1 for gadgets on popup on basewindow, 2 for gadgets on popup on popup, etc.
                #
                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 execute code in main widget microthread.
                to:                             Replyqueue,                             # Used to call 'pass_*' methods in other imps.
                palette:                        wt::Gadget_Palette,
                #
                default_redraw_fn:              Redraw_Fn,
                #
                lower_limit:                    Int,
                upper_limit:                    Int,
                #
                show_limits:                    Bool,
                show_value:                     Bool,
                #
                slider_value:                   Int,                                    # 
                slider_relief:                  wt::Relief,                             # Is the slider outline a slope, a ridge, or a flat band?
                coverage:                       Float,

                text:                           Null_Or(String),
                fonts:                          List(String),
                font_weight:                    Null_Or(wt::Font_Weight),
                font_size:                      Null_Or(Int),

                no_box:                         Bool,
                margin:                         Int,
                thick:                          Int
              }

        withtype
        Redraw_Fn
          =
          Redraw_Fn_Arg
          ->
          { displaylist:                gd::Gui_Displaylist,
            point_in_gadget:            Null_Or(g2d::Point -> Bool),                    # 
            point_to_value:             g2d::Point -> Int,                              # 
            pixels_high_min:            Int,
            pixels_wide_min:            Int
          }
          ;



        Mouse_Click_Fn_Arg
            =
            MOUSE_CLICK_FN_ARG                                                          # Needs to be a sumtype because of recursive reference in default_mouse_click_fn.
              {
                id:                             Id,                                     # Unique Id for widget.
                doc:                            String,                                 # Human-readable description of this widget, for debug and inspection.
                event:                          gt::Mousebutton_Event,                  # MOUSEBUTTON_PRESS or MOUSEBUTTON_RELEASE.
                button:                         evt::Mousebutton,                       # Which mousebutton was pressed/released.
                point:                          g2d::Point,                             # Where the mouse was.
                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 execute code in main widget microthread.
                to:                             Replyqueue,                             # Used to call 'pass_*' methods in other imps.
                #
                default_mouse_click_fn:         Mouse_Click_Fn,
                #
                lower_limit:                    Int,
                upper_limit:                    Int,
                #
                show_limits:                    Bool,
                show_value:                     Bool,
                #
                slider_value:                   Int,                                    # 
                slider_relief:                  wt::Relief,                             # Is the slider outline a slope, a ridge, or a flat band?
                coverage:                       Float,
                point_to_value:                 g2d::Point -> Int,
                #
                initial_value:                  Int,                                    # Original state of slider.
                note_value:                     Int -> Void,                            # Change state of slider. This takes care of notifying our state-watchers. (Does NOT call needs_redraw_gadget_request.)
                needs_redraw_gadget_request:    Void -> Void                            # Notify guiboss-imp that this slider needs to be redrawn (i.e., sent a redraw_gadget_request()).
              }
        withtype
        Mouse_Click_Fn =  Mouse_Click_Fn_Arg -> Void;



        Mouse_Drag_Fn_Arg
            =
            MOUSE_DRAG_FN_ARG
              {
                id:                             Id,                                     # Unique Id for widget.
                doc:                            String,                                 # Human-readable description of this widget, for debug and inspection.
                event_point:                    g2d::Point,
                start_point:                    g2d::Point,
                last_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.
                phase:                          gt::Drag_Phase, 
                button:                         evt::Mousebutton,
                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 execute code in main widget microthread.
                to:                             Replyqueue,                             # Used to call 'pass_*' methods in other imps.
                #
                default_mouse_drag_fn:          Mouse_Drag_Fn,
                #
                lower_limit:                    Int,
                upper_limit:                    Int,
                #
                show_limits:                    Bool,
                show_value:                     Bool,
                #
                slider_value:                   Int,                                    # 
                slider_relief:                  wt::Relief,                             # Is the slider outline a slope, a ridge, or a flat band?
                coverage:                       Float,
                point_to_value:                 g2d::Point -> Int,
                #
                initial_value:                  Int,                                    # Original state of slider.
                note_value:                     Int -> Void,                            # Change state of slider. This takes care of notifying our state-watchers.  (Does NOT call needs_redraw_gadget_request.)
                needs_redraw_gadget_request:    Void -> Void                            # Notify guiboss-imp that this slider needs to be redrawn (i.e., sent a redraw_gadget_request()).
              }
        withtype
        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.
            =
            MOUSE_TRANSIT_FN_ARG
              {
                id:                             Id,                                     # Unique Id for widget.
                doc:                            String,                                 # Human-readable description of this widget, for debug and inspection.
                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.
                transit:                        gt::Gadget_Transit,                     # Mouse is entering (CAME) or leaving (LEFT) widget, or moving (MOVE) across it.
                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 execute code in main widget microthread.
                to:                             Replyqueue,                             # Used to call 'pass_*' methods in other imps.
                #
                default_mouse_transit_fn:       Mouse_Transit_Fn,
                #
                lower_limit:                    Int,
                upper_limit:                    Int,
                #
                show_limits:                    Bool,
                show_value:                     Bool,
                #
                slider_value:                   Int,                                    # 
                slider_relief:                  wt::Relief,                             # Is the slider outline a slope, a ridge, or a flat band?
                coverage:                       Float,
                point_to_value:                 g2d::Point -> Int,
                #
                initial_value:                  Int,                                    # Original state of slider.
                note_value:                     Int -> Void,                            # Change state of slider. This takes care of notifying our state-watchers. (Does NOT call needs_redraw_gadget_request.)
                needs_redraw_gadget_request:    Void -> Void                            # Notify guiboss-imp that this slider needs to be redrawn (i.e., sent a redraw_gadget_request()).
              }
        withtype
        Mouse_Transit_Fn =  Mouse_Transit_Fn_Arg -> Void;



        Key_Event_Fn_Arg
            =
            KEY_EVENT_FN_ARG
              {
                id:                             Id,                                     # Unique Id for widget.
                doc:                            String,                                 # Human-readable description of this widget, for debug and inspection.
                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 execute code in main widget microthread.
                to:                             Replyqueue,                             # Used to call 'pass_*' methods in other imps.
                #
                default_key_event_fn:           Key_Event_Fn,
                #
                lower_limit:                    Int,
                upper_limit:                    Int,
                #
                show_limits:                    Bool,
                show_value:                     Bool,
                #
                slider_value:                   Int,                                    # 
                slider_relief:                  wt::Relief,                             # Is the slider outline a slope, a ridge, or a flat band?
                coverage:                       Float,
                point_to_value:                 g2d::Point -> Int,
                #
                initial_value:                  Int,                                    # Original state of slider.
                note_value:                     Int -> Void,                            # Change state of slider. This takes care of notifying our state-watchers. (Does NOT call needs_redraw_gadget_request.)
                needs_redraw_gadget_request:    Void -> Void                            # Notify guiboss-imp that this slider needs to be redrawn (i.e., sent a redraw_gadget_request()).
              }
        withtype
        Key_Event_Fn =  Key_Event_Fn_Arg -> Void;



        Option  = PIXELS_SQUARE         Int                                             # ==  [ PIXELS_HIGH_MIN i,  PIXELS_WIDE_MIN i,  PIXELS_HIGH_CUT 0.0,  PIXELS_WIDE_CUT 0.0 ]
                #
                | PIXELS_HIGH_MIN       Int                                             # Give widget at least this many pixels vertically.
                | PIXELS_WIDE_MIN       Int                                             # Give widget at least this many pixels vertically.
                #
                | PIXELS_HIGH_CUT       Float                                           # Give widget this big a share of remaining pixels vertically.    0.0 means to never expand it beyond its minimum size.
                | PIXELS_WIDE_CUT       Float                                           # Give widget this big a share of remaining pixels vertically.  0.0 means to never expand it beyond its minimum size.
                #
                | LOWER_LIMIT           Int                                             # Smallest value which slider value is allowed to assume.   Defaults to 0.
                | UPPER_LIMIT           Int                                             # Largest  value which slider value is allowed to assume.   Defaults to 1000.
                | COVERAGE              Float                                           
                #
                | SHOW_LIMITS           Bool                                            # If TRUE, display limits in decimal on slider widget.      Defaults to TRUE.
                | SHOW_VALUE            Bool                                            # If TRUE, display value  in decimal on slider widget.      Defaults to TRUE.
                #
                | INITIAL_VALUE         Int
                | INITIALLY_ACTIVE      Bool
                #
                | BODY_COLOR                            rgb::Rgb
                | BODY_COLOR_WITH_MOUSEFOCUS            rgb::Rgb
                #
                | ID                    Id
                | DOC                   String
                #
                | RELIEF                wt::Relief                                      # Should slider gutter boundary be drawn flat, raised, sunken, ridged or grooved?
                | MARGIN                Int                                             # How many pixels to inset slider relative to its assigned window site.  Default is 4.
                | THICK                 Int                                             # Thickness of lines (well, polygons) forming slider gutter.  Default is 5.
                | NO_BOX                                                                # Do not draw a box around slider gutter.
                #
                | TEXT                  String                                          # Text to draw inside slider.  Default is "".
                #
                | FONT_SIZE             Int                                             # Show any text in this pointsize.  Default is 12.
                | FONTS                 List(String)                                    # Override theme font:  Font to use for text label, e.g. "-*-courier-bold-r-*-*-20-*-*-*-*-*-*-*".  We'll use the first font in list which is found on X server, else "9x15" (which X guarantees to have).
                #
                | ROMAN                                                                 # Show any text in plain  font from widget-theme.  This is the default.
                | ITALIC                                                                # Show any text in italic font from widget-theme.
                | BOLD                                                                  # Show any text in bold   font from widget-theme.  NB: Text is either bold or italic, not both.
                #
                | REDRAW_FN             Redraw_Fn                                       # Application-specific handler for widget redraw.
                | MOUSE_CLICK_FN        Mouse_Click_Fn                                  # Application-specific handler for mousebutton clicks.
                | MOUSE_DRAG_FN         Mouse_Drag_Fn                                   # Application-specific handler for mouse drags.
                | MOUSE_TRANSIT_FN      Mouse_Transit_Fn                                # Application-specific handler for mouse crossings.
                | KEY_EVENT_FN          Key_Event_Fn                                    # Application-specific handler for keyboard input.
                #
                | INT_OUT               (Int -> Void)                                   # Widget's current state              will be sent to these fns each time state changes.
                | PORTWATCHER           (Null_Or(App_To_Vertical_Int_Slider) -> Void)   # Widget's app port                   will be sent to these fns at widget startup.
                | SITEWATCHER           (Null_Or((Id,g2d::Box)) -> Void)                # Widget's site in window coordinates will be sent to these fns each time it changes.
                ;                                                                       # To help prevent deadlock, watcher fns should be fast and nonblocking, typically just setting a var or entering something into a mailqueue.
                
        with:  List(Option) -> gt::Gp_Widget_Type;                                      # The point of the 'with' name is that GUI coders can write 'vertical_int_slider::with { this => that, foo => bar, ... }.'
    };
end;


## COPYRIGHT (c) 1994 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