-
Notifications
You must be signed in to change notification settings - Fork 23
/
wViewAsEditor.w
376 lines (280 loc) · 11.9 KB
/
wViewAsEditor.w
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI
&ANALYZE-RESUME
&Scoped-define WINDOW-NAME wEditor
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS wEditor
/*------------------------------------------------------------------------
Name: wViewAsEditor.w
Desc: Show text in editor widget
----------------------------------------------------------------------*/
/* This .W file was created with the Progress AppBuilder. */
/*----------------------------------------------------------------------*/
CREATE WIDGET-POOL.
{ DataDigger.i }
/* Parameters Definitions --- */
&IF DEFINED(UIB_IS_RUNNING) = 0 &THEN
DEFINE INPUT-OUTPUT PARAMETER pcValue AS LONGCHAR NO-UNDO.
&ELSE
DEFINE VARIABLE pcValue AS LONGCHAR NO-UNDO.
&ENDIF
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
/* ******************** Preprocessor Definitions ******************** */
&Scoped-define PROCEDURE-TYPE Window
&Scoped-define DB-AWARE no
/* Name of designated FRAME-NAME and/or first browse and/or first query */
&Scoped-define FRAME-NAME DEFAULT-FRAME
/* Standard List Definitions */
&Scoped-Define ENABLED-OBJECTS edValue btnOk btnCancel
&Scoped-Define DISPLAYED-OBJECTS edValue
/* Custom List Definitions */
/* List-1,List-2,List-3,List-4,List-5,List-6 */
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Control Definitions ********************** */
/* Define the widget handle for the window */
DEFINE VAR wEditor AS WIDGET-HANDLE NO-UNDO.
/* Definitions of the field level widgets */
DEFINE BUTTON btnCancel AUTO-END-KEY
LABEL "Cancel"
SIZE-PIXELS 75 BY 24
BGCOLOR 8 .
DEFINE BUTTON btnOk AUTO-GO
LABEL "OK"
SIZE-PIXELS 75 BY 24
BGCOLOR 8 .
DEFINE VARIABLE edValue AS CHARACTER
VIEW-AS EDITOR SCROLLBAR-VERTICAL LARGE
SIZE-PIXELS 400 BY 130 NO-UNDO.
/* ************************ Frame Definitions *********************** */
DEFINE FRAME DEFAULT-FRAME
edValue AT Y 0 X 0 NO-LABEL
btnOk AT Y 140 X 234
btnCancel AT Y 140 X 314
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT X 0 Y 0
SIZE-PIXELS 400 BY 170.
/* *********************** Procedure Settings ************************ */
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: Window
Allow: Basic,Browse,DB-Fields,Window,Query
Other Settings: COMPILE
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
/* ************************* Create Window ************************** */
&ANALYZE-SUSPEND _CREATE-WINDOW
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
CREATE WINDOW wEditor ASSIGN
HIDDEN = YES
TITLE = "Edit Field Value"
HEIGHT-P = 173
WIDTH-P = 400
MAX-HEIGHT-P = 6720
MAX-WIDTH-P = 1600
VIRTUAL-HEIGHT-P = 6720
VIRTUAL-WIDTH-P = 1600
RESIZE = yes
SCROLL-BARS = no
STATUS-AREA = no
BGCOLOR = ?
FGCOLOR = ?
KEEP-FRAME-Z-ORDER = yes
THREE-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
/* END WINDOW DEFINITION */
&ANALYZE-RESUME
/* *********** Runtime Attributes and AppBuilder Settings *********** */
&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW wEditor
VISIBLE,,RUN-PERSISTENT */
/* SETTINGS FOR FRAME DEFAULT-FRAME
FRAME-NAME */
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wEditor)
THEN wEditor:HIDDEN = no.
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME
/* ************************ Control Triggers ************************ */
&Scoped-define SELF-NAME wEditor
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wEditor wEditor
ON END-ERROR OF wEditor /* Edit Field Value */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
/* This case occurs when the user presses the "Esc" key.
In a persistently run window, just ignore this. If we did not, the
application would exit. */
IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wEditor wEditor
ON LEAVE OF wEditor /* Edit Field Value */
OR "LEAVE" OF wEditor
DO:
/* This event will close the window and terminate the procedure. */
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wEditor wEditor
ON WINDOW-CLOSE OF wEditor /* Edit Field Value */
DO:
/* This event will close the window and terminate the procedure. */
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wEditor wEditor
ON WINDOW-RESIZED OF wEditor /* Edit Field Value */
DO:
/* Sanity checks */
IF wEditor:WIDTH-PIXELS < 100
OR wEditor:HEIGHT-PIXELS < 100 THEN RETURN.
RUN LockWindow (INPUT wEditor:HANDLE, INPUT YES).
DO WITH FRAME {&FRAME-NAME}:
/* Make everything small so we don't get errors on resizing the window */
btnOk:X = 0.
btnOk:Y = 0.
btnCancel:X = 0.
btnCancel:Y = 0.
edValue:X = 0.
edValue:Y = 0.
edValue:WIDTH-PIXELS = 10.
edValue:HEIGHT-PIXELS = 10.
/* Set frame width */
FRAME {&FRAME-NAME}:WIDTH-PIXELS = wEditor:WIDTH-PIXELS NO-ERROR.
FRAME {&FRAME-NAME}:HEIGHT-PIXELS = wEditor:HEIGHT-PIXELS NO-ERROR.
/* Adjust the browse */
edValue:WIDTH-PIXELS = FRAME {&FRAME-NAME}:WIDTH-PIXELS.
edValue:HEIGHT-PIXELS = FRAME {&FRAME-NAME}:HEIGHT-PIXELS - 40.
btnOk:X = FRAME {&FRAME-NAME}:WIDTH-PIXELS - 165.
btnOk:Y = FRAME {&FRAME-NAME}:HEIGHT-PIXELS - 30.
btnCancel:X = FRAME {&FRAME-NAME}:WIDTH-PIXELS - 85.
btnCancel:Y = FRAME {&FRAME-NAME}:HEIGHT-PIXELS - 30.
/* Save settings */
setRegistry("DataDigger:ViewAsEditor", "Window:x", STRING(wEditor:X) ).
setRegistry("DataDigger:ViewAsEditor", "Window:y", STRING(wEditor:Y) ).
setRegistry("DataDigger:ViewAsEditor", "Window:height", STRING(wEditor:HEIGHT-PIXELS) ).
setRegistry("DataDigger:ViewAsEditor", "Window:width", STRING(wEditor:WIDTH-PIXELS) ).
END.
RUN showScrollBars(FRAME {&FRAME-NAME}:HANDLE, NO, NO).
RUN LockWindow (INPUT wEditor:HANDLE, INPUT NO).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME btnOk
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btnOk wEditor
ON CHOOSE OF btnOk IN FRAME DEFAULT-FRAME /* OK */
OR "F2" OF edValue
DO:
pcValue = edValue:SCREEN-VALUE.
APPLY "CLOSE" TO THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME edValue
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL edValue wEditor
ON CTRL-A OF edValue IN FRAME DEFAULT-FRAME
DO:
edValue:SET-SELECTION(1,LENGTH(edValue:SCREEN-VALUE) + 1).
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&UNDEFINE SELF-NAME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK wEditor
/* *************************** Main Block *************************** */
/* Set CURRENT-WINDOW: this will parent dialog-boxes and frames. */
ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.
/* The CLOSE event can be used from inside or outside the procedure to */
/* terminate it. */
ON CLOSE OF THIS-PROCEDURE
DO:
/* Save settings */
setRegistry("DataDigger:ViewAsEditor", "Window:x", STRING(wEditor:X) ).
setRegistry("DataDigger:ViewAsEditor", "Window:y", STRING(wEditor:Y) ).
setRegistry("DataDigger:ViewAsEditor", "Window:height", STRING(wEditor:HEIGHT-PIXELS) ).
setRegistry("DataDigger:ViewAsEditor", "Window:width", STRING(wEditor:WIDTH-PIXELS) ).
RUN disable_UI.
END.
/* Best default for GUI applications is... */
PAUSE 0 BEFORE-HIDE.
/* Now enable the interface and wait for the exit condition. */
/* (NOTE: handle ERROR and END-KEY so cleanup code will always fire. */
MAIN-BLOCK:
DO ON ERROR UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
ASSIGN edValue = SUBSTRING(pcValue,1,{&field-maxLength}).
edValue:MAX-CHARS = {&field-maxLength}.
RUN enable_UI.
RUN initializeObject.
IF NOT THIS-PROCEDURE:PERSISTENT THEN
WAIT-FOR CLOSE OF THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ********************** Internal Procedures *********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI wEditor _DEFAULT-DISABLE
PROCEDURE disable_UI :
/*------------------------------------------------------------------------------
Purpose: DISABLE the User Interface
Parameters: <none>
Notes: Here we clean-up the user-interface by deleting
dynamic widgets we have created and/or hide
frames. This procedure is usually called when
we are ready to "clean-up" after running.
------------------------------------------------------------------------------*/
/* Delete the WINDOW we created */
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wEditor)
THEN DELETE WIDGET wEditor.
IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI wEditor _DEFAULT-ENABLE
PROCEDURE enable_UI :
/*------------------------------------------------------------------------------
Purpose: ENABLE the User Interface
Parameters: <none>
Notes: Here we display/view/enable the widgets in the
user-interface. In addition, OPEN all queries
associated with each FRAME and BROWSE.
These statements here are based on the "Other
Settings" section of the widget Property Sheets.
------------------------------------------------------------------------------*/
DISPLAY edValue
WITH FRAME DEFAULT-FRAME IN WINDOW wEditor.
ENABLE edValue btnOk btnCancel
WITH FRAME DEFAULT-FRAME IN WINDOW wEditor.
{&OPEN-BROWSERS-IN-QUERY-DEFAULT-FRAME}
VIEW wEditor.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initializeObject wEditor
PROCEDURE initializeObject :
/* Init frame and font
*/
DEFINE VARIABLE iValue AS INTEGER NO-UNDO.
DO WITH FRAME {&FRAME-NAME}:
/* Set default font */
FRAME {&FRAME-NAME}:FONT = getFont('Default').
edValue:FONT = getFont('Fixed').
/* Restore window */
iValue = INTEGER(getRegistry('DataDigger:ViewAsEditor', 'Window:x' )).
IF iValue > 0 THEN ASSIGN wEditor:X = iValue NO-ERROR.
iValue = INTEGER(getRegistry('DataDigger:ViewAsEditor', 'Window:y' )).
IF iValue > 0 THEN ASSIGN wEditor:Y = iValue NO-ERROR.
iValue = INTEGER(getRegistry('DataDigger:ViewAsEditor', 'Window:height' )).
IF iValue > 0 THEN ASSIGN wEditor:HEIGHT-PIXELS = iValue NO-ERROR.
iValue = INTEGER(getRegistry('DataDigger:ViewAsEditor', 'Window:width' )).
IF iValue > 0 THEN ASSIGN wEditor:WIDTH-PIXELS = iValue NO-ERROR.
END.
APPLY "window-resized" TO wEditor.
END PROCEDURE. /* initializeObject */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME