ultimatepp/uppsrc/CtrlCore/DrawX11.h
rylek 4c872d55ca GetPaintRect support in SystemDraw
git-svn-id: svn://ultimatepp.org/upp/trunk@1423 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2009-07-17 11:50:58 +00:00

179 lines
4.7 KiB
C++

#ifdef PLATFORM_X11
#define Time XTime
#define Font XFont
#define Display XDisplay
#define Picture XPicture
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xft/Xft.h>
#include <X11/extensions/Xrender.h>
#undef Picture
#undef Time
#undef Font
#undef Display
#undef True
#undef False
#define XFalse 0
#define XTrue 1
NAMESPACE_UPP
extern XDisplay *Xdisplay;
extern Visual *Xvisual;
extern int Xscreenno;
extern Window Xroot;
extern Screen *Xscreen;
extern Colormap Xcolormap;
extern int Xheight;
extern int Xwidth;
extern int XheightMM;
extern int XwidthMM;
extern int Xdepth;
extern dword Xblack;
extern dword Xwhite;
extern int Xconnection;
extern dword (*Xgetpixel)(int r, int g, int b);
void InitX11Draw(const char *dispname = NULL);
void InitX11Draw(XDisplay *display);
void XError();
void XError(const char *s);
inline dword GetXPixel(int r, int g, int b) { return (*Xgetpixel)(r, g, b); }
inline dword GetXPixel(Color color) { return (*Xgetpixel)(color.GetR(), color.GetG(), color.GetB()); }
enum {
X11_ROP2_ZERO,
X11_ROP2_AND,
X11_ROP2_AND_NOT,
X11_ROP2_COPY,
X11_ROP2_NOT_AND,
X11_ROP2_NOP,
X11_ROP2_XOR,
X11_ROP2_OR,
X11_ROP2_NOT_AND_NOT,
X11_ROP2_NOT_XOR,
X11_ROP2_INVERT,
X11_ROP2_OR_NOT,
X11_ROP2_NOT_COPY,
X11_ROP2_NOT_OR,
X11_ROP2_NOT_OR_NOT,
X11_ROP2_ONE,
};
void SetClip(GC gc, XftDraw *xftdraw, const Vector<Rect>& cl);
class SystemDraw : public Draw {
public:
virtual dword GetInfo() const;
virtual Size GetPageSize() const;
virtual void BeginOp();
virtual void EndOp();
virtual void OffsetOp(Point p);
virtual bool ClipOp(const Rect& r);
virtual bool ClipoffOp(const Rect& r);
virtual bool ExcludeClipOp(const Rect& r);
virtual bool IntersectClipOp(const Rect& r);
virtual bool IsPaintingOp(const Rect& r) const;
virtual Rect GetPaintRect() const;
virtual void DrawRectOp(int x, int y, int cx, int cy, Color color);
virtual void DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color);
virtual void DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color);
virtual void DrawPolyPolylineOp(const Point *vertices, int vertex_count,
const int *counts, int count_count,
int width, Color color, Color doxor);
virtual void DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count,
const int *subpolygon_counts, int scc,
const int *disjunct_polygon_counts, int dpcc,
Color color, int width, Color outline,
uint64 pattern, Color doxor);
virtual void DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color);
virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor);
virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font,
Color ink, int n, const int *dx);
virtual Size GetNativeDpi() const;
virtual void BeginNative();
virtual void EndNative();
virtual int GetCloffLevel() const;
private:
Size pageSize;
SystemDraw();
friend class ImageDraw;
friend class FontInfo;
friend class Font;
friend class ViewDraw;
friend void StaticExitDraw_();
friend Font StdFont();
FontInfo lastFont;
Point actual_offset;
Point actual_offset_bak;
struct Cloff : Moveable<Cloff> {
Point org;
int clipi;
int offseti;
};
Array<Cloff> cloff;
Rect drawingclip;
Vector< Vector<Rect> > clip;
Vector<Point> offset;
Drawable dw;
GC gc;
XftDraw *xftdraw;
int foreground;
int linewidth;
void Init();
void Init(const Vector<Rect>& clip, Point offset = Point(0, 0));
void CloneClip();
friend class BackDraw;
friend class ScreenDraw;
public:
static void Flush() { XSync(Xdisplay, false); }
Point GetOffset() const { return actual_offset; }
static XftFont *CreateXftFont(Font f, int angle);
XftDraw *GetXftDraw() const { return xftdraw; }
Rect GetClip() const;
void SetForeground(Color color);
void SetLineStyle(int width);
void SetClip();
Drawable GetDrawable() const { return dw; }
GC GetGC() const { return gc; }
const Vector<Rect>& GetClipList() const { return clip.Top(); }
SystemDraw(Drawable dw, GC gc, XftDraw *xftdraw, const Vector<Rect>& clip);
};
END_UPP_NAMESPACE
#endif