19#include <Cocoa/Cocoa.h> 
   85          "Execute, gVirtualX is either null or not of TGCocoa type");
 
   95   assert(segments != 0 && 
"DrawSegments, segments parameter is null");
 
   96   assert(nSegments > 0 && 
"DrawSegments, nSegments <= 0");
 
   98   fSegments.assign(segments, segments + nSegments);
 
  105          "Execute, gVirtualX is either null or not of TGCocoa type");
 
  121          "Execute, gVirtualX is either null or not of TGCocoa type");
 
  146          "Execute, gVirtualX is either null or not of TGCocoa type");
 
  155                       const std::string &
text)
 
  166          "Execute, gVirtualX is either null or not of TGCocoa type");
 
  176                    fRectangle(rectangle)
 
  184          "Execute, gVirtualX is either null or not of TGCocoa type");
 
  196   assert(
points != 0 && 
"FillPolygon, points parameter is null");
 
  197   assert(nPoints > 0 && 
"FillPolygon, nPoints <= 0");
 
  206          "Execute, gVirtualX is either null or not of TGCocoa type");
 
  215                   fRectangle(rectangle)
 
  223          "Execute, gVirtualX is either null or not of TGCocoa type");
 
  235   assert(
view != nil && 
"UpdateWindow, view parameter is nil");
 
  241   assert(
fView.
fContext != 0 && 
"Execute, view.fContext is null");
 
  244      [
fView copy : pixmap area : 
Rectangle(0, 0, pixmap.fWidth, pixmap.fHeight)
 
  245         withMask : nil clipOrigin : 
Point() toPoint : 
Point()];
 
  258          "Execute, gVirtualX is either null or not of TGCocoa type");
 
  282    return NSPoint{CGFloat(rp.fX), CGFloat(rp.fY)};
 
  288   assert(ctx && 
"Execute, 'ctx' parameter is nullptr");
 
  293   CGContextStrokeRect(ctx, CGRectMake(btLeft.x, btLeft.y, 
fP2.
fX - 
fP1.
fX, 
height));
 
  313   assert(ctx && 
"Execute, invalid (nullptr) parameter 'ctx'");
 
  317   for (
auto &point : 
line) {
 
  319      point = [
view convertPoint : point toView : nil];
 
  322   CGContextBeginPath(ctx);
 
  323   CGContextMoveToPoint(ctx, 
line[0].
x, 
line[0].
y);
 
  324   CGContextAddLineToPoint(ctx, 
line[1].
x, 
line[1].
y);
 
  325   CGContextStrokePath(ctx);
 
  349   } 
catch (
const std::exception &) {
 
  358   assert(segments != 0 && 
"AddDrawSegments, segments parameter is null");
 
  359   assert(nSegments > 0 && 
"AddDrawSegments, nSegments <= 0");
 
  362      std::unique_ptr<DrawSegments> cmd(
new DrawSegments(
wid, 
gc, segments, nSegments));
 
  365   } 
catch (
const std::exception &) {
 
  382   } 
catch (
const std::exception &) {
 
  402   } 
catch (
const std::exception &) {
 
  414      const std::string substr(
text, 
len);
 
  418   } 
catch (
const std::exception &) {
 
  436   } 
catch (
const std::exception &) {
 
  454   } 
catch (
const std::exception &) {
 
  463   assert(polygon != 0 && 
"AddFillPolygon, polygon parameter is null");
 
  464   assert(nPoints > 0 && 
"AddFillPolygon, nPoints <= 0");
 
  467      std::unique_ptr<FillPolygon> cmd(
new FillPolygon(
wid, 
gc, polygon, nPoints));
 
  470   } 
catch (
const std::exception &) {
 
  478   assert(view != nil && 
"AddUpdateWindow, view parameter is nil");
 
  481      std::unique_ptr<UpdateWindow> cmd(
new UpdateWindow(view));
 
  484   } 
catch (
const std::exception &) {
 
  493      std::unique_ptr<DeletePixmap> cmd(
new DeletePixmap(pixmapID));
 
  496   } 
catch (
const std::exception &) {
 
  508   } 
catch (
const std::exception &) {
 
  520   } 
