BitmapP.h revision eaef79e5
1eaef79e5Smrg/* $Xorg: BitmapP.h,v 1.4 2001/02/09 02:05:28 xorgcvs Exp $ */ 2eaef79e5Smrg/* 3eaef79e5Smrg 4eaef79e5SmrgCopyright 1989, 1998 The Open Group 5eaef79e5Smrg 6eaef79e5SmrgPermission to use, copy, modify, distribute, and sell this software and its 7eaef79e5Smrgdocumentation for any purpose is hereby granted without fee, provided that 8eaef79e5Smrgthe above copyright notice appear in all copies and that both that 9eaef79e5Smrgcopyright notice and this permission notice appear in supporting 10eaef79e5Smrgdocumentation. 11eaef79e5Smrg 12eaef79e5SmrgThe above copyright notice and this permission notice shall be included 13eaef79e5Smrgin all copies or substantial portions of the Software. 14eaef79e5Smrg 15eaef79e5SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16eaef79e5SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17eaef79e5SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18eaef79e5SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 19eaef79e5SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20eaef79e5SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21eaef79e5SmrgOTHER DEALINGS IN THE SOFTWARE. 22eaef79e5Smrg 23eaef79e5SmrgExcept as contained in this notice, the name of The Open Group shall 24eaef79e5Smrgnot be used in advertising or otherwise to promote the sale, use or 25eaef79e5Smrgother dealings in this Software without prior written authorization 26eaef79e5Smrgfrom The Open Group. 27eaef79e5Smrg 28eaef79e5Smrg*/ 29eaef79e5Smrg/* $XFree86: xc/programs/bitmap/BitmapP.h,v 1.3 2001/01/17 23:44:51 dawes Exp $ */ 30eaef79e5Smrg 31eaef79e5Smrg/* 32eaef79e5Smrg * Author: Davor Matic, MIT X Consortium 33eaef79e5Smrg */ 34eaef79e5Smrg 35eaef79e5Smrg 36eaef79e5Smrg 37eaef79e5Smrg#ifndef _BitmapP_h 38eaef79e5Smrg#define _BitmapP_h 39eaef79e5Smrg 40eaef79e5Smrg#define bit int 41eaef79e5Smrg 42eaef79e5Smrg#include "Bitmap.h" 43eaef79e5Smrg#include "Requests.h" 44eaef79e5Smrg#include <X11/Xaw/SimpleP.h> 45eaef79e5Smrg 46eaef79e5Smrgtypedef struct { 47eaef79e5Smrg Atom *targets; 48eaef79e5Smrg Cardinal num_targets; 49eaef79e5Smrg BWRequestRec *requests; 50eaef79e5Smrg Cardinal num_requests; 51eaef79e5Smrg BWRequestRec *request[100]; 52eaef79e5Smrg 53eaef79e5Smrg} BitmapClassPart; 54eaef79e5Smrg 55eaef79e5Smrg/* Full class record declaration */ 56eaef79e5Smrgtypedef struct _BitmapClassRec { 57eaef79e5Smrg CoreClassPart core_class; 58eaef79e5Smrg SimpleClassPart simple_class; 59eaef79e5Smrg BitmapClassPart bitmap_class; 60eaef79e5Smrg} BitmapClassRec; 61eaef79e5Smrg 62eaef79e5Smrgextern BitmapClassRec bitmapClassRec; 63eaef79e5Smrg 64eaef79e5Smrgtypedef void (*EngageProc)(Widget, BWStatus *, XtPointer, int *); 65eaef79e5Smrgtypedef void (*TerminateProc)( Widget, BWStatus *, XtPointer); 66eaef79e5Smrgtypedef void (*RemoveProc)(Widget w, BWStatus *, XtPointer); 67eaef79e5Smrg 68eaef79e5Smrg/**********/ 69eaef79e5Smrgstruct _BWRequestRec { 70eaef79e5Smrg char *name; 71eaef79e5Smrg int status_size; 72eaef79e5Smrg EngageProc engage; 73eaef79e5Smrg XtPointer engage_client_data; 74eaef79e5Smrg TerminateProc terminate; 75eaef79e5Smrg XtPointer terminate_client_data; 76eaef79e5Smrg RemoveProc remove; 77eaef79e5Smrg XtPointer remove_client_data; 78eaef79e5Smrg} ; 79eaef79e5Smrg 80eaef79e5Smrgtypedef struct { 81eaef79e5Smrg Position from_x, from_y, 82eaef79e5Smrg to_x, to_y; 83eaef79e5Smrg} BWArea; 84eaef79e5Smrg 85eaef79e5Smrgtypedef struct { 86eaef79e5Smrg BWRequestRec *request; 87eaef79e5Smrg XtPointer status; 88eaef79e5Smrg Boolean trap; 89eaef79e5Smrg XtPointer call_data; 90eaef79e5Smrg} BWRequestStack; 91eaef79e5Smrg 92eaef79e5Smrgtypedef struct { 93eaef79e5Smrg XImage *image, *buffer; 94eaef79e5Smrg XPoint hot; 95eaef79e5Smrg Position at_x, at_y; 96eaef79e5Smrg Boolean fold; 97eaef79e5Smrg Boolean grid; 98eaef79e5Smrg Boolean changed; 99eaef79e5Smrg} BWZoom; 100eaef79e5Smrg 101eaef79e5Smrgtypedef struct { 102eaef79e5Smrg Boolean own; 103eaef79e5Smrg Boolean limbo; 104eaef79e5Smrg} BWSelection; 105eaef79e5Smrg 106eaef79e5Smrg/* New fields for the Bitmap widget record */ 107eaef79e5Smrgtypedef struct { 108eaef79e5Smrg /* resources */ 109eaef79e5Smrg Pixel foreground_pixel; 110eaef79e5Smrg Pixel highlight_pixel; 111eaef79e5Smrg Pixel frame_pixel; 112eaef79e5Smrg Pixmap stipple; 113eaef79e5Smrg Boolean stippled; 114eaef79e5Smrg Boolean proportional; 115eaef79e5Smrg Boolean grid; 116eaef79e5Smrg Dimension grid_tolerance; 117eaef79e5Smrg Pixmap dashes; 118eaef79e5Smrg Boolean dashed; 119eaef79e5Smrg Boolean axes; 120eaef79e5Smrg Boolean resize; 121eaef79e5Smrg Dimension margin, squareW, squareH, width, height; 122eaef79e5Smrg XPoint hot; 123eaef79e5Smrg int button_function[5]; 124eaef79e5Smrg String filename, basename; 125eaef79e5Smrg /* private state */ 126eaef79e5Smrg String size; 127eaef79e5Smrg Position horizOffset, vertOffset; 128eaef79e5Smrg XtActionProc notify; 129eaef79e5Smrg BWRequestStack *request_stack; 130eaef79e5Smrg Cardinal cardinal, current; 131eaef79e5Smrg /*Boolean trapping;*/ 132eaef79e5Smrg XImage *image, *buffer, *storage; 133eaef79e5Smrg XPoint buffer_hot; 134eaef79e5Smrg BWArea mark, buffer_mark; 135eaef79e5Smrg GC drawing_gc; 136eaef79e5Smrg GC highlighting_gc; 137eaef79e5Smrg GC frame_gc; 138eaef79e5Smrg GC axes_gc; 139eaef79e5Smrg Boolean changed; 140eaef79e5Smrg Boolean fold; 141eaef79e5Smrg Boolean zooming; 142eaef79e5Smrg BWZoom zoom; 143eaef79e5Smrg XtPointer *value; 144eaef79e5Smrg char status[80]; 145eaef79e5Smrg BWSelection selection; 146eaef79e5Smrg Boolean stipple_change_expose_event; 147eaef79e5Smrg} BitmapPart; 148eaef79e5Smrg 149eaef79e5Smrg/* Full instance record declaration */ 150eaef79e5Smrgtypedef struct _BitmapRec { 151eaef79e5Smrg CorePart core; 152eaef79e5Smrg SimplePart simple; 153eaef79e5Smrg BitmapPart bitmap; 154eaef79e5Smrg} BitmapRec; 155eaef79e5Smrg 156eaef79e5Smrg/* Private functions */ 157eaef79e5Smrg 158eaef79e5Smrg#define Length(width, height)\ 159eaef79e5Smrg (((int)(width) + 7) / 8 * (height)) 160eaef79e5Smrg 161eaef79e5Smrg#define InBitmapX(BW, x)\ 162eaef79e5Smrg (Position)(min((Position)((Dimension)(max(BW->bitmap.horizOffset,x) -\ 163eaef79e5Smrg BW->bitmap.horizOffset) /\ 164eaef79e5Smrg BW->bitmap.squareW), BW->bitmap.width - 1)) 165eaef79e5Smrg 166eaef79e5Smrg#define InBitmapY(BW, y)\ 167eaef79e5Smrg (Position)(min((Position)((Dimension)(max(BW->bitmap.vertOffset, y) -\ 168eaef79e5Smrg BW->bitmap.vertOffset) /\ 169eaef79e5Smrg BW->bitmap.squareH), BW->bitmap.height - 1)) 170eaef79e5Smrg 171eaef79e5Smrg#define InWindowX(BW, x)\ 172eaef79e5Smrg (Position) (BW->bitmap.horizOffset + ((x) * BW->bitmap.squareW)) 173eaef79e5Smrg 174eaef79e5Smrg#define InWindowY(BW, y)\ 175eaef79e5Smrg (Position) (BW->bitmap.vertOffset + ((y) * BW->bitmap.squareH)) 176eaef79e5Smrg 177eaef79e5Smrg#define GetPixmap(BW, image)\ 178eaef79e5Smrg XCreateBitmapFromData(XtDisplay(BW), XtWindow(BW),\ 179eaef79e5Smrg image->data, image->width, image->height) 180eaef79e5Smrg 181eaef79e5Smrg 182eaef79e5Smrg#define QuerySet(x, y) (((x) != NotSet) && ((y) != NotSet)) 183eaef79e5Smrg 184eaef79e5Smrg#define bit int 185eaef79e5Smrg 186eaef79e5Smrg#define QueryZero(x, y) (((x) == 0) || ((y) == 0)) 187eaef79e5Smrg 188eaef79e5Smrg#define Swap(x, y) {Position t; t = x; x = y; y = t;} 189eaef79e5Smrg 190eaef79e5Smrg#define QuerySwap(x, y) if(x > y) Swap(x, y) 191eaef79e5Smrg 192eaef79e5Smrg#define QueryInBitmap(BW, x, y)\ 193eaef79e5Smrg (((x) >= 0) && ((x) < BW->bitmap.image->width) &&\ 194eaef79e5Smrg ((y) >= 0) && ((y) < BW->bitmap.image->height)) 195eaef79e5Smrg 196eaef79e5Smrg#define Value(BW, button) (BW->bitmap.button_function[button - 1]) 197eaef79e5Smrg 198eaef79e5Smrg#define CreateCleanData(length) XtCalloc(length, sizeof(char)) 199eaef79e5SmrgXImage *CreateBitmapImage(BitmapWidget BW, char *data, Dimension width, Dimension height); 200eaef79e5Smrgvoid DestroyBitmapImage(XImage **image); 201eaef79e5Smrgvoid TransferImageData(XImage *source, XImage *destination); 202eaef79e5Smrgvoid CopyImageData(XImage *source, XImage *destination, 203eaef79e5Smrg Position from_x, Position from_y, 204eaef79e5Smrg Position to_x, Position to_y, 205eaef79e5Smrg Position at_x, Position at_y); 206eaef79e5SmrgXImage *GetImage(BitmapWidget BW, Pixmap pixmap); 207eaef79e5SmrgXImage *ConvertToBitmapImage(BitmapWidget BW, XImage *image); 208eaef79e5SmrgXImage *ScaleBitmapImage(BitmapWidget BW, XImage *src, 209eaef79e5Smrg double scale_x, double scale_y); 210eaef79e5Smrg 211eaef79e5Smrg#endif /* _BitmapP_h */ 212