1 #ifndef _Paint_h 2 #define _Paint_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: Paint.h,v 1.17 2005/03/20 20:15:32 demailly Exp $ */ 20 21 /**************************************************************** 22 * 23 * Paint widget 24 * 25 ****************************************************************/ 26 27 /* Resources: 28 29 Name Class RepType Default Value 30 ---- ----- ------- ------------- 31 background Background Pixel XtDefaultBackground 32 border BorderColor Pixel XtDefaultForeground 33 borderWidth BorderWidth Dimension 1 34 destroyCallback Callback Pointer NULL 35 height Height Dimension 0 36 mappedWhenManaged MappedWhenManaged Boolean True 37 sensitive Sensitive Boolean True 38 width Width Dimension 0 39 x Position Position 0 40 y Position Position 0 41 42 */ 43 44 /* define any special resource names here that are not in <X11/StringDefs.h> */ 45 46 #define XtNpaintResource "paintResource" 47 #define XtNpattern "pattern" 48 #define XtNmenubar "menubar" 49 #define XtNfullmenu "fullmenu" 50 #define XtNgrid "grid" 51 #define XtNgridmode "gridmode" 52 #define XtNgridcolor "gridcolor" 53 #define XtNinterpolation "interpolation" 54 #define XtNtransparent "transparent" 55 #define XtNsnapX "snapX" 56 #define XtNsnapY "snapY" 57 #define XtNsnapOn "snapOn" 58 #define XtNlineWidth "lineWidth" 59 #define XtNfatBack "fatBack" 60 #define XtNsizeChanged "sizeChanged" 61 #define XtNundoSize "undoSize" 62 #define XtNlocked "locked" 63 #define XtNzoom "zoom" 64 #define XtNpaint "paint" 65 #define XtNzoomX "zoomX" 66 #define XtNzoomY "zoomY" 67 #define XtNdrawWidth "drawWidth" 68 #define XtNdrawHeight "drawHeight" 69 #define XtNcompress "compress" 70 #define XtNdirty "dirty" 71 #define XtNfillRule "fillRule" 72 #define XtNregionCallback "regionSetCallback" 73 #define XtNdownX "downX" 74 #define XtNdownY "downY" 75 #define XtNlineForeground "lineForeground" 76 #define XtNlinePattern "linePattern" 77 #define XtNlineFillRule "lineFillRule" 78 #ifndef XtNreadOnly 79 #define XtNreadOnly "readOnly" 80 #endif 81 #ifndef XtNcursor 82 #define XtNcursor "cursor" 83 #endif 84 #define XtNfilename "filename" 85 #define XtNmenuwidgets "menuwidgets" 86 87 #define XtCPaintResource "PaintResource" 88 #define XtCPattern "Pattern" 89 #define XtCMenubar "Menubar" 90 #define XtCFullMenu "FullMenu" 91 #define XtCGrid "Grid" 92 #define XtCGridMode "GridMode" 93 #define XtCGridColor "GridColor" 94 #define XtCInterpolation "Interpolation" 95 #define XtCTransparent "Transparent" 96 #define XtCSnapX "SnapX" 97 #define XtCSnapY "SnapY" 98 #define XtCSnapOn "SnapOn" 99 #define XtCLineWidth "LineWidth" 100 #define XtCFatBack "FatBack" 101 #define XtCSizeChanged "SizeChanged" 102 #define XtCLocked "Locked" 103 #define XtCUndoSize "UndoSize" 104 #define XtCZoom "Zoom" 105 #define XtCPaint "Paint" 106 #define XtCZoomX "ZoomX" 107 #define XtCZoomY "ZoomY" 108 #define XtCDrawWidth "DrawWidth" 109 #define XtCDrawHeight "DrawHeight" 110 #define XtCCompress "Compress" 111 #define XtCDirty "Dirty" 112 #define XtCEditable "Editable" 113 #define XtCFillRule "FillRule" 114 #define XtCRegionCallback "RegionSetCallback" 115 #define XtCDownX "DownX" 116 #define XtCDownY "DownY" 117 #define XtCLineForeground "LineForeground" 118 #define XtCLinePattern "LinePattern" 119 #define XtCLineFillRule "LineFillRule" 120 #ifndef XtCReadOnly 121 #define XtCReadOnly "ReadOnly" 122 #endif 123 #define XtCfilename "Filename" 124 #define XtCmenuwidgets "Menuwidgets" 125 126 #define XtRXFTFontStruct "XFTFontStruct" 127 128 /* declare specific PaintWidget class and instance datatypes */ 129 130 typedef struct _PaintClassRec *PaintClass; 131 typedef struct _PaintRec *PaintWidget; 132 133 /* declare the class constant */ 134 135 extern WidgetClass paintWidgetClass; 136 137 /* 138 ** Operation callback information 139 */ 140 141 typedef struct { 142 Pixmap pixmap; 143 unsigned char *alpha; 144 } AlphaPixmap; 145 146 typedef enum { 147 opPixmap = 0x01, opWindow = 0x02 148 } OpSurface; 149 150 typedef struct { 151 int refCount; 152 OpSurface surface; 153 Drawable drawable; 154 GC first_gc, second_gc, base_gc; 155 void *data; 156 int isFat; 157 int x, y; 158 int realX, realY; 159 int zoom; 160 Pixmap base; 161 } OpInfo; 162 163 typedef double pwMatrix[2][2]; 164 165 /* Brush Item structure */ 166 typedef struct { 167 int width, height; 168 int numpixels; /* Total number of set pixels */ 169 char *brushbits; 170 Pixmap pixmap, bw; 171 Cursor cursor; 172 Widget icon; 173 } BrushItem; 174 175 typedef void (*OpEventProc) (Widget, void *, XEvent *, OpInfo *); 176 void OpRemoveEventHandler(Widget, int, int, Boolean, OpEventProc, void *); 177 void OpAddEventHandler(Widget, int, int, Boolean, OpEventProc, void *); 178 void UndoStart(Widget, OpInfo *); 179 void UndoStartRectangle(Widget, OpInfo *, XRectangle *); 180 void UndoStartPoint(Widget, OpInfo *, int, int); 181 void UndoSetRectangle(Widget, XRectangle *); 182 void UndoGrow(Widget, int, int); 183 184 AlphaPixmap PwUndoStart(Widget, XRectangle *); 185 void PwUndoSetRectangle(Widget, XRectangle *); 186 void PwUndoAddRectangle(Widget, XRectangle *); 187 void Undo(Widget); 188 void Redo(Widget); 189 void UndoInitialize(PaintWidget pw, int n); 190 191 #define PwZoomParent ((int) -10000) 192 193 /* 194 ** Public functions 195 */ 196 197 void PwUpdate(Widget, XRectangle *, Boolean); 198 void PwUpdateDrawable(Widget, Drawable, XRectangle *); 199 void PwSetDrawn(Widget, Boolean); 200 void PwGetPixmap(Widget, Pixmap *, int *, int *); 201 void PwPutPixmap(Widget w, Pixmap pix); 202 XRectangle *PwScaleRectangle(Widget, XRectangle *); 203 XImage *PwGetImage(Widget, XRectangle *); 204 void zoomUpdate(PaintWidget pw, Boolean isExpose, XRectangle * rect); 205 Pixel AlphaTwistPixel(Pixel p, unsigned char *u); 206 Pixel AlphaTwistPixel8(Pixel p, unsigned char *u); 207 void AlphaTwistImage(PaintWidget w, XImage *xim, 208 unsigned char *alpha, int width, 209 int dx, int dy, int ax, int ay); 210 211 /* 212 ** Region routines 213 */ 214 void PwDrawVisibleGrid(PaintWidget, Widget, Boolean, int, int, int, int); 215 void PwRegionExpose(Widget, PaintWidget, XEvent *, Boolean *); 216 void PwRegionSet(Widget, XRectangle *, Pixmap, Pixmap); 217 void PwRegionSetRawPixmap(Widget, Pixmap); 218 void PwRegionTear(Widget); 219 Boolean PwRegionGet(Widget, Pixmap *, Pixmap *); 220 Pixmap PwGetRawPixmap(Widget); 221 void PwRegionSetMatrix(Widget, pwMatrix); 222 void PwRegionAppendMatrix(Widget, pwMatrix); 223 void PwRegionAddScale(Widget, double *, double *); 224 void PwRegionSetScale(Widget, double *, double *); 225 void PwRegionReset(Widget, Boolean); 226 void PwRegionClear(Widget); 227 void PwRegionFinish(Widget, Boolean); 228 Boolean PwRegionOff(Widget w, Boolean flag); 229 230 typedef Pixmap(*pwRegionDoneProc) (Widget, XImage *, pwMatrix); 231 232 void PwRegionSetDone(Widget, pwRegionDoneProc); 233 234 #endif /* _Paint_h */ 235