catch (
const std::exception &) {
 
  528   assert(impl != 0 && 
"Flush, impl parameter is null");
 
  544      if (drawable.fIsPixmap) {
 
  551      if (prevView != view)
 
  557         if ([view lockFocusIfCanDraw]) {
 
  558            NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
 
  559            assert(nsContext != nil && 
"Flush, currentContext is nil");
 
  561            assert(currContext != 0 && 
"Flush, graphicsPort is null");
 
  564            if (prevContext && prevContext != currContext)
 
  565               CGContextFlush(prevContext);
 
  566            prevContext = currContext;
 
  584                 withMask : nil clipOrigin : 
Point() toPoint : 
Point()];
 
  591      } 
catch (
const std::exception &) {
 
  602      CGContextFlush(currContext);
 
  621   assert(impl != 0 && 
"FlushXOROps, impl parameter is null");
 
  624   assert([drawable isKindOfClass : [
QuartzView class]] &&
 
  625          "FlushXOROps, drawable must be of type QuartzView");
 
  630   auto xorWindow = [window findXorWindow];
 
  632      ::Warning(
"FlushXOROps", 
"No XorDrawingWindow found to draw into");
 
  638   [cv setXorOperations: 
fXorOps]; 
 
  640   [cv setNeedsDisplay : YES];
 
  708bool RectsOverlap(
const NSRect &r1, 
const NSRect &r2)
 
  710   if (r2.origin.x >= r1.origin.x + r1.size.width)
 
  712   if (r2.origin.x + r2.size.width <= r1.origin.x)
 
  714   if (r2.origin.y >= r1.origin.y + r1.size.height)
 
  716   if (r2.origin.y + r2.size.height <= r1.origin.y)
 
  740   assert(view != nil && 
"ClipOverlaps, view parameter is nil");
 
  742   typedef std::vector<QuartzView *>::reverse_iterator reverse_iterator;
 
  743   typedef std::vector<CGRect>::iterator rect_iterator;
 
  766   const NSRect frame2 = view.frame;
 
  770      bool doCheck = 
false;
 
  772         if (ancestorView == sibling) {
 
  777         } 
else if (!doCheck || sibling.fMapState != 
kIsViewable) {
 
  781         frame1 = sibling.frame;
 
  783         if (!frame1.size.width || !frame1.size.height)
 
  786         frame1.origin = [sibling.fParentView convertPoint : frame1.origin
 
  790         if (RectsOverlap(frame2, frame1)) {
 
  792            clipRect.
fX1 = frame1.origin.x;
 
  793            clipRect.
fX2 = clipRect.
fX1 + frame1.size.width;
 
  794            clipRect.
fY1 = frame1.origin.y;
 
  795            clipRect.
fY2 = clipRect.
fY1 + frame1.size.height;
 
  807      frame1 = 
child.frame;
 
  809      if (!frame1.size.width || !frame1.size.height)
 
  813         frame1.origin = [view convertPoint : frame1.origin toView : view.
fParentView];
 
  815      if (RectsOverlap(frame2, frame1)) {
 
  816         clipRect.
fX1 = frame1.origin.x;
 
  817         clipRect.
fX2 = clipRect.
fX1 + frame1.size.width;
 
  818         clipRect.
fY1 = frame1.origin.y;
 
  819         clipRect.
fY2 = clipRect.
fY1 + frame1.size.height;
 
  828      WidgetRect rect(frame2.origin.x, frame2.origin.y, frame2.origin.x + frame2.size.width,
 
  829                      frame2.origin.y + frame2.size.height);
 
  837         for (; recIt != eIt; ++recIt) {
 
  838            if (!recIt->size.width && !recIt->size.height) {
 
  840               assert(
fClippedRegion.size() == 1 && 
"ClipOverlaps, internal logic error");
 
  843            recIt->origin = NSPointToCGPoint([view.
fParentView convertPoint :
 
  844                                              NSPointFromCGPoint(recIt->origin) toView : view]);
 
  852typedef std::vector<int>::iterator int_iterator;
 
  855int_iterator BinarySearchLeft(int_iterator 
first, int_iterator last, 
int value)
 
  860   const int_iterator it = std::lower_bound(
first, last, 
value);
 
  861   assert(it != last && (it == 
first || *it == 
value) && 
"internal logic error");
 
  864   return it == 
first && *it != 
value ? last : it;
 
  868int_iterator BinarySearchRight(int_iterator 
first, int_iterator last, 
int value)
 
  873   const int_iterator it = std::lower_bound(
first, last, 
value);
 
  874   assert((it == last || *it == 
value) && 
"internal logic error");
 
  903   typedef std::vector<WidgetRect>::const_iterator rect_const_iterator;
 
  905   assert(
fRectsToClip.size() != 0 && 
"BuildClipRegion, nothing to clip");
 
  913   for (; recIt != endIt; ++recIt) {
 
  914      if (recIt->fX1 <= 
rect.fX1 && recIt->fX2 >= 
rect.fX2 &&
 
  915          recIt->fY1 <= 
rect.fY1 && recIt->fY2 >= 
rect.fY2) {
 
  921      if (recIt->fX1 > 
rect.fX1)
 
  924      if (recIt->fX2 < 
rect.fX2)
 
  927      if (recIt->fY1 > 
rect.fY1)
 
  930      if (recIt->fY2 < 
rect.fY2)
 
  938   const int_iterator xBoundsEnd = std::unique(
fXBounds.begin(), 
fXBounds.end());
 
  939   const int_iterator yBoundsEnd = std::unique(
fYBounds.begin(), 
fYBounds.end());
 
  945   fGrid.assign(nXBands * nYBands, 
false);
 
  949   for (; recIt != endIt; ++recIt) {
 
  950      const int_iterator left = BinarySearchLeft(
fXBounds.begin(), xBoundsEnd, recIt->fX1);
 
  951      const size_type firstXBand = left == xBoundsEnd ? 0 : left - 
fXBounds.begin() + 1;
 
  953      const int_iterator right = BinarySearchRight(
fXBounds.begin(), xBoundsEnd, recIt->fX2);
 
  956      const int_iterator bottom = BinarySearchLeft(
fYBounds.begin(), yBoundsEnd, recIt->fY1);
 
  957      const size_type firstYBand = bottom == yBoundsEnd ? 0 : bottom - 
fYBounds.begin() + 1;
 
  959      const int_iterator top = BinarySearchRight(
fYBounds.begin(), yBoundsEnd, recIt->fY2);
 
  962      for (
size_type i = firstYBand; i < lastYBand; ++i) {
 
  964         for (
size_type j = firstXBand; j < lastXBand; ++j)
 
  965            fGrid[baseIndex + j] = 
true;
 
  973   for (
size_type i = 0; i < nYBands; ++i) {
 
  975      for (
size_type j = 0; j < nXBands; ++j) {
 
  976         if (!
fGrid[baseIndex + j]) {
 
  980            newRect.size.width = (j == nXBands - 1 ? 
rect.fX2 : 
fXBounds[j]) - newRect.origin.x;
 
  981            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.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
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 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 TPoint const char y2
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 RemoveXORGraphicsOperationsForWindow(Window_t wid)
void AddDrawBoxXor(Window_t windowID, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
std::vector< WidgetRect > fRectsToClip
std::vector< CGRect > fClippedRegion
std::vector< Command * > fXorOps
std::vector< bool > fGrid
void AddDrawLineXor(Window_t windowID, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
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 FlushXOROps(Details::CocoaPrivate *impl)
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 ClearXOROperations()
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
CopyArea(Drawable_t src, Drawable_t dst, const GCValues_t &gc, const Rectangle_t &area, const Point &dstPoint)
DeletePixmap(Pixmap_t pixmap)
DrawBoxXor(Window_t windowID, const Point &p1, const Point &p2)
DrawLineXor(Window_t windowID, const Point &p1, const Point &p2)
DrawLine(Drawable_t wid, const GCValues_t &gc, const Point &p1, const Point &p2)
DrawRectangle(Drawable_t wid, const GCValues_t &gc, const Rectangle_t &rectangle)
std::vector< Segment_t > fSegments
DrawSegments(Drawable_t wid, const GCValues_t &gc, const Segment_t *segments, Int_t nSegments)
DrawString(Drawable_t wid, const GCValues_t &gc, const Point &point, const std::string &text)
std::vector< Point_t > fPolygon
FillPolygon(Drawable_t wid, const GCValues_t &gc, const Point_t *points, Int_t nPoints)
const Rectangle_t fRectangle
FillRectangle(Drawable_t wid, const GCValues_t &gc, const Rectangle_t &rectangle)
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
QuartzWindow * fQuartzWindow
QuartzImage * fShapeCombineMask
void ClipToShapeMask(NSView< X11Window > *view, CGContextRef ctx)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Graphics context structure.
Pixmap_t fClipMask
bitmap clipping; other calls for rects
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)