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

Last change on this file since 104 was 104, 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: 13.0 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 CONTROLDEF_GROUP(pcsz, id) { WC_STATIC, pcsz, \
183 WS_VISIBLE | SS_GROUPBOX | DT_MNEMONIC, \
184 id, CTL_COMMON_FONT, 0, { -1, -1 }, 0 }
185
186 #define CONTROLDEF_TEXT(pcsz, id, cx, cy) { WC_STATIC, pcsz, \
187 WS_VISIBLE | SS_TEXT | DT_LEFT | DT_VCENTER | DT_MNEMONIC, \
188 id, CTL_COMMON_FONT, 0, {cx, cy}, 5 }
189
190 #define CONTROLDEF_DEFPUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
191 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT, \
192 id, CTL_COMMON_FONT, 0, {cx, cy}, 5 }
193
194 #define CONTROLDEF_PUSHBUTTON(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
195 WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, \
196 id, CTL_COMMON_FONT, 0, {cx, cy}, 5 }
197
198 #define CONTROLDEF_AUTOCHECKBOX(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
199 WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, \
200 id, CTL_COMMON_FONT, 0, { cx, cy }, 5 }
201
202 #define CONTROLDEF_FIRST_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
203 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON | WS_GROUP, \
204 id, CTL_COMMON_FONT, 0, { cx, cy }, 5 }
205
206 #define CONTROLDEF_NEXT_AUTORADIO(pcsz, id, cx, cy) { WC_BUTTON, pcsz, \
207 WS_VISIBLE | WS_TABSTOP | BS_AUTORADIOBUTTON, \
208 id, CTL_COMMON_FONT, 0, { cx, cy }, 5 }
209
210 #define CONTROLDEF_ENTRYFIELD(pcsz, id, cx, cy) { WC_ENTRYFIELD, pcsz, \
211 WS_VISIBLE | WS_TABSTOP | ES_MARGIN, \
212 id, CTL_COMMON_FONT, 0, { cx, cy }, 5 }
213
214 #define CONTROLDEF_SPINBUTTON(id, cx, cy) { WC_SPINBUTTON, NULL, \
215 WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | SPBS_NUMERICONLY | SPBS_JUSTCENTER | SPBS_FASTSPIN, \
216 id, CTL_COMMON_FONT, 0, {cx, cy}, 5 }
217
218 /* ******************************************************************
219 *
220 * APIs
221 *
222 ********************************************************************/
223
224 APIRET XWPENTRY dlghCreateDlg(HWND *phwndDlg,
225 HWND hwndOwner,
226 ULONG flCreateFlags,
227 PFNWP pfnwpDialogProc,
228 const char *pcszDlgTitle,
229 PDLGHITEM paDlgItems,
230 ULONG cDlgItems,
231 PVOID pCreateParams,
232 const char *pcszControlsFont);
233 typedef APIRET XWPENTRY DLGHCREATEDLG(HWND *phwndDlg,
234 HWND hwndOwner,
235 ULONG flCreateFlags,
236 PFNWP pfnwpDialogProc,
237 const char *pcszDlgTitle,
238 PDLGHITEM paDlgItems,
239 ULONG cDlgItems,
240 PVOID pCreateParams,
241 const char *pcszControlsFont);
242 typedef DLGHCREATEDLG *PDLGHCREATEDLG;
243
244 /*
245 *@@ MSGBOXSTRINGS:
246 *
247 *@@added V0.9.13 (2001-06-21) [umoeller]
248 */
249
250 typedef struct _MSGBOXSTRINGS
251 {
252 const char *pcszYes, // "~Yes"
253 *pcszNo, // "~No"
254 *pcszOK, // "~OK"
255 *pcszCancel, // "~Cancel"
256 *pcszAbort, // "~Abort"
257 *pcszRetry, // "~Retry"
258 *pcszIgnore, // "~Ignore"
259 *pcszEnter,
260 *pcszYesToAll; // "Yes to ~all"
261 } MSGBOXSTRINGS, *PMSGBOXSTRINGS;
262
263 /* the following are in os2.h somewhere:
264 #define MB_OK 0x0000
265 #define MB_OKCANCEL 0x0001
266 #define MB_RETRYCANCEL 0x0002
267 #define MB_ABORTRETRYIGNORE 0x0003
268 #define MB_YESNO 0x0004
269 #define MB_YESNOCANCEL 0x0005
270 #define MB_CANCEL 0x0006
271 #define MB_ENTER 0x0007
272 #define MB_ENTERCANCEL 0x0008 */
273 // we add:
274 #define MB_YES_YES2ALL_NO 0x0009
275
276 /* the following are in os2.h somewhere:
277 #define MBID_OK 1
278 #define MBID_CANCEL 2
279 #define MBID_ABORT 3
280 #define MBID_RETRY 4
281 #define MBID_IGNORE 5
282 #define MBID_YES 6
283 #define MBID_NO 7
284 #define MBID_HELP 8
285 #define MBID_ENTER 9 */
286 // we add:
287 #define MBID_YES2ALL 10
288
289 APIRET dlghCreateMessageBox(HWND *phwndDlg,
290 HWND hwndOwner,
291 HPOINTER hptrIcon,
292 const char *pcszTitle,
293 const char *pcszMessage,
294 ULONG flFlags,
295 const char *pcszFont,
296 const MSGBOXSTRINGS *pStrings,
297 PULONG pulAlarmFlag);
298
299 ULONG dlghMessageBox(HWND hwndOwner,
300 HPOINTER hptrIcon,
301 const char *pcszTitle,
302 const char *pcszMessage,
303 ULONG flFlags,
304 const char *pcszFont,
305 const MSGBOXSTRINGS *pStrings);
306
307 #define TEBF_REMOVETILDE 0x0001
308 #define TEBF_REMOVEELLIPSE 0x0002
309 #define TEBF_SELECTALL 0x0004
310
311 PSZ dlghTextEntryBox(HWND hwndOwner,
312 const char *pcszTitle,
313 const char *pcszDescription,
314 const char *pcszDefault,
315 const char *pcszOK,
316 const char *pcszCancel,
317 ULONG ulMaxLen,
318 ULONG fl,
319 const char *pcszFont);
320
321 VOID dlghSetPrevFocus(PVOID pvllWindows);
322
323 VOID dlghSetNextFocus(PVOID pvllWindows);
324
325 HWND dlghProcessMnemonic(PVOID pvllWindows,
326 USHORT usch);
327
328 BOOL dlghEnter(PVOID pvllWindows);
329
330#endif
331
332#if __cplusplus
333}
334#endif
335
Note: See TracBrowser for help on using the repository browser.