Logo ROOT  
Reference Guide
X11Buffer.h
Go to the documentation of this file.
1// @(#)root/graf2d:$Id$
2// Author: Timur Pocheptsov 29/02/2012
3
4/*************************************************************************
5 * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_X11Buffer
13#define ROOT_X11Buffer
14
15#include <vector>
16#include <string>
17
18#include <Cocoa/Cocoa.h>
19
20#include "CocoaGuiTypes.h"
21#include "GuiTypes.h"
22
23//////////////////////////////////////////////////////////////////////////////////
24// //
25// Unfortunately, TGCocoa's drawing methods can be called in a //
26// "wrong" time and place: not from QuartzView -drawRect. //
27// For example, on mouse move. This is bad and unnatural for Cocoa application, //
28// since I expect GUI to draw only when I'm ready == ... called from drawRect. //
29// In X11 commands are buffered and this buffer is flushed at some points. //
30// I'm trying to emulate this, just to make GUI happy. //
31// //
32//////////////////////////////////////////////////////////////////////////////////
33
34@class QuartzView;
35
36namespace ROOT {
37namespace MacOSX {
38
39namespace Details {
40class CocoaPrivate;
41}
42
43namespace X11 {
44
45class Command {
46 friend class CommandBuffer;
47
48protected:
51
52public:
54 Command(Drawable_t wid, const GCValues_t &gc);
55 virtual ~Command();
56
57 virtual bool HasOperand(Drawable_t drawable)const;
58 virtual bool IsGraphicsCommand()const;//By-default - false.
59
60 virtual void Execute()const = 0;
61 virtual void Execute(CGContextRef /*ctx*/)const;
62
63private:
64 Command(const Command &rhs);
66};
67
68class DrawLine : public Command {
69private:
70 const Point fP1;
71 const Point fP2;
72
73public:
74 DrawLine(Drawable_t wid, const GCValues_t &gc, const Point &p1, const Point &p2);
75 void Execute()const;
77 {
78 return true;
79 }
80};
81
82class DrawSegments : public Command {
83private:
84 std::vector<Segment_t> fSegments;
85
86public:
87 DrawSegments(Drawable_t wid, const GCValues_t &gc, const Segment_t *segments, Int_t nSegments);
88 void Execute()const;
90 {
91 return true;
92 }
93};
94
95class ClearArea : public Command {
96private:
97 const Rectangle_t fArea;//to be replaced with X11::Rectangle
98
99public:
100 ClearArea(Window_t wid, const Rectangle_t &area);
101 void Execute()const;
103 {
104 return true;
105 }
106};
107
108class CopyArea : public Command {
109private:
111 const Rectangle_t fArea;//to be replaced with X11::Rectangle
113
114public:
115 CopyArea(Drawable_t src, Drawable_t dst, const GCValues_t &gc, const Rectangle_t &area, const Point &dstPoint);
116
117 bool HasOperand(Drawable_t drawable)const;
119 {
120 return true;
121 }
122
123 void Execute()const;
124
125};
126
127class DrawString : public Command {
128private:
130 const std::string fText;
131
132public:
133 DrawString(Drawable_t wid, const GCValues_t &gc, const Point &point, const std::string &text);
134
136 {
137 return true;
138 }
139
140 void Execute()const;
141};
142
143class FillRectangle : public Command {
144private:
145 const Rectangle_t fRectangle;//to be replaced with X11::Rectangle
146
147public:
148 FillRectangle(Drawable_t wid, const GCValues_t &gc, const Rectangle_t &rectangle);
149
151 {
152 return true;
153 }
154
155 void Execute()const;
156};
157
158class FillPolygon : public Command {
159private:
160 std::vector<Point_t> fPolygon;
161
162public:
163 FillPolygon(Drawable_t wid, const GCValues_t &gc, const Point_t *points, Int_t nPoints);
164
166 {
167 return true;
168 }
169
170 void Execute()const;
171};
172
173class DrawRectangle : public Command {
174private:
175 Rectangle_t fRectangle;//to be replaced with X11::Rectangle
176
177public:
178 DrawRectangle(Drawable_t wid, const GCValues_t &gc, const Rectangle_t &rectangle);
179
181 {
182 return true;
183 }
184
185 void Execute()const;
186};
187
188class UpdateWindow : public Command {
189private:
191
192public:
194
196 {
197 return true;
198 }
199
200 void Execute()const;
201};
202
203class DeletePixmap : public Command {
204public:
205 DeletePixmap(Pixmap_t pixmap);
206 void Execute()const;
207};
208
209//Set of 'xor' operations, required by TCanvas and ExecuteEvent's machinery.
210class DrawBoxXor : public Command {
211private:
214
215public:
216 DrawBoxXor(Window_t windowID, const Point &p1, const Point &p2);
217
218 void Execute()const;
219 void Execute(CGContextRef ctx)const;
220};
221
222class DrawLineXor : public Command {
223private:
226
227public:
228 DrawLineXor(Window_t windowID, const Point &p1, const Point &p2);
229
230 void Execute()const;
231 void Execute(CGContextRef ctx)const;
232
233 Point start() const {return fP1;}
234 Point end() const {return fP2;}
235};
236
238private:
241
242 std::vector<Command *> fCommands;
243 std::vector<QuartzView *> fViewBranch;
244
245 std::vector<Command *> fXorOps;
246public:
247 typedef std::vector<Command *>::size_type size_type;
248
251
252 void AddDrawLine(Drawable_t wid, const GCValues_t &gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2);
253 void AddDrawSegments(Drawable_t wid, const GCValues_t &gc, const Segment_t *segments, Int_t nSegments);
254 void AddClearArea(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h);
255 void AddCopyArea(Drawable_t src, Drawable_t dst, const GCValues_t &gc, Int_t srcX, Int_t srcY, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY);
256 void AddDrawString(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, const char *text, Int_t len);
257 void AddFillRectangle(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, UInt_t w, UInt_t h);
258 void AddFillPolygon(Drawable_t wid, const GCValues_t &gc, const Point_t *polygon, Int_t nPoints);
259 void AddDrawRectangle(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, UInt_t w, UInt_t h);
260 void AddUpdateWindow(QuartzView *view);
261 void AddDeletePixmap(Pixmap_t pixmap);
262
263 //'XOR' graphics for canvas.
264 void AddDrawBoxXor(Window_t windowID, Int_t x1, Int_t y1, Int_t x2, Int_t y2);
265 void AddDrawLineXor(Window_t windowID, Int_t x1, Int_t y1, Int_t x2, Int_t y2);
266
267 void Flush(Details::CocoaPrivate *impl);
272
274 {
275 return fCommands.size();
276 }
277
278 void ClearXOROperations();
279private:
280 void ClearCommands();
281 //Clip related stuff.
282 struct WidgetRect {
283 int fX1;
284 int fY1;
285 int fX2;
286 int fY2;
287
289 : fX1(0), fY1(0), fX2(0), fY2(0)
290 {
291 }
292
293 WidgetRect(int leftX, int bottomY, int rightX, int topY)
294 : fX1(leftX), fY1(bottomY), fX2(rightX), fY2(topY)
295 {
296 }
297 };
298
299 void ClipOverlaps(QuartzView *view);
300 void BuildClipRegion(const WidgetRect &rect);
301
302 std::vector<WidgetRect> fRectsToClip;
303 std::vector<CGRect> fClippedRegion;
304 std::vector<int> fXBounds;
305 std::vector<int> fYBounds;
306 std::vector<bool> fGrid;
307};
308
309}//X11
310}//MacOSX
311}//ROOT
312
313#endif
Handle_t Pixmap_t
Definition: GuiTypes.h:29
Handle_t Drawable_t
Definition: GuiTypes.h:30
Handle_t Window_t
Definition: GuiTypes.h:28
#define h(i)
Definition: RSha256.hxx:106
static const double x2[5]
static const double x1[5]
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
point * points
Definition: X3DBuffer.c:22
ClearArea(Window_t wid, const Rectangle_t &area)
Definition: X11Buffer.mm:111
const Rectangle_t fArea
Definition: X11Buffer.h:97
bool IsGraphicsCommand() const
Definition: X11Buffer.h:102
void RemoveXORGraphicsOperationsForWindow(Window_t wid)
Definition: X11Buffer.mm:687
void AddDrawBoxXor(Window_t windowID, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Definition: X11Buffer.mm:487
std::vector< WidgetRect > fRectsToClip
Definition: X11Buffer.h:302
std::vector< CGRect > fClippedRegion
Definition: X11Buffer.h:303
std::vector< Command * > fXorOps
Definition: X11Buffer.h:245
std::vector< bool > fGrid
Definition: X11Buffer.h:306
void AddDrawLineXor(Window_t windowID, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Definition: X11Buffer.mm:499
void Flush(Details::CocoaPrivate *impl)
Definition: X11Buffer.mm:511
CommandBuffer(const CommandBuffer &rhs)
void AddDrawSegments(Drawable_t wid, const GCValues_t &gc, const Segment_t *segments, Int_t nSegments)
Definition: X11Buffer.mm:340
void AddFillPolygon(Drawable_t wid, const GCValues_t &gc, const Point_t *polygon, Int_t nPoints)
Definition: X11Buffer.mm:445
void FlushXOROps(Details::CocoaPrivate *impl)
Definition: X11Buffer.mm:593
void ClipOverlaps(QuartzView *view)
Definition: X11Buffer.mm:737
std::vector< QuartzView * > fViewBranch
Definition: X11Buffer.h:243
void RemoveGraphicsOperationsForWindow(Window_t wid)
Definition: X11Buffer.mm:674
void AddClearArea(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition: X11Buffer.mm:356
std::vector< int > fYBounds
Definition: X11Buffer.h:305
void AddDrawRectangle(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition: X11Buffer.mm:427
void AddDrawLine(Drawable_t wid, const GCValues_t &gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Definition: X11Buffer.mm:326
void RemoveOperationsForDrawable(Drawable_t wid)
Definition: X11Buffer.mm:656
std::vector< Command * >::size_type size_type
Definition: X11Buffer.h:247
void AddDrawString(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, const char *text, Int_t len)
Definition: X11Buffer.mm:393
CommandBuffer & operator=(const CommandBuffer &rhs)
void AddDeletePixmap(Pixmap_t pixmap)
Definition: X11Buffer.mm:475
std::vector< Command * > fCommands
Definition: X11Buffer.h:242
std::vector< int > fXBounds
Definition: X11Buffer.h:304
void AddCopyArea(Drawable_t src, Drawable_t dst, const GCValues_t &gc, Int_t srcX, Int_t srcY, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY)
Definition: X11Buffer.mm:373
void AddUpdateWindow(QuartzView *view)
Definition: X11Buffer.mm:461
void BuildClipRegion(const WidgetRect &rect)
Definition: X11Buffer.mm:894
size_type BufferSize() const
Definition: X11Buffer.h:273
void AddFillRectangle(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition: X11Buffer.mm:409
const GCValues_t fGC
Definition: X11Buffer.h:50
Command & operator=(const Command &rhs)
Command(Drawable_t wid)
Definition: X11Buffer.mm:45
const Drawable_t fID
Definition: X11Buffer.h:49
Command(const Command &rhs)
virtual bool IsGraphicsCommand() const
Definition: X11Buffer.mm:68
virtual void Execute() const =0
virtual bool HasOperand(Drawable_t drawable) const
Definition: X11Buffer.mm:62
bool IsGraphicsCommand() const
Definition: X11Buffer.h:118
bool HasOperand(Drawable_t drawable) const
Definition: X11Buffer.mm:137
const Drawable_t fSrc
Definition: X11Buffer.h:110
CopyArea(Drawable_t src, Drawable_t dst, const GCValues_t &gc, const Rectangle_t &area, const Point &dstPoint)
Definition: X11Buffer.mm:127
const Rectangle_t fArea
Definition: X11Buffer.h:111
DeletePixmap(Pixmap_t pixmap)
Definition: X11Buffer.mm:249
DrawBoxXor(Window_t windowID, const Point &p1, const Point &p2)
Definition: X11Buffer.mm:264
DrawLineXor(Window_t windowID, const Point &p1, const Point &p2)
Definition: X11Buffer.mm:294
DrawLine(Drawable_t wid, const GCValues_t &gc, const Point &p1, const Point &p2)
Definition: X11Buffer.mm:74
bool IsGraphicsCommand() const
Definition: X11Buffer.h:76
DrawRectangle(Drawable_t wid, const GCValues_t &gc, const Rectangle_t &rectangle)
Definition: X11Buffer.mm:212
std::vector< Segment_t > fSegments
Definition: X11Buffer.h:84
DrawSegments(Drawable_t wid, const GCValues_t &gc, const Segment_t *segments, Int_t nSegments)
Definition: X11Buffer.mm:91
DrawString(Drawable_t wid, const GCValues_t &gc, const Point &point, const std::string &text)
Definition: X11Buffer.mm:154
bool IsGraphicsCommand() const
Definition: X11Buffer.h:135
const std::string fText
Definition: X11Buffer.h:130
std::vector< Point_t > fPolygon
Definition: X11Buffer.h:160
FillPolygon(Drawable_t wid, const GCValues_t &gc, const Point_t *points, Int_t nPoints)
Definition: X11Buffer.mm:192
const Rectangle_t fRectangle
Definition: X11Buffer.h:145
FillRectangle(Drawable_t wid, const GCValues_t &gc, const Rectangle_t &rectangle)
Definition: X11Buffer.mm:173
UpdateWindow(QuartzView *view)
Definition: X11Buffer.mm:231
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21
WidgetRect(int leftX, int bottomY, int rightX, int topY)
Definition: X11Buffer.h:293