Initial release of Maemo 5 port of gnuplot
[gnuplot] / src / win / wgnuplib.h
1 /*
2  * $Id: wgnuplib.h,v 1.24 2006/03/05 01:15:56 broeker Exp $
3  */
4
5 /* GNUPLOT - win/wgnuplib.h */
6
7 /*[
8  * Copyright 1982 - 1993, 1998, 2004   Russell Lang
9  *
10  * Permission to use, copy, and distribute this software and its
11  * documentation for any purpose with or without fee is hereby granted,
12  * provided that the above copyright notice appear in all copies and
13  * that both that copyright notice and this permission notice appear
14  * in supporting documentation.
15  *
16  * Permission to modify the software is granted, but not the right to
17  * distribute the complete modified source code.  Modifications are to
18  * be distributed as patches to the released version.  Permission to
19  * distribute binaries produced by compiling modified sources is granted,
20  * provided you
21  *   1. distribute the corresponding source modifications from the
22  *    released version in the form of a patch file along with the binaries,
23  *   2. add special version identification to distinguish your version
24  *    in addition to the base release version number,
25  *   3. provide your name and address as the primary contact for the
26  *    support of your modified version, and
27  *   4. retain our contact information in regard to use of the base
28  *    software.
29  * Permission to distribute the released version of the source code along
30  * with corresponding source modifications in the form of a patch file is
31  * granted with same provisions 2 through 4 for binary distributions.
32  *
33  * This software is provided "as is" without express or implied warranty
34  * to the extent permitted by applicable law.
35 ]*/
36
37 /*
38  * AUTHORS
39  *
40  *   Russell Lang
41  */
42
43 /* this file contains items to be visible outside wgnuplot.dll */
44
45 #include <windows.h>
46
47 #ifdef _WINDOWS
48 #define _Windows
49 #endif
50
51 /* HBB 19990506: The following used to be #ifdef __DLL__.
52  * But  _export is needed outside the DLL, as well. The long-standing
53  * bug crashing 16bit wgnuplot on Alt-F4 or pressing the 'close' button
54  * stemmed here.  */
55 #ifndef WIN32
56 #define WINEXPORT _export
57 #else
58 #define WINEXPORT
59 #endif
60
61 /* Functions flagged WDPROC are to be export by the DLL, so they can be called
62  * directly from win.trm or the gnuplot core */
63 #define WDPROC WINAPI WINEXPORT
64
65 /* HBB: bumped version for pointsize, linewidth and PM3D implementation */
66 /* HBB: bumped version for massive changes due to mouse-ing and removal of
67  *      variables no longer needed, in struct GW */
68 /* HBB: bumped version because of changes in PM3D interface and pointtypes */
69 /* HBB: bumped version for filledboxes support */
70 /* HBB: bumped version for larger NUMMENU in wresourc.h */
71 #define WGNUPLOTVERSION  "1.6   2003-01-23"
72 BOOL WDPROC CheckWGNUPLOTVersion(LPSTR str);
73
74 /* ================================== */
75 /* symbols for the two icons          */
76 #define TEXTICON 123
77 #define GRPICON 124
78
79 /* ================================== */
80 /* For WIN32 API's */
81 #ifdef WIN32
82 /* #define DEFAULT_CHARSET ANSI_CHARSET */
83 # define OFFSETOF(x)  (x)
84 # define SELECTOROF(x)  (x)
85 # define MoveTo(hdc,x,y) MoveToEx(hdc,x,y,(LPPOINT)NULL);
86 # if !defined(__TURBOC__) || (__TURBOC__>=0x410) /* Borland C has these defines, already... */
87 #  define farmalloc(x) malloc(x)
88 #  define farrealloc(s,n) realloc(s,n)
89 #  define farfree(s) free(s)
90 # endif /* __TURBOC__ */
91 #endif
92
93 #if defined(__MINGW32__) && (__GNUC__ < 3) && !defined(CYGWIN)
94 /* windowsx.h in MinGW32 2.x doesn't define some of the more traditional
95  * things gnuplot expects in every Windows C compiler, it seems: */
96 #define _fstrstr(s1,s2) (strstr(s1,s2))
97 #define _fstrchr(s,c) (strchr(s,c))
98 #define _fstrrchr(s,c) (strrchr(s,c))
99 #define _fstrlen(s) (strlen(s))
100 #define _fstrcpy(d,s) (strcpy(d,s))
101 #define _fstrncpy(d,s,n) (strncpy(d,s,n))
102 #define _fstrcat(s1,s2) (strcat(s1,s2))
103 #endif /* __MINGW32__ */
104
105 /* ================================== */
106 /* wprinter.c - windows printer routines */
107 void WDPROC DumpPrinter(HWND hwnd, LPSTR szAppName, LPSTR szFileName);
108
109
110 typedef struct tagPRINT {
111         HDC             hdcPrn;
112         HWND    hDlgPrint;
113         BOOL    bUserAbort;
114         POINT   pdef;
115         POINT   psize;
116         POINT   poff;
117         struct tagPRINT FAR *next;
118 } GP_PRINT;
119 typedef GP_PRINT FAR*  GP_LPPRINT;
120
121
122 /* ================================== */
123 /* wpause.c - pause window structure */
124 typedef struct tagPW
125 {
126         HINSTANCE       hInstance;              /* required */
127         HINSTANCE       hPrevInstance;  /* required */
128         LPSTR   Title;                  /* required */
129         LPSTR   Message;                /* required */
130         POINT   Origin;                 /* optional */
131         HWND    hWndParent;             /* optional */
132         HWND    hWndPause;
133         HWND    hOK;
134         HWND    hCancel;
135         BOOL    bPause;
136         BOOL    bPauseCancel;
137         BOOL    bDefOK;
138         WNDPROC lpfnOK;
139         WNDPROC lpfnCancel;
140         WNDPROC lpfnPauseButtonProc;
141 } PW;
142 typedef PW FAR*  LPPW;
143
144 int WDPROC PauseBox(LPPW lppw);
145
146 /* ================================== */
147 /* wmenu.c - menu structure */
148 #define BUTTONMAX 10
149 typedef struct tagMW
150 {
151         LPSTR   szMenuName;             /* required */
152         HMENU   hMenu;
153         BYTE FAR * FAR *macro;
154         BYTE FAR *macrobuf;
155         int             nCountMenu;
156         DLGPROC lpProcInput;
157         char    *szPrompt;
158         char    *szAnswer;
159         int             nChar;
160         int             nButton;
161         HWND    hButton[BUTTONMAX];
162         int             hButtonID[BUTTONMAX];
163         WNDPROC lpfnMenuButtonProc;
164         WNDPROC lpfnButtonProc[BUTTONMAX];
165 } MW;
166 typedef MW FAR * LPMW;
167
168 /* ================================== */
169 /* wtext.c text window structure */
170 /* If an optional item is not specified it must be zero */
171 #define MAXFONTNAME 80
172 typedef struct tagTW
173 {
174         GP_LPPRINT      lpr;                    /* must be first */
175         HINSTANCE hInstance;            /* required */
176         HINSTANCE hPrevInstance;        /* required */
177         LPSTR   Title;                  /* required */
178         LPMW    lpmw;                   /* optional */
179         POINT   ScreenSize;             /* optional */
180         unsigned int KeyBufSize;        /* optional */
181         LPSTR   IniFile;                /* optional */
182         LPSTR   IniSection;             /* optional */
183         LPSTR   DragPre;                /* optional */
184         LPSTR   DragPost;               /* optional */
185         int             nCmdShow;               /* optional */
186         FARPROC shutdown;               /* optional */
187         HICON   hIcon;                  /* optional */
188         LPSTR   AboutText;              /* optional */
189         HMENU   hPopMenu;
190         HWND    hWndText;
191         HWND    hWndParent;
192         POINT   Origin;
193         POINT   Size;
194         BYTE FAR *ScreenBuffer;
195         BYTE FAR *AttrBuffer;
196         BYTE FAR *KeyBuf;
197         BYTE FAR *KeyBufIn;
198         BYTE FAR *KeyBufOut;
199         BYTE    Attr;
200         BOOL    bFocus;
201         BOOL    bGetCh;
202         BOOL    bSysColors;
203         HBRUSH  hbrBackground;
204         char    fontname[MAXFONTNAME];  /* font name */
205         int             fontsize;                               /* font size in pts */
206         HFONT   hfont;
207         int             CharAscent;
208         int             ButtonHeight;
209         int             CaretHeight;
210         int             CursorFlag;
211         POINT   CursorPos;
212         POINT   ClientSize;
213         POINT   CharSize;
214         POINT   ScrollPos;
215         POINT   ScrollMax;
216         POINT   MarkBegin;
217         POINT   MarkEnd;
218         BOOL    Marking;
219 } TW;
220 typedef TW FAR*  LPTW;
221
222
223 /* ================================== */
224 /* wtext.c - Text Window */
225 void WDPROC TextMessage(void);
226 int WDPROC TextInit(LPTW lptw);
227 void WDPROC TextClose(LPTW lptw);
228 void WDPROC TextToCursor(LPTW lptw);
229 int WDPROC  TextKBHit(LPTW);
230 int WDPROC TextGetCh(LPTW);
231 int WDPROC TextGetChE(LPTW);
232 LPSTR WDPROC TextGetS(LPTW lptw, LPSTR str, unsigned int size);
233 int WDPROC TextPutCh(LPTW, BYTE);
234 int WDPROC TextPutS(LPTW lptw, LPSTR str);
235 void WDPROC TextGotoXY(LPTW lptw, int x, int y);
236 int  WDPROC TextWhereX(LPTW lptw);
237 int  WDPROC TextWhereY(LPTW lptw);
238 void WDPROC TextCursorHeight(LPTW lptw, int height);
239 void WDPROC TextClearEOL(LPTW lptw);
240 void WDPROC TextClearEOS(LPTW lptw);
241 void WDPROC TextInsertLine(LPTW lptw);
242 void WDPROC TextDeleteLine(LPTW lptw);
243 void WDPROC TextScrollReverse(LPTW lptw);
244 void WDPROC TextAttr(LPTW lptw, BYTE attr);
245 void WDPROC AboutBox(HWND hwnd, LPSTR str);
246
247 /* ================================== */
248 /* wgraph.c - graphics window */
249
250 /* windows data */
251
252 /* number of different 'basic' pens supported (the ones you can modify
253  * by the 'Line styles...' dialog, and save to/from wgnuplot.ini). */
254 #define WGNUMPENS 15
255
256 /* Information about one graphical operation to be stored by the
257  * driver for the sake of redraws. Array of GWOP kept in global block */
258 struct GWOP {
259         WORD op;
260         WORD x, y;
261         HLOCAL htext;
262 };
263
264 /* memory block for graph operations */
265 struct GWOPBLK {                        /* kept in local memory */
266         struct GWOPBLK *next;
267         HGLOBAL hblk;                   /* handle to a global block */
268         struct GWOP FAR *gwop;  /* pointer to global block if locked */
269         UINT used;                              /* number of GWOP's used */
270 };
271
272 /* ops */
273 #define W_endoflist 0
274
275 #define W_dot 10
276 #define W_plus 11
277 #define W_cross 12
278 #define W_star 13
279 #define W_box 14
280 #define W_fbox 15
281 #define W_circle 16
282 #define W_fcircle 17
283 #define W_itriangle 18
284 #define W_fitriangle 19
285 #define W_triangle 20
286 #define W_ftriangle 21
287 #define W_diamond 22
288 #define W_fdiamond 23
289 #define W_pentagon 24
290 #define W_fpentagon 25
291
292 #define W_move 30
293 #define W_vect 31
294 #define W_line_type 32
295 #define W_put_text 33
296 #define W_justify 34
297 #define W_text_angle 35
298 #define W_pointsize 36
299 #define W_line_width 37
300 #define W_pm3d_setcolor 38
301 #define W_pm3d_filled_polygon_pt   39
302 #define W_pm3d_filled_polygon_draw 40
303 #define W_boxfill 41
304 #define W_fillstyle 42          /* NOTE HBB 20010916: used #if _FILLEDBOXES */
305 #define W_font 43
306 #define W_image 50
307
308 typedef struct tagGW {
309         GP_LPPRINT      lpr;            /* must be first */
310         HINSTANCE hInstance;    /* required */
311         HINSTANCE hPrevInstance;        /* required */
312         LPSTR   Title;          /* required */
313         int     xmax;           /* required */
314         int     ymax;           /* required */
315         LPTW    lptw;           /* optional */  /* associated text window */
316         POINT   Origin;         /* optional */  /* origin of graph window */
317         POINT   Size;           /* optional */  /* size of graph window */
318         LPSTR   IniFile;        /* optional */
319         LPSTR   IniSection;     /* optional */
320         HWND    hWndGraph;      /* window handle */
321         HMENU   hPopMenu;       /* popup menu */
322         int     pen;            /* current pen number */
323         int     htic;           /* horizontal size of point symbol (xmax units) */
324         int     vtic;           /* vertical size of point symbol (ymax units)*/
325         int     hchar;          /* horizontal size of character (xmax units) */
326         int     vchar;          /* vertical size of character (ymax units)*/
327         int     angle;          /* text angle */
328         BOOL    rotate;         /* can text be rotated 90 degrees ? */
329         char    fontname[MAXFONTNAME];  /* font name */
330         int     fontsize;       /* font size in pts */
331         char    deffontname[MAXFONTNAME]; /* default font name */
332         int     deffontsize;    /* default font size */
333         HFONT   hfonth;         /* horizonal font */
334         HFONT   hfontv;         /* rotated font (arbitrary angle) */
335         LOGFONT lf;             /* cached to speed up rotated fonts */
336         BOOL    resized;        /* has graph window been resized? */
337         BOOL    graphtotop;     /* bring graph window to top after every plot? */
338         BOOL    color;          /* color pens? */
339         HPEN    hapen;          /* stored current pen */
340         LOGPEN  colorpen[WGNUMPENS+2];  /* color pen definitions */
341         LOGPEN  monopen[WGNUMPENS+2];   /* mono pen definitions */
342         COLORREF background;            /* background color */
343         HBRUSH  hbrush;         /* background brush */
344         HBRUSH  colorbrush[WGNUMPENS+2];   /* brushes to fill points */
345         struct GWOPBLK *gwopblk_head;
346         struct GWOPBLK *gwopblk_tail;
347         unsigned int nGWOP;
348         BOOL    locked;         /* locked if being written */
349         double  org_pointsize;  /* Original Pointsize */
350 } GW;
351 typedef GW FAR*  LPGW;
352
353 #define WINFONTSIZE 10
354 #define WIN30FONT "Courier"
355 #define WINFONT "Arial"
356
357 #if 0
358 enum JUSTIFY {
359         LEFT, CENTRE, RIGHT
360 };
361 #endif
362
363 void WDPROC GraphInit(LPGW lpgw);
364 void WDPROC GraphClose(LPGW lpgw);
365 void WDPROC GraphStart(LPGW lpgw, double pointsize);
366 void WDPROC GraphEnd(LPGW lpgw);
367 void WDPROC GraphResume(LPGW lpgw);
368 void WDPROC GraphOp(LPGW lpgw, WORD op, WORD x, WORD y, LPCSTR str);
369 void WDPROC GraphOpSize(LPGW lpgw, WORD op, WORD x, WORD y, LPCSTR str, DWORD size);
370 void WDPROC GraphPrint(LPGW lpgw);
371 void WDPROC GraphRedraw(LPGW lpgw);
372 void WDPROC GraphChangeFont(LPGW lpgw, LPCSTR font, int fontsize, HDC hdc, RECT rect);
373 unsigned int WDPROC GraphGetTextLength(LPGW lpgw, LPCSTR text, LPCSTR fontname, int fontsize);
374 int WDPROC GraphGetFontScaling(LPGW lpgw, LPCSTR font, int fontsize);
375
376 #ifdef USE_MOUSE
377 void WDPROC Graph_set_cursor (LPGW lpgw, int c, int x, int y );
378 void WDPROC Graph_set_ruler (LPGW lpgw, int x, int y );
379 void WDPROC Graph_put_tmptext(LPGW lpgw, int i, LPCSTR str);
380 void WDPROC Graph_set_clipboard (LPGW lpgw, LPCSTR s);
381 #endif
382
383 /* ================================== */