20#include <Cocoa/Cocoa.h>
88 "Execute, gVirtualX is either null or not of TGCocoa type");
98 assert(segments != 0 &&
"DrawSegments, segments parameter is null");
99 assert(nSegments > 0 &&
"DrawSegments, nSegments <= 0");
101 fSegments.assign(segments, segments + nSegments);
108 "Execute, gVirtualX is either null or not of TGCocoa type");
124 "Execute, gVirtualX is either null or not of TGCocoa type");
142 return fID == drawable ||
fSrc == drawable ||
fGC.fClipMask == drawable;
149 "Execute, gVirtualX is either null or not of TGCocoa type");
158 const std::string &
text)
169 "Execute, gVirtualX is either null or not of TGCocoa type");
187 "Execute, gVirtualX is either null or not of TGCocoa type");
199 assert(
points != 0 &&
"FillPolygon, points parameter is null");
200 assert(nPoints > 0 &&
"FillPolygon, nPoints <= 0");
209 "Execute, gVirtualX is either null or not of TGCocoa type");
226 "Execute, gVirtualX is either null or not of TGCocoa type");
238 assert(
view != nil &&
"UpdateWindow, view parameter is nil");
244 assert(
fView.fContext != 0 &&
"Execute, view.fContext is null");
247 [
fView copy : pixmap area :
Rectangle(0, 0, pixmap.fWidth, pixmap.fHeight)
248 withMask : nil clipOrigin :
Point() toPoint :
Point()];
261 "Execute, gVirtualX is either null or not of TGCocoa type");
273 std::swap(
fP1.fX,
fP2.fX);
275 std::swap(
fP1.fY,
fP2.fY);
281 return NSPoint{CGFloat(rp.fX), CGFloat(rp.fY)};
287 assert(ctx &&
"Execute, 'ctx' parameter is nullptr");
292 CGContextStrokeRect(ctx, CGRectMake(btLeft.x, btLeft.y,
fP2.fX -
fP1.fX,
height));
306 assert(ctx &&
"Execute, invalid (nullptr) parameter 'ctx'");
310 for (
auto &point :
line) {
312 point = [
view convertPoint : point toView : nil];
315 CGContextBeginPath(ctx);
316 CGContextMoveToPoint(ctx,
line[0].
x,
line[0].
y);
317 CGContextAddLineToPoint(ctx,
line[1].
x,
line[1].
y);
318 CGContextStrokePath(ctx);
325 for (
Int_t i = 0; i <
n; ++i) {
326 auto point = NSPoint{CGFloat(
xy[i].fX), CGFloat(
xy[i].fY)};
327 point = [
view convertPoint : point toView : nil];
336 assert(ctx &&
"Execute, invalid (nullptr) parameter 'ctx'");
356 for (
Int_t i = 0; i <
n; ++i) {
357 auto point = NSPoint{CGFloat(
xy[i].fX), CGFloat(
xy[i].fY)};
358 point = [
view convertPoint : point toView : nil];
367 assert(ctx &&
"Execute, invalid (nullptr) parameter 'ctx'");
394 }
catch (
const std::exception &) {
403 assert(segments != 0 &&
"AddDrawSegments, segments parameter is null");
404 assert(nSegments > 0 &&
"AddDrawSegments, nSegments <= 0");
407 std::unique_ptr<DrawSegments> cmd(
new DrawSegments(
wid,
gc, segments, nSegments));
410 }
catch (
const std::exception &) {
427 }
catch (
const std::exception &) {
447 }
catch (
const std::exception &) {
459 const std::string substr(
text,
len);
463 }
catch (
const std::exception &) {
481 }
catch (
const std::exception &) {
499 }
catch (
const std::exception &) {
508 assert(polygon != 0 &&
"AddFillPolygon, polygon parameter is null");
509 assert(nPoints > 0 &&
"AddFillPolygon, nPoints <= 0");
512 std::unique_ptr<FillPolygon> cmd(
new FillPolygon(
wid,
gc, polygon, nPoints));
515 }
catch (
const std::exception &) {
523 assert(view != nil &&
"AddUpdateWindow, view parameter is nil");
526 std::unique_ptr<UpdateWindow> cmd(
new UpdateWindow(view));
529 }
catch (
const std::exception &) {
538 std::unique_ptr<DeletePixmap> cmd(
new DeletePixmap(pixmapID));
541 }
catch (
const std::exception &) {
549 assert(impl != 0 &&
"Flush, impl parameter is null");
565 if (drawable.fIsPixmap) {
572 if (prevView != view)
578 if ([view lockFocusIfCanDraw]) {
579 NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
580 assert(nsContext != nil &&
"Flush, currentContext is nil");
582 assert(currContext != 0 &&
"Flush, graphicsPort is null");
585 if (prevContext && prevContext != currContext)
586 CGContextFlush(prevContext);
587 prevContext = currContext;
605 withMask : nil clipOrigin :
Point() toPoint :
Point()];
612 }
catch (
const std::exception &) {
623 CGContextFlush(currContext);
666bool RectsOverlap(
const NSRect &r1,
const NSRect &r2)
668 if (r2.origin.x >= r1.origin.x + r1.size.width)
670 if (r2.origin.x + r2.size.width <= r1.origin.x)
672 if (r2.origin.y >= r1.origin.y + r1.size.height)
674 if (r2.origin.y + r2.size.height <= r1.origin.y)
698 assert(view != nil &&
"ClipOverlaps, view parameter is nil");
700 typedef std::vector<QuartzView *>::reverse_iterator reverse_iterator;
701 typedef std::vector<CGRect>::iterator rect_iterator;
724 const NSRect frame2 = view.frame;
728 bool doCheck =
false;
730 if (ancestorView == sibling) {
735 }
else if (!doCheck || sibling.fMapState !=
kIsViewable) {
739 frame1 = sibling.frame;
741 if (!frame1.size.width || !frame1.size.height)
744 frame1.origin = [sibling.fParentView convertPoint : frame1.origin
748 if (RectsOverlap(frame2, frame1)) {
750 clipRect.
fX1 = frame1.origin.x;
751 clipRect.
fX2 = clipRect.
fX1 + frame1.size.width;
752 clipRect.
fY1 = frame1.origin.y;
753 clipRect.
fY2 = clipRect.
fY1 + frame1.size.height;
765 frame1 =
child.frame;
767 if (!frame1.size.width || !frame1.size.height)
771 frame1.origin = [view convertPoint : frame1.origin toView : view.
fParentView];
773 if (RectsOverlap(frame2, frame1)) {
774 clipRect.
fX1 = frame1.origin.x;
775 clipRect.
fX2 = clipRect.
fX1 + frame1.size.width;
776 clipRect.
fY1 = frame1.origin.y;
777 clipRect.
fY2 = clipRect.
fY1 + frame1.size.height;
786 WidgetRect rect(frame2.origin.x, frame2.origin.y, frame2.origin.x + frame2.size.width,
787 frame2.origin.y + frame2.size.height);
795 for (; recIt != eIt; ++recIt) {
796 if (!recIt->size.width && !recIt->size.height) {
798 assert(
fClippedRegion.size() == 1 &&
"ClipOverlaps, internal logic error");
801 recIt->origin = NSPointToCGPoint([view.
fParentView convertPoint :
802 NSPointFromCGPoint(recIt->origin) toView : view]);
810typedef std::vector<int>::iterator int_iterator;
813int_iterator BinarySearchLeft(int_iterator first, int_iterator last,
int value)
818 const int_iterator it = std::lower_bound(first, last,
value);
819 assert(it != last && (it == first || *it ==
value) &&
"internal logic error");
822 return it == first && *it !=
value ? last : it;
826int_iterator BinarySearchRight(int_iterator first, int_iterator last,
int value)
831 const int_iterator it = std::lower_bound(first, last,
value);
832 assert((it == last || *it ==
value) &&
"internal logic error");
861 typedef std::vector<WidgetRect>::const_iterator rect_const_iterator;
863 assert(
fRectsToClip.size() != 0 &&
"BuildClipRegion, nothing to clip");
871 for (; recIt != endIt; ++recIt) {
872 if (recIt->fX1 <=
rect.fX1 && recIt->fX2 >=
rect.fX2 &&
873 recIt->fY1 <=
rect.fY1 && recIt->fY2 >=
rect.fY2) {
879 if (recIt->fX1 >
rect.fX1)
882 if (recIt->fX2 <
rect.fX2)
885 if (recIt->fY1 >
rect.fY1)
888 if (recIt->fY2 <
rect.fY2)
896 const int_iterator xBoundsEnd = std::unique(
fXBounds.begin(),
fXBounds.end());
897 const int_iterator yBoundsEnd = std::unique(
fYBounds.begin(),
fYBounds.end());
903 fGrid.assign(nXBands * nYBands,
false);
907 for (; recIt != endIt; ++recIt) {
908 const int_iterator left = BinarySearchLeft(
fXBounds.begin(), xBoundsEnd, recIt->fX1);
909 const size_type firstXBand = left == xBoundsEnd ? 0 : left -
fXBounds.begin() + 1;
911 const int_iterator right = BinarySearchRight(
fXBounds.begin(), xBoundsEnd, recIt->fX2);
914 const int_iterator bottom = BinarySearchLeft(
fYBounds.begin(), yBoundsEnd, recIt->fY1);
915 const size_type firstYBand = bottom == yBoundsEnd ? 0 : bottom -
fYBounds.begin() + 1;
917 const int_iterator top = BinarySearchRight(
fYBounds.begin(), yBoundsEnd, recIt->fY2);
920 for (
size_type i = firstYBand; i < lastYBand; ++i) {
922 for (
size_type j = firstXBand; j < lastXBand; ++j)
923 fGrid[baseIndex + j] =
true;
931 for (
size_type i = 0; i < nYBands; ++i) {
933 for (
size_type j = 0; j < nXBands; ++j) {
934 if (!
fGrid[baseIndex + j]) {
938 newRect.size.width = (j == nXBands - 1 ?
rect.fX2 :
fXBounds[j]) - newRect.origin.x;
939 newRect.size.height = (i == nYBands - 1 ?
rect.fY2 :
fYBounds[i]) - newRect.origin.y;
Handle_t Pixmap_t
Pixmap handle.
Handle_t Window_t
Window handle.
Handle_t Drawable_t
Drawable handle.
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
int Int_t
Signed integer 4 bytes (int)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
short SCoord_t
Screen coordinates (short)
if(isa< VarDecl >(D)||isa< FieldDecl >(D)||isa< EnumConstantDecl >(D))
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t CopyArea
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char FillPolygon
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char DrawLine
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t FillRectangle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
NSObject< X11Drawable > * GetDrawable(Drawable_t drawableD) const
NSObject< X11Window > * GetWindow(Window_t windowID) const
ClearArea(Window_t wid, const Rectangle_t &area)
void Execute() const override
std::vector< WidgetRect > fRectsToClip
std::vector< CGRect > fClippedRegion
std::vector< bool > fGrid
void Flush(Details::CocoaPrivate *impl)
void AddDrawSegments(Drawable_t wid, const GCValues_t &gc, const Segment_t *segments, Int_t nSegments)
void AddFillPolygon(Drawable_t wid, const GCValues_t &gc, const Point_t *polygon, Int_t nPoints)
void ClipOverlaps(QuartzView *view)
std::vector< QuartzView * > fViewBranch
void RemoveGraphicsOperationsForWindow(Window_t wid)
void AddClearArea(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
std::vector< int > fYBounds
void AddDrawRectangle(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
void AddDrawLine(Drawable_t wid, const GCValues_t &gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
void RemoveOperationsForDrawable(Drawable_t wid)
std::vector< Command * >::size_type size_type
void AddDrawString(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, const char *text, Int_t len)
void AddDeletePixmap(Pixmap_t pixmap)
std::vector< Command * > fCommands
std::vector< int > fXBounds
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)
void AddUpdateWindow(QuartzView *view)
void BuildClipRegion(const WidgetRect &rect)
void AddFillRectangle(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
virtual bool IsGraphicsCommand() const
virtual void Execute() const =0
virtual bool HasOperand(Drawable_t drawable) const
bool HasOperand(Drawable_t drawable) const override
CopyArea(Drawable_t src, Drawable_t dst, const GCValues_t &gc, const Rectangle_t &area, const Point &dstPoint)
void Execute() const override
DeletePixmap(Pixmap_t pixmap)
void Execute() const override
void Execute() const override
DrawBoxXor(Window_t windowID, const Point &p1, const Point &p2)
DrawLineXor(Window_t windowID, const Point &p1, const Point &p2)
void Execute() const override
void Execute() const override
DrawLine(Drawable_t wid, const GCValues_t &gc, const Point &p1, const Point &p2)
void setPoints(Int_t n, TPoint *xy)
std::vector< TPoint > fPnts
void Execute() const override
std::vector< TPoint > fPnts
void setPoints(Int_t n, TPoint *xy)
void Execute() const override
DrawRectangle(Drawable_t wid, const GCValues_t &gc, const Rectangle_t &rectangle)
void Execute() const override
std::vector< Segment_t > fSegments
DrawSegments(Drawable_t wid, const GCValues_t &gc, const Segment_t *segments, Int_t nSegments)
void Execute() const override
DrawString(Drawable_t wid, const GCValues_t &gc, const Point &point, const std::string &text)
void Execute() const override
std::vector< Point_t > fPolygon
void Execute() const override
FillPolygon(Drawable_t wid, const GCValues_t &gc, const Point_t *points, Int_t nPoints)
const Rectangle_t fRectangle
void Execute() const override
FillRectangle(Drawable_t wid, const GCValues_t &gc, const Rectangle_t &rectangle)
void Execute() const override
UpdateWindow(QuartzView *view)
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D.
void DrawLineAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
void FillRectangleAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x, Int_t y, UInt_t w, UInt_t h)
void CopyAreaAux(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)
void DrawRectangleAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x, Int_t y, UInt_t w, UInt_t h)
void DrawStringAux(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, const char *s, Int_t len)
void ClearAreaAux(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
void DrawSegmentsAux(Drawable_t wid, const GCValues_t &gcVals, const Segment_t *segments, Int_t nSegments)
QuartzPixmap * fBackBuffer
QuartzWindow * fQuartzWindow
QuartzImage * fShapeCombineMask
void ClipToShapeMask(NSView< X11Window > *view, CGContextRef ctx)
Bool_t SetLineColor(CGContextRef ctx, Color_t colorIndex)
void DrawPolyMarker(CGContextRef ctx, unsigned nPoints, const TPoint *marker, const TAttMarker &attmark, float scaleFactor)
void DrawPolyLine(CGContextRef ctx, Int_t n, const TPoint *xy)
void SetLineWidth(CGContextRef ctx, Int_t width)
void SetLineStyle(CGContextRef ctx, Int_t lstyle)
Graphics context structure.
Point structure (maps to the X11 XPoint structure)
Rectangle structure (maps to the X11 XRectangle structure)
Used for drawing line segments (maps to the X11 XSegments structure)