Annotation of OpenXM_contrib2/windows/engine2000/ox_plot_win.c, Revision 1.3
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.3 ! noro 48: * $OpenXM: OpenXM_contrib2/windows/engine2000/ox_plot_win.c,v 1.2 2001/10/09 01:36:29 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.3 ! noro 102: void popdown_canvas(int index);
! 103:
1.2 noro 104: void destroy_canvas(struct canvas *can)
1.1 noro 105: {
106: if ( can == current_can ) {
107: reset_busy(can); current_can = 0;
108: }
1.3 ! noro 109: popdown_canvas(can->index);
1.1 noro 110: }
111:
1.2 noro 112: void clear_pixmap(struct canvas *can)
1.1 noro 113: {
114: RECT rect;
115:
116: create_brushes();
117: rect.left = 0; rect.top = 0;
118: rect.right = can->width; rect.bottom = can->height;
119: FillRect(can->pix,&rect,ClearBrush);
120: }
121:
1.2 noro 122: void alloc_pixmap(struct canvas *can)
1.1 noro 123: {
124: HDC pix;
125: HBITMAP bm;
126: int bpp,np;
127: BITMAP bmobj;
128: void *bits;
129:
130: can->pix = pix = CreateCompatibleDC(NULL);
131: bpp = GetDeviceCaps(pix,BITSPIXEL);
132: np = GetDeviceCaps(pix,PLANES);
133:
134: // XXX: CreateCompatibleBitmap() creates a monochrome bitmap
135: // bm = CreateCompatibleBitmap(pix,can->width,can->height);
136: bits = (void *)calloc(((bpp*can->width+31)/32)*can->height*np,4);
137: bm = CreateBitmap(can->width,can->height,np,bpp,bits);
138:
139: SelectObject(pix,bm);
140: clear_pixmap(can);
141: current_can = can;
142: }
143:
1.2 noro 144: void copy_to_canvas(struct canvas *can)
1.1 noro 145: {
146: PostThreadMessage(MainThread,WM_APP,can->index,0);
1.3 ! noro 147: }
! 148:
! 149: void popup_canvas(int index)
! 150: {
! 151: PostThreadMessage(MainThread,WM_APP+1,index,0);
! 152: }
! 153:
! 154: void popdown_canvas(int index)
! 155: {
! 156: PostThreadMessage(MainThread,WM_APP+2,index,0);
1.1 noro 157: }
158:
1.2 noro 159: void copy_subimage(struct canvas *subcan,struct canvas *can,POINT pos)
1.1 noro 160: {
161: BitBlt(can->pix,pos.x,pos.y,subcan->width,subcan->height,subcan->pix,0,0,SRCCOPY);
162: }
163:
1.2 noro 164: void draw_wideframe(struct canvas *can,DRAWABLE d)
1.1 noro 165: {
166: struct canvas fakecan;
167: double xmid,ymid,dx,dy;
168: POINT s,e;
169: RECT rect;
170:
171: fakecan = *can;
172: dx = 10*(can->xmax-can->xmin); dy = 10*(can->ymax-can->ymin);
173: xmid = (can->xmax+can->xmin)/2; ymid = (can->ymax+can->ymin)/2;
174:
175: fakecan.xmin = xmid-dx/2; fakecan.xmax = xmid+dx/2;
176: fakecan.ymin = ymid-dy/2; fakecan.ymax = ymid+dy/2;
177:
178: rect.left = 0; rect.top = 0;
179: rect.right = can->width; rect.bottom = can->height;
180: create_brushes();
181: FillRect(d,&rect,ClearBrush);
182: pline(display,&fakecan,d);
183: XC(s) = can->width*9/20; YC(s) = can->height*9/20;
184: XC(e) = can->width*11/20; YC(e) = can->height*11/20;
185: draw_frame0(d,s,e);
186: }
187:
188: void create_brushes()
189: {
190: if ( !ClearBrush )
191: ClearBrush = CreateSolidBrush(0xffffff);
192: if ( !DrawBrush )
193: DrawBrush = CreateSolidBrush(0);
194: }
195:
1.2 noro 196: void draw_frame0(DRAWABLE d,POINT spos,POINT epos)
1.1 noro 197: {
198: RECT rect;
199: int ulx,uly,w,h;
200:
201: ulx = MIN(XC(spos),XC(epos)); uly = MIN(YC(spos),YC(epos));
202: w = ABS(XC(spos)-XC(epos)); h = ABS(YC(spos)-YC(epos));
203: if ( !w || !h )
204: return;
205: rect.left = spos.x; rect.top = spos.y;
206: rect.right = epos.x; rect.bottom = epos.y;
207: FrameRect(d,&rect,DrawBrush);
208: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>