Annotation of OpenXM_contrib2/windows/engine2000/ox_plot_win.c, Revision 1.4
1.1 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.4 ! noro 48: * $OpenXM: OpenXM_contrib2/windows/engine2000/ox_plot_win.c,v 1.3 2002/07/30 03:06:20 noro Exp $
1.1 noro 49: */
50: #include "ca.h"
51: #include "parse.h"
52: #include "ox.h"
53: #include "ifplot.h"
54:
55: #ifdef ABS
56: #undef ABS
57: #define ABS(a) ((a)>0?(a):-(a))
58: #endif
59:
60: static char *dname;
61: static int remotes;
62: static int depth,scrn;
63:
64: extern jmp_buf ox_env;
65: extern DWORD MainThread;
66:
67:
68: static int busy;
69:
70: HBRUSH ClearBrush,DrawBrush;
71:
72: #define LABELWIDTH 150
73:
74: int search_canvas()
75: {
76: int i;
77:
78: for ( i = 0; i < MAXCANVAS; i++ )
79: if ( !canvas[i] ) {
80: canvas[i] = (struct canvas *)MALLOC(sizeof(struct canvas));
81: canvas[i]->index = i; return i;
82: }
83: }
84:
85: int search_active_canvas()
86: {
87: int i;
88:
89: for ( i = 0; i < MAXCANVAS; i++ )
90: if ( canvas[i] )
91: return i;
92: return -1;
93: }
94:
1.2 noro 95: void create_canvas(struct canvas *can)
1.1 noro 96: {
97: alloc_pixmap(can);
98: can->real_can = can;
99: PostThreadMessage(MainThread,WM_APP,can->index,0);
100: }
101:
1.2 noro 102: void destroy_canvas(struct canvas *can)
1.1 noro 103: {
104: if ( can == current_can ) {
105: reset_busy(can); current_can = 0;
106: }
1.4 ! noro 107: can->window = 0;
! 108: DeleteObject(can->pix);
! 109: closed_canvas[can->index] = can;
! 110: canvas[can->index] = 0;
1.1 noro 111: }
112:
1.2 noro 113: void clear_pixmap(struct canvas *can)
1.1 noro 114: {
115: RECT rect;
116:
117: create_brushes();
118: rect.left = 0; rect.top = 0;
119: rect.right = can->width; rect.bottom = can->height;
120: FillRect(can->pix,&rect,ClearBrush);
121: }
122:
1.2 noro 123: void alloc_pixmap(struct canvas *can)
1.1 noro 124: {
125: HDC pix;
126: HBITMAP bm;
127: int bpp,np;
128: BITMAP bmobj;
129: void *bits;
130:
131: can->pix = pix = CreateCompatibleDC(NULL);
132: bpp = GetDeviceCaps(pix,BITSPIXEL);
133: np = GetDeviceCaps(pix,PLANES);
134:
135: // XXX: CreateCompatibleBitmap() creates a monochrome bitmap
136: // bm = CreateCompatibleBitmap(pix,can->width,can->height);
137: bits = (void *)calloc(((bpp*can->width+31)/32)*can->height*np,4);
138: bm = CreateBitmap(can->width,can->height,np,bpp,bits);
139:
140: SelectObject(pix,bm);
141: clear_pixmap(can);
142: current_can = can;
143: }
144:
1.2 noro 145: void copy_to_canvas(struct canvas *can)
1.1 noro 146: {
147: PostThreadMessage(MainThread,WM_APP,can->index,0);
1.3 noro 148: }
149:
150: void popup_canvas(int index)
151: {
1.4 ! noro 152: create_canvas(canvas[index]);
1.1 noro 153: }
154:
1.2 noro 155: void copy_subimage(struct canvas *subcan,struct canvas *can,POINT pos)
1.1 noro 156: {
157: BitBlt(can->pix,pos.x,pos.y,subcan->width,subcan->height,subcan->pix,0,0,SRCCOPY);
158: }
159:
1.2 noro 160: void draw_wideframe(struct canvas *can,DRAWABLE d)
1.1 noro 161: {
162: struct canvas fakecan;
163: double xmid,ymid,dx,dy;
164: POINT s,e;
165: RECT rect;
166:
167: fakecan = *can;
168: dx = 10*(can->xmax-can->xmin); dy = 10*(can->ymax-can->ymin);
169: xmid = (can->xmax+can->xmin)/2; ymid = (can->ymax+can->ymin)/2;
170:
171: fakecan.xmin = xmid-dx/2; fakecan.xmax = xmid+dx/2;
172: fakecan.ymin = ymid-dy/2; fakecan.ymax = ymid+dy/2;
173:
174: rect.left = 0; rect.top = 0;
175: rect.right = can->width; rect.bottom = can->height;
176: create_brushes();
177: FillRect(d,&rect,ClearBrush);
178: pline(display,&fakecan,d);
179: XC(s) = can->width*9/20; YC(s) = can->height*9/20;
180: XC(e) = can->width*11/20; YC(e) = can->height*11/20;
181: draw_frame0(d,s,e);
182: }
183:
184: void create_brushes()
185: {
186: if ( !ClearBrush )
187: ClearBrush = CreateSolidBrush(0xffffff);
188: if ( !DrawBrush )
189: DrawBrush = CreateSolidBrush(0);
190: }
191:
1.2 noro 192: void draw_frame0(DRAWABLE d,POINT spos,POINT epos)
1.1 noro 193: {
194: RECT rect;
195: int ulx,uly,w,h;
196:
197: ulx = MIN(XC(spos),XC(epos)); uly = MIN(YC(spos),YC(epos));
198: w = ABS(XC(spos)-XC(epos)); h = ABS(YC(spos)-YC(epos));
199: if ( !w || !h )
200: return;
201: rect.left = spos.x; rect.top = spos.y;
202: rect.right = epos.x; rect.bottom = epos.y;
203: FrameRect(d,&rect,DrawBrush);
204: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>