1 |
|
---|
2 | /*
|
---|
3 | *@@sourcefile dialog.h:
|
---|
4 | * header file for dialog.c. See remarks there.
|
---|
5 | *
|
---|
6 | * Note: Version numbering in this file relates to XWorkplace version
|
---|
7 | * numbering.
|
---|
8 | *
|
---|
9 | *@@added V0.9.9 (2001-04-01) [umoeller]
|
---|
10 | *@@include <os2.h>
|
---|
11 | *@@include #include "helpers\linklist.h" // for mnemonic helpers
|
---|
12 | *@@include #include "helpers\dialog.h"
|
---|
13 | */
|
---|
14 |
|
---|
15 | /* Copyright (C) 2001 Ulrich Mller.
|
---|
16 | * This file is part of the "XWorkplace helpers" source package.
|
---|
17 | * This is free software; you can redistribute it and/or modify
|
---|
18 | * it under the terms of the GNU General Public License as published
|
---|
19 | * by the Free Software Foundation, in version 2 as it comes in the
|
---|
20 | * "COPYING" file of the XWorkplace main distribution.
|
---|
21 | * This program is distributed in the hope that it will be useful,
|
---|
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
24 | * GNU General Public License for more details.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #if __cplusplus
|
---|
28 | extern "C" {
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | #ifndef DIALOG_HEADER_INCLUDED
|
---|
32 | #define DIALOG_HEADER_INCLUDED
|
---|
33 |
|
---|
34 | #ifndef NULL_POINT
|
---|
35 | #define NULL_POINT {0, 0}
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | /* ******************************************************************
|
---|
39 | *
|
---|
40 | * Error codes
|
---|
41 | *
|
---|
42 | ********************************************************************/
|
---|
43 |
|
---|
44 | #define DLGERR_FIRST 10000
|
---|
45 | #define DLGERR_ROW_BEFORE_TABLE (DLGERR_FIRST)
|
---|
46 | #define DLGERR_CONTROL_BEFORE_ROW (DLGERR_FIRST + 1)
|
---|
47 | #define DLGERR_NULL_CTL_DEF (DLGERR_FIRST + 2)
|
---|
48 | #define DLGERR_CANNOT_CREATE_FRAME (DLGERR_FIRST + 3)
|
---|
49 | #define DLGERR_INVALID_CODE (DLGERR_FIRST + 4)
|
---|
50 | #define DLGERR_TABLE_NOT_CLOSED (DLGERR_FIRST + 5)
|
---|
51 | #define DLGERR_TOO_MANY_TABLES_CLOSED (DLGERR_FIRST + 6)
|
---|
52 | #define DLGERR_CANNOT_CREATE_CONTROL (DLGERR_FIRST + 7)
|
---|
53 | #define DLGERR_ARRAY_TOO_SMALL (DLGERR_FIRST + 8)
|
---|
54 | #define DLGERR_INVALID_CONTROL_TITLE (DLGERR_FIRST + 9)
|
---|
55 | #define DLGERR_INVALID_STATIC_BITMAP (DLGERR_FIRST + 10)
|
---|
56 |
|
---|
57 | /* ******************************************************************
|
---|
58 | *
|
---|
59 | * Structures
|
---|
60 | *
|
---|
61 | ********************************************************************/
|
---|
62 |
|
---|
63 | #define SZL_AUTOSIZE (-1)
|
---|
64 |
|
---|
65 | #define CTL_COMMON_FONT ((const char *)-1)
|
---|
66 |
|
---|
67 | #define ROW_VALIGN_MASK 0x0003
|
---|
68 | #define ROW_VALIGN_BOTTOM 0x0000
|
---|
69 | #define ROW_VALIGN_CENTER 0x0001
|
---|
70 | #define ROW_VALIGN_TOP 0x0002
|
---|
71 |
|
---|
72 | /*
|
---|
73 | *@@ CONTROLDEF:
|
---|
74 | * defines a single control. Used
|
---|
75 | * with the TYPE_CONTROL_DEF type in
|
---|
76 | * DLGHITEM.
|
---|
77 | *
|
---|
78 | *@@changed V0.9.12 (2001-05-31) [umoeller]: added control data
|
---|
79 | */
|
---|
80 |
|
---|
81 | typedef struct _CONTROLDEF
|
---|
82 | {
|
---|
83 | const char *pcszClass; // registered PM window class
|
---|
84 | const char *pcszText;
|
---|
85 | // window text (class-specific)
|
---|
86 | // special hacks:
|
---|
87 | // -- For WS_STATIC with SS_BITMAP or SS_ICON set,
|
---|
88 | // you may specify the exact HPOINTER here.
|
---|
89 | // The dlg routine will then subclass the static
|
---|
90 | //
|
---|
91 |
|
---|
92 | ULONG flStyle; // standard window styles
|
---|
93 |
|
---|
94 | USHORT usID; // dlg item ID
|
---|
95 |
|
---|
96 | const char *pcszFont; // font presparam, or NULL for no presparam,
|
---|
97 | // or CTL_COMMON_FONT for standard dialog
|
---|
98 | // font specified on input to dlghCreateDlg
|
---|
99 |
|
---|
100 | USHORT usAdjustPosition;
|
---|
101 | // flags for winhAdjustControls; any combination of
|
---|
102 | // XAC_MOVEX, XAC_MOVEY, XAC_SIZEX, XAC_SIZEY
|
---|
103 | // @@todo not implemented yet
|
---|
104 |
|
---|
105 | SIZEL szlControlProposed;
|
---|
106 | // proposed size; a number of special flags are
|
---|
107 | // available (per cx, cy field):
|
---|
108 | // -- SZL_AUTOSIZE: determine size automatically.
|
---|
109 | // Works only for statics with SS_TEXT and
|
---|
110 | // SS_BITMAP.
|
---|
111 | // This field is IGNORED if the CONTROLDEF appears
|
---|
112 | // with a START_NEW_TABLE type in _DLGHITEM.
|
---|
113 |
|
---|
114 | ULONG ulSpacing; // spacing around control
|
---|
115 |
|
---|
116 | PVOID pvCtlData; // for WinCreateWindow
|
---|
117 |
|
---|
118 | } CONTROLDEF, *PCONTROLDEF;
|
---|
119 |
|
---|
120 | /*
|
---|
121 | *@@ DLGHITEMTYPE:
|
---|
122 | *
|
---|
123 | */
|
---|
124 |
|
---|
125 | typedef enum _DLGHITEMTYPE
|
---|
126 | {
|
---|
127 | TYPE_START_NEW_TABLE, // beginning of a new table; may nest
|
---|
128 | TYPE_START_NEW_ROW, // beginning of a new row in a table
|
---|
129 | TYPE_CONTROL_DEF, // control definition
|
---|
130 | TYPE_END_TABLE // end of a table
|
---|
131 | } DLGHITEMTYPE;
|
---|
132 |
|
---|
133 | // a few handy macros for defining templates
|
---|
134 |
|
---|
135 | #define START_TABLE { TYPE_START_NEW_TABLE, 0 }
|
---|
136 |
|
---|
137 | // this macro is slightly insane, but performs type checking
|
---|
138 | // in case the user gives a pointer which is not of CONTROLDEF
|
---|
139 | #define START_GROUP_TABLE(pDef) { TYPE_START_NEW_TABLE, \
|
---|
140 | ( (ULONG)(&(pDef)->pcszClass) ) }
|
---|
141 |
|
---|
142 | #define END_TABLE { TYPE_END_TABLE, 0 }
|
---|
143 |
|
---|
144 | #define START_ROW(fl) { TYPE_START_NEW_ROW, fl }
|
---|
145 |
|
---|
146 | #define CONTROL_DEF(pDef) { TYPE_CONTROL_DEF, \
|
---|
147 | ( (ULONG)(&(pDef)->pcszClass) ) }
|
---|
148 |
|
---|
149 | /*
|
---|
150 | *@@ DLGHITEM:
|
---|
151 | * dialog format array item.
|
---|
152 | *
|
---|
153 | * An array of these must be passed to dlghCreateDlg
|
---|
154 | * to tell it what controls the dialog contains.
|
---|
155 | * See dlghCreateDlg for details.
|
---|
156 | *
|
---|
157 | */
|
---|
158 |
|
---|
159 | typedef struct _DLGHITEM
|
---|
160 | {
|
---|
161 | DLGHITEMTYPE Type;
|
---|
162 | // one of:
|
---|
163 | // TYPE_START_NEW_TABLE, // beginning of a new table
|
---|
164 | // TYPE_START_NEW_ROW, // beginning of a new row in a table
|
---|
165 | // TYPE_CONTROL_DEF // control definition
|
---|
166 | // TYPE_END_TABLE // end of table
|
---|
167 |
|
---|
168 | ULONG ulData;
|
---|
169 | // -- with TYPE_START_NEW_TABLE: if NULL, this starts
|
---|
170 | // an invisible table (for formatting only).
|
---|
171 | // Otherwise a _CONTROLDEF pointer to specify
|
---|
172 | // a control to be produced around the table.
|
---|
173 | // For example, you can specify a WC_STATIC
|
---|
174 | // with SS_GROUPBOX to create a group around
|
---|
175 | // the table.
|
---|
176 | // -- with TYPE_START_NEW_ROW: ROW_* formatting flags.
|
---|
177 | // -- with TYPE_CONTROL_DEF: _CONTROLDEF pointer to a control definition
|
---|
178 | } DLGHITEM, *PDLGHITEM;
|
---|
179 |
|
---|
180 | /* ******************************************************************
|
---|
181 | *
|
---|
182 | * Macros
|
---|
183 | *
|
---|
184 | ********************************************************************/
|
---|
185 |
|
---|
186 | #define COMMON_SPACING 3
|
---|
187 |
|
---|
188 | #define CONTROLDEF_GROUP(pcsz, id) { WC_STATIC, pcsz, \
|
---|
189 | WS_VISIBLE | SS_GROUPBOX | DT_MNEMONIC, \
|
---|
190 | id, CTL_COMMON_FONT, 0, { -1, -1 }, 0 }
|
---|
191 |
|
---|
192 | #define CONTROLDEF_TEXT(pcsz, id, cx, cy) { WC_STATIC, pcsz, \
|
---|
193 | WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER | DT_MNEMONIC, \
|
---|
194 | id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
|
---|
195 |
|
---|
196 | #define CONTROLDEF_TEXT_WORDBREAK(pcsz, id, cx) { WC_STATIC, pcsz, \
|
---|
197 | WS_VISIBLE | SS_TEXT | DT_LEFT | DT_TOP | DT_WORDBREAK, \
|
---|
198 | id, CTL_COMMON_FONT, 0, {cx, -1}, COMMON_SPACING }
|
---|
199 |
|
---|
200 | #define CONTROLDEF_ICON(hptr, id) { WC_STATIC, (PCSZ)(hptr), \
|
---|
201 | WS_VISIBLE | SS_ICON | DT_LEFT | DT_VCENTER, \
|
---|
202 | id, CTL_COMMON_FONT, 0, {-1, -1}, COMMON_SPACING }
|
---|
203 |
|
---|
204 | #define CONTROLDEF_BITMAP(hbm, id) { WC_STATIC, (PCSZ)(hbm), \
|
---|
205 | WS_VISIBLE | SS_BITMAP | DT_LEFT | DT_VCENTER, \
|
---|
206 | id, CTL_COMMON_FONT, 0, {-1, -1}, COMMON_SPACING }
|
---|
207 |
|
---|
208 | #define CONTROLDEF_DEFPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
|
---|
209 | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT, \
|
---|
210 | id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
|
---|
211 |
|
---|
212 | #define CONTROLDEF_PUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
|
---|
213 | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, \
|
---|
214 | id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
|
---|
215 |
|
---|
216 | #define CONTROLDEF_HELPPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
|
---|
217 | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_HELP, \
|
---|
218 | id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
|
---|
219 |
|
---|
220 | #define CONTROLDEF_AUTOCHECKBOX(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
|
---|
221 | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, \
|
---|
222 | id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
|
---|
223 |
|
---|
224 | #define CONTROLDEF_FIRST_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
|
---|
225 | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON | WS_GROUP, \
|
---|
226 | id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
|
---|
227 |
|
---|
228 | #define CONTROLDEF_NEXT_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
|
---|
229 | WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, \
|
---|
230 | id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
|
---|
231 |
|
---|
232 | #define CONTROLDEF_ENTRYFIELD(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \
|
---|
233 | WS_VISIBLE | WS_TABSTOP | ES_MARGIN | ES_AUTOSCROLL, \
|
---|
234 | id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING + 5 }
|
---|
235 |
|
---|
236 | #define CONTROLDEF_ENTRYFIELD_RO(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \
|
---|
237 | WS_VISIBLE | WS_TABSTOP | ES_MARGIN | ES_READONLY | ES_AUTOSCROLL, \
|
---|
238 | id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING + 5 }
|
---|
239 |
|
---|
240 | #define CONTROLDEF_MLE(pcsz, id, cx, cy) { WC_MLE, pcsz, \
|
---|
241 | WS_VISIBLE | WS_TABSTOP | MLS_BORDER | MLS_IGNORETAB | MLS_WORDWRAP, \
|
---|
242 | id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
|
---|
243 |
|
---|
244 | #define CONTROLDEF_SPINBUTTON(id, cx, cy) { WC_SPINBUTTON, NULL, \
|
---|
245 | WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTCENTER | SPBS_FASTSPIN, \
|
---|
246 | id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
|
---|
247 |
|
---|
248 | /* ******************************************************************
|
---|
249 | *
|
---|
250 | * Dialog formatter entry points
|
---|
251 | *
|
---|
252 | ********************************************************************/
|
---|
253 |
|
---|
254 | APIRET XWPENTRY dlghCreateDlg(HWND *phwndDlg,
|
---|
255 | HWND hwndOwner,
|
---|
256 | ULONG flCreateFlags,
|
---|
257 | PFNWP pfnwpDialogProc,
|
---|
258 | const char *pcszDlgTitle,
|
---|
259 | PDLGHITEM paDlgItems,
|
---|
260 | ULONG cDlgItems,
|
---|
261 | PVOID pCreateParams,
|
---|
262 | const char *pcszControlsFont);
|
---|
263 | typedef APIRET XWPENTRY DLGHCREATEDLG(HWND *phwndDlg,
|
---|
264 | HWND hwndOwner,
|
---|
265 | ULONG flCreateFlags,
|
---|
266 | PFNWP pfnwpDialogProc,
|
---|
267 | const char *pcszDlgTitle,
|
---|
268 | PDLGHITEM paDlgItems,
|
---|
269 | ULONG cDlgItems,
|
---|
270 | PVOID pCreateParams,
|
---|
271 | const char *pcszControlsFont);
|
---|
272 | typedef DLGHCREATEDLG *PDLGHCREATEDLG;
|
---|
273 |
|
---|
274 | APIRET dlghFormatDlg(HWND hwndDlg,
|
---|
275 | PDLGHITEM paDlgItems,
|
---|
276 | ULONG cDlgItems,
|
---|
277 | const char *pcszControlsFont,
|
---|
278 | ULONG flFlags);
|
---|
279 |
|
---|
280 | #define DFFL_RESIZEFRAME 0x0001
|
---|
281 | #define DFFL_CREATECONTROLS 0x0002
|
---|
282 |
|
---|
283 | /* ******************************************************************
|
---|
284 | *
|
---|
285 | * Dialog arrays
|
---|
286 | *
|
---|
287 | ********************************************************************/
|
---|
288 |
|
---|
289 | /*
|
---|
290 | *@@ DLGARRAY:
|
---|
291 | * dialog array structure used with dlghCreateArray.
|
---|
292 | * See remarks there.
|
---|
293 | *
|
---|
294 | *@@added V0.9.16 (2001-10-15) [umoeller]
|
---|
295 | */
|
---|
296 |
|
---|
297 | typedef struct _DLGARRAY
|
---|
298 | {
|
---|
299 | DLGHITEM *paDlgItems; // array of DLGHITEM's, allocated once
|
---|
300 | // by dlghCreateArray
|
---|
301 | ULONG cDlgItemsMax, // copied from dlghCreateArray
|
---|
302 | cDlgItemsNow; // initially 0, raised after each
|
---|
303 | // dlghAppendToArray; pass this to the
|
---|
304 | // dialog formatter
|
---|
305 | } DLGARRAY, *PDLGARRAY;
|
---|
306 |
|
---|
307 | APIRET dlghCreateArray(ULONG cMaxItems,
|
---|
308 | PDLGARRAY *ppArray);
|
---|
309 |
|
---|
310 | APIRET dlghFreeArray(PDLGARRAY *ppArray);
|
---|
311 |
|
---|
312 | APIRET dlghAppendToArray(PDLGARRAY pArray,
|
---|
313 | DLGHITEM *paItems,
|
---|
314 | ULONG cItems);
|
---|
315 |
|
---|
316 | /* ******************************************************************
|
---|
317 | *
|
---|
318 | * Standard dialogs
|
---|
319 | *
|
---|
320 | ********************************************************************/
|
---|
321 |
|
---|
322 | /*
|
---|
323 | *@@ MSGBOXSTRINGS:
|
---|
324 | *
|
---|
325 | *@@added V0.9.13 (2001-06-21) [umoeller]
|
---|
326 | */
|
---|
327 |
|
---|
328 | typedef struct _MSGBOXSTRINGS
|
---|
329 | {
|
---|
330 | const char *pcszYes, // "~Yes"
|
---|
331 | *pcszNo, // "~No"
|
---|
332 | *pcszOK, // "~OK"
|
---|
333 | *pcszCancel, // "~Cancel"
|
---|
334 | *pcszAbort, // "~Abort"
|
---|
335 | *pcszRetry, // "~Retry"
|
---|
336 | *pcszIgnore, // "~Ignore"
|
---|
337 | *pcszEnter,
|
---|
338 | *pcszYesToAll; // "Yes to ~all"
|
---|
339 | } MSGBOXSTRINGS, *PMSGBOXSTRINGS;
|
---|
340 |
|
---|
341 | /* the following are in os2.h somewhere:
|
---|
342 | #define MB_OK 0x0000
|
---|
343 | #define MB_OKCANCEL 0x0001
|
---|
344 | #define MB_RETRYCANCEL 0x0002
|
---|
345 | #define MB_ABORTRETRYIGNORE 0x0003
|
---|
346 | #define MB_YESNO 0x0004
|
---|
347 | #define MB_YESNOCANCEL 0x0005
|
---|
348 | #define MB_CANCEL 0x0006
|
---|
349 | #define MB_ENTER 0x0007
|
---|
350 | #define MB_ENTERCANCEL 0x0008 */
|
---|
351 | // we add:
|
---|
352 | #define MB_YES_YES2ALL_NO 0x0009
|
---|
353 |
|
---|
354 | /* the following are in os2.h somewhere:
|
---|
355 | #define MBID_OK 1
|
---|
356 | #define MBID_CANCEL 2
|
---|
357 | #define MBID_ABORT 3
|
---|
358 | #define MBID_RETRY 4
|
---|
359 | #define MBID_IGNORE 5
|
---|
360 | #define MBID_YES 6
|
---|
361 | #define MBID_NO 7
|
---|
362 | #define MBID_HELP 8
|
---|
363 | #define MBID_ENTER 9 */
|
---|
364 | // we add:
|
---|
365 | #define MBID_YES2ALL 10
|
---|
366 |
|
---|
367 | APIRET dlghCreateMessageBox(HWND *phwndDlg,
|
---|
368 | HWND hwndOwner,
|
---|
369 | HPOINTER hptrIcon,
|
---|
370 | const char *pcszTitle,
|
---|
371 | const char *pcszMessage,
|
---|
372 | ULONG flFlags,
|
---|
373 | const char *pcszFont,
|
---|
374 | const MSGBOXSTRINGS *pStrings,
|
---|
375 | PULONG pulAlarmFlag);
|
---|
376 |
|
---|
377 | ULONG dlghMessageBox(HWND hwndOwner,
|
---|
378 | HPOINTER hptrIcon,
|
---|
379 | const char *pcszTitle,
|
---|
380 | const char *pcszMessage,
|
---|
381 | ULONG flFlags,
|
---|
382 | const char *pcszFont,
|
---|
383 | const MSGBOXSTRINGS *pStrings);
|
---|
384 |
|
---|
385 | #define TEBF_REMOVETILDE 0x0001
|
---|
386 | #define TEBF_REMOVEELLIPSE 0x0002
|
---|
387 | #define TEBF_SELECTALL 0x0004
|
---|
388 |
|
---|
389 | PSZ dlghTextEntryBox(HWND hwndOwner,
|
---|
390 | const char *pcszTitle,
|
---|
391 | const char *pcszDescription,
|
---|
392 | const char *pcszDefault,
|
---|
393 | const char *pcszOK,
|
---|
394 | const char *pcszCancel,
|
---|
395 | ULONG ulMaxLen,
|
---|
396 | ULONG fl,
|
---|
397 | const char *pcszFont);
|
---|
398 |
|
---|
399 | /* ******************************************************************
|
---|
400 | *
|
---|
401 | * Dialog input handlers
|
---|
402 | *
|
---|
403 | ********************************************************************/
|
---|
404 |
|
---|
405 | VOID dlghSetPrevFocus(PVOID pvllWindows);
|
---|
406 |
|
---|
407 | VOID dlghSetNextFocus(PVOID pvllWindows);
|
---|
408 |
|
---|
409 | HWND dlghProcessMnemonic(PVOID pvllWindows,
|
---|
410 | USHORT usch);
|
---|
411 |
|
---|
412 | BOOL dlghEnter(PVOID pvllWindows);
|
---|
413 |
|
---|
414 | #endif
|
---|
415 |
|
---|
416 | #if __cplusplus
|
---|
417 | }
|
---|
418 | #endif
|
---|
419 |
|
---|