Module cDbTextEdit.pkg
1Use cTextEdit.pkg
2Use Text_Win.pkg
3Use DFNav_mx.pkg // Navigation changes for DF DEOs
4Use DFCdDeo.pkg // DEO Code message support
5Use DD_Deomx.pkg // mixin support for dd classes
6
7// DFO: cDbTextEdit.Dfo
8// DFC: cDbTextEdit.Dfc
9
10{ ClassType=Abstract }
11{ HelpTopic=cDbTextEdit_ }
12Class cDbTextEdit_ is a cTextEdit
13
14 Import_Class_Protocol Text_Window_mixin
15
16 //
17 // created for EntItem simulation and Server support:
18 // if file# = 0, display only if Data_File is in Done-array
19 // else display only if file# = Data_File
20 //
21 { Visibility=Private }
22 procedure Entry_Display integer iFile integer iFlag
23 Boolean bUpdate bOld
24 Integer iDataFile
25 get data_file to iDataFile
26 if (iDataFile) begin // if not data file, we have nothing to update
27 if (iFile=0) begin
28 is_file_included iDataFile 1
29 Move (found) to bUpdate
30 end
31 else begin
32 Move (iFile=iDataFile or iFlag) to bUpdate
33 end
34
35 If bUpdate begin
36 get dynamic_update_state to bOld
37 set dynamic_update_state to false
38 send Delete_Data // init buffer
39 send DisplayData // read buffer from file
40 send beginning_of_data
41 set dynamic_update_state to bOld
42 end
43 end
44 end_procedure
45
46 { Visibility=Private }
47 Procedure DisplayData
48 integer iFile iField iFldLen
49 Address pField
50 Boolean bOk bOld
51 Get Data_File to iFile
52 Get Data_Field to iField
53 If (iFile>0 and iField>0) begin
54 Get Change_Disabled_State to bOld
55 Set Change_Disabled_State to True
56 Get_Attribute DF_FIELD_LENGTH of iFile iField to iFldLen
57 // when allocating field lengths for get_field_value you *must* always add one
58 // extra character for a terminating 0.
59 Move (Alloc(iFldLen+1)) to pField
60 Get_Field_value iFile iField to pField
61 Set paValue to pField
62 Move (Free(pField)) to bOk
63 Set Change_Disabled_State to bOld
64 end
65 End_procedure
66
67 //
68 // This is designed onlt to work with DDs. With DDs, this is called under
69 // two conditons.
70 // 1. Update for find (passes iFile and Flag=1). We never want to update for finds. Text is not indexed
71 // 2. Update for save (passes iFile=0 and Flag=3).
72 // Thus we update if a ddo save (iFlag=3) the field is changed, and the file is in done array
73 //
74 { Visibility=Private }
75 procedure Entry_Update integer iFile integer iFlag
76 Integer iDataFile
77 Boolean bUpdate
78 If (iFlag=3 and changed_State(Self)) begin
79 get Data_File to iDataFile
80 If (iDataFile) begin
81 is_file_included iDataFile 1 // is file in done array (will it get saved)?
82 Move (found) to bUpdate
83 end
84 If bUpdate begin
85 send UpdateData
86 end
87 end
88 end_procedure
89
90 // Move data from Text Control to the File/field buffer
91 { Visibility=Private }
92 Procedure UpdateData
93 integer iFile iField iFldLen
94 Address pField
95 Boolean bOk
96 Get Data_File to iFile
97 Get Data_Field to iField
98 If (iFile>0 and iField>0) begin
99 Get paValue to pField
100 Move (CStringLength(pField)) to iFldLen
101 //Move (Length(pField)) to iFldLen
102 Set_Field_Value iFile iField to pField LENGTH iFldLen
103 Move (Free(pField)) to bOk
104 End
105 End_procedure
106
107End_Class
108
109{ ClassType=Abstract }
110{ HelpTopic=cDbTextEditDS_ }
111Class cDbTextEditDS_ is a cDbTextEdit_
112
113 Procedure Construct_Object
114 Forward Send Construct_Object
115 Send Define_DFNavigation // GUI navigate changes
116 // restore standard begin/end of text window behavior (which
117 // is altered by CM packages
118 On_key kBegin_of_data send default_key
119 On_Key kEnd_of_data Send default_key
120
121 // if true, we dynamically test the length of the stream (i.e., the real length that gets
122 // written to the database) to see if it is too long. If you text is very long this may be
123 // too slow and you would therefore want to disable it.
124 { Category=Behavior }
125 Property Boolean pbTestCharCount True
126
127 { Visibility=Private }
128 Property Integer piMaxStreamLength 0
129 { Visibility=Private }
130 Property Integer piLastCharCount 0
131 End_Procedure // Construct_Object
132
133 Import_Class_Protocol DFNavigate_Mixin
134 Import_Class_Protocol DFCode_DEO_Mixin
135 Import_Class_Protocol DataFile_Help_Mixin
136
137 // these should be in text_win.pkg All DEOs shoudld understand this
138 // message. Needed for smart pulldown shadowing of these items
139 //
140 { MethodType=Property NoDoc=True }
141 Function Prompt_Object integer item# returns integer
142 End_Function
143
144 { MethodType=Property NoDoc=True }
145 Function Zoom_Object integer item# returns integer
146 End_Function
147
148 { Visibility=Private }
149 Procedure Bind_Data integer File# Integer Field#
150 Set Data_File to File#
151 Set Data_Field to Field#
152 End_Procedure // Bind_Data
153
154 // augment to raise an error if the field length is too long. When we set max length in the control is handles CR/LF as one character.
155 // When it is streamed (paValue or Value) those become two characters. Therefore the max length enforced in the control may still be too
156 // long for the field buffer. That's why we must check this one more time.
157 function Validate_Items integer flag returns integer
158 integer iFile iField iFldLen iEditLen
159 Address pField
160 Boolean bOk
161 Get Data_File to iFile
162 Get Data_Field to iField
163 If (iFile>0 and iField>0) begin
164 Get_Attribute DF_FIELD_LENGTH of iFile iField to iFldLen
165 Get CharCount to iEditLen
166 If (iEditLen>iFldLen) begin
167 Send Activate_Area True
168 Error DFERR_TEXT_TOO_LARGE_FOR_FIELD (sFormat(C_$MaxLenAndCurrentLen,iFldLen,iEditLen))
169 Function_return 1
170 end
171 end
172 end_function
173
174 // do an additional test in EN_CHANGE to handle testing of stream length
175 { NoDoc=True }
176 Procedure Command Integer wParam Integer lParam
177 Boolean bTestCharCount bSuppress
178 Integer iMax iEditLen iLast iFile iField
179
180 Forward Send Command wParam lParam
181
182 If (hi(wParam)=EN_CHANGE) Begin
183 Get pbSuppressChange to bSuppress
184 If bSuppress Begin
185 // if we are suppressing change notification, reset the last count. It doesn't
186 // matter if the count is accurate.
187 Set piLastCharCount to 0
188 End
189 Else Begin
190 Get pbTestCharCount to bTestCharCount
191 If bTestCharCount Begin
192 Get Data_File to iFile
193 If (iFile) Begin
194 Get Data_Field to iField
195 Get_Attribute DF_FIELD_Length of iFile iField to iMax
196 End
197 // Get the current stream length. This is the potentially expensive operation.
198 Get CharCount to iEditLen
199 Get piLastCharCount to iLast
200 // set this so we know when we are getting smaller
201 Set piLastCharCount to iEditLen
202 // if the length is too long and the attempt was to make it longer we
203 // have an error. If do the piLastCharCount test so that you don't get errors
204 // when you are trying to make the text shorter (like backspacing after you get the error).
205 If (iMax>0 and iEditLen>iMax and iEditLen>iLast) Begin
206 Error DFERR_TEXT_TOO_LARGE_FOR_FIELD (sFormat(C_$MaxLenAndCurrentLen,iMax,iEditLen))
207 Send OnMaxText
208 End
209 End
210 End
211 End
212 End_Procedure
213
214
215End_Class
216
217
218
219{ HelpTopic=cDbTextEdit }
220{ DataBindable=True }
221Class cDbTextEdit is a cDbTextEditDS_
222 Import_Class_Protocol Extended_DEO_Status_Help_Mixin
223 Import_Class_Protocol Extended_DEO_Status_Help_Tooltip_Mixin
224
225 Procedure Construct_Object
226 Forward Send Construct_Object
227 { Category=Appearance }
228 { PropertyType=Boolean }
229 Property Integer Auto_Label_State False
230 End_Procedure // Construct_Object
231
232 //************************************************************************//
233 // Copy_Item_Options //
234 // Currently there is nothing to do except optionally support an auto- //
235 // label. We maintain this format to keep in similar to the other DEOs //
236 //************************************************************************//
237 //
238 { Visibility=Private }
239 Procedure Copy_Item_Options Integer iDSO Integer iFile Integer iField ;
240 Integer iDEO Integer iItem
241 If not (Extended_DSO_State(iDSO)) Begin
242 Procedure_Return
243 End
244 If (Auto_Label_State(Self)) Begin
245 Send Assign_DD_Label iDSO iFile iField iDEO iItem
246 End
247
248 // Assign the tooltip according to the DDO's Status_Help string....
249 Send SetToolTipFromStatusHelp
250 End_Procedure
251
252 //************************************************************************//
253 // Assign_DD_Label //
254 // This assigns the DEO's from the DD. This uses long labels and //
255 // and sets the label property //
256 //************************************************************************//
257 //
258 { Visibility=Private }
259 Procedure Assign_DD_Label Integer iDSO Integer iFile Integer iField ;
260 Integer iDEO Integer iItem
261 string sName
262 Get File_Field_Label of iDSO iFile iField DD_LABEL_LONG to sName
263 Set Label to sName
264 End_Procedure
265
266End_Class
267
268
269
270