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

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

Misc helpers updates.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 13.7 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
54 /* ******************************************************************
55 *
56 * Structures
57 *
58 ********************************************************************/
59
60 #define SZL_AUTOSIZE (-1)
61
62 #define CTL_COMMON_FONT ((const char *)-1)
63
64 #define ROW_VALIGN_MASK 0x0003
65 #define ROW_VALIGN_BOTTOM 0x0000
66 #define ROW_VALIGN_CENTER 0x0001
67 #define ROW_VALIGN_TOP 0x0002
68
69 /*
70 *@@ CONTROLDEF:
71 * defines a single control. Used
72 * with the TYPE_CONTROL_DEF type in
73 * DLGHITEM.
74 *
75 *@@changed V0.9.12 (2001-05-31) [umoeller]: added control data
76 */
77
78 typedef struct _CONTROLDEF
79 {
80 const char *pcszClass; // registered PM window class
81 const char *pcszText;
82 // window text (class-specific)
83 // special hacks:
84 // -- For WS_STATIC with SS_BITMAP or SS_ICON set,
85 // you may specify the exact HPOINTER here.
86 // The dlg routine will then subclass the static
87 //
88
89 ULONG flStyle; // standard window styles
90
91 USHORT usID; // dlg item ID
92
93 const char *pcszFont; // font presparam, or NULL for no presparam,
94 // or CTL_COMMON_FONT for standard dialog
95 // font specified on input to dlghCreateDlg
96
97 USHORT usAdjustPosition;
98 // flags for winhAdjustControls; any combination of
99 // XAC_MOVEX, XAC_MOVEY, XAC_SIZEX, XAC_SIZEY
100
101 SIZEL szlControlProposed;
102 // proposed size; a number of special flags are
103 // available (per cx, cy field):
104 // -- SZL_AUTOSIZE: determine size automatically.
105 // Works only for statics with SS_TEXT and
106 // SS_BITMAP.
107 // This field is IGNORED if the CONTROLDEF appears
108 // with a START_NEW_TABLE type in _DLGHITEM.
109
110 ULONG ulSpacing; // spacing around control
111
112 PVOID pvCtlData; // for WinCreateWindow
113
114 } CONTROLDEF, *PCONTROLDEF;
115
116 /*
117 *@@ DLGHITEMTYPE:
118 *
119 */
120
121 typedef enum _DLGHITEMTYPE
122 {
123 TYPE_START_NEW_TABLE, // beginning of a new table; may nest
124 TYPE_START_NEW_ROW, // beginning of a new row in a table
125 TYPE_CONTROL_DEF, // control definition
126 TYPE_END_TABLE // end of a table
127 } DLGHITEMTYPE;
128
129 // a few handy macros for defining templates
130
131 #define START_TABLE { TYPE_START_NEW_TABLE, 0 }
132
133 // this macro is slightly insane, but performs type checking
134 // in case the user gives a pointer which is not of CONTROLDEF
135 #define START_GROUP_TABLE(pDef) { TYPE_START_NEW_TABLE, \
136 ( (ULONG)(&(pDef)->pcszClass) ) }
137
138 #define END_TABLE { TYPE_END_TABLE, 0 }
139
140 #define START_ROW(fl) { TYPE_START_NEW_ROW, fl }
141
142 #define CONTROL_DEF(pDef) { TYPE_CONTROL_DEF, \
143 ( (ULONG)(&(pDef)->pcszClass) ) }
144
145 /*
146 *@@ DLGHITEM:
147 * dialog format array item.
148 *
149 * An array of these must be passed to dlghCreateDlg
150 * to tell it what controls the dialog contains.
151 * See dlghCreateDlg for details.
152 *
153 */
154
155 typedef struct _DLGHITEM
156 {
157 DLGHITEMTYPE Type;
158 // one of:
159 // TYPE_START_NEW_TABLE, // beginning of a new table
160 // TYPE_START_NEW_ROW, // beginning of a new row in a table
161 // TYPE_CONTROL_DEF // control definition
162 // TYPE_END_TABLE // end of table
163
164 ULONG ulData;
165 // -- with TYPE_START_NEW_TABLE: if NULL, this starts
166 // an invisible table (for formatting only).
167 // Otherwise a _CONTROLDEF pointer to specify
168 // a control to be produced around the table.
169 // For example, you can specify a WC_STATIC
170 // with SS_GROUPBOX to create a group around
171 // the table.
172 // -- with TYPE_START_NEW_ROW: ROW_* formatting flags.
173 // -- with TYPE_CONTROL_DEF: _CONTROLDEF pointer to a control definition
174 } DLGHITEM, *PDLGHITEM;
175
176 /* ******************************************************************
177 *
178 * Macros
179 *
180 ********************************************************************/
181
182 #define COMMON_SPACING 3
183
184 #define CONTROLDEF_GROUP(pcsz, id) { WC_STATIC, pcsz, \
185 WS_VISIBLE | SS_GROUPBOX | DT_MNEMONIC, \
186 id, CTL_COMMON_FONT, 0, { -1, -1 }, 0 }
187
188 #define CONTROLDEF_TEXT(pcsz, id, cx, cy) { WC_STATIC, pcsz, \
189 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER | DT_MNEMONIC, \
190 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
191
192 #define CONTROLDEF_DEFPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
193 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT, \
194 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
195
196 #define CONTROLDEF_PUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
197 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, \
198 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
199
200 #define CONTROLDEF_HELPPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
201 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_HELP, \
202 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
203
204 #define CONTROLDEF_AUTOCHECKBOX(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
205 WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, \
206 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
207
208 #define CONTROLDEF_FIRST_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
209 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON | WS_GROUP, \
210 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
211
212 #define CONTROLDEF_NEXT_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
213 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, \
214 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
215
216 #define CONTROLDEF_ENTRYFIELD(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \
217 WS_VISIBLE | WS_TABSTOP | ES_MARGIN, \
218 id, CTL_COMMON_FONT, 0, { cx, cy }, COMMON_SPACING }
219
220 #define CONTROLDEF_SPINBUTTON(id, cx, cy) { WC_SPINBUTTON, NULL, \
221 WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTCENTER | SPBS_FASTSPIN, \
222 id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING }
223
224 /* ******************************************************************
225 *
226 * APIs
227 *
228 ********************************************************************/
229
230 APIRET XWPENTRY dlghCreateDlg(HWND *phwndDlg,
231 HWND hwndOwner,
232 ULONG flCreateFlags,
233 PFNWP pfnwpDialogProc,
234 const char *pcszDlgTitle,
235 PDLGHITEM paDlgItems,
236 ULONG cDlgItems,
237 PVOID pCreateParams,
238 const char *pcszControlsFont);
239 typedef APIRET XWPENTRY DLGHCREATEDLG(HWND *phwndDlg,
240 HWND hwndOwner,
241 ULONG flCreateFlags,
242 PFNWP pfnwpDialogProc,
243 const char *pcszDlgTitle,
244 PDLGHITEM paDlgItems,
245 ULONG cDlgItems,
246 PVOID pCreateParams,
247 const char *pcszControlsFont);
248 typedef DLGHCREATEDLG *PDLGHCREATEDLG;
249
250 APIRET dlghFormatDlg(HWND hwndDlg,
251 PDLGHITEM paDlgItems,
252 ULONG cDlgItems,
253 const char *pcszControlsFont,
254 ULONG flFlags);
255
256 #define DFFL_RESIZEFRAME 0x0001
257 #define DFFL_CREATECONTROLS 0x0002
258
259 /*
260 *@@ MSGBOXSTRINGS:
261 *
262 *@@added V0.9.13 (2001-06-21) [umoeller]
263 */
264
265 typedef struct _MSGBOXSTRINGS
266 {
267 const char *pcszYes, // "~Yes"
268 *pcszNo, // "~No"
269 *pcszOK, // "~OK"
270 *pcszCancel, // "~Cancel"
271 *pcszAbort, // "~Abort"
272 *pcszRetry, // "~Retry"
273 *pcszIgnore, // "~Ignore"
274 *pcszEnter,
275 *pcszYesToAll; // "Yes to ~all"
276 } MSGBOXSTRINGS, *PMSGBOXSTRINGS;
277
278 /* the following are in os2.h somewhere:
279 #define MB_OK 0x0000
280 #define MB_OKCANCEL 0x0001
281 #define MB_RETRYCANCEL 0x0002
282 #define MB_ABORTRETRYIGNORE 0x0003
283 #define MB_YESNO 0x0004
284 #define MB_YESNOCANCEL 0x0005
285 #define MB_CANCEL 0x0006
286 #define MB_ENTER 0x0007
287 #define MB_ENTERCANCEL 0x0008 */
288 // we add:
289 #define MB_YES_YES2ALL_NO 0x0009
290
291 /* the following are in os2.h somewhere:
292 #define MBID_OK 1
293 #define MBID_CANCEL 2
294 #define MBID_ABORT 3
295 #define MBID_RETRY 4
296 #define MBID_IGNORE 5
297 #define MBID_YES 6
298 #define MBID_NO 7
299 #define MBID_HELP 8
300 #define MBID_ENTER 9 */
301 // we add:
302 #define MBID_YES2ALL 10
303
304 APIRET dlghCreateMessageBox(HWND *phwndDlg,
305 HWND hwndOwner,
306 HPOINTER hptrIcon,
307 const char *pcszTitle,
308 const char *pcszMessage,
309 ULONG flFlags,
310 const char *pcszFont,
311 const MSGBOXSTRINGS *pStrings,
312 PULONG pulAlarmFlag);
313
314 ULONG dlghMessageBox(HWND hwndOwner,
315 HPOINTER hptrIcon,
316 const char *pcszTitle,
317 const char *pcszMessage,
318 ULONG flFlags,
319 const char *pcszFont,
320 const MSGBOXSTRINGS *pStrings);
321
322 #define TEBF_REMOVETILDE 0x0001
323 #define TEBF_REMOVEELLIPSE 0x0002
324 #define TEBF_SELECTALL 0x0004
325
326 PSZ dlghTextEntryBox(HWND hwndOwner,
327 const char *pcszTitle,
328 const char *pcszDescription,
329 const char *pcszDefault,
330 const char *pcszOK,
331 const char *pcszCancel,
332 ULONG ulMaxLen,
333 ULONG fl,
334 const char *pcszFont);
335
336 VOID dlghSetPrevFocus(PVOID pvllWindows);
337
338 VOID dlghSetNextFocus(PVOID pvllWindows);
339
340 HWND dlghProcessMnemonic(PVOID pvllWindows,
341 USHORT usch);
342
343 BOOL dlghEnter(PVOID pvllWindows);
344
345#endif
346
347#if __cplusplus
348}
349#endif
350
Note: See TracBrowser for help on using the repository browser.