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 "dialog.h"
|
---|
12 | */
|
---|
13 |
|
---|
14 | /* Copyright (C) 2001 Ulrich Mller.
|
---|
15 | * This file is part of the "XWorkplace helpers" source package.
|
---|
16 | * This is free software; you can redistribute it and/or modify
|
---|
17 | * it under the terms of the GNU General Public License as published
|
---|
18 | * by the Free Software Foundation, in version 2 as it comes in the
|
---|
19 | * "COPYING" file of the XWorkplace main distribution.
|
---|
20 | * This program is distributed in the hope that it will be useful,
|
---|
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
23 | * GNU General Public License for more details.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #if __cplusplus
|
---|
27 | extern "C" {
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | #ifndef DIALOG_HEADER_INCLUDED
|
---|
31 | #define DIALOG_HEADER_INCLUDED
|
---|
32 |
|
---|
33 | #ifndef NULL_POINT
|
---|
34 | #define NULL_POINT {0, 0}
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | /* ******************************************************************
|
---|
38 | *
|
---|
39 | * Error codes
|
---|
40 | *
|
---|
41 | ********************************************************************/
|
---|
42 |
|
---|
43 | #define DLGERR_FIRST 10000
|
---|
44 | #define DLGERR_ROW_BEFORE_TABLE (DLGERR_FIRST)
|
---|
45 | #define DLGERR_CONTROL_BEFORE_ROW (DLGERR_FIRST + 1)
|
---|
46 | #define DLGERR_NULL_CTL_DEF (DLGERR_FIRST + 2)
|
---|
47 | #define DLGERR_CANNOT_CREATE_FRAME (DLGERR_FIRST + 3)
|
---|
48 | #define DLGERR_INVALID_CODE (DLGERR_FIRST + 4)
|
---|
49 | #define DLGERR_TABLE_NOT_CLOSED (DLGERR_FIRST + 5)
|
---|
50 | #define DLGERR_TOO_MANY_TABLES_CLOSED (DLGERR_FIRST + 6)
|
---|
51 |
|
---|
52 | /* ******************************************************************
|
---|
53 | *
|
---|
54 | * Structures
|
---|
55 | *
|
---|
56 | ********************************************************************/
|
---|
57 |
|
---|
58 | #define SZL_AUTOSIZE (-1)
|
---|
59 |
|
---|
60 | #define CTL_COMMON_FONT ((const char *)-1)
|
---|
61 |
|
---|
62 | #define ROW_VALIGN_MASK 0x0003
|
---|
63 | #define ROW_VALIGN_BOTTOM 0x0000
|
---|
64 | #define ROW_VALIGN_CENTER 0x0001
|
---|
65 | #define ROW_VALIGN_TOP 0x0002
|
---|
66 |
|
---|
67 | /*
|
---|
68 | *@@ CONTROLDEF:
|
---|
69 | * defines a single control. Used
|
---|
70 | * with the TYPE_CONTROL_DEF type in
|
---|
71 | * DLGHITEM.
|
---|
72 | *
|
---|
73 | */
|
---|
74 |
|
---|
75 | typedef struct _CONTROLDEF
|
---|
76 | {
|
---|
77 | const char *pcszClass; // registered PM window class
|
---|
78 | const char *pcszText;
|
---|
79 | // window text (class-specific)
|
---|
80 | // special hacks:
|
---|
81 | // -- For WS_STATIC with SS_BITMAP or SS_ICON set,
|
---|
82 | // you may specify the exact HPOINTER here.
|
---|
83 | // The dlg routine will then subclass the static
|
---|
84 | //
|
---|
85 |
|
---|
86 | ULONG flStyle; // standard window styles
|
---|
87 |
|
---|
88 | USHORT usID; // dlg item ID
|
---|
89 |
|
---|
90 | const char *pcszFont; // font presparam, or NULL for no presparam,
|
---|
91 | // or CTL_COMMON_FONT for standard dialog
|
---|
92 | // font specified on input to dlghCreateDlg
|
---|
93 |
|
---|
94 | USHORT usAdjustPosition;
|
---|
95 | // flags for winhAdjustControls; any combination of
|
---|
96 | // XAC_MOVEX, XAC_MOVEY, XAC_SIZEX, XAC_SIZEY
|
---|
97 |
|
---|
98 | SIZEL szlControlProposed;
|
---|
99 | // proposed size; a number of special flags are
|
---|
100 | // available (per cx, cy field):
|
---|
101 | // -- SZL_AUTOSIZE: determine size automatically.
|
---|
102 | // Works only for statics with SS_TEXT and
|
---|
103 | // SS_BITMAP.
|
---|
104 | // This field is IGNORED if the CONTROLDEF appears
|
---|
105 | // with a START_NEW_TABLE type in _DLGHITEM.
|
---|
106 |
|
---|
107 | ULONG ulSpacing; // spacing around control
|
---|
108 |
|
---|
109 | } CONTROLDEF, *PCONTROLDEF;
|
---|
110 |
|
---|
111 | /*
|
---|
112 | *@@ DLGHITEMTYPE:
|
---|
113 | *
|
---|
114 | */
|
---|
115 |
|
---|
116 | typedef enum _DLGHITEMTYPE
|
---|
117 | {
|
---|
118 | TYPE_START_NEW_TABLE, // beginning of a new table; may nest
|
---|
119 | TYPE_START_NEW_ROW, // beginning of a new row in a table
|
---|
120 | TYPE_CONTROL_DEF, // control definition
|
---|
121 | TYPE_END_TABLE // end of a table
|
---|
122 | } DLGHITEMTYPE;
|
---|
123 |
|
---|
124 | // a few handy macros for defining templates
|
---|
125 |
|
---|
126 | #define START_TABLE { TYPE_START_NEW_TABLE, 0 }
|
---|
127 |
|
---|
128 | // this macro is slightly insane, but performs type checking
|
---|
129 | // in case the user gives a pointer which is not of CONTROLDEF
|
---|
130 | #define START_GROUP_TABLE(pDef) { TYPE_START_NEW_TABLE, \
|
---|
131 | ( (ULONG)(&(pDef)->pcszClass) ) }
|
---|
132 |
|
---|
133 | #define END_TABLE { TYPE_END_TABLE, 0 }
|
---|
134 |
|
---|
135 | #define START_ROW(fl) { TYPE_START_NEW_ROW, fl }
|
---|
136 |
|
---|
137 | #define CONTROL_DEF(pDef) { TYPE_CONTROL_DEF, \
|
---|
138 | ( (ULONG)(&(pDef)->pcszClass) ) }
|
---|
139 |
|
---|
140 | /*
|
---|
141 | *@@ DLGHITEM:
|
---|
142 | * dialog format array item.
|
---|
143 | *
|
---|
144 | * An array of these must be passed to dlghCreateDlg
|
---|
145 | * to tell it what controls the dialog contains.
|
---|
146 | * See dlghCreateDlg for details.
|
---|
147 | *
|
---|
148 | */
|
---|
149 |
|
---|
150 | typedef struct _DLGHITEM
|
---|
151 | {
|
---|
152 | DLGHITEMTYPE Type;
|
---|
153 | // one of:
|
---|
154 | // TYPE_START_NEW_TABLE, // beginning of a new table
|
---|
155 | // TYPE_START_NEW_ROW, // beginning of a new row in a table
|
---|
156 | // TYPE_CONTROL_DEF // control definition
|
---|
157 | // TYPE_END_TABLE // end of table
|
---|
158 |
|
---|
159 | ULONG ulData;
|
---|
160 | // -- with TYPE_START_NEW_TABLE: if NULL, this starts
|
---|
161 | // an invisible table (for formatting only).
|
---|
162 | // Otherwise a _CONTROLDEF pointer to specify
|
---|
163 | // a control to be produced around the table.
|
---|
164 | // For example, you can specify a WC_STATIC
|
---|
165 | // with SS_GROUPBOX to create a group around
|
---|
166 | // the table.
|
---|
167 | // -- with TYPE_START_NEW_ROW: ROW_* formatting flags.
|
---|
168 | // -- with TYPE_CONTROL_DEF: _CONTROLDEF pointer to a control definition
|
---|
169 | } DLGHITEM, *PDLGHITEM;
|
---|
170 |
|
---|
171 | /* ******************************************************************
|
---|
172 | *
|
---|
173 | * APIs
|
---|
174 | *
|
---|
175 | ********************************************************************/
|
---|
176 |
|
---|
177 | APIRET dlghCreateDlg(HWND *phwndDlg,
|
---|
178 | HWND hwndOwner,
|
---|
179 | ULONG flCreateFlags,
|
---|
180 | PFNWP pfnwpDialogProc,
|
---|
181 | const char *pcszDlgTitle,
|
---|
182 | PDLGHITEM paDlgItems,
|
---|
183 | ULONG cDlgItems,
|
---|
184 | PVOID pCreateParams,
|
---|
185 | const char *pcszControlsFont);
|
---|
186 |
|
---|
187 | #endif
|
---|
188 |
|
---|
189 | #if __cplusplus
|
---|
190 | }
|
---|
191 | #endif
|
---|
192 |
|
---|