home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / dataflex / actionbr.pkg < prev    next >
Encoding:
Text File  |  1993-08-10  |  8.6 KB  |  309 lines

  1. //************************************************************************
  2. //
  3. // Copyright 1987-1992 Data Access Corporation, Miami FL, USA
  4. // All Rights reserved
  5. // DataFlex is a registered trademark of Data Access Corporation.
  6. //
  7. //
  8. //     $Source: /u3/source.30/product/pkg/RCS/actionbr.pkg,v $
  9. //     $Revision: 1.1 $
  10. //     $State: Exp $
  11. //     $Author: james $
  12. //     $Date: 1992/09/08 14:43:02 $
  13. //     $Locker:  $
  14. //
  15. //     $Log: actionbr.pkg,v $
  16. //Revision 1.1  1992/09/08  14:43:02  james
  17. //Initial revision
  18. //
  19. //Revision 1.6  92/06/19  16:31:34  james
  20. //Last minute changes made to correct problem with 
  21. //SWITCH_BACK
  22. //
  23. //Revision 1.5  92/05/29  14:04:32  lee
  24. //removed end_construct_* messages from mixins; now, classes that use the mixin
  25. //send the message that used to be sent by the end_construct_* message (for
  26. //efficiency).
  27. //
  28. //Revision 1.4  92/05/14  16:47:52  SWM
  29. //Updated Copyright slug.
  30. //
  31. //Revision 1.3  92/03/29  18:44:33  lee
  32. //added MSG_END_CONSTRUCT_OBJECT, moved ENDMAC macro stuff into END_CONSTRUCT-
  33. //OBJECT procedures (in .pkgs). moved Flag_ITems to list.pkg after generalizing
  34. //it based on PROTOTYPE_OBJECT instead of Whether or not it is a table-oriented
  35. //object. Moved define_access_keys mechanism completely into actionbr.pkg.
  36. //fixed two typos: import_class_protocol used !# instead of !3, and register-
  37. //procedure used !1 instead of !2.
  38. //
  39. //Revision 1.2  92/03/09  19:00:25  james
  40. //Added #CHKSUB directive to insure source
  41. //only compiled with correct revision of 
  42. //compiler.
  43. //
  44. //Revision 1.1  91/10/23  10:19:34  elsa
  45. //Initial revision
  46. //
  47. //************************************************************************/
  48.  
  49. //************************************************************************
  50. //     File Name: ActionBr.Pkg
  51. // Creation Date: January 1, 1991
  52. // Modified Date: July 12, 1991
  53. //     Author(s): Steven A. Lowe
  54. //
  55. // This module defines the support routines and properties required by
  56. // the action-bar interface, collected in the abstract class
  57. // Action_Bar_Mixin class.
  58. //
  59. // This file should be USEd prior to and IMPORTed within the scope of the
  60. // class definition by any user-interface (esp. data-entry) class which
  61. // must support the data-entry object standards.
  62. //************************************************************************/
  63.  
  64. #CHKSUB 1 1 // Verify the UI subsystem.
  65.  
  66. use ui
  67.  
  68. class Action_Bar_Mixin is a message
  69.  
  70.   //
  71.   // Description
  72.   //
  73.   //   This procedure defines the Action_Bar_ID property, which is required
  74.   //   to hold the object id of the action-bar associated with an object.
  75.   //
  76.   // Assumptions/Preconditions
  77.   //
  78.   //   This procedure may only be invoked from the Construct_Object
  79.   //   procedure of a class definition.
  80.   //
  81.   // Exceptions
  82.   //
  83.   //   None.
  84.   //
  85.   // Notes
  86.   //
  87.   //   The property defined by this procedure is private; a function to access
  88.   //   it and a procedure to set it are defined below.
  89.   //
  90.   procedure define_action_bar
  91.     Property integer private.Action_Bar_ID PUBLIC 0
  92.   end_procedure
  93.  
  94.  
  95.   //
  96.   // Description
  97.   //
  98.   //   This function returns the object identifier for the action-bar
  99.   //   associated with this object, if any.
  100.   //
  101.   // Assumptions/Preconditions
  102.   //
  103.   //   None.
  104.   //
  105.   // Exceptions
  106.   //
  107.   //   If no action-bar is associated with this object, 0 is returned.
  108.   //
  109.   // Notes
  110.   //
  111.   //   If this object does not have its own action-bar, it will return
  112.   //   the object id of its parent's action-bar, if any.
  113.   //
  114.   function Action_Bar_ID returns integer
  115.     local integer retval
  116.     get private.Action_Bar_ID to retval
  117.     if (retval = 0 AND Component_State(current_object)) ;
  118.         delegate get Action_Bar_ID to retval
  119.     function_return retval
  120.   end_function
  121.  
  122.  
  123.   //
  124.   // Description
  125.   //
  126.   //   This procedure associates an action-bar with this object.
  127.   //
  128.   // Assumptions/Preconditions
  129.   //
  130.   //   newVal is a valid object id, or 0.
  131.   //
  132.   // Exceptions
  133.   //
  134.   //   None.
  135.   //
  136.   // Notes
  137.   //
  138.   //   This procedure sets the private property defined by define_action_bar.
  139.   //
  140.   procedure SET Action_Bar_ID integer newVal
  141.     set private.Action_Bar_ID to newVal
  142.   end_procedure
  143.  
  144.  
  145.   //
  146.   // Description
  147.   //
  148.   //   This procedure ensures that this object's action-bar, if any, is
  149.   //   in the focus list (on the screen) whenever this object is activated.
  150.   //   This procedure returns a non-zero value if the normal activating failed.
  151.   //
  152.   // Assumptions/Preconditions
  153.   //
  154.   //   None.
  155.   //
  156.   // Exceptions
  157.   //
  158.   //   If this object's normal Activating fails, no other action is taken.
  159.   //
  160.   // Notes
  161.   //
  162.   //   None.
  163.   //
  164.   procedure activating returns integer
  165.     local integer dirt actbar#
  166.     forward get MSG_activating to dirt
  167.     if dirt eq 0 begin
  168.       get Action_Bar_ID to actbar#
  169.       if (actbar# <> 0 AND Active_State(actbar#) = 0) ;
  170.           send Add_Focus to actbar# current_object
  171.     end
  172.     procedure_return dirt
  173.   end_procedure
  174.  
  175.  
  176.   //
  177.   // Description
  178.   //
  179.   //   This procedure ensures that this object's action-bar, if any, does
  180.   //   not have the focus as the result of a group activation.
  181.   //
  182.   // Assumptions/Preconditions
  183.   //
  184.   //   None.
  185.   //
  186.   // Exceptions
  187.   //
  188.   //   If this object is a RINGed client with no focusable children, the
  189.   //   action-bar, if any, will have the focus on exit from this procedure,
  190.   //   as there would be no other objects to receive the focus.
  191.   //
  192.   // Notes
  193.   //
  194.   //   None.
  195.   //
  196.   procedure activate_group
  197.     local integer actbar#
  198.     forward send activate_group
  199.     get Action_Bar_ID to actbar#
  200.     if actbar# ne 0 move (object_id(actbar#)) to actbar#
  201.     if (actbar# <> 0 AND focus(desktop) = actbar# AND ;
  202.         next_object_id(actbar#,2) <> actbar#) send Switch to actbar#
  203.   end_procedure
  204.  
  205.  
  206.   //
  207.   // Description
  208.   //
  209.   //   This procedure ensures that this object's action-bar, if any, does not
  210.   //   have the focus after this object is placed on the screen and given the
  211.   //   focus.
  212.   //
  213.   // Assumptions/Preconditions
  214.   //
  215.   //   None.
  216.   //
  217.   // Exceptions
  218.   //
  219.   //   If this object is a RINGed client with no focusable children, the
  220.   //   action-bar, if any, will have the focus on exit from this procedure,
  221.   //   as there would be no other objects to receive the focus.
  222.   //
  223.   // Notes
  224.   //
  225.   //   None.
  226.   //
  227.   procedure Activate returns integer
  228.     local integer actbar# ret_val
  229.     forward get msg_activate to ret_val
  230.     get Action_Bar_ID to actbar#
  231.     if actbar# ne 0 move (object_id(actbar#)) to actbar#
  232.     if (actbar# <> 0 AND focus(desktop) = actbar# AND ;
  233.         next_object_id(actbar#,2) <> actbar#) send Switch to actbar#
  234.     function_return ret_val
  235.   end_procedure
  236.  
  237.  
  238.   //
  239.   // Description
  240.   //
  241.   //   This procedure defines accelerator keys for this object as dictated
  242.   //   by its action-bar, if any, and also causes this object's children to
  243.   //   define accelerator keys in the same manner.
  244.   //
  245.   // Assumptions/Preconditions
  246.   //
  247.   //   act# must be a valid object id or 0.
  248.   //
  249.   // Exceptions
  250.   //
  251.   //   None.
  252.   //
  253.   // Notes
  254.   //
  255.   //   This procedure relies on the global procedure assign_action_bar_keys.
  256.   //
  257.   register_procedure assign_action_bar_keys integer act#
  258.   procedure define_access_keys integer act#
  259.     local integer actp#
  260.     get private.action_bar_id to actp#
  261.     if (popup_state(current_object) and actp# = 0) procedure_return
  262.     if ((act# = 0 and actp# <> 0) or (actp# = 0 and act# <> 0)) begin
  263.       if act# eq 0 move actp# to act#
  264.       send assign_action_bar_keys act#
  265.       if (child_count(current_object) > 0) ;
  266.           broadcast send define_access_keys act#
  267.     end
  268.   end_procedure
  269. end_class
  270.  
  271.  
  272. //
  273. // Description
  274. //
  275. //   This macro finds the object-creation parameter ACTION_BAR in the
  276. //   command line, and, if found, associates the argument of ACTION_BAR
  277. //   with this object.
  278. //
  279. // Assumptions/Preconditions
  280. //
  281. //   If ACTION_BAR exists in the command-line, the argument after it must
  282. //   be either a valid object name, a valid object id, or an object-access
  283. //   expression.
  284. //
  285. // Exceptions
  286. //
  287. //   None.
  288. //
  289. // Notes
  290. //
  291. //   If the ACTION_BAR parameter does not appear in the command line, no
  292. //   action is taken.
  293. //
  294. #COMMAND bind_action_bar
  295.   #IF (!0>0)
  296.     #IFSAME !1 ACTION_BAR
  297.       #IFDEF !2
  298.         set action_bar_id to !2
  299.       #ELSE
  300.         set action_bar_id to !2.OBJ
  301.       #ENDIF
  302.     #ELSE
  303.       bind_action_bar !2 !3 !4 !5 !6 !7 !8 !9
  304.     #ENDIF
  305.   #ENDIF
  306. #ENDCOMMAND
  307.  
  308.                                                                                                                        
  309.