Module Dfpanel.pkg

     1//*************************************************************************
     2//*
     3//*  Copyright (c) 1997-2001 Data Access Corporation, Miami Florida,
     4//*  All rights reserved.
     5//*  DataFlex is a registered trademark of Data Access Corporation.
     6//*
     7//************************************************************************/
     8
     9// Dfpanel.Pkg
    10//  09-01-1994 : Created
    11//
    12// Author: John J. Tuohy
    13//
    14// 11/12/94  Added Save_Environment
    15// 01/23/95  Added windows help support
    16// 02/14/95 JJT - Added DFGSINI for 3.01/3.05 dual support of .ini name.
    17//                and section name
    18// 02/21/95 JJT - Added Make_dialog_proportional message so compiler is
    19//                happy
    20//************************************************************************
    21// 3.1 Changes  - Added Make_panel_normal
    22//************************************************************************
    23// 07/23/96 JJT - New Class names
    24// 08/10/96 SWB - Changed class colors
    25// 10/04/96 SWB - Added support for Restored-window position & size
    26// 10/14/97 JJT - Changed add_components to send message to client. Otherwise when
    27//                starting maximized w/ no tool or status bar, the client was 0,0 size
    28// 10/14/97 JJT - added support for saving toolbar and status bar visible status to regsitry
    29//                (now saved as part of normal shutdown)
    30//************************************************************************
    31// VDF8 changes
    32// 10/23/2001 JJT/SWB - Added Application object support, removed workspace and KEY support.
    33//                      Removed internal messages Get Restoredxx (X,Y,CX,CY), Parse_complex, Complex_to_String
    34//                      Removed ghoWorkspace support
    35
    36Use Windows.pkg
    37Use dfcolor.pkg
    38
    39
    40
    41//
    42//  Used when help object makes a request to the object requesting help.
    43//
    44Use HelpSystemConstants.pkg
    45
    46Enumeration_List
    47  DEFINE amTop
    48  DEFINE amBottom
    49  DEFINE amLeft
    50  DEFINE amRight
    51End_Enumeration_List
    52
    53// Use DFGSINI // access to profile strings-----removed for VDF8
    54
    55Use DFAStBar.pkg  // df application status bar
    56Use DFABtBar.pkg  // df application button bar
    57Use DFAClnt.pkg   // df application Client
    58Use DFADlg.pkg    // df application Dialog
    59
    60
    61Register_Function pbPreserveEnvironment Returns Boolean
    62Register_Procedure set phoMainPanel handle hoMain
    63Register_Procedure DoSaveEnvironment Handle hoContainer Boolean bProgram
    64Register_Procedure DoLoadEnvironment Handle hoContainer Boolean bProgram
    65Register_Procedure Set pbVisible Boolean bVisible
    66Register_Function  pbVisible Returns Boolean
    67
    68
    69{ ClassType=Abstract }
    70{ HelpTopic=AppPanel }
    71{ DesignerClass=cDTMDIPanel }
    72{ ComponentType=WinAppClass }
    73{ OverrideProperty=Scope_State InitialValue=True }
    74{ OverrideProperty=Mdi_State InitialValue=True }
    75{ OverrideProperty=Size InitialValue=274,479}
    76{ OverrideProperty=pbSizeToClientArea InitialValue=False }
    77
    78Class AppPanel is a BasicPanel
    79  //
    80  //  Panel defaults. Use windows MDI color
    81  //
    82  //
    83    Procedure Construct_Object
    84        Forward Send Construct_Object
    85
    86        { Category=Behavior }
    87        { PropertyType=Boolean }
    88        Property Integer Auto_Activate_State True
    89
    90        // Support status for toolbar and status bar. For now we support
    91        // 0=Hide, 1=Show,
    92        //
    93        { Visibility=Private }
    94        Property Integer Private.ToolBar_State  1
    95
    96        { Visibility=Private }
    97        Property Integer Private.StatusBar_State  1
    98        
    99        { Visibility=Private }
   100        Property Handle[] phoAutoActivateViews
   101
   102        Set Scope_State to TRUE
   103        Set Mdi_State to TRUE
   104
   105        Set Size to 274 479
   106        Set pbSizeToClientArea  to False
   107    End_Procedure // Construct_Object
   108
   109    { MethodType=Property }
   110    { Category=Behavior }
   111    { PropertyType=Boolean }
   112    { InitialValue=True }
   113    Procedure Set Auto_Arrange_Icons_State Integer bState
   114        Integer hoClient
   115        Get Client_id To hoClient
   116        If (hoClient AND hoClient<>self ) ;
   117           Set Auto_Arrange_Icons_State of hoClient To bState
   118    End_Procedure
   119
   120    { MethodType=Property }
   121    Function Auto_Arrange_Icons_State Returns Integer
   122        Integer hoClient bState
   123        Get Client_id To hoClient
   124        If (hoClient AND hoClient<>self ) ;
   125            Get Auto_Arrange_Icons_State of hoClient To bState
   126        Function_Return bState
   127    End_Function
   128
   129    Procedure Toggle_Auto_Arrange_Icons
   130        Set Auto_Arrange_Icons_State ;
   131                to (NOT(Auto_Arrange_Icons_State(self)))
   132    End_procedure
   133
   134    { MethodType=Property }
   135    { Category=Behavior }
   136    { PropertyType=Boolean }
   137    { InitialValue=True }
   138    Procedure Set Client_Scrollbar_State Integer bState
   139        Integer hoClient
   140        Get Client_id To hoClient
   141        If (hoClient AND hoClient<>self ) ;
   142           Set Client_Scrollbar_State of hoClient To bState
   143    End_Procedure
   144
   145    { MethodType=Property }
   146    Function Client_Scrollbar_State Returns Integer
   147        Integer hoClient bState
   148        Get Client_id To hoClient
   149        If (hoClient AND hoClient<>self ) ;
   150            Get Client_Scrollbar_State of hoClient To bState
   151        Function_Return bState
   152    End_Function
   153
   154    { Visibility=Private }
   155    Procedure Toggle_Client_Scrollbar_State
   156        Set Client_Scrollbar_State ;
   157                to (NOT(Client_Scrollbar_State(self)))
   158    End_procedure
   159
   160    { MethodType=Property }
   161    Function ToolBar_State returns Integer
   162        function_return (private.Toolbar_State(self))
   163    End_function
   164
   165    { MethodType=Property }
   166    { InitialValue=True }
   167    { Category=Behavior }
   168    { PropertyType=Boolean }
   169    { DesignTime=False }
   170    Procedure Set Toolbar_State Integer bState
   171       Integer hoToolBar
   172       Handle hoCommandBars
   173       If (bState<>toolbar_State(Self)) Begin
   174          Set private.toolbar_State to bState
   175
   176          Get phoCommandBars to hoCommandbars
   177          If hoCommandbars Procedure_Return
   178          
   179          If (Window_Handle(Self)) Begin
   180             Get toolBar_ID to hoToolBar
   181             If hoToolBar Send Activate_Component hoToolBar bState (Focus_Mode(hoToolbar))
   182          End
   183       end
   184    End_procedure
   185
   186    Procedure Toggle_Toolbar
   187       Set Toolbar_State to (Not(Toolbar_State(self)))
   188    End_procedure
   189
   190    { MethodType=Property }
   191    Function StatusBar_State returns Integer
   192       Handle hoCommandBars hoStatusBar
   193       Boolean bState
   194       Get phoCommandBars to hoCommandbars
   195       If hoCommandbars Begin
   196          Get Statusbar_ID to hoStatusBar
   197          If hoStatusBar Begin
   198             Get pbVisible of hoStatusBar to bState
   199          End            
   200       End
   201       Else Begin
   202          Get private.Statusbar_state to bState
   203       End
   204       Function_Return bState
   205    End_function
   206
   207    { MethodType=Property }
   208    { InitialValue=True }
   209    { Category=Behavior }
   210    { PropertyType=Boolean }
   211    { DesignTime=False }
   212    Procedure Set Statusbar_State Integer bState
   213       Handle hoStatusBar hoCommandBars
   214       If (bState<>Statusbar_State(self)) Begin
   215          Set private.Statusbar_State to bState
   216          Get Statusbar_ID to hoStatusBar
   217
   218          Get phoCommandBars to hoCommandbars
   219          If hoCommandbars Begin
   220             If hoStatusBar Begin
   221                Set pbVisible of hoStatusBar to bState            
   222             End
   223          End
   224          Else Begin
   225              If (Window_Handle(Self)) Begin
   226                 If hoStatusBar Send Activate_Component hoStatusBar bState  nonfocusable
   227              End
   228          End
   229       End
   230    End_Procedure
   231
   232    Procedure Toggle_Statusbar
   233       Set Statusbar_State to (not(statusbar_State(Self)))
   234    end_procedure
   235
   236    { Visibility=Private }
   237    Procedure AutoSizeLocate
   238    end_procedure
   239
   240    { Visibility=Private }
   241    Procedure Size_Components
   242        Integer iToolBar iStatBar //iClient
   243        Integer iSizeToolBar
   244        Handle hoCommandbars 
   245        
   246        Get phoCommandBars to hoCommandbars
   247        If hoCommandbars Procedure_Return
   248
   249        If not (Window_Handle(self)) procedure_Return
   250
   251        Get ToolBar_id   To iToolBar
   252        Get StatusBar_id To iStatBar
   253        //Get Client_id    To iClient
   254
   255        If (iToolBar And Window_Handle(iToolbar)) Begin
   256            //Send AutoSizeLocate To iToolBar
   257            Get GuiSize of iToolbar to iSizeToolbar
   258            set GUIsize of iToolbar to (hi(iSizeToolbar)) (low(iSizeToolbar)) // forces auto resize - don't change size
   259            //set GUIsize of iToolbar to 28 800 // forces auto resize
   260        End
   261
   262        If (iStatBar and Window_Handle(iStatBar)) Begin
   263            Send AutoSizeLocate To iStatBar
   264        End
   265    End_Procedure
   266
   267    { Visibility=Private }
   268    Procedure Activate_Component Integer Obj Integer st integer focusmode
   269       integer act
   270       If Not Obj Procedure_Return
   271       Get Active_State of Obj to act
   272       If (st AND act=0) Begin
   273          Set Focus_Mode of obj to focusable
   274          Send Add_focus to obj self
   275          Set Focus_Mode of obj to focusmode
   276       End
   277       else if (st=0 and act) ;
   278          Send deactivate to obj
   279    end_procedure
   280
   281    { Visibility=Private }
   282    Procedure Add_Components
   283        Integer hClient
   284        Handle hoCommandbars 
   285        Get phoCommandBars to hoCommandbars
   286        If not hoCommandbars Begin
   287            Get Client_id to hClient
   288            If (hClient and hClient<>Self ) ; // this forces the client to start at a
   289               Set mdi_top_margin of hClient to (mdi_top_margin(hClient)) // proper size when maximized w/ no components.
   290            Send Activate_Component (Toolbar_Id(Self)) ;
   291                                    (Toolbar_State(Self)) nonfocusable
   292            Send Activate_Component (Statusbar_Id(Self)) ;
   293                                    (Statusbar_State(Self)) nonfocusable
   294            Send Size_Components
   295        End
   296    End_procedure
   297
   298    { NoDoc=True }
   299    Procedure Activate Returns Integer
   300        Integer bFail
   301        Forward Get MSG_activate to bFail
   302        //If NOT bFail Send Add_Components
   303        Send Add_Components
   304        Set Main_Window to self
   305        Procedure_Return bFail
   306    End_Procedure // activate
   307
   308    { Visibility=Private }
   309    Procedure Client_Message Integer Msg_Id
   310        integer hoClient
   311        Get Client_id to hoClient
   312        If (hoClient and hoClient <> self) ;
   313            Send Msg_id to hoClient
   314    End_Procedure
   315
   316    { Visibility=Private }
   317    Procedure Arrange_Icons
   318        Send Client_Message Current_Message
   319    End_Procedure
   320
   321    Procedure Cascade_Windows
   322        Send Client_Message Current_Message
   323    End_Procedure
   324
   325    Procedure Tile_Windows_Horizontal
   326        Send Client_Message Current_Message
   327    End_Procedure
   328
   329    Procedure Tile_Windows_Vertical
   330        Send Client_Message Current_Message
   331    End_Procedure
   332
   333    { MethodType=Property Visibility=Private }
   334    Procedure Set GuiSize Integer sizy Integer sizx
   335      Forward Set GUISize to sizy sizx
   336      If BuildingObjectId Procedure_Return
   337      Send Size_Components
   338    end_procedure
   339
   340    //  Returns false to indicate that this is not a DEO. This is used by
   341    //  delegation to figure out if you are within a DEO and should therefore
   342    //  send a DEO message. DEO view clients set this true
   343    //
   344    { Visibility=Private }
   345    Function Is_Function Integer MsgId Integer ObjId Integer DelegateFg Returns Integer
   346      Integer DelMode rVal Id
   347      Move ( If(DelegateFg,self,ObjId) ) to Id
   348      Get Delegation_mode of Id to DelMode
   349      Set Delegation_mode of Id to No_Delegate_or_Error
   350      Get MsgId of ObjId to rVal
   351      Set Delegation_mode of Id to DelMode
   352      Function_Return rVal
   353    End_Function
   354
   355    // In this class this should return an id or nothing (no delegation).
   356    // Note, if no context exists return a 0 or ''.
   357    //
   358   { Visibility=Private }
   359    Function Help_Context Integer Context_Type Returns String
   360      Integer ID
   361      String  rVal
   362
   363      If Context_Type eq HELP_CONTEXT_ID ;
   364             Get Help_ID to rVal
   365      else If Context_Type eq HELP_CONTEXT_KEYWORD ;
   366             Get Help_Keyword to rVal
   367      else If Context_Type eq HELP_CONTEXT_ID_OR_KEY Begin
   368             Get Help_ID to ID
   369             If ID eq 0 Get Help_Keyword to rVal
   370             Move ID to rVal
   371             If rval eq '' Move 0 to rVal
   372      end
   373      else if Context_Type eq HELP_CONTEXT_DATAFILE ;
   374             Move '' to rVal
   375
   376      Function_Return rVal
   377    End_Function // Help_Context
   378
   379    // Get context based on eContext. If no content found, Don't delegate with panels --- end the search (added to 11.1. See help_mx.pkg)
   380    //
   381    { Visibility=Private }
   382    Function HtmlHelpContext Integer eContext String BYREF sContext Returns Integer
   383        integer eContextFound
   384        Get HtmlHelpObjectContext eContext (&sContext) to eContextFound // context for this one object
   385        Function_return eContextFound
   386    end_function
   387
   388
   389    // When verify_exit_appliction is received by default just
   390    // send this message to the Mdi-client Id.
   391    //
   392    { MethodType=Event }
   393    Function Verify_Exit_Application Returns Integer
   394       Integer Id rVal
   395       Get Client_Id to id
   396       If (Id AND Id<>self) ;
   397          Get Verify_Exit_application of Id to rVal
   398       Function_Return Rval
   399    End_Function
   400
   401    // When exit notifiction is received by default just
   402    // send this message to the Mdi-client Id.
   403    //
   404    { MethodType=Event }
   405    Procedure Notify_Exit_Application
   406       Send Client_Message Current_Message
   407    End_Procedure // Notify_Exit_Application
   408
   409    Procedure Minimize_all_Windows
   410       Send Client_Message Current_Message
   411    End_Procedure
   412
   413    Procedure Restore_all_Windows
   414       Send Client_Message Current_Message
   415    End_Procedure
   416
   417    // augmented to  activate if required
   418    //
   419    Procedure End_Construct_Object
   420       Forward Send End_Construct_object
   421       If (Auto_activate_state(self)) Send Activate
   422    End_Procedure // End_Construct_object
   423    
   424    { NoDoc=True }
   425    Procedure Add_Focus Handle hoParent Returns Integer
   426        Integer iError i iViews
   427        Handle[] hoAutoActivateViews
   428        Forward Get msg_Add_Focus hoParent to iError
   429        If (iError=0) Begin
   430            Get phoAutoActivateViews to hoAutoActivateViews
   431            Move (SizeOfArray(hoAutoActivateViews)) to iViews
   432            For i from 0 to (iViews-1)
   433                Send Activate_View of hoAutoActivateViews[i]
   434            Loop
   435        End
   436    End_Procedure
   437    
   438    // adds a view to the array of views to be autoactivated
   439    { Visibility=Private }
   440    
   441    Procedure AddAutoActivateView Handle hoView
   442        Handle[] hoAutoActivateViews
   443        Get phoAutoActivateViews to hoAutoActivateViews
   444        Move hoView to hoAutoActivateViews[SizeOfArray(hoAutoActivateViews)]
   445        Set phoAutoActivateViews to hoAutoActivateViews
   446    End_Procedure
   447    
   448End_Class
   449
   450
   451Use DFCursor.pkg
   452
   453//  Main DEO High level main Panel Class
   454//
   455{ HelpTopic=Panel }
   456Class Panel is a AppPanel
   457
   458    Procedure Construct_Object
   459        String St
   460        integer iVal
   461        dWord dwState
   462        Forward Send Construct_Object
   463        
   464        // defaults to hourglass...end_construct will remove
   465        Send Cursor_wait to (Cursor_Control(self)) // hourglass
   466
   467    End_Procedure // Construct_Object
   468
   469
   470    // This sends the message register_active_view to all child objects.
   471    // It passes the object ID of the object that is requesting this
   472    // information. The flag BCast_Focus determines if this should
   473    // broadcast or broadcast_focus
   474    //
   475    { Visibility=Private }
   476    Procedure Notify_All_Views integer Msg integer obj integer Bcast_Focus
   477       integer clobj
   478       Get Client_ID to clObj
   479       if ClObj eq 0 Move self to ClObj
   480       If BCast_Focus Broadcast_focus send Msg to Clobj obj
   481       Else           Broadcast       send Msg to Clobj obj
   482    End_Procedure // Notify_all_Views
   483
   484    //
   485    // Save any information you wish about this panel.
   486    //
   487    //  Rules for saving:
   488    //  1. only save if SaveEnvironment=TRUE, ON or YES
   489    //  2. Save current size and location to ApplicationSize, ApplicationLocation
   490    //
   491    { Visibility=Private }
   492    Procedure Save_Environment
   493      If ghoApplication Send DoSaveEnvironment of ghoApplication Self True
   494    End_Procedure
   495
   496    // For high level panel support save of environment
   497    //
   498    { MethodType=Event  NoDoc=True }
   499    Procedure Notify_Exit_Application
   500      Send Save_Environment
   501      Forward Send Notify_Exit_Application
   502    End_Procedure
   503
   504    // augmented to remove hourglass
   505    //
   506    Procedure End_Construct_Object
   507       // if application object exists, we need to tell that object that we are the main panel
   508       If ghoApplication ;
   509          set phoMainPanel of ghoApplication to self
   510       Forward Send End_Construct_object
   511       Send Cursor_ready to (Cursor_Control(self)) // restore
   512    End_Procedure // End_Construct_object
   513
   514    { MethodType=Event Visibility=Private }
   515    Procedure Page Integer iState
   516        Forward Send Page iState
   517        If (iState =1) Begin
   518            If ghoApplication Send DoLoadEnvironment of ghoApplication self True
   519        End
   520    End_Procedure
   521
   522End_Class
   523
   524//  Main DEO High level main MDI Client Class
   525//
   526//  Currently there is nothing special about this class but it was
   527//  created because it is logically correct. Extensions may go here in
   528//  the futire
   529{ HelpTopic=ClientArea }
   530Class ClientArea is a AppClientArea
   531End_Class
   532