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

Last change on this file since 115 was 111, 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.1 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 ((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_DEFPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
201 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT, \
202 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
203
204 #define CONTROLDEF_PUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
205 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, \
206 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
207
208 #define CONTROLDEF_HELPPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
209 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_HELP, \
210 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
211
212 #define CONTROLDEF_AUTOCHECKBOX(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
213 WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, \
214 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
215
216 #define CONTROLDEF_FIRST_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
217 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON | WS_GROUP, \
218 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
219
220 #define CONTROLDEF_NEXT_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
221 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, \
222 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
223
224 #define CONTROLDEF_ENTRYFIELD(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \
225 WS_VISIBLE | WS_TABSTOP | ES_MARGIN | ES_AUTOSCROLL, \
226 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING + 5 }
227
228 #define CONTROLDEF_ENTRYFIELD_RO(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \
229 WS_VISIBLE | WS_TABSTOP | ES_MARGIN | ES_READONLY | ES_AUTOSCROLL, \
230 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING + 5 }
231
232 #define CONTROLDEF_MLE(pcsz, id, cx, cy) { WC_MLE, pcsz, \
233 WS_VISIBLE | WS_TABSTOP | MLS_BORDER | MLS_IGNORETAB | MLS_WORDWRAP, \
234 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
235
236 #define CONTROLDEF_SPINBUTTON(id, cx, cy) { WC_SPINBUTTON, NULL, \
237 WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTCENTER | SPBS_FASTSPIN, \
238 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
239
240 /* ******************************************************************
241 *
242 * Dialog formatter entry points
243 *
244 ********************************************************************/
245
246 APIRET XWPENTRY dlghCreateDlg(HWND *phwndDlg,
247 HWND hwndOwner,
248 ULONG flCreateFlags,
249 PFNWP pfnwpDialogProc,
250 const char *pcszDlgTitle,
251 PDLGHITEM paDlgItems,
252 ULONG cDlgItems,
253 PVOID pCreateParams,
254 const char *pcszControlsFont);
255 typedef APIRET XWPENTRY DLGHCREATEDLG(HWND *phwndDlg,
256 HWND hwndOwner,
257 ULONG flCreateFlags,
258 PFNWP pfnwpDialogProc,
259 const char *pcszDlgTitle,
260 PDLGHITEM paDlgItems,
261 ULONG cDlgItems,
262 PVOID pCreateParams,
263 const char *pcszControlsFont);
264 typedef DLGHCREATEDLG *PDLGHCREATEDLG;
265
266 APIRET dlghFormatDlg(HWND hwndDlg,
267 PDLGHITEM paDlgItems,
268 ULONG cDlgItems,
269 const char *pcszControlsFont,
270 ULONG flFlags);
271
272 #define DFFL_RESIZEFRAME 0x0001
273 #define DFFL_CREATECONTROLS 0x0002
274
275 /* ******************************************************************
276 *
277 * Dialog arrays
278 *
279 ********************************************************************/
280
281 /*
282 *@@ DLGARRAY:
283 * dialog array structure used with dlghCreateArray.
284 * See remarks there.
285 *
286 *@@added V0.9.16 (2001-10-15) [umoeller]
287 */
288
289 typedef struct _DLGARRAY
290 {
291 DLGHITEM *paDlgItems; // array of DLGHITEM's, allocated once
292 // by dlghCreateArray
293 ULONG cDlgItemsMax, // copied from dlghCreateArray
294 cDlgItemsNow; // initially 0, raised after each
295 // dlghAppendToArray; pass this to the
296 // dialog formatter
297 } DLGARRAY, *PDLGARRAY;
298
299 APIRET dlghCreateArray(ULONG cMaxItems,
300 PDLGARRAY *ppArray);
301
302 APIRET dlghFreeArray(PDLGARRAY *ppArray);
303
304 APIRET dlghAppendToArray(PDLGARRAY pArray,
305 DLGHITEM *paItems,
306 ULONG cItems);
307
308 /* ******************************************************************
309 *
310 * Standard dialogs
311 *
312 ********************************************************************/
313
314 /*
315 *@@ MSGBOXSTRINGS:
316 *
317 *@@added V0.9.13 (2001-06-21) [umoeller]
318 */
319
320 typedef struct _MSGBOXSTRINGS
321 {
322 const char *pcszYes, // "~Yes"
323 *pcszNo, // "~No"
324 *pcszOK, // "~OK"
325 *pcszCancel, // "~Cancel"
326 *pcszAbort, // "~Abort"
327 *pcszRetry, // "~Retry"
328 *pcszIgnore, // "~Ignore"
329 *pcszEnter,
330 *pcszYesToAll; // "Yes to ~all"
331 } MSGBOXSTRINGS, *PMSGBOXSTRINGS;
332
333 /* the following are in os2.h somewhere:
334 #define MB_OK 0x0000
335 #define MB_OKCANCEL 0x0001
336 #define MB_RETRYCANCEL 0x0002
337 #define MB_ABORTRETRYIGNORE 0x0003
338 #define MB_YESNO 0x0004
339 #define MB_YESNOCANCEL 0x0005
340 #define MB_CANCEL 0x0006
341 #define MB_ENTER 0x0007
342 #define MB_ENTERCANCEL 0x0008 */
343 // we add:
344 #define MB_YES_YES2ALL_NO 0x0009
345
346 /* the following are in os2.h somewhere:
347 #define MBID_OK 1
348 #define MBID_CANCEL 2
349 #define MBID_ABORT 3
350 #define MBID_RETRY 4
351 #define MBID_IGNORE 5
352 #define MBID_YES 6
353 #define MBID_NO 7
354 #define MBID_HELP 8
355 #define MBID_ENTER 9 */
356 // we add:
357 #define MBID_YES2ALL 10
358
359 APIRET dlghCreateMessageBox(HWND *phwndDlg,
360 HWND hwndOwner,
361 HPOINTER hptrIcon,
362 const char *pcszTitle,
363 const char *pcszMessage,
364 ULONG flFlags,
365 const char *pcszFont,
366 const MSGBOXSTRINGS *pStrings,
367 PULONG pulAlarmFlag);
368
369 ULONG dlghMessageBox(HWND hwndOwner,
370 HPOINTER hptrIcon,
371 const char *pcszTitle,
372 const char *pcszMessage,
373 ULONG flFlags,
374 const char *pcszFont,
375 const MSGBOXSTRINGS *pStrings);
376
377 #define TEBF_REMOVETILDE 0x0001
378 #define TEBF_REMOVEELLIPSE 0x0002
379 #define TEBF_SELECTALL 0x0004
380
381 PSZ dlghTextEntryBox(HWND hwndOwner,
382 const char *pcszTitle,
383 const char *pcszDescription,
384 const char *pcszDefault,
385 const char *pcszOK,
386 const char *pcszCancel,
387 ULONG ulMaxLen,
388 ULONG fl,
389 const char *pcszFont);
390
391 /* ******************************************************************
392 *
393 * Dialog input handlers
394 *
395 ********************************************************************/
396
397 VOID dlghSetPrevFocus(PVOID pvllWindows);
398
399 VOID dlghSetNextFocus(PVOID pvllWindows);
400
401 HWND dlghProcessMnemonic(PVOID pvllWindows,
402 USHORT usch);
403
404 BOOL dlghEnter(PVOID pvllWindows);
405
406#endif
407
408#if __cplusplus
409}
410#endif
411
Note: See TracBrowser for help on using the repository browser.