8c3cd914 |
1 | /* |
2 | * winstuff.h: Windows-specific inter-module stuff. |
3 | */ |
4 | |
f7f27309 |
5 | #ifndef PUTTY_WINSTUFF_H |
6 | #define PUTTY_WINSTUFF_H |
7 | |
9a30e26b |
8 | #include <stdio.h> /* for FILENAME_MAX */ |
9 | |
fe8abbf4 |
10 | #include "tree234.h" |
11 | |
12 | #include "winhelp.h" |
13 | |
9a30e26b |
14 | struct Filename { |
15 | char path[FILENAME_MAX]; |
16 | }; |
17 | #define f_open(filename, mode) ( fopen((filename).path, (mode)) ) |
18 | |
19 | struct FontSpec { |
20 | char name[64]; |
21 | int isbold; |
22 | int height; |
23 | int charset; |
24 | }; |
25 | |
8c3cd914 |
26 | /* |
27 | * Global variables. Most modules declare these `extern', but |
28 | * window.c will do `#define PUTTY_DO_GLOBALS' before including this |
29 | * module, and so will get them properly defined. |
30 | */ |
f7f27309 |
31 | #ifndef GLOBAL |
8c3cd914 |
32 | #ifdef PUTTY_DO_GLOBALS |
33 | #define GLOBAL |
34 | #else |
35 | #define GLOBAL extern |
36 | #endif |
f7f27309 |
37 | #endif |
38 | |
a8327734 |
39 | #ifndef DONE_TYPEDEFS |
40 | #define DONE_TYPEDEFS |
41 | typedef struct config_tag Config; |
42 | typedef struct backend_tag Backend; |
43 | typedef struct terminal_tag Terminal; |
44 | #endif |
45 | |
f7f27309 |
46 | #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY" |
47 | #define PUTTY_REG_PARENT "Software\\SimonTatham" |
48 | #define PUTTY_REG_PARENT_CHILD "PuTTY" |
49 | #define PUTTY_REG_GPARENT "Software" |
50 | #define PUTTY_REG_GPARENT_CHILD "SimonTatham" |
51 | |
52 | #define GETTICKCOUNT GetTickCount |
53 | #define CURSORBLINK GetCaretBlinkTime() |
54 | #define TICKSPERSEC 1000 /* GetTickCount returns milliseconds */ |
55 | |
56 | #define DEFAULT_CODEPAGE CP_ACP |
57 | |
58 | typedef HDC Context; |
8c3cd914 |
59 | |
f7f27309 |
60 | /* |
61 | * Window handles for the dialog boxes that can be running during a |
62 | * PuTTY session. |
63 | */ |
64 | GLOBAL HWND logbox; |
65 | |
66 | /* |
67 | * The all-important instance handle. |
68 | */ |
8c3cd914 |
69 | GLOBAL HINSTANCE hinst; |
70 | |
71 | /* |
6b78788a |
72 | * Details of the help file. |
73 | */ |
74 | GLOBAL char *help_path; |
75 | GLOBAL int help_has_contents; |
76 | |
77 | /* |
a8327734 |
78 | * The terminal and logging context are notionally local to the |
79 | * Windows front end, but they must be shared between window.c and |
0b4f0bc0 |
80 | * windlg.c. Likewise the saved-sessions list. |
a8327734 |
81 | */ |
82 | GLOBAL Terminal *term; |
83 | GLOBAL void *logctx; |
84 | |
85 | /* |
f7f27309 |
86 | * I've just looked in the windows standard headr files for WM_USER, there |
87 | * are hundreds of flags defined using the form WM_USER+123 so I've |
88 | * renumbered this NETEVENT value and the two in window.c |
89 | */ |
90 | #define WM_XUSER (WM_USER + 0x2000) |
91 | #define WM_NETEVENT (WM_XUSER + 5) |
92 | |
93 | /* |
e6346999 |
94 | * On Windows, we send MA_2CLK as the only event marking the second |
95 | * press of a mouse button. Compare unix.h. |
96 | */ |
97 | #define MULTICLICK_ONLY_EVENT 1 |
98 | |
99 | /* |
100 | * On Windows, data written to the clipboard must be NUL-terminated. |
101 | */ |
102 | #define SELECTION_NUL_TERMINATED 1 |
103 | |
104 | /* |
0f351587 |
105 | * On Windows, copying to the clipboard terminates lines with CRLF. |
106 | */ |
107 | #define SEL_NL { 13, 10 } |
108 | |
109 | /* |
2f92b717 |
110 | * sk_getxdmdata() does not exist under Windows (not that I |
111 | * couldn't write it if I wanted to, but I haven't bothered), so |
112 | * it's a macro which always returns FALSE. With any luck this will |
113 | * cause the compiler to notice it can optimise away the |
114 | * implementation of XDM-AUTHORIZATION-1 in x11fwd.c :-) |
115 | */ |
116 | #define sk_getxdmdata(socket, ip, port) (0) |
117 | |
118 | /* |
fe8abbf4 |
119 | * File-selector filter strings used in the config box. On Windows, |
120 | * these strings are of exactly the type needed to go in |
121 | * `lpstrFilter' in an OPENFILENAME structure. |
122 | */ |
123 | #define FILTER_KEY_FILES ("PuTTY Private Key Files (*.ppk)\0*.ppk\0" \ |
124 | "All Files (*.*)\0*\0\0\0") |
125 | #define FILTER_WAVE_FILES ("Wave Files (*.wav)\0*.WAV\0" \ |
126 | "All Files (*.*)\0*\0\0\0") |
127 | |
128 | /* |
8c3cd914 |
129 | * Exports from winctrls.c. |
130 | */ |
131 | |
132 | struct ctlpos { |
133 | HWND hwnd; |
134 | WPARAM font; |
135 | int dlu4inpix; |
136 | int ypos, width; |
137 | int xoff; |
3ac9cd9f |
138 | int boxystart, boxid; |
8c3cd914 |
139 | char *boxtext; |
140 | }; |
141 | |
ca20bfcf |
142 | /* |
c0a81592 |
143 | * Exports from winutils.c. |
144 | */ |
d3a1a808 |
145 | void split_into_argv(char *, int *, char ***, char ***); |
c0a81592 |
146 | |
147 | /* |
ca20bfcf |
148 | * Private structure for prefslist state. Only in the header file |
149 | * so that we can delegate allocation to callers. |
150 | */ |
151 | struct prefslist { |
152 | int listid, upbid, dnbid; |
153 | int srcitem; |
154 | int dummyitem; |
155 | int dragging; |
156 | }; |
157 | |
f7f27309 |
158 | /* |
fe8abbf4 |
159 | * This structure is passed to event handler functions as the `dlg' |
160 | * parameter, and hence is passed back to winctrls access functions. |
161 | */ |
162 | struct dlgparam { |
163 | HWND hwnd; /* the hwnd of the dialog box */ |
164 | struct winctrls *controltrees[8]; /* can have several of these */ |
165 | int nctrltrees; |
166 | char *errtitle; /* title of error sub-messageboxes */ |
167 | void *data; /* data to pass in refresh events */ |
168 | union control *focused, *lastfocused; /* which ctrl has focus now/before */ |
4e6d4091 |
169 | char shortcuts[128]; /* track which shortcuts in use */ |
fe8abbf4 |
170 | int coloursel_wanted; /* has an event handler asked for |
171 | * a colour selector? */ |
fe8abbf4 |
172 | struct { unsigned char r, g, b, ok; } coloursel_result; /* 0-255 */ |
4e6d4091 |
173 | tree234 *privdata; /* stores per-control private data */ |
fe8abbf4 |
174 | int ended, endresult; /* has the dialog been ended? */ |
175 | }; |
176 | |
177 | /* |
f7f27309 |
178 | * Exports from winctrls.c. |
179 | */ |
8c3cd914 |
180 | void ctlposinit(struct ctlpos *cp, HWND hwnd, |
32874aea |
181 | int leftborder, int rightborder, int topborder); |
ca20bfcf |
182 | HWND doctl(struct ctlpos *cp, RECT r, |
32874aea |
183 | char *wclass, int wstyle, int exstyle, char *wtext, int wid); |
8c3cd914 |
184 | void bartitle(struct ctlpos *cp, char *name, int id); |
3ac9cd9f |
185 | void beginbox(struct ctlpos *cp, char *name, int idbox); |
8c3cd914 |
186 | void endbox(struct ctlpos *cp); |
fe8abbf4 |
187 | void multiedit(struct ctlpos *cp, int password, ...); |
32874aea |
188 | void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...); |
d74d141c |
189 | void bareradioline(struct ctlpos *cp, int nacross, ...); |
8c3cd914 |
190 | void radiobig(struct ctlpos *cp, char *text, int id, ...); |
191 | void checkbox(struct ctlpos *cp, char *text, int id); |
66ee282a |
192 | void statictext(struct ctlpos *cp, char *text, int lines, int id); |
8c3cd914 |
193 | void staticbtn(struct ctlpos *cp, char *stext, int sid, |
32874aea |
194 | char *btext, int bid); |
af282e3b |
195 | void static2btn(struct ctlpos *cp, char *stext, int sid, |
196 | char *btext1, int bid1, char *btext2, int bid2); |
8c3cd914 |
197 | void staticedit(struct ctlpos *cp, char *stext, |
32874aea |
198 | int sid, int eid, int percentedit); |
2c9c6388 |
199 | void staticddl(struct ctlpos *cp, char *stext, |
200 | int sid, int lid, int percentlist); |
b8ae1f0f |
201 | void combobox(struct ctlpos *cp, char *text, int staticid, int listid); |
6e522441 |
202 | void staticpassedit(struct ctlpos *cp, char *stext, |
32874aea |
203 | int sid, int eid, int percentedit); |
6e522441 |
204 | void bigeditctrl(struct ctlpos *cp, char *stext, |
32874aea |
205 | int sid, int eid, int lines); |
206 | void ersatztab(struct ctlpos *cp, char *stext, int sid, int lid, int s2id); |
8c3cd914 |
207 | void editbutton(struct ctlpos *cp, char *stext, int sid, |
32874aea |
208 | int eid, char *btext, int bid); |
8c3cd914 |
209 | void sesssaver(struct ctlpos *cp, char *text, |
32874aea |
210 | int staticid, int editid, int listid, ...); |
8c3cd914 |
211 | void envsetter(struct ctlpos *cp, char *stext, int sid, |
32874aea |
212 | char *e1stext, int e1sid, int e1id, |
213 | char *e2stext, int e2sid, int e2id, |
214 | int listid, char *b1text, int b1id, char *b2text, int b2id); |
8c3cd914 |
215 | void charclass(struct ctlpos *cp, char *stext, int sid, int listid, |
32874aea |
216 | char *btext, int bid, int eid, char *s2text, int s2id); |
8c3cd914 |
217 | void colouredit(struct ctlpos *cp, char *stext, int sid, int listid, |
32874aea |
218 | char *btext, int bid, ...); |
fe8abbf4 |
219 | void prefslist(struct prefslist *hdl, struct ctlpos *cp, int lines, |
220 | char *stext, int sid, int listid, int upbid, int dnbid); |
ca20bfcf |
221 | int handle_prefslist(struct prefslist *hdl, |
222 | int *array, int maxmemb, |
223 | int is_dlmsg, HWND hwnd, |
224 | WPARAM wParam, LPARAM lParam); |
6e522441 |
225 | void progressbar(struct ctlpos *cp, int id); |
d74d141c |
226 | void fwdsetter(struct ctlpos *cp, int listid, char *stext, int sid, |
227 | char *e1stext, int e1sid, int e1id, |
228 | char *e2stext, int e2sid, int e2id, |
a4b92c62 |
229 | char *btext, int bid, |
230 | char *r1text, int r1id, char *r2text, int r2id); |
f7f27309 |
231 | |
fe8abbf4 |
232 | #define MAX_SHORTCUTS_PER_CTRL 16 |
233 | |
234 | /* |
235 | * This structure is what's stored for each `union control' in the |
236 | * portable-dialog interface. |
237 | */ |
238 | struct winctrl { |
239 | union control *ctrl; |
240 | /* |
241 | * The control may have several components at the Windows |
242 | * level, with different dialog IDs. To avoid needing N |
243 | * separate platformsidectrl structures (which could be stored |
244 | * separately in a tree234 so that lookup by ID worked), we |
245 | * impose the constraint that those IDs must be in a contiguous |
246 | * block. |
247 | */ |
248 | int base_id; |
249 | int num_ids; |
250 | /* |
251 | * Remember what keyboard shortcuts were used by this control, |
252 | * so that when we remove it again we can take them out of the |
253 | * list in the dlgparam. |
254 | */ |
255 | char shortcuts[MAX_SHORTCUTS_PER_CTRL]; |
256 | /* |
257 | * Some controls need a piece of allocated memory in which to |
258 | * store temporary data about the control. |
259 | */ |
260 | void *data; |
261 | }; |
262 | /* |
263 | * And this structure holds a set of the above, in two separate |
264 | * tree234s so that it can find an item by `union control' or by |
265 | * dialog ID. |
266 | */ |
267 | struct winctrls { |
268 | tree234 *byctrl, *byid; |
269 | }; |
d1582b2e |
270 | struct controlset; |
271 | struct controlbox; |
272 | |
fe8abbf4 |
273 | void winctrl_init(struct winctrls *); |
274 | void winctrl_cleanup(struct winctrls *); |
275 | void winctrl_add(struct winctrls *, struct winctrl *); |
276 | void winctrl_remove(struct winctrls *, struct winctrl *); |
277 | struct winctrl *winctrl_findbyctrl(struct winctrls *, union control *); |
278 | struct winctrl *winctrl_findbyid(struct winctrls *, int); |
279 | struct winctrl *winctrl_findbyindex(struct winctrls *, int); |
280 | void winctrl_layout(struct dlgparam *dp, struct winctrls *wc, |
281 | struct ctlpos *cp, struct controlset *s, int *id); |
282 | int winctrl_handle_command(struct dlgparam *dp, UINT msg, |
283 | WPARAM wParam, LPARAM lParam); |
d1582b2e |
284 | void winctrl_rem_shortcuts(struct dlgparam *dp, struct winctrl *c); |
285 | int winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id); |
286 | |
4e6d4091 |
287 | void dp_init(struct dlgparam *dp); |
288 | void dp_add_tree(struct dlgparam *dp, struct winctrls *tree); |
289 | void dp_cleanup(struct dlgparam *dp); |
290 | |
d1582b2e |
291 | /* |
292 | * Exports from wincfg.c. |
293 | */ |
294 | void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help, |
295 | int midsession); |
fe8abbf4 |
296 | |
f7f27309 |
297 | /* |
298 | * Exports from windlg.c. |
299 | */ |
300 | void defuse_showwindow(void); |
301 | int do_config(void); |
302 | int do_reconfig(HWND); |
f7f27309 |
303 | void showeventlog(HWND); |
304 | void showabout(HWND); |
f7f27309 |
305 | void force_normal(HWND hwnd); |
d1582b2e |
306 | void modal_about_box(HWND hwnd); |
307 | void show_help(HWND hwnd); |
f7f27309 |
308 | |
f7f27309 |
309 | /* |
310 | * Exports from sizetip.c. |
311 | */ |
312 | void UpdateSizeTip(HWND src, int cx, int cy); |
313 | void EnableSizeTip(int bEnable); |
314 | |
facd762c |
315 | /* |
316 | * Exports from unicode.c. |
317 | */ |
07b2a9cd |
318 | struct unicode_data; |
21d2b241 |
319 | void init_ucs(Config *, struct unicode_data *); |
facd762c |
320 | |
f7f27309 |
321 | #endif |