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