Annotation of OpenXM_contrib/gnuplot/win/wgraph.c, Revision 1.1.1.3
1.1 maekawa 1: #ifndef lint
1.1.1.3 ! ohara 2: static char *RCSid = "$Id: wgraph.c,v 1.5.2.2 1999/11/17 18:13:34 lhecking Exp $";
1.1 maekawa 3: #endif
4:
5: /* GNUPLOT - win/wgraph.c */
6: /*[
7: * Copyright 1992, 1993, 1998 Maurice Castro, Russell Lang
8: *
9: * Permission to use, copy, and distribute this software and its
10: * documentation for any purpose with or without fee is hereby granted,
11: * provided that the above copyright notice appear in all copies and
12: * that both that copyright notice and this permission notice appear
13: * in supporting documentation.
14: *
15: * Permission to modify the software is granted, but not the right to
16: * distribute the complete modified source code. Modifications are to
17: * be distributed as patches to the released version. Permission to
18: * distribute binaries produced by compiling modified sources is granted,
19: * provided you
20: * 1. distribute the corresponding source modifications from the
21: * released version in the form of a patch file along with the binaries,
22: * 2. add special version identification to distinguish your version
23: * in addition to the base release version number,
24: * 3. provide your name and address as the primary contact for the
25: * support of your modified version, and
26: * 4. retain our contact information in regard to use of the base
27: * software.
28: * Permission to distribute the released version of the source code along
29: * with corresponding source modifications in the form of a patch file is
30: * granted with same provisions 2 through 4 for binary distributions.
31: *
32: * This software is provided "as is" without express or implied warranty
33: * to the extent permitted by applicable law.
34: ]*/
35:
36: /*
37: * AUTHORS
38: *
39: * Maurice Castro
40: * Russell Lang
41: *
42: * Send your comments or suggestions to
43: * info-gnuplot@dartmouth.edu.
44: * This is a mailing list; to join it send a note to
45: * majordomo@dartmouth.edu.
46: * Send bug reports to
47: * bug-gnuplot@dartmouth.edu.
48: */
49:
50: #define STRICT
51: #include <windows.h>
52: #include <windowsx.h>
53: #if WINVER >= 0x030a
54: #include <commdlg.h>
55: #endif
56: #ifndef __MSC__
57: #include <mem.h>
58: #endif
59: #include <stdio.h>
60: #include <string.h>
61: #include "wgnuplib.h"
62: #include "wresourc.h"
63: #include "wcommon.h"
64:
65: LRESULT CALLBACK WINEXPORT WndGraphProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
66:
67: void ReadGraphIni(LPGW lpgw);
68:
69: /* ================================== */
70:
71: #define MAXSTR 255
72:
73: #define WGDEFCOLOR 15
74: COLORREF wginitcolor[WGDEFCOLOR] = {
75: RGB(255,0,0), /* red */
76: RGB(0,255,0), /* green */
77: RGB(0,0,255), /* blue */
78: RGB(255,0,255), /* magenta */
79: RGB(0,0,128), /* dark blue */
80: RGB(128,0,0), /* dark red */
81: RGB(0,128,128), /* dark cyan */
82: RGB(0,0,0), /* black */
83: RGB(128,128,128), /* grey */
84: RGB(0,128,64), /* very dark cyan */
85: RGB(128,128,0), /* dark yellow */
86: RGB(128,0,128), /* dark magenta */
87: RGB(192,192,192), /* light grey */
88: RGB(0,255,255), /* cyan */
89: RGB(255,255,0), /* yellow */
90: };
91: #define WGDEFSTYLE 5
92: int wginitstyle[WGDEFSTYLE] = {PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT};
93:
94: /* ================================== */
95:
96: /* destroy memory blocks holding graph operations */
97: void
98: DestroyBlocks(LPGW lpgw)
99: {
100: struct GWOPBLK *this, *next;
101: struct GWOP FAR *gwop;
102: unsigned int i;
103:
104: this = lpgw->gwopblk_head;
105: while (this != NULL) {
106: next = this->next;
107: if (!this->gwop) {
108: this->gwop = (struct GWOP FAR *)GlobalLock(this->hblk);
109: }
110: if (this->gwop) {
111: /* free all text strings within this block */
112: gwop = this->gwop;
113: for (i=0; i<GWOPMAX; i++) {
114: if (gwop->htext)
115: LocalFree(gwop->htext);
116: gwop++;
117: }
118: }
119: GlobalUnlock(this->hblk);
120: GlobalFree(this->hblk);
121: LocalFreePtr(this);
122: this = next;
123: }
124: lpgw->gwopblk_head = NULL;
125: lpgw->gwopblk_tail = NULL;
126: lpgw->nGWOP = 0;
127: }
128:
129:
130: /* add a new memory block for graph operations */
131: /* returns TRUE if block allocated */
132: BOOL
133: AddBlock(LPGW lpgw)
134: {
135: HGLOBAL hblk;
136: struct GWOPBLK *next, *this;
137:
138: /* create new block */
139: next = (struct GWOPBLK *)LocalAllocPtr(LHND, sizeof(struct GWOPBLK) );
140: if (next == NULL)
141: return FALSE;
142: hblk = GlobalAlloc(GHND, GWOPMAX*sizeof(struct GWOP));
143: if (hblk == NULL)
144: return FALSE;
145: next->hblk = hblk;
146: next->gwop = (struct GWOP FAR *)NULL;
147: next->next = (struct GWOPBLK *)NULL;
148: next->used = 0;
149:
150: /* attach it to list */
151: this = lpgw->gwopblk_tail;
152: if (this == NULL) {
153: lpgw->gwopblk_head = next;
154: }
155: else {
156: this->next = next;
157: this->gwop = (struct GWOP FAR *)NULL;
158: GlobalUnlock(this->hblk);
159: }
160: lpgw->gwopblk_tail = next;
161: next->gwop = (struct GWOP FAR *)GlobalLock(next->hblk);
162: if (next->gwop == (struct GWOP FAR *)NULL)
163: return FALSE;
164:
165: return TRUE;
166: }
167:
168:
169: void WDPROC
170: GraphOp(LPGW lpgw, WORD op, WORD x, WORD y, LPSTR str)
171: {
172: struct GWOPBLK *this;
173: struct GWOP FAR *gwop;
174: char *npstr;
175:
176: this = lpgw->gwopblk_tail;
177: if ( (this==NULL) || (this->used >= GWOPMAX) ) {
178: /* not enough space so get new block */
179: if (!AddBlock(lpgw))
180: return;
181: this = lpgw->gwopblk_tail;
182: }
183: gwop = &this->gwop[this->used];
184: gwop->op = op;
185: gwop->x = x;
186: gwop->y = y;
187: gwop->htext = 0;
188: if (str) {
189: gwop->htext = LocalAlloc(LHND, _fstrlen(str)+1);
190: npstr = LocalLock(gwop->htext);
191: if (gwop->htext && (npstr != (char *)NULL))
192: lstrcpy(npstr, str);
193: LocalUnlock(gwop->htext);
194: }
195: this->used++;
196: lpgw->nGWOP++;
197: return;
198: }
199:
200: /* ================================== */
201:
202: void WDPROC
203: GraphInit(LPGW lpgw)
204: {
205: HMENU sysmenu;
206: WNDCLASS wndclass;
207: char buf[80];
208:
209: if (!lpgw->hPrevInstance) {
210: wndclass.style = CS_HREDRAW | CS_VREDRAW;
211: wndclass.lpfnWndProc = WndGraphProc;
212: wndclass.cbClsExtra = 0;
213: wndclass.cbWndExtra = 2 * sizeof(void FAR *);
214: wndclass.hInstance = lpgw->hInstance;
215: wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
216: wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
217: wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
218: wndclass.lpszMenuName = NULL;
219: wndclass.lpszClassName = szGraphClass;
220: RegisterClass(&wndclass);
221: }
222:
223: ReadGraphIni(lpgw);
224:
225: lpgw->hWndGraph = CreateWindow(szGraphClass, lpgw->Title,
226: WS_OVERLAPPEDWINDOW,
227: lpgw->Origin.x, lpgw->Origin.y,
228: lpgw->Size.x, lpgw->Size.y,
229: NULL, NULL, lpgw->hInstance, lpgw);
230:
231: lpgw->hPopMenu = CreatePopupMenu();
232: AppendMenu(lpgw->hPopMenu, MF_STRING | (lpgw->graphtotop ? MF_CHECKED : MF_UNCHECKED),
233: M_GRAPH_TO_TOP, "Bring to &Top");
234: AppendMenu(lpgw->hPopMenu, MF_STRING | (lpgw->color ? MF_CHECKED : MF_UNCHECKED),
235: M_COLOR, "C&olor");
236: AppendMenu(lpgw->hPopMenu, MF_STRING, M_COPY_CLIP, "&Copy to Clipboard");
237: #if WINVER >= 0x030a
238: AppendMenu(lpgw->hPopMenu, MF_STRING, M_BACKGROUND, "&Background...");
239: AppendMenu(lpgw->hPopMenu, MF_STRING, M_CHOOSE_FONT, "Choose &Font...");
240: AppendMenu(lpgw->hPopMenu, MF_STRING, M_LINESTYLE, "&Line Styles...");
241: #endif
242: AppendMenu(lpgw->hPopMenu, MF_STRING, M_PRINT, "&Print...");
243: if (lpgw->IniFile != (LPSTR)NULL) {
244: wsprintf(buf,"&Update %s",lpgw->IniFile);
245: AppendMenu(lpgw->hPopMenu, MF_STRING, M_WRITEINI, (LPSTR)buf);
246: }
247:
248: /* modify the system menu to have the new items we want */
249: sysmenu = GetSystemMenu(lpgw->hWndGraph,0);
250: AppendMenu(sysmenu, MF_SEPARATOR, 0, NULL);
251: AppendMenu(sysmenu, MF_POPUP, (UINT)lpgw->hPopMenu, "&Options");
252: AppendMenu(sysmenu, MF_STRING, M_ABOUT, "&About");
253:
254: if (!IsWindowVisible(lpgw->lptw->hWndParent)) {
255: AppendMenu(sysmenu, MF_SEPARATOR, 0, NULL);
256: AppendMenu(sysmenu, MF_STRING, M_COMMANDLINE, "C&ommand Line");
257: }
258:
259: ShowWindow(lpgw->hWndGraph, SW_SHOWNORMAL);
260: }
261:
262: /* close a graph window */
263: void WDPROC
264: GraphClose(LPGW lpgw)
265: {
266: /* close window */
267: if (lpgw->hWndGraph)
268: DestroyWindow(lpgw->hWndGraph);
269: TextMessage();
270: lpgw->hWndGraph = NULL;
271:
272: lpgw->locked = TRUE;
273: DestroyBlocks(lpgw);
274: lpgw->locked = FALSE;
275:
276: }
277:
278:
279: void WDPROC
280: GraphStart(LPGW lpgw, double pointsize)
281: {
282: lpgw->locked = TRUE;
283: DestroyBlocks(lpgw);
284: lpgw->org_pointsize = pointsize;
285: if ( !lpgw->hWndGraph || !IsWindow(lpgw->hWndGraph) )
286: GraphInit(lpgw);
287: if (IsIconic(lpgw->hWndGraph))
288: ShowWindow(lpgw->hWndGraph, SW_SHOWNORMAL);
289: if (lpgw->graphtotop)
290: BringWindowToTop(lpgw->hWndGraph);
291:
292: }
293:
294: void WDPROC
295: GraphEnd(LPGW lpgw)
296: {
297: RECT rect;
298: GetClientRect(lpgw->hWndGraph, &rect);
299: InvalidateRect(lpgw->hWndGraph, (LPRECT) &rect, 1);
300: lpgw->locked = FALSE;
301: UpdateWindow(lpgw->hWndGraph);
302: }
303:
304: void WDPROC
305: GraphResume(LPGW lpgw)
306: {
307: lpgw->locked = TRUE;
308: }
309:
310: void WDPROC
311: GraphPrint(LPGW lpgw)
312: {
313: if (lpgw->hWndGraph && IsWindow(lpgw->hWndGraph))
314: SendMessage(lpgw->hWndGraph,WM_COMMAND,M_PRINT,0L);
315: }
316:
317: void WDPROC
318: GraphRedraw(LPGW lpgw)
319: {
320: if (lpgw->hWndGraph && IsWindow(lpgw->hWndGraph))
321: SendMessage(lpgw->hWndGraph,WM_COMMAND,M_REBUILDTOOLS,0L);
322: }
323: /* ================================== */
324:
325: void
326: StorePen(LPGW lpgw, int i, COLORREF ref, int colorstyle, int monostyle)
327: {
328: LOGPEN FAR *plp;
329:
330: plp = &lpgw->colorpen[i];
331: plp->lopnColor = ref;
332: if (colorstyle < 0) {
333: plp->lopnWidth.x = -colorstyle;
334: plp->lopnStyle = 0;
335: }
336: else {
337: plp->lopnWidth.x = 1;
338: plp->lopnStyle = colorstyle % 5;
339: }
340: plp->lopnWidth.y = 0;
341:
342: plp = &lpgw->monopen[i];
343: plp->lopnColor = RGB(0,0,0);
344: if (monostyle < 0) {
345: plp->lopnWidth.x = -monostyle;
346: plp->lopnStyle = 0;
347: }
348: else {
349: plp->lopnWidth.x = 1;
350: plp->lopnStyle = monostyle % 5;
351: }
352: plp->lopnWidth.y = 0;
353: }
354:
355: void
356: MakePens(LPGW lpgw, HDC hdc)
357: {
358: int i;
359:
360: if ((GetDeviceCaps(hdc,NUMCOLORS) == 2) || !lpgw->color) {
361: /* Monochrome Device */
362: /* create border pens */
363: lpgw->hbpen = CreatePenIndirect((LOGPEN FAR *)&lpgw->monopen[0]); /* border */
364: lpgw->hapen = CreatePenIndirect((LOGPEN FAR *)&lpgw->monopen[1]); /* axis */
365: /* create drawing pens */
366: for (i=0; i<WGNUMPENS; i++)
367: {
368: lpgw->hpen[i] = CreatePenIndirect((LOGPEN FAR *)&lpgw->monopen[i+2]);
1.1.1.3 ! ohara 369: lpgw->hsolidpen[i] = CreatePenIndirect((LOGPEN FAR *)&lpgw->monopen[2]);
1.1 maekawa 370: }
371: /* find number of solid, unit width line styles */
372: for (i=0; i<WGNUMPENS && lpgw->monopen[i+2].lopnStyle==PS_SOLID
373: && lpgw->monopen[i+2].lopnWidth.x==1; i++) ;
374: lpgw->numsolid = i ? i : 1; /* must be at least 1 */
375: lpgw->hbrush = CreateSolidBrush(RGB(255,255,255));
376: for (i=0; i<WGNUMPENS+2; i++)
377: lpgw->colorbrush[i] = CreateSolidBrush(RGB(0,0,0));
378: }
379: else {
380: /* Color Device */
381: /* create border pens */
382: lpgw->hbpen = CreatePenIndirect((LOGPEN FAR *)&lpgw->colorpen[0]); /* border */
383: lpgw->hapen = CreatePenIndirect((LOGPEN FAR *)&lpgw->colorpen[1]); /* axis */
384: /* create drawing pens */
385: for (i=0; i<WGNUMPENS; i++)
386: {
387: lpgw->hpen[i] = CreatePenIndirect((LOGPEN FAR *)&lpgw->colorpen[i+2]);
1.1.1.2 maekawa 388: #if 1 /* HBB 980118 fix 'numsolid' problem */
389: lpgw->hsolidpen[i] = CreatePen(PS_SOLID, 1, lpgw->colorpen[i+2].lopnColor);
390: #endif
1.1 maekawa 391: }
392: /* find number of solid, unit width line styles */
393: for (i=0; i<WGNUMPENS && lpgw->colorpen[i+2].lopnStyle==PS_SOLID
394: && lpgw->colorpen[i+2].lopnWidth.x==1; i++) ;
395: lpgw->numsolid = i ? i : 1; /* must be at least 1 */
396: lpgw->hbrush = CreateSolidBrush(lpgw->background);
397: for (i=0; i<WGNUMPENS+2; i++)
398: lpgw->colorbrush[i] = CreateSolidBrush(lpgw->colorpen[i].lopnColor);
399: }
400: }
401:
402: void
403: DestroyPens(LPGW lpgw)
404: {
405: int i;
406:
407: DeleteObject(lpgw->hbrush);
408: DeleteObject(lpgw->hbpen);
409: DeleteObject(lpgw->hapen);
410: for (i=0; i<WGNUMPENS; i++)
411: DeleteObject(lpgw->hpen[i]);
1.1.1.2 maekawa 412: #if 1 /* HBB 980118: fix 'numsolid' gotcha */
413: for (i=0; i<WGNUMPENS; i++)
414: DeleteObject(lpgw->hsolidpen[i]);
415: #endif
1.1 maekawa 416: for (i=0; i<WGNUMPENS+2; i++)
417: DeleteObject(lpgw->colorbrush[i]);
418: }
419:
420: /* ================================== */
421:
422: void
423: MakeFonts(LPGW lpgw, LPRECT lprect, HDC hdc)
424: {
425: LOGFONT lf;
426: HFONT hfontold;
427: TEXTMETRIC tm;
428: int result;
429: char FAR *p;
430: int cx, cy;
431:
432: lpgw->rotate = FALSE;
433: _fmemset(&lf, 0, sizeof(LOGFONT));
434: _fstrncpy(lf.lfFaceName,lpgw->fontname,LF_FACESIZE);
435: lf.lfHeight = -MulDiv(lpgw->fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
436: lf.lfCharSet = DEFAULT_CHARSET;
437: if ( (p = _fstrstr(lpgw->fontname," Italic")) != (LPSTR)NULL ) {
438: lf.lfFaceName[ (unsigned int)(p-lpgw->fontname) ] = '\0';
439: lf.lfItalic = TRUE;
440: }
441: if ( (p = _fstrstr(lpgw->fontname," Bold")) != (LPSTR)NULL ) {
442: lf.lfFaceName[ (unsigned int)(p-lpgw->fontname) ] = '\0';
443: lf.lfWeight = FW_BOLD;
444: }
445:
446: if (lpgw->hfonth == 0) {
447: lpgw->hfonth = CreateFontIndirect((LOGFONT FAR *)&lf);
448: }
449:
450: if (lpgw->hfontv == 0) {
451: lf.lfEscapement = 900;
452: lf.lfOrientation = 900;
453: lpgw->hfontv = CreateFontIndirect((LOGFONT FAR *)&lf);
454: }
455:
456: /* save text size */
457: hfontold = SelectObject(hdc, lpgw->hfonth);
458: #ifdef WIN32
459: {
460: SIZE size;
461: GetTextExtentPoint(hdc,"0123456789",10, (LPSIZE)&size);
462: cx = size.cx;
463: cy = size.cy;
464: }
465: #else
466: {
467: DWORD extent;
468: extent = GetTextExtent(hdc,"0123456789",10);
469: cx = LOWORD(extent);
470: cy = HIWORD(extent);
471: }
472: #endif
473: lpgw->vchar = MulDiv(cy,lpgw->ymax,lprect->bottom - lprect->top);
474: lpgw->hchar = MulDiv(cx/10,lpgw->xmax,lprect->right - lprect->left);
475: /* CMW: Base tick size on character size */
476: lpgw->htic = lpgw->hchar/2;
477: cy = MulDiv(cx/20, GetDeviceCaps(hdc,LOGPIXELSY), GetDeviceCaps(hdc,LOGPIXELSX));
478: lpgw->vtic = MulDiv(cy,lpgw->ymax,lprect->bottom - lprect->top);
479: /* find out if we can rotate text 90deg */
480: SelectObject(hdc, lpgw->hfontv);
481: result = GetDeviceCaps(hdc, TEXTCAPS);
482: if ((result & TC_CR_90) || (result & TC_CR_ANY))
483: lpgw->rotate = 1;
484: GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm);
485: if (tm.tmPitchAndFamily & TMPF_VECTOR)
486: lpgw->rotate = 1; /* vector fonts can all be rotated */
487: #if WINVER >=0x030a
488: if (tm.tmPitchAndFamily & TMPF_TRUETYPE)
489: lpgw->rotate = 1; /* truetype fonts can all be rotated */
490: #endif
491: SelectObject(hdc, hfontold);
492: return;
493: }
494:
495: void
496: DestroyFonts(LPGW lpgw)
497: {
498: if (lpgw->hfonth) {
499: DeleteObject(lpgw->hfonth);
500: lpgw->hfonth = 0;
501: }
502: if (lpgw->hfontv) {
503: DeleteObject(lpgw->hfontv);
504: lpgw->hfontv = 0;
505: }
506: return;
507: }
508:
509: void
510: SetFont(LPGW lpgw, HDC hdc)
511: {
512: if (lpgw->rotate && lpgw->angle) {
513: if (lpgw->hfontv)
514: SelectObject(hdc, lpgw->hfontv);
515: }
516: else {
517: if (lpgw->hfonth)
518: SelectObject(hdc, lpgw->hfonth);
519: }
520: return;
521: }
522:
523: void
524: SelFont(LPGW lpgw) {
525: #if WINVER >= 0x030a
526: LOGFONT lf;
527: CHOOSEFONT cf;
528: HDC hdc;
529: char lpszStyle[LF_FACESIZE];
530: char FAR *p;
531:
532: /* Set all structure fields to zero. */
533: _fmemset(&cf, 0, sizeof(CHOOSEFONT));
534: _fmemset(&lf, 0, sizeof(LOGFONT));
535: cf.lStructSize = sizeof(CHOOSEFONT);
536: cf.hwndOwner = lpgw->hWndGraph;
537: _fstrncpy(lf.lfFaceName,lpgw->fontname,LF_FACESIZE);
538: if ( (p = _fstrstr(lpgw->fontname," Bold")) != (LPSTR)NULL ) {
539: _fstrncpy(lpszStyle,p+1,LF_FACESIZE);
540: lf.lfFaceName[ (unsigned int)(p-lpgw->fontname) ] = '\0';
541: }
542: else if ( (p = _fstrstr(lpgw->fontname," Italic")) != (LPSTR)NULL ) {
543: _fstrncpy(lpszStyle,p+1,LF_FACESIZE);
544: lf.lfFaceName[ (unsigned int)(p-lpgw->fontname) ] = '\0';
545: }
546: else
547: _fstrcpy(lpszStyle,"Regular");
548: cf.lpszStyle = lpszStyle;
549: hdc = GetDC(lpgw->hWndGraph);
550: lf.lfHeight = -MulDiv(lpgw->fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
551: ReleaseDC(lpgw->hWndGraph, hdc);
552: cf.lpLogFont = &lf;
553: cf.nFontType = SCREEN_FONTTYPE;
554: cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT | CF_USESTYLE;
555: if (ChooseFont(&cf)) {
556: _fstrcpy(lpgw->fontname,lf.lfFaceName);
557: lpgw->fontsize = cf.iPointSize / 10;
558: if (cf.nFontType & BOLD_FONTTYPE)
559: lstrcat(lpgw->fontname," Bold");
560: if (cf.nFontType & ITALIC_FONTTYPE)
561: lstrcat(lpgw->fontname," Italic");
562: SendMessage(lpgw->hWndGraph,WM_COMMAND,M_REBUILDTOOLS,0L);
563: }
564: #endif
565: }
566:
567: /* ================================== */
568:
569: static void dot(HDC hdc, int xdash, int ydash)
570: {
571: MoveTo(hdc, xdash, ydash);
572: LineTo(hdc, xdash, ydash+1);
573: }
574:
575:
576: void
577: drawgraph(LPGW lpgw, HDC hdc, LPRECT rect)
578: {
579: int xdash, ydash; /* the transformed coordinates */
580: int rr, rl, rt, rb;
581: struct GWOP FAR *curptr;
582: struct GWOPBLK *blkptr;
583: int htic, vtic;
584: int hshift, vshift;
585: unsigned int lastop=-1; /* used for plotting last point on a line */
586: int pen, numsolid;
587: int polymax = 200;
588: int polyi = 0;
589: POINT *ppt;
590: unsigned int ngwop=0;
591: BOOL isColor;
592:
593: if (lpgw->locked)
594: return;
595:
596: isColor= (GetDeviceCaps(hdc, PLANES)*GetDeviceCaps(hdc,BITSPIXEL)) > 2;
597: if (lpgw->background != RGB(255,255,255) && lpgw->color && isColor) {
598: SetBkColor(hdc,lpgw->background);
599: FillRect(hdc, rect, lpgw->hbrush);
600: }
601:
602: ppt = (POINT *)LocalAllocPtr(LHND, (polymax+1) * sizeof(POINT));
603:
604: rr = rect->right;
605: rl = rect->left;
606: rt = rect->top;
607: rb = rect->bottom;
608:
609: htic = lpgw->org_pointsize*MulDiv(lpgw->htic, rr-rl, lpgw->xmax) + 1;
610: vtic = lpgw->org_pointsize*MulDiv(lpgw->vtic, rb-rt, lpgw->ymax) + 1;
611:
612: lpgw->angle = 0;
613: SetFont(lpgw, hdc);
614: SetTextAlign(hdc, TA_LEFT|TA_BOTTOM);
615: vshift = MulDiv(lpgw->vchar, rb-rt, lpgw->ymax)/2;
616: /* HBB 980630: new variable for moving rotated text to the correct
617: * position: */
618: hshift = MulDiv(lpgw->vchar, rr-rl, lpgw->xmax)/2;
619:
620: pen = 0;
621: SelectObject(hdc, lpgw->hpen[pen]);
622: SelectObject(hdc, lpgw->colorbrush[pen+2]);
623: numsolid = lpgw->numsolid;
624:
625: /* do the drawing */
626: blkptr = lpgw->gwopblk_head;
627: curptr = NULL;
628: if (blkptr) {
629: if (!blkptr->gwop)
630: blkptr->gwop = (struct GWOP FAR *)GlobalLock(blkptr->hblk);
631: if (!blkptr->gwop)
632: return;
633: curptr = (struct GWOP FAR *)blkptr->gwop;
634: }
635: while(ngwop < lpgw->nGWOP)
636: {
637: /* transform the coordinates */
638: xdash = MulDiv(curptr->x, rr-rl-1, lpgw->xmax) + rl;
639: ydash = MulDiv(curptr->y, rt-rb+1, lpgw->ymax) + rb - 1;
640: if ((lastop==W_vect) && (curptr->op!=W_vect)) {
641: if (polyi >= 2)
642: Polyline(hdc, ppt, polyi);
643: polyi = 0;
644: }
645: switch (curptr->op) {
646: case 0: /* have run past last in this block */
647: break;
648: case W_move:
649: ppt[0].x = xdash;
650: ppt[0].y = ydash;
651: polyi = 1;
652: break;
653: case W_vect:
654: ppt[polyi].x = xdash;
655: ppt[polyi].y = ydash;
656: polyi++;
657: if (polyi >= polymax) {
658: Polyline(hdc, ppt, polyi);
659: ppt[0].x = xdash;
660: ppt[0].y = ydash;
661: polyi = 1;;
662: }
663: break;
664: case W_line_type:
665: switch (curptr->x)
666: {
667: case (WORD) -2: /* black 2 pixel wide */
668: SelectObject(hdc, lpgw->hbpen);
669: if (lpgw->color && isColor)
670: SetTextColor(hdc, lpgw->colorpen[0].lopnColor);
671: break;
672: case (WORD) -1: /* black 1 pixel wide doted */
673: SelectObject(hdc, lpgw->hapen);
674: if (lpgw->color && isColor)
675: SetTextColor(hdc, lpgw->colorpen[1].lopnColor);
676: break;
677: default:
678: SelectObject(hdc, lpgw->hpen[(curptr->x)%WGNUMPENS]);
679: if (lpgw->color && isColor)
680: SetTextColor(hdc, lpgw->colorpen[(curptr->x)%WGNUMPENS + 2].lopnColor);
681: }
682: pen = curptr->x;
683: SelectObject(hdc, lpgw->colorbrush[pen%WGNUMPENS + 2]);
684: break;
685: case W_put_text:
686: {char *str;
687: str = LocalLock(curptr->htext);
688: if (str) {
689: /* HBB 980630: shift differently for rotated text: */
690: if (lpgw->angle)
691: xdash += hshift;
692: else
693: ydash += vshift;
694: SetBkMode(hdc,TRANSPARENT);
695: TextOut(hdc,xdash,ydash,str,lstrlen(str));
696: SetBkMode(hdc,OPAQUE);
697: }
698: LocalUnlock(curptr->htext);
699: }
700: break;
701: case W_text_angle:
702: lpgw->angle = curptr->x;
703: SetFont(lpgw,hdc);
704: break;
705: case W_justify:
706: switch (curptr->x)
707: {
708: case LEFT:
709: SetTextAlign(hdc, TA_LEFT|TA_BOTTOM);
710: break;
711: case RIGHT:
712: SetTextAlign(hdc, TA_RIGHT|TA_BOTTOM);
713: break;
714: case CENTRE:
715: SetTextAlign(hdc, TA_CENTER|TA_BOTTOM);
716: break;
717: }
718: break;
719: case W_pointsize:
720: /* HBB 980309: term->pointsize() passes the number as a scaled-up
721: * integer now, so we can avoid calling sscanf() here (in a Win16
722: * DLL sharing stack with the stack-starved wgnuplot.exe !).
723: */
724: if (curptr->x != 0) {
725: double pointsize = curptr->x / 100.0;
726: /* HBB 980309: the older code didn't make *any* use of the
727: * pointsize at all! That obviously can't be correct. So use it! */
728: htic = pointsize*MulDiv(lpgw->htic, rr-rl, lpgw->xmax) + 1;
729: vtic = pointsize*MulDiv(lpgw->vtic, rb-rt, lpgw->ymax) + 1;
730: } else {
731: char *str;
732: str = LocalLock(curptr->htext);
733: if (str) {
734: double pointsize;
735: sscanf(str, "%lg", &pointsize);
736: htic = lpgw->org_pointsize*MulDiv(lpgw->htic, rr-rl, lpgw->xmax) + 1;
737: vtic = lpgw->org_pointsize*MulDiv(lpgw->vtic, rb-rt, lpgw->ymax) + 1;
738: }
739: LocalUnlock(curptr->htext);
740: }
741: break;
742: default: /* A plot mark */
1.1.1.2 maekawa 743: #if 0 /* HBB 980118: fix 'sumsolid' gotcha: */
1.1 maekawa 744: if (pen >= numsolid) {
745: pen %= numsolid; /* select solid pen */
746: SelectObject(hdc, lpgw->hpen[pen]);
747: SelectObject(hdc, lpgw->colorbrush[pen+2]);
748: }
1.1.1.2 maekawa 749: #else
750: SelectObject(hdc, lpgw->hsolidpen[pen%WGNUMPENS]);
751: #endif
1.1 maekawa 752: switch (curptr->op) {
753: case W_dot:
754: dot(hdc, xdash, ydash);
755: break;
756: case W_plus: /* do plus */
757: MoveTo(hdc,xdash-htic,ydash);
758: LineTo(hdc,xdash+htic+1,ydash);
759: MoveTo(hdc,xdash,ydash-vtic);
760: LineTo(hdc,xdash,ydash+vtic+1);
761: break;
762: case W_cross: /* do X */
763: MoveTo(hdc,xdash-htic,ydash-vtic);
764: LineTo(hdc,xdash+htic+1,ydash+vtic+1);
765: MoveTo(hdc,xdash-htic,ydash+vtic);
766: LineTo(hdc,xdash+htic+1,ydash-vtic-1);
767: break;
768: case W_star: /* do star */
769: MoveTo(hdc,xdash-htic,ydash);
770: LineTo(hdc,xdash+htic+1,ydash);
771: MoveTo(hdc,xdash,ydash-vtic);
772: LineTo(hdc,xdash,ydash+vtic+1);
773: MoveTo(hdc,xdash-htic,ydash-vtic);
774: LineTo(hdc,xdash+htic+1,ydash+vtic+1);
775: MoveTo(hdc,xdash-htic,ydash+vtic);
776: LineTo(hdc,xdash+htic+1,ydash-vtic-1);
777: break;
778: case W_circle: /* do open circle */
779: Arc(hdc, xdash-htic, ydash-vtic, xdash+htic+1, ydash+vtic+1, xdash, ydash+vtic+1, xdash, ydash+vtic+1);
780: dot(hdc, xdash, ydash);
781: break;
782: case W_fcircle: /* do filled circle */
783: Ellipse(hdc, xdash-htic, ydash-vtic, xdash+htic+1, ydash+vtic+1);
784: break;
785: default: /* Closed figure */
786: { POINT p[6];
787: int i;
788: int shape;
789: int filled = 0;
790: static float pointshapes[5][10] = {
791: {-1, -1, +1, -1, +1, +1, -1, +1, 0, 0}, /* box */
792: { 0, +1, -1, 0, 0, -1, +1, 0, 0, 0}, /* diamond */
793: { 0, -4./3, -4./3, 2./3, 4./3, 2./3, 0, 0}, /* triangle */
794: { 0, 4./3, -4./3, -2./3, 4./3, -2./3, 0, 0}, /* inverted triangle */
795: { 0, 1, 0.95106, 0.30902, 0.58779, -0.80902, -0.58779, -0.80902, -0.95106, 0.30902} /* pentagon (not used) */
796: };
797: switch (curptr->op) {
798: case W_box: shape = 0; break;
799: case W_diamond: shape = 1; break;
800: case W_itriangle: shape = 2; break;
801: case W_triangle: shape = 3; break;
802: default: shape = curptr->op-W_fbox;
803: filled = 1;
804: break;
805: }
806:
807: for ( i = 0; i<5; ++i )
808: if ( pointshapes[shape][i*2+1] == 0 && pointshapes[shape][i*2] == 0 )
809: break;
810: else {
811: p[i].x = xdash + htic*pointshapes[shape][i*2] + 0.5;
812: p[i].y = ydash + vtic*pointshapes[shape][i*2+1] + 0.5;
813: }
814: if ( filled )
815: /* Filled polygon */
816: Polygon(hdc, p, i);
817: else {
818: /* Outline polygon */
819: p[i].x = p[0].x;
820: p[i].y = p[0].y;
821: Polyline(hdc, p, i+1);
822: dot(hdc, xdash, ydash);
823: }
824: }
825: }
826: }
827: lastop = curptr->op;
828: ngwop++;
829: curptr++;
830: if ((unsigned)(curptr - blkptr->gwop) >= GWOPMAX) {
831: GlobalUnlock(blkptr->hblk);
832: blkptr->gwop = (struct GWOP FAR *)NULL;
833: blkptr = blkptr->next;
834: if (!blkptr->gwop)
835: blkptr->gwop = (struct GWOP FAR *)GlobalLock(blkptr->hblk);
836: if (!blkptr->gwop)
837: return;
838: curptr = (struct GWOP FAR *)blkptr->gwop;
839: }
840: }
841: if (polyi >= 2)
842: Polyline(hdc, ppt, polyi);
843: LocalFreePtr(ppt);
844: }
845:
846: /* ================================== */
847:
848: /* copy graph window to clipboard */
849: void
850: CopyClip(LPGW lpgw)
851: {
852: RECT rect;
853: HDC mem;
854: HBITMAP bitmap;
855: HANDLE hmf;
856: GLOBALHANDLE hGMem;
857: LPMETAFILEPICT lpMFP;
858: HWND hwnd;
859: HDC hdc;
860:
861: hwnd = lpgw->hWndGraph;
862:
863: /* view the window */
864: if (IsIconic(hwnd))
865: ShowWindow(hwnd, SW_SHOWNORMAL);
866: BringWindowToTop(hwnd);
867: UpdateWindow(hwnd);
868:
869: /* get the context */
870: hdc = GetDC(hwnd);
871: GetClientRect(hwnd, &rect);
872: /* make a bitmap and copy it there */
873: mem = CreateCompatibleDC(hdc);
874: bitmap = CreateCompatibleBitmap(hdc, rect.right - rect.left,
875: rect.bottom - rect.top);
876: if (bitmap) {
877: /* there is enough memory and the bitmaps OK */
878: SelectObject(mem, bitmap);
879: BitBlt(mem,0,0,rect.right - rect.left,
880: rect.bottom - rect.top, hdc, rect.left,
881: rect.top, SRCCOPY);
882: }
883: else {
884: MessageBeep(MB_ICONHAND);
885: MessageBox(hwnd, "Insufficient Memory to Copy Clipboard",
886: lpgw->Title, MB_ICONHAND | MB_OK);
887: }
888: DeleteDC(mem);
889: {
890: GW gwclip = *lpgw;
891: int windowfontsize = MulDiv(lpgw->fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
892: int i;
893: gwclip.fontsize = MulDiv(windowfontsize, lpgw->ymax, rect.bottom);
894: gwclip.hfonth = gwclip.hfontv = 0;
895:
896: /* HBB 981203: scale up pens as well... */
897: for (i=0; i<WGNUMPENS+2; i++) {
898: if(gwclip.monopen[i].lopnWidth.x > 1)
899: gwclip.monopen[i].lopnWidth.x =
900: MulDiv(gwclip.monopen[i].lopnWidth.x,
901: gwclip.xmax, rect.right-rect.left);
902: if(gwclip.colorpen[i].lopnWidth.x > 1)
903: gwclip.colorpen[i].lopnWidth.x =
904: MulDiv(gwclip.colorpen[i].lopnWidth.x,
905: gwclip.xmax, rect.right-rect.left);
906: }
907:
908: rect.right = lpgw->xmax;
909: rect.bottom = lpgw->ymax;
910:
911: MakePens(&gwclip, hdc);
912: MakeFonts(&gwclip, &rect, hdc);
913:
914: ReleaseDC(hwnd, hdc);
915:
916: hdc = CreateMetaFile((LPSTR)NULL);
917:
918: /* HBB 981203: According to Petzold, Metafiles shouldn't contain SetMapMode() calls: */
919: /*SetMapMode(hdc, MM_ANISOTROPIC);*/
920: #ifdef WIN32
921: SetWindowExtEx(hdc, rect.right, rect.bottom, (LPSIZE)NULL);
922: #else
923: SetWindowExt(hdc, rect.right, rect.bottom);
924: #endif
925: drawgraph(&gwclip, hdc, (void *) &rect);
926: hmf = CloseMetaFile(hdc);
927: DestroyFonts(&gwclip);
928: DestroyPens(&gwclip);
929: }
930:
931: hGMem = GlobalAlloc(GMEM_MOVEABLE, (DWORD)sizeof(METAFILEPICT));
932: lpMFP = (LPMETAFILEPICT) GlobalLock(hGMem);
933: hdc = GetDC(hwnd); /* get window size */
934: GetClientRect(hwnd, &rect);
935: /* in MM_ANISOTROPIC, xExt & yExt give suggested size in 0.01mm units */
936: lpMFP->mm = MM_ANISOTROPIC;
937: lpMFP->xExt = MulDiv(rect.right-rect.left, 2540, GetDeviceCaps(hdc, LOGPIXELSX));
938: /* HBB 981203: Seems it should be LOGPIXELS_Y_, here, not _X_*/
939: lpMFP->yExt = MulDiv(rect.bottom-rect.top, 2540, GetDeviceCaps(hdc, LOGPIXELSY));
940: lpMFP->hMF = hmf;
941: ReleaseDC(hwnd, hdc);
942: GlobalUnlock(hGMem);
943:
944: OpenClipboard(hwnd);
945: EmptyClipboard();
946: SetClipboardData(CF_METAFILEPICT,hGMem);
947: SetClipboardData(CF_BITMAP, bitmap);
948: CloseClipboard();
949: return;
950: }
951:
952: /* copy graph window to printer */
953: void
954: CopyPrint(LPGW lpgw)
955: {
956: #ifdef WIN32
957: DOCINFO docInfo;
958: #endif
959:
960: #if WINVER >= 0x030a
961: HDC printer;
962: DLGPROC lpfnAbortProc;
963: DLGPROC lpfnPrintDlgProc;
964: PRINTDLG pd;
965: HWND hwnd;
966: RECT rect;
967: PRINT pr;
968: UINT widabort;
969:
970: hwnd = lpgw->hWndGraph;
971:
972: _fmemset(&pd, 0, sizeof(PRINTDLG));
973: pd.lStructSize = sizeof(PRINTDLG);
974: pd.hwndOwner = hwnd;
975: pd.Flags = PD_PRINTSETUP | PD_RETURNDC;
976:
977: if (!PrintDlg(&pd))
978: return;
979: printer = pd.hDC;
980: if (NULL == printer)
981: return; /* abort */
982:
983: if (!PrintSize(printer, hwnd, &rect)) {
984: DeleteDC(printer);
985: return; /* abort */
986: }
987:
988: pr.hdcPrn = printer;
989: SetWindowLong(hwnd, 4, (LONG)((LPPRINT)&pr));
990: #ifdef WIN32
991: PrintRegister((LPPRINT)&pr);
992: #endif
993:
994: EnableWindow(hwnd,FALSE);
995: pr.bUserAbort = FALSE;
996: #ifdef WIN32
997: pr.hDlgPrint = CreateDialogParam(hdllInstance,"CancelDlgBox",hwnd,PrintDlgProc,(LPARAM)lpgw->Title);
998: SetAbortProc(printer,PrintAbortProc);
999:
1000: memset(&docInfo, 0, sizeof(DOCINFO));
1001: docInfo.cbSize = sizeof(DOCINFO);
1002: docInfo.lpszDocName = lpgw->Title;
1003:
1004: if (StartDoc(printer, &docInfo) > 0) {
1005: #else
1006: #ifdef __DLL__
1007: lpfnPrintDlgProc = (DLGPROC)GetProcAddress(hdllInstance, "PrintDlgProc");
1008: lpfnAbortProc = (DLGPROC)GetProcAddress(hdllInstance, "PrintAbortProc");
1009: #else
1010: lpfnPrintDlgProc = (DLGPROC)MakeProcInstance((FARPROC)PrintDlgProc, hdllInstance);
1011: lpfnAbortProc = (DLGPROC)MakeProcInstance((FARPROC)PrintAbortProc, hdllInstance);
1012: #endif
1013: pr.hDlgPrint = CreateDialogParam(hdllInstance,"CancelDlgBox",hwnd,lpfnPrintDlgProc,(LPARAM)lpgw->Title);
1014: Escape(printer,SETABORTPROC,0,(LPSTR)lpfnAbortProc,NULL);
1015: if (Escape(printer, STARTDOC, lstrlen(lpgw->Title),lpgw->Title, NULL) > 0) {
1016: #endif
1017: SetMapMode(printer, MM_TEXT);
1018: SetBkMode(printer,OPAQUE);
1019: #ifdef WIN32
1020: StartPage(printer);
1021: #endif
1022: DestroyFonts(lpgw);
1023: MakeFonts(lpgw, (RECT FAR *)&rect, printer);
1024: DestroyPens(lpgw); /* rebuild pens */
1025: MakePens(lpgw, printer);
1026: drawgraph(lpgw, printer, (void *) &rect);
1027: #ifdef WIN32
1028: if (EndPage(printer) > 0)
1029: EndDoc(printer);
1030: #else
1031: if (Escape(printer,NEWFRAME,0,NULL,NULL) > 0)
1032: Escape(printer,ENDDOC,0,NULL,NULL);
1033: #endif
1034: }
1035: if (!pr.bUserAbort) {
1036: EnableWindow(hwnd,TRUE);
1037: DestroyWindow(pr.hDlgPrint);
1038: }
1039: #ifndef WIN32
1040: #ifndef __DLL__
1041: FreeProcInstance((FARPROC)lpfnPrintDlgProc);
1042: FreeProcInstance((FARPROC)lpfnAbortProc);
1043: #endif
1044: #endif
1045: DeleteDC(printer);
1046: SetWindowLong(hwnd, 4, (LONG)(0L));
1047: #ifdef WIN32
1048: PrintUnregister((LPPRINT)&pr);
1049: #endif
1050: /* make certain that the screen pen set is restored */
1051: SendMessage(lpgw->hWndGraph,WM_COMMAND,M_REBUILDTOOLS,0L);
1052: #endif
1053: return;
1054: }
1055:
1056: /* ================================== */
1057: /* INI file stuff */
1058: void
1059: WriteGraphIni(LPGW lpgw)
1060: {
1061: RECT rect;
1062: int i;
1063: char entry[32];
1064: LPLOGPEN pc;
1065: LPLOGPEN pm;
1066: LPSTR file = lpgw->IniFile;
1067: LPSTR section = lpgw->IniSection;
1068: char profile[80];
1069:
1070: if ((file == (LPSTR)NULL) || (section == (LPSTR)NULL))
1071: return;
1072: if (IsIconic(lpgw->hWndGraph))
1073: ShowWindow(lpgw->hWndGraph, SW_SHOWNORMAL);
1074: GetWindowRect(lpgw->hWndGraph,&rect);
1075: wsprintf(profile, "%d %d", rect.left, rect.top);
1076: WritePrivateProfileString(section, "GraphOrigin", profile, file);
1077: wsprintf(profile, "%d %d", rect.right-rect.left, rect.bottom-rect.top);
1078: WritePrivateProfileString(section, "GraphSize", profile, file);
1079: wsprintf(profile, "%s,%d", lpgw->fontname, lpgw->fontsize);
1080: WritePrivateProfileString(section, "GraphFont", profile, file);
1081: wsprintf(profile, "%d", lpgw->color);
1082: WritePrivateProfileString(section, "GraphColor", profile, file);
1083: wsprintf(profile, "%d", lpgw->graphtotop);
1084: WritePrivateProfileString(section, "GraphToTop", profile, file);
1085: wsprintf(profile, "%d %d %d",GetRValue(lpgw->background),
1086: GetGValue(lpgw->background), GetBValue(lpgw->background));
1087: WritePrivateProfileString(section, "GraphBackground", profile, file);
1088:
1089: /* now save pens */
1090: for (i=0; i<WGNUMPENS+2; i++) {
1091: if (i==0)
1092: _fstrcpy(entry,"Border");
1093: else if (i==1)
1094: _fstrcpy(entry,"Axis");
1095: else
1096: wsprintf(entry,"Line%d",i-1);
1097: pc = &lpgw->colorpen[i];
1098: pm = &lpgw->monopen[i];
1099: wsprintf(profile, "%d %d %d %d %d",GetRValue(pc->lopnColor),
1100: GetGValue(pc->lopnColor), GetBValue(pc->lopnColor),
1101: (pc->lopnWidth.x != 1) ? -pc->lopnWidth.x : pc->lopnStyle,
1102: (pm->lopnWidth.x != 1) ? -pm->lopnWidth.x : pm->lopnStyle);
1103: WritePrivateProfileString(section, entry, profile, file);
1104: }
1105: return;
1106: }
1107:
1108: void
1109: ReadGraphIni(LPGW lpgw)
1110: {
1111: LPSTR file = lpgw->IniFile;
1112: LPSTR section = lpgw->IniSection;
1113: char profile[81];
1114: char entry[32];
1115: LPSTR p;
1116: int i,r,g,b,colorstyle,monostyle;
1117: COLORREF ref;
1118: BOOL bOKINI;
1119:
1120: bOKINI = (file != (LPSTR)NULL) && (section != (LPSTR)NULL);
1121: if (!bOKINI)
1122: profile[0] = '\0';
1123:
1124: if (bOKINI)
1125: GetPrivateProfileString(section, "GraphOrigin", "", profile, 80, file);
1126: if ( (p = GetInt(profile, (LPINT)&lpgw->Origin.x)) == NULL)
1127: lpgw->Origin.x = CW_USEDEFAULT;
1128: if ( (p = GetInt(p, (LPINT)&lpgw->Origin.y)) == NULL)
1129: lpgw->Origin.y = CW_USEDEFAULT;
1130: if (bOKINI)
1131: GetPrivateProfileString(section, "GraphSize", "", profile, 80, file);
1132: if ( (p = GetInt(profile, (LPINT)&lpgw->Size.x)) == NULL)
1133: lpgw->Size.x = CW_USEDEFAULT;
1134: if ( (p = GetInt(p, (LPINT)&lpgw->Size.y)) == NULL)
1135: lpgw->Size.y = CW_USEDEFAULT;
1136:
1137: if (bOKINI)
1138: GetPrivateProfileString(section, "GraphFont", "", profile, 80, file);
1139: {
1140: char FAR *size;
1141: size = _fstrchr(profile,',');
1142: if (size) {
1143: *size++ = '\0';
1144: if ( (p = GetInt(size, (LPINT)&lpgw->fontsize)) == NULL)
1145: lpgw->fontsize = WINFONTSIZE;
1146: }
1147: _fstrcpy(lpgw->fontname, profile);
1148: if (lpgw->fontsize == 0)
1149: lpgw->fontsize = WINFONTSIZE;
1150: if (!(*lpgw->fontname))
1151: if (LOWORD(GetVersion()) == 3)
1152: _fstrcpy(lpgw->fontname,WIN30FONT);
1153: else
1154: _fstrcpy(lpgw->fontname,WINFONT);
1155: }
1156:
1157: if (bOKINI)
1158: GetPrivateProfileString(section, "GraphColor", "", profile, 80, file);
1159: if ( (p = GetInt(profile, (LPINT)&lpgw->color)) == NULL)
1160: lpgw->color = TRUE;
1161:
1162: if (bOKINI)
1163: GetPrivateProfileString(section, "GraphToTop", "", profile, 80, file);
1164: if ( (p = GetInt(profile, (LPINT)&lpgw->graphtotop)) == NULL)
1165: lpgw->graphtotop = TRUE;
1166:
1167: lpgw->background = RGB(255,255,255);
1168: if (bOKINI)
1169: GetPrivateProfileString(section, "GraphBackground", "", profile, 80, file);
1170: if ( ((p = GetInt(profile, (LPINT)&r)) != NULL) &&
1171: ((p = GetInt(p, (LPINT)&g)) != NULL) &&
1172: ((p = GetInt(p, (LPINT)&b)) != NULL) )
1173: lpgw->background = RGB(r,g,b);
1174:
1175: StorePen(lpgw, 0,RGB(0,0,0),PS_SOLID,PS_SOLID);
1176: if (bOKINI)
1177: GetPrivateProfileString(section, "Border", "", profile, 80, file);
1178: if ( ((p = GetInt(profile, (LPINT)&r)) != NULL) &&
1179: ((p = GetInt(p, (LPINT)&g)) != NULL) &&
1180: ((p = GetInt(p, (LPINT)&b)) != NULL) &&
1181: ((p = GetInt(p, (LPINT)&colorstyle)) != NULL) &&
1182: ((p = GetInt(p, (LPINT)&monostyle)) != NULL) )
1183: StorePen(lpgw,0,RGB(r,g,b),colorstyle,monostyle);
1184:
1185: StorePen(lpgw, 1,RGB(192,192,192),PS_DOT,PS_DOT);
1186: if (bOKINI)
1187: GetPrivateProfileString(section, "Axis", "", profile, 80, file);
1188: if ( ((p = GetInt(profile, (LPINT)&r)) != NULL) &&
1189: ((p = GetInt(p, (LPINT)&g)) != NULL) &&
1190: ((p = GetInt(p, (LPINT)&b)) != NULL) &&
1191: ((p = GetInt(p, (LPINT)&colorstyle)) != NULL) &&
1192: ((p = GetInt(p, (LPINT)&monostyle)) != NULL) )
1193: StorePen(lpgw,1,RGB(r,g,b),colorstyle,monostyle);
1194:
1195: for (i=0; i<WGNUMPENS; i++)
1196: {
1197: ref = wginitcolor[ i%WGDEFCOLOR ];
1198: colorstyle = wginitstyle[ (i/WGDEFCOLOR) % WGDEFSTYLE ];
1199: monostyle = wginitstyle[ i%WGDEFSTYLE ];
1200: StorePen(lpgw, i+2,ref,colorstyle,monostyle);
1201: wsprintf(entry,"Line%d",i+1);
1202: if (bOKINI)
1203: GetPrivateProfileString(section, entry, "", profile, 80, file);
1204: if ( ((p = GetInt(profile, (LPINT)&r)) != NULL) &&
1205: ((p = GetInt(p, (LPINT)&g)) != NULL) &&
1206: ((p = GetInt(p, (LPINT)&b)) != NULL) &&
1207: ((p = GetInt(p, (LPINT)&colorstyle)) != NULL) &&
1208: ((p = GetInt(p, (LPINT)&monostyle)) != NULL) )
1209: StorePen(lpgw,i+2,RGB(r,g,b),colorstyle,monostyle);
1210: }
1211: }
1212:
1213:
1214: /* ================================== */
1215:
1216: #define LS_DEFLINE 2
1217: typedef struct tagLS {
1218: int widtype;
1219: int wid;
1220: HWND hwnd;
1221: int pen; /* current pen number */
1222: LOGPEN colorpen[WGNUMPENS+2]; /* logical color pens */
1223: LOGPEN monopen[WGNUMPENS+2]; /* logical mono pens */
1224: } LS;
1225: typedef LS FAR* LPLS;
1226:
1227:
1228: COLORREF
1229: GetColor(HWND hwnd, COLORREF ref)
1230: {
1231: CHOOSECOLOR cc;
1232: COLORREF aclrCust[16];
1233: int i;
1234:
1235: for (i=0; i<16; i++) {
1236: aclrCust[i] = RGB(0,0,0);
1237: }
1238: _fmemset(&cc, 0, sizeof(CHOOSECOLOR));
1239: cc.lStructSize = sizeof(CHOOSECOLOR);
1240: cc.hwndOwner = hwnd;
1241: cc.lpCustColors = aclrCust;
1242: cc.rgbResult = ref;
1243: cc.Flags = CC_RGBINIT;
1244: if (ChooseColor(&cc))
1245: return cc.rgbResult;
1246: return ref;
1247: }
1248:
1249:
1250: /* force update of owner draw button */
1251: void
1252: UpdateColorSample(HWND hdlg)
1253: {
1254: RECT rect;
1255: POINT ptul, ptlr;
1256: GetWindowRect( GetDlgItem(hdlg, LS_COLORSAMPLE), &rect);
1257: ptul.x = rect.left;
1258: ptul.y = rect.top;
1259: ptlr.x = rect.right;
1260: ptlr.y = rect.bottom;
1261: ScreenToClient(hdlg, &ptul);
1262: ScreenToClient(hdlg, &ptlr);
1263: rect.left = ptul.x;
1264: rect.top = ptul.y;
1265: rect.right = ptlr.x;
1266: rect.bottom = ptlr.y;
1267: InvalidateRect(hdlg, &rect, TRUE);
1268: UpdateWindow(hdlg);
1269: }
1270:
1271: BOOL CALLBACK WINEXPORT
1272: LineStyleDlgProc(HWND hdlg, UINT wmsg, WPARAM wparam, LPARAM lparam)
1273: {
1274: char buf[16];
1275: LPLS lpls;
1276: int i;
1277: UINT pen;
1278: LPLOGPEN plpm, plpc;
1279: lpls = (LPLS)GetWindowLong(GetParent(hdlg), 4);
1280:
1281: switch (wmsg) {
1282: case WM_INITDIALOG:
1283: pen = 2;
1284: for (i=0; i<WGNUMPENS+2; i++) {
1285: if (i==0)
1286: _fstrcpy(buf,"Border");
1287: else if (i==1)
1288: _fstrcpy(buf,"Axis");
1289: else
1290: wsprintf(buf,"Line%d",i-1);
1291: SendDlgItemMessage(hdlg, LS_LINENUM, LB_ADDSTRING, 0,
1292: (LPARAM)((LPSTR)buf));
1293: }
1294: SendDlgItemMessage(hdlg, LS_LINENUM, LB_SETCURSEL, pen, 0L);
1295:
1296: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_ADDSTRING, 0,
1297: (LPARAM)((LPSTR)"Solid"));
1298: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_ADDSTRING, 0,
1299: (LPARAM)((LPSTR)"Dash"));
1300: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_ADDSTRING, 0,
1301: (LPARAM)((LPSTR)"Dot"));
1302: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_ADDSTRING, 0,
1303: (LPARAM)((LPSTR)"DashDot"));
1304: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_ADDSTRING, 0,
1305: (LPARAM)((LPSTR)"DashDotDot"));
1306:
1307: plpm = &lpls->monopen[pen];
1308: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_SETCURSEL,
1309: plpm->lopnStyle, 0L);
1310: wsprintf(buf,"%d",plpm->lopnWidth.x);
1311: SetDlgItemText(hdlg, LS_MONOWIDTH, buf);
1312:
1313: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_ADDSTRING, 0,
1314: (LPARAM)((LPSTR)"Solid"));
1315: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_ADDSTRING, 0,
1316: (LPARAM)((LPSTR)"Dash"));
1317: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_ADDSTRING, 0,
1318: (LPARAM)((LPSTR)"Dot"));
1319: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_ADDSTRING, 0,
1320: (LPARAM)((LPSTR)"DashDot"));
1321: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_ADDSTRING, 0,
1322: (LPARAM)((LPSTR)"DashDotDot"));
1323:
1324: plpc = &lpls->colorpen[pen];
1325: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_SETCURSEL,
1326: plpc->lopnStyle, 0L);
1327: wsprintf(buf,"%d",plpc->lopnWidth.x);
1328: SetDlgItemText(hdlg, LS_COLORWIDTH, buf);
1329:
1330: return TRUE;
1331: case WM_COMMAND:
1332: pen = (UINT)SendDlgItemMessage(hdlg, LS_LINENUM, LB_GETCURSEL, 0, 0L);
1333: plpm = &lpls->monopen[pen];
1334: plpc = &lpls->colorpen[pen];
1335: switch (LOWORD(wparam)) {
1336: case LS_LINENUM:
1337: wsprintf(buf,"%d",plpm->lopnWidth.x);
1338: SetDlgItemText(hdlg, LS_MONOWIDTH, buf);
1339: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_SETCURSEL,
1340: plpm->lopnStyle, 0L);
1341: wsprintf(buf,"%d",plpc->lopnWidth.x);
1342: SetDlgItemText(hdlg, LS_COLORWIDTH, buf);
1343: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_SETCURSEL,
1344: plpc->lopnStyle, 0L);
1345: UpdateColorSample(hdlg);
1346: return FALSE;
1347: case LS_MONOSTYLE:
1348: plpm->lopnStyle =
1349: (UINT)SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_GETCURSEL, 0, 0L);
1350: if (plpm->lopnStyle != 0) {
1351: plpm->lopnWidth.x = 1;
1352: wsprintf(buf,"%d",plpm->lopnWidth.x);
1353: SetDlgItemText(hdlg, LS_MONOWIDTH, buf);
1354: }
1355: return FALSE;
1356: case LS_MONOWIDTH:
1357: GetDlgItemText(hdlg, LS_MONOWIDTH, buf, 15);
1358: GetInt(buf, (LPINT)&plpm->lopnWidth.x);
1359: if (plpm->lopnWidth.x != 1) {
1360: plpm->lopnStyle = 0;
1361: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_SETCURSEL,
1362: plpm->lopnStyle, 0L);
1363: }
1364: return FALSE;
1365: case LS_CHOOSECOLOR:
1366: plpc->lopnColor = GetColor(hdlg, plpc->lopnColor);
1367: UpdateColorSample(hdlg);
1368: return FALSE;
1369: case LS_COLORSTYLE:
1370: plpc->lopnStyle =
1371: (UINT)SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_GETCURSEL, 0, 0L);
1372: if (plpc->lopnStyle != 0) {
1373: plpc->lopnWidth.x = 1;
1374: wsprintf(buf,"%d",plpc->lopnWidth.x);
1375: SetDlgItemText(hdlg, LS_COLORWIDTH, buf);
1376: }
1377: return FALSE;
1378: case LS_COLORWIDTH:
1379: GetDlgItemText(hdlg, LS_COLORWIDTH, buf, 15);
1380: GetInt(buf, (LPINT)&plpc->lopnWidth.x);
1381: if (plpc->lopnWidth.x != 1) {
1382: plpc->lopnStyle = 0;
1383: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_SETCURSEL,
1384: plpc->lopnStyle, 0L);
1385: }
1386: return FALSE;
1387: case LS_DEFAULT:
1388: plpm = lpls->monopen;
1389: plpc = lpls->colorpen;
1390: /* border */
1391: plpc->lopnColor = RGB(0,0,0);
1392: plpc->lopnStyle = PS_SOLID;
1393: plpc->lopnWidth.x = 1;
1394: plpm->lopnStyle = PS_SOLID;
1395: plpm->lopnWidth.x = 1;
1396: plpc++; plpm++;
1397: /* axis */
1398: plpc->lopnColor = RGB(192,192,192);
1399: plpc->lopnStyle = PS_DOT;
1400: plpc->lopnWidth.x = 1;
1401: plpm->lopnStyle = PS_DOT;
1402: plpm->lopnWidth.x = 1;
1403: /* LineX */
1404: for (i=0; i<WGNUMPENS; i++) {
1405: plpc++; plpm++;
1406: plpc->lopnColor = wginitcolor[ i%WGDEFCOLOR ];
1407: plpc->lopnStyle = wginitstyle[ (i/WGDEFCOLOR) % WGDEFSTYLE ];
1408: plpc->lopnWidth.x = 1;
1409: plpm->lopnStyle = wginitstyle[ i%WGDEFSTYLE ];
1410: plpm->lopnWidth.x = 1;
1411: }
1412: /* update window */
1413: plpm = &lpls->monopen[pen];
1414: plpc = &lpls->colorpen[pen];
1415: SendDlgItemMessage(hdlg, LS_LINENUM, LB_SETCURSEL, pen, 0L);
1416: wsprintf(buf,"%d",plpm->lopnWidth.x);
1417: SetDlgItemText(hdlg, LS_MONOWIDTH, buf);
1418: SendDlgItemMessage(hdlg, LS_MONOSTYLE, CB_SETCURSEL,
1419: plpm->lopnStyle, 0L);
1420: wsprintf(buf,"%d",plpc->lopnWidth.x);
1421: SetDlgItemText(hdlg, LS_COLORWIDTH, buf);
1422: SendDlgItemMessage(hdlg, LS_COLORSTYLE, CB_SETCURSEL,
1423: plpc->lopnStyle, 0L);
1424: UpdateColorSample(hdlg);
1425: return FALSE;
1426: case IDOK:
1427: EndDialog(hdlg, IDOK);
1428: return TRUE;
1429: case IDCANCEL:
1430: EndDialog(hdlg, IDCANCEL);
1431: return TRUE;
1432: }
1433: break;
1434: case WM_DRAWITEM:
1435: {
1436: HBRUSH hBrush;
1437: LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lparam;
1438: pen = (UINT)SendDlgItemMessage(hdlg, LS_LINENUM, LB_GETCURSEL, (WPARAM)0, (LPARAM)0);
1439: plpc = &lpls->colorpen[pen];
1440: hBrush = CreateSolidBrush(plpc->lopnColor);
1441: FillRect(lpdis->hDC, &lpdis->rcItem, hBrush);
1442: FrameRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)GetStockObject(BLACK_BRUSH));
1443: DeleteObject(hBrush);
1444: }
1445: return FALSE;
1446: }
1447: return FALSE;
1448: }
1449:
1450:
1451:
1452: /* GetWindowLong(hwnd, 4) must be available for use */
1453: BOOL
1454: LineStyle(LPGW lpgw)
1455: {
1456: DLGPROC lpfnLineStyleDlgProc ;
1457: BOOL status = FALSE;
1458: LS ls;
1459:
1460: SetWindowLong(lpgw->hWndGraph, 4, (LONG)((LPLS)&ls));
1461: _fmemcpy(&ls.colorpen, &lpgw->colorpen, (WGNUMPENS + 2) * sizeof(LOGPEN));
1462: _fmemcpy(&ls.monopen, &lpgw->monopen, (WGNUMPENS + 2) * sizeof(LOGPEN));
1463:
1464: #ifdef WIN32
1465: if (DialogBox (hdllInstance, "LineStyleDlgBox", lpgw->hWndGraph, LineStyleDlgProc)
1466: #else
1467: #ifdef __DLL__
1468: lpfnLineStyleDlgProc = (DLGPROC)GetProcAddress(hdllInstance, "LineStyleDlgProc");
1469: #else
1470: lpfnLineStyleDlgProc = (DLGPROC)MakeProcInstance((FARPROC)LineStyleDlgProc, hdllInstance);
1471: #endif
1472: if (DialogBox (hdllInstance, "LineStyleDlgBox", lpgw->hWndGraph, lpfnLineStyleDlgProc)
1473: #endif
1474: == IDOK) {
1475: _fmemcpy(&lpgw->colorpen, &ls.colorpen, (WGNUMPENS + 2) * sizeof(LOGPEN));
1476: _fmemcpy(&lpgw->monopen, &ls.monopen, (WGNUMPENS + 2) * sizeof(LOGPEN));
1477: status = TRUE;
1478: }
1479: #ifndef WIN32
1480: #ifndef __DLL__
1481: FreeProcInstance((FARPROC)lpfnLineStyleDlgProc);
1482: #endif
1483: #endif
1484: SetWindowLong(lpgw->hWndGraph, 4, (LONG)(0L));
1485: return status;
1486: }
1487:
1488: /* ================================== */
1489:
1490: LRESULT CALLBACK WINEXPORT
1491: WndGraphProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
1492: {
1493: HDC hdc;
1494: PAINTSTRUCT ps;
1495: RECT rect;
1496: LPGW lpgw;
1497: HMENU sysmenu;
1498: int i;
1499:
1500: lpgw = (LPGW)GetWindowLong(hwnd, 0);
1501:
1502: switch(message)
1503: {
1504: case WM_SYSCOMMAND:
1505: switch(LOWORD(wParam))
1506: {
1507: case M_GRAPH_TO_TOP:
1508: case M_COLOR:
1509: case M_CHOOSE_FONT:
1510: case M_COPY_CLIP:
1511: case M_LINESTYLE:
1512: case M_BACKGROUND:
1513: case M_PRINT:
1514: case M_WRITEINI:
1515: case M_REBUILDTOOLS:
1516: SendMessage(hwnd, WM_COMMAND, wParam, lParam);
1517: break;
1518: case M_ABOUT:
1519: if (lpgw->lptw)
1520: AboutBox(hwnd,lpgw->lptw->AboutText);
1521: return 0;
1522: case M_COMMANDLINE:
1523: sysmenu = GetSystemMenu(lpgw->hWndGraph,0);
1524: i = GetMenuItemCount (sysmenu);
1525: DeleteMenu (sysmenu, --i, MF_BYPOSITION);
1526: DeleteMenu (sysmenu, --i, MF_BYPOSITION);
1527: ShowWindow (lpgw->lptw->hWndParent, SW_SHOW);
1528: break;
1529: }
1530: break;
1531: case WM_COMMAND:
1532: switch(LOWORD(wParam))
1533: {
1534: case M_GRAPH_TO_TOP:
1535: lpgw->graphtotop = !lpgw->graphtotop;
1536: SendMessage(hwnd,WM_COMMAND,M_REBUILDTOOLS,0L);
1537: return(0);
1538: case M_COLOR:
1539: lpgw->color = !lpgw->color;
1540: SendMessage(hwnd,WM_COMMAND,M_REBUILDTOOLS,0L);
1541: return(0);
1542: case M_CHOOSE_FONT:
1543: SelFont(lpgw);
1544: return 0;
1545: case M_COPY_CLIP:
1546: CopyClip(lpgw);
1547: return 0;
1548: case M_LINESTYLE:
1549: if (LineStyle(lpgw))
1550: SendMessage(hwnd,WM_COMMAND,M_REBUILDTOOLS,0L);
1551: return 0;
1552: case M_BACKGROUND:
1553: lpgw->background = GetColor(hwnd, lpgw->background);
1554: SendMessage(hwnd,WM_COMMAND,M_REBUILDTOOLS,0L);
1555: return 0;
1556: case M_PRINT:
1557: CopyPrint(lpgw);
1558: return 0;
1559: case M_WRITEINI:
1560: WriteGraphIni(lpgw);
1561: if (lpgw->lptw)
1562: WriteTextIni(lpgw->lptw);
1563: return 0;
1564: case M_REBUILDTOOLS:
1565: lpgw->resized = TRUE;
1566: if (lpgw->color)
1567: CheckMenuItem(lpgw->hPopMenu, M_COLOR, MF_BYCOMMAND | MF_CHECKED);
1568: else
1569: CheckMenuItem(lpgw->hPopMenu, M_COLOR, MF_BYCOMMAND | MF_UNCHECKED);
1570: if (lpgw->graphtotop)
1571: CheckMenuItem(lpgw->hPopMenu, M_GRAPH_TO_TOP, MF_BYCOMMAND | MF_CHECKED);
1572: else
1573: CheckMenuItem(lpgw->hPopMenu, M_GRAPH_TO_TOP, MF_BYCOMMAND | MF_UNCHECKED);
1574: DestroyPens(lpgw);
1575: DestroyFonts(lpgw);
1576: hdc = GetDC(hwnd);
1577: MakePens(lpgw, hdc);
1578: GetClientRect(hwnd, &rect);
1579: MakeFonts(lpgw, (LPRECT)&rect, hdc);
1580: ReleaseDC(hwnd, hdc);
1581: GetClientRect(hwnd, &rect);
1582: InvalidateRect(hwnd, (LPRECT) &rect, 1);
1583: UpdateWindow(hwnd);
1584: return 0;
1585: }
1586: return 0;
1587: case WM_RBUTTONDOWN:
1588: {
1589: POINT pt;
1590: pt.x = LOWORD(lParam);
1591: pt.y = HIWORD(lParam);
1592: ClientToScreen(hwnd,&pt);
1593: TrackPopupMenu(lpgw->hPopMenu, TPM_LEFTALIGN,
1594: pt.x, pt.y, 0, hwnd, NULL);
1595: }
1596: return(0);
1597: case WM_CREATE:
1598: lpgw = ((CREATESTRUCT FAR *)lParam)->lpCreateParams;
1599: SetWindowLong(hwnd, 0, (LONG)lpgw);
1600: lpgw->hWndGraph = hwnd;
1601: hdc = GetDC(hwnd);
1602: MakePens(lpgw, hdc);
1603: GetClientRect(hwnd, &rect);
1604: MakeFonts(lpgw, (LPRECT)&rect, hdc);
1605: ReleaseDC(hwnd, hdc);
1606: #if WINVER >= 0x030a
1607: {
1608: WORD version = LOWORD(GetVersion());
1609: if ((LOBYTE(version)*100 + HIBYTE(version)) >= 310)
1610: if ( lpgw->lptw && (lpgw->lptw->DragPre!=(LPSTR)NULL) && (lpgw->lptw->DragPost!=(LPSTR)NULL) )
1611: DragAcceptFiles(hwnd, TRUE);
1612: }
1613: #endif
1614: return(0);
1615: case WM_PAINT:
1616: hdc = BeginPaint(hwnd, &ps);
1617: SetMapMode(hdc, MM_TEXT);
1618: SetBkMode(hdc,OPAQUE);
1619: GetClientRect(hwnd, &rect);
1620: #ifdef WIN32
1621: SetViewportExtEx(hdc, rect.right, rect.bottom, NULL);
1622: #else
1623: SetViewportExt(hdc, rect.right, rect.bottom);
1624: #endif
1625: drawgraph(lpgw, hdc, (void *) &rect);
1626: EndPaint(hwnd, &ps);
1627: return 0;
1628: case WM_SIZE:
1629: /* update font sizes if graph resized */
1630: if ((wParam == SIZE_MAXIMIZED) || (wParam == SIZE_RESTORED)) {
1631: RECT rect;
1632: SendMessage(hwnd,WM_SYSCOMMAND,M_REBUILDTOOLS,0L);
1633: GetWindowRect(hwnd,&rect);
1634: lpgw->Size.x = rect.right-rect.left;
1635: lpgw->Size.y = rect.bottom-rect.top;
1636: }
1637: break;
1638: #if WINVER >= 0x030a
1639: case WM_DROPFILES:
1640: {
1641: WORD version = LOWORD(GetVersion());
1642: if ((LOBYTE(version)*100 + HIBYTE(version)) >= 310)
1643: if (lpgw->lptw)
1644: DragFunc(lpgw->lptw, (HDROP)wParam);
1645: }
1646: break;
1647: #endif
1648: case WM_DESTROY:
1649: DestroyPens(lpgw);
1650: DestroyFonts(lpgw);
1651: #if __TURBOC__ >= 0x410 /* Borland C++ 3.1 or later */
1652: {
1653: WORD version = LOWORD(GetVersion());
1654: if ((LOBYTE(version)*100 + HIBYTE(version)) >= 310)
1655: DragAcceptFiles(hwnd, FALSE);
1656: }
1657: #endif
1658: if (lpgw->lptw && !IsWindowVisible(lpgw->lptw->hWndParent)) {
1659: PostMessage (lpgw->lptw->hWndParent, WM_CLOSE, 0, 0);
1660: }
1661: return 0;
1662: case WM_CLOSE:
1663: GraphClose(lpgw);
1664: return 0;
1665: }
1666: return DefWindowProc(hwnd, message, wParam, lParam);
1667: }
1668:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>