Module Dd_radmx.pkg

     1//****************************************************************************//
     2//                                                                            //
     3// $File name  : dd_radmx.pkg                                                 //
     4// $File title :                                                              //
     5// Notice      :                                                              //
     6// $System     : Extended Data Sets 3.1                                       //
     7// Created     : 06/11/96 05:15 pm                                            //
     8// $Last Rev   : 06/11/96 05:15 pm                                            //
     9//                                                                            //
    10// $Description                                                               //
    11//                                                                            //
    12//                                                                            //
    13// $Rev History                                                               //
    14// JT 07/30/97 removed Initialize_list (which checked for non-static_state    //
    15//             Non-Status radios really don't make sense.                     //
    16//JT 09/12/96 Added NoPut_State support, Shadow_State set by DD               //
    17//JT 06/11/96 File header created                                             //
    18//                                                                            //
    19//****************************************************************************//
    20
    21//****************************************************************************//
    22// Extended_Deo_Mixin                                                         //
    23// This creates DD mixim methods for radio-entry-form classes. This provides  //
    24// the needed methods to allow radio lists to fill by using the DD (and most  //
    25// often validation tables). This is similar in concept to combo forms.       //
    26//                                                                            //
    27// Important: We assume that this mixin will get mixed at the same level as   //
    28// DD_Deomx support AND that this will get mixed in after DD_Deomx. This      //
    29// contains many methods which replace (not augment) the existing dd_deomx    //
    30// mixin methods and it is assumed that forward sending messages from here    //
    31// forward to the radio-entry-form and not to the dd_deomx mixin level.       //
    32//****************************************************************************//
    33Use VdfBase.pkg
    34
    35Class Extended_Deo_Radio_mixin is a mixin
    36
    37  //************************************************************************//
    38  // Radio_fill_item                                                        //
    39  // Callback procedure. We request that the DD sends this message to this  //
    40  // object for each item in the table. The DD always passes the following  //
    41  // params (we do not use all of them). This message name is passed to the //
    42  // DD in fill_list.                                                       //
    43  //************************************************************************//
    44
    45  { Visibility=Private }
    46  Procedure Radio_Fill_Item integer iItem string sValue string sDescription ;
    47                            integer iFile integer riId
    48     If sDescription eq '' Move sValue to sDescription
    49     Send Add_Radio_item sDescription sValue // first may get altered - we will not use the rowId for now.
    50  End_Procedure
    51
    52
    53
    54  //************************************************************************//
    55  // Fill_List                                                              //
    56  // Fills list by sending file_field_fill_list to its DD and asking it to  //
    57  // send callback messages (radio_fill_item) to this object.               //
    58  //************************************************************************//
    59
    60  { Visibility=Private }
    61  Procedure Fill_List
    62    integer iFile
    63    integer iField
    64    integer iSrvr
    65    integer iNdx
    66    integer iValFile
    67    integer iObj
    68    integer iOldState
    69    integer iOldcdSt
    70
    71    If not (Extended_Deo_State(Self)) Begin
    72       Forward Send Fill_List
    73       Procedure_Return
    74    End
    75
    76    Get Server to iSrvr
    77    Get Data_File  to iFile
    78    Get Data_Field to iField
    79    If (iSrvr AND iFile) Begin
    80       // setting this will keep set select_state from attempting to update
    81       // the DD. We don't want that during list filling.
    82       Get Entry_Refresh_State to iOldState
    83       Set Entry_Refresh_State to True
    84       Get Change_Disabled_State to iOldcdSt
    85       Set Change_Disabled_State to TRUE // for Entry_defaults
    86       Get Item_Field_Property GET_File_Field_Table_Object 0 to iObj
    87       //If iObj get Main_File of iObj to iValFile
    88       // currently we do not use relational_state. Relational validation
    89       // tables is not supported in radio lists (nor do they make sense)
    90       //Set Relational_State to (iFile<>0 AND iValFile=iFile)
    91       Send File_Field_Fill_List to iSrvr iFile iField Self msg_Radio_Fill_Item
    92       Send Entry_Defaults
    93       Set Change_Disabled_State to iOldcdSt
    94       Set Entry_Refresh_State to iOldState
    95    End
    96  End_Procedure
    97
    98
    99  //************************************************************************//
   100  // File_field_Value_Changed                                               //
   101  // This replaces (not augments) the DD_Deomx version of this message. This//
   102  // does not check items - there is only one datafiel/field for this object//
   103  //************************************************************************//
   104
   105  { Visibility=Private }
   106  Procedure File_Field_Value_Changed Integer iFile Integer iField ;
   107             String sValue Integer iChangeDisabled
   108    Integer iData
   109    Integer iOldState
   110    Get Data_File to iData
   111    If iData EQ iFile Begin
   112       Get Data_Field 0 to iData
   113       If iData EQ iField Begin
   114          If iChangeDisabled Begin
   115             Get Change_Disabled_State to iOldState
   116             Set Change_Disabled_State to TRUE
   117             Send Item_Value_Changed 0 sValue
   118             Set Change_Disabled_State to iOldState
   119          End
   120          Else ;
   121             Send Item_Value_Changed 0 sValue
   122        End
   123    End
   124  End_Procedure
   125
   126  //************************************************************************//
   127  // Item_Value_Changed                                                     //
   128  // This replaces (not augments) the DD_Deomx version of this message. This//
   129  // is passed the data value. It finds the appropriate radio description   //
   130  // item and makes it current and sets select_state as needed. It also sets//
   131  // the object's changed_state (the item equivalant of item_changed_state) //
   132  //************************************************************************//
   133
   134  { Visibility=Private }
   135  Procedure Item_Value_Changed Integer iItem String sValue
   136      // convert from data to description and display
   137      Send Display_Description sValue
   138      Forward Set Changed_State to True
   139  End_Procedure
   140
   141  //************************************************************************//
   142  // Entry_Defaults                                                         //
   143  // This replaces (not augments) the dd_deomx version of this. If a value  //
   144  // exists in the DD it is displayed as a default. If there is no value in //
   145  // the DD and the radio is an auto-select list (either auto_select or no_ //
   146  // select) we must set a default item (first item) and notify the DD that //
   147  // there is now a value.                                                  //
   148  //************************************************************************//
   149
   150  { Visibility=Private }
   151  Procedure Entry_Defaults
   152    String  sValue
   153    Integer iData_File
   154    Integer iData_Field
   155    Integer iDSO
   156    integer iOldState
   157    integer iState
   158    integer iMode
   159
   160    If Not (Extended_deo_State(Self)) Begin
   161       Forward Send Entry_Defaults
   162       Procedure_Return
   163    End
   164
   165    Get Server to iDSO
   166    If Not iDSO ;
   167      Procedure_Return
   168
   169    Get Entry_Refresh_State to iOldState
   170    Set Entry_Refresh_State to True
   171
   172    Get Data_File to iData_File
   173    Get Data_Field to iData_Field
   174    If iData_File Begin
   175       Get File_Field_Changed_State of iDSO iData_File iData_Field to iState
   176       // If the DD's field is changed, then we have a default to set
   177       If iState Begin
   178          Get File_Field_Current_Value of iDSO iData_File iData_Field to sValue
   179          Send Item_Value_Changed 0 sValue
   180       End
   181       Else Begin
   182
   183//#IFDEF IS$WINDOWS
   184          Set File_Field_Default_Value of iDSO iData_File iData_Field ;
   185                                       to (Item_Data_Value(Self,0))
   186//#ELSE
   187//          // No default, if we need one we must set one, and notify the DD.
   188//          // Note that we treat no_select as a special case of auto_select.
   189//          // When no_select, we assume the current-item is the choice.
   190//          Get Select_Mode to iMode
   191//          if (iMode=Auto_Select OR iMode=No_select) ;
   192//             Set File_Field_Default_Value of iDSO iData_File iData_Field ;
   193//                                          to (Item_Data_Value(Self,0))
   194//#ENDIF
   195
   196       End
   197    End
   198    Set Entry_Refresh_State to iOldState
   199  End_Procedure
   200
   201
   202  //************************************************************************//
   203  // Set Value                                                              //
   204  // Replaces (not augments) this message in dd_deomx. Set value is only    //
   205  // used to set the values of item's in the radio list. It has no DD       //
   206  // purpose.                                                               //
   207  //************************************************************************//
   208
   209  { MethodType=Property  NoDoc=True }
   210  Procedure Set Value Integer iItem String sValue
   211     Set Local_Value item iItem to sValue
   212  End_procedure
   213
   214
   215  //************************************************************************//
   216  // Set Changed_State                                                      //
   217  // Augmented to set item_field_changed_state in the DD. Normally item_    //
   218  // changed_state does this - in radios, we work at the object level.      //
   219  //************************************************************************//
   220
   221  { MethodType=Property  NoDoc=True }
   222  { DesignTime=False }
   223  { PropertyType=Boolean }
   224  Procedure Set Changed_State Integer iState
   225     If Not (Change_Disabled_State(Self)) Begin
   226        Forward Set Changed_State to iState
   227        If (iState AND Extended_Deo_State(Self) AND ;
   228            (NoPut_State(Self)=0) ) ;
   229               Set Item_Field_Changed_State item 0 to iState
   230     End
   231  End_procedure
   232
   233
   234  //************************************************************************//
   235  // Copy_item_Options                                                      //
   236  // Replaces (not augments) this message in dd_deomx. Sets NoPut_State and //
   237  // in windows sets object_Shadow_state.                                   //
   238  //************************************************************************//
   239
   240  { Visibility=Private }
   241  Procedure Copy_Item_Options Integer iDSO Integer iFile Integer iField ;
   242                              Integer iDEO Integer iItem
   243    Integer iDSO_Opt
   244    Integer iState
   245    Get File_Field_Options of iDSO iFile iField to iDSO_Opt
   246    If (iDSO_Opt iand DD_NOPUT) Begin
   247       Set NoPut_State to True
   248    End
   249
   250//#IFDEF IS$WINDOWS
   251    If (iDSO_Opt iand DD_DISPLAYONLY) Begin
   252       Set Object_Shadow_State to True
   253    End
   254        
   255    // Assign the tooltip according to the DDO's Status_Help string....
   256    Send SetToolTipFromStatusHelp
   257//#ENDIF
   258  End_Procedure
   259
   260
   261  //************************************************************************//
   262  // Display_Description                                                    //
   263  // Augmented to shut off any select_state DD activity.                    //
   264  //************************************************************************//
   265
   266  { Visibility=Private }
   267  Procedure Display_Description String DataVal
   268    integer iOldState
   269    Get Entry_Refresh_State to iOldState
   270    Set Entry_Refresh_State to True
   271    Forward Send Display_Description DataVal
   272    Set Entry_Refresh_State to iOldState
   273  End_Procedure // Display_Description
   274
   275//#IFDEF IS$WINDOWS
   276
   277  { Visibility=Private }
   278  Procedure Notify_Select_State Integer NewItem Integer OldItem
   279    If Not (Extended_Deo_State(Self)) Begin
   280       Forward Send Notify_Select_State NewItem OldItem
   281       Procedure_Return
   282    End
   283
   284    // We only need to update the DSO if the data-set itself is not responsible
   285    // for calling this message. DSOs will only do when their operation_mode is
   286    // non-zero. Also if there is no change, there is no need to notify the DSO
   287    If (Operation_mode eq 0 AND ;
   288        (Entry_Refresh_State(Self)=0) AND ;
   289        OldItem<>NewItem AND ;
   290        Data_File(Self,0) AND ;
   291        (NoPut_State(Self)=0) ) Begin
   292
   293        If NewItem ge 0 ;
   294           Set Item_Field_Current_Value item 0 to ;
   295                 (Item_Data_Value(Self,NewItem)) // indirectly update the value
   296        else ;
   297           Set Item_Field_Current_Value item 0 to '' // indirectly update the value
   298    End
   299    Else ;
   300       Forward Send Notify_Select_State NewItem OldItem
   301  End_Procedure // Set Select_State
   302
   303
   304//#ELSE
   305
   306//  //************************************************************************//
   307//  // Set select_state                                                       //
   308//  // Replaces (not augments) this message in dd_deomx. This is the main     //
   309//  // method which notifies the DD of changes. When a new item is selected   //
   310//  // the value of the data in the DD must change. The DD will then notify   //
   311//  // all DEOs (including this one) of the new data. This, in turn, sets this//
   312//  // objects select_state. So select_state is set indirectly (this procedure//
   313//  // notifies the DD, the DD notifies this object, which sets select_state. //
   314//  // This process only occurs when the DD did not start the process (the    //
   315//  // did).                                                                  //
   316//  //************************************************************************//
   317
   318//  Procedure Set Select_State Integer iItem Integer iState
   319
   320//    If Not (Extended_Deo_State(Self)) Begin
   321//       Forward Set Select_State item iItem to iState
   322//       Procedure_Return
   323//    End
   324
   325//    // We only need to update the DSO if the data-set itself is not responsible
   326//    // for calling this message. DSOs will only do when their operation_mode is
   327//    // non-zero. Also if there is no change, there is no need to notify the DSO
   328//    If (Operation_mode eq 0 AND ;
   329//        (Entry_Refresh_State(Self)=0) AND ;
   330//        Select_State(Self,iItem)<>iState AND ;
   331//        Data_File(Self,0) AND ;
   332//        (NoPut_State(Self)=0) ) Begin
   333
   334//        // DF passes a third state named Toggle_state. If passed to the
   335//        // work to toggle it and proceed on.
   336//        If iState eq TOGGLE_STATE ;
   337//               Move (Not(Select_State(Self,iItem))) to iState
   338//        // Normally, iState will be true - when you change select_states only
   339//        // the new item being selected is notified. It is only set false when
   340//        // you've got single select and an item is being un-selected (nothing
   341//        // is selected).
   342//        If iState ;
   343//           Set Item_Field_Current_Value item 0 to ;
   344//                 (Item_Data_Value(Self,iItem)) // indirectly update the value
   345//        else ;
   346//           Set Item_Field_Current_Value item 0 to '' // indirectly update the value
   347//    End
   348//    Else ;
   349//        Forward Set Select_state item iItem to iState
   350//  End_Procedure // Set Select_State
   351
   352//#ENDIF
   353
   354
   355  //************************************************************************//
   356  // Entry_Display                                                          //
   357  // Replaces (not augments) this message in dd_deomx. The radio version of //
   358  // this does what we need - just set flag so that select_state will not   //
   359  // notify the DD during this process.                                     //
   360  //************************************************************************//
   361
   362  { Visibility=Private }
   363  Procedure Entry_Display Integer iFile Integer iFlag
   364    integer iOldState
   365    Get Entry_Refresh_State to iOldState
   366    Set Entry_Refresh_State to True
   367    Forward send Entry_Display iFile iFlag // do normal entdisplay
   368    Set Entry_Refresh_State to iOldState
   369  end_procedure
   370
   371
   372  //************************************************************************//
   373  // Data_Value                                                             //
   374  // Replaces (not augments) this message in dd_deomx. Returns the data     //
   375  // value of the current "selected" item.                                  //
   376  //************************************************************************//
   377
   378  { MethodType=Property Visibility=Private }
   379  Function Data_Value Integer iItem returns String
   380     Function_Return (Current_Item_Data_Value(Self))
   381  End_Function // Data_Value
   382
   383
   384  //************************************************************************//
   385  // Item_Change                                                            //
   386  // Used for no_select lists. In these cases this is the message we must   //
   387  // use to notify the DD of a changed value.                               //
   388  //************************************************************************//
   389
   390  { MethodType=Event }
   391  Procedure Item_Change Integer iFromItem Integer iToItem returns integer
   392    Integer rval
   393    Forward get MSG_Item_change iFromItem iToItem to Rval
   394    If (Extended_DEO_State(Self) AND ;
   395        Select_Mode(Self)=NO_SELECT) Begin
   396       If (Operation_mode=0 AND Entry_Refresh_State(Self)=0 AND ;
   397           Data_File(Self,0) AND ;
   398           (NoPut_State(Self)=0) ) ;
   399              Set Item_Field_Current_Value item 0 to (Item_Data_Value(Self,Rval)) // indirectly update the value
   400    end
   401    Procedure_Return rVal
   402  End_Procedure // Item_change
   403
   404  //************************************************************************//
   405  // Item_Changed_state                                                     //
   406  // While a list is getting filled this may get called. We must disalbe    //
   407  // this.                                                                  //
   408  //************************************************************************//
   409
   410  { MethodType=Property Visibility=Private }
   411  Procedure Set Item_Changed_State Integer iItem Integer iState
   412    If (iState=0 OR Entry_Refresh_State(Self)=0) ;
   413       Forward Set Item_Changed_State iItem to iState
   414  End_Procedure
   415
   416  // change so that list is initialized first. Also, set extended_deo_state before
   417  // attempting to fill list (it needs that information).
   418  //
   419  { Visibility=Private }
   420  Procedure Attach_Deo_To_Server
   421      Integer iSrvr
   422      Get Server to iSrvr
   423      If iSrvr ;
   424          Set Extended_DEO_State to (Extended_DSO_State(iSrvr))
   425      Send initialize_list
   426      Forward Send Attach_deo_to_Server
   427  End_Procedure
   428
   429  // this replaces normal prompt object. Disables if not a real sellist
   430  // we can't use the standard prompt_object because it looks for checkbox_item_state.
   431  //
   432  { MethodType=Property  NoDoc=True }
   433  Function Prompt_Object Integer iItem Returns Integer
   434    Integer iObj
   435    // this is standard get prompt logic
   436    Forward Get Prompt_Object item iItem to iObj
   437    If (iObj=0 AND Extended_DEO_State(self)) begin
   438        Get Item_Field_Property GET_File_Field_Prompt_Object iItem to iObj
   439        // checks to see if the checkbox is assigned to a validation table prompt. If it
   440        // is suppress it, it provides no useful information
   441        If (iObj=DD_Global_Validation_Prompt_Object) ;
   442           move 0 to iObj
   443    end
   444    Function_Return iObj
   445  End_Function
   446
   447End_Class
   448
   449