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

Last change on this file since 133 was 132, checked in by umoeller, 24 years ago

Misc changes.

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