File: Paint.h

package info (click to toggle)
xpaint 2.9.1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 5,552 kB
  • sloc: ansic: 73,017; sh: 492; yacc: 247; lex: 126; sed: 43; makefile: 10
file content (234 lines) | stat: -rw-r--r-- 7,731 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#ifndef _Paint_h
#define _Paint_h

/* +-------------------------------------------------------------------+ */
/* | Copyright 1992, 1993, David Koblas (koblas@netcom.com)            | */
/* | Copyright 1995, 1996 Torsten Martinsen (bullestock@dk-online.dk)  | */
/* |                                                                   | */
/* | Permission to use, copy, modify, and to distribute this software  | */
/* | and its documentation for any purpose is hereby granted without   | */
/* | fee, provided that the above copyright notice appear in all       | */
/* | copies and that both that copyright notice and this permission    | */
/* | notice appear in supporting documentation.  There is no           | */
/* | representations about the suitability of this software for        | */
/* | any purpose.  this software is provided "as is" without express   | */
/* | or implied warranty.                                              | */
/* |                                                                   | */
/* +-------------------------------------------------------------------+ */

/* $Id: Paint.h,v 1.17 2005/03/20 20:15:32 demailly Exp $ */

/****************************************************************
 *
 * Paint widget
 *
 ****************************************************************/

/* Resources:

   Name              Class              RepType         Default Value
   ----              -----              -------         -------------
   background        Background         Pixel           XtDefaultBackground
   border            BorderColor        Pixel           XtDefaultForeground
   borderWidth       BorderWidth        Dimension       1
   destroyCallback   Callback           Pointer         NULL
   height            Height             Dimension       0
   mappedWhenManaged MappedWhenManaged  Boolean         True
   sensitive         Sensitive          Boolean         True
   width             Width              Dimension       0
   x                 Position           Position        0
   y                 Position           Position        0

 */

/* define any special resource names here that are not in <X11/StringDefs.h> */

#define XtNpaintResource "paintResource"
#define XtNpattern	 "pattern"
#define XtNmenubar	 "menubar"
#define XtNfullmenu	 "fullmenu"
#define XtNgrid	 	 "grid"
#define XtNgridmode 	 "gridmode"
#define XtNgridcolor 	 "gridcolor"
#define XtNinterpolation "interpolation"
#define XtNtransparent   "transparent"
#define XtNsnapX 	 "snapX"
#define XtNsnapY 	 "snapY"
#define XtNsnapOn 	 "snapOn"
#define XtNlineWidth	 "lineWidth"
#define XtNfatBack	 "fatBack"
#define XtNsizeChanged	 "sizeChanged"
#define XtNundoSize	 "undoSize"
#define XtNlocked 	 "locked"
#define XtNzoom	 	 "zoom"
#define XtNpaint	 "paint"
#define XtNzoomX	 "zoomX"
#define XtNzoomY	 "zoomY"
#define XtNdrawWidth	 "drawWidth"
#define XtNdrawHeight	 "drawHeight"
#define XtNcompress	 "compress"
#define XtNdirty	 "dirty"
#define XtNfillRule	 "fillRule"
#define XtNregionCallback	"regionSetCallback"
#define XtNdownX		"downX"
#define XtNdownY		"downY"
#define XtNlineForeground	"lineForeground"
#define XtNlinePattern		"linePattern"
#define XtNlineFillRule		"lineFillRule"
#ifndef XtNreadOnly
#define XtNreadOnly		"readOnly"
#endif
#ifndef XtNcursor
#define XtNcursor		"cursor"
#endif
#define XtNfilename		"filename"
#define XtNmenuwidgets		"menuwidgets"

#define XtCPaintResource "PaintResource"
#define XtCPattern	 "Pattern"
#define XtCMenubar	 "Menubar"
#define XtCFullMenu	 "FullMenu"
#define XtCGrid		 "Grid"
#define XtCGridMode	 "GridMode"
#define XtCGridColor	 "GridColor"
#define XtCInterpolation "Interpolation"
#define XtCTransparent   "Transparent"
#define XtCSnapX	 "SnapX"
#define XtCSnapY	 "SnapY"
#define XtCSnapOn	 "SnapOn"
#define XtCLineWidth	 "LineWidth"
#define XtCFatBack	 "FatBack"
#define XtCSizeChanged	 "SizeChanged"
#define XtCLocked	 "Locked"
#define XtCUndoSize	 "UndoSize"
#define XtCZoom	  	 "Zoom"
#define XtCPaint	 "Paint"
#define XtCZoomX	 "ZoomX"
#define XtCZoomY	 "ZoomY"
#define XtCDrawWidth	 "DrawWidth"
#define XtCDrawHeight	 "DrawHeight"
#define XtCCompress	 "Compress"
#define XtCDirty	 "Dirty"
#define XtCEditable	 "Editable"
#define XtCFillRule	 "FillRule"
#define XtCRegionCallback	"RegionSetCallback"
#define XtCDownX		"DownX"
#define XtCDownY		"DownY"
#define XtCLineForeground	"LineForeground"
#define XtCLinePattern		"LinePattern"
#define XtCLineFillRule		"LineFillRule"
#ifndef XtCReadOnly
#define XtCReadOnly		"ReadOnly"
#endif
#define XtCfilename		"Filename"
#define XtCmenuwidgets		"Menuwidgets"

