PreviousUpNext

15.4.1568  src/lib/x-kit/widget/theme/widget/widget-theme.pkg

## widget-theme.pkg
#
# For the big picture see the imp dataflow diagrams in
#
#     src/lib/x-kit/xclient/src/window/xclient-ximps.pkg
#
# At the moment I think this is evolving from being an imp to
# being a simple static datastructure, but we'll see. -- 2014-07-22 CrT

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



###            "I believe OS/2 is destined to be
###             the most important operating system,
###             and possibly program, of all times."
###
###                          -- Bill Gates, 1988 



stipulate
    include package   threadkit;                                                                # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
#   package psi =  widgetspace_imp;                                                             # widgetspace_imp               is from   src/lib/x-kit/widget/space/widget/widgetspace-imp.pkg
    #
    package g2d =  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 c64 =  rgb;                         # Colors with Float64 red-green-blue values.    # rgb                           is from   src/lib/x-kit/xclient/src/color/rgb.pkg
    package c8  =  rgb8;                        # Colors with Unt8    red-green-blue values.    # rgb8                          is from   src/lib/x-kit/xclient/src/color/rgb8.pkg

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

    Once(X) = Oneshot_Maildrop(X);
herein

    # This port is implemented in:
    #
    #     src/lib/x-kit/widget/xkit/theme/widget/default/widget-theme-imp.pkg
    #
    package widget_theme {
        #
        Gadget_Palette                                                                          # This is the palette of colors that will actually be used by the gadget's drawing logic.
          =                                                                                     # We'll probably want more colors here by and by, but this seems like a good initial set.
          { text_color:                         c64::Rgb,                                       # Text       color for gadget, e.g. the text  inside  the outline of a button. This will typically be grayed-out when the button is inactive.
            surround_color:                     c64::Rgb,                                       # Surround   color for gadget, e.g. the color outside the outline of a button. This shouldn't change with gadget state because it is shared by all gadgets in the gui; it would look weird for one to have a different surround.
            body_color:                         c64::Rgb,                                       # Background color for gadget, e.g. the color inside  the outline of a button.
            #
            upperleft_bevel_color:              c64::Rgb,                                       # These two are used to give a "3-D" raised/lowered appearance to the button. They will 
            lowerright_bevel_color:             c64::Rgb                                        # be reversed when the button is ON vs OFF, to make it visually look pushed vs popped.
          };                                                                                    # NB: Standard lighting for scientific illustration etc is from over user's left shoulder.

        Relief = FLAT | RAISED | SUNKEN | GROOVE | RIDGE;

        Font_Weight = ROMAN_FONT
                    | ITALIC_FONT
                    | BOLD_FONT
                    ;

        fun relief_to_string FLAT       => "FLAT";
            relief_to_string RAISED     => "RAISED";
            relief_to_string SUNKEN     => "SUNKEN";
            relief_to_string GROOVE     => "GROOVE";
            relief_to_string RIDGE      => "RIDGE";
        end;

        Pictureframe
          =
          { box:                        g2d::Box,                                               # 'box' gives the outer contour for the picture-frame.
            thick:                      Int,                                                    # Inner contour is this many pixels inside of outer contour.
            relief:                     Relief
          };

        Rounded_Pictureframe                                                                    # A frame with rounded corners.
          =
          { box:                        g2d::Box,
            thick:                      Int,
            corner_wide:                Int,
            corner_high:                Int,
            relief:                     Relief
          };

        Polygon3d
          =
          { points:                     List( g2d::Point ),
            thick:                      Int,
            relief:                     Relief
          };

        Gadget_Mode                                                                             # We use this mostly to control how a widget draws itself.
          =                                                                                     # To avoid a package cycle, duplicated here from    src/lib/x-kit/widget/gui/guiboss-types.pkg
          {                                                                                     # We probably should find/make another home for this def. XXX SUCKO FIXME
            is_active:                          Bool,                                           # An inactive gadget is passed no user input. Inactive widgets are typically drawn "grayed-out".
            has_mouse_focus:                    Bool,                                           # A widget which has the mouse cursor on it may want to draw itself brigher or such.
            has_keyboard_focus:                 Bool                                            # A widget which has the keyboard focus will often      draw a black outline around its text-entry rectangle.
          };

        Widget_Theme
          =
          { do_something:                       Int -> Void,


            #######################################
            # Space and widget factory calls:

#           widgetspace:                        ps::Widgetspace_Arg -> psi::Widgetspace_Egg,



            #######################################
            # Widget-customization stuff.
            #
            # The colorset here is motivated by the problem of drawing
            # a button on a surround, delimited by a bevel, for example
            #
            #             surround_color
            #
            #        SSSSSSSSSSSSSSSSSSSSSSSS
            #        SssssssssssssssssssssssSs
            #        Ss                     Ss
            #        Ss      body_color     Ss
            #        Ss                     Ss
            #        Ss                     Ss
            #        SSSSSSSSSSSSSSSSSSSSSSSSs
            #         ssssssssssssssssssssssSs
            # 
            #             surround_color
            #
            # 'S' == sunny_bevel_color
            # 's' == shady_bevel_color
            #
            # For convenience and to provide consistency across a GUI:
            #
            #  o  We derive the other colors from base_color, so that
            #     a user can change the overall colorscheme just by
            #     changing base_color.
            #
            #  o  We adjust surround_color and body_color based on
            #     popup nesting depth, to visually distinguish them.
            #
            #  o  We provide precomputed color variations for body_color
            #     based on button on/off state and whether the button
            #     currently has the mouse focus.  The palette.body_color
            #     passed to a widget redraw function is automatically
            #     selected appropriately from these four variations,
            #     making it easy for widgets to highlight on rollover.                  # For an example see default_redraw_widget in   src/lib/x-kit/widget/leaf/button.pkg

            base_color:                         Ref(        c64::Rgb ),                 # By default light gray.  This is the master color from which the other colors are derived.
            surround_color:                     Ref( Int -> c64::Rgb ),                 # By default base_color lightened and warmed in proportion to popup_nesting_depth.
                                                                                        # The Int args here are all popup_nesting_depth -- as a visual aid we draw 'closer' popups in slightly warmer and lighter colors, since the eye interprets darker, bluer objects as more distant.
            body_color:                         Ref( Int -> c64::Rgb ),                 # By default                            *theme.surround_color;
            body_color_with_mousefocus:         Ref( Int -> c64::Rgb ),                 # By default  *theme.slight_whitening   *theme.surround_color;
            body_color_when_on:                 Ref( Int -> c64::Rgb ),                 # By default  *theme.medium_whitening   *theme.surround_color;
            body_color_when_on_with_mousefocus: Ref( Int -> c64::Rgb ),                 # By default  *theme.lavish_whitening   *theme.surround_color;

            text_color:                         Ref( Int -> c64::Rgb ),                 # By default black if body_color() is light, else white.
            textfield_color:                    Ref( Int -> c64::Rgb ),                 # By default slightly offwhite (0.9).

            sunny_bevel_color:                  Ref( Int -> c64::Rgb ),                 # By default a slightly-darkened  shade of surround_color.      Used for drawing "3-D" bevels around things.
            shady_bevel_color:                  Ref( Int -> c64::Rgb ),                 # By default a     much-darkened  shade of surround_color.      Used for drawing "3-D" bevels around things.

            current_gadget_colors:      Ref(  { gadget_is_on:           Bool,           # TRUE iff the pushbutton is in 'ON' state. Not very meaningful for non-button gadgets.
                                                gadget_mode:            Gadget_Mode,    # Tells us whether the gadget is inactive, if the mouse is over it etc.
                                                popup_nesting_depth:    Int,            # 0 for gadgets on basewindow, 1 for gadgets on popup on basewindow, 2 for gadgets on popup on popup, etc.
                                                
                                                #
                                                body_color:                             Null_Or( c64::Rgb ),
                                                body_color_when_on:                     Null_Or( c64::Rgb ),
                                                body_color_with_mousefocus:             Null_Or( c64::Rgb ),
                                                body_color_when_on_with_mousefocus:     Null_Or( c64::Rgb )
                                              }
                                              ->
                                              Gadget_Palette
                                           ),

            pictureframe:               Ref( Gadget_Palette                                     # Displaylist for a picture-frame of 'width' in 'relief'. Interior is untouched.
                                                -> Pictureframe
                                                -> gd::Gui_Displaylist
                                           ),
            filled_pictureframe:        Ref( Gadget_Palette                                     # Same as pictureframe except we fill the interior of the box in body_color.
                                                -> Pictureframe
                                                -> gd::Gui_Displaylist
                                           ),

            rounded_pictureframe:       Ref( Gadget_Palette                                     # Displaylist for a frame with rounded corners.
                                                -> Rounded_Pictureframe
                                                -> gd::Gui_Displaylist
                                           ),
            polygon3d:                  Ref( Gadget_Palette                                     # Displaylist for an arbitrary polygon with pseudo-3d shading.
                                                -> Polygon3d
                                                -> gd::Gui_Displaylist
                                           ),

            color_by_depth:             Ref((c64::Rgb,Int) -> c64::Rgb ),                       # The Int is popup_nesting_depth.

            slight_blackening:          Ref( c64::Rgb -> c64::Rgb ),
            medium_blackening:          Ref( c64::Rgb -> c64::Rgb ),
            lavish_blackening:          Ref( c64::Rgb -> c64::Rgb ),

            slight_graying:             Ref( c64::Rgb -> c64::Rgb ),
            medium_graying:             Ref( c64::Rgb -> c64::Rgb ),
            lavish_graying:             Ref( c64::Rgb -> c64::Rgb ),

            slight_whitening:           Ref( c64::Rgb -> c64::Rgb ),
            medium_whitening:           Ref( c64::Rgb -> c64::Rgb ),
            lavish_whitening:           Ref( c64::Rgb -> c64::Rgb ),



#               make_button_displaylist:        Ref ((Gadget_Mode, Bool) -> Displaylist)        # Bool is on/off state of button,  shown by interchanging roles of light_edge_color and dark_edge_color.


            #######################################
            # font stuff:

            default_font_size:          Ref( Int ),
            #
            roman_font_spex:            Ref( String ),                                          # Something like "-adobe-times-medium-r-normal--*-%d-*-*-p-*-iso8859-1"
            italic_font_spex:           Ref( String ),                                          # Something like "-adobe-times-medium-i-normal--*-%d-*-*-p-*-iso8859-1"
            bold_font_spex:             Ref( String ),                                          # Something like "-adobe-times-bold-r-normal--*-%d-*-*-p-*-iso8859-1"

            get_roman_fontname:         Ref (Int -> String),
            get_italic_fontname:        Ref (Int -> String),
            get_bold_fontname:          Ref (Int -> String),

            get_roman_font:             Ref (Int -> evt::Font),
            get_italic_font:            Ref (Int -> evt::Font),
            get_bold_font:              Ref (Int -> evt::Font),


            #######################################
            # initialization stuff:

            guiboss_to_hostwindow:      Ref( Null_Or(gtg::Guiboss_To_Hostwindow) )              # This is set by guiboss-imp.pkg while responding to client_to_guiboss.make_hostwindow().

            #######################################
            # Misc:


          };
    };                                                                                          # package widget_theme;
end;




Comments and suggestions to: bugs@mythryl.org

PreviousUpNext