Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
48const Float_t kScale = 0.93376068;
49
50
51namespace X11 = ROOT::MacOSX::X11;
52namespace Quartz = ROOT::Quartz;
53namespace Util = ROOT::MacOSX::Util;
54
55namespace {
56
57//______________________________________________________________________________
58void ConvertPointsROOTToCocoa(Int_t nPoints, const TPoint *xy, std::vector<TPoint> &dst,
59 NSObject<X11Drawable> *drawable)
60{
61 assert(nPoints != 0 && "ConvertPointsROOTToCocoa, nPoints parameter is 0");
62 assert(xy != 0 && "ConvertPointsROOTToCocoa, xy parameter is null");
63 assert(drawable != 0 && "ConvertPointsROOTToCocoa, drawable parameter is null");
64
65 const auto scaleFactor = drawable.fScaleFactor;
66
67 dst.resize(nPoints);
68 for (Int_t i = 0; i < nPoints; ++i) {
69 dst[i].fX = SCoord_t(xy[i].fX * scaleFactor);
70 dst[i].fY = SCoord_t(X11::LocalYROOTToCocoa(drawable, xy[i].fY) * scaleFactor);
71 }
72}
73
74}
75
76//______________________________________________________________________________
78 : fUseAA(true), fUseFAAA(false)
79{
80 //Default ctor.
81
82 TTF::Init();
83
84 //I do not know why TTF::Init returns void and I have to check IsInitialized() again.
85 if (!TTF::IsInitialized())
86 Error("TGQuartz", "TTF::Init() failed");
87
88 fAlign.x = 0;
89 fAlign.y = 0;
90
91 SetAA();
92}
93
94
95//______________________________________________________________________________
96TGQuartz::TGQuartz(const char *name, const char *title)
97 : TGCocoa(name, title),
98 fUseAA(true), fUseFAAA(false)
99{
100 //Constructor.
101
102 TTF::Init();
103
104 //I do not know why TTF::Init returns void and I have to check IsInitialized() again.
105 if (!TTF::IsInitialized())
106 Error("TGQuartz", "TTF::Init() failed");
107
108 fAlign.x = 0;
109 fAlign.y = 0;
110
111 SetAA();
112}
113
114//______________________________________________________________________________
116{
117 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
118 if (!drawable0)
119 return;
120
121 //Check some conditions first.
122 if ([drawable0 isDirectDraw]) {
123 if (!drawable0.fIsPixmap) {
124 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
125 if (!view) {
126 ::Warning("DrawBoxW", "Invalid view/window for XOR-mode");
127 return;
128 }
129
130 [view.fQuartzWindow addXorBox: view : x1 : y1 : x2 : y2];
131 }
132 return;
133 }
134
135 auto &attline = GetAttLine(wctxt);
136 auto &attfill = GetAttFill(wctxt);
137
138 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawBoxW");
139 if (!drawable)
140 return;
141
142 CGContextRef ctx = drawable.fContext;
144 //AA flag is not a part of a state.
146
147 //Go to low-left-corner system.
148 y1 = Int_t(X11::LocalYROOTToCocoa(drawable, y1));
149 y2 = Int_t(X11::LocalYROOTToCocoa(drawable, y2));
150
151 if (const TColorGradient * const gradient = dynamic_cast<TColorGradient *>(gROOT->GetColor(attfill.GetFillColor()))) {
152 //Draw a box with a gradient fill and a shadow.
153 //Ignore all fill styles and EBoxMode, use a gradient fill.
154 TPoint polygon[4];
155 polygon[0].fX = x1, polygon[0].fY = y1;
156 polygon[1].fX = x2, polygon[1].fY = y1;
157 polygon[2].fX = x2, polygon[2].fY = y2;
158 polygon[3].fX = x1, polygon[3].fY = y2;
159
160 Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
161 4, polygon, kFALSE); //kFALSE == don't draw a shadow.
162 } else {
163 const bool isHollow = mode == kHollow || attfill.GetFillStyle() / 1000 == 2;
164
165 //Note! Pattern index (and its address) MUST live
166 //long enough to be valid at the point of Quartz::DrawBox call!
167 unsigned patternIndex = 0;
168 if (isHollow) {
169 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
170 Error("DrawBoxW", "Can not find color for index %d", int(attline.GetLineColor()));
171 return;
172 }
173 } else {
175 Error("DrawBoxW", "SetFillAreaParameters failed");
176 return;
177 }
178 }
179 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
180 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
181 Quartz::DrawBox(ctx, x1, y1, x2, y2, isHollow);
182 }
183}
184
185
186//______________________________________________________________________________
191
192//______________________________________________________________________________
194{
195 //Comment from TVirtualX:
196
197 // Draw a filled area through all points.
198 // n : number of points
199 // xy : array of points
200
201 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
202 if (!drawable0)
203 return;
204
205 if (n < 3)
206 return;
207 // No fill area with direct drawing
208 if ([drawable0 isDirectDraw])
209 return;
210
211 auto &attfill = GetAttFill(wctxt);
212
213 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawFillAreaW");
214 if (!drawable)
215 return;
216
217 CGContextRef ctx = drawable.fContext;
218
219 //Convert points to bottom-left system:
221
223 //AA flag is not a part of a state.
225
226 if (drawable.fScaleFactor > 1.) {
227 // The CTM will be restored by 'ctxGuard'.
228 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
229 }
230
231 const TColor * const fillColor = gROOT->GetColor(attfill.GetFillColor());
232 if (!fillColor) {
233 Error("DrawFillAreaW", "Could not find TColor for index %d", attfill.GetFillColor());
234 return;
235 }
236
237 if (const TColorGradient * const gradient = dynamic_cast<const TColorGradient *>(fillColor)) {
238 Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
239 n, &fConvertedPoints[0], kFALSE);//kFALSE == don't draw a shadow.
240 } else {
241 unsigned patternIndex = 0;
243 Error("DrawFillAreaW", "SetFillAreaParameters failed");
244 return;
245 }
246
247 // kFALSE - do not draw shadows.
248 // last argument - fill style
250 }
251}
252
253
254//______________________________________________________________________________
259
260
261//______________________________________________________________________________
262void TGQuartz::DrawCellArray(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/,
263 Int_t /*nx*/, Int_t /*ny*/, Int_t */*ic*/)
264{
265 //Noop.
266}
267
268//______________________________________________________________________________
270{
271 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
272 if (!drawable0)
273 return;
274
275 if ([drawable0 isDirectDraw]) {
276 if (!drawable0.fIsPixmap) {
277 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
278 if (!view) {
279 ::Warning("DrawLineW", "Invalid view/window for XOR-mode");
280 return;
281 }
282
283 [view.fQuartzWindow addXorLine: view : x1 : y1 : x2 : y2];
284 }
285
286 return;
287 }
288
289 auto &attline = GetAttLine(wctxt);
290
291 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawLineW");
292 if (!drawable)
293 return;
294
295 CGContextRef ctx = drawable.fContext;
297 //AA flag is not a part of a state.
299
300 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
301 Error("DrawLineW", "Could not set line color for index %d", int(attline.GetLineColor()));
302 return;
303 }
304
305 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
306 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
307
309 X11::LocalYROOTToCocoa(drawable, y2));
310}
311
312//______________________________________________________________________________
314{
315 // Draw a line.
316 // x1,y1 : begin of line
317 // x2,y2 : end of line
318
319 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawLine, bad drawable is selected");
320
322}
323
324
325//______________________________________________________________________________
327{
328 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
329 if (!drawable0)
330 return;
331
332 //Some checks first.
333 if ([drawable0 isDirectDraw])
334 return;
335
336 auto &attline = GetAttLine(wctxt);
337
338 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawPolyLineW");
339 if (!drawable)
340 return;
341
342 CGContextRef ctx = drawable.fContext;
344 //AA flag is not a part of a state.
346
347 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
348 Error("DrawPolyLineW", "Could not find TColor for index %d", attline.GetLineColor());
349 return;
350 }
351
352 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
353 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
354
355 //Convert to bottom-left-corner system.
357
358 if (drawable.fScaleFactor > 1.)
359 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
360
362
363 // CTM (current transformation matrix) is restored by 'ctxGuard's dtor.
364}
365
366//______________________________________________________________________________
368{
369 //Comment from TVirtualX:
370 // Draw a line through all points.
371 // n : number of points
372 // xy : list of points
373 //End of comment.
374
375 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawPolyLine, bad drawable is selected");
376
378}
379
380//______________________________________________________________________________
382{
383 for(Int_t i = 0; i < 2*n; i += 2)
384 DrawPolyLineW(wctxt, 2, &xy[i]);
385}
386
387//______________________________________________________________________________
389{
390 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
391 if (!drawable0)
392 return;
393
394 //Do some checks first.
395 if ([drawable0 isDirectDraw])
396 return;
397
398 auto &attmark = GetAttMarker(wctxt);
399
400 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawPolyMarkerW");
401 if (!drawable)
402 return;
403
404 CGContextRef ctx = drawable.fContext;
406 //AA flag is not a part of a state.
408
409 if (!Quartz::SetFillColor(ctx, attmark.GetMarkerColor())) {
410 Error("DrawPolyMarker", "Could not find TColor for index %d", attmark.GetMarkerColor());
411 return;
412 }
413
414 Quartz::SetLineColor(ctx, attmark.GetMarkerColor());//Can not fail (for coverity).
415 Quartz::SetLineStyle(ctx, 1);
417
419
420 if (drawable.fScaleFactor > 1.)
421 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
422
424
425 // The fast pixel markers need to be treated separately
426 if (markerstyle == 1 || markerstyle == 6 || markerstyle == 7) {
429 } else {
432 }
433
435 Quartz::DrawPolyMarker(ctx, n, &fConvertedPoints[0], MarkerSizeReduced * drawable.fScaleFactor, markerstyle);
436
439}
440
441//______________________________________________________________________________
443{
444 //Comment from TVirtualX:
445 // Draw PolyMarker
446 // n : number of points
447 // xy : list of points
448 //End of comment.
449
451}
452
453
454//______________________________________________________________________________
455
456std::vector<UniChar> quartz_get_greek_unicars(const char *text)
457{
458 //This is a hack. Correct way is to extract glyphs from symbol.ttf,
459 //find correct mapping, place this glyphs. This requires manual layout though (?),
460 //and as usually, I have to many things to do, may be, one day I'll fix text rendering also.
461 //This hack work only on MacOSX 10.7.3, does not work on iOS and I'm not sure about future/previous
462 //versions of MacOSX.
463 std::vector<UniChar> unichars(std::strlen(text));
464 for (std::size_t i = 0; i < unichars.size(); ++i)
465 unichars[i] = 0xF000 + (unsigned char)text[i];
466 return unichars;
467}
468
469//______________________________________________________________________________
471 const char *text, ETextMode /* mode */)
472{
473 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
474 if (!drawable0)
475 return;
476
477 if ([drawable0 isDirectDraw])
478 return;
479
480 if (!text || !text[0])//Can this ever happen? TPad::PaintText does not check this.
481 return;
482
483 auto &atttext = GetAttText(wctxt);
484
485 if (atttext.GetTextSize() < 1.5)//Do not draw anything, or CoreText will create some small (but not of size 0 font).
486 return;
487
488 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawTextW");
489 if (!drawable)
490 return;
491
492 CGContextRef ctx = drawable.fContext;
494
495 //Before any core text drawing operations, reset text matrix.
497
498 try {
499 if (CTFontRef currentFont = fPimpl->fFontManager.SelectFont(atttext.GetTextFont(), kScale * atttext.GetTextSize())) {
500 const unsigned fontIndex = atttext.GetTextFont() / 10;
501 if (fontIndex == 12 || fontIndex == 15) {
502 //Greek and math symbols.
505 ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y), atttext);
506 } else {
507 const Quartz::TextLine ctLine(text, currentFont, atttext.GetTextColor());
508 ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y), atttext);
509 }
510 }
511 } catch (const std::exception &e) {
512 Error("DrawTextW", "Exception from Quartz::TextLine: %s", e.what());
513 }
514}
515
516//______________________________________________________________________________
522
523//______________________________________________________________________________
525 const wchar_t *text, ETextMode mode)
526{
527 if (!text || !text[0])
528 return;
529
530 if (!TTF::IsInitialized()) {
531 Error("DrawTextW", "wchar_t string to draw, but TTF initialization failed");
532 return;
533 }
534
539
542
544}
545
546//______________________________________________________________________________
552
553//______________________________________________________________________________
555{
556 // Returns the size of the specified character string "mess".
557 //
558 // w - the text width
559 // h - the text height
560 // text - the string
561
562 w = h = 0;
563
564 if (!text || !*text)
565 return;
566
567 auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize());
568 if (!fontref)
569 return;
570 const unsigned fontIndex = GetTextFont() / 10;
571 if (fontIndex == 12 || fontIndex == 15) {
572 //Greek and math symbols.
574 fPimpl->fFontManager.GetTextBounds(fontref, w, h, unichars);
575 } else {
576 fPimpl->fFontManager.GetTextBounds(fontref, w, h, text);
577 }
578}
579
580//______________________________________________________________________________
582{
583 if (!text || !*text) {
584 w = h = 0;
585 return kTRUE;
586 }
587
588 auto fontref = fPimpl->fFontManager.SelectFont(font, kScale * size);
589 if (!fontref)
590 return kFALSE;
591
592 const unsigned fontIndex = font / 10;
593 if (fontIndex == 12 || fontIndex == 15) {
594 //Greek and math symbols.
596 fPimpl->fFontManager.GetTextBounds(fontref, w, h, unichars);
597 } else {
598 fPimpl->fFontManager.GetTextBounds(fontref, w, h, text);
599 }
600
601 return kTRUE;
602}
603
604//______________________________________________________________________________
606{
607 // do not handle wchar, pad painter will switch to TTF
608 w = h = 0;
609 return kFALSE;
610}
611
612
613//______________________________________________________________________________
615{
616 // Returns the ascent of the current font (in pixels).
617 // The ascent of a font is the distance from the baseline
618 // to the highest position characters extend to.
619 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
620 return Int_t(fPimpl->fFontManager.GetAscent(fontref));
621
622 return 0;
623}
624
625//______________________________________________________________________________
627{
628 // Returns the ascent of the current font (in pixels).
629 // The ascent of a font is the distance from the baseline
630 // to the highest position characters extend to.
631
632 //In case of any problem we can always resort to the old version:
633 if (!text || !*text)
634 return GetFontAscent();
635
636 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
637 const unsigned fontIndex = GetTextFont() / 10;
638 if (fontIndex == 12 || fontIndex == 15) {
639 //Greek and math symbols.
641 return Int_t(fPimpl->fFontManager.GetAscent(fontref, unichars));
642 } else
643 return Int_t(fPimpl->fFontManager.GetAscent(fontref, text));
644 }
645
646 return 0;
647}
648
649//______________________________________________________________________________
651{
652 // Returns the descent of the current font (in pixels.
653 // The descent is the distance from the base line
654 // to the lowest point characters extend to.
655 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
656 return Int_t(fPimpl->fFontManager.GetDescent(fontref));
657
658 return 0;
659}
660
661//______________________________________________________________________________
663{
664 // Returns the descent of the current font (in pixels.
665 // The descent is the distance from the base line
666 // to the lowest point characters extend to.
667
668 //That's how it's tested in ROOT:
669 if (!text || !*text)
670 return GetFontDescent();
671
672 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
673 const unsigned fontIndex = GetTextFont() / 10;
674 if (fontIndex == 12 || fontIndex == 15) {
675 //Greek and math symbols.
677 return Int_t(fPimpl->fFontManager.GetDescent(fontref, unichars));
678 } else
679 return Int_t(fPimpl->fFontManager.GetDescent(fontref, text));
680 }
681
682 return 0;
683}
684
685//______________________________________________________________________________
687{
688 a = d = 0;
689
690 auto fontref = fPimpl->fFontManager.SelectFont(font, kScale * size);
691 if (!fontref)
692 return kFALSE;
693
694 const unsigned fontIndex = font / 10;
695 if (!text || !*text) {
696 a = fPimpl->fFontManager.GetAscent(fontref);
697 d = fPimpl->fFontManager.GetDescent(fontref);
698 } else if (fontIndex == 12 || fontIndex == 15) {
699 //Greek and math symbols.
701 a = fPimpl->fFontManager.GetAscent(fontref, unichars);
702 d = fPimpl->fFontManager.GetDescent(fontref, unichars);
703 } else {
704 a = fPimpl->fFontManager.GetAscent(fontref, text);
705 d = fPimpl->fFontManager.GetDescent(fontref, text);
706 }
707
708 return kTRUE;
709}
710
711
712//______________________________________________________________________________
714{
715 // Returns the current font magnification factor
716 return 0;
717}
718
719//______________________________________________________________________________
721{
722 // Set color index "cindex" for drawing lines.
724
726}
727
728
729//______________________________________________________________________________
731{
732 // Set line style.
734
736}
737
738
739//______________________________________________________________________________
741{
742 // Set the line width.
743
745
747}
748
749
750//______________________________________________________________________________
752{
753 // Set color index "cindex" for fill areas.
754
756
758}
759
760
761//______________________________________________________________________________
763{
764 // Set fill area style.
766
768}
769
770
771//______________________________________________________________________________
773{
774 // Set color index "cindex" for markers.
776
778}
779
780
781//______________________________________________________________________________
783{
784 // Set marker size index.
785 //
786 // markersize - the marker scale factor
788
790}
791
792
793//______________________________________________________________________________
795{
796 // Set marker style.
797
799
801}
802
803
804//______________________________________________________________________________
806{
807 // Set the text alignment.
808
810
812}
813
814//______________________________________________________________________________
816{
817 // Set the color index "cindex" for text.
818
820
822}
823
824
825//______________________________________________________________________________
827{
828 // Set the current text font number.
829
831
833}
834
835//______________________________________________________________________________
837{
838 //This function is never used in gPad (in normal text rendering,
839 //so I'm not setting anything for CoreText).
840 if (!TTF::IsInitialized()) {
841 Error("SetTextFont", "TTF is not initialized");
842 return 0;
843 }
844
846}
847
848//______________________________________________________________________________
850{
851 // Set the current text size to "textsize"
852
854
856}
857
858
859//______________________________________________________________________________
861{
862 // Set opacity of the current window. This image manipulation routine
863 // works by adding to a percent amount of neutral to each pixels RGB.
864 // Since it requires quite some additional color map entries is it
865 // only supported on displays with more than > 8 color planes (> 256
866 // colors).
867}
868
869//______________________________________________________________________________
870void TGQuartz::SetOpacityW(WinContext_t /* wctxt */, Int_t /* percent */)
871{
872}
873
874//______________________________________________________________________________
876{
877 att.Copy(GetAttFill(wctxt));
878
879 // TODO: remove this after transition done
880 TAttFill::SetFillColor(att.GetFillColor());
881 TAttFill::SetFillStyle(att.GetFillStyle());
882}
883
884//______________________________________________________________________________
886{
887 att.Copy(GetAttLine(wctxt));
888
889 // TODO: remove this after transition done
890 TAttLine::SetLineColor(att.GetLineColor());
891 TAttLine::SetLineStyle(att.GetLineStyle());
892 TAttLine::SetLineWidth(att.GetLineWidth());
893}
894
895//______________________________________________________________________________
897{
898 att.Copy(GetAttMarker(wctxt));
899
900 // TODO: remove this after transition done
901 TAttMarker::SetMarkerColor(att.GetMarkerColor());
902 TAttMarker::SetMarkerSize(att.GetMarkerSize());
903 TAttMarker::SetMarkerStyle(att.GetMarkerStyle());
904}
905
906//______________________________________________________________________________
908{
909 att.Copy(GetAttText(wctxt));
910
911 if (!TTF::IsInitialized()) {
912 Error("SetAttText", "TTF is not initialized");
913 return;
914 }
915
916 TTF::SetTextSize(att.GetTextSize());
917 TTF::SetTextFont(att.GetTextFont());
918
919 // TODO: remove this after transition done
920 TAttText::SetTextAlign(att.GetTextAlign());
921 TAttText::SetTextAngle(att.GetTextAngle());
922 TAttText::SetTextColor(att.GetTextColor());
923 TAttText::SetTextSize(att.GetTextSize());
924 TAttText::SetTextFont(att.GetTextFont());
925}
926
927//TTF related part.
928
929//______________________________________________________________________________
931{
932 //Comment from TGX11TTF:
933 // Compute alignment variables. The alignment is done on the horizontal string
934 // then the rotation is applied on the alignment variables.
935 // SetRotation and LayoutGlyphs should have been called before.
936 //End of comment.
937
938 //This code is from TGX11TTF (with my fixes).
939 //It looks like align can not be both X and Y align?
940
941 auto &atttext = GetAttText(wctxt);
942
943 Int_t txalh = atttext.GetTextAlign() / 10;
944 Int_t txalv = atttext.GetTextAlign() % 10;
945
946 // const EAlign align = EAlign(fTextAlign);
947 // vertical alignment
948 if (txalv == 3) // align == kTLeft || align == kTCenter || align == kTRight)
950 else if (txalv == 2) // if (align == kMLeft || align == kMCenter || align == kMRight) {
951 fAlign.y = TTF::GetAscent() / 2;
952 else
953 fAlign.y = 0;
954
955 // horizontal alignment
956 if (txalh == 3) // align == kTRight || align == kMRight || align == kBRight) {
957 fAlign.x = TTF::GetWidth();
958 else if (txalh == 2) // (align == kTCenter || align == kMCenter || align == kBCenter) {
959 fAlign.x = TTF::GetWidth() / 2;
960 else
961 fAlign.x = 0;
962
964 //This shift is from the original code.
965 fAlign.x = fAlign.x >> 6;
966 fAlign.y = fAlign.y >> 6;
967}
968
969//______________________________________________________________________________
971{
972 //Comment from TGX11TTF:
973 // Test if there is really something to render.
974 //End of comment.
975
976 //This code is from TGX11TTF (with modifications).
977
978 //Comment from TGX11TTF:
979 // If w or h is 0, very likely the string is only blank characters
980 if (!w || !h || !wctxt)
981 return kFALSE;
982
983 auto drawable = (NSObject<X11Drawable> * const) wctxt;
984
985 UInt_t width = 0;
986 UInt_t height = 0;
987 Int_t xy = 0;
988
989 GetWindowSize((Drawable_t) drawable.fID, xy, xy, width, height);
990
991 // If string falls outside window, there is probably no need to draw it.
992 if (x + int(w) <= 0 || x >= int(width))
993 return kFALSE;
994
995 if (y + int(h) <= 0 || y >= int(height))
996 return kFALSE;
997
998 return kTRUE;
999}
1000
1001//______________________________________________________________________________
1003{
1004 //Comment from TGX11TTF:
1005 // Perform the string rendering in the pad.
1006 // LayoutGlyphs should have been called before.
1007 //End of comment.
1008
1009 //This code is a modified (for Quartz) version of TG11TTF::RenderString.
1010
1011 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
1012 if (!drawable0)
1013 return;
1014
1015 if ([drawable0 isDirectDraw])
1016 return;
1017
1018 auto &atttext = GetAttText(wctxt);
1019
1020 if (!atttext.GetTextSize())//Do not draw anything, or CoreText will create some small (but not of size 0 font).
1021 return;
1022
1023 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "RenderTTFString");
1024 if (!drawable)
1025 return;
1026
1028 if ([drawable isKindOfClass : [QuartzPixmap class]])
1029 dstPixmap = (QuartzPixmap *)drawable;
1030 else if ([drawable isKindOfClass : [QuartzView class]] || [drawable isKindOfClass : [QuartzWindow class]])
1031 dstPixmap = ((NSObject<X11Window> *)drawable).fBackBuffer;
1032
1033 if (!dstPixmap) {
1034 //I can not read pixels from a window (I can, but this is too slow and unreliable).
1035 Error("RenderTTFString", "fSelectedDrawable is neither QuartzPixmap nor a double buffered window");
1036 return;
1037 }
1038
1039 //Comment from TGX11TTF:
1040 // compute the size and position of the XImage that will contain the text
1041 const Int_t xOff = TTF::GetBox().xMin < 0 ? -TTF::GetBox().xMin : 0;
1042 const Int_t yOff = TTF::GetBox().yMin < 0 ? -TTF::GetBox().yMin : 0;
1043
1044 const Int_t w = TTF::GetBox().xMax + xOff;
1045 const Int_t h = TTF::GetBox().yMax + yOff;
1046
1047 const Int_t x1 = x - xOff - fAlign.x;
1048 const Int_t y1 = y + yOff + fAlign.y - h;
1049
1050 if (!IsTTFStringVisible(wctxt, x1, y1, w, h))
1051 return;
1052
1053 //By default, all pixels are set to 0 (all components, that's what code in TGX11TTF also does here).
1055 if (!pixmap.Get()) {
1056 Error("RenderTTFString", "pixmap creation failed");
1057 return;
1058 }
1059
1060 const unsigned char defaultBackgroundPixel[] = {255, 255, 255, 255};
1062 if (mode == kClear) {
1063 //For this mode, TGX11TTF does some work to: a) preserve pixels under symbols
1064 //b) calculate (interpolate) pixel for glyphs.
1065
1066 X11::Rectangle bbox(x1, y1, w, h);
1067 //We already check IsVisible, so, in principle, bbox at least has intersection with
1068 //the current selected drawable.
1069 if (X11::AdjustCropArea(dstPixmap, bbox))
1070 arrayGuard.Reset([dstPixmap readColorBits : bbox]);
1071
1072 if (!arrayGuard.Get()) {
1073 Error("RenderTTFString", "problem with reading background pixels");
1074 return;
1075 }
1076
1077 // This is copy & paste from TGX11TTF:
1078 const Int_t xo = x1 < 0 ? -x1 : 0;
1079 const Int_t yo = y1 < 0 ? -y1 : 0;
1080
1081 for (int yp = 0; yp < int(bbox.fHeight) && yo + yp < h; ++yp) {
1082 const unsigned char *srcBase = arrayGuard.Get() + bbox.fWidth * yp * 4;
1083 for (int xp = 0; xp < int(bbox.fWidth) && xo + xp < w; ++xp) {
1084 const unsigned char * const pixel = srcBase + xp * 4;
1085 [pixmap.Get() putPixel : pixel X : xo + xp Y : yo + yp];
1086 }
1087 }
1088 } else {
1089 //Find background color and set for all pixels.
1091 }
1092
1093 CGContextRef ctx = drawable.fContext;
1094 const Quartz::CGStateGuard ctxGuard(ctx);
1095
1096 CGContextSetRGBStrokeColor(ctx, 0., 0., 1., 1.);
1097 // paint the glyphs in the pixmap.
1099 for (int n = 0; n < TTF::GetNumGlyphs(); ++n, ++glyph) {
1101 continue;
1102
1104 FT_Bitmap *source = &bitmap->bitmap;
1105 const Int_t bx = bitmap->left + xOff;
1106 const Int_t by = h - bitmap->top - yOff;
1107
1109 mode == kClear ? ULong_t(-1) : 0xffffff, bx, by);
1110 }
1111
1112 const X11::Rectangle copyArea(0, 0, w, h);
1113 const X11::Point dstPoint(x1, y1);
1115}
1116
1117//______________________________________________________________________________
1119{
1120 //This function is a "remake" of TGX11FFT::DrawImage.
1121
1122 //I'm using this code to reproduce the same text as generated by TGX11TTF.
1123 //It's quite sloppy, as in original version. I tried to make it not so ugly and
1124 //more or less readable.
1125
1127 assert(pixmap != nil && "DrawFTGlyphIntoPixmap, pixmap parameter is nil");
1128 assert(source != 0 && "DrawFTGlyphIntoPixmap, source parameter is null");
1129
1130 if (TTF::GetSmoothing()) {
1131 static ColorStruct_t col[5];
1132 // background kClear, i.e. transparent, we take as background color
1133 // the average of the rgb values of all pixels covered by this character
1134 if (back == ULong_t(-1) && source->width) {
1135 const int maxDots = 50000;
1136 int dots = Int_t(source->width * source->rows);
1137 if (dots > maxDots)
1138 dots = maxDots;
1139
1140 //In original code, they first have to extract
1141 //pixels and call XQueryColors.
1142 //I have only one loop here.
1143 ULong_t r = 0, g = 0, b = 0;
1144 for (int y = 0, dotCnt = 0; y < int(source->rows); y++) {
1145 for (int x = 0; x < int(source->width); x++) {
1146 if (x + bx < int(pixmap.fWidth) && y + by < int(pixmap.fHeight)) {
1147 const unsigned char * const pixels = pixmap.fData + (y + by) * pixmap.fWidth * 4 + (x + bx) * 4;
1148 r += UShort_t(pixels[0] / 255. * 0xffff);
1149 g += UShort_t(pixels[1] / 255. * 0xffff);
1150 b += UShort_t(pixels[2] / 255. * 0xffff);
1151 }
1152
1153 if (++dotCnt >= maxDots)
1154 break;
1155 }
1156 }
1157
1158 if (dots) {
1159 r /= dots;
1160 g /= dots;
1161 b /= dots;
1162 }
1163
1164 if (col[0].fRed == r && col[0].fGreen == g && col[0].fBlue == b) {
1165 col[0].fPixel = back;
1166 } else {
1167 col[0].fPixel = ~back;//???
1168 col[0].fRed = (UShort_t) r;
1169 col[0].fGreen = (UShort_t) g;
1170 col[0].fBlue = (UShort_t) b;
1171 }
1172 }
1173
1174 // if fore or background have changed from previous character
1175 // recalculate the 3 smoothing colors (interpolation between fore-
1176 // and background colors)
1177 if (fore != col[4].fPixel || back != col[0].fPixel) {
1178 col[4].fPixel = fore;
1179 TGCocoa::QueryColor(kNone, col[4]);//calculate fRed/fGreen/fBlue triple from fPixel.
1180 if (back != (ULong_t)-1) {
1181 col[0].fPixel = back;
1182 TGCocoa::QueryColor(kNone, col[0]);
1183 }
1184
1185 // interpolate between fore and background colors
1186 for (int x = 3; x > 0; --x) {
1187 col[x].fRed = (col[4].fRed * x + col[0].fRed * (4 - x)) / 4;
1188 col[x].fGreen = (col[4].fGreen * x + col[0].fGreen * (4 - x)) / 4;
1189 col[x].fBlue = (col[4].fBlue * x + col[0].fBlue * (4 - x)) / 4;
1190 TGCocoa::AllocColor(kNone, col[x]);//Calculate fPixel from fRed/fGreen/fBlue triplet.
1191 }
1192 }
1193
1194 // put smoothed character, character pixmap values are an index
1195 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
1196 const unsigned char *s = source->buffer;
1197 for (int y = 0; y < (int) source->rows; ++y) {
1198 for (int x = 0; x < (int) source->width; ++x) {
1199 unsigned char d = *s++ & 0xff;//???
1200 d = ((d + 10) * 5) / 256;//???
1201 if (d > 4)
1202 d = 4;
1203 if (d && x < (int) source->width) {
1204 const UChar_t pixel[] = {UChar_t(double(col[d].fRed) / 0xffff * 255),
1205 UChar_t(double(col[d].fGreen) / 0xffff * 255),
1206 UChar_t(double(col[d].fBlue) / 0xffff * 255), 255};
1207 [pixmap putPixel : pixel X : bx + x Y : by + y];
1208 }
1209 }
1210 }
1211 } else {
1212 // no smoothing, just put character using foreground color
1213 unsigned char rgba[4] = {};
1214 rgba[3] = 255;
1216 unsigned char d = 0;
1217
1218 const unsigned char *row = source->buffer;
1219 for (int y = 0; y < int(source->rows); ++y) {
1220 int n = 0;
1221 const unsigned char *s = row;
1222 for (int x = 0; x < int(source->width); ++x) {
1223 if (!n)
1224 d = *s++;
1225
1226 if (TESTBIT(d,7 - n))
1227 [pixmap putPixel : rgba X : bx + x Y : by + y];
1228
1229 if (++n == int(kBitsPerByte))
1230 n = 0;
1231 }
1232
1233 row += source->pitch;
1234 }
1235 }
1236}
1237
1238//Aux. functions.
1239
1240//______________________________________________________________________________
1242{
1243 if (gEnv) {
1244 const TString value(TString(gEnv->GetValue("Cocoa.EnableAntiAliasing", "auto")).Strip());
1245 if (value == "auto") {
1246 [[NSScreen mainScreen] backingScaleFactor] > 1. ? fUseAA = true : fUseAA = false;
1247 } else if (value == "no")
1248 fUseAA = false;
1249 else {
1250 assert(value == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1251 fUseAA = true;
1252 }
1253 const TString valuefa(TString(gEnv->GetValue("Cocoa.EnableFillAreaAntiAliasing", "auto")).Strip());
1254 if (valuefa == "auto") {
1256 } else if (valuefa == "no")
1257 fUseFAAA = false;
1258 else {
1259 assert(valuefa == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1260 fUseFAAA = true;
1261 }
1262 }
1263}
1264
1265//______________________________________________________________________________
1267{
1268 // attributes stored in direct drawable (view) and not in underlying pixmap
1269 auto drawable = (NSObject<X11Drawable> *) wctxt;
1270 if (!drawable || !drawable.attFill)
1271 return *this;
1272 return *drawable.attFill;
1273}
1274
1275//______________________________________________________________________________
1277{
1278 // attributes stored in direct drawable (view) and not in underlying pixmap
1279 auto drawable = (NSObject<X11Drawable> *) wctxt;
1280 if (!drawable || !drawable.attLine)
1281 return *this;
1282 return *drawable.attLine;
1283}
1284
1285//______________________________________________________________________________
1287{
1288 // attributes stored in direct drawable (view) and not in underlying pixmap
1289 auto drawable = (NSObject<X11Drawable> *) wctxt;
1290 if (!drawable || !drawable.attMarker)
1291 return *this;
1292 return *drawable.attMarker;
1293}
1294
1295//______________________________________________________________________________
1297{
1298 // attributes stored in direct drawable (view) and not in underlying pixmap
1299 auto drawable = (NSObject<X11Drawable> *) wctxt;
1300 if (!drawable || !drawable.attText)
1301 return *this;
1302 return *drawable.attText;
1303}
1304
1305//______________________________________________________________________________
1306void *TGQuartz::GetPixmapDrawable(void *drawable0, const char *calledFrom) const
1307{
1308 assert(calledFrom != 0 && "GetDrawableChecked, calledFrom parameter is null");
1309
1310 if (!drawable0)
1311 return nullptr;
1312
1313 auto drawable = (NSObject<X11Drawable> *) drawable0;
1314 if (!drawable.fIsPixmap) {
1315 //TPad/TCanvas ALWAYS draw only into a pixmap.
1316 if ([drawable isKindOfClass : [QuartzView class]]) {
1317 QuartzView *view = (QuartzView *)drawable;
1318 if (!view.fBackBuffer) {
1319 Error(calledFrom, "Selected window is not double buffered");
1320 return nullptr;
1321 }
1322
1323 drawable = view.fBackBuffer;
1324 } else {
1325 Error(calledFrom, "Selected drawable is neither a pixmap, nor a double buffered window");
1326 return nullptr;
1327 }
1328 }
1329
1330 if (!drawable.fContext) {
1331 Error(calledFrom, "Context is null");
1332 return nullptr;
1333 }
1334
1335 return drawable;
1336}
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
Handle_t Drawable_t
Drawable handle.
Definition GuiTypes.h:32
const Handle_t kNone
Definition GuiTypes.h:89
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Style_t
Style number (short)
Definition RtypesCore.h:96
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:54
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
constexpr ULong_t kBitsPerByte
Definition RtypesCore.h:130
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
short Width_t
Line width (short)
Definition RtypesCore.h:98
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
short Font_t
Font number (short)
Definition RtypesCore.h:95
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
short SCoord_t
Screen coordinates (short)
Definition RtypesCore.h:100
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define TESTBIT(n, i)
Definition Rtypes.h:94
const Float_t kScale
Definition TASImage.cxx:135
#define X(type, name)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
const Float_t kScale
Definition TGQuartz.mm:48
std::vector< UniChar > quartz_get_greek_unicars(const char *text)
Definition TGQuartz.mm:456
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 GetWindowSize
Option_t Option_t cindex
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t mgn
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 markerstyle
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 bitmap
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t textsize
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t width
Option_t Option_t style
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 text
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:148
#define gROOT
Definition TROOT.h:426
Fill Area Attributes class.
Definition TAttFill.h:21
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
Line Attributes class.
Definition TAttLine.h:21
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:46
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
Marker Attributes class.
Definition TAttMarker.h:21
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:41
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:35
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:43
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:48
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
Text Attributes class.
Definition TAttText.h:21
virtual Float_t GetTextSize() const
Return the text size.
Definition TAttText.h:39
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:48
virtual Font_t GetTextFont() const
Return the text font.
Definition TAttText.h:38
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition TAttText.h:49
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:50
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:52
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:53
TColorGradient extends basic TColor.
The color creation and management class.
Definition TColor.h:22
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:503
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D.
Definition TGCocoa.h:57
Bool_t AllocColor(Colormap_t cmap, ColorStruct_t &color) override
Allocates a read-only colormap entry corresponding to the closest RGB value supported by the hardware...
Definition TGCocoa.mm:2978
std::unique_ptr< ROOT::MacOSX::Details::CocoaPrivate > fPimpl
!
Definition TGCocoa.h:451
void QueryColor(Colormap_t cmap, ColorStruct_t &color) override
Returns the current RGB value for the pixel in the "color" structure.
Definition TGCocoa.mm:2988
WinContext_t GetSelectedContext()
Definition TGCocoa.mm:693
Drawable_t fSelectedDrawable
Definition TGCocoa.h:449
ULong_t GetPixel(Color_t cindex) override
Returns pixel value associated to specified ROOT color number "cindex".
Definition TGCocoa.mm:3003
void SetLineWidth(Width_t width) override
Set the line width.
Definition TGQuartz.mm:740
TAttMarker & GetAttMarker(WinContext_t wctxt)
Definition TGQuartz.mm:1286
bool fUseFAAA
Definition TGQuartz.h:112
void SetAttLine(WinContext_t wctxt, const TAttLine &att) override
Set line attributes for specified window.
Definition TGQuartz.mm:885
void SetMarkerColor(Color_t cindex) override
Set the marker color.
Definition TGQuartz.mm:772
void SetFillStyle(Style_t style) override
Set the fill area style.
Definition TGQuartz.mm:762
void SetOpacity(Int_t percent) override
Sets opacity of the current window.
Definition TGQuartz.mm:860
void SetFillColor(Color_t cindex) override
Set the fill area color.
Definition TGQuartz.mm:751
void DrawPolyLine(Int_t n, TPoint *xy) override
Draws a line through all points in the list.
Definition TGQuartz.mm:367
Float_t GetTextMagnitude() override
Returns the current font magnification factor.
Definition TGQuartz.mm:713
void SetAttText(WinContext_t wctxt, const TAttText &att) override
Set text attributes for specified window.
Definition TGQuartz.mm:907
void SetAA()
Definition TGQuartz.mm:1241
void DrawFillArea(Int_t n, TPoint *xy) override
Fills area described by the polygon.
Definition TGQuartz.mm:255
void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode) override
Draws a text string using current font.
Definition TGQuartz.mm:517
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draws a line.
Definition TGQuartz.mm:313
Bool_t IsTTFStringVisible(WinContext_t wctxt, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition TGQuartz.mm:970
void DrawTextW(WinContext_t wctxt, Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode) override
Draw text on specified window.
Definition TGQuartz.mm:470
void SetTextColor(Color_t cindex) override
Set the text color.
Definition TGQuartz.mm:815
Bool_t GetTextExtentA(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const char *mess) override
Returns the size of the specified character string "mess" for font and size.
Definition TGQuartz.mm:581
void SetMarkerStyle(Style_t markerstyle) override
Set the marker style.
Definition TGQuartz.mm:794
bool fUseAA
Definition TGQuartz.h:111
void DrawFTGlyphIntoPixmap(void *pixmap, FT_Bitmap *source, ULong_t fore, ULong_t back, Int_t bx, Int_t by)
Definition TGQuartz.mm:1118
void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode) override
Draws a box between [x1,y1] and [x2,y2] according to the "mode".
Definition TGQuartz.mm:187
void SetAttFill(WinContext_t wctxt, const TAttFill &att) override
Set fill attributes for specified window.
Definition TGQuartz.mm:875
std::vector< TPoint > fConvertedPoints
Definition TGQuartz.h:103
void SetTextAlign(Short_t talign=11) override
Set the text alignment.
Definition TGQuartz.mm:805
TAttText & GetAttText(WinContext_t wctxt)
Definition TGQuartz.mm:1296
void SetLineColor(Color_t cindex) override
Set the line color.
Definition TGQuartz.mm:720
void SetTextFont(Font_t fontnumber) override
Set the text font.
Definition TGQuartz.mm:826
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override
Set marker attributes for specified window.
Definition TGQuartz.mm:896
void RenderTTFString(WinContext_t wctxt, Int_t x, Int_t y, ETextMode mode)
Definition TGQuartz.mm:1002
void GetTextExtent(UInt_t &w, UInt_t &h, char *text) override
Returns the size of the specified character string "mess".
Definition TGQuartz.mm:554
Int_t GetFontAscent() const override
Returns the ascent of the current font (in pixels).
Definition TGQuartz.mm:614
void SetMarkerSize(Float_t markersize) override
Set the marker size.
Definition TGQuartz.mm:782
void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, Int_t *ic) override
Draws a cell array.
Definition TGQuartz.mm:262
void DrawLinesSegmentsW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw line segments on specified window.
Definition TGQuartz.mm:381
void SetTextSize(Float_t textsize) override
Set the text size.
Definition TGQuartz.mm:849
Bool_t GetFontAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const char *mess) override
Returns ascent/descent for specified character string "mess" with font and size.
Definition TGQuartz.mm:686
void AlignTTFString(WinContext_t wctxt)
Definition TGQuartz.mm:930
void DrawPolyMarkerW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly marker on specified window.
Definition TGQuartz.mm:388
void DrawLineW(WinContext_t wctxt, Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draw line on specified window.
Definition TGQuartz.mm:269
void DrawPolyLineW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly line on specified window.
Definition TGQuartz.mm:326
void SetLineStyle(Style_t linestyle) override
Set the line style.
Definition TGQuartz.mm:730
TAttFill & GetAttFill(WinContext_t wctxt)
Definition TGQuartz.mm:1266
Int_t GetFontDescent() const override
Returns the descent of the current font (in pixels.
Definition TGQuartz.mm:650
void DrawBoxW(WinContext_t wctxt, Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode) override
Draw box on specified window.
Definition TGQuartz.mm:115
void SetOpacityW(WinContext_t wctxt, Int_t percent) override
Set opactity for specified window.
Definition TGQuartz.mm:870
void DrawPolyMarker(Int_t n, TPoint *xy) override
Draws "n" markers with the current attributes at position [x,y].
Definition TGQuartz.mm:442
void * GetPixmapDrawable(void *drawable0, const char *calledFrom) const
Definition TGQuartz.mm:1306
void DrawFillAreaW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw fill area on specified window.
Definition TGQuartz.mm:193
TAttLine & GetAttLine(WinContext_t wctxt)
Definition TGQuartz.mm:1276
FT_Vector fAlign
Definition TGQuartz.h:30
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
Basic string class.
Definition TString.h:138
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1170
TTF helper class containing glyphs description.
Definition TTF.h:65
static Bool_t IsInitialized()
Definition TTF.cxx:647
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:304
static void Init()
Initialise the TrueType fonts interface.
Definition TTF.cxx:64
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition TTF.cxx:216
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:403
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:380
static void CleanupGlyphs()
Remove temporary data created by LayoutGlyphs.
Definition TTF.cxx:285
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:528
static Int_t GetAscent()
Definition TTF.cxx:661
static TTGlyph * GetGlyphs()
Definition TTF.cxx:696
static Int_t GetNumGlyphs()
Definition TTF.cxx:668
static Int_t GetWidth()
Definition TTF.cxx:654
static const FT_BBox & GetBox()
Definition TTF.cxx:689
static Bool_t GetSmoothing()
Definition TTF.cxx:640
static void SetTextSize(Float_t textsize)
Set current text size.
Definition TTF.cxx:599
static FT_Matrix * GetRotMatrix()
Definition TTF.cxx:675
QuartzPixmap * fBackBuffer
QuartzWindow * fQuartzWindow
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
#define H(x, y, z)
void PixelToRGB(Pixel_t pixelColor, CGFloat *rgb)
Definition X11Colors.mm:920
int LocalYROOTToCocoa(NSView< X11Window > *parentView, CGFloat yROOT)
bool AdjustCropArea(const Rectangle &srcRect, Rectangle &cropArea)
void DrawPolyLine(CGContextRef ctx, Int_t n, TPoint *xy)
void DrawBox(CGContextRef ctx, Int_t x1, Int_t y1, Int_t x2, Int_t y2, bool hollow)
Bool_t SetLineColor(CGContextRef ctx, Color_t colorIndex)
Definition QuartzLine.mm:29
Bool_t SetFillAreaParameters(CGContextRef ctx, unsigned *patternIndex, const TAttFill &attfill)
void DrawFillArea(CGContextRef ctx, Int_t n, TPoint *xy, Bool_t drawShadow, const TAttFill &attfill)
void DrawPolyMarker(CGContextRef ctx, const std::vector< TPoint > &marker, Size_t markerSize, Style_t markerStyle)
Bool_t SetFillColor(CGContextRef ctx, Color_t colorIndex)
void DrawPolygonWithGradientFill(CGContextRef ctx, const TColorGradient *extendedColor, const CGSize &sizeOfDrawable, Int_t nPoints, const TPoint *xy, Bool_t drawShadow)
void DrawLine(CGContextRef ctx, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
void SetLineWidth(CGContextRef ctx, Int_t width)
void SetLineStyle(CGContextRef ctx, Int_t lstyle)
Definition QuartzLine.mm:75
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Definition TMath.h:691
ULong_t fPixel
color pixel value (index in color table)
Definition GuiTypes.h:312
UShort_t fRed
red component (0..65535)
Definition GuiTypes.h:313
UShort_t fGreen
green component (0..65535)
Definition GuiTypes.h:314
UShort_t fBlue
blue component (0..65535)
Definition GuiTypes.h:315