Module cCJGridColumnEdit.pkg
1Use UI
2Use Windows.pkg
3
4{ Visibility=Private }
5Class cCJGridColumnEdit is a DfBaseEntry
6
7 Import_Class_Protocol FloatingPopupMenu_Mixin
8
9 Procedure Construct_Object
10 Forward Send Construct_Object
11 Set Border_Style to Border_None
12 Set Form_Border to Border_None
13 Set Attach_Parent_State to True
14
15 Property Boolean pbCancel False // tells us if the edit was cancelled
16 Property Boolean pbInDeactivate False // says we are within a deactivate
17 Property Boolean pbNoKill False // used to stop the OnKillFocus logic. Needed when form buttons triggers a kill focus
18 Property Boolean pbControlValueUpdated // tells us if the control value is updated, which can occur in several places
19
20 Property Handle phoGrid 0
21
22 Send Define_FloatingPopupMenu_Mixin
23 Set Floating_Menu_Object to Default_Form_Floating_Menu_Id
24
25 On_Key Key_Escape Send EscPressed
26 On_Key Key_Enter Send EnterPressed
27 On_Key Key_Tab Send Next
28 On_Key Key_Down_Arrow Send MoveDownRow
29 On_Key Key_Up_Arrow Send MoveUpRow
30 On_Key Key_PgDn Send MovePageDown
31 On_Key Key_PgUp Send MovePageUp
32 On_Key Kswitch Send Switch_Next_Area
33 On_Key Kswitch_Back Send Switch_Prior_Area
34 End_Procedure
35
36 Procedure Switch_Next_Area
37 Delegate Send Switch_Next_Area
38 End_Procedure
39
40 Procedure Switch_Prior_Area
41 Delegate Send Switch_Prior_Area
42 End_Procedure
43
44
45 // help should be handled by grid
46 Procedure Help
47 Delegate Send Help
48 End_Procedure
49
50 Procedure Set Capslock_State Integer bCaps
51 Integer iOpts
52 If bCaps Begin
53 Get Form_Options to iOpts
54 Set Form_Options to (iOpts ior CAPSLOCK_BIT_VALUE)
55 End
56 End_Procedure
57
58 Procedure CancelEdit
59 Handle hoGrid
60 Get phoGrid to hoGrid
61 Set pbCancel to True
62 Send EndEdit of hoGrid
63 End_Procedure
64
65 Procedure EndEdit
66 Handle hoGrid
67 Get phoGrid to hoGrid
68 Send EndEdit of hoGrid
69 End_Procedure
70
71 Procedure EnterPressed
72 Handle hoGrid
73 Get phoGrid to hoGrid
74 Send OnEnterKey of hoGrid
75 End_Procedure
76
77 Procedure EscPressed
78 Handle hoGrid
79 Get phoGrid to hoGrid
80 Send OnEscKey of hoGrid
81 End_Procedure
82
83 Procedure MoveDownRow
84 Handle hoGrid
85 Get phoGrid to hoGrid
86 Send MoveDownRow of hoGrid
87 End_Procedure
88
89 Procedure MoveUpRow
90 Handle hoGrid
91 Get phoGrid to hoGrid
92 Send MoveUpRow of hoGrid
93 End_Procedure
94
95 Procedure MovePageDown
96 Handle hoGrid
97 Get phoGrid to hoGrid
98 Send MovePageDown of hoGrid
99 End_Procedure
100
101 Procedure MovePageDown
102 Handle hoGrid
103 Get phoGrid to hoGrid
104 Send MovePageDown of hoGrid
105 End_Procedure
106
107 Procedure Next
108 Handle hoGrid
109 Get phoGrid to hoGrid
110 Send Next of hoGrid
111 End_Procedure
112
113 Procedure Previous
114 Handle hoGrid
115 Get phoGrid to hoGrid
116 Send Previous of hoGrid
117 End_Procedure
118
119 Procedure UpdateCustomEdit
120 String sVal
121 Boolean bCancel bUpdated
122 Handle hoGrid
123 Integer iIndex
124
125 Get pbControlValueUpdated to bUpdated
126 If not bUpdated Begin
127 Set pbControlValueUpdated to True
128 Get pbCancel to bCancel
129 If (not(bCancel)) Begin
130 Get Value to sVal
131 Get phoGrid to hoGrid
132 Get piColumnId to iIndex
133 Send NotifyCustomEndEdit of hoGrid iIndex sVal
134 End
135 End
136 End_Procedure
137
138 Procedure Exiting Handle hoDestination Returns Integer
139 Boolean bCancel
140 Handle hoGrid
141
142 Get phoGrid to hoGrid
143 // this may be the first focus change notification. If it is, we want to update the edit value
144 Send UpdateCustomEdit
145 If (hoGrid<>hoDestination) Begin
146 Get msg_Exiting of hoGrid hoDestination to bCancel
147 End
148 Procedure_Return bCancel
149 End_Procedure
150
151 Procedure Form_Button_Mouse_Down Integer iItem Integer Counter
152 // normally this causes a windows focus change, which sends kill_focus, which deactivates the form
153 // we cannot kill the focus during form mouse down or you get an exception
154 Set pbNoKill to True
155 End_Procedure
156
157 Procedure Form_Button_Notification Integer iItem Integer iPosition
158 Set pbNoKill to False // it's now safe to kill the form, which promtp may do
159 Send Prompt
160 End_Procedure
161
162 Procedure Prompt
163 Delegate Send Activate // pass focus to grid and deactivate this form
164 Delegate Send Prompt // do the prompt
165 Delegate Send BeginEdit // start edit again. Use beginEdit because position may change
166 End_Procedure
167
168 Function Prompt_Object Integer iItem Returns Integer
169 Handle hoObject
170 Delegate Get Prompt_Object to hoObject
171 Function_Return hoObject
172 End_Function
173
174 Procedure Notify_Focus_Change Integer Fg
175 If Fg Send OnSetFocus
176 Else Send OnKillFocus
177 End_Procedure
178
179 Procedure Deactivate Integer eDeactivateScope Returns Integer
180 Set pbInDeactivate to True
181 Forward Send Deactivate eDeactivateScope
182 Set pbInDeactivate to False
183 End_Procedure
184
185 // this is sent by a modal dialog before it takes the focus (sent from Create_Dialog). It is sent to the
186 // focus object. If the edit control is the focus, we remove the edit by activating the grid. This forces the
187 // invoking object to be the grid and not the edit control. It also insures that the popup's focus parent is the grid.
188 // All other classes do nothing with this message.
189 Procedure OnPreCreate_Dialog
190 If (Focus(Self)<>Self) Begin
191 Error DFERR_PROGRAM "Assert: OnPreCreate_Dialog called when not the focus"
192 End
193 Delegate Send Activate
194 End_Procedure
195
196 // before activation is attempted we must set the grid's phoCustomEdit
197 // property to indicate that the custom edit has or is about to take the
198 // focus. This must be set before the grid gets the exiting message
199 Procedure ActivateForm
200 Handle hoGrid
201 String sValue
202 Boolean bActive
203 Get Active_State to bActive
204 If not bActive Begin
205 Get phoGrid to hoGrid
206 Set phoCustomEdit of hoGrid to Self
207 Get SelectedRowValue to sValue
208 Set New_Item to 0
209 Set Value to sValue
210 Set pbControlValueUpdated to False
211 Set pbCancel to False
212 Send CreatePromptButton
213 Send Activate
214 End
215 End_Procedure
216
217 // This is needed to make the value appear in the form.
218 Procedure Page_Object Boolean bPage
219 String sVal
220 If bPage Begin
221 Get Value to sVal
222 Forward Send Page_Object bPage
223 Set Value to sVal
224 End
225 Else Begin
226 Forward Send Page_Object bPage
227 End
228
229 End_Procedure
230
231 Procedure OnSetFocus
232 End_Procedure
233
234 Procedure OnKillFocus
235 String sVal
236 Boolean bCancel bDeactivating bNoKill
237 Handle hoGrid hoFocus hoFocusPre
238
239 Get phoGrid to hoGrid
240 Get pbInDeactivate to bDeactivating
241
242 Get pbNoKill to bNoKill
243 If bNoKill Begin
244 Procedure_Return
245 End
246
247 // this may be the first focus change notification. If it is, we want to update the edit value
248 Send UpdateCustomEdit
249
250 If not bDeactivating Begin
251 Get Focus to hoFocusPre
252 Send Deactivate 0
253 Get Focus to hoFocus
254 // if the focus is the grid and the orignal focus was this control then
255 // probably this kill focus is a result of switching to something outside
256 // of this application. Whatever it is, it's best to just repaint the screen
257 // so any change is updated
258 If (hoFocus=hoGrid and hoFocusPre=Self) Begin
259 // When deactivate returns the focus to the grid, it does not reset the COM control
260 // as the active control. We will do that here with OnDfSetFocus.
261 Send onDfFocus of hoGrid 1 0
262 Send ComRedraw of hoGrid
263 End
264 // if the focus is not on the grid it has gone to other place under the apps
265 // control. We can do a deferred redraw.
266 Else If (hoFocus<>hoGrid) Begin
267 Send DeferredRedraw of hoGrid
268 End
269 // else focus was already move to the grid. We should not need to redraw
270 End
271
272 Set phoCustomEdit of hoGrid to 0
273
274 End_Procedure
275
276 // called when object is paged to determine if a prompt button is used.
277 Procedure CreatePromptButton
278 Integer eCreate
279 Handle hoPrompt
280 Boolean bOn
281 String sValue
282 Delegate Get Prompt_Button_Mode to eCreate
283 If (eCreate=PB_PromptAuto) Begin // 0 = if auto-create and prompt object
284 Get Prompt_Object to bOn
285 End
286 Else Begin // 1 = make an object, 2= remove object
287 Move (eCreate=PB_PromptOn) to bOn
288 End
289 If bOn Begin
290 Delegate Get Prompt_Button_Value to sValue
291 Set Form_Button_Value to sValue
292 Set Form_Button to FORM_BUTTON_PROMPT
293 End
294 Else Begin
295 Set Form_Button to FORM_BUTTON_NONE
296 End
297 End_Procedure
298
299 { Visibility=Private MethodType=Event }
300 Procedure Command Integer wParam Integer lParam
301 Forward Send Command wParam lParam
302 If (Hi(wParam)) eq EN_CHANGE Begin
303 Delegate Send OnEditChanging
304 End
305 End_Procedure
306
307End_Class
308
309