Module cStatusPanel.pkg

     1// cStausPanel.pkg
     2
     3// This is an abstract class that can be used to create status panels. The interface at this level
     4// is very simple. You can start, stop, request a cancel and allow the object to paint.
     5//
     6// Interface:
     7//
     8//    Get/Set pbCancel - set true if you want to request a cancel.
     9//    Send Activate - activate the panel
    10//    Send Deactivate - deactivate the panel
    11//    Send ProcessEvents - allows panel to paint in a tight loop
    12//    Send Close_panel - sets pbCancel, indicating that you'd like to cancel the panel.
    13//
    14// Look at cProcessStatusPanel.pkg to see how this is used.  
    15
    16use Windows.pkg
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43Class cStatusPanel is a FloatingPanel
    44
    45    Procedure Construct_Object
    46        Forward Send Construct_object
    47
    48        
    49        Property boolean pbCancel False
    50
    51        Set Extended_Window_Style To WS_EX_DLGMODALFRAME True // kills sysmenu as long as there is no icon
    52        Set Icon to '' // this must be cleared so there will be no icon
    53        Set locate_mode to CENTER_ON_PANEL
    54        Set Border_Style  to Border_Dialog
    55        // should be scoped so it will not try to change the focus if there is no focusable button inside
    56        Set Scope_State to True
    57
    58        On_key KEXIT_APPLICATION Send Close_Panel
    59    end_procedure
    60
    61   // this is private and required. Never send this. 
    62   
    63   Procedure Deactivate_Group
    64       If (Active_State(self)) begin
    65           Send SuspendGUI of Desktop False
    66       end
    67       Forward Send Deactivate_Group
    68   End_procedure
    69
    70    // Send this message to stop the panel
    71    Procedure Deactivate
    72       If (Active_State(self)) begin
    73           Send SuspendGUI of Desktop False
    74       end
    75       Forward Send Deactivate
    76    End_procedure
    77
    78    // Send this message to start the panel
    79    Procedure Activate
    80       If not (Active_State(self)) begin
    81          Set pbCancel to False
    82          Send SuspendGUI of Desktop True
    83       end
    84       Forward send Activate
    85    End_procedure
    86
    87    // This allows the panel to paint when used in a tight loop, which is what status panels are
    88    // used for. Any time you update the panel or wish to check for a cancel, you should call this.
    89    Procedure ProcessEvents
    90       If (Active_State(self)) begin
    91           Send PumpMsgQueue of Desktop
    92       end
    93    End_Procedure
    94
    95    // note close panel does not actually close the panel. It just sets pbCancel to True, informing the
    96    // process using this that it wants to close. It is then up the process close the panel. 
    97    Procedure Close_Panel
    98        set pbCancel to True
    99    End_procedure
   100
   101End_Class