home *** CD-ROM | disk | FTP | other *** search
- //************************************************************************
- //
- // Copyright 1987-1992 Data Access Corporation, Miami FL, USA
- // All Rights reserved
- // DataFlex is a registered trademark of Data Access Corporation.
- //
- //
- // $Source: /u3/source.30/product/pkg/RCS/list.pkg,v $
- // $Revision: 1.1 $
- // $State: Exp $
- // $Author: james $
- // $Date: 1992/09/08 14:43:07 $
- // $Locker: $
- //
- // $Log: list.pkg,v $
- //Revision 1.1 1992/09/08 14:43:07 james
- //Initial revision
- //
- //Revision 1.9 92/06/06 01:57:36 lee
- //added register_procedure move_value_out
- //
- //Revision 1.8 92/05/29 14:06:13 lee
- //removed end_construct_* messages from mixins; now, classes that use the mixin
- //send the message that used to be sent by the end_construct_* message (for
- //efficiency).
- //
- //Revision 1.7 92/05/14 15:53:34 unknown
- //Updated Copyright slug - SWM.
- //
- //Revision 1.6 92/04/01 00:33:32 lee
- //removed navstart and liststart (unused), renamed bind_main_file and bind_index
- //in datalist to bind_list_main_file and bind_list_index to avoid conflict with
- //commands used by data_set, moved bind_static from sellist to datalist as it
- //only sets properties defined in datalist (not sellist).
- //
- //Revision 1.5 92/03/29 18:45:01 lee
- //added MSG_END_CONSTRUCT_OBJECT, moved ENDMAC macro stuff into END_CONSTRUCT-
- //OBJECT procedures (in .pkgs). moved Flag_ITems to list.pkg after generalizing
- //it based on PROTOTYPE_OBJECT instead of Whether or not it is a table-oriented
- //object. Moved define_access_keys mechanism completely into actionbr.pkg.
- //fixed two typos: import_class_protocol used !# instead of !3, and register-
- //procedure used !1 instead of !2.
- //
- //Revision 1.4 92/03/09 19:03:16 james
- //Added #CHKSUB directive to insure source
- //only compiled with correct revision of
- //compiler.
- //
- //Revision 1.3 92/02/12 17:46:53 steve-l
- //Bind_Target corrected - was skipping arg !2 on recursion
- //
- //Revision 1.2 91/11/08 09:23:28 steve-l
- //it
- //
- //************************************************************************/
-
- //************************************************************************
- // File Name: List.Pkg
- // Creation Date: January 1, 1991
- // Modified Date: Feb 12, 1992
- // Author(s): Steven A. Lowe
- //
- // This module defines the properties and operations required to support
- // list-selection, collected in the abstract class List_Mixin.
- //
- // This file should be USEd prior to and IMPORTed within the scope of the
- // class definition by any user-interface (esp. data-entry) class which
- // must support the data-entry object standards.
- //
- // This file is used by PICKLIST.PKG and SELLIST.PKG.
- //************************************************************************/
-
- #CHKSUB 1 1 // Verify the UI subsystem.
-
- use ui
-
- register_procedure move_value_out
-
- class list_mixin is a message
-
- //
- // Description
- //
- // This procedure defines the accelerator keys and properties required
- // to support the standard list-selection options.
- //
- // Assumptions/Preconditions
- //
- // This procedure should only be invoked from within the Construct_Object
- // procedure of a class.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // Enumeration_Counter is used to scan selected items.
- //
- // Export_Item_State determines if the value of the selected item in a
- // single-select or auto-select list should be placed into the current
- // item of the object which 'invoked' the list (i.e. the object which
- // had the focus when this object was activated - see Invoking_Object_ID).
- //
- // Invoking_Object_ID is the object id of the object which had the focus
- // when this object was activated.
- //
- // Original_Selection is the item# (if batch) or record number (if virtual)
- // of the item which was selected when the list was activated.
- //
- // Radio_State determines if the items in this list are radio-buttons.
- //
- // Target_Field identifies the field (in the Target_File), if any, which
- // should receive the value of the currently selected item during a save
- // operation (i.e. when the Entry_Update message is received during a
- // save operation). This only applies to single-select or auto-select
- // lists, not multi-select or no-select lists.
- //
- // Target_File identifies the file, if any, which has a field that should
- // receive the value of the currently selected item during a save operation
- // (see Target_Field).
- //
- procedure define_list
- set select_mode to SINGLE_SELECT
- set search_mode to INCREMENTAL
- on_key kCancel SEND CANCEL PRIVATE
- on_key kEnter SEND OK PRIVATE
- on_key kSpace SEND Toggle_Select PRIVATE
- Property integer Enumeration_Counter PUBLIC 0
- Property integer Export_Item_State PUBLIC 0
- Property integer Invoking_Object_ID PUBLIC 0
- Property integer Original_Selection PUBLIC 0
- Property integer Radio_State PUBLIC 0
- Property integer Target_Field PUBLIC 0
- Property integer Target_File PUBLIC 0
- end_procedure
-
-
- //
- // Description
- //
- // This procedure records the identity of the object which has the focus
- // prior to the normal activation of this object (sets Invoking_Object_ID
- // if activation succeeds). This procedure returns a non-zero value if
- // the activation failed.
- //
- // Assumptions/Preconditions
- //
- // This object (or one of its ancestor classes) understands the Activating
- // message.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // None.
- //
- procedure activating returns integer
- local integer pScope item# dirt
- local string val
- get focus of desktop to pscope
- forward get MSG_activating to dirt
- if dirt ne 0 procedure_return dirt
- if (pscope <> 0 AND pscope <> DESKTOP) ;
- set Invoking_Object_ID to pScope
- end_procedure
-
-
- //
- // Description
- //
- // This procedure resets Block_Mouse_State and Scope_State for this object
- // after a successful deactivation if this object is a pop-up object.
- // This procedure returns a non-zero value if the deactivation failed.
- //
- // Assumptions/Preconditions
- //
- // This object (or one of its ancestor classes) understands the
- // Deactivating message, and has the (boolean) properties Popup_State and
- // Block_Mouse_State.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // Reverses the side-effects of the PopUp procedure (see below).
- //
- procedure deactivating returns integer
- local integer dirt
- forward get MSG_deactivating to dirt
- if dirt ne 0 procedure_return dirt
- if (Popup_State(current_object)) begin
- set Block_Mouse_State to false
- set Scope_State to FALSE
- end
- end_procedure
-
-
- //
- // Description
- //
- // This procedure sets the Block_Mouse_State and Scope_State properties
- // of this object to TRUE prior to the normal pop-up activation operation,
- // if and only if the PopUp_State of this object is TRUE. This is done to
- // ensure that pop-up list objects are scoped (to prevent the entry- and
- // exit-messages of items from being executed) and that the mouse is
- // prevented from clicking anywhere outside of this list object.
- //
- // Assumptions/Preconditions
- //
- // This object (or one of its ancestor classes) understands the
- // PopUp message, and has the (boolean) properties Popup_State and
- // Block_Mouse_State.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // The Deactivating procedure reverses the side-effects of this procedure.
- //
- procedure popup
- if (Popup_State(current_object)) begin
- set Block_Mouse_state to true
- set scope_state to true
- end
- forward send popup
- end_procedure
-
-
- //
- // Description
- //
- // This procedure inserts a new item into the list before the specified
- // item#, using the specified message id (msg#) and value.
- //
- // It ensures that the Entry_State of the new item is FALSE, and that
- // the Checkbox_Item_State of the new item is TRUE if this object's
- // Radio_State is TRUE.
- //
- // Assumptions/Preconditions
- //
- // msg# should be a valid message id or 0.
- // item# should be a valid item index (between 0 and Item_Count-1).
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // After successful execution, the item index of the new item is the same
- // as the originally specified item#.
- //
- procedure insert_item integer msg# string value integer item#
- forward send insert_item msg# value item#
- set entry_state item item# to false
- if (Radio_State(current_object)) ;
- set Checkbox_Item_State item item# to true
- end_procedure
-
-
- //
- // Description
- //
- // This procedure adds a new item at the end of the list, using the
- // specified message id (msg#) and value.
- //
- // It ensures that the Entry_State of the new item is FALSE, and that
- // the Checkbox_Item_State of the new item is TRUE if this object's
- // Radio_State is TRUE.
- //
- // Assumptions/Preconditions
- //
- // msg# should be a valid message id or 0.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // After successful execution, the item index of the new item is
- // Item_Count-1.
- //
- procedure add_item integer msg# string value
- local integer item#
- forward send add_item msg# value
- calc (item_count(current_object) - 1) to item#
- set entry_state item item# to false
- if (Radio_State(current_object)) ;
- set Checkbox_Item_State item item# to true
- end_procedure
-
-
- //
- // Description
- //
- // This procedure accepts the selected item(s) in the list, and surrenders
- // the focus.
- //
- // The incremental-search index is reset.
- //
- // The value of the current item may be exported to the current item of the
- // invoking object, and this object deactivated, if this object is a pop-up,
- // or the focus may be given to the next object in the rotation order.
- //
- // Assumptions/Preconditions
- //
- // This object (or one or its ancestor classes) must understand the
- // Move_Value_Out message as a method of exporting a value, the
- // Request_Cancel message as a method of deactivating this object, and
- // the Next message as a method of rotating to the next focusable object.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // Sent by kENTER.
- //
- procedure OK returns integer
- local integer selMode
- set search_mode to (search_mode(current_object)) //reset incr srch index
- if (popup_state(current_object)) begin
- get select_mode to selMode
- set select_state item CURRENT to true
- if ((SelMode = SINGLE_SELECT OR SelMode = AUTO_SELECT) AND ;
- Select_Count(current_object) > 0) send move_value_out
- else set Enumeration_Counter to 0 //multi-select or none selected
- send request_cancel
- end
- else send NEXT
- end_procedure
-
- //
- // Description
- //
- // This procedure toggles the select_state of the current item unless the
- // select-mode of this object is no_select, in which case this procedure
- // mimics the pressing of the space-bar to generate a space character for
- // incremental search.
- //
- // Assumptions/Preconditions
- //
- // This object must understand the Key message as a method of character
- // input, and must also understand the Select_Toggling message as a method
- // of altering the select_state of an item.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // Sent by kSpace.
- //
- procedure toggle_select
- if (select_mode(current_object) = NO_SELECT) send key kSpace
- else send select_toggling CURRENT TOGGLE_STATE
- end_procedure
-
- procedure Flag_Items
- local integer count maxx radState obj#
- move (Prototype_Object(current_object)) to obj#
- calc (Item_Count(obj#) - 1) to maxx
- get Radio_State to radState
- for count from 0 to maxx
- set Entry_State of obj# item count to false
- if radState ne 0 set Checkbox_Item_State of obj# item count to true
- loop
- end_procedure
- end_class
-
-
- //
- // Description
- //
- // This macro processes the argument to the FOR option of the listStart
- // macro, if any.
- //
- // Target_File and Target_Field are set according to the argument.
- //
- // Assumptions/Preconditions
- //
- // The argument to the FOR option (if there is a FOR option in the
- // command line arguments) must be a file.field identifier.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // None.
- //
- #COMMAND Bind_Target
- #IF (!0>1)
- #IFSAME !1 FOR
- #PUSH !u
- #SET U$ !2 //get file#
- set Target_File to |CI!u
- #SET U$ %!2 //get field#
- set Target_Field to |CI!u
- #POP U$
- #ELSE
- Bind_Target !2 !3 !4 !5 !6 !7 !8 !9
- #ENDIF
- #ENDIF
- #ENDCOMMAND
-
-
- //
- // Description
- //
- // This macro processes the RADIO option of the listStart macro.
- //
- // Radio_State is set to TRUE, and Select_Mode is set to auto-select
- // if the RADIO option appears in the command line arguments.
- //
- // Assumptions/Preconditions
- //
- // None.
- //
- // Exceptions
- //
- // None.
- //
- // Notes
- //
- // None.
- //
- #COMMAND Bind_Radio
- #IF (!0>0)
- #IFSAME !1 RADIO
- set Radio_State to true
- set select_mode to AUTO_SELECT
- #ELSE
- Bind_Radio !2 !3 !4 !5 !6 !7 !8 !9
- #ENDIF
- #ENDIF
- #ENDCOMMAND
-