File: PaintP.h

package info (click to toggle)
xpaint 2.5.1-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,488 kB
  • ctags: 2,478
  • sloc: ansic: 25,980; makefile: 36; sh: 23
file content (186 lines) | stat: -rw-r--r-- 4,984 bytes parent folder | download | duplicates (4)
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
#ifndef _PaintP_h
#define _PaintP_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: PaintP.h,v 1.8 1996/04/19 09:03:59 torsten Exp $ */

#include "Paint.h"

#include <X11/IntrinsicP.h>	/* necessary for CoreP.h */
/* include superclass private header file */
#include <X11/CoreP.h>
#include <X11/CompositeP.h>
#include <X11/Xutil.h>

/* define unique representation types not found in <X11/StringDefs.h> */

#define XtRPaintResource "PaintResource"

typedef struct {
    int empty;
} PaintClassPart;

typedef struct _PaintClassRec {
    CoreClassPart core_class;
    CompositeClassPart composite_class;
    PaintClassPart paint_class;
} PaintClassRec;

extern PaintClassRec paintClassRec;

typedef struct s_undoStack {
    XRectangle box;
    Pixmap pixmap;
    Boolean pushed;
    struct s_undoStack *next;
} UndoStack;

typedef struct {
    int drawWidth, drawHeight;
    int fillRule, lineFillRule;
    GC gc, igc, fgc, sgc;
    Pixmap sourcePixmap;
    Pixmap pattern, linePattern;
    int lineWidth;
    XFontStruct *fontInfo;
    Pixel foreground, background, lineForeground;
    int undoSize;		/* number of undo stacks */

    /*
    **	The undo system
     */
    Pixmap current;		/* The currently displayed pixmap */
    UndoStack * undo, * head;
    Boolean dirty;
    /* The undo/redo stacks: */
    int nlevels;		/* Maximum stack depth */
    Pixmap * undostack, * redostack;
    int undobot, undoitems, redobot, redoitems;

    Boolean snapOn, grid;
    int snap;
    void *eventList;
    XtCallbackList fatcalls;
    XtCallbackList sizecalls;
    XtCallbackList regionCalls;
    int zoomX, zoomY;
    int zoom;
    GC tgc;			/* scratch GC, for stuffing clip masks into */
    GC mgc;			/* region mask GC, 1 bit deep */
    GC xgc;			/* XOR (invert) GC */
    Widget paint;
    int paintChildrenSize;
    Widget *paintChildren;
    Pixel linePixel;
    Boolean compress;
    Cursor cursor;

    /*
    **	Region info
     */
    struct {
	Widget child;
	Widget grip[9];
	Position offX, offY;
	Position baseX, baseY;
	XRectangle rect, orig;
	GC fg_gc, bg_gc;

	Boolean isTracking, isDrawn, isRotate;
	float lastAngle;
	Position lastX, lastY;
	int fixedPoint;
	float lineDelta[4], lineBase[2];
	float startScaleX, startScaleY;

	Pixmap source, mask, notMask;
	XImage *sourceImg, *maskImg, *notMaskImg;

	Boolean isAttached, isVisible, needResize;
	Pixmap undoPixmap;
	/*
	**  The scale{X,Y} are combined with the rotMat
	**    to produce mat.
	 */
	float centerX, centerY;
	float scaleX, scaleY;
	pwMatrix rotMat, mat;

	int curZoom;
	pwRegionDoneProc *proc;
    } region;

    Boolean invalidateRegion;
    Region imageRegion;
    XImage *image;

    Position downX, downY;	/* Last button down X & Y pos */

    /*
    **	Taken from our parent shell
     */
    Visual *visual;

    /*
     * Used by the revert function
     */
    char *filename;

    WidgetList menuwidgets;
} PaintPart;

#define PwPixmap(w)	((w)->paint.active->pixmap)

typedef struct _PaintRec {
    CorePart core;
    CompositePart composite;
    PaintPart paint;
} PaintRec;


#define _GET_PIXMAP(pw) ((pw)->paint.current)
#define GET_PIXMAP(pw) (pw->paint.paint ? \
		_GET_PIXMAP((PaintWidget)pw->paint.paint) : _GET_PIXMAP(pw))

#define _GET_ZOOM(pw)	pw->paint.zoom
#define GET_ZOOM(pw) ((pw->paint.zoom == PwZoomParent) ? \
		_GET_ZOOM(((PaintWidget)pw->paint.paint)) : _GET_ZOOM(pw))

#define GET_MGC(pw, msk)	((pw)->paint.mgc == None ? \
	(pw->paint.mgc = XCreateGC(XtDisplay(pw), msk, 0, 0)) : pw->paint.mgc)

void pwRegionZoomPosChanged(PaintWidget);
void _PwZoomDraw(PaintWidget, Widget, GC, XImage *, XImage *,
		 Boolean, int, int, int, XRectangle *);

/*
**  Try to optimize XGetPixel and XPutPixel
**
 */
#define ZINDEX8(x, y, img)  ((y) * img->bytes_per_line) + (x)
#define xxGetPixel(img, x, y)					\
		((img->bits_per_pixel == 8) ?			\
			img->data[ZINDEX8(x, y, img)] :		\
			XGetPixel(img, x, y))
#define xxPutPixel(img, x, y, p) do {				\
		if (img->bits_per_pixel == 8)			\
			img->data[ZINDEX8(x, y, img)] = p;	\
		else						\
			XPutPixel(img, x, y, p);		\
	} while (0)

#endif				/* _PaintP_h */