Module Enclient.pkg

     1//************************************************************************
     2//
     3// Confidential Trade Secret.
     4// Copyright 1987-1997 Data Access Corporation, Miami FL, USA
     5// All Rights reserved
     6// DataFlex is a registered trademark of Data Access Corporation.
     7//
     8//************************************************************************/
     9
    10//************************************************************************
    11//     File Name: EnClient.Pkg
    12// Creation Date: January 1, 1991
    13// Modified Date: July 1, 1991
    14//     Author(s): Steven A. Lowe
    15//
    16// This module contains the Entry_Client class definition.
    17//************************************************************************/
    18
    19//************************************************************************
    20// Version: 1.0
    21//  12-01-1992 : Created
    22//
    23// Author: John J. Tuohy
    24//
    25//  1. Adds Stop_UI_State Support
    26//  2. Adds Should_Save Property
    27//  3. Adds Auto_Locate_State Support
    28//  4. Adds movable object support (used to be at view_client0 level)
    29//  5. Added dep_item broadcast support (LS)
    30//
    31//  Class Entry_View_Client0     is an Entry_Client0
    32//
    33//  1. Sets Scope_State, Attach_Parent_State, Ring_State to TRUE
    34//  2. Define string property called view_name (for future enhancements).
    35//  3. add dependant_item support ver 1.1
    36//
    37//  Class Selection_List_CLient0 is an Entry_View_Client0
    38//
    39//  Must be used when selection list's need a client.
    40//  1. Sets Attach_Parent_State to FALSE
    41//  2. If Popup, Sets Move_Value_Out_State of Selection list to TRUE
    42//
    43// Sun  03-28-1993 - modified Selection_list_Client. Activate now sets
    44//                   move_value_out_State if activate succeeded.
    45// 05-09-1993  Add Auto_Locate_State support
    46// 08-15-1993  Took movable client support out of client and moved it into
    47//             the view sub-class. Otherwise an entry_Client0 inside a view
    48//             would have it's own move logic (and could block the view's
    49//             move logic).
    50// 10-07-1993  Add include file with new exit_function procedure.
    51// 03/11/94    add dependent item support
    52// 03/17/94    Add movable item supprt at the client level!!
    53// 03/21/94    (LS) v1.1 Changed order of sends in end_construct_object.
    54//             Added non_dep_item_mixin to entry_client0.
    55// 04/08/94    (LS) v1.1 Added deo delegation (also adds other DEO
    56//             behaviors).
    57// 04/30/94    Changed move_value_out setting in sel-list-client so that this
    58//             property gets set the first time.
    59// 09/02/94    JJT Added should_save to forward get changed_state
    60//                 Added Should_save to  return changed_state
    61//             (LS) undid this mod.
    62//************************************************************************/
    63
    64//************************************************************************/
    65// 12/22/94 JJT Merge Changes
    66//              Merged the 0 class into classes
    67//              Added the DEO request_ messages directly into the
    68//              class along with their should_delegate logic. The
    69//              request_find (and super) now do nothing in clients.
    70//              Activating in entry_client must duplicate and replace
    71//              some code in actionbr.
    72// 05/22/95 JJT Added object_Item_validation to focus support in
    73//              request_clear and request_clear_all (also see deodlgmx.pkg)
    74// 09/04/95 JJT - Code Clean up (removed dead commented code)
    75//************************************************************************/
    76//************************************************************************/
    77// 02/03/95    JJT Changes marked **JJT**(2). Changes in buffer latching
    78//                 and DEO<->DSO connecting. In Views
    79// 02/15/95    JJT Created Auto_Top_View_State and activate logic to
    80//                 support it.
    81// 02/16/95    JJT Created Auto_top_item_State and set it Off in sel-list
    82//                 clients
    83// 03/27/95    JJT Fixed Add_focus to check in-use first. Seed_data_sets
    84//                 had find_by_recnum with wrong params.
    85// 05/30/95    JJT Seed_Data_sets does a request_assign latch.
    86//                 Last_View_Focus also checks that the object is active.
    87//                 Entering_Scope always does a broadcast of refind_records.
    88//************************************************************************/
    89//  11/26/97   JJT 1) added subView_Changed to dbclient class. this just
    90//                 broadcasts the message to its kids (looking for dbtabviews)
    91//                 2) Changed dbView add_focus to handle initializing of DDOs
    92//                 differently. It now send messages on to child objects allowing
    93//                 for sub-views (tabviews) to property initialize.
    94//  7/31/97    JJT Changed seed_data_sets to not send clear to an auto-fill
    95//                 server (else a single grid will init with an empty line)
    96//                 and to not do anything if the srvr has a record and it is not
    97//                 auto-fill (under the assumption that someone went to the
    98//                 work to seed the DSO (this makes server based Sel-lists
    99//                 seed properly.
   100// 04/07/97    JJT Changed Seed_data_sets to send clear to Main DD if no
   101//                 record exists. This should force defaults to show up.
   102// 01/31/97    JJT Moved Connect_DEOs_to_Server from opening_view to add_focus
   103//                 This solves problem where GUI masks and buttons did not occur
   104//                 when opening_view was not forwarded (which you should do
   105//                 anyway). We need to adjust server.pkg to attach deo before
   106//                 display (next rev. too risky for now)
   107// 04/28/96    JJT Renamed Main_Data_Set to Main_DD
   108//************************************************************************/
   109// 2/26/2002  JJT - 8.2 clean up (indirect_file, local, self, etc.)
   110
   111
   112
   113#CHKSUB 1 1 // Verify the UI subsystem.
   114
   115use windows.pkg
   116use NESTING.pkg       //include DEO nesting standard support module
   117use NAVIGATE.pkg      //include DEO navigation standard support module
   118use SERVER.pkg        //include Server support module
   119use VERIFY.pkg        //include Verification support module
   120use ACTIONBR.pkg      //include action-bar support module
   121Use AutoLcMx.pkg   // Auto locate of popup mixin
   122Use Dep_item.pkg   // ver 1.1
   123Use DEODlgMx.pkg   // v1.1 DEO delegation support
   124
   125//
   126//Class: _Entry_Client
   127//
   128//SuperClass: CLIENT
   129//
   130//Description: This class implements a data-entry object grouping agent
   131//
   132class Entry_Client_mixin is a mixin
   133  //
   134  //Operation: CONSTRUCT_OBJECT
   135  //
   136  //Assumption(s): MyImg identifies an image for the client area
   137  //
   138  //Goal(s): define an instance of client with a properties appropriate to
   139  //  this specialization.
   140  //
   141  //Algorithm: augmented to define and initialize properties
   142  //
   143  //Usage: used internally
   144  //
   145  procedure Construct_Object integer myImg
   146    forward send construct_object myImg
   147    set Ring_State to false
   148    { Visibility=Private }
   149    Property integer private.Changed_State 0
   150
   151    // We need this property to fully emulate a DEO
   152    // (Actually, entry_clients should realy support ALL the DEO messages!)
   153    { Category=Data }
   154    { PropertyType=Boolean }
   155    Property Integer Auto_Clear_DEO_State True
   156
   157    send define_nesting      //invoke DEO nesting standard support constructor
   158    send define_navigation   //invoke DEO navigation standard support constructor
   159    send define_server       //invoke Server support constructor
   160    send define_action_bar   //invoke action-bar support constructor
   161    send define_verify       //invoke Verification support constructor
   162    Send define_Auto_Locate
   163
   164    Send define_DEO_Delegate // v1.1
   165    Send Define_Auto_Locate
   166
   167  end_procedure
   168
   169  IMPORT_CLASS_PROTOCOL NESTING_Mixin
   170  IMPORT_CLASS_PROTOCOL NAVIGATE_Mixin
   171  IMPORT_CLASS_PROTOCOL SERVER_Mixin
   172  IMPORT_CLASS_PROTOCOL VERIFY_Mixin
   173  IMPORT_CLASS_PROTOCOL ACTION_BAR_Mixin
   174  IMPORT_CLASS_PROTOCOL Auto_Locate_Mixin
   175  IMPORT_CLASS_PROTOCOL Non_Dependent_Item_Mixin // ver 1.1
   176  IMPORT_CLASS_PROTOCOL Deo_Delegate_Mixin // ver 1.1
   177
   178
   179  //
   180  // created for Server support
   181  //
   182  { Visibility=Private }
   183  procedure Display
   184    broadcast send display
   185  end_procedure
   186
   187  //
   188  // created for Server support
   189  //
   190  { Visibility=Private }
   191  procedure Clear
   192    broadcast send clear
   193  end_procedure
   194
   195  //
   196  // created for Server support
   197  //
   198  { Visibility=Private }
   199  procedure Clear_Set
   200    broadcast send clear_set
   201  end_procedure
   202
   203  //
   204  // created for property support
   205  //
   206  { MethodType=Property }
   207  function Changed_State returns Integer
   208    integer retval
   209    get Private.Changed_State to retval
   210    function_Return retval
   211  end_function
   212
   213  //
   214  // cancelled from Server mixin
   215  //
   216  { MethodType=Property }
   217  { DesignTime=False }
   218  { PropertyType=Boolean }
   219  procedure SET Changed_State Integer newVal
   220  end_procedure
   221
   222  //
   223  // created for EntItem convenience
   224  //
   225  { Visibility=Private }
   226  procedure Entry_Clear integer file#
   227    if (Has_Components_State(self)) ;
   228        broadcast send Entry_Clear file#
   229  end_procedure
   230
   231  //
   232  // created for EntItem convenience
   233  //
   234  { Visibility=Private }
   235  procedure Entry_Clear_All integer file#
   236    if (Has_Components_State(self)) ;
   237        broadcast send Entry_Clear_All file#
   238  end_procedure
   239
   240  //
   241  // created for EntItem convenience
   242  //
   243  { Visibility=Private }
   244  procedure Entry_Display integer file# integer flag
   245    if (Has_Components_State(self)) ;
   246        broadcast send Entry_Display file# flag
   247  end_procedure
   248
   249  //
   250  // created for EntItem convenience
   251  //
   252  { Visibility=Private }
   253  procedure Entry_Update integer file# integer flag
   254    if (Has_Components_State(self)) ;
   255        broadcast send Entry_Update file# flag
   256  end_procedure
   257
   258  procedure End_Construct_Object
   259    send Mark_Components      // nesting
   260    send Define_Access_Keys 0 // action_bar_keys
   261    forward send End_Construct_Object
   262  end_procedure
   263
   264  //************* JJT ************
   265  // Added for deo delegate support
   266
   267  procedure Request_Clear
   268      integer obj# retval foc
   269      if (should_delegate_clear(self)) ;
   270          delegate send request_clear
   271      else begin
   272          get Locate_Server to obj# // locate needed in case this is a DSO
   273          if (should_save(self) AND ;
   274              (Verify_Data_Loss(self) <> 0)) ;
   275            procedure_return
   276
   277          Get Focus of desktop to Foc
   278          get Object_Item_Validation of Foc to retval
   279          set Object_Item_Validation of Foc to false
   280
   281          if obj# ne 0 send clear to obj#
   282          else         send entry_clear 0
   283          if (Auto_Top_Panel_State(self)) send beginning_of_panel
   284          set Object_Item_Validation of Foc to retval
   285      end
   286  end_procedure
   287
   288  procedure Request_Clear_All
   289      integer obj# retval foc
   290      if (should_delegate_clear(self)) ;
   291         delegate send request_clear_all
   292      else begin
   293          get Locate_Server to obj#
   294          if (Should_Save(self) AND ;
   295              (Verify_Data_Loss(self) <> 0)) ;
   296            procedure_return
   297
   298          Get Focus of desktop to Foc
   299          get Object_Item_Validation of Foc to retval
   300          set Object_Item_Validation of Foc to false
   301
   302          if obj# ne 0 send clear_all to obj#
   303          else         send entry_clear_all 0
   304          if (Auto_Top_Panel_State(self)) send beginning_of_panel
   305          set Object_Item_Validation of Foc to retval
   306      end
   307  end_procedure
   308
   309  procedure Request_Delete
   310      integer obj#
   311
   312      if (should_delegate_delete(self)) ;
   313         delegate send request_delete
   314      else begin
   315          indicate err false
   316          get Locate_Server to obj#
   317          if (obj# <> 0 AND can_delete(obj#) <> 0) begin
   318            if (Verify_Delete(self) <> 0) procedure_return
   319            set changed_State to false
   320            if (Deferred_State(self)) ;
   321                send Request_Assign to obj# 0  //0 means main_file of Server
   322            send Request_Delete to obj#
   323            // ignore auto_clear_deo_state in deletes. Always clear deleted record
   324            If (not(err))  send Request_Clear
   325            //[not err] if (Auto_Clear_DEO_State(self)) send Request_Clear
   326          end
   327      end
   328  end_procedure
   329
   330  procedure Request_Find integer mode integer entUpdtFlag
   331      if (should_delegate_find(self)) ;
   332         delegate send request_find mode entUpdtFlag
   333      else begin // for now don't support any default find behavior
   334                 // in clients
   335          Procedure_return
   336      End
   337  end_procedure
   338
   339  procedure Request_Save
   340      integer obj# retval
   341
   342      if (should_delegate_save(self)) ;
   343         delegate send request_save
   344      else begin
   345          get Locate_Server to obj#
   346
   347          if (obj# <> 0 AND not(Read_Only_State(obj#))) begin
   348            indicate err false
   349
   350            if (Should_Save(self)) begin
   351              get Request_Validate of obj# to retval
   352              if retval ne 0 procedure_Return
   353              //
   354              // modification for Verify support
   355              //
   356              if (Verify_Save(self) <> 0) procedure_return
   357              //
   358              // modification for Save support
   359              //
   360              if (Deferred_State(self)) ;
   361                  send Request_Assign to obj# 0  //0 means main_file of server
   362
   363              send Request_Save to obj#
   364            end
   365            //
   366            [not err] if (Auto_Clear_DEO_State(self)) send Request_Clear
   367          end
   368      end
   369  end_procedure
   370
   371  // this allows us to save a record without it clearing regardless of
   372  // the Auto_Clear_DEO_State value
   373  //
   374  Procedure Request_Save_No_Clear
   375    integer oldclr
   376    if (should_delegate_save(self)) ;
   377       delegate send request_save_no_clear
   378    else Begin
   379       Get Auto_Clear_DEO_State to OldClr  // whatever it was
   380       Set Auto_Clear_DEO_State to False   // it is no NO!
   381       send request_save                   // do your magic
   382       Set Auto_Clear_DEO_State to OldClr  // back to whatever it was
   383    End
   384  End_procedure
   385
   386  procedure Request_Superfind integer mode
   387      integer ser# datafile
   388
   389      if (should_delegate_find(self)) ;
   390          delegate send request_superfind mode
   391      else begin
   392          Procedure_return
   393      end
   394  end_procedure
   395
   396  //  Augment to Support AutoLocate.
   397  //  This replaces (not augments) the procedure in actionbr. We need
   398  //  to look into this (activating is very risky to augment activating
   399  //  in mixins).
   400  { MethodType=Event  NoDoc=True }
   401  // as of 15.1 we changed all deactivating/activating signatures to not return values (see windows.pkg / ComboForm / Activating for more)
   402  Procedure Activating // Returns Integer
   403    integer InvokingId RVal
   404    Get Focus of desktop to InvokingId
   405    //
   406    forward get MSG_activating to rVal   //  This is the standard
   407    If rVal Procedure_Return rVal        //  actionbr activating
   408    Send Add_action_bar                  //  logic
   409    If (Auto_Locate_State(self) ) ;
   410       Send Auto_Locate InvokingId
   411  End_Procedure
   412
   413  // add this so that all db clients delegate this message.
   414  // this is used to catch sub-views (tabview). Tab views (sub
   415  // views) will augment this to do something useful
   416  { MethodType=Property Visibility=Private }
   417  Function SubView_Changed returns integer
   418    integer hObj
   419    Broadcast Get SubView_Changed to hObj
   420    Function_return hObj
   421  End_Function
   422
   423  // these are needed to pass these on to possible tabview.
   424  { Visibility=Private }
   425  Function Opening_view_Recursive Returns integer
   426        integer bFail
   427        Broadcast Get Opening_View_Recursive to bFail
   428        Function_Return bFail
   429  End_Function
   430
   431  // these are needed to pass these on to possible tabview.
   432  { Visibility=Private }
   433  Procedure Seed_Data_Sets_Recursive
   434        Broadcast send Seed_Data_Sets_Recursive
   435  End_Procedure
   436
   437
   438
   439end_class
   440
   441
   442//
   443//  Entry_View_Client
   444//
   445//
   446// Alter earlier in allentry.pkg if desired
   447//
   448Define DEFAULT_VIEW_LATCH_STATE         for 1 // **JJT**(2)
   449Define DEFAULT_VIEW_STATIC_SERVER_STATE for 1 // **JJT**(2)
   450Define DEFAULT_DSO_DETACH_MODE          for DETACH_IF_NO_CHANGE // **JJT**(2)
   451
   452class Entry_View_Client_mixin is a mixin
   453  Procedure Construct_Object integer img#
   454    forward send construct_object img#
   455    { Visibility=Private }
   456    Property String View_Name ''  // default name...could be useful
   457    set scope_State to TRUE         // defaults to a Scope
   458    set Attach_Parent_State to TRUE // default...controls parentage better
   459    Set Ring_State to TRUE          // default to Ring...makes sense
   460    Send Define_View_dependent_item   // ver 1.1
   461
   462    // **JJT**(2) New properties
   463    { EnumList="Default_View_Latch_State, Default_View_Static_Server_State, Default_DSO_Detach_Mode" }
   464    { Category=Data }
   465    Property Integer DSO_Detach_Mode          Default_DSO_Detach_Mode
   466    { Category=Data }
   467    { PropertyType=Boolean }
   468    Property Integer DEO_Attach_All_State     False
   469
   470    // **JJT**(2) New properties
   471    // If Main_DD is defined
   472    //     View_latch_state = T : Latch if main-file exists
   473    //     View_latch_state = F : Clear the buffer
   474    { Category=Data }
   475    { PropertyType=Boolean }
   476    Property Integer View_Latch_State         True  // Default_View_Latch_State
   477    { DesignTime=False }
   478    Property Integer Main_DD                  0
   479    // keeps track of main-file record when new view is entered!
   480
   481    // this was public but is no longer user. RowId replaces it.
   482    //Property Integer Initial_Main_record      0 // obsolete...should it be maintained?
   483
   484    { DesignTime=False }
   485    Property RowId priInitialRowId
   486
   487    // **JJT**(2) New properties
   488    // when false activate will attempt to activate the scope_focus
   489    // when true, activate activates first object.
   490    { Category=Behavior }
   491    { PropertyType=Boolean }
   492    Property Integer Auto_Top_View_State      False
   493    // When activate is performed (as opposed to set current_scope) the
   494    // first focusable object is activated. Should the first item of the
   495    // first object become the current_item?
   496    // If Top_View is true and Top_Item is false you get the old dac
   497    // behaviors.
   498    { Category=Behavior }
   499    { PropertyType=Boolean }
   500    Property Integer Auto_Top_Item_State      True
   501
   502    // **JJT**(2)
   503    // When changing views this will keep track of the object that had
   504    // the focus when this view (scope) was exited. This manages nested
   505    // scopes within a view.
   506    { Visibility=Private }
   507    Property Integer private.Last_View_Focus  0
   508    { Visibility=Private }
   509    property integer wasNotinUse_State        false // internal use
   510  End_Procedure
   511
   512  IMPORT_CLASS_PROTOCOL View_Dependent_Item_Mixin  // ver 1.1
   513
   514  //
   515  // Augment exit_application_check. If a change
   516  // is detected activate the changed view. This way the user sees what
   517  // has been changed.
   518  //
   519  Function Exit_Application_Check Returns Integer
   520    Integer rVal Obj
   521
   522    Get Should_Save to Rval // changes in this object???
   523    If rVal eq 0 BroadCast Get Exit_Application_Check to Rval // check w/ kids
   524
   525    If Rval ne 0 Begin  // ok a change exist...activate changed view.
   526       //
   527       // before activating the changed view make sure that we are not
   528       // trying to activate this on top of a modal object. Check the current
   529       // focus and all of its parent record up to (but not including) the
   530       // desktop. If any of these object are modal (have block_mouse_state
   531       // set to true) then do not display the changed view.
   532       //
   533       get Focus of desktop to Obj
   534       While Obj Gt DESKTOP
   535          If (Block_Mouse_State(Obj)) Function_Return rVal // if modal..exit
   536          Get Parent of Obj to Obj
   537       Loop
   538       Send Activate
   539    End
   540    Function_return rVal
   541  End_Function
   542
   543  // augment for dependent_item view support v.1.1
   544  Procedure End_Construct_Object
   545     Forward Send End_Construct_Object
   546     Send Construct_Item_groups // must send after fwd: constr_itm_grps uses
   547          // component_state stuff initialized in superclass' end_constr_obj
   548  End_Procedure // End_Construct_Object
   549
   550  { Visibility=Private }
   551  Function Opening_view_Recursive Returns integer
   552     integer main bFail
   553     Set delegation_mode to delegate_to_parent
   554     Get Main_DD to Main
   555     Set WasNotInUse_State to ( Main AND In_use_State(Main)=0 )
   556     Get Opening_View to bFail
   557     If not bFail Broadcast Get Opening_View_Recursive to bFail
   558     Function_Return bFail
   559  End_Function
   560
   561  { Visibility=Private }
   562  Procedure Seed_Data_Sets_Recursive
   563     integer NotInUse
   564     Set delegation_mode to delegate_to_parent
   565     Get WasNotInUse_State to NotInUse
   566     If NotInUse Send Seed_Data_Sets  // if ok, we've got blank in-use DSO.
   567     Set WasNotInUse_State to False
   568     Broadcast send Seed_Data_Sets_Recursive
   569  End_Procedure
   570
   571
   572  // **JJT**(2) --- Start of changes
   573  //
   574  //  Augmented to send Opening_view. If add_focus fails it sends
   575  //  closing_view to reverse effects of Opening_view
   576  //
   577  { NoDoc=True }
   578  Procedure Add_Focus Handle hoParent Returns Integer
   579     integer rVal Main NotInUse
   580     //Get Main_DD to Main
   581     //Move ( Main AND In_use_State(Main)=0 ) to NotinUse
   582     //Get Opening_View to rVal
   583     Get Opening_View_Recursive to rval
   584     //
   585     If Rval eq 0 Begin
   586        // Connect DEOs and DSOs as required.
   587        Send Connect_DEOs_to_Servers (DEO_Attach_All_State(self))
   588        Forward Get MSG_add_focus hoParent to rVal
   589        //this seems to be overkill here
   590        //If rVal Send Closing_View // if add_focus fails, reverse effects.
   591        //Else Begin
   592          // only seed_data_sets if not in use and we've got a Main_DD
   593          // Else we would proceed with an empty buffer.
   594          //If NotInUse ;
   595           //  Send Seed_Data_Sets  // if ok, we've got blank in-use DSO.
   596          send Seed_Data_Sets_Recursive
   597
   598        //End                      // seed it as requried!
   599     End
   600     Procedure_Return rVal
   601  End_Procedure
   602
   603  // Augmented to Send Closing view
   604  { MethodType=Event  NoDoc=True }
   605  // as of 15.1 we changed all deactivating/activating signatures to not return values (see windows.pkg / ComboForm / Activating for more)
   606  Procedure Deactivating //Returns Integer
   607     Integer rVal
   608     Forward Get MSG_Deactivating to rVal
   609     If Rval eq 0 ;
   610        Send closing_View
   611  End_Procedure
   612
   613  //  Disconnect servers from deos according to rules.
   614  //
   615  { MethodType=Event }
   616  Procedure Closing_View
   617     integer Mode
   618     Get DSO_Detach_Mode to Mode
   619     // If we had a View with no DEOs the DSOs would remain in use. We
   620     // will take the extra step to set all DSOs in-use-states to false.
   621     Send Disconnect_DEOs_from_Servers Mode
   622     // we assume that only DSOs understand Set In_Use_State and that
   623     // no delegation occurs as part of setting this to false.
   624     if Mode eq DETACH_ALWAYS ;
   625        Broadcast recursive Set In_use_State to False
   626  End_Procedure // Closing_View
   627
   628  // use to preload anything into DSOs. By default, if a Main_DD is
   629  // defined, we will attempt to latch on
   630  // the record that was in the buffer when the view was entered!
   631  { MethodType=Event }
   632  Procedure Seed_Data_Sets
   633    integer srvr# File#
   634    integer bFill
   635    rowId   riInitalRowId
   636    boolean bFound
   637    Get Main_DD to srvr#
   638    // If no Main-dd we don't do anything automatically, you are on your
   639    // own to seed the data-sets any way you want.
   640    If Srvr# Begin
   641       Get auto_fill_State of srvr# to bFill
   642       // if not auto-fill and we've got a record, someone went to a lot of
   643       // trouble to set up a record. Don't change it. Normally this would
   644       // occur w/ selection lists (which are not auto-fill) that seed the
   645       // list in advance.
   646       If ( bFill=0 AND HasRecord(srvr#) ) Procedure_Return
   647       Get priInitialRowId to riInitalRowId
   648       If ( not(IsNullRowId(riInitalRowId)) AND View_Latch_State(self) ) Begin
   649          // if initial record and we latch, refind it via DSO
   650          // Find & relate record manually and then perform
   651          // a request_assign. This will not work if the finding file is
   652          // a constrained child file
   653          Get Main_file of Srvr# to File#
   654//          Clear File#
   655//          Set_Field_Value File# 0 to Rec#
   656//          VFind File# 0 eq
   657          Move (FindByRowId(File#,riInitalRowId)) to bFound
   658          If bFound Begin
   659             Relate File#
   660             Send Request_Assign to Srvr# File#
   661          End
   662       End
   663       Else ;                 // if no initial record, do a formal
   664          if not bFill ;
   665             Send Clear to Srvr# // clear
   666             // If the srvr is auto-fill and there was no initial record we
   667             // will chose to do nothing under the assumption that the server
   668             // has already done an auto-fill and its guess is as good as
   669             // anything we could come up with.
   670    End
   671  End_Procedure // Seed_data_sets
   672
   673  //  Needed by view. Find the record number of the requested file.
   674  //  If file = 0 use the main_file of Main_DD (if it exists).
   675  { Visibility=Private }
   676  Function FileRowId Integer iFile Returns rowId
   677    handle hoMain
   678    RowId  riID
   679    // if file not passed use main-file of main data set
   680    If (iFile=0) Begin
   681       Get Main_DD to hoMain
   682       If hoMain begin
   683           get main_file of hoMain to iFile
   684       end
   685    end
   686    If iFile begin
   687        Move (GetRowId(iFile)) to riId
   688    end
   689    Function_Return riId
   690  End_Function
   691
   692//  Function File_Recnum Integer File# Returns Integer
   693//    integer Obj rec#
   694//    // if file not passed use main-file of main data set
   695//    If File# eq 0 Begin
   696//       Get Main_DD to Obj
   697//       If Obj get main_file of Obj to file#
   698//    end
   699//    If File# begin
   700////       Move file# to filenumber
   701////       move 0 to fieldindex
   702////       Move Indirect_file.recnum to Rec#
   703//       Get_Field_Value file# 0 to Rec#
   704//    end
   705//    Function_Return rec#
   706//  End_Function
   707
   708
   709  // We maintain Last_View_Focus to control for nested scopes. A normal
   710  // will have its scope_state true and no scoped children. However, a
   711  // zoom might be scoped. We control this by keeping track of the scope when
   712  // a scope is exited.
   713
   714  { MethodType=Property Visibility=Private }
   715  Procedure Set Last_View_Focus Integer Foc
   716     Set private.Last_View_Focus to Foc
   717  End_Procedure // Set Last_View_Focus
   718
   719  // Returns The last scope in the view to have the focus. Before returning
   720  // the value make sure that the scope object is active, else return 0
   721  { MethodType=Property Visibility=Private }
   722  Function Last_View_Focus Returns integer
   723     integer foc
   724     Get private.Last_View_Focus to Foc
   725     // if not a valid object or this object is not active make it 0
   726     If (Foc<=DESKTOP OR Active_state(self)=0 OR Active_State(Foc)=0) ;
   727        Move 0 to Foc
   728     Function_Return Foc
   729  End_Function
   730
   731  // 1) Take care of any buffer initialization
   732  //
   733  { MethodType=Event }
   734  Function Opening_View Returns Integer
   735     integer main
   736     RowId riId
   737
   738     // if a main DSO exists and it is not in use we must perform
   739     // any required pre-seeding logic.
   740     //Get Main_DD to Main
   741     //If ( Main AND In_use_State(Main)=0 ) Begin
   742     If ( wasNotinUse_State(self))  Begin
   743       // Always clear all file buffers and keep track of the record number
   744       // that was in the main-dso's file-buffer.
   745       // This is used by seed_data_sets to seed as required.
   746       Get FileRowId 0 to riId
   747       Set priInitialRowId to riId
   748       //Set Initial_Main_record to Rec#
   749       Send Prepare_Data_Sets         // allow custom setting
   750       broadcast send clear_main_file // Send refind_records to main
   751     end
   752  End_Function
   753
   754  // only called if Main_DD exists and it is not yet in-use
   755  { MethodType=Event }
   756  Procedure Prepare_Data_Sets
   757  End_Procedure
   758
   759  // added to make the file buffers more reliable
   760  { MethodType=Event  NoDoc=True }
   761  Procedure Entering_Scope Returns integer
   762     integer rVal
   763     Forward Get MSG_entering_scope to rVal
   764     // The refind is probably a feature that should always happen.
   765     // The main-data-set was a way to make this backwards compatable.
   766     // Maybe that made no sense.
   767     //If ( rVal=0 AND Main_DD(self) ) ;
   768     If rVal eq 0 ;
   769        broadcast send refind_DD_records // only refinds in-use DDs.
   770     Procedure_Return rVal
   771  end_procedure
   772
   773  // Augment to keep track of the scope that had the focus when this
   774  // view was exited. Exiting_Scope seems to get called at the right
   775  // times - only when focus is moved to an object outside of view's focus.
   776  { MethodType=Event  NoDoc=True }
   777  Procedure Exiting_Scope Handle hoNewScope
   778    Integer rVal
   779    Forward Get MSG_Exiting_Scope hoNewScope to rVal
   780    If rVal eq 0 set Last_View_Focus to (Current_Scope(self))
   781  End_Procedure
   782
   783  //  Augmented to allow views to take the focus without changing the
   784  //  focus within the object. The property Auto_top_View_State controls
   785  //  this. If true, always return to first object, first item. If false
   786  //  return to current-item of scope focus (when possible).
   787  //
   788  { NoDoc=True }
   789  Procedure Activate Returns Integer
   790     integer rVal Foc
   791     if ( Auto_Top_View_State(self)=0 AND ; // Do we want behavior?
   792          scope_state(self) AND ;           // s/b true.
   793          Active_state(self) ) Begin        // Only if active.
   794              // Last_View_Focus is the last scope to have the focus.
   795              // It should be active (if not the prop is 0).
   796              // If for some reason the focus is 0, do a vanilla activate.
   797              Get Last_View_Focus to Foc
   798              If Foc   Set Current_Scope to Foc
   799              Else     Forward Get Msg_Activate to rVal
   800     End
   801     Else Begin
   802           Forward Get Msg_Activate to rVal
   803           // first Item of first object.
   804           If ( Rval=0 and Auto_Top_Item_State(self) ) ;
   805                Send Beginning_of_Panel
   806     End
   807     Procedure_Return rVal
   808  End_procedure
   809
   810  // Views don't delegate to get this property. It uses system default
   811  { MethodType=Property Visibility=Private }
   812  Function Default_Static_Server_State Returns Integer
   813     Function_Return DEFAULT_VIEW_STATIC_SERVER_STATE
   814  End_Function // Default_Static_Server_State
   815  // **JJT**(2) --- End of changes
   816
   817
   818End_Class
   819
   820//
   821//  Client for Selection Lists.
   822//
   823//  Selection_lists and Pick_lists need to know if they should
   824//  move their values out. With simple sel/pick lists it figures this
   825//  out if the list is a popup object. (POPUP sets the property
   826//  move_value_out_state to TRUE. If the sel\pick list needs to be
   827//  encapulsated by a client the actual list object is no longer a
   828//  popup (the client is). We need this special client to set the
   829//  move_value_out_state of the list. It does this by broadcasting
   830//  this to all objects. This only works if the sel/pick list object is
   831//  a direct child of the client (which it always will be).
   832//
   833//  Also note that this class supports movable objects
   834
   835register_procedure Set Move_Value_Out_State integer State
   836
   837// used to catch old obsolete syntax
   838#COMMAND ECstart R
   839  FORWARD_BEGIN_CONSTRUCT !1 !2
   840  bind_using !2 !3 !4 !5 !6 !7 !8 !9
   841#ENDCOMMAND
   842
   843