Module Dd_cmbmx.pkg
1//****************************************************************************//
2// //
3// $File name : dd_Cmbmx.pkg //
4// $File title : //
5// Notice : //
6// $System : Extended Data Sets 3.1 //
7// Created : 03/28/96 04:48 pm //
8// $Last Rev : 03/28/96 04:48 pm41 //
9// //
10// $Description //
11// //
12// //
13// $Rev History //
14//JT 07/30/97 Added Allow_Undefined_State support for no edit combos. This //
15// forces the user to pick a choice instead of using the default //
16//JT 04/07/97 Added Entry_Defaults to set a DD value if entry_state=F and //
17// there is no current DD value. Otherwise the value in the DEO //
18// does not match the value in the DD buffer. Only required when //
19// entry_state is false. //
20//JT 09/10/96 Added Data_Value message which splits data and descr. //
21//JT 08/07/96 Combo_Item_Changed is now sets the DD value. This message is //
22// now called by cbn_selchange everytime. Combos no longer //
23// externally get or set value. //
24//JT 07/18/96 Create copy_mask_items to do nothing. Combos do not understand //
25// masking right now. //
26//JT 07/03/96 Augmented Command to notify the DD when a combo change is made //
27// When the passes param is CBN_SELCHANGE the value of the item //
28// may get changed. If value is changed we will notify the DD //
29//JT 04/25/96 Item_Field_Value changed to Item_Field_Current_Value. //
30//JT 28-03-96 File header created //
31// //
32//****************************************************************************//
33
34//****************************************************************************//
35// This creates mixin methods for combo entry from classes. It provides a wide//
36// range of fetatures when used with xdata-sets. It used lists provided with //
37// the DSO and automatically loads them. It can display either the data or a //
38// description (allowing seperation of database and display data). This works //
39// with all types of lists including code lists (the DSO handles this). //
40//****************************************************************************//
41
42Use VdfBase.pkg
43
44// Combo selection-list for static data-file lookup.
45//
46//
47Class Extended_Deo_dfCombo_mixin is a Mixin
48 { Visibility=Private }
49 Procedure ComboFillItem integer iItem string sValue string sDescription ;
50 integer iFile RowId riId
51 If sDescription eq '' Move sValue to sDescription
52 Send Combo_Add_Item sDescription sValue // first may get altered
53 Set RowIdNumber iItem to riId
54 End_Procedure
55
56// Procedure Combo_Fill_Item integer iItem string sValue string sDescription ;
57// integer iFile integer iRec
58// If sDescription eq '' Move sValue to sDescription
59// Send Combo_Add_Item sDescription sValue // first may get altered
60// Set Record_Number Item iItem to iRec
61// End_Procedure
62
63
64 // Fills the list by loading the entire defined data-file
65 //
66 { Visibility=Private }
67 Procedure Combo_Fill_List
68 integer iFile
69 integer iField
70 integer iSrvr
71 integer iNdx
72 integer iValFile
73 integer iObj
74
75 If not (Extended_Deo_State(Self)) Begin
76 Forward Send Combo_Fill_List
77 Procedure_Return
78 End
79
80 Get Server to iSrvr
81 Get Data_File to iFile
82 Get Data_Field to iField
83 If (iSrvr AND iFIle) Begin
84 Get Item_Field_Property GET_File_Field_Table_Object 0 to iObj
85 If iObj get Main_File of iObj to iValFile
86 Set Relational_State to (iFile<>0 AND iValFile=iFile)
87// Send File_Field_Fill_List to iSrvr iFile iField Self msg_Combo_Fill_Item
88 Send File_Field_Fill_List to iSrvr iFile iField Self msg_ComboFillItem
89 If (iObj AND Entry_State(Self,0)=0 AND ;
90 (Allow_Blank_State(iObj) OR Allow_Undefined_state(Self))) ;
91 Send Combo_Add_Blank_Item DD_BLANK_CODE_DESCRIPTION
92 End
93 Else ;
94 Send Combo_Fill_List_Local
95 End_Procedure
96
97 { Visibility=Private }
98 Procedure Combo_Add_Blank_Item String Blank_Desc
99 Send ComboFillItem (Combo_Item_Count(Self)) '' Blank_Desc 0 (NullRowId())
100// Send Combo_Fill_Item (Combo_Item_Count(Self)) '' Blank_Desc 0 0
101 End_Procedure
102
103 { MethodType=Property Visibility=Private }
104 Procedure Set Item_Field_Current_Value Integer iItem String sValue
105 // Convert from description to data
106 //showln "set item field " iitem ' ' svalue
107 Get Description_to_data sValue to sValue
108 If sValue ne CB_INVALID_VALUE ;
109 Forward Set Item_Field_Current_Value item iItem to sValue
110 End_Procedure // Set Item_Field_Current_Value
111
112 { Visibility=Private }
113 Procedure Item_Value_Changed Integer iItem String sValue
114 // convert from data to description
115 Get Data_to_Description sValue to sValue
116 If sValue ne CB_INVALID_VALUE ;
117 Forward Send Item_Value_Changed iItem sValue
118 End_Procedure
119
120
121 { Nodoc=True }
122 Procedure Activate returns integer
123 integer iRVal
124 integer iObj
125 String sValue
126 Forward Get MSG_Activate to iRVal
127
128 If not (Extended_Deo_State(Self)) ;
129 Procedure_Return iRVal
130
131 if not iRVal Begin
132 Get Item_Field_Property GET_File_Field_Table_Object 0 to iObj
133 If (iObj AND (Static_State(iObj)=0 OR Table_Loaded_State(iObj)=0)) Begin
134 Set Deferred_State to True
135 Get Value item 0 to sValue
136 Send Combo_Delete_Data
137 Send Combo_Initialize_List
138 Set Deferred_State to False
139 Set Combo_data_object to (Combo_Data_Object(Self))
140 Set Local_Value Item 0 to sValue
141 End
142 End
143 Procedure_Return iRVal
144 End_Procedure // Activate
145
146 { MethodType=Event Nodoc=True }
147 Procedure Combo_Item_Changed
148 Forward Send combo_item_Changed
149 If (Extended_deo_State(Self)) ;
150 Set Item_Field_Current_Value item 0 to (Value(Self,0))
151 end_Procedure
152
153 // Right now combo forms do not understand masks
154 //
155 { Visibility=Private }
156 Procedure Copy_Mask_Options Integer iDSO Integer iFile Integer iField ;
157 Integer iDEO Integer iItem
158 End_Procedure
159
160 // This Replaces DD message with one that understands
161 // description and data difference. Actually Combos have this but
162 // lose it with the DD mixin. These restablishes it.
163 //
164 { MethodType=Property Visibility=Private }
165 Function Data_Value integer item# Returns String
166 string sValue
167 Get Value item item# to sValue
168 Get Description_to_Data sValue to sValue
169 Function_Return SValue
170 End_Function
171
172 // Augmented to handle entry_state=F combos. These type of combos must
173 // have a default value (since something always appears in the form). So
174 // we must check for cases where we have a value in the combo that is
175 // not reflected in the DD buffer. In such a case, update the buffer with
176 // a default value.
177 //
178 { MethodType=Event Visibility=Private Nodoc=True }
179 Procedure Entry_Defaults
180 Integer iData_File
181 Integer iData_Field
182 Integer iDSO
183 integer iOldState
184 integer iState
185
186 Forward Send Entry_Defaults // first do a normal entry-defaults
187 Get Server to iDSO
188 If (Entry_State(Self,0)=0 AND ; // only for no edit combos
189 Extended_deo_State(Self) AND iDSO ) Begin
190 Get Data_File to iData_File
191 Get Data_Field to iData_Field
192 If iData_File Begin
193 Get File_Field_Changed_State of iDSO iData_File iData_Field to iState
194 // if DDO field not changed we must set the default in the DD buffer
195 If Not iState Begin
196 Get Entry_Refresh_State to iOldState
197 Set Entry_Refresh_State to True // this stops recursion
198 // set default value in DD to the data value of current combo
199 Set File_Field_Default_Value of iDSO iData_File iData_Field ;
200 to (Data_Value(Self,0))
201 Set Entry_Refresh_State to iOldState
202 End
203 End
204 End
205 End_Procedure
206
207 // change so that list is initialized first. Also, set extended_deo_state before
208 // attempting to fill list (it needs that information).
209 { Visibility=Private }
210 Procedure Attach_Deo_To_Server
211 Integer iSrvr
212 Get Server to iSrvr
213 If iSrvr ;
214 Set Extended_DEO_State to (Extended_DSO_State(iSrvr))
215 Send Combo_initialize_list
216 Forward Send Attach_deo_to_Server
217 End_Procedure
218
219 // added to support DD based autofinds. DoAutoFind is defined in dd_deomx.pkg
220 // It is rather odd to have an autofind as part of a dbCombo, but this was supported
221 // in VDF7 when dd_autofind was added to the item-options. Now that autofinds are handled
222 // through the DD, we need these messages to call doAutoFind at the right time
223 //
224 { MethodType=Event Nodoc=True }
225 Procedure Exiting Handle hoDestination Returns Integer
226 integer bErr
227 // although exiting does not do a validate it should do an
228 // autofind (if autofind is needed). This is consisent with
229 // character mode behavior.
230 send doAutofind // // this does an autofind if needed, this is needed before save
231 Forward get msg_exiting hoDestination to bErr
232 function_return bErr
233 end_procedure
234
235 { NoDoc=True }
236 procedure Request_Save
237 Send doAutofind // this does an autofind if needed, this is needed before save
238 forward send request_save
239 end_procedure
240
241 // augment to unset capslock state if the combo is not a code display. The DD might have set the capslock but
242 // this only makes sense if you are displaying the actual data.
243 { Visibility=Private }
244 Procedure Copy_Item_Options Integer iDSO Integer iFile Integer iField Integer iDEO Integer iItem
245 Integer eDisplayMode
246 Boolean bDataOnly
247 Forward Send Copy_Item_Options iDSO iFile iField iDEO iItem
248 If Not (Extended_deo_State(self)) Procedure_Return
249 Get Code_Display_mode to eDisplayMode
250 Get Data_Only_State to bDataOnly
251 If (eDisplayMode<>CB_CODE_DISPLAY_CODE and not(bDataOnly)) Begin
252 // if display code or it's not data only we clear the capslock
253 Set Capslock_State to False
254 end
255 End_Procedure
256
257End_Class
258
259