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

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

Buncha fixes.

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