1
|
#define GUI_X11
|
2
|
#define PLATFORM_X11
|
3
|
|
4
|
#define Time XTime
|
5
|
#define Font XFont
|
6
|
#define Display XDisplay
|
7
|
#define Picture XPicture
|
8
|
|
9
|
#include <X11/Xlib.h>
|
10
|
#include <X11/Xutil.h>
|
11
|
#include <X11/Xatom.h>
|
12
|
|
13
|
#include <X11/Xft/Xft.h>
|
14
|
#include <X11/extensions/Xrender.h>
|
15
|
#include <X11/extensions/Xinerama.h>
|
16
|
|
17
|
#undef Picture
|
18
|
#undef Time
|
19
|
#undef Font
|
20
|
#undef Display
|
21
|
|
22
|
#undef True
|
23
|
#undef False
|
24
|
|
25
|
#define XFalse 0
|
26
|
#define XTrue 1
|
27
|
|
28
|
NAMESPACE_UPP
|
29
|
|
30
|
extern XDisplay *Xdisplay;
|
31
|
extern Visual *Xvisual;
|
32
|
extern int Xscreenno;
|
33
|
extern Window Xroot;
|
34
|
extern Screen *Xscreen;
|
35
|
extern Colormap Xcolormap;
|
36
|
extern int Xheight;
|
37
|
extern int Xwidth;
|
38
|
extern int XheightMM;
|
39
|
extern int XwidthMM;
|
40
|
extern int Xdepth;
|
41
|
extern dword Xblack;
|
42
|
extern dword Xwhite;
|
43
|
extern int Xconnection;
|
44
|
|
45
|
extern dword (*Xgetpixel)(int r, int g, int b);
|
46
|
|
47
|
void InitX11Draw(const char *dispname = NULL);
|
48
|
void InitX11Draw(XDisplay *display);
|
49
|
|
50
|
void XError();
|
51
|
void XError(const char *s);
|
52
|
|
53
|
inline dword GetXPixel(int r, int g, int b) { return (*Xgetpixel)(r, g, b); }
|
54
|
inline dword GetXPixel(Color color) { return (*Xgetpixel)(color.GetR(), color.GetG(), color.GetB()); }
|
55
|
|
56
|
enum {
|
57
|
X11_ROP2_ZERO,
|
58
|
X11_ROP2_AND,
|
59
|
X11_ROP2_AND_NOT,
|
60
|
X11_ROP2_COPY,
|
61
|
X11_ROP2_NOT_AND,
|
62
|
X11_ROP2_NOP,
|
63
|
X11_ROP2_XOR,
|
64
|
X11_ROP2_OR,
|
65
|
X11_ROP2_NOT_AND_NOT,
|
66
|
X11_ROP2_NOT_XOR,
|
67
|
X11_ROP2_INVERT,
|
68
|
X11_ROP2_OR_NOT,
|
69
|
X11_ROP2_NOT_COPY,
|
70
|
X11_ROP2_NOT_OR,
|
71
|
X11_ROP2_NOT_OR_NOT,
|
72
|
X11_ROP2_ONE,
|
73
|
};
|
74
|
|
75
|
void SetClip(GC gc, XftDraw *xftdraw, const Vector<Rect>& cl);
|
76
|
|
77
|
class SystemDraw : public Draw {
|
78
|
public:
|
79
|
virtual dword GetInfo() const;
|
80
|
virtual Size GetPageSize() const;
|
81
|
|
82
|
virtual void BeginOp();
|
83
|
virtual void EndOp();
|
84
|
virtual void OffsetOp(Point p);
|
85
|
virtual bool ClipOp(const Rect& r);
|
86
|
virtual bool ClipoffOp(const Rect& r);
|
87
|
virtual bool ExcludeClipOp(const Rect& r);
|
88
|
virtual bool IntersectClipOp(const Rect& r);
|
89
|
virtual bool IsPaintingOp(const Rect& r) const;
|
90
|
virtual Rect GetPaintRect() const;
|
91
|
|
92
|
virtual void DrawRectOp(int x, int y, int cx, int cy, Color color);
|
93
|
virtual void SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color);
|
94
|
virtual void DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color);
|
95
|
|
96
|
virtual void DrawPolyPolylineOp(const Point *vertices, int vertex_count,
|
97
|
const int *counts, int count_count,
|
98
|
int width, Color color, Color doxor);
|
99
|
virtual void DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count,
|
100
|
const int *subpolygon_counts, int scc,
|
101
|
const int *disjunct_polygon_counts, int dpcc,
|
102
|
Color color, int width, Color outline,
|
103
|
uint64 pattern, Color doxor);
|
104
|
virtual void DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color);
|
105
|
|
106
|
virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor);
|
107
|
virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font,
|
108
|
Color ink, int n, const int *dx);
|
109
|
|
110
|
virtual Size GetNativeDpi() const;
|
111
|
virtual void BeginNative();
|
112
|
virtual void EndNative();
|
113
|
|
114
|
virtual int GetCloffLevel() const;
|
115
|
|
116
|
private:
|
117
|
Size pageSize;
|
118
|
|
119
|
SystemDraw();
|
120
|
|
121
|
friend class ImageDraw;
|
122
|
friend class FontInfo;
|
123
|
friend class Font;
|
124
|
friend class ViewDraw;
|
125
|
|
126
|
friend void StaticExitDraw_();
|
127
|
friend Font StdFont();
|
128
|
|
129
|
Point actual_offset;
|
130
|
Point actual_offset_bak;
|
131
|
struct Cloff : Moveable<Cloff> {
|
132
|
Point org;
|
133
|
int clipi;
|
134
|
int offseti;
|
135
|
};
|
136
|
|
137
|
Array<Cloff> cloff;
|
138
|
Rect drawingclip;
|
139
|
Vector< Vector<Rect> > clip;
|
140
|
Vector<Point> offset;
|
141
|
|
142
|
Drawable dw;
|
143
|
GC gc;
|
144
|
XftDraw *xftdraw;
|
145
|
|
146
|
int foreground;
|
147
|
int linewidth;
|
148
|
|
149
|
void Init();
|
150
|
void Init(const Vector<Rect>& clip, Point offset = Point(0, 0));
|
151
|
void CloneClip();
|
152
|
|
153
|
friend class BackDraw;
|
154
|
friend class ScreenDraw;
|
155
|
|
156
|
public:
|
157
|
static void Flush() { XSync(Xdisplay, false); }
|
158
|
static Image X11Cursor(int c);
|
159
|
static void *CursorX11(const Image& img);
|
160
|
|
161
|
Point GetOffset() const { return actual_offset; }
|
162
|
|
163
|
static XftFont *CreateXftFont(Font f, int angle);
|
164
|
XftDraw *GetXftDraw() const { return xftdraw; }
|
165
|
|
166
|
Rect GetClip() const;
|
167
|
|
168
|
void SetForeground(Color color);
|
169
|
void SetLineStyle(int width);
|
170
|
void SetClip();
|
171
|
|
172
|
Drawable GetDrawable() const { return dw; }
|
173
|
GC GetGC() const { return gc; }
|
174
|
const Vector<Rect>& GetClipList() const { return clip.Top(); }
|
175
|
|
176
|
SystemDraw(Drawable dw, GC gc, XftDraw *xftdraw, const Vector<Rect>& clip);
|
177
|
|
178
|
bool CanSetSurface() { return true; }
|
179
|
};
|
180
|
|
181
|
Image X11Cursor(int c);
|
182
|
void *CursorX11(const Image& img);
|
183
|
|
184
|
class BackDraw : public SystemDraw {
|
185
|
public:
|
186
|
virtual bool IsPaintingOp(const Rect& r) const;
|
187
|
|
188
|
protected:
|
189
|
Pixmap pixmap;
|
190
|
Size size;
|
191
|
Draw *painting;
|
192
|
Point painting_offset;
|
193
|
|
194
|
public:
|
195
|
void Put(SystemDraw& w, int x, int y);
|
196
|
void Put(SystemDraw& w, Point p) { Put(w, p.x, p.y); }
|
197
|
|
198
|
void Create(SystemDraw& w, int cx, int cy);
|
199
|
void Create(SystemDraw& w, Size sz) { Create(w, sz.cx, sz.cy); }
|
200
|
void Destroy();
|
201
|
|
202
|
void SetPaintingDraw(Draw& w, Point off) { painting = &w; painting_offset = off; }
|
203
|
|
204
|
BackDraw();
|
205
|
~BackDraw();
|
206
|
};
|
207
|
|
208
|
class ImageDraw : public SystemDraw {
|
209
|
Size size;
|
210
|
SystemDraw alpha;
|
211
|
bool has_alpha;
|
212
|
|
213
|
void Init();
|
214
|
Image Get(bool pm) const;
|
215
|
|
216
|
public:
|
217
|
Draw& Alpha();
|
218
|
|
219
|
operator Image() const;
|
220
|
|
221
|
Image GetStraight() const;
|
222
|
|
223
|
ImageDraw(Size sz);
|
224
|
ImageDraw(int cx, int cy);
|
225
|
~ImageDraw();
|
226
|
};
|
227
|
|
228
|
END_UPP_NAMESPACE
|
229
|
|
230
|
#include "X11/keysym.h"
|
231
|
|
232
|
|
233
|
#define GUIPLATFORM_KEYCODES_INCLUDE "X11Keys.h"
|
234
|
|
235
|
|
236
|
#define GUIPLATFORM_CTRL_TOP_DECLS \
|
237
|
Window window;
|
238
|
|
239
|
|
240
|
#define GUIPLATFORM_CTRL_DECLS_INCLUDE "X11Ctrl.h"
|
241
|
|
242
|
#define GUIPLATFORM_TOPWINDOW_DECLS_INCLUDE "X11Top.h"
|
243
|
|
244
|
#define GUIPLATFORM_PASTECLIP_DECLS \
|
245
|
int type;
|
246
|
|
247
|
NAMESPACE_UPP
|
248
|
|
249
|
String XAtomName(Atom atom);
|
250
|
Atom XAtom(const char *name);
|
251
|
|
252
|
String GetProperty(Window w, Atom property, Atom rtype = AnyPropertyType);
|
253
|
Vector<int> GetPropertyInts(Window w, Atom property, Atom rtype = AnyPropertyType);
|
254
|
String ReadPropertyData(Window w, Atom property, Atom rtype = AnyPropertyType);
|
255
|
|
256
|
Index<Atom>& _NET_Supported();
|
257
|
|
258
|
#include "stdids.h"
|
259
|
|
260
|
#define GUIPLATFORM_INCLUDE_AFTER "X11GuiA.h"
|
261
|
|
262
|
END_UPP_NAMESPACE
|