source: trunk/include/helpers/dialog.h@ 147

Last change on this file since 147 was 145, checked in by umoeller, 23 years ago

misc changes

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 17.5 KB
Line 
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 M”ller.
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
28extern "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 ((PCSZ)-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 (-1): determine size automatically.
109 // Works only for statics with SS_TEXT and
110 // SS_BITMAP.
111 // -- Any other _negative_ value is considered a
112 // percentage of the largest row width in the
113 // table. For example, -50 would mean 50% of
114 // the largest row in the table. This is valid
115 // for the CX field only.
116 // If the CONTROLDEF appears with a START_NEW_TABLE
117 // type in _DLGHITEM (to specify a group table)
118 // and they are not SZL_AUTOSIZE, they specify the
119 // table size (to override the automatic formatting).
120
121 ULONG ulSpacing; // spacing around control
122
123 PVOID pvCtlData; // for WinCreateWindow
124
125 } CONTROLDEF, *PCONTROLDEF;
126
127 typedef const struct _CONTROLDEF *PCCONTROLDEF;
128
129 /*
130 *@@ DLGHITEMTYPE:
131 *
132 */
133
134 typedef enum _DLGHITEMTYPE
135 {
136 TYPE_START_NEW_TABLE, // beginning of a new table; may nest
137 TYPE_START_NEW_ROW, // beginning of a new row in a table
138 TYPE_CONTROL_DEF, // control definition
139 TYPE_END_TABLE // end of a table
140 } DLGHITEMTYPE;
141
142 // a few handy macros for defining templates
143
144 #define START_TABLE { TYPE_START_NEW_TABLE, 0 }
145
146 // this macro is slightly insane, but performs type checking
147 // in case the user gives a pointer which is not of CONTROLDEF
148 #define START_GROUP_TABLE(pDef) { TYPE_START_NEW_TABLE, \
149 ( (ULONG)(&(pDef)->pcszClass) ) }
150
151 #define END_TABLE { TYPE_END_TABLE, 0 }
152
153 #define START_ROW(fl) { TYPE_START_NEW_ROW, fl }
154
155 #define CONTROL_DEF(pDef) { TYPE_CONTROL_DEF, \
156 ( (ULONG)(&(pDef)->pcszClass) ) }
157
158 /*
159 *@@ DLGHITEM:
160 * dialog format array item.
161 *
162 * An array of these must be passed to dlghCreateDlg
163 * to tell it what controls the dialog contains.
164 * See dlghCreateDlg for details.
165 *
166 */
167
168 typedef struct _DLGHITEM
169 {
170 DLGHITEMTYPE Type;
171 // one of:
172 // TYPE_START_NEW_TABLE, // beginning of a new table
173 // TYPE_START_NEW_ROW, // beginning of a new row in a table
174 // TYPE_CONTROL_DEF // control definition
175 // TYPE_END_TABLE // end of table
176
177 ULONG ulData;
178 // -- with TYPE_START_NEW_TABLE: if NULL, this starts
179 // an invisible table (for formatting only).
180 // Otherwise a _CONTROLDEF pointer to specify
181 // a control to be produced around the table.
182 // For example, you can specify a WC_STATIC
183 // with SS_GROUPBOX to create a group around
184 // the table.
185 // -- with TYPE_START_NEW_ROW: ROW_* formatting flags.
186 // -- with TYPE_CONTROL_DEF: _CONTROLDEF pointer to a control definition
187 } DLGHITEM, *PDLGHITEM;
188
189 typedef const struct _DLGHITEM *PCDLGHITEM;
190
191 /* ******************************************************************
192 *
193 * Macros
194 *
195 ********************************************************************/
196
197 #define COMMON_SPACING 3
198
199 #define CONTROLDEF_GROUP(pcsz, id, cx, cy) { WC_STATIC, pcsz, \
200 WS_VISIBLE | SS_GROUPBOX | DT_MNEMONIC, \
201 id, CTL_COMMON_FONT, 0, { cx, cy }, 0 }
202
203 #define CONTROLDEF_TEXT(pcsz, id, cx, cy) { WC_STATIC, pcsz, \
204 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER | DT_MNEMONIC, \
205 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
206
207 #define CONTROLDEF_TEXT_WORDBREAK(pcsz, id, cx) { WC_STATIC, pcsz, \
208 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_TOP | DT_WORDBREAK, \
209 id, CTL_COMMON_FONT, 0, {cx, -1}, COMMON_SPACING }
210
211 #define CONTROLDEF_ICON(hptr, id) { WC_STATIC, (PCSZ)(hptr), \
212 WS_VISIBLE | SS_ICON | DT_LEFT | DT_VCENTER, \
213 id, CTL_COMMON_FONT, 0, {-1, -1}, COMMON_SPACING }
214
215 #define CONTROLDEF_BITMAP(hbm, id) { WC_STATIC, (PCSZ)(hbm), \
216 WS_VISIBLE | SS_BITMAP | DT_LEFT | DT_VCENTER, \
217 id, CTL_COMMON_FONT, 0, {-1, -1}, COMMON_SPACING }
218
219 #define CONTROLDEF_DEFPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
220 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT, \
221 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
222
223 #define CONTROLDEF_PUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
224 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, \
225 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
226
227 #define CONTROLDEF_HELPPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
228 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_HELP, \
229 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
230
231 #define CONTROLDEF_AUTOCHECKBOX(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
232 WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, \
233 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
234
235 #define CONTROLDEF_FIRST_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
236 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON | WS_GROUP, \
237 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
238
239 #define CONTROLDEF_NEXT_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
240 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, \
241 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
242
243 #define CONTROLDEF_ENTRYFIELD(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \
244 WS_VISIBLE | WS_TABSTOP | ES_MARGIN | ES_AUTOSCROLL, \
245 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
246
247 #define CONTROLDEF_ENTRYFIELD_RO(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \
248 WS_VISIBLE | WS_TABSTOP | ES_MARGIN | ES_READONLY | ES_AUTOSCROLL, \
249 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
250
251 #define CONTROLDEF_MLE(pcsz, id, cx, cy) { WC_MLE, pcsz, \
252 WS_VISIBLE | WS_TABSTOP | MLS_BORDER | MLS_IGNORETAB | MLS_WORDWRAP, \
253 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
254
255 #define CONTROLDEF_LISTBOX(id, cx, cy) { WC_LISTBOX, NULL, \
256 WS_VISIBLE | WS_TABSTOP | LS_HORZSCROLL | LS_NOADJUSTPOS, \
257 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
258
259 #define CONTROLDEF_SPINBUTTON(id, cx, cy) { WC_SPINBUTTON, NULL, \
260 WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTCENTER | SPBS_FASTSPIN, \
261 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
262
263 #define CONTROLDEF_CONTAINER(id, cx, cy) { WC_CONTAINER, NULL, \
264 WS_VISIBLE | WS_TABSTOP | 0, \
265 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
266
267 /* ******************************************************************
268 *
269 * Dialog formatter entry points
270 *
271 ********************************************************************/
272
273 APIRET XWPENTRY dlghCreateDlg(HWND *phwndDlg,
274 HWND hwndOwner,
275 ULONG flCreateFlags,
276 PFNWP pfnwpDialogProc,
277 PCSZ pcszDlgTitle,
278 PCDLGHITEM paDlgItems,
279 ULONG cDlgItems,
280 PVOID pCreateParams,
281 PCSZ pcszControlsFont);
282 typedef APIRET XWPENTRY DLGHCREATEDLG(HWND *phwndDlg,
283 HWND hwndOwner,
284 ULONG flCreateFlags,
285 PFNWP pfnwpDialogProc,
286 PCSZ pcszDlgTitle,
287 PCDLGHITEM paDlgItems,
288 ULONG cDlgItems,
289 PVOID pCreateParams,
290 PCSZ pcszControlsFont);
291 typedef DLGHCREATEDLG *PDLGHCREATEDLG;
292
293 #define DFFL_CREATECONTROLS 0x0002
294
295 APIRET dlghFormatDlg(HWND hwndDlg,
296 PCDLGHITEM paDlgItems,
297 ULONG cDlgItems,
298 PCSZ pcszControlsFont,
299 ULONG flFlags,
300 PSIZEL pszlClient,
301 PVOID *ppllControls);
302
303 VOID dlghResizeFrame(HWND hwndDlg,
304 PSIZEL pszlClient);
305
306 /* ******************************************************************
307 *
308 * Dialog arrays
309 *
310 ********************************************************************/
311
312 /*
313 *@@ DLGARRAY:
314 * dialog array structure used with dlghCreateArray.
315 * See remarks there.
316 *
317 *@@added V0.9.16 (2001-10-15) [umoeller]
318 */
319
320 typedef struct _DLGARRAY
321 {
322 DLGHITEM *paDlgItems; // array of DLGHITEM's, allocated once
323 // by dlghCreateArray
324 ULONG cDlgItemsMax, // copied from dlghCreateArray
325 cDlgItemsNow; // initially 0, raised after each
326 // dlghAppendToArray; pass this to the
327 // dialog formatter
328 } DLGARRAY, *PDLGARRAY;
329
330 APIRET dlghCreateArray(ULONG cMaxItems,
331 PDLGARRAY *ppArray);
332
333 APIRET dlghFreeArray(PDLGARRAY *ppArray);
334
335 APIRET dlghAppendToArray(PDLGARRAY pArray,
336 PCDLGHITEM paItems,
337 ULONG cItems);
338
339 /* ******************************************************************
340 *
341 * Standard dialogs
342 *
343 ********************************************************************/
344
345 /*
346 *@@ MSGBOXSTRINGS:
347 *
348 *@@added V0.9.13 (2001-06-21) [umoeller]
349 */
350
351 typedef struct _MSGBOXSTRINGS
352 {
353 const char *pcszYes, // "~Yes"
354 *pcszNo, // "~No"
355 *pcszOK, // "~OK"
356 *pcszCancel, // "~Cancel"
357 *pcszAbort, // "~Abort"
358 *pcszRetry, // "~Retry"
359 *pcszIgnore, // "~Ignore"
360 *pcszEnter,
361 *pcszYesToAll; // "Yes to ~all"
362 } MSGBOXSTRINGS, *PMSGBOXSTRINGS;
363
364 /* the following are in os2.h somewhere:
365 #define MB_OK 0x0000
366 #define MB_OKCANCEL 0x0001
367 #define MB_RETRYCANCEL 0x0002
368 #define MB_ABORTRETRYIGNORE 0x0003
369 #define MB_YESNO 0x0004
370 #define MB_YESNOCANCEL 0x0005
371 #define MB_CANCEL 0x0006
372 #define MB_ENTER 0x0007
373 #define MB_ENTERCANCEL 0x0008 */
374 // we add:
375 #define MB_YES_YES2ALL_NO 0x0009
376
377 /* the following are in os2.h somewhere:
378 #define MBID_OK 1
379 #define MBID_CANCEL 2
380 #define MBID_ABORT 3
381 #define MBID_RETRY 4
382 #define MBID_IGNORE 5
383 #define MBID_YES 6
384 #define MBID_NO 7
385 #define MBID_HELP 8
386 #define MBID_ENTER 9 */
387 // we add:
388 #define MBID_YES2ALL 10
389
390 APIRET dlghCreateMessageBox(HWND *phwndDlg,
391 HWND hwndOwner,
392 HPOINTER hptrIcon,
393 PCSZ pcszTitle,
394 PCSZ pcszMessage,
395 ULONG flFlags,
396 PCSZ pcszFont,
397 const MSGBOXSTRINGS *pStrings,
398 PULONG pulAlarmFlag);
399
400 ULONG dlghMessageBox(HWND hwndOwner,
401 HPOINTER hptrIcon,
402 PCSZ pcszTitle,
403 PCSZ pcszMessage,
404 ULONG flFlags,
405 PCSZ pcszFont,
406 const MSGBOXSTRINGS *pStrings);
407
408 #define TEBF_REMOVETILDE 0x0001
409 #define TEBF_REMOVEELLIPSE 0x0002
410 #define TEBF_SELECTALL 0x0004
411
412 PSZ dlghTextEntryBox(HWND hwndOwner,
413 PCSZ pcszTitle,
414 PCSZ pcszDescription,
415 PCSZ pcszDefault,
416 PCSZ pcszOK,
417 PCSZ pcszCancel,
418 ULONG ulMaxLen,
419 ULONG fl,
420 PCSZ pcszFont);
421
422 /* ******************************************************************
423 *
424 * Dialog input handlers
425 *
426 ********************************************************************/
427
428 VOID dlghSetPrevFocus(PVOID pvllWindows);
429
430 VOID dlghSetNextFocus(PVOID pvllWindows);
431
432 HWND dlghProcessMnemonic(PVOID pvllWindows,
433 USHORT usch);
434
435 BOOL dlghEnter(PVOID pvllWindows);
436
437#endif
438
439#if __cplusplus
440}
441#endif
442
Note: See TracBrowser for help on using the repository browser.