1 #ifndef _PaintP_h 2 #define _PaintP_h 3 4 /* +-------------------------------------------------------------------+ */ 5 /* | Copyright 1992, 1993, David Koblas (koblas@netcom.com) | */ 6 /* | Copyright 1995, 1996 Torsten Martinsen (bullestock@dk-online.dk) | */ 7 /* | | */ 8 /* | Permission to use, copy, modify, and to distribute this software | */ 9 /* | and its documentation for any purpose is hereby granted without | */ 10 /* | fee, provided that the above copyright notice appear in all | */ 11 /* | copies and that both that copyright notice and this permission | */ 12 /* | notice appear in supporting documentation. There is no | */ 13 /* | representations about the suitability of this software for | */ 14 /* | any purpose. this software is provided "as is" without express | */ 15 /* | or implied warranty. | */ 16 /* | | */ 17 /* +-------------------------------------------------------------------+ */ 18 19 /* $Id: PaintP.h,v 1.17 2005/03/20 20:15:32 demailly Exp $ */ 20 21 #include "Paint.h" 22 23 #include <X11/IntrinsicP.h> /* necessary for CoreP.h */ 24 /* include superclass private header file */ 25 #include <X11/CoreP.h> 26 #include <X11/CompositeP.h> 27 #include <X11/Xutil.h> 28 29 /* define unique representation types not found in <X11/StringDefs.h> */ 30 31 #define XtRPaintResource "PaintResource" 32 33 typedef struct { 34 int empty; 35 } PaintClassPart; 36 37 typedef struct _PaintClassRec { 38 CoreClassPart core_class; 39 CompositeClassPart composite_class; 40 PaintClassPart paint_class; 41 } PaintClassRec; 42 43 extern PaintClassRec paintClassRec; 44 45 typedef struct s_undoStack { 46 XRectangle box; 47 AlphaPixmap alphapix; 48 Boolean pushed; 49 struct s_undoStack *next; 50 } UndoStack; 51 52 typedef struct { 53 int drawWidth, drawHeight; 54 int fillRule, lineFillRule; 55 GC gc, igc, fgc, sgc; 56 Pixmap sourcePixmap; 57 Pixmap pattern, linePattern; 58 int lineWidth; 59 Pixel foreground, background, lineForeground; 60 61 /* 62 ** The undo system 63 */ 64 AlphaPixmap current; /* The currently displayed pixmap */ 65 UndoStack * undo, * head; 66 /* The undo/redo stacks: */ 67 AlphaPixmap * undostack, * redostack; 68 int undobot, undoitems, redobot, redoitems; 69 int nlevels; /* Maximum stack depth */ 70 int undoSize; /* number of undo stacks */ 71 int alpha_mode; /* alpha_mode = 0,1,2,3 default 0 */ 72 73 Boolean dirty, locked, menubar, fullmenu, snapOn, grid, compress; 74 int snap_x, snap_y, gridmode, interpolation, transparent; 75 void *eventList; 76 XtCallbackList fatcalls; 77 XtCallbackList sizecalls; 78 XtCallbackList regionCalls; 79 80 int zoomX, zoomY, zoom; 81 GC tgc; /* scratch GC, for stuffing clip masks into */ 82 GC mgc; /* region mask GC, 1 bit deep */ 83 GC xgc; /* XOR (invert) GC */ 84 Widget paint; 85 int paintChildrenSize; 86 Widget *paintChildren; 87 Pixel linePixel; 88 Pixel gridcolor; 89 Cursor cursor; 90 91 /* 92 ** Region info 93 */ 94 struct { 95 Widget child; 96 Widget grip[9]; 97 Position offX, offY; 98 Position baseX, baseY; 99 XRectangle rect, orig; 100 GC fg_gc, bg_gc; 101 102 Boolean isTracking, isDrawn, isRotate; 103 double lastAngle; 104 Position lastX, lastY; 105 int fixedPoint; 106 double lineDelta[4], lineBase[2]; 107 double startScaleX, startScaleY; 108 109 Pixmap source, mask, notMask; 110 XImage *sourceImg, *maskImg, *notMaskImg; 111 unsigned char *alpha; 112 113 Boolean isAttached, isVisible, needResize; 114 Pixmap unfilterPixmap; 115 AlphaPixmap undo_alphapix; 116 117 /* 118 ** The scale{X,Y} are combined with the rotMat 119 ** to produce mat. 120 */ 121 double centerX, centerY; 122 double scaleX, scaleY; 123 pwMatrix rotMat, mat; 124 125 int curZoom; 126 pwRegionDoneProc *proc; 127 } region; 128 129 Boolean invalidateRegion; 130 Region imageRegion; 131 XImage *image; 132 Position downX, downY; /* Last button down X & Y pos */ 133 134 /* 135 ** Taken from our parent shell 136 */ 137 Visual *visual; 138 139 /* 140 * Used by the revert function 141 */ 142 char *filename; 143 144 WidgetList menuwidgets; 145 } PaintPart; 146 147 typedef struct _PaintRec { 148 CorePart core; 149 CompositePart composite; 150 PaintPart paint; 151 } PaintRec; 152 153 154 #define _GET_PIXMAP(pw) ((pw)->paint.current.pixmap) 155 #define GET_PIXMAP(pw) (pw->paint.paint ? \ 156 _GET_PIXMAP((PaintWidget)pw->paint.paint) : _GET_PIXMAP(pw)) 157 158 #define _GET_ZOOM(pw) pw->paint.zoom 159 #define GET_ZOOM(pw) ((pw->paint.zoom == PwZoomParent) ? \ 160 _GET_ZOOM(((PaintWidget)pw->paint.paint)) : _GET_ZOOM(pw)) 161 162 #define GET_MGC(pw, msk) ((pw)->paint.mgc == None ? \ 163 (pw->paint.mgc = XCreateGC(XtDisplay(pw), msk, 0, 0)) : pw->paint.mgc) 164 165 #define ALPHA_PIXEL_MODE(x, y) ((((x)/12+(y)/12)&1)? 153:102) 166 167 void PwRegionZoomPosChanged(PaintWidget); 168 void PwZoomDraw(PaintWidget, Widget, GC, XImage *, XImage *, 169 Boolean, int, int, int, XRectangle *); 170 171 /* 172 ** Try to optimize XGetPixel and XPutPixel 173 ** 174 */ 175 #define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x) 176 #define xxGetPixel(img, x, y) \ 177 ((img->bits_per_pixel == 8) ? \ 178 img->data[ZINDEX8(x, y, img)] : \ 179 XGetPixel(img, x, y)) 180 #define xxPutPixel(img, x, y, p) { \ 181 if (img->bits_per_pixel == 8) \ 182 img->data[ZINDEX8(x, y, img)] = p; \ 183 else \ 184 XPutPixel(img, x, y, p); \ 185 } 186 187 #endif /* _PaintP_h */ 188