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