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