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
83 if (!TTF::IsInitialized())
84 TTF::Init();
85
86 //I do not know why TTF::Init returns void and I have to check IsInitialized() again.
87 if (!TTF::IsInitialized())
88 Error("TGQuartz", "TTF::Init() failed");
89
90 fAlign.x = 0;
91 fAlign.y = 0;
92
93 SetAA();
94}
95
96
97//______________________________________________________________________________
98TGQuartz::TGQuartz(const char *name, const char *title)
99 : TGCocoa(name, title),
100 fUseAA(true), fUseFAAA(false)
101{
102 //Constructor.
103 if (!TTF::IsInitialized())
104 TTF::Init();
105
106 //I do not know why TTF::Init returns void and I have to check IsInitialized() again.
107 if (!TTF::IsInitialized())
108 Error("TGQuartz", "TTF::Init() failed");
109
110 fAlign.x = 0;
111 fAlign.y = 0;
112
113 SetAA();
114}
115
116//______________________________________________________________________________
118{
119 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
120 if (!drawable0)
121 return;
122
123 //Check some conditions first.
124 if ([drawable0 isDirectDraw]) {
125 if (!drawable0.fIsPixmap) {
126 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
127 if (!view) {
128 ::Warning("DrawBoxW", "Invalid view/window for XOR-mode");
129 return;
130 }
131
132 [view.fQuartzWindow addXorBox: view : x1 : y1 : x2 : y2];
133 }
134 return;
135 }
136
137 auto &attline = GetAttLine(wctxt);
138 auto &attfill = GetAttFill(wctxt);
139
140 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawBoxW");
141 if (!drawable)
142 return;
143
144 CGContextRef ctx = drawable.fContext;
146 //AA flag is not a part of a state.
148
149 //Go to low-left-corner system.
150 y1 = Int_t(X11::LocalYROOTToCocoa(drawable, y1));
151 y2 = Int_t(X11::LocalYROOTToCocoa(drawable, y2));
152
153 if (const TColorGradient * const gradient = dynamic_cast<TColorGradient *>(gROOT->GetColor(attfill.GetFillColor()))) {
154 //Draw a box with a gradient fill and a shadow.
155 //Ignore all fill styles and EBoxMode, use a gradient fill.
156 TPoint polygon[4];
157 polygon[0].fX = x1, polygon[0].fY = y1;
158 polygon[1].fX = x2, polygon[1].fY = y1;
159 polygon[2].fX = x2, polygon[2].fY = y2;
160 polygon[3].fX = x1, polygon[3].fY = y2;
161
162 Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
163 4, polygon, kFALSE); //kFALSE == don't draw a shadow.
164 } else {
165 const bool isHollow = mode == kHollow || attfill.GetFillStyle() / 1000 == 2;
166
167 //Note! Pattern index (and its address) MUST live
168 //long enough to be valid at the point of Quartz::DrawBox call!
169 unsigned patternIndex = 0;
170 if (isHollow) {
171 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
172 Error("DrawBoxW", "Can not find color for index %d", int(attline.GetLineColor()));
173 return;
174 }
175 } else {
177 Error("DrawBoxW", "SetFillAreaParameters failed");
178 return;
179 }
180 }
181 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
182 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
183 Quartz::DrawBox(ctx, x1, y1, x2, y2, isHollow);
184 }
185}
186
187
188//______________________________________________________________________________
193
194//______________________________________________________________________________
196{
197 //Comment from TVirtualX:
198
199 // Draw a filled area through all points.
200 // n : number of points
201 // xy : array of points
202
203 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
204 if (!drawable0)
205 return;
206
207 if (n < 3)
208 return;
209 // No fill area with direct drawing
210 if ([drawable0 isDirectDraw])
211 return;
212
213 auto &attfill = GetAttFill(wctxt);
214
215 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawFillAreaW");
216 if (!drawable)
217 return;
218
219 CGContextRef ctx = drawable.fContext;
220
221 //Convert points to bottom-left system:
223
225 //AA flag is not a part of a state.
227
228 if (drawable.fScaleFactor > 1.) {
229 // The CTM will be restored by 'ctxGuard'.
230 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
231 }
232
233 const TColor * const fillColor = gROOT->GetColor(attfill.GetFillColor());
234 if (!fillColor) {
235 Error("DrawFillAreaW", "Could not find TColor for index %d", attfill.GetFillColor());
236 return;
237 }
238
239 if (const TColorGradient * const gradient = dynamic_cast<const TColorGradient *>(fillColor)) {
240 Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
241 n, &fConvertedPoints[0], kFALSE);//kFALSE == don't draw a shadow.
242 } else {
243 unsigned patternIndex = 0;
245 Error("DrawFillAreaW", "SetFillAreaParameters failed");
246 return;
247 }
248
249 // kFALSE - do not draw shadows.
250 // last argument - fill style
252 }
253}
254
255
256//______________________________________________________________________________
261
262
263//______________________________________________________________________________
264void TGQuartz::DrawCellArray(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/,
265 Int_t /*nx*/, Int_t /*ny*/, Int_t */*ic*/)
266{
267 //Noop.
268}
269
270//______________________________________________________________________________
272{
273 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
274 if (!drawable0)
275 return;
276
277 if ([drawable0 isDirectDraw]) {
278 if (!drawable0.fIsPixmap) {
279 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
280 if (!view) {
281 ::Warning("DrawLineW", "Invalid view/window for XOR-mode");
282 return;
283 }
284
285 [view.fQuartzWindow addXorLine: view : x1 : y1 : x2 : y2];
286 }
287
288 return;
289 }
290
291 auto &attline = GetAttLine(wctxt);
292
293 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawLineW");
294 if (!drawable)
295 return;
296
297 CGContextRef ctx = drawable.fContext;
299 //AA flag is not a part of a state.
301
302 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
303 Error("DrawLineW", "Could not set line color for index %d", int(attline.GetLineColor()));
304 return;
305 }
306
307 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
308 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
309
311 X11::LocalYROOTToCocoa(drawable, y2));
312}
313
314//______________________________________________________________________________
316{
317 // Draw a line.
318 // x1,y1 : begin of line
319 // x2,y2 : end of line
320
321 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawLine, bad drawable is selected");
322
324}
325
326
327//______________________________________________________________________________
329{
330 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
331 if (!drawable0)
332 return;
333
334 //Some checks first.
335 if ([drawable0 isDirectDraw])
336 return;
337
338 auto &attline = GetAttLine(wctxt);
339
340 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawPolyLineW");
341 if (!drawable)
342 return;
343
344 CGContextRef ctx = drawable.fContext;
346 //AA flag is not a part of a state.
348
349 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
350 Error("DrawPolyLineW", "Could not find TColor for index %d", attline.GetLineColor());
351 return;
352 }
353
354 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
355 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
356
357 //Convert to bottom-left-corner system.
359
360 if (drawable.fScaleFactor > 1.)
361 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
362
364
365 // CTM (current transformation matrix) is restored by 'ctxGuard's dtor.
366}
367
368//______________________________________________________________________________
370{
371 //Comment from TVirtualX:
372 // Draw a line through all points.
373 // n : number of points
374 // xy : list of points
375 //End of comment.
376
377 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawPolyLine, bad drawable is selected");
378
380}
381
382//______________________________________________________________________________
384{
385 for(Int_t i = 0; i < 2*n; i += 2)
386 DrawPolyLineW(wctxt, 2, &xy[i]);
387}
388
389//______________________________________________________________________________
391{
392 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
393 if (!drawable0)
394 return;
395
396 //Do some checks first.
397 if ([drawable0 isDirectDraw])
398 return;
399
400 auto &attmark = GetAttMarker(wctxt);
401
402 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawPolyMarkerW");
403 if (!drawable)
404 return;
405
406 CGContextRef ctx = drawable.fContext;
408 //AA flag is not a part of a state.
410
411 if (!Quartz::SetFillColor(ctx, attmark.GetMarkerColor())) {
412 Error("DrawPolyMarker", "Could not find TColor for index %d", attmark.GetMarkerColor());
413 return;
414 }
415
416 Quartz::SetLineColor(ctx, attmark.GetMarkerColor());//Can not fail (for coverity).
417 Quartz::SetLineStyle(ctx, 1);
419
421
422 if (drawable.fScaleFactor > 1.)
423 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
424
426
427 // The fast pixel markers need to be treated separately
428 if (markerstyle == 1 || markerstyle == 6 || markerstyle == 7) {
431 } else {
434 }
435
437 Quartz::DrawPolyMarker(ctx, n, &fConvertedPoints[0], MarkerSizeReduced * drawable.fScaleFactor, markerstyle);
438
441}
442
443//______________________________________________________________________________
445{
446 //Comment from TVirtualX:
447 // Draw PolyMarker
448 // n : number of points
449 // xy : list of points
450 //End of comment.
451
453}
454
455
456//______________________________________________________________________________
458 const char *text, ETextMode /* mode */)
459{
460 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
461 if (!drawable0)
462 return;
463
464 if ([drawable0 isDirectDraw])
465 return;
466
467 if (!text || !text[0])//Can this ever happen? TPad::PaintText does not check this.
468 return;
469
470 auto &atttext = GetAttText(wctxt);
471
472 if (atttext.GetTextSize() < 1.5)//Do not draw anything, or CoreText will create some small (but not of size 0 font).
473 return;
474
475 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawTextW");
476 if (!drawable)
477 return;
478
479 CGContextRef ctx = drawable.fContext;
481
482 //Before any core text drawing operations, reset text matrix.
484
485 try {
486 if (CTFontRef currentFont = fPimpl->fFontManager.SelectFont(atttext.GetTextFont(), kScale * atttext.GetTextSize())) {
487 const unsigned fontIndex = atttext.GetTextFont() / 10;
488 if (fontIndex == 12 || fontIndex == 15) {//Greek and math symbols.
489 //This is a hack. Correct way is to extract glyphs from symbol.ttf,
490 //find correct mapping, place this glyphs. This requires manual layout though (?),
491 //and as usually, I have to many things to do, may be, one day I'll fix text rendering also.
492 //This hack work only on MacOSX 10.7.3, does not work on iOS and I'm not sure about future/previous
493 //versions of MacOSX.
494 typedef std::vector<UniChar>::size_type size_type;
495
496 std::vector<UniChar> unichars(std::strlen(text));
497 for (size_type i = 0, len = unichars.size(); i < len; ++i)
498 unichars[i] = 0xF000 + (unsigned char)text[i];
499
501 ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y), atttext);
502 } else {
503 const Quartz::TextLine ctLine(text, currentFont, atttext.GetTextColor());
504 ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y), atttext);
505 }
506 }
507 } catch (const std::exception &e) {
508 Error("DrawTextW", "Exception from Quartz::TextLine: %s", e.what());
509 }
510}
511
512//______________________________________________________________________________
518
519//______________________________________________________________________________
521 const wchar_t *text, ETextMode mode)
522{
523 if (!text || !text[0])
524 return;
525
526 if (!TTF::IsInitialized()) {
527 Error("DrawTextW", "wchar_t string to draw, but TTF initialization failed");
528 return;
529 }
530
535
538}
539
540//______________________________________________________________________________
546
547//______________________________________________________________________________
549{
550 // Returns the size of the specified character string "mess".
551 //
552 // w - the text width
553 // h - the text height
554 // text - the string
555
556 if (!text || !text[0]) {
557 w = 0;
558 h = 0;
559 return;
560 }
561
562 if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
563 const unsigned fontIndex = GetTextFont() / 10;
564 if (fontIndex == 12 || fontIndex == 15) {//Greek and math symbols.
565 typedef std::vector<UniChar>::size_type size_type;
566
567 std::vector<UniChar> unichars(std::strlen(text));
568 for (size_type i = 0, len = unichars.size(); i < len; ++i)
569 unichars[i] = 0xF000 + (unsigned char)text[i];
570
571 fPimpl->fFontManager.GetTextBounds(w, h, unichars);
572 } else {
573 fPimpl->fFontManager.GetTextBounds(w, h, text);
574 }
575 }
576}
577
578//______________________________________________________________________________
580{
581 // Returns the ascent of the current font (in pixels).
582 // The ascent of a font is the distance from the baseline
583 // to the highest position characters extend to.
584 if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
585 return Int_t(fPimpl->fFontManager.GetAscent());
586
587 return 0;
588}
589
590//______________________________________________________________________________
592{
593 // Returns the ascent of the current font (in pixels).
594 // The ascent of a font is the distance from the baseline
595 // to the highest position characters extend to.
596
597 //In case of any problem we can always resort to the old version:
598 if (!text || !text[0])//How it's usually tested in ROOT
599 return GetFontAscent();
600
601 if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
602 const unsigned fontIndex = GetTextFont() / 10;
603 if (fontIndex == 12 || fontIndex == 15) {//Greek and math symbols.
604 //That's an ugly hack :)
605 typedef std::vector<UniChar>::size_type size_type;
606
607 std::vector<UniChar> unichars(std::strlen(text));
608 for (size_type i = 0, len = unichars.size(); i < len; ++i)
609 unichars[i] = 0xF000 + (unsigned char)text[i];
610
611 return Int_t(fPimpl->fFontManager.GetAscent(unichars));
612 } else
613 return Int_t(fPimpl->fFontManager.GetAscent(text));
614 }
615
616 return 0;
617}
618
619//______________________________________________________________________________
621{
622 // Returns the descent of the current font (in pixels.
623 // The descent is the distance from the base line
624 // to the lowest point characters extend to.
625 if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
626 return Int_t(fPimpl->fFontManager.GetDescent());
627
628 return 0;
629}
630
631//______________________________________________________________________________
633{
634 // Returns the descent of the current font (in pixels.
635 // The descent is the distance from the base line
636 // to the lowest point characters extend to.
637
638 //That's how it's tested in ROOT:
639 if (!text || !text[0])
640 return GetFontDescent();
641
642 if (fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
643 const unsigned fontIndex = GetTextFont() / 10;
644 if (fontIndex == 12 || fontIndex == 15) {//Greek and math symbols.
645 //That's an ugly hack :)
646 typedef std::vector<UniChar>::size_type size_type;
647
648 std::vector<UniChar> unichars(std::strlen(text));
649 for (size_type i = 0, len = unichars.size(); i < len; ++i)
650 unichars[i] = 0xF000 + (unsigned char)text[i];
651
652 return Int_t(fPimpl->fFontManager.GetDescent(unichars));
653 } else
654 return Int_t(fPimpl->fFontManager.GetDescent(text));
655 }
656
657 return 0;
658}
659
660
661//______________________________________________________________________________
663{
664 // Returns the current font magnification factor
665 return 0;
666}
667
668//______________________________________________________________________________
670{
671 // Set color index "cindex" for drawing lines.
673
675}
676
677
678//______________________________________________________________________________
680{
681 // Set line style.
683
685}
686
687
688//______________________________________________________________________________
690{
691 // Set the line width.
692
694
696}
697
698
699//______________________________________________________________________________
701{
702 // Set color index "cindex" for fill areas.
703
705
707}
708
709
710//______________________________________________________________________________
712{
713 // Set fill area style.
715
717}
718
719
720//______________________________________________________________________________
722{
723 // Set color index "cindex" for markers.
725
727}
728
729
730//______________________________________________________________________________
732{
733 // Set marker size index.
734 //
735 // markersize - the marker scale factor
737
739}
740
741
742//______________________________________________________________________________
744{
745 // Set marker style.
746
748
750}
751
752
753//______________________________________________________________________________
755{
756 // Set the text alignment.
757
759
761}
762
763//______________________________________________________________________________
765{
766 // Set the color index "cindex" for text.
767
769
771}
772
773
774//______________________________________________________________________________
776{
777 // Set the current text font number.
778
780
782}
783
784//______________________________________________________________________________
786{
787 //This function is never used in gPad (in normal text rendering,
788 //so I'm not setting anything for CoreText).
789 if (!TTF::IsInitialized()) {
790 Error("SetTextFont", "TTF is not initialized");
791 return 0;
792 }
793
795}
796
797//______________________________________________________________________________
799{
800 // Set the current text size to "textsize"
801
803
805}
806
807
808//______________________________________________________________________________
810{
811 // Set opacity of the current window. This image manipulation routine
812 // works by adding to a percent amount of neutral to each pixels RGB.
813 // Since it requires quite some additional color map entries is it
814 // only supported on displays with more than > 8 color planes (> 256
815 // colors).
816}
817
818
819//______________________________________________________________________________
821{
822 att.Copy(GetAttFill(wctxt));
823
824 // TODO: remove this after transition done
825 TAttFill::SetFillColor(att.GetFillColor());
826 TAttFill::SetFillStyle(att.GetFillStyle());
827}
828
829//______________________________________________________________________________
831{
832 att.Copy(GetAttLine(wctxt));
833
834 // TODO: remove this after transition done
835 TAttLine::SetLineColor(att.GetLineColor());
836 TAttLine::SetLineStyle(att.GetLineStyle());
837 TAttLine::SetLineWidth(att.GetLineWidth());
838}
839
840//______________________________________________________________________________
842{
843 att.Copy(GetAttMarker(wctxt));
844
845 // TODO: remove this after transition done
846 TAttMarker::SetMarkerColor(att.GetMarkerColor());
847 TAttMarker::SetMarkerSize(att.GetMarkerSize());
848 TAttMarker::SetMarkerStyle(att.GetMarkerStyle());
849}
850
851//______________________________________________________________________________
853{
854 att.Copy(GetAttText(wctxt));
855
856 if (!TTF::IsInitialized()) {
857 Error("SetAttText", "TTF is not initialized");
858 return;
859 }
860
861 TTF::SetTextSize(att.GetTextSize());
862 TTF::SetTextFont(att.GetTextFont());
863
864 // TODO: remove this after transition done
865 TAttText::SetTextAlign(att.GetTextAlign());
866 TAttText::SetTextAngle(att.GetTextAngle());
867 TAttText::SetTextColor(att.GetTextColor());
868 TAttText::SetTextSize(att.GetTextSize());
869 TAttText::SetTextFont(att.GetTextFont());
870}
871
872//TTF related part.
873
874//______________________________________________________________________________
876{
877 //Comment from TGX11TTF:
878 // Compute alignment variables. The alignment is done on the horizontal string
879 // then the rotation is applied on the alignment variables.
880 // SetRotation and LayoutGlyphs should have been called before.
881 //End of comment.
882
883 //This code is from TGX11TTF (with my fixes).
884 //It looks like align can not be both X and Y align?
885
886 auto &atttext = GetAttText(wctxt);
887
888 Int_t txalh = atttext.GetTextAlign() / 10;
889 Int_t txalv = atttext.GetTextAlign() % 10;
890
891 // const EAlign align = EAlign(fTextAlign);
892 // vertical alignment
893 if (txalv == 3) // align == kTLeft || align == kTCenter || align == kTRight)
895 else if (txalv == 2) // if (align == kMLeft || align == kMCenter || align == kMRight) {
896 fAlign.y = TTF::GetAscent() / 2;
897 else
898 fAlign.y = 0;
899
900 // horizontal alignment
901 if (txalh == 3) // align == kTRight || align == kMRight || align == kBRight) {
902 fAlign.x = TTF::GetWidth();
903 else if (txalh == 2) // (align == kTCenter || align == kMCenter || align == kBCenter) {
904 fAlign.x = TTF::GetWidth() / 2;
905 else
906 fAlign.x = 0;
907
909 //This shift is from the original code.
910 fAlign.x = fAlign.x >> 6;
911 fAlign.y = fAlign.y >> 6;
912}
913
914//______________________________________________________________________________
916{
917 //Comment from TGX11TTF:
918 // Test if there is really something to render.
919 //End of comment.
920
921 //This code is from TGX11TTF (with modifications).
922
923 //Comment from TGX11TTF:
924 // If w or h is 0, very likely the string is only blank characters
925 if (!w || !h || !wctxt)
926 return kFALSE;
927
928 auto drawable = (NSObject<X11Drawable> * const) wctxt;
929
930 UInt_t width = 0;
931 UInt_t height = 0;
932 Int_t xy = 0;
933
934 GetWindowSize((Drawable_t) drawable.fID, xy, xy, width, height);
935
936 // If string falls outside window, there is probably no need to draw it.
937 if (x + int(w) <= 0 || x >= int(width))
938 return kFALSE;
939
940 if (y + int(h) <= 0 || y >= int(height))
941 return kFALSE;
942
943 return kTRUE;
944}
945
946//______________________________________________________________________________
948{
949 //Comment from TGX11TTF:
950 // Perform the string rendering in the pad.
951 // LayoutGlyphs should have been called before.
952 //End of comment.
953
954 //This code is a modified (for Quartz) version of TG11TTF::RenderString.
955
956 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
957 if (!drawable0)
958 return;
959
960 if ([drawable0 isDirectDraw])
961 return;
962
963 auto &atttext = GetAttText(wctxt);
964
965 if (!atttext.GetTextSize())//Do not draw anything, or CoreText will create some small (but not of size 0 font).
966 return;
967
968 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "RenderTTFString");
969 if (!drawable)
970 return;
971
973 if ([drawable isKindOfClass : [QuartzPixmap class]])
974 dstPixmap = (QuartzPixmap *)drawable;
975 else if ([drawable isKindOfClass : [QuartzView class]] || [drawable isKindOfClass : [QuartzWindow class]])
976 dstPixmap = ((NSObject<X11Window> *)drawable).fBackBuffer;
977
978 if (!dstPixmap) {
979 //I can not read pixels from a window (I can, but this is too slow and unreliable).
980 Error("RenderTTFString", "fSelectedDrawable is neither QuartzPixmap nor a double buffered window");
981 return;
982 }
983
984 //Comment from TGX11TTF:
985 // compute the size and position of the XImage that will contain the text
986 const Int_t xOff = TTF::GetBox().xMin < 0 ? -TTF::GetBox().xMin : 0;
987 const Int_t yOff = TTF::GetBox().yMin < 0 ? -TTF::GetBox().yMin : 0;
988
989 const Int_t w = TTF::GetBox().xMax + xOff;
990 const Int_t h = TTF::GetBox().yMax + yOff;
991
992 const Int_t x1 = x - xOff - fAlign.x;
993 const Int_t y1 = y + yOff + fAlign.y - h;
994
995 if (!IsTTFStringVisible(wctxt, x1, y1, w, h))
996 return;
997
998 //By default, all pixels are set to 0 (all components, that's what code in TGX11TTF also does here).
1000 if (!pixmap.Get()) {
1001 Error("RenderTTFString", "pixmap creation failed");
1002 return;
1003 }
1004
1005 const unsigned char defaultBackgroundPixel[] = {255, 255, 255, 255};
1007 if (mode == kClear) {
1008 //For this mode, TGX11TTF does some work to: a) preserve pixels under symbols
1009 //b) calculate (interpolate) pixel for glyphs.
1010
1011 X11::Rectangle bbox(x1, y1, w, h);
1012 //We already check IsVisible, so, in principle, bbox at least has intersection with
1013 //the current selected drawable.
1014 if (X11::AdjustCropArea(dstPixmap, bbox))
1015 arrayGuard.Reset([dstPixmap readColorBits : bbox]);
1016
1017 if (!arrayGuard.Get()) {
1018 Error("RenderTTFString", "problem with reading background pixels");
1019 return;
1020 }
1021
1022 // This is copy & paste from TGX11TTF:
1023 const Int_t xo = x1 < 0 ? -x1 : 0;
1024 const Int_t yo = y1 < 0 ? -y1 : 0;
1025
1026 for (int yp = 0; yp < int(bbox.fHeight) && yo + yp < h; ++yp) {
1027 const unsigned char *srcBase = arrayGuard.Get() + bbox.fWidth * yp * 4;
1028 for (int xp = 0; xp < int(bbox.fWidth) && xo + xp < w; ++xp) {
1029 const unsigned char * const pixel = srcBase + xp * 4;
1030 [pixmap.Get() putPixel : pixel X : xo + xp Y : yo + yp];
1031 }
1032 }
1033 } else {
1034 //Find background color and set for all pixels.
1036 }
1037
1038 CGContextRef ctx = drawable.fContext;
1039 const Quartz::CGStateGuard ctxGuard(ctx);
1040
1041 CGContextSetRGBStrokeColor(ctx, 0., 0., 1., 1.);
1042 // paint the glyphs in the pixmap.
1044 for (int n = 0; n < TTF::GetNumGlyphs(); ++n, ++glyph) {
1046 continue;
1047
1049 FT_Bitmap *source = &bitmap->bitmap;
1050 const Int_t bx = bitmap->left + xOff;
1051 const Int_t by = h - bitmap->top - yOff;
1052
1054 mode == kClear ? ULong_t(-1) : 0xffffff, bx, by);
1055 }
1056
1057 const X11::Rectangle copyArea(0, 0, w, h);
1058 const X11::Point dstPoint(x1, y1);
1060}
1061
1062//______________________________________________________________________________
1064{
1065 //This function is a "remake" of TGX11FFT::DrawImage.
1066
1067 //I'm using this code to reproduce the same text as generated by TGX11TTF.
1068 //It's quite sloppy, as in original version. I tried to make it not so ugly and
1069 //more or less readable.
1070
1072 assert(pixmap != nil && "DrawFTGlyphIntoPixmap, pixmap parameter is nil");
1073 assert(source != 0 && "DrawFTGlyphIntoPixmap, source parameter is null");
1074
1075 if (TTF::GetSmoothing()) {
1076 static ColorStruct_t col[5];
1077 // background kClear, i.e. transparent, we take as background color
1078 // the average of the rgb values of all pixels covered by this character
1079 if (back == ULong_t(-1) && source->width) {
1080 const int maxDots = 50000;
1081 int dots = Int_t(source->width * source->rows);
1082 if (dots > maxDots)
1083 dots = maxDots;
1084
1085 //In original code, they first have to extract
1086 //pixels and call XQueryColors.
1087 //I have only one loop here.
1088 ULong_t r = 0, g = 0, b = 0;
1089 for (int y = 0, dotCnt = 0; y < int(source->rows); y++) {
1090 for (int x = 0; x < int(source->width); x++) {
1091 if (x + bx < int(pixmap.fWidth) && y + by < int(pixmap.fHeight)) {
1092 const unsigned char * const pixels = pixmap.fData + (y + by) * pixmap.fWidth * 4 + (x + bx) * 4;
1093 r += UShort_t(pixels[0] / 255. * 0xffff);
1094 g += UShort_t(pixels[1] / 255. * 0xffff);
1095 b += UShort_t(pixels[2] / 255. * 0xffff);
1096 }
1097
1098 if (++dotCnt >= maxDots)
1099 break;
1100 }
1101 }
1102
1103 if (dots) {
1104 r /= dots;
1105 g /= dots;
1106 b /= dots;
1107 }
1108
1109 if (col[0].fRed == r && col[0].fGreen == g && col[0].fBlue == b) {
1110 col[0].fPixel = back;
1111 } else {
1112 col[0].fPixel = ~back;//???
1113 col[0].fRed = (UShort_t) r;
1114 col[0].fGreen = (UShort_t) g;
1115 col[0].fBlue = (UShort_t) b;
1116 }
1117 }
1118
1119 // if fore or background have changed from previous character
1120 // recalculate the 3 smoothing colors (interpolation between fore-
1121 // and background colors)
1122 if (fore != col[4].fPixel || back != col[0].fPixel) {
1123 col[4].fPixel = fore;
1124 TGCocoa::QueryColor(kNone, col[4]);//calculate fRed/fGreen/fBlue triple from fPixel.
1125 if (back != (ULong_t)-1) {
1126 col[0].fPixel = back;
1127 TGCocoa::QueryColor(kNone, col[0]);
1128 }
1129
1130 // interpolate between fore and background colors
1131 for (int x = 3; x > 0; --x) {
1132 col[x].fRed = (col[4].fRed * x + col[0].fRed * (4 - x)) / 4;
1133 col[x].fGreen = (col[4].fGreen * x + col[0].fGreen * (4 - x)) / 4;
1134 col[x].fBlue = (col[4].fBlue * x + col[0].fBlue * (4 - x)) / 4;
1135 TGCocoa::AllocColor(kNone, col[x]);//Calculate fPixel from fRed/fGreen/fBlue triplet.
1136 }
1137 }
1138
1139 // put smoothed character, character pixmap values are an index
1140 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
1141 const unsigned char *s = source->buffer;
1142 for (int y = 0; y < (int) source->rows; ++y) {
1143 for (int x = 0; x < (int) source->width; ++x) {
1144 unsigned char d = *s++ & 0xff;//???
1145 d = ((d + 10) * 5) / 256;//???
1146 if (d > 4)
1147 d = 4;
1148 if (d && x < (int) source->width) {
1149 const UChar_t pixel[] = {UChar_t(double(col[d].fRed) / 0xffff * 255),
1150 UChar_t(double(col[d].fGreen) / 0xffff * 255),
1151 UChar_t(double(col[d].fBlue) / 0xffff * 255), 255};
1152 [pixmap putPixel : pixel X : bx + x Y : by + y];
1153 }
1154 }
1155 }
1156 } else {
1157 // no smoothing, just put character using foreground color
1158 unsigned char rgba[4] = {};
1159 rgba[3] = 255;
1161 unsigned char d = 0;
1162
1163 const unsigned char *row = source->buffer;
1164 for (int y = 0; y < int(source->rows); ++y) {
1165 int n = 0;
1166 const unsigned char *s = row;
1167 for (int x = 0; x < int(source->width); ++x) {
1168 if (!n)
1169 d = *s++;
1170
1171 if (TESTBIT(d,7 - n))
1172 [pixmap putPixel : rgba X : bx + x Y : by + y];
1173
1174 if (++n == int(kBitsPerByte))
1175 n = 0;
1176 }
1177
1178 row += source->pitch;
1179 }
1180 }
1181}
1182
1183//Aux. functions.
1184
1185//______________________________________________________________________________
1187{
1188 if (gEnv) {
1189 const TString value(TString(gEnv->GetValue("Cocoa.EnableAntiAliasing", "auto")).Strip());
1190 if (value == "auto") {
1191 [[NSScreen mainScreen] backingScaleFactor] > 1. ? fUseAA = true : fUseAA = false;
1192 } else if (value == "no")
1193 fUseAA = false;
1194 else {
1195 assert(value == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1196 fUseAA = true;
1197 }
1198 const TString valuefa(TString(gEnv->GetValue("Cocoa.EnableFillAreaAntiAliasing", "auto")).Strip());
1199 if (valuefa == "auto") {
1201 } else if (valuefa == "no")
1202 fUseFAAA = false;
1203 else {
1204 assert(valuefa == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1205 fUseFAAA = true;
1206 }
1207 }
1208}
1209
1210//______________________________________________________________________________
1212{
1213 // attributes stored in direct drawable (view) and not in underlying pixmap
1214 auto drawable = (NSObject<X11Drawable> *) wctxt;
1215 if (!drawable || !drawable.attFill)
1216 return *this;
1217 return *drawable.attFill;
1218}
1219
1220//______________________________________________________________________________
1222{
1223 // attributes stored in direct drawable (view) and not in underlying pixmap
1224 auto drawable = (NSObject<X11Drawable> *) wctxt;
1225 if (!drawable || !drawable.attLine)
1226 return *this;
1227 return *drawable.attLine;
1228}
1229
1230//______________________________________________________________________________
1232{
1233 // attributes stored in direct drawable (view) and not in underlying pixmap
1234 auto drawable = (NSObject<X11Drawable> *) wctxt;
1235 if (!drawable || !drawable.attMarker)
1236 return *this;
1237 return *drawable.attMarker;
1238}
1239
1240//______________________________________________________________________________
1242{
1243 // attributes stored in direct drawable (view) and not in underlying pixmap
1244 auto drawable = (NSObject<X11Drawable> *) wctxt;
1245 if (!drawable || !drawable.attText)
1246 return *this;
1247 return *drawable.attText;
1248}
1249
1250//______________________________________________________________________________
1251void *TGQuartz::GetPixmapDrawable(void *drawable0, const char *calledFrom) const
1252{
1253 assert(calledFrom != 0 && "GetDrawableChecked, calledFrom parameter is null");
1254
1255 if (!drawable0)
1256 return nullptr;
1257
1258 auto drawable = (NSObject<X11Drawable> *) drawable0;
1259 if (!drawable.fIsPixmap) {
1260 //TPad/TCanvas ALWAYS draw only into a pixmap.
1261 if ([drawable isKindOfClass : [QuartzView class]]) {
1262 QuartzView *view = (QuartzView *)drawable;
1263 if (!view.fBackBuffer) {
1264 Error(calledFrom, "Selected window is not double buffered");
1265 return nullptr;
1266 }
1267
1268 drawable = view.fBackBuffer;
1269 } else {
1270 Error(calledFrom, "Selected drawable is neither a pixmap, nor a double buffered window");
1271 return nullptr;
1272 }
1273 }
1274
1275 if (!drawable.fContext) {
1276 Error(calledFrom, "Context is null");
1277 return nullptr;
1278 }
1279
1280 return drawable;
1281}
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 h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
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:134
#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
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 depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char 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:146
#define gROOT
Definition TROOT.h:414
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:46
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:47
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:48
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:50
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:51
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:58
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:2970
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:2980
WinContext_t GetSelectedContext()
Definition TGCocoa.mm:692
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:2995
void SetLineWidth(Width_t width) override
Set the line width.
Definition TGQuartz.mm:689
TAttMarker & GetAttMarker(WinContext_t wctxt)
Definition TGQuartz.mm:1231
bool fUseFAAA
Definition TGQuartz.h:107
void SetAttLine(WinContext_t wctxt, const TAttLine &att) override
Set line attributes for specified window.
Definition TGQuartz.mm:830
void SetMarkerColor(Color_t cindex) override
Set the marker color.
Definition TGQuartz.mm:721
void SetFillStyle(Style_t style) override
Set the fill area style.
Definition TGQuartz.mm:711
void SetOpacity(Int_t percent) override
Sets opacity of the current window.
Definition TGQuartz.mm:809
void SetFillColor(Color_t cindex) override
Set the fill area color.
Definition TGQuartz.mm:700
void DrawPolyLine(Int_t n, TPoint *xy) override
Draws a line through all points in the list.
Definition TGQuartz.mm:369
Float_t GetTextMagnitude() override
Returns the current font magnification factor.
Definition TGQuartz.mm:662
void SetAttText(WinContext_t wctxt, const TAttText &att) override
Set text attributes for specified window.
Definition TGQuartz.mm:852
void SetAA()
Definition TGQuartz.mm:1186
void DrawFillArea(Int_t n, TPoint *xy) override
Fills area described by the polygon.
Definition TGQuartz.mm:257
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:513
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draws a line.
Definition TGQuartz.mm:315
Bool_t IsTTFStringVisible(WinContext_t wctxt, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition TGQuartz.mm:915
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:457
void SetTextColor(Color_t cindex) override
Set the text color.
Definition TGQuartz.mm:764
void SetMarkerStyle(Style_t markerstyle) override
Set the marker style.
Definition TGQuartz.mm:743
bool fUseAA
Definition TGQuartz.h:106
void DrawFTGlyphIntoPixmap(void *pixmap, FT_Bitmap *source, ULong_t fore, ULong_t back, Int_t bx, Int_t by)
Definition TGQuartz.mm:1063
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:189
void SetAttFill(WinContext_t wctxt, const TAttFill &att) override
Set fill attributes for specified window.
Definition TGQuartz.mm:820
std::vector< TPoint > fConvertedPoints
Definition TGQuartz.h:98
void SetTextAlign(Short_t talign=11) override
Set the text alignment.
Definition TGQuartz.mm:754
TAttText & GetAttText(WinContext_t wctxt)
Definition TGQuartz.mm:1241
void SetLineColor(Color_t cindex) override
Set the line color.
Definition TGQuartz.mm:669
void SetTextFont(Font_t fontnumber) override
Set the text font.
Definition TGQuartz.mm:775
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override
Set marker attributes for specified window.
Definition TGQuartz.mm:841
void RenderTTFString(WinContext_t wctxt, Int_t x, Int_t y, ETextMode mode)
Definition TGQuartz.mm:947
void GetTextExtent(UInt_t &w, UInt_t &h, char *text) override
Returns the size of the specified character string "mess".
Definition TGQuartz.mm:548
Int_t GetFontAscent() const override
Returns the ascent of the current font (in pixels).
Definition TGQuartz.mm:579
void SetMarkerSize(Float_t markersize) override
Set the marker size.
Definition TGQuartz.mm:731
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:264
void DrawLinesSegmentsW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw line segments on specified window.
Definition TGQuartz.mm:383
void SetTextSize(Float_t textsize) override
Set the text size.
Definition TGQuartz.mm:798
void AlignTTFString(WinContext_t wctxt)
Definition TGQuartz.mm:875
void DrawPolyMarkerW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly marker on specified window.
Definition TGQuartz.mm:390
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:271
void DrawPolyLineW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly line on specified window.
Definition TGQuartz.mm:328
void SetLineStyle(Style_t linestyle) override
Set the line style.
Definition TGQuartz.mm:679
TAttFill & GetAttFill(WinContext_t wctxt)
Definition TGQuartz.mm:1211
Int_t GetFontDescent() const override
Returns the descent of the current font (in pixels.
Definition TGQuartz.mm:620
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:117
void DrawPolyMarker(Int_t n, TPoint *xy) override
Draws "n" markers with the current attributes at position [x,y].
Definition TGQuartz.mm:444
void * GetPixmapDrawable(void *drawable0, const char *calledFrom) const
Definition TGQuartz.mm:1251
void DrawFillAreaW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw fill area on specified window.
Definition TGQuartz.mm:195
TAttLine & GetAttLine(WinContext_t wctxt)
Definition TGQuartz.mm:1221
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:614
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition TTF.cxx:271
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:202
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition TTF.cxx:370
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition TTF.cxx:347
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition TTF.cxx:495
static Int_t GetAscent()
Definition TTF.cxx:628
static TTGlyph * GetGlyphs()
Definition TTF.cxx:663
static Int_t GetNumGlyphs()
Definition TTF.cxx:635
static Int_t GetWidth()
Definition TTF.cxx:621
static const FT_BBox & GetBox()
Definition TTF.cxx:656
static Bool_t GetSmoothing()
Definition TTF.cxx:607
static void SetTextSize(Float_t textsize)
Set current text size.
Definition TTF.cxx:566
static FT_Matrix * GetRotMatrix()
Definition TTF.cxx:642
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