#define XtRXFTFontStruct "XFTFontStruct"

/* declare specific PaintWidget class and instance datatypes */

typedef struct _PaintClassRec *PaintClass;
typedef struct _PaintRec *PaintWidget;

/* declare the class constant */

extern WidgetClass paintWidgetClass;

/*
**  Operation callback information
 */

typedef struct {
    Pixmap pixmap;
    unsigned char *alpha;
} AlphaPixmap;

typedef enum {
    opPixmap = 0x01, opWindow = 0x02
} OpSurface;

typedef struct {
    int refCount;
    OpSurface surface;
    Drawable drawable;
    GC first_gc, second_gc, base_gc;
    void *data;
    int isFat;
    int x, y;
    int realX, realY;
    int zoom;
    Pixmap base;
} OpInfo;

typedef float pwMatrix[2][2];

/* Brush Item structure */
typedef struct {
    int width, height;
    int numpixels;		/* Total number of set pixels */
    char *brushbits;
    Pixmap pixmap, bw;
    Cursor cursor;
    Widget icon;
} BrushItem;

typedef void (*OpEventProc) (Widget, void *, XEvent *, OpInfo *);
void OpRemoveEventHandler(Widget, int, int, Boolean, OpEventProc, void *);
void OpAddEventHandler(Widget, int, int, Boolean, OpEventProc, void *);
void UndoStart(Widget, OpInfo *);
void UndoStartRectangle(Widget, OpInfo *, XRectangle *);
void UndoStartPoint(Widget, OpInfo *, int, int);
void UndoSetRectangle(Widget, XRectangle *);
void UndoGrow(Widget, int, int);

AlphaPixmap PwUndoStart(Widget, XRectangle *);
void PwUndoSetRectangle(Widget, XRectangle *);
void PwUndoAddRectangle(Widget, XRectangle *);
void Undo(Widget);
void Redo(Widget);
void UndoInitialize(PaintWidget pw, int n);

#define PwZoomParent	((int) -10000)

/*
**  Public functions
 */

void PwUpdate(Widget, XRectangle *, Boolean);
void PwUpdateDrawable(Widget, Drawable, XRectangle *);
void PwSetDrawn(Widget, Boolean);
void PwGetPixmap(Widget, Pixmap *, int *, int *);
void PwPutPixmap(Widget w, Pixmap pix);
XRectangle *PwScaleRectangle(Widget, XRectangle *);
XImage *PwGetImage(Widget, XRectangle *);
void zoomUpdate(PaintWidget pw, Boolean isExpose, XRectangle * rect);
Pixel AlphaTwistPixel(Pixel p, unsigned char *u);
Pixel AlphaTwistPixel8(Pixel p, unsigned char *u);
void AlphaTwistImage(PaintWidget w, XImage *xim, 
                     unsigned char *alpha, int width,
                     int dx, int dy, int ax, int ay);

/*
**  Region routines
 */
void PwDrawVisibleGrid(PaintWidget, Widget, Boolean, int, int, int, int);
void PwRegionExpose(Widget, PaintWidget, XEvent *, Boolean *);
void PwRegionSet(Widget, XRectangle *, Pixmap, Pixmap);
void PwRegionSetRawPixmap(Widget, Pixmap);
void PwRegionTear(Widget);
Boolean PwRegionGet(Widget, Pixmap *, Pixmap *);
Pixmap PwGetRawPixmap(Widget);
void PwRegionSetMatrix(Widget, pwMatrix);
void PwRegionAppendMatrix(Widget, pwMatrix);
void PwRegionAddScale(Widget, float *, float *);
void PwRegionSetScale(Widget, float *, float *);
void PwRegionReset(Widget, Boolean);
void PwRegionClear(Widget);
void PwRegionFinish(Widget, Boolean);
Boolean PwRegionOff(Widget w, Boolean flag);

typedef Pixmap(*pwRegionDoneProc) (Widget, XImage *, pwMatrix);

void PwRegionSetDone(Widget, pwRegionDoneProc);

#endif				/* _Paint_h */