20.1 Controls Interface

ORIGIN 'guienv';
LIB_DEF 'guienvcontrols' '../lib';
BODY 'private/controlsbody';
(*
 * COPYRIGHT
 *       Copyright (C) Mjolner Informatics, 1991-96
 *       All rights reserved.
 *)
-- windowLib: Attributes --
control: windowitem
(* a control is a graphical object in the window that the user can
 * use to perform actions. All user interaction with the control
 * that can result in an action should give some kind of visual
 * feedback.
 *)
  (#
     <<SLOT controlLib:Attributes>>;
     open::< (#
          create::< 
            (# 
            do ...
            #);
          
       do ...
       #);
     eventHandler::< 
       (#
          onEnabledChanged::< 
            (# 
            ...
            #);
          
       #);
     close::<  (#  do ... #);
     private:
       @...;
     
  #)
  (* control *)
  ;
scrollbar: control
(* A scrollbar controls the scrolling of a textfield or picture
 * etc.
 *)
  (#
     <<SLOT scrollbarLib:Attributes>>;
     eventhandler::< 
       (#
          thumbMoved: event
          (* is called whenever a user has moved the thumb of
           * THIS(scrollbar)
           *)
            (# amount: @integer; 
            enter amount
            do ...; 
            #);
          onThumbMoved:< thumbMoved;
          pageDown: event
          (* called when the user clicks in the page down area *)
            (#  do ...;  #);
          onPageDown:< pageDown;
          pageUp: event
          (* called when the user clicks in the page up area *)
            (#  do ... #);
          onPageUp:< pageUp;
          buttonDown: event
          (* called when the user clicks at the down button *)
            (#  do ... #);
          onButtonDown:<
           buttonDown;
          buttonUp: event (* called when the user clicks at the up button *)
            (#  do ... #);
          onButtonUp:< buttonUp;
          pageScrollAmountChanged:
           event (* called when the scrollamount is changed *)
            (#  do INNER ;  #);
          onPageScrollAmountChanged:< pageScrollAmountChanged;
          scrollAmountChanged: event
          (* called when the scrollamount is changed *)
            (#  do INNER ;  #);
          onScrollAmountChanged:< scrollAmountChanged;
          maxValueChanged: event (* called when the max value is changed *)
            (#  do INNER ;  #);
          onMaxValueChanged:< maxValueChanged;
          valueChanged: event (* called when the value is changed *)
            (#  do INNER ;  #);
          onValueChanged:< valueChanged;
          onFrameChanged::< 
            (#  do ... #);
          onRefresh::< 
            (# 
            do ...
            #);
          onMouseDown::< 
            (#  do ... #);
          onActivate::< 
            (# 
            do ...
            #);
          onDeactivate::< 
            (#  do ... #);
          
       #);
     vertical:<
     (* Specifies if THIS(scrollbar) is vertical, false is the
      * default value
      *) booleanValue;
     scrollAmount:
     (* scrollAmount is the amount the scrollbars thumb will move,
      * when the user clicks in the up button or in the down button
      *)
       (# value: @integer
       enter
         (# 
         enter value
         do ...
         #)
       exit
         (# 
         do ...
         exit value
         #)
       #);
     pageScrollAmount:
     (* pageScrollAmount is the amount the scrollbars thumb will
      * move, when the user clicks in the page down or page up area
      *)
       (# value: @integer; 
       enter
         (# 
         enter value
         do ...
         #)
       exit
         (# 
         do ...
         exit value
         #)
       #);
     maxValue:
     (* this combines setMaxValue and getMaxValue.  Evaluate the
      * enter part to set the maximum value and evaluate the exit
      * part to get the maximum value
      *)
       (# value: @integer
       enter
         (# 
         enter value
         do ...
         #)
       exit
         (# 
         do ...
         exit value
         #)
       #);
     value:
     (* evaluate the enter part to set the value and evaluate the
      * exit part to the maximum value.  The thumb of the scrollbar
      * is drawn acording to maxValue and the current value. That
      * is, if maxValue is 100 and value is 50, the thumb will be
      * drawn in the middle of the scrollbar
      *)
       (# pos: @integer; 
       enter
         (#  enter pos do ... #)
       exit
         (# 
         do ...
         exit pos
         #)
       #);
     length:
     (* the length is either the height or the width of the frame
      * depending of the orientation
      *)
       (# theLength: @integer; 
       enter
         (# 
         enter theLength
         do ...
         #)
       exit
         (# 
         do ...
         exit theLength
         #)
       #);
     open::< 
       (# create::<  (#  do ... #)
       do ...
       #);
     close::<  (#  do ...;  #);
     private:
       @...;
     
  #)
  (* scrollbar *)
  ;
button: control
(* this is the abstract superpattern for all button-like controls *)
  (#
     <<SLOT buttonLib:Attributes>>;
     eventhandler::< 
       (#
          labelChanged: event
          (* is called whenever the label is changed *)
            (#  do INNER ;  #);
          onLabelChanged:< labelChanged;
          styleChanged: event (* is called whenever the style is changed *)
            (# do INNER #);
          onStyleChanged:< styleChanged;
          onFrameChanged::< 
            (#  do ... #);
          onRefresh::< 
            (# 
            do ...
            #);
          onMouseDown::< 
            (#  do ... #);
          
       #);
     label:
     (* the label is the text displayed in THIS(button).  The event
      * labelChanged is called, when the label is changed
      *)
       (# theLabel: ^text; 
       enter
         (#  enter theLabel[] do ... #)
       exit
         (#  do ... exit theLabel[] #)
       #);
     style: (* the text style used for drawing the label  *)
       (# theStyle: ^textStyle
       enter
         (#  enter theStyle[] do ... #)
       exit
         (#  do ... exit theStyle[] #)
       #);
     foregroundColor:
       (# c: @color
       enter c
       do ...
       #);
     open::< 
       (#
          create::< 
            (# 
            do ...
            #)
       do ...
       #);
     close::< 
       (# 
       do ...
       #);
     private: @...;
     
  #)
  (* button *)
  ;
pushButton: button
(* this is a button like the OK and Cancel buttons in dialogs *)
  (#
     <<SLOT pushButtonLib:Attributes>>;
     automaticTarget::< trueObject;
     open::< 
       (#
          create::< 
            (# 
            do ...
            #)
       do ...
       #);
     close::< 
       (# 
       do ...
       #);
     eventHandler::< 
       (#
          onMouseDown::<  (#  ... #);
          onRefresh::<  (#  ... #);
          onHiliteChanged::< 
            (# 
            ...
            #);
          
       #);
     private: @...;
     
  #)
  (* pushButton *)
  ;
staticText: button
(* normally a staticText is used to label editText fields *)
  (#
     <<SLOT staticTextLib:Attributes>>;
     eventhandler::< 
       (#
          onRefresh::< 
            (# 
            do ...
            #);
          
       #);
     open::< 
       (# create::<  (#  do ... #)
       do ...
       #);
     close::<  (#  do ... #);
     private:
       @...;
     
  #)
  (* staticText *)
  ;
iconButton: button
(* an icon has a label, which is drawn centered just below the
 * image of the icon
 *)
  (#
     <<SLOT iconButtonLib:Attributes>>;
     eventhandler::< 
       (#
          showLabelChanged: event
          (* called when showLabel is changed *) (# do INNER #);
          onShowLabelChanged:< showLabelChanged;
          iconChanged: event (* Called when the icon is changed *)
            (# do INNER #);
          onIconChanged:< iconChanged;
          onRefresh::< 
            (#  do ... #);
          onHiliteChanged::< 
            (# 
            do ...
            #);
          onMouseDown::<  (#  ... #);
          
       #);
     showLabel:
     (* if true, the label is shown centered under the image of the
      * Icon
      *)
       (# doShow: @boolean
       enter
         (# 
         enter doShow
         do ...
         #)
       exit
         (# 
         do ...
         exit doShow
         #)
       #);
     icon:
       (# theIcon: ^pixmap; 
       enter
         (# 
         enter theIcon[]
         do ...
         #)
       exit
         (# 
         do ...; 
         exit theIcon[]
         #)
       #);
     open::< 
       (#
          create::< 
            (# 
            do ...
            #)
       do ...
       #);
     close::< 
       (# 
       do ...
       #);
     private: @...;
     
  #)
  (* iconButton *)
  ;
optionButton: button
(* a optionButton has a menu, which pops up, when the user clicks
 * at the button. A normal way to use a optionButton is to set the
 * label of the button to the current selected item in the menu
 *)
  (#
     <<SLOT optionButtonLib:Attributes>>;
     eventhandler::< 
       (#
          currentItemChanged: event
          (* called when currentItem is changed *) (# do INNER #);
          onCurrentItemChanged:< currentItemChanged;
          popUpMenuChanged: event (* called when popUpMenu is changed *)
            (# do INNER #);
          onPopUpMenuChanged:< popUpMenuChanged;
          onLabelChanged::< 
            (#  do ... #);
          onStyleChanged::<
            (#  do ... #);
          onRefresh:: 
            (# 
            ...
            #);
          
       #);
     currentItem:
     (* the current item is the number of the item, which name is
      * currently shown in the popup box.  You can get a reference
      * to that item by calling: currentItem ->
      * theMenu.getItemByNumber -> theItem[];
      *)
       (# itemNo: @integer
       enter
         (# 
         enter itemNo
         do ...
         #)
       exit
         (# 
         do ...
         exit itemNo
         #)
       #);
     popupMenu:
     (* evaluate the enter part to set the menu that pops up in
      * THIS(optionButton). And evaluate the exit part to get the
      * menu
      *)
       (# popupMenu: ^menu; 
       enter
         (# 
         enter popupMenu[]
         do ...
         #)
       exit
         (# 
         do ...
         exit PopupMenu[]
         #)
       #);
     open::< 
       (#
          create::<  (#  do ... #)
       do ...
       #);
     close::< 
       (# 
       do ...
       #);
     private: @...;
     
  #)
  (* optionButton *)
  ;
toggleButton: button
(* this is the abstract superpattern for all buttons that toggle
 * between two states (on/off buttons)
 *)
  (#
     <<SLOT toggleButtonLib:Attributes>>;
     eventhandler::< 
       (#
          stateChanged: event
          (* this event is called whenever the state of
           * THIS(toggleButton) is changed
           *) (# do INNER #);
          onStateChanged:< stateChanged;
          onMouseUp::<  (#  ... #);
          
       #);
     state:
       (# theState: @boolean; 
       enter
         (# 
         enter theState
         do ...
         #)
       exit
         (# 
         do ...
         exit theState
         #)
       #);
     open::< 
       (#
          create::< 
            (# 
            do ...
            #)
       do ...
       #);
     close::< 
       (# 
       do ...
       #);
     private: @...;
     
  #)
  (* toggleButton *)
  ;
radioButton: toggleButton
(* a radioButton is mostly used in a radiobutton cluster, where
 * only one radioButton is set at a time. A radioButton is thus
 * useful to let the user choose among different alternatives
 *)
  (#
     <<SLOT radioButtonLib:Attributes>>;
     open::< 
       (#
          create::< 
            (# 
            do ...
            #)
       do ...
       #);
     close::< 
       (# 
       do ...
       #);
     private: @...;
     
  #)
  (* radioButton *)
  ;
checkBox: toggleButton
(* this is useful for setting options in dialogs *)
  (#
     <<SLOT checkBoxLib:Attributes>>;
     automaticTarget::< trueObject;
     open::< 
       (#
          create::< 
            (# 
            do ...
            #);
          
       do ...
       #);
     close::< 
       (# 
       do ...
       #);
     private: @...;
     
  #)
  (* checkBox *)
  ;
editText: control
(* this is a simple version of textField. Only one textStyle is
 * allowed.  The purpose of this control is to build dialogs
 *)
  (#
     <<SLOT editTextLib:Attributes>>;
     automaticTarget::< trueObject;
     style:
     (* an editText can only have one textStyle.  Evaluate the
      * enter part to set the textStyle.  Evaluate the exit part to
      * get the textStyle
      *)
       (# txStyle: ^textStyle
       enter
         (# 
         enter txStyle[]
         do ...
         #)
       exit
         (# 
         do ...
         exit txStyle[]
         #)
       #);
     contents:
     (* the contents of an editText is text.  Evaluate the enter
      * part to set the contents, and evaluate the exit part to get
      * the contents
      *)
       (# str: ^text
       enter
         (#  enter str[] do ... #)
       exit
         (#  do ... exit str[] #)
       #);
     eventhandler::< 
       (#
          onFrameChanged::< 
            (#  do ... #);
          onKeyDown::< 
            (# 
            do ...
            #);
          onMouseDown::< 
            (#  do ... #);
          onRefresh::< 
            (# 
            do ...
            #);
          onEnableTarget::< 
            (#  do ... #);
          onDisableTarget::< 
            (# 
            do ...
            #);
          
       #);
     open::<
     (* the textStyle of THIS(editText) is initially set to the
      * system's textStyle
      *) 
       (# create::<  (#  do ... #); 
       do ...
       #);
     close::<  (#  do ... #);
     private:
       @...;
     
  #)
  (* editText *)
  ;
defaultButton:
(* the defaultButton in the window recieves a mouseUp event when
 * the user presses the return-key
 *)
  (# theButton: ^button
  enter
    (#  enter theButton[] do ... #)
  exit
    (# 
    do ...
    exit theButton[]
    #)
  #)


20.1 Controls Interface
© 1994-2004 Mjølner Informatics
[Modified: Wednesday January 23rd 2002 at 11:29]