Created new data types `Filename' and `FontSpec', intended to be
[u/mdw/putty] / winstuff.h
1 /*
2 * winstuff.h: Windows-specific inter-module stuff.
3 */
4
5 #ifndef PUTTY_WINSTUFF_H
6 #define PUTTY_WINSTUFF_H
7
8 #include <stdio.h> /* for FILENAME_MAX */
9
10 struct Filename {
11 char path[FILENAME_MAX];
12 };
13 #define f_open(filename, mode) ( fopen((filename).path, (mode)) )
14
15 struct FontSpec {
16 char name[64];
17 int isbold;
18 int height;
19 int charset;
20 };
21
22 /*
23 * Global variables. Most modules declare these `extern', but
24 * window.c will do `#define PUTTY_DO_GLOBALS' before including this
25 * module, and so will get them properly defined.
26 */
27 #ifndef GLOBAL
28 #ifdef PUTTY_DO_GLOBALS
29 #define GLOBAL
30 #else
31 #define GLOBAL extern
32 #endif
33 #endif
34
35 #ifndef DONE_TYPEDEFS
36 #define DONE_TYPEDEFS
37 typedef struct config_tag Config;
38 typedef struct backend_tag Backend;
39 typedef struct terminal_tag Terminal;
40 #endif
41
42 #define PUTTY_REG_POS "Software\\SimonTatham\\PuTTY"
43 #define PUTTY_REG_PARENT "Software\\SimonTatham"
44 #define PUTTY_REG_PARENT_CHILD "PuTTY"
45 #define PUTTY_REG_GPARENT "Software"
46 #define PUTTY_REG_GPARENT_CHILD "SimonTatham"
47
48 #define GETTICKCOUNT GetTickCount
49 #define CURSORBLINK GetCaretBlinkTime()
50 #define TICKSPERSEC 1000 /* GetTickCount returns milliseconds */
51
52 #define DEFAULT_CODEPAGE CP_ACP
53
54 typedef HDC Context;
55
56 /*
57 * Window handles for the dialog boxes that can be running during a
58 * PuTTY session.
59 */
60 GLOBAL HWND logbox;
61
62 /*
63 * The all-important instance handle.
64 */
65 GLOBAL HINSTANCE hinst;
66
67 /*
68 * Details of the help file.
69 */
70 GLOBAL char *help_path;
71 GLOBAL int help_has_contents;
72
73 /*
74 * The terminal and logging context are notionally local to the
75 * Windows front end, but they must be shared between window.c and
76 * windlg.c. Likewise the saved-sessions list.
77 */
78 GLOBAL Terminal *term;
79 GLOBAL void *logctx;
80
81 /*
82 * I've just looked in the windows standard headr files for WM_USER, there
83 * are hundreds of flags defined using the form WM_USER+123 so I've
84 * renumbered this NETEVENT value and the two in window.c
85 */
86 #define WM_XUSER (WM_USER + 0x2000)
87 #define WM_NETEVENT (WM_XUSER + 5)
88
89 /*
90 * On Windows, we send MA_2CLK as the only event marking the second
91 * press of a mouse button. Compare unix.h.
92 */
93 #define MULTICLICK_ONLY_EVENT 1
94
95 /*
96 * On Windows, data written to the clipboard must be NUL-terminated.
97 */
98 #define SELECTION_NUL_TERMINATED 1
99
100 /*
101 * On Windows, copying to the clipboard terminates lines with CRLF.
102 */
103 #define SEL_NL { 13, 10 }
104
105 /*
106 * sk_getxdmdata() does not exist under Windows (not that I
107 * couldn't write it if I wanted to, but I haven't bothered), so
108 * it's a macro which always returns FALSE. With any luck this will
109 * cause the compiler to notice it can optimise away the
110 * implementation of XDM-AUTHORIZATION-1 in x11fwd.c :-)
111 */
112 #define sk_getxdmdata(socket, ip, port) (0)
113
114 /*
115 * Exports from winctrls.c.
116 */
117
118 struct ctlpos {
119 HWND hwnd;
120 WPARAM font;
121 int dlu4inpix;
122 int ypos, width;
123 int xoff;
124 int boxystart, boxid;
125 char *boxtext;
126 };
127
128 /*
129 * Exports from winutils.c.
130 */
131 void split_into_argv(char *, int *, char ***, char ***);
132
133 /*
134 * Private structure for prefslist state. Only in the header file
135 * so that we can delegate allocation to callers.
136 */
137 struct prefslist {
138 int listid, upbid, dnbid;
139 int srcitem;
140 int dummyitem;
141 int dragging;
142 };
143
144 /*
145 * Exports from winctrls.c.
146 */
147 void ctlposinit(struct ctlpos *cp, HWND hwnd,
148 int leftborder, int rightborder, int topborder);
149 HWND doctl(struct ctlpos *cp, RECT r,
150 char *wclass, int wstyle, int exstyle, char *wtext, int wid);
151 void bartitle(struct ctlpos *cp, char *name, int id);
152 void beginbox(struct ctlpos *cp, char *name, int idbox);
153 void endbox(struct ctlpos *cp);
154 void multiedit(struct ctlpos *cp, ...);
155 void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...);
156 void bareradioline(struct ctlpos *cp, int nacross, ...);
157 void radiobig(struct ctlpos *cp, char *text, int id, ...);
158 void checkbox(struct ctlpos *cp, char *text, int id);
159 void statictext(struct ctlpos *cp, char *text, int lines, int id);
160 void staticbtn(struct ctlpos *cp, char *stext, int sid,
161 char *btext, int bid);
162 void static2btn(struct ctlpos *cp, char *stext, int sid,
163 char *btext1, int bid1, char *btext2, int bid2);
164 void staticedit(struct ctlpos *cp, char *stext,
165 int sid, int eid, int percentedit);
166 void staticddl(struct ctlpos *cp, char *stext,
167 int sid, int lid, int percentlist);
168 void combobox(struct ctlpos *cp, char *text, int staticid, int listid);
169 void staticpassedit(struct ctlpos *cp, char *stext,
170 int sid, int eid, int percentedit);
171 void bigeditctrl(struct ctlpos *cp, char *stext,
172 int sid, int eid, int lines);
173 void ersatztab(struct ctlpos *cp, char *stext, int sid, int lid, int s2id);
174 void editbutton(struct ctlpos *cp, char *stext, int sid,
175 int eid, char *btext, int bid);
176 void sesssaver(struct ctlpos *cp, char *text,
177 int staticid, int editid, int listid, ...);
178 void envsetter(struct ctlpos *cp, char *stext, int sid,
179 char *e1stext, int e1sid, int e1id,
180 char *e2stext, int e2sid, int e2id,
181 int listid, char *b1text, int b1id, char *b2text, int b2id);
182 void charclass(struct ctlpos *cp, char *stext, int sid, int listid,
183 char *btext, int bid, int eid, char *s2text, int s2id);
184 void colouredit(struct ctlpos *cp, char *stext, int sid, int listid,
185 char *btext, int bid, ...);
186 void prefslist(struct prefslist *hdl, struct ctlpos *cp, char *stext,
187 int sid, int listid, int upbid, int dnbid);
188 int handle_prefslist(struct prefslist *hdl,
189 int *array, int maxmemb,
190 int is_dlmsg, HWND hwnd,
191 WPARAM wParam, LPARAM lParam);
192 void progressbar(struct ctlpos *cp, int id);
193 void fwdsetter(struct ctlpos *cp, int listid, char *stext, int sid,
194 char *e1stext, int e1sid, int e1id,
195 char *e2stext, int e2sid, int e2id,
196 char *btext, int bid,
197 char *r1text, int r1id, char *r2text, int r2id);
198
199 /*
200 * Exports from windlg.c.
201 */
202 void defuse_showwindow(void);
203 int do_config(void);
204 int do_reconfig(HWND);
205 void showeventlog(HWND);
206 void showabout(HWND);
207 void force_normal(HWND hwnd);
208
209 /*
210 * Exports from sizetip.c.
211 */
212 void UpdateSizeTip(HWND src, int cx, int cy);
213 void EnableSizeTip(int bEnable);
214
215 /*
216 * Exports from unicode.c.
217 */
218 struct unicode_data;
219 void init_ucs(Config *, struct unicode_data *);
220
221 #endif