1 /* 2 * $Id: wgnuplib.h,v 1.89.2.2 2017/06/17 20:05:43 markisch 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 #ifndef WGNUPLIB_H 44 #define WGNUPLIB_H 45 46 #include <windows.h> 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 #include "screenbuf.h" 53 #include "term_api.h" 54 55 /* ================================== */ 56 /* symbols for the two icons */ 57 #define TEXTICON 123 58 #define GRPICON 124 59 60 /* ================================== */ 61 /* For WIN32 API's */ 62 /* #define DEFAULT_CHARSET ANSI_CHARSET */ 63 # define MoveTo(hdc,x,y) MoveToEx(hdc,x,y,(LPPOINT)NULL); 64 65 /* printf format for TCHAR arguments */ 66 #ifdef UNICODE 67 # define TCHARFMT "%ls" 68 #else 69 # define TCHARFMT "%hs" 70 #endif 71 72 /* ================================== */ 73 /* wprinter.c - windows printer routines */ 74 void DumpPrinter(HWND hwnd, LPTSTR szAppName, LPTSTR szFileName); 75 76 77 typedef struct tagPRINT { 78 HDC hdcPrn; 79 HWND hDlgPrint; 80 BOOL bUserAbort; 81 LPCTSTR szTitle; 82 POINT pdef; 83 POINT psize; 84 POINT poff; 85 BOOL bDriverChanged; 86 void * services; 87 struct tagPRINT *next; 88 } GP_PRINT; 89 typedef GP_PRINT * GP_LPPRINT; 90 91 92 /* ================================== */ 93 /* wpause.c - pause window structure */ 94 typedef struct tagPW 95 { 96 HINSTANCE hInstance; /* required */ 97 HINSTANCE hPrevInstance; /* required */ 98 LPWSTR Title; /* required */ 99 LPWSTR Message; /* required */ 100 POINT Origin; /* optional */ 101 HWND hWndParent; /* optional */ 102 HWND hWndPause; 103 HWND hOK; 104 HWND hCancel; 105 BOOL bPause; 106 BOOL bPauseCancel; 107 BOOL bDefOK; 108 WNDPROC lpfnOK; 109 WNDPROC lpfnCancel; 110 WNDPROC lpfnPauseButtonProc; 111 } PW; 112 typedef PW * LPPW; 113 114 TBOOLEAN MousableWindowOpened(void); 115 int PauseBox(LPPW lppw); 116 117 /* ================================== */ 118 /* wmenu.c - menu structure */ 119 #define BUTTONMAX 10 120 typedef struct tagMW 121 { 122 LPTSTR szMenuName; /* required */ 123 HMENU hMenu; 124 BYTE **macro; 125 BYTE *macrobuf; 126 int nCountMenu; 127 DLGPROC lpProcInput; 128 LPWSTR szPrompt; 129 LPWSTR szAnswer; 130 int nChar; 131 int nButton; 132 HWND hToolbar; 133 HWND hButton[BUTTONMAX]; 134 int hButtonID[BUTTONMAX]; 135 } MW; 136 typedef MW * LPMW; 137 138 139 /* ================================== */ 140 /* wtext.c text window structure */ 141 /* If an optional item is not specified it must be zero */ 142 #define MAXFONTNAME 80 143 typedef struct tagTW 144 { 145 GP_LPPRINT lpr; /* must be first */ 146 HINSTANCE hInstance; /* required */ 147 HINSTANCE hPrevInstance; /* required */ 148 LPWSTR Title; /* required */ 149 LPMW lpmw; /* optional */ 150 POINT ScreenSize; /* optional */ /* size of the visible screen in characters */ 151 unsigned int KeyBufSize; /* optional */ 152 LPTSTR IniFile; /* optional */ 153 LPTSTR IniSection; /* optional */ 154 LPWSTR DragPre; /* optional */ 155 LPWSTR DragPost; /* optional */ 156 int nCmdShow; /* optional */ 157 FARPROC shutdown; /* optional */ 158 HICON hIcon; /* optional */ 159 LPTSTR AboutText; /* optional */ 160 HMENU hPopMenu; 161 HWND hWndText; 162 HWND hWndParent; 163 HWND hWndToolbar; 164 HWND hStatusbar; 165 HWND hWndSeparator; 166 HWND hWndFocus; /* window with input focus */ 167 POINT Origin; 168 POINT Size; 169 SB ScreenBuffer; 170 BOOL bWrap; /* wrap long lines */ 171 BYTE *KeyBuf; 172 BYTE *KeyBufIn; 173 BYTE *KeyBufOut; 174 BYTE Attr; 175 BOOL bFocus; 176 BOOL bGetCh; 177 BOOL bSysColors; 178 HBRUSH hbrBackground; 179 TCHAR fontname[MAXFONTNAME]; /* font name */ 180 int fontsize; /* font size in pts */ 181 HFONT hfont; 182 int CharAscent; 183 int ButtonHeight; 184 int StatusHeight; 185 int CaretHeight; 186 int CursorFlag; /* scroll to cursor after \n & \r */ 187 POINT CursorPos; /* cursor position on screen */ 188 POINT ClientSize; /* size of the client window in pixels */ 189 POINT CharSize; 190 POINT ScrollPos; 191 POINT ScrollMax; 192 POINT MarkBegin; 193 POINT MarkEnd; 194 BOOL Marking; 195 int bSuspend; 196 int MaxCursorPos; 197 /* variables for docked graphs */ 198 UINT nDocked; 199 UINT VertFracDock; 200 UINT HorzFracDock; 201 UINT nDockCols; 202 UINT nDockRows; 203 UINT SeparatorWidth; 204 COLORREF SeparatorColor; 205 BOOL bFracChanging; 206 } TW; 207 typedef TW * LPTW; 208 209 210 #ifndef WGP_CONSOLE 211 /* ================================== */ 212 /* wtext.c - Text Window */ 213 void TextMessage(void); 214 int TextInit(LPTW lptw); 215 void TextClose(LPTW lptw); 216 int TextKBHit(LPTW); 217 int TextGetCh(LPTW); 218 int TextGetChE(LPTW); 219 LPSTR TextGetS(LPTW lptw, LPSTR str, unsigned int size); 220 int TextPutCh(LPTW, BYTE); 221 int TextPutChW(LPTW lptw, WCHAR ch); 222 int TextPutS(LPTW lptw, LPSTR str); 223 void TextStartEditing(LPTW lptw); 224 void TextStopEditing(LPTW lptw); 225 #if 0 226 /* The new screen buffer currently does not support these */ 227 void TextGotoXY(LPTW lptw, int x, int y); 228 int TextWhereX(LPTW lptw); 229 int TextWhereY(LPTW lptw); 230 void TextCursorHeight(LPTW lptw, int height); 231 void TextClearEOL(LPTW lptw); 232 void TextClearEOS(LPTW lptw); 233 void TextInsertLine(LPTW lptw); 234 void TextDeleteLine(LPTW lptw); 235 void TextScrollReverse(LPTW lptw); 236 #endif 237 void TextAttr(LPTW lptw, BYTE attr); 238 #endif /* WGP_CONSOLE */ 239 240 void AboutBox(HWND hwnd, LPTSTR str); 241 242 /* ================================== */ 243 /* wgraph.c - graphics window */ 244 245 /* windows data */ 246 247 /* number of different 'basic' pens supported (the ones you can modify 248 * by the 'Line styles...' dialog, and save to/from wgnuplot.ini). */ 249 #define WGNUMPENS 15 250 251 /* maximum number of different colors per palette, used to be hardcoded (256) */ 252 #define WIN_PAL_COLORS 4096 253 254 /* hypertext structure 255 */ 256 struct tooltips { 257 LPWSTR text; 258 RECT rect; 259 }; 260 261 /* Information about one graphical operation to be stored by the 262 * driver for the sake of redraws. Array of GWOP kept in global block */ 263 struct GWOP { 264 UINT op; 265 UINT x, y; 266 HLOCAL htext; 267 }; 268 269 /* memory block for graph operations */ 270 struct GWOPBLK { /* kept in local memory */ 271 struct GWOPBLK *next; 272 HGLOBAL hblk; /* handle to a global block */ 273 struct GWOP *gwop; /* pointer to global block if locked */ 274 UINT used; /* number of GWOP's used */ 275 }; 276 277 /* point types */ 278 enum win_pointtypes { 279 W_invalid_pointtype = 0, 280 W_dot = 10, 281 W_plus, W_cross, W_star, 282 W_box, W_fbox, 283 W_circle, W_fcircle, 284 W_itriangle, W_fitriangle, 285 W_triangle, W_ftriangle, 286 W_diamond, W_fdiamond, 287 W_pentagon, W_fpentagon, 288 W_last_pointtype = W_fpentagon 289 }; 290 // The dot is reserved for pt 0, number of (remaining) point types: 291 #define WIN_POINT_TYPES (W_last_pointtype - W_plus + 1) 292 293 /* ops */ 294 enum win_draw_commands { 295 W_endoflist = 0, 296 W_point = 9, 297 W_pointsize = 30, 298 W_setcolor, 299 W_polyline, W_line_type, W_dash_type, W_line_width, 300 W_put_text, W_enhanced_text, W_boxedtext, 301 W_text_encoding, W_font, W_justify, W_text_angle, 302 W_filled_polygon_draw, W_filled_polygon_pt, 303 W_fillstyle, 304 W_move, W_boxfill, 305 W_image, 306 W_layer, 307 W_hypertext 308 }; 309 310 311 typedef struct tagGW { 312 GP_LPPRINT lpr; /* must be first */ 313 HINSTANCE hInstance; /* required */ 314 HINSTANCE hPrevInstance;/* required */ 315 int Id; /* plot number */ 316 LPTSTR Title; /* required */ 317 int xmax; /* required */ 318 int ymax; /* required */ 319 LPTW lptw; /* optional */ /* associated text window */ 320 BOOL bDocked; /* is the graph docked to the text window? */ 321 POINT Origin; /* optional */ /* origin of graph window */ 322 POINT Size; /* optional */ /* size of graph window */ 323 LPTSTR IniFile; /* optional */ 324 LPTSTR IniSection; /* optional */ 325 HWND hWndGraph; /* window handle */ 326 HWND hStatusbar; /* window handle of status bar */ 327 int StatusHeight; /* height of status line area */ 328 HWND hToolbar; 329 int ToolbarHeight; 330 HMENU hPopMenu; /* popup menu */ 331 HBITMAP hBitmap; /* bitmap of current graph */ 332 BOOL buffervalid; /* indicates if hBitmap is valid */ 333 BOOL rotating; /* are we currently rotating the graph? */ 334 POINT Canvas; /* requested size of the canvas */ 335 POINT Decoration; /* extent of the window decorations */ 336 337 struct GWOPBLK *gwopblk_head; 338 struct GWOPBLK *gwopblk_tail; 339 unsigned int nGWOP; 340 BOOL locked; /* locked if being written */ 341 342 BOOL initialized; /* already initialized? */ 343 BOOL graphtotop; /* bring graph window to top after every plot? */ 344 BOOL color; /* color pens? */ 345 BOOL dashed; /* dashed lines? */ 346 BOOL rounded; /* rounded line caps and joins? */ 347 BOOL oversample; /* oversampling? */ 348 BOOL gdiplus; /* Use GDI+ only backend? */ 349 BOOL d2d; 350 BOOL antialiasing; /* anti-aliasing? */ 351 BOOL polyaa; /* anti-aliasing for polygons ? */ 352 BOOL fastrotation; /* rotate without anti-aliasing? */ 353 354 BOOL *hideplot; 355 unsigned int maxhideplots; 356 BOOL hidegrid; 357 unsigned int numplots; 358 BOOL hasgrid; 359 LPRECT keyboxes; 360 unsigned int maxkeyboxes; 361 362 HWND hTooltip; /* tooltip windows for hypertext */ 363 struct tooltips * tooltips; 364 unsigned int maxtooltips; 365 unsigned int numtooltips; 366 367 int htic; /* horizontal size of point symbol (xmax units) */ 368 int vtic; /* vertical size of point symbol (ymax units)*/ 369 int hchar; /* horizontal size of character (xmax units) */ 370 int vchar; /* vertical size of character (ymax units)*/ 371 372 TCHAR fontname[MAXFONTNAME]; /* current font name */ 373 int fontsize; /* current font size in pts */ 374 TCHAR deffontname[MAXFONTNAME]; /* default font name */ 375 int deffontsize; /* default font size */ 376 int angle; /* text angle */ 377 BOOL rotate; /* can text be rotated 90 degrees ? */ 378 int justify; /* text justification */ 379 HFONT hfonth; /* horizonal font */ 380 HFONT hfontv; /* rotated font (arbitrary angle) */ 381 LOGFONT lf; /* cached to speed up rotated fonts */ 382 double org_pointsize; /* Original Pointsize */ 383 int encoding_error; /* last unknown encoding */ 384 double fontscale; /* scale factor for font sizes */ 385 double pointscale; /* scale factor for point sizes */ 386 enum set_encoding_id encoding; /* text encoding */ 387 LONG tmHeight; /* text metric of current font */ 388 LONG tmAscent; 389 LONG tmDescent; 390 391 HPEN hapen; /* stored current pen */ 392 HPEN hsolid; /* solid sibling of current pen */ 393 HPEN hnull; /* empty null pen */ 394 LOGPEN colorpen[WGNUMPENS+2]; /* color pen definitions */ 395 LOGPEN monopen[WGNUMPENS+2]; /* mono pen definitions */ 396 double linewidth; /* scale factor for linewidth */ 397 398 HBRUSH colorbrush[WGNUMPENS+2]; /* brushes to fill points */ 399 COLORREF background; /* background color */ 400 HBRUSH hbrush; /* background brush */ 401 HBRUSH hcolorbrush; /* */ 402 403 struct tagGW * next; /* pointer to next window */ 404 } GW; 405 typedef GW * LPGW; 406 407 408 typedef struct { 409 LPGW lpgw; /* graph window */ 410 LPRECT rect; /* rect to update */ 411 BOOL opened_string; /* started processing of substring? */ 412 BOOL show; /* print this substring? */ 413 int overprint; /* overprint flag */ 414 BOOL widthflag; /* FALSE for zero width boxes */ 415 BOOL sizeonly; /* only measure length of substring? */ 416 double base; /* current baseline position (above initial baseline) */ 417 int xsave, ysave; /* save text position for overprinted text */ 418 int x, y; /* current text position */ 419 TCHAR fontname[MAXFONTNAME]; /* current font name */ 420 double fontsize; /* current font size */ 421 int totalwidth; /* total width of printed text */ 422 int totalasc; /* total height above center line */ 423 int totaldesc; /* total height below center line */ 424 double res_scale; /* scaling due to different resolution (printers) */ 425 int shift; /* baseline alignment */ 426 void (* set_font)(); 427 unsigned (* text_length)(char *); 428 void (* put_text)(int , int, char *); 429 void (* cleanup)(); 430 } enhstate_struct; 431 extern enhstate_struct enhstate; 432 433 434 /* No TEXT Macro required for fonts */ 435 #define WINFONTSIZE 10 436 #ifndef WINFONT 437 # define WINFONT "Tahoma" 438 #endif 439 #ifndef WINJPFONT 440 # define WINJPFONT "MS PGothic" 441 #endif 442 443 #define WINGRAPHTITLE TEXT("gnuplot graph") 444 445 extern termentry * WIN_term; 446 extern TCHAR WIN_inifontname[MAXFONTNAME]; 447 extern int WIN_inifontsize; 448 449 void GraphInitStruct(LPGW lpgw); 450 void GraphInit(LPGW lpgw); 451 void GraphUpdateWindowPosSize(LPGW lpgw); 452 void GraphClose(LPGW lpgw); 453 void GraphStart(LPGW lpgw, double pointsize); 454 void GraphEnd(LPGW lpgw); 455 void GraphChangeTitle(LPGW lpgw); 456 void GraphResume(LPGW lpgw); 457 void GraphOp(LPGW lpgw, UINT op, UINT x, UINT y, LPCSTR str); 458 void GraphOpSize(LPGW lpgw, UINT op, UINT x, UINT y, LPCSTR str, DWORD size); 459 void GraphPrint(LPGW lpgw); 460 void GraphRedraw(LPGW lpgw); 461 void GraphModifyPlots(LPGW lpgw, unsigned int operations, int plotno); 462 void win_close_terminal_window(LPGW lpgw); 463 TBOOLEAN GraphHasWindow(LPGW lpgw); 464 LPTSTR GraphDefaultFont(void); 465 466 #ifdef USE_MOUSE 467 void Graph_set_cursor(LPGW lpgw, int c, int x, int y); 468 void Graph_set_ruler(LPGW lpgw, int x, int y); 469 void Graph_put_tmptext(LPGW lpgw, int i, LPCSTR str); 470 void Graph_set_clipboard(LPGW lpgw, LPCSTR s); 471 #endif 472 473 /* BM: callback functions for enhanced text */ 474 void GraphEnhancedOpen(char *fontname, double fontsize, double base, 475 TBOOLEAN widthflag, TBOOLEAN showflag, int overprint); 476 void GraphEnhancedFlush(void); 477 478 void WIN_update_options __PROTO((void)); 479 480 481 /* ================================== */ 482 483 #ifdef __cplusplus 484 } 485 #endif 486 487 #endif 488