Logo ROOT  
Reference Guide
TGQuartz.mm
Go to the documentation of this file.
1 // @(#)root/graf2d:$Id$
2 // Author: Olivier Couet, Timur Pocheptsov 23/01/2012
3 
4 
5 /*************************************************************************
6  * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
7  * All rights reserved. *
8  * *
9  * For the licensing terms see $ROOTSYS/LICENSE. *
10  * For the list of contributors see $ROOTSYS/README/CREDITS. *
11  *************************************************************************/
12 
13 //#define NDEBUG
14 
15 #include <stdexcept>
16 #include <iostream>
17 #include <cstring>
18 #include <cassert>
19 #include <limits>
20 
21 #include <Cocoa/Cocoa.h>
22 
23 # include <ft2build.h>
24 # include FT_FREETYPE_H
25 # include FT_GLYPH_H
26 
27 #include "QuartzFillArea.h"
28 #include "TColorGradient.h"
29 #include "QuartzMarker.h"
30 #include "CocoaPrivate.h"
31 #include "QuartzWindow.h"
32 #include "QuartzPixmap.h"
33 #include "QuartzUtils.h"
34 #include "X11Drawable.h"
35 #include "QuartzText.h"
36 #include "QuartzLine.h"
37 #include "CocoaUtils.h"
38 #include "TGQuartz.h"
39 #include "TString.h"
40 #include "TPoint.h"
41 #include "TColor.h"
42 #include "TStyle.h"
43 #include "TROOT.h"
44 #include "TEnv.h"
45 #include "TMath.h"
46 
47 // To scale fonts to the same size as the TTF version
48 const Float_t kScale = 0.93376068;
49 
51 
52 namespace X11 = ROOT::MacOSX::X11;
53 namespace Quartz = ROOT::Quartz;
54 namespace Util = ROOT::MacOSX::Util;
55 
56 namespace {
57 
58 //______________________________________________________________________________
59 void ConvertPointsROOTToCocoa(Int_t nPoints, const TPoint *xy, std::vector<TPoint> &dst,
60  NSObject<X11Drawable> *drawable)
61 {
62  assert(nPoints != 0 && "ConvertPointsROOTToCocoa, nPoints parameter is 0");
63  assert(xy != 0 && "ConvertPointsROOTToCocoa, xy parameter is null");
64  assert(drawable != 0 && "ConvertPointsROOTToCocoa, drawable parameter is null");
65 
66  const auto scaleFactor = drawable.fScaleFactor;
67 
68  dst.resize(nPoints);
69  for (Int_t i = 0; i < nPoints; ++i) {
70  dst[i].fX = SCoord_t(xy[i].fX * scaleFactor);
71  dst[i].fY = SCoord_t(X11::LocalYROOTToCocoa(drawable, xy[i].fY) * scaleFactor);
72  }
73 }
74 
75 }
76 
77 //______________________________________________________________________________
79  : fUseAA(true), fUseFAAA(false)
80 {
81  //Default ctor.
82 
83 
84  if (!TTF::IsInitialized())
85  TTF::Init();
86 
87  //I do not know why TTF::Init returns void and I have to check IsInitialized() again.
88  if (!TTF::IsInitialized())
89  Error("TGQuartz", "TTF::Init() failed");
90 
91  fAlign.x = 0;
92  fAlign.y = 0;
93 
94  SetAA();
95 }
96 
97 
98 //______________________________________________________________________________
99 TGQuartz::TGQuartz(const char *name, const char *title)
100  : TGCocoa(name, title),
101  fUseAA(true), fUseFAAA(false)
102 {
103  //Constructor.
104  if (!TTF::IsInitialized())
105  TTF::Init();
106 
107  //I do not know why TTF::Init returns void and I have to check IsInitialized() again.
108  if (!TTF::IsInitialized())
109  Error("TGQuartz", "TTF::Init() failed");
110 
111  fAlign.x = 0;
112  fAlign.y = 0;
113 
114  SetAA();
115 }
116 
117 
118 //______________________________________________________________________________
120 {
121  //Check some conditions first.
122  if (fDirectDraw) {
123  if (!fPimpl->GetDrawable(fSelectedDrawable).fIsPixmap)
124  fPimpl->fX11CommandBuffer.AddDrawBoxXor(fSelectedDrawable, x1, y1, x2, y2);
125  return;
126  }
127 
129  if (!drawable)
130  return;
131 
132  CGContextRef ctx = drawable.fContext;
133  const Quartz::CGStateGuard ctxGuard(ctx);
134  //AA flag is not a part of a state.
135  const Quartz::CGAAStateGuard aaCtxGuard(ctx, fUseAA);
136 
137  //Go to low-left-corner system.
138  y1 = Int_t(X11::LocalYROOTToCocoa(drawable, y1));
139  y2 = Int_t(X11::LocalYROOTToCocoa(drawable, y2));
140 
141  if (const TColorGradient * const gradient = dynamic_cast<TColorGradient *>(gROOT->GetColor(GetFillColor()))) {
142  //Draw a box with a gradient fill and a shadow.
143  //Ignore all fill styles and EBoxMode, use a gradient fill.
144  TPoint polygon[4];
145  polygon[0].fX = x1, polygon[0].fY = y1;
146  polygon[1].fX = x2, polygon[1].fY = y1;
147  polygon[2].fX = x2, polygon[2].fY = y2;
148  polygon[3].fX = x1, polygon[3].fY = y2;
149 
150  Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
151  4, polygon, kFALSE); //kFALSE == don't draw a shadow.
152  } else {
153  const bool isHollow = mode == kHollow || GetFillStyle() / 1000 == 2;
154 
155  //Note! Pattern index (and its address) MUST live
156  //long enough to be valid at the point of Quartz::DrawBox call!
157  unsigned patternIndex = 0;
158  if (isHollow) {
159  if (!Quartz::SetLineColor(ctx, GetLineColor())) {
160  Error("DrawBox", "Can not find color for index %d", int(GetLineColor()));
161  return;
162  }
163  } else {
164  if (!Quartz::SetFillAreaParameters(ctx, &patternIndex)) {
165  Error("DrawBox", "SetFillAreaParameters failed");
166  return;
167  }
168  }
169  Quartz::SetLineStyle(ctx, GetLineStyle());
170  Quartz::SetLineWidth(ctx, GetLineWidth());
171  Quartz::DrawBox(ctx, x1, y1, x2, y2, isHollow);
172  }
173 }
174 
175 
176 //______________________________________________________________________________
178 {
179  //Comment from TVirtualX:
180 
181  // Draw a filled area through all points.
182  // n : number of points
183  // xy : array of points
184 
185  //End of comment.
186  if (n < 3)
187  return;
188 
189  //Do some checks first.
190  if (fDirectDraw)//To avoid warnings from Quartz - no context at the moment!
191  return;
192 
193  NSObject<X11Drawable> * const drawable =
195 
196  if (!drawable)
197  return;
198 
199  CGContextRef ctx = drawable.fContext;
200 
201  //Convert points to bottom-left system:
202  ConvertPointsROOTToCocoa(n, xy, fConvertedPoints, drawable);
203 
204  const Quartz::CGStateGuard ctxGuard(ctx);
205  //AA flag is not a part of a state.
206  const Quartz::CGAAStateGuard aaCtxGuard(ctx, fUseFAAA);
207 
208  if (drawable.fScaleFactor > 1.) {
209  // The CTM will be restored by 'ctxGuard'.
210  CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
211  }
212 
213  const TColor * const fillColor = gROOT->GetColor(GetFillColor());
214  if (!fillColor) {
215  Error("DrawFillArea", "Could not find TColor for index %d", GetFillColor());
216  return;
217  }
218 
219  if (const TColorGradient * const gradient = dynamic_cast<const TColorGradient *>(fillColor)) {
220  Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
221  n, &fConvertedPoints[0], kFALSE);//kFALSE == don't draw a shadow.
222  } else {
223  unsigned patternIndex = 0;
224  if (!Quartz::SetFillAreaParameters(ctx, &patternIndex)) {
225  Error("DrawFillArea", "SetFillAreaParameters failed");
226  return;
227  }
228 
229  Quartz::DrawFillArea(ctx, n, &fConvertedPoints[0], kFALSE);//The last argument - do not draw shadows.
230  }
231 }
232 
233 
234 //______________________________________________________________________________
235 void TGQuartz::DrawCellArray(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/,
236  Int_t /*nx*/, Int_t /*ny*/, Int_t */*ic*/)
237 {
238  //Noop.
239 }
240 
241 
242 //______________________________________________________________________________
244 {
245  // Draw a line.
246  // x1,y1 : begin of line
247  // x2,y2 : end of line
248 
249  if (fDirectDraw) {
250  if (!fPimpl->GetDrawable(fSelectedDrawable).fIsPixmap) {
251  QuartzView * const view = (QuartzView *)fPimpl->GetWindow(fSelectedDrawable).fContentView;
252  if (!view) {
253  ::Warning("DrawLine", "Invalid view/window for XOR-mode");
254  return;
255  }
256 
257  [view.fQuartzWindow addCrosshairWindow];
258  fPimpl->fX11CommandBuffer.AddDrawLineXor(fSelectedDrawable, x1, y1, x2, y2);
259  }
260 
261  return;
262  }
263 
264  //Do some checks first:
265  assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawLine, bad drawable is selected");
266  NSObject<X11Drawable> * const drawable =
268  if (!drawable)
269  return;
270 
271  CGContextRef ctx = drawable.fContext;
272  const Quartz::CGStateGuard ctxGuard(ctx);
273  //AA flag is not a part of a state.
274  const Quartz::CGAAStateGuard aaCtxGuard(ctx, fUseAA);
275 
276  if (!Quartz::SetLineColor(ctx, GetLineColor())) {
277  Error("DrawLine", "Could not set line color for index %d", int(GetLineColor()));
278  return;
279  }
280 
281  Quartz::SetLineStyle(ctx, GetLineStyle());
282  Quartz::SetLineWidth(ctx, GetLineWidth());
283 
284  Quartz::DrawLine(ctx, x1, X11::LocalYROOTToCocoa(drawable, y1), x2,
285  X11::LocalYROOTToCocoa(drawable, y2));
286 }
287 
288 
289 //______________________________________________________________________________
291 {
292  //Comment from TVirtualX:
293  // Draw a line through all points.
294  // n : number of points
295  // xy : list of points
296  //End of comment.
297 
298  //Some checks first.
299  if (fDirectDraw)//To avoid warnings from Quartz - no context at the moment!
300  return;
301 
302  NSObject<X11Drawable> * const drawable =
304  if (!drawable)
305  return;
306 
307  CGContextRef ctx = drawable.fContext;
308  const Quartz::CGStateGuard ctxGuard(ctx);
309  //AA flag is not a part of a state.
310  const Quartz::CGAAStateGuard aaCtxGuard(ctx, fUseAA);
311 
312  if (!Quartz::SetLineColor(ctx, GetLineColor())) {
313  Error("DrawPolyLine", "Could not find TColor for index %d", GetLineColor());
314  return;
315  }
316 
317  Quartz::SetLineStyle(ctx, GetLineStyle());
318  Quartz::SetLineWidth(ctx, GetLineWidth());
319 
320  //Convert to bottom-left-corner system.
321  ConvertPointsROOTToCocoa(n, xy, fConvertedPoints, drawable);
322 
323  if (drawable.fScaleFactor > 1.)
324  CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
325 
327 
328  // CTM (current transformation matrix) is restored by 'ctxGuard's dtor.
329 }
330 
331 
332 //______________________________________________________________________________
334 {
335  //Comment from TVirtualX:
336  // Draw PolyMarker
337  // n : number of points
338  // xy : list of points
339  //End of comment.
340 
341  //Do some checks first.
342  if (fDirectDraw)//To avoid warnings from Quartz - no context at the moment!
343  return;
344 
345  NSObject<X11Drawable> * const drawable =
347  if (!drawable)
348  return;
349 
350  CGContextRef ctx = drawable.fContext;
351  const Quartz::CGStateGuard ctxGuard(ctx);
352  //AA flag is not a part of a state.
353  const Quartz::CGAAStateGuard aaCtxGuard(ctx, fUseAA);
354 
355  if (!Quartz::SetFillColor(ctx, GetMarkerColor())) {
356  Error("DrawPolyMarker", "Could not find TColor for index %d", GetMarkerColor());
357  return;
358  }
359 
360  Quartz::SetLineColor(ctx, GetMarkerColor());//Can not fail (for coverity).
361  Quartz::SetLineStyle(ctx, 1);
363 
364  ConvertPointsROOTToCocoa(n, xy, fConvertedPoints, drawable);
365 
366  if (drawable.fScaleFactor > 1.)
367  CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
368 
369  CGContextSetLineJoin(ctx, kCGLineJoinRound);
370  CGContextSetLineCap(ctx, kCGLineCapRound);
371 
372  Float_t MarkerSizeReduced = GetMarkerSize() - TMath::Floor(TAttMarker::GetMarkerLineWidth(GetMarkerStyle())/2.)/4.;
373  Quartz::DrawPolyMarker(ctx, n, &fConvertedPoints[0], MarkerSizeReduced * drawable.fScaleFactor, TAttMarker::GetMarkerStyleBase(GetMarkerStyle()));
374 
375  CGContextSetLineJoin(ctx, kCGLineJoinMiter);
376  CGContextSetLineCap(ctx, kCGLineCapButt);
377 }
378 
379 
380 //______________________________________________________________________________
381 void TGQuartz::DrawText(Int_t x, Int_t y, Float_t /*angle*/, Float_t /*mgn*/,
382  const char *text, ETextMode /*mode*/)
383 {
384  if (fDirectDraw)//To avoid warnings from Quartz - no context at the moment!
385  return;
386 
387  if (!text || !text[0])//Can this ever happen? TPad::PaintText does not check this.
388  return;
389 
390  if (GetTextSize()<1.5)//Do not draw anything, or CoreText will create some small (but not of size 0 font).
391  return;
392 
393  NSObject<X11Drawable> * const drawable =
395  if (!drawable)
396  return;
397 
398  CGContextRef ctx = drawable.fContext;
399  const Quartz::CGStateGuard ctxGuard(ctx);
400 
401  //Before any core text drawing operations, reset text matrix.
402  CGContextSetTextMatrix(ctx, CGAffineTransformIdentity);
403 
404  try {
405  if (CTFontRef currentFont = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
406  const unsigned fontIndex = GetTextFont() / 10;
407  if (fontIndex == 12 || fontIndex == 15) {//Greek and math symbols.
408  //This is a hack. Correct way is to extract glyphs from symbol.ttf,
409  //find correct mapping, place this glyphs. This requires manual layout though (?),
410  //and as usually, I have to many things to do, may be, one day I'll fix text rendering also.
411  //This hack work only on MacOSX 10.7.3, does not work on iOS and I'm not sure about future/previous
412  //versions of MacOSX.
413  typedef std::vector<UniChar>::size_type size_type;
414 
415  std::vector<UniChar> unichars(std::strlen(text));
416  for (size_type i = 0, len = unichars.size(); i < len; ++i)
417  unichars[i] = 0xF000 + (unsigned char)text[i];
418 
419  Quartz::TextLine ctLine(unichars, currentFont, GetTextColor());
420  ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y));
421  } else {
422  const Quartz::TextLine ctLine(text, currentFont, GetTextColor());
423  ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y));
424  }
425  }
426  } catch (const std::exception &e) {
427  Error("DrawText", "Exception from Quartz::TextLine: %s", e.what());
428  }
429 }
430 
431 //______________________________________________________________________________
432 void TGQuartz::DrawText(Int_t x, Int_t y, Float_t angle, Float_t /*mgn*/, const wchar_t *text, ETextMode mode)
433 {
434  if (!text || !text[0])
435  return;
436 
437  if (!TTF::IsInitialized()) {
438  Error("DrawText", "wchar_t string to draw, but TTF initialization failed");
439  return;
440  }
441 
442  if (!GetTextSize())//Do not draw anything, or CoreText will create some small (but not of size 0 font).
443  return;
444 
445  (void)x;
446  (void)y;
447  (void)angle;
448  (void)mode;
449 
451  TTF::SetRotationMatrix(angle);
454 
455  AlignTTFString();
456  RenderTTFString(x, y, mode);
457 }
458 
459 //______________________________________________________________________________
461 {
462  // Returns the size of the specified character string "mess".
463  //
464  // w - the text width
465  // h - the text height
466  // text - the string
467 
468  if (!text || !text[0]) {
469  w = 0;
470  h = 0;
471  return;
472  }
473 
474  if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
475  const unsigned fontIndex = GetTextFont() / 10;
476  if (fontIndex == 12 || fontIndex == 15) {//Greek and math symbols.
477  typedef std::vector<UniChar>::size_type size_type;
478 
479  std::vector<UniChar> unichars(std::strlen(text));
480  for (size_type i = 0, len = unichars.size(); i < len; ++i)
481  unichars[i] = 0xF000 + (unsigned char)text[i];
482 
483  fPimpl->fFontManager.GetTextBounds(w, h, unichars);
484  } else {
485  fPimpl->fFontManager.GetTextBounds(w, h, text);
486  }
487  }
488 }
489 
490 //______________________________________________________________________________
492 {
493  // Returns the ascent of the current font (in pixels).
494  // The ascent of a font is the distance from the baseline
495  // to the highest position characters extend to.
496  if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
497  return Int_t(fPimpl->fFontManager.GetAscent());
498 
499  return 0;
500 }
501 
502 //______________________________________________________________________________
504 {
505  // Returns the ascent of the current font (in pixels).
506  // The ascent of a font is the distance from the baseline
507  // to the highest position characters extend to.
508 
509  //In case of any problem we can always resort to the old version:
510  if (!text || !text[0])//How it's usually tested in ROOT
511  return GetFontAscent();
512 
513  if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
514  const unsigned fontIndex = GetTextFont() / 10;
515  if (fontIndex == 12 || fontIndex == 15) {//Greek and math symbols.
516  //That's an ugly hack :)
517  typedef std::vector<UniChar>::size_type size_type;
518 
519  std::vector<UniChar> unichars(std::strlen(text));
520  for (size_type i = 0, len = unichars.size(); i < len; ++i)
521  unichars[i] = 0xF000 + (unsigned char)text[i];
522 
523  return Int_t(fPimpl->fFontManager.GetAscent(unichars));
524  } else
525  return Int_t(fPimpl->fFontManager.GetAscent(text));
526  }
527 
528  return 0;
529 }
530 
531 //______________________________________________________________________________
533 {
534  // Returns the descent of the current font (in pixels.
535  // The descent is the distance from the base line
536  // to the lowest point characters extend to.
537  if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
538  return Int_t(fPimpl->fFontManager.GetDescent());
539 
540  return 0;
541 }
542 
543 //______________________________________________________________________________
545 {
546  // Returns the descent of the current font (in pixels.
547  // The descent is the distance from the base line
548  // to the lowest point characters extend to.
549 
550  //That's how it's tested in ROOT:
551  if (!text || !text[0])
552  return GetFontDescent();
553 
554  if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
555  const unsigned fontIndex = GetTextFont() / 10;
556  if (fontIndex == 12 || fontIndex == 15) {//Greek and math symbols.
557  //That's an ugly hack :)
558  typedef std::vector<UniChar>::size_type size_type;
559 
560  std::vector<UniChar> unichars(std::strlen(text));
561  for (size_type i = 0, len = unichars.size(); i < len; ++i)
562  unichars[i] = 0xF000 + (unsigned char)text[i];
563 
564  return Int_t(fPimpl->fFontManager.GetDescent(unichars));
565  } else
566  return Int_t(fPimpl->fFontManager.GetDescent(text));
567  }
568 
569  return 0;
570 }
571 
572 
573 //______________________________________________________________________________
575 {
576  // Returns the current font magnification factor
577  return 0;
578 }
579 
580 //______________________________________________________________________________
582 {
583  // Set color index "cindex" for drawing lines.
584  TAttLine::SetLineColor(cindex);
585 }
586 
587 
588 //______________________________________________________________________________
590 {
591  // Set line style.
592  TAttLine::SetLineStyle(lstyle);
593 }
594 
595 
596 //______________________________________________________________________________
598 {
599  // Set the line width.
600 
602 }
603 
604 
605 //______________________________________________________________________________
607 {
608  // Set color index "cindex" for fill areas.
609 
610  TAttFill::SetFillColor(cindex);
611 }
612 
613 
614 //______________________________________________________________________________
616 {
617  // Set fill area style.
619 }
620 
621 
622 //______________________________________________________________________________
624 {
625  // Set color index "cindex" for markers.
627 }
628 
629 
630 //______________________________________________________________________________
632 {
633  // Set marker size index.
634  //
635  // markersize - the marker scale factor
636  TAttMarker::SetMarkerSize(markersize);
637 }
638 
639 
640 //______________________________________________________________________________
642 {
643  // Set marker style.
644 
645  TAttMarker::SetMarkerStyle(markerstyle);
646 }
647 
648 
649 //______________________________________________________________________________
651 {
652  // Set the text alignment.
653  //
654  // talign = txalh horizontal text alignment
655  // talign = txalv vertical text alignment
656 
657  TAttText::SetTextAlign(talign);
658 }
659 
660 //______________________________________________________________________________
662 {
663  // Set the color index "cindex" for text.
664 
665  TAttText::SetTextColor(cindex);
666 }
667 
668 
669 //______________________________________________________________________________
671 {
672  // Set the current text font number.
673 
674  TAttText::SetTextFont(fontNumber);
675 
676  if (!TTF::IsInitialized()) {
677  Error("SetTextFont", "TTF is not initialized");
678  return;
679  }
680 
681  TTF::SetTextFont(fontNumber);
682 }
683 
684 //______________________________________________________________________________
685 Int_t TGQuartz::SetTextFont(char *fontName, ETextSetMode /*mode*/)
686 {
687  //This function is never used in gPad (in normal text rendering,
688  //so I'm not setting anything for CoreText).
689  if (!TTF::IsInitialized()) {
690  Error("SetTextFont", "TTF is not initialized");
691  return 0;
692  }
693 
694  return TTF::SetTextFont(fontName);
695 }
696 
697 //______________________________________________________________________________
699 {
700  // Set the current text size to "textsize"
701 
702  TAttText::SetTextSize(textsize);
703 
704  if (!TTF::IsInitialized()) {
705  Error("SetTextSize", "TTF is not initialized");
706  return;
707  }
708 
709  TTF::SetTextSize(textsize);
710 }
711 
712 
713 //______________________________________________________________________________
714 void TGQuartz::SetOpacity(Int_t /*percent*/)
715 {
716  // Set opacity of the current window. This image manipulation routine
717  // works by adding to a percent amount of neutral to each pixels RGB.
718  // Since it requires quite some additional color map entries is it
719  // only supported on displays with more than > 8 color planes (> 256
720  // colors).
721 }
722 
723 //TTF related part.
724 
725 //______________________________________________________________________________
727 {
728  //Comment from TGX11TTF:
729  // Compute alignment variables. The alignment is done on the horizontal string
730  // then the rotation is applied on the alignment variables.
731  // SetRotation and LayoutGlyphs should have been called before.
732  //End of comment.
733 
734  //This code is from TGX11TTF (with my fixes).
735  //It looks like align can not be both X and Y align?
736 
737  const EAlign align = EAlign(fTextAlign);
738 
739  // vertical alignment
740  if (align == kTLeft || align == kTCenter || align == kTRight) {
741  fAlign.y = TTF::GetAscent();
742  } else if (align == kMLeft || align == kMCenter || align == kMRight) {
743  fAlign.y = TTF::GetAscent() / 2;
744  } else {
745  fAlign.y = 0;
746  }
747 
748  // horizontal alignment
749  if (align == kTRight || align == kMRight || align == kBRight) {
750  fAlign.x = TTF::GetWidth();
751  } else if (align == kTCenter || align == kMCenter || align == kBCenter) {
752  fAlign.x = TTF::GetWidth() / 2;
753  } else {
754  fAlign.x = 0;
755  }
756 
757  FT_Vector_Transform(&fAlign, TTF::GetRotMatrix());
758  //This shift is from the original code.
759  fAlign.x = fAlign.x >> 6;
760  fAlign.y = fAlign.y >> 6;
761 }
762 
763 //______________________________________________________________________________
765 {
766  //Comment from TGX11TTF:
767  // Test if there is really something to render.
768  //End of comment.
769 
770  //This code is from TGX11TTF (with modifications).
771 
772  //Comment from TGX11TTF:
773  // If w or h is 0, very likely the string is only blank characters
774  if (!w || !h)
775  return kFALSE;
776 
777  UInt_t width = 0;
778  UInt_t height = 0;
779  Int_t xy = 0;
780 
781  GetWindowSize(GetCurrentWindow(), xy, xy, width, height);
782 
783  // If string falls outside window, there is probably no need to draw it.
784  if (x + int(w) <= 0 || x >= int(width))
785  return kFALSE;
786 
787  if (y + int(h) <= 0 || y >= int(height))
788  return kFALSE;
789 
790  return kTRUE;
791 }
792 
793 //______________________________________________________________________________
795 {
796  //Comment from TGX11TTF:
797  // Perform the string rendering in the pad.
798  // LayoutGlyphs should have been called before.
799  //End of comment.
800 
801  //This code is a modified (for Quartz) version of TG11TTF::RenderString.
802 
804  if (!drawable)
805  return;
806 
807  QuartzPixmap *dstPixmap = nil;
808  if ([drawable isKindOfClass : [QuartzPixmap class]])
809  dstPixmap = (QuartzPixmap *)drawable;
810  else if ([drawable isKindOfClass : [QuartzView class]] || [drawable isKindOfClass : [QuartzWindow class]])
811  dstPixmap = ((NSObject<X11Window> *)drawable).fBackBuffer;
812 
813  if (!dstPixmap) {
814  //I can not read pixels from a window (I can, but this is too slow and unreliable).
815  Error("DrawText", "fSelectedDrawable is neither QuartzPixmap nor a double buffered window");
816  return;
817  }
818 
819  //Comment from TGX11TTF:
820  // compute the size and position of the XImage that will contain the text
821  const Int_t xOff = TTF::GetBox().xMin < 0 ? -TTF::GetBox().xMin : 0;
822  const Int_t yOff = TTF::GetBox().yMin < 0 ? -TTF::GetBox().yMin : 0;
823 
824  const Int_t w = TTF::GetBox().xMax + xOff;
825  const Int_t h = TTF::GetBox().yMax + yOff;
826 
827  const Int_t x1 = x - xOff - fAlign.x;
828  const Int_t y1 = y + yOff + fAlign.y - h;
829 
830  if (!IsTTFStringVisible(x1, y1, w, h))
831  return;
832 
833  //By default, all pixels are set to 0 (all components, that's what code in TGX11TTF also does here).
834  Util::NSScopeGuard<QuartzPixmap> pixmap([[QuartzPixmap alloc] initWithW : w H : h scaleFactor : 1.f]);
835  if (!pixmap.Get()) {
836  Error("DrawText", "pixmap creation failed");
837  return;
838  }
839 
840  const unsigned char defaultBackgroundPixel[] = {255, 255, 255, 255};
841  Util::ScopedArray<unsigned char> arrayGuard;
842  if (mode == kClear) {
843  //For this mode, TGX11TTF does some work to: a) preserve pixels under symbols
844  //b) calculate (interpolate) pixel for glyphs.
845 
846  X11::Rectangle bbox(x1, y1, w, h);
847  //We already check IsVisible, so, in principle, bbox at least has intersection with
848  //the current selected drawable.
849  if (X11::AdjustCropArea(dstPixmap, bbox))
850  arrayGuard.Reset([dstPixmap readColorBits : bbox]);
851 
852  if (!arrayGuard.Get()) {
853  Error("DrawText", "problem with reading background pixels");
854  return;
855  }
856 
857  // This is copy & paste from TGX11TTF:
858  const Int_t xo = x1 < 0 ? -x1 : 0;
859  const Int_t yo = y1 < 0 ? -y1 : 0;
860 
861  for (int yp = 0; yp < int(bbox.fHeight) && yo + yp < h; ++yp) {
862  const unsigned char *srcBase = arrayGuard.Get() + bbox.fWidth * yp * 4;
863  for (int xp = 0; xp < int(bbox.fWidth) && xo + xp < w; ++xp) {
864  const unsigned char * const pixel = srcBase + xp * 4;
865  [pixmap.Get() putPixel : pixel X : xo + xp Y : yo + yp];
866  }
867  }
868  } else {
869  //Find background color and set for all pixels.
870  [pixmap.Get() addPixel : defaultBackgroundPixel];
871  }
872 
873  CGContextRef ctx = drawable.fContext;
874  const Quartz::CGStateGuard ctxGuard(ctx);
875 
876  CGContextSetRGBStrokeColor(ctx, 0., 0., 1., 1.);
877  // paint the glyphs in the pixmap.
878  TTF::TTGlyph *glyph = TTF::GetGlyphs();
879  for (int n = 0; n < TTF::GetNumGlyphs(); ++n, ++glyph) {
880  if (FT_Glyph_To_Bitmap(&glyph->fImage, TTF::GetSmoothing() ? ft_render_mode_normal : ft_render_mode_mono, 0, 1 ))
881  continue;
882 
883  FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph->fImage;
884  FT_Bitmap *source = &bitmap->bitmap;
885  const Int_t bx = bitmap->left + xOff;
886  const Int_t by = h - bitmap->top - yOff;
887 
888  DrawFTGlyphIntoPixmap(pixmap.Get(), source, TGCocoa::GetPixel(GetTextColor()),
889  mode == kClear ? ULong_t(-1) : 0xffffff, bx, by);
890  }
891 
892  const X11::Rectangle copyArea(0, 0, w, h);
893  const X11::Point dstPoint(x1, y1);
894  [dstPixmap copy : pixmap.Get() area : copyArea withMask : nil clipOrigin : X11::Point() toPoint : dstPoint];
895 }
896 
897 //______________________________________________________________________________
898 void TGQuartz::DrawFTGlyphIntoPixmap(void *pHack, FT_Bitmap *source, ULong_t fore, ULong_t back, Int_t bx, Int_t by)
899 {
900  //This function is a "remake" of TGX11FFT::DrawImage.
901 
902  //I'm using this code to reproduce the same text as generated by TGX11TTF.
903  //It's quite sloppy, as in original version. I tried to make it not so ugly and
904  //more or less readable.
905 
906  QuartzPixmap *pixmap = (QuartzPixmap *)pHack;
907  assert(pixmap != nil && "DrawFTGlyphIntoPixmap, pixmap parameter is nil");
908  assert(source != 0 && "DrawFTGlyphIntoPixmap, source parameter is null");
909 
910  if (TTF::GetSmoothing()) {
911  static ColorStruct_t col[5];
912  // background kClear, i.e. transparent, we take as background color
913  // the average of the rgb values of all pixels covered by this character
914  if (back == ULong_t(-1) && source->width) {
915  const int maxDots = 50000;
916  int dots = Int_t(source->width * source->rows);
917  if (dots > maxDots)
918  dots = maxDots;
919 
920  //In original code, they first have to extract
921  //pixels and call XQueryColors.
922  //I have only one loop here.
923  ULong_t r = 0, g = 0, b = 0;
924  for (int y = 0, dotCnt = 0; y < int(source->rows); y++) {
925  for (int x = 0; x < int(source->width); x++) {
926  if (x + bx < int(pixmap.fWidth) && y + by < int(pixmap.fHeight)) {
927  const unsigned char * const pixels = pixmap.fData + (y + by) * pixmap.fWidth * 4 + (x + bx) * 4;
928  r += UShort_t(pixels[0] / 255. * 0xffff);
929  g += UShort_t(pixels[1] / 255. * 0xffff);
930  b += UShort_t(pixels[2] / 255. * 0xffff);
931  }
932 
933  if (++dotCnt >= maxDots)
934  break;
935  }
936  }
937 
938  if (dots) {
939  r /= dots;
940  g /= dots;
941  b /= dots;
942  }
943 
944  if (col[0].fRed == r && col[0].fGreen == g && col[0].fBlue == b) {
945  col[0].fPixel = back;
946  } else {
947  col[0].fPixel = ~back;//???
948  col[0].fRed = (UShort_t) r;
949  col[0].fGreen = (UShort_t) g;
950  col[0].fBlue = (UShort_t) b;
951  }
952  }
953 
954  // if fore or background have changed from previous character
955  // recalculate the 3 smoothing colors (interpolation between fore-
956  // and background colors)
957  if (fore != col[4].fPixel || back != col[0].fPixel) {
958  col[4].fPixel = fore;
959  TGCocoa::QueryColor(kNone, col[4]);//calculate fRed/fGreen/fBlue triple from fPixel.
960  if (back != (ULong_t)-1) {
961  col[0].fPixel = back;
962  TGCocoa::QueryColor(kNone, col[0]);
963  }
964 
965  // interpolate between fore and background colors
966  for (int x = 3; x > 0; --x) {
967  col[x].fRed = (col[4].fRed * x + col[0].fRed * (4 - x)) / 4;
968  col[x].fGreen = (col[4].fGreen * x + col[0].fGreen * (4 - x)) / 4;
969  col[x].fBlue = (col[4].fBlue * x + col[0].fBlue * (4 - x)) / 4;
970  TGCocoa::AllocColor(kNone, col[x]);//Calculate fPixel from fRed/fGreen/fBlue triplet.
971  }
972  }
973 
974  // put smoothed character, character pixmap values are an index
975  // into the 5 colors used for aliasing (4 = foreground, 0 = background)
976  const unsigned char *s = source->buffer;
977  for (int y = 0; y < (int) source->rows; ++y) {
978  for (int x = 0; x < (int) source->width; ++x) {
979  unsigned char d = *s++ & 0xff;//???
980  d = ((d + 10) * 5) / 256;//???
981  if (d > 4)
982  d = 4;
983  if (d && x < (int) source->width) {
984  const UChar_t pixel[] = {UChar_t(double(col[d].fRed) / 0xffff * 255),
985  UChar_t(double(col[d].fGreen) / 0xffff * 255),
986  UChar_t(double(col[d].fBlue) / 0xffff * 255), 255};
987  [pixmap putPixel : pixel X : bx + x Y : by + y];
988  }
989  }
990  }
991  } else {
992  // no smoothing, just put character using foreground color
993  unsigned char rgba[4] = {};
994  rgba[3] = 255;
995  X11::PixelToRGB(fore, rgba);
996  unsigned char d = 0;
997 
998  const unsigned char *row = source->buffer;
999  for (int y = 0; y < int(source->rows); ++y) {
1000  int n = 0;
1001  const unsigned char *s = row;
1002  for (int x = 0; x < int(source->width); ++x) {
1003  if (!n)
1004  d = *s++;
1005 
1006  if (TESTBIT(d,7 - n))
1007  [pixmap putPixel : rgba X : bx + x Y : by + y];
1008 
1009  if (++n == int(kBitsPerByte))
1010  n = 0;
1011  }
1012 
1013  row += source->pitch;
1014  }
1015  }
1016 }
1017 
1018 //Aux. functions.
1019 
1020 //______________________________________________________________________________
1022 {
1023  if (gEnv) {
1024  const TString value(TString(gEnv->GetValue("Cocoa.EnableAntiAliasing", "auto")).Strip());
1025  if (value == "auto") {
1026  [[NSScreen mainScreen] backingScaleFactor] > 1. ? fUseAA = true : fUseAA = false;
1027  } else if (value == "no")
1028  fUseAA = false;
1029  else {
1030  assert(value == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1031  fUseAA = true;
1032  }
1033  const TString valuefa(TString(gEnv->GetValue("Cocoa.EnableFillAreaAntiAliasing", "auto")).Strip());
1034  if (valuefa == "auto") {
1035  [[NSScreen mainScreen] backingScaleFactor] > 1. ? fUseFAAA = true : fUseFAAA = false;
1036  } else if (valuefa == "no")
1037  fUseFAAA = false;
1038  else {
1039  assert(valuefa == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1040  fUseFAAA = true;
1041  }
1042  }
1043 }
1044 
1045 //______________________________________________________________________________
1046 void *TGQuartz::GetSelectedDrawableChecked(const char *calledFrom) const
1047 {
1048  assert(calledFrom != 0 && "GetSelectedDrawableChecked, calledFrom parameter is null");
1049  assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "GetSelectedDrawableChecked, bad drawable is selected");
1050 
1051  NSObject<X11Drawable> *drawable = fPimpl->GetDrawable(fSelectedDrawable);
1052  if (!drawable.fIsPixmap) {
1053  //TPad/TCanvas ALWAYS draw only into a pixmap.
1054  if ([drawable isKindOfClass : [QuartzView class]]) {
1055  QuartzView *view = (QuartzView *)drawable;
1056  if (!view.fBackBuffer) {
1057  Error(calledFrom, "Selected window is not double buffered");
1058  return 0;
1059  }
1060 
1061  drawable = view.fBackBuffer;
1062  } else {
1063  Error(calledFrom, "Selected drawable is neither a pixmap, nor a double buffered window");
1064  return 0;
1065  }
1066  }
1067 
1068  if (!drawable.fContext) {
1069  Error(calledFrom, "Context is null");
1070  return 0;
1071  }
1072 
1073  return drawable;
1074 }
TGQuartz::fAlign
FT_Vector fAlign
Definition: TGQuartz.h:33
TGQuartz::SetTextFont
virtual void SetTextFont(Font_t fontnumber)
Sets the current text font number.
Definition: TGQuartz.mm:670
ColorStruct_t::fBlue
UShort_t fBlue
Definition: GuiTypes.h:313
QuartzPixmap::fData
std::vector< unsigned char > fData
Definition: QuartzPixmap.h:46
SetMarkerStyle
m SetMarkerStyle(20)
n
const Int_t n
Definition: legend1.C:16
TGQuartz::kMLeft
@ kMLeft
Definition: TGQuartz.h:30
TGQuartz::kMRight
@ kMRight
Definition: TGQuartz.h:31
TTF::GetWidth
static Int_t GetWidth()
Definition: TTF.cxx:615
QuartzFillArea.h
TTF::TTGlyph
Definition: TTF.h:65
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
e
#define e(i)
Definition: RSha256.hxx:121
Style_t
short Style_t
Definition: RtypesCore.h:80
SetMarkerColor
m SetMarkerColor(kBlue)
ColorStruct_t::fPixel
ULong_t fPixel
Definition: GuiTypes.h:310
TGQuartz::DrawText
virtual void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode)
Draws a text string using current font.
Definition: TGQuartz.mm:381
TGCocoa::fDirectDraw
bool fDirectDraw
Definition: TGCocoa.h:448
H
#define H(x, y, z)
TGQuartz::IsTTFStringVisible
Bool_t IsTTFStringVisible(Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition: TGQuartz.mm:764
X11Drawable.h
QuartzText.h
TTF::LayoutGlyphs
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition: TTF.cxx:181
f
#define f(i)
Definition: RSha256.hxx:122
TVirtualX::kHollow
@ kHollow
Definition: TVirtualX.h:50
CocoaUtils.h
TTF::Init
static void Init()
Initialise the TrueType fonts interface.
Definition: TTF.cxx:65
ROOT::Quartz::CGAAStateGuard
Definition: QuartzUtils.h:50
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TTF::TTGlyph::fImage
FT_Glyph fImage
glyph image
Definition: TTF.h:69
QuartzView::fBackBuffer
QuartzPixmap * fBackBuffer
Definition: QuartzWindow.h:207
TString::Strip
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1106
TGQuartz::DrawBox
virtual void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode)
Draws a box between [x1,y1] and [x2,y2] according to the "mode".
Definition: TGQuartz.mm:119
QuartzWindow.h
UShort_t
unsigned short UShort_t
Definition: RtypesCore.h:40
gEnv
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
ColorStruct_t
Definition: GuiTypes.h:309
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
QuartzPixmap::fHeight
unsigned fHeight
Definition: QuartzPixmap.h:44
TTF::SetSmoothing
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition: TTF.cxx:365
TAttMarker::GetMarkerLineWidth
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
Definition: TAttMarker.cxx:297
ROOT::Quartz::TextLine::DrawLine
void DrawLine(CGContextRef ctx) const
Definition: QuartzText.mm:279
TGQuartz::SetAA
void SetAA()
Definition: TGQuartz.mm:1021
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TGQuartz::kNone
@ kNone
Definition: TGQuartz.h:30
SetFillStyle
a SetFillStyle(0)
TAttText::fTextAlign
Short_t fTextAlign
Text alignment.
Definition: TAttText.h:29
TGCocoa::GetPixel
virtual ULong_t GetPixel(Color_t cindex)
Returns pixel value associated to specified ROOT color number "cindex".
Definition: TGCocoa.mm:2914
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TTF::SetTextSize
static void SetTextSize(Float_t textsize)
Set current text size.
Definition: TTF.cxx:562
TGQuartz::EAlign
EAlign
Definition: TGQuartz.h:30
QuartzPixmap::fWidth
unsigned fWidth
Definition: QuartzPixmap.h:43
TVirtualX::ETextSetMode
ETextSetMode
Definition: TVirtualX.h:52
QuartzUtils.h
TGQuartz::fUseAA
bool fUseAA
Definition: TGQuartz.h:93
Float_t
float Float_t
Definition: RtypesCore.h:57
TColorGradient.h
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TStyle.h
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
Int_t
int Int_t
Definition: RtypesCore.h:45
TTF::SetTextFont
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition: TTF.cxx:491
Font_t
short Font_t
Definition: RtypesCore.h:79
TGQuartz::SetMarkerColor
virtual void SetMarkerColor(Color_t cindex)
Sets color index "cindex" for markers.
Definition: TGQuartz.mm:623
TGQuartz::AlignTTFString
void AlignTTFString()
Definition: TGQuartz.mm:726
x
Double_t x[n]
Definition: legend1.C:17
TGCocoa::GetWindowSize
virtual void GetWindowSize(Drawable_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Returns the location and the size of window "id".
Definition: TGCocoa.mm:1385
TGQuartz::GetTextMagnitude
virtual Float_t GetTextMagnitude()
Returns the current font magnification factor.
Definition: TGQuartz.mm:574
TEnv::GetValue
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:492
TColor.h
TGQuartz::DrawLine
virtual void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Draws a line.
Definition: TGQuartz.mm:243
ROOT::Quartz::DrawFillArea
void DrawFillArea(CGContextRef ctx, Int_t n, TPoint *xy, Bool_t drawShadow)
Definition: QuartzFillArea.mm:455
TGQuartz::kTLeft
@ kTLeft
Definition: TGQuartz.h:30
TGQuartz::DrawCellArray
virtual void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, Int_t *ic)
Draws a cell array.
Definition: TGQuartz.mm:235
TEnv.h
TPoint::fY
SCoord_t fY
Definition: TPoint.h:42
TTF::GetRotMatrix
static FT_Matrix * GetRotMatrix()
Definition: TTF.cxx:636
TString
Definition: TString.h:136
TESTBIT
#define TESTBIT(n, i)
Definition: Rtypes.h:88
Color_t
short Color_t
Definition: RtypesCore.h:83
TTF::GetSmoothing
static Bool_t GetSmoothing()
Definition: TTF.cxx:601
TGQuartz::kBRight
@ kBRight
Definition: TGQuartz.h:31
text
TText * text
Definition: entrylist_figure1.C:10
b
#define b(i)
Definition: RSha256.hxx:118
TString.h
QuartzMarker.h
bool
ROOT::MacOSX::Util
Definition: CocoaUtils.h:34
ROOT::Quartz::DrawPolygonWithGradientFill
void DrawPolygonWithGradientFill(CGContextRef ctx, const TColorGradient *extendedColor, const CGSize &sizeOfDrawable, Int_t nPoints, const TPoint *xy, Bool_t drawShadow)
Definition: QuartzFillArea.mm:491
TColorGradient
Definition: TColorGradient.h:35
TGQuartz::SetMarkerStyle
virtual void SetMarkerStyle(Style_t markerstyle)
Sets marker style.
Definition: TGQuartz.mm:641
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
SCoord_t
short SCoord_t
Definition: RtypesCore.h:84
xy
XPoint xy[kMAXMK]
Definition: TGX11.cxx:123
TGCocoa::QueryColor
virtual void QueryColor(Colormap_t cmap, ColorStruct_t &color)
Returns the current RGB value for the pixel in the "color" structure.
Definition: TGCocoa.mm:2899
TROOT.h
style
TCanvas * style()
Definition: style.C:1
TGQuartz
Definition: TGQuartz.h:28
TGQuartz::fConvertedPoints
std::vector< TPoint > fConvertedPoints
Definition: TGQuartz.h:85
TGQuartz::GetFontDescent
virtual Int_t GetFontDescent() const
Returns the descent of the current font (in pixels.
Definition: TGQuartz.mm:532
ROOT::Quartz::CGStateGuard
Definition: QuartzUtils.h:35
kScale
const Float_t kScale
Definition: TGQuartz.mm:48
TGQuartz::SetTextSize
virtual void SetTextSize(Float_t textsize)
Sets the current text size to "textsize".
Definition: TGQuartz.mm:698
SetLineWidth
f1 SetLineWidth(4)
SetFillColor
h1 SetFillColor(kGreen)
TColor
Definition: TColor.h:19
h
#define h(i)
Definition: RSha256.hxx:124
TGCocoa
Definition: TGCocoa.h:58
QuartzPixmap
Definition: QuartzPixmap.h:31
TGQuartz::GetFontAscent
virtual Int_t GetFontAscent() const
Returns the ascent of the current font (in pixels).
Definition: TGQuartz.mm:491
SetMarkerSize
gr SetMarkerSize(1.3)
TGCocoa::GetCurrentWindow
virtual Window_t GetCurrentWindow() const
pointer to the current internal window used in canvas graphics
Definition: TGCocoa.mm:808
TMath::Floor
Double_t Floor(Double_t x)
Definition: TMath.h:692
TGCocoa::fPimpl
std::unique_ptr< ROOT::MacOSX::Details::CocoaPrivate > fPimpl
Definition: TGCocoa.h:444
Width_t
short Width_t
Definition: RtypesCore.h:82
QuartzView
Definition: QuartzWindow.h:183
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
ColorStruct_t::fGreen
UShort_t fGreen
Definition: GuiTypes.h:312
ColorStruct_t::fRed
UShort_t fRed
Definition: GuiTypes.h:311
SetTextColor
pt SetTextColor(4)
TGQuartz::SetTextAlign
virtual void SetTextAlign(Short_t talign=11)
Sets the text alignment.
Definition: TGQuartz.mm:650
ROOT::Quartz::SetFillAreaParameters
Bool_t SetFillAreaParameters(CGContextRef ctx, unsigned *patternIndex)
Definition: QuartzFillArea.mm:403
ROOT::MacOSX::X11::LocalYROOTToCocoa
int LocalYROOTToCocoa(NSView< X11Window > *parentView, CGFloat yROOT)
Definition: QuartzWindow.mm:244
TGQuartz::DrawPolyMarker
virtual void DrawPolyMarker(Int_t n, TPoint *xy)
Draws "n" markers with the current attributes at position [x,y].
Definition: TGQuartz.mm:333
ROOT::Quartz::DrawPolyMarker
void DrawPolyMarker(CGContextRef ctx, const std::vector< TPoint > &marker, Size_t markerSize, Style_t markerStyle)
Definition: QuartzMarker.mm:1036
DrawLine
lv DrawLine(0.33, 0.0, 0.33, 1.0)
ROOT::MacOSX::X11::Rectangle
Definition: CocoaGuiTypes.h:20
QuartzView::fQuartzWindow
QuartzWindow * fQuartzWindow
Definition: QuartzWindow.h:269
TGQuartz::TGQuartz
TGQuartz()
Definition: TGQuartz.mm:78
TVirtualX::EBoxMode
EBoxMode
Definition: TVirtualX.h:50
y
Double_t y[n]
Definition: legend1.C:17
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
Short_t
short Short_t
Definition: RtypesCore.h:39
TGQuartz::SetMarkerSize
virtual void SetMarkerSize(Float_t markersize)
Sets marker size index.
Definition: TGQuartz.mm:631
TTF::GetAscent
static Int_t GetAscent()
Definition: TTF.cxx:622
TObject::Warning
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:876
ROOT::Quartz::DrawBox
void DrawBox(CGContextRef ctx, Int_t x1, Int_t y1, Int_t x2, Int_t y2, bool hollow)
Definition: QuartzFillArea.mm:439
void
typedef void((*Func_t)())
TPoint::fX
SCoord_t fX
Definition: TPoint.h:41
TGQuartz::SetLineWidth
virtual void SetLineWidth(Width_t width)
Sets the line width.
Definition: TGQuartz.mm:597
TGQuartz::fUseFAAA
bool fUseFAAA
Definition: TGQuartz.h:94
unsigned int
TTF::GetGlyphs
static TTGlyph * GetGlyphs()
Definition: TTF.cxx:650
TGQuartz.h
TAttMarker::GetMarkerStyleBase
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
Definition: TAttMarker.cxx:246
ROOT::Quartz::TextLine
Definition: QuartzText.h:49
TGQuartz::SetLineColor
virtual void SetLineColor(Color_t cindex)
Sets color index "cindex" for drawing lines.
Definition: TGQuartz.mm:581
TGQuartz::RenderTTFString
void RenderTTFString(Int_t x, Int_t y, ETextMode mode)
Definition: TGQuartz.mm:794
ROOT::Quartz::DrawPolyLine
void DrawPolyLine(CGContextRef ctx, Int_t n, TPoint *xy)
Definition: QuartzLine.mm:147
TPoint
Definition: TPoint.h:31
SetTextAlign
th1 SetTextAlign(11)
TGQuartz::kTRight
@ kTRight
Definition: TGQuartz.h:30
TGQuartz::SetOpacity
virtual void SetOpacity(Int_t percent)
Sets opacity of the current window.
Definition: TGQuartz.mm:714
QuartzLine.h
ROOT::Quartz
Definition: QuartzFillArea.h:33
ROOT::MacOSX::X11::AdjustCropArea
bool AdjustCropArea(const Rectangle &srcRect, Rectangle &cropArea)
Definition: QuartzPixmap.mm:862
TGQuartz::DrawFTGlyphIntoPixmap
void DrawFTGlyphIntoPixmap(void *pixmap, FT_Bitmap *source, ULong_t fore, ULong_t back, Int_t bx, Int_t by)
Definition: TGQuartz.mm:898
TGQuartz::GetSelectedDrawableChecked
void * GetSelectedDrawableChecked(const char *calledFrom) const
Definition: TGQuartz.mm:1046
TGCocoa::AllocColor
virtual Bool_t AllocColor(Colormap_t cmap, ColorStruct_t &color)
Allocates a read-only colormap entry corresponding to the closest RGB value supported by the hardware...
Definition: TGCocoa.mm:2889
TGQuartz::kBCenter
@ kBCenter
Definition: TGQuartz.h:31
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
TGQuartz::SetLineStyle
virtual void SetLineStyle(Style_t linestyle)
Sets the line style.
Definition: TGQuartz.mm:589
name
char name[80]
Definition: TGX11.cxx:110
NSObject
TTF::IsInitialized
static Bool_t IsInitialized()
Definition: TTF.cxx:608
d
#define d(i)
Definition: RSha256.hxx:120
ROOT::MacOSX::X11::PixelToRGB
void PixelToRGB(Pixel_t pixelColor, CGFloat *rgb)
Definition: X11Colors.mm:938
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
TTF::GetNumGlyphs
static Int_t GetNumGlyphs()
Definition: TTF.cxx:629
kBitsPerByte
const ULong_t kBitsPerByte
Definition: RtypesCore.h:114
TTF::PrepareString
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition: TTF.cxx:250
TTF::SetRotationMatrix
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition: TTF.cxx:342
SetLineColor
lv SetLineColor(kBlue)
TPoint.h
SetTextFont
pt SetTextFont(42)
TGQuartz::kMCenter
@ kMCenter
Definition: TGQuartz.h:31
TGQuartz::SetTextColor
virtual void SetTextColor(Color_t cindex)
Sets the color index "cindex" for text.
Definition: TGQuartz.mm:661
TTF::GetBox
static const FT_BBox & GetBox()
Definition: TTF.cxx:643
QuartzPixmap.h
ROOT::MacOSX::X11::Point
Definition: CocoaGuiTypes.h:12
SetTextSize
th1 SetTextSize(0.12)
TGQuartz::GetTextExtent
virtual void GetTextExtent(UInt_t &w, UInt_t &h, char *text)
Returns the size of the specified character string "mess".
Definition: TGQuartz.mm:460
TGQuartz::DrawFillArea
virtual void DrawFillArea(Int_t n, TPoint *xy)
Fills area described by the polygon.
Definition: TGQuartz.mm:177
TGQuartz::kTCenter
@ kTCenter
Definition: TGQuartz.h:30
TGQuartz::SetFillStyle
virtual void SetFillStyle(Style_t style)
Sets fill area style.
Definition: TGQuartz.mm:615
TVirtualX::ETextMode
ETextMode
Definition: TVirtualX.h:51
TMath.h
TGCocoa::fSelectedDrawable
Drawable_t fSelectedDrawable
Definition: TGCocoa.h:442
TGQuartz::DrawPolyLine
virtual void DrawPolyLine(Int_t n, TPoint *xy)
Draws a line through all points in the list.
Definition: TGQuartz.mm:290
TGQuartz::SetFillColor
virtual void SetFillColor(Color_t cindex)
Sets color index "cindex" for fill areas.
Definition: TGQuartz.mm:606
gROOT
#define gROOT
Definition: TROOT.h:406
CocoaPrivate.h
int
ROOT::MacOSX::X11
Definition: CocoaGuiTypes.h:10
TVirtualX::kClear
@ kClear
Definition: TVirtualX.h:51
SetLineStyle
lv SetLineStyle(3)
QuartzWindow
Definition: QuartzWindow.h:56
g
#define g(i)
Definition: RSha256.hxx:123