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 "TMath.h"
45#include "TEnv.h"
46#include "TTF.h"
47
48// To scale fonts to the same size as the TTF version
49const Float_t kScale = 0.93376068;
50
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 if (!TTFhandle::Init())
83 Error("TGQuartz", "TTFhandle::Init() failed");
84
85 SetAA();
86}
87
88
89//______________________________________________________________________________
90TGQuartz::TGQuartz(const char *name, const char *title)
91 : TGCocoa(name, title),
92 fUseAA(true), fUseFAAA(false)
93{
94 //Constructor.
95 if (!TTFhandle::Init())
96 Error("TGQuartz", "TTFhandle::Init() failed");
97
98 SetAA();
99}
100
101//______________________________________________________________________________
103{
104 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
105 if (!drawable0)
106 return;
107
108 //Check some conditions first.
109 if ([drawable0 isDirectDraw]) {
110 if (!drawable0.fIsPixmap) {
111 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
112 if (!view) {
113 ::Warning("DrawBoxW", "Invalid view/window for XOR-mode");
114 return;
115 }
116
117 [view.fQuartzWindow addXorBox: view : x1 : y1 : x2 : y2];
118 }
119 return;
120 }
121
122 auto &attline = GetAttLine(wctxt);
123 auto &attfill = GetAttFill(wctxt);
124
125 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawBoxW");
126 if (!drawable)
127 return;
128
129 CGContextRef ctx = drawable.fContext;
131 //AA flag is not a part of a state.
133
134 //Go to low-left-corner system.
135 y1 = Int_t(X11::LocalYROOTToCocoa(drawable, y1));
136 y2 = Int_t(X11::LocalYROOTToCocoa(drawable, y2));
137
138 if (const TColorGradient * const gradient = dynamic_cast<TColorGradient *>(gROOT->GetColor(attfill.GetFillColor()))) {
139 //Draw a box with a gradient fill and a shadow.
140 //Ignore all fill styles and EBoxMode, use a gradient fill.
141 TPoint polygon[4];
142 polygon[0].fX = x1, polygon[0].fY = y1;
143 polygon[1].fX = x2, polygon[1].fY = y1;
144 polygon[2].fX = x2, polygon[2].fY = y2;
145 polygon[3].fX = x1, polygon[3].fY = y2;
146
147 Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
148 4, polygon, kFALSE); //kFALSE == don't draw a shadow.
149 } else {
150 const bool isHollow = mode == kHollow || attfill.GetFillStyle() / 1000 == 2;
151
152 //Note! Pattern index (and its address) MUST live
153 //long enough to be valid at the point of Quartz::DrawBox call!
154 unsigned patternIndex = 0;
155 if (isHollow) {
156 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
157 Error("DrawBoxW", "Can not find color for index %d", int(attline.GetLineColor()));
158 return;
159 }
160 } else {
162 Error("DrawBoxW", "SetFillAreaParameters failed");
163 return;
164 }
165 }
166 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
167 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
168 Quartz::DrawBox(ctx, x1, y1, x2, y2, isHollow);
169 }
170}
171
172
173//______________________________________________________________________________
178
179//______________________________________________________________________________
181{
182 //Comment from TVirtualX:
183
184 // Draw a filled area through all points.
185 // n : number of points
186 // xy : array of points
187
188 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
189 if (!drawable0)
190 return;
191
192 if (n < 3)
193 return;
194 // No fill area with direct drawing
195 if ([drawable0 isDirectDraw])
196 return;
197
198 auto &attfill = GetAttFill(wctxt);
199
200 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawFillAreaW");
201 if (!drawable)
202 return;
203
204 CGContextRef ctx = drawable.fContext;
205
206 //Convert points to bottom-left system:
208
210 //AA flag is not a part of a state.
212
213 if (drawable.fScaleFactor > 1.) {
214 // The CTM will be restored by 'ctxGuard'.
215 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
216 }
217
218 const TColor * const fillColor = gROOT->GetColor(attfill.GetFillColor());
219 if (!fillColor) {
220 Error("DrawFillAreaW", "Could not find TColor for index %d", attfill.GetFillColor());
221 return;
222 }
223
224 if (const TColorGradient * const gradient = dynamic_cast<const TColorGradient *>(fillColor)) {
225 Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
226 n, &fConvertedPoints[0], kFALSE);//kFALSE == don't draw a shadow.
227 } else {
228 unsigned patternIndex = 0;
230 Error("DrawFillAreaW", "SetFillAreaParameters failed");
231 return;
232 }
233
234 // kFALSE - do not draw shadows.
235 // last argument - fill style
237 }
238}
239
240
241//______________________________________________________________________________
246
247
248//______________________________________________________________________________
249void TGQuartz::DrawCellArray(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/,
250 Int_t /*nx*/, Int_t /*ny*/, Int_t */*ic*/)
251{
252 //Noop.
253}
254
255//______________________________________________________________________________
257{
258 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
259 if (!drawable0)
260 return;
261
262 if ([drawable0 isDirectDraw]) {
263 if (!drawable0.fIsPixmap) {
264 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
265 if (!view) {
266 ::Warning("DrawLineW", "Invalid view/window for XOR-mode");
267 return;
268 }
269
270 [view.fQuartzWindow addXorLine: view : x1 : y1 : x2 : y2];
271 }
272
273 return;
274 }
275
276 auto &attline = GetAttLine(wctxt);
277
278 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawLineW");
279 if (!drawable)
280 return;
281
282 CGContextRef ctx = drawable.fContext;
284 //AA flag is not a part of a state.
286
287 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
288 Error("DrawLineW", "Could not set line color for index %d", int(attline.GetLineColor()));
289 return;
290 }
291
292 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
293 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
294
296 X11::LocalYROOTToCocoa(drawable, y2));
297}
298
299//______________________________________________________________________________
301{
302 // Draw a line.
303 // x1,y1 : begin of line
304 // x2,y2 : end of line
305
306 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawLine, bad drawable is selected");
307
309}
310
311
312//______________________________________________________________________________
314{
315 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
316 if (!drawable0)
317 return;
318
319 //Some checks first.
320 if ([drawable0 isDirectDraw])
321 return;
322
323 auto &attline = GetAttLine(wctxt);
324
325 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawPolyLineW");
326 if (!drawable)
327 return;
328
329 CGContextRef ctx = drawable.fContext;
331 //AA flag is not a part of a state.
333
334 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
335 Error("DrawPolyLineW", "Could not find TColor for index %d", attline.GetLineColor());
336 return;
337 }
338
339 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
340 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
341
342 //Convert to bottom-left-corner system.
344
345 if (drawable.fScaleFactor > 1.)
346 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
347
349
350 // CTM (current transformation matrix) is restored by 'ctxGuard's dtor.
351}
352
353//______________________________________________________________________________
355{
356 //Comment from TVirtualX:
357 // Draw a line through all points.
358 // n : number of points
359 // xy : list of points
360 //End of comment.
361
362 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawPolyLine, bad drawable is selected");
363
365}
366
367//______________________________________________________________________________
369{
370 for(Int_t i = 0; i < 2*n; i += 2)
371 DrawPolyLineW(wctxt, 2, &xy[i]);
372}
373
374//______________________________________________________________________________
376{
377 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
378 if (!drawable0)
379 return;
380
381 //Do some checks first.
382 if ([drawable0 isDirectDraw])
383 return;
384
385 auto &attmark = GetAttMarker(wctxt);
386
387 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawPolyMarkerW");
388 if (!drawable)
389 return;
390
391 CGContextRef ctx = drawable.fContext;
393 //AA flag is not a part of a state.
395
396 if (!Quartz::SetFillColor(ctx, attmark.GetMarkerColor())) {
397 Error("DrawPolyMarker", "Could not find TColor for index %d", attmark.GetMarkerColor());
398 return;
399 }
400
401 Quartz::SetLineColor(ctx, attmark.GetMarkerColor());//Can not fail (for coverity).
402 Quartz::SetLineStyle(ctx, 1);
404
406
407 if (drawable.fScaleFactor > 1.)
408 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
409
411
412 // The fast pixel markers need to be treated separately
413 if (markerstyle == 1 || markerstyle == 6 || markerstyle == 7) {
416 } else {
419 }
420
422 Quartz::DrawPolyMarker(ctx, n, &fConvertedPoints[0], MarkerSizeReduced * drawable.fScaleFactor, markerstyle);
423
426}
427
428//______________________________________________________________________________
430{
431 //Comment from TVirtualX:
432 // Draw PolyMarker
433 // n : number of points
434 // xy : list of points
435 //End of comment.
436
438}
439
440
441//______________________________________________________________________________
442
443std::vector<UniChar> quartz_get_greek_unicars(const char *text)
444{
445 //This is a hack. Correct way is to extract glyphs from symbol.ttf,
446 //find correct mapping, place this glyphs. This requires manual layout though (?),
447 //and as usually, I have to many things to do, may be, one day I'll fix text rendering also.
448 //This hack work only on MacOSX 10.7.3, does not work on iOS and I'm not sure about future/previous
449 //versions of MacOSX.
450 std::vector<UniChar> unichars(std::strlen(text));
451 for (std::size_t i = 0; i < unichars.size(); ++i)
452 unichars[i] = 0xF000 + (unsigned char)text[i];
453 return unichars;
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) {
489 //Greek and math symbols.
492 ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y), atttext);
493 } else {
494 const Quartz::TextLine ctLine(text, currentFont, atttext.GetTextColor());
495 ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y), atttext);
496 }
497 }
498 } catch (const std::exception &e) {
499 Error("DrawTextW", "Exception from Quartz::TextLine: %s", e.what());
500 }
501}
502
503//______________________________________________________________________________
509
510//______________________________________________________________________________
512 const wchar_t *text, ETextMode mode)
513{
514 if (!text || !*text)
515 return;
516
517 if (!TTFhandle::Init()) {
518 Error("DrawTextW", "wchar_t string to draw, but TTF initialization failed");
519 return;
520 }
521
522 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
523 if (!drawable0)
524 return;
525
526 if ([drawable0 isDirectDraw])
527 return;
528
529 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawTextW");
530 if (!drawable)
531 return;
532
533
534 //Do not draw anything, or CoreText will create some small (but not of size 0 font).
535 auto &att = GetAttText(wctxt);
536
537 if (att.GetTextSize() < 1.5)//Do not draw anything, or CoreText will create some small (but not of size 0 font).
538 return;
539
541
543
544 ttf.SetTextFont(att.GetTextFont());
545 ttf.SetTextSize(att.GetTextSize());
546 ttf.SetRotationMatrix(angle);
547 ttf.PrepareString(text);
548 ttf.LayoutGlyphs();
549
550 Int_t txalh = att.GetTextAlign() / 10;
551 Int_t txalv = att.GetTextAlign() % 10;
552 FT_Vector align_vect; ///< alignment vector
553
554 // const EAlign align = EAlign(fTextAlign);
555 // vertical alignment
556 if (txalv == 3) // align == kTLeft || align == kTCenter || align == kTRight)
557 align_vect.y = ttf.GetAscent();
558 else if (txalv == 2) // if (align == kMLeft || align == kMCenter || align == kMRight) {
559 align_vect.y = ttf.GetAscent() / 2;
560 else
561 align_vect.y = 0;
562
563 // horizontal alignment
564 if (txalh == 3) // align == kTRight || align == kMRight || align == kBRight) {
565 align_vect.x = ttf.GetWidth();
566 else if (txalh == 2) // (align == kTCenter || align == kMCenter || align == kBCenter) {
567 align_vect.x = ttf.GetWidth() / 2;
568 else
569 align_vect.x = 0;
570
571 FT_Vector_Transform(&align_vect, ttf.GetRotMatrix());
572 //This shift is from the original code.
573 align_vect.x = align_vect.x >> 6;
574 align_vect.y = align_vect.y >> 6;
575
576
577 //This code is a modified (for Quartz) version of TG11TTF text drawing
578
580 if ([drawable isKindOfClass : [QuartzPixmap class]])
581 dstPixmap = (QuartzPixmap *)drawable;
582 else if ([drawable isKindOfClass : [QuartzView class]] || [drawable isKindOfClass : [QuartzWindow class]])
583 dstPixmap = ((NSObject<X11Window> *)drawable).fBackBuffer;
584
585 if (!dstPixmap) {
586 //I can not read pixels from a window (I can, but this is too slow and unreliable).
587 Error("DrawTextW", "fSelectedDrawable is neither QuartzPixmap nor a double buffered window");
588 return;
589 }
590
591 //Comment from TGX11TTF:
592 // compute the size and position of the XImage that will contain the text
593 const Int_t xOff = TMath::Max(0, (Int_t) -ttf.GetBox().xMin);
594 const Int_t yOff = TMath::Max(0, (Int_t) -ttf.GetBox().yMin);
595
596 const Int_t w = ttf.GetBox().xMax + xOff;
597 const Int_t h = ttf.GetBox().yMax + yOff;
598
599 // If w or h is 0, very likely the string is only blank characters
600 if (w <= 0 || h <= 0)
601 return;
602
603 const Int_t x1 = x - xOff - align_vect.x;
604 const Int_t y1 = y + yOff + align_vect.y - h;
605
606 UInt_t width = 0, height = 0;
607 Int_t xy = 0;
608
610
611 // If string falls outside window, there is probably no need to draw it.
613 return;
614
615 //By default, all pixels are set to 0 (all components, that's what code in TGX11TTF also does here).
617 if (!pixmap.Get()) {
618 Error("DrawTextW", "pixmap creation failed");
619 return;
620 }
621
622 const unsigned char defaultBackgroundPixel[] = {255, 255, 255, 255};
624 if (mode == kClear) {
625 //For this mode, TGX11TTF does some work to: a) preserve pixels under symbols
626 //b) calculate (interpolate) pixel for glyphs.
627
628 X11::Rectangle bbox(x1, y1, w, h);
629 //We already check IsVisible, so, in principle, bbox at least has intersection with
630 //the current selected drawable.
632 arrayGuard.Reset([dstPixmap readColorBits : bbox]);
633
634 if (!arrayGuard.Get()) {
635 Error("DrawTextW", "problem with reading background pixels");
636 return;
637 }
638
639 // This is copy & paste from TGX11TTF:
640 const Int_t xo = x1 < 0 ? -x1 : 0;
641 const Int_t yo = y1 < 0 ? -y1 : 0;
642
643 for (int yp = 0; yp < int(bbox.fHeight) && yo + yp < h; ++yp) {
644 const unsigned char *srcBase = arrayGuard.Get() + bbox.fWidth * yp * 4;
645 for (int xp = 0; xp < int(bbox.fWidth) && xo + xp < w; ++xp) {
646 const unsigned char * const pixel = srcBase + xp * 4;
647 [pixmap.Get() putPixel : pixel X : xo + xp Y : yo + yp];
648 }
649 }
650 } else {
651 //Find background color and set for all pixels.
653 }
654
655 CGContextRef ctx = drawable.fContext;
657
658 CGContextSetRGBStrokeColor(ctx, 0., 0., 1., 1.);
659 // paint the glyphs in the pixmap.
660 for (UInt_t n = 0; n < ttf.GetNumGlyphs(); ++n) {
661 if (auto bitmap = ttf.GetGlyphBitmap(n)) {
662 const Int_t bx = bitmap->left + xOff;
663 const Int_t by = h - bitmap->top - yOff;
664
665 DrawFTGlyph(pixmap.Get(), &bitmap->bitmap, TGCocoa::GetPixel(att.GetTextColor()),
666 mode == kClear ? ULong_t(-1) : 0xffffff, bx, by);
667 }
668 }
669
670 const X11::Rectangle copyArea(0, 0, w, h);
671 const X11::Point dstPoint(x1, y1);
673}
674
675//______________________________________________________________________________
681
682//______________________________________________________________________________
684{
685 // Returns the size of the specified character string "mess".
686 //
687 // w - the text width
688 // h - the text height
689 // text - the string
690
691 w = h = 0;
692
693 if (!text || !*text)
694 return;
695
696 auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize());
697 if (!fontref)
698 return;
699 const unsigned fontIndex = GetTextFont() / 10;
700 if (fontIndex == 12 || fontIndex == 15) {
701 //Greek and math symbols.
703 fPimpl->fFontManager.GetTextBounds(fontref, w, h, unichars);
704 } else {
705 fPimpl->fFontManager.GetTextBounds(fontref, w, h, text);
706 }
707}
708
709//______________________________________________________________________________
711{
712 if (!text || !*text) {
713 w = h = 0;
714 return kTRUE;
715 }
716
717 auto fontref = fPimpl->fFontManager.SelectFont(font, kScale * size);
718 if (!fontref)
719 return kFALSE;
720
721 const unsigned fontIndex = font / 10;
722 if (fontIndex == 12 || fontIndex == 15) {
723 //Greek and math symbols.
725 fPimpl->fFontManager.GetTextBounds(fontref, w, h, unichars);
726 } else {
727 fPimpl->fFontManager.GetTextBounds(fontref, w, h, text);
728 }
729
730 return kTRUE;
731}
732
733//______________________________________________________________________________
735{
736 // do not handle wchar, pad painter will switch to TTF
737 w = h = 0;
738 return kFALSE;
739}
740
741
742//______________________________________________________________________________
744{
745 // Returns the ascent of the current font (in pixels).
746 // The ascent of a font is the distance from the baseline
747 // to the highest position characters extend to.
748 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
749 return Int_t(fPimpl->fFontManager.GetAscent(fontref));
750
751 return 0;
752}
753
754//______________________________________________________________________________
756{
757 // Returns the ascent of the current font (in pixels).
758 // The ascent of a font is the distance from the baseline
759 // to the highest position characters extend to.
760
761 //In case of any problem we can always resort to the old version:
762 if (!text || !*text)
763 return GetFontAscent();
764
765 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
766 const unsigned fontIndex = GetTextFont() / 10;
767 if (fontIndex == 12 || fontIndex == 15) {
768 //Greek and math symbols.
770 return Int_t(fPimpl->fFontManager.GetAscent(fontref, unichars));
771 } else
772 return Int_t(fPimpl->fFontManager.GetAscent(fontref, text));
773 }
774
775 return 0;
776}
777
778//______________________________________________________________________________
780{
781 // Returns the descent of the current font (in pixels.
782 // The descent is the distance from the base line
783 // to the lowest point characters extend to.
784 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
785 return Int_t(fPimpl->fFontManager.GetDescent(fontref));
786
787 return 0;
788}
789
790//______________________________________________________________________________
792{
793 // Returns the descent of the current font (in pixels.
794 // The descent is the distance from the base line
795 // to the lowest point characters extend to.
796
797 //That's how it's tested in ROOT:
798 if (!text || !*text)
799 return GetFontDescent();
800
801 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
802 const unsigned fontIndex = GetTextFont() / 10;
803 if (fontIndex == 12 || fontIndex == 15) {
804 //Greek and math symbols.
806 return Int_t(fPimpl->fFontManager.GetDescent(fontref, unichars));
807 } else
808 return Int_t(fPimpl->fFontManager.GetDescent(fontref, text));
809 }
810
811 return 0;
812}
813
814//______________________________________________________________________________
816{
817 a = d = 0;
818
819 auto fontref = fPimpl->fFontManager.SelectFont(font, kScale * size);
820 if (!fontref)
821 return kFALSE;
822
823 const unsigned fontIndex = font / 10;
824 if (!text || !*text) {
825 a = fPimpl->fFontManager.GetAscent(fontref);
826 d = fPimpl->fFontManager.GetDescent(fontref);
827 } else if (fontIndex == 12 || fontIndex == 15) {
828 //Greek and math symbols.
830 a = fPimpl->fFontManager.GetAscent(fontref, unichars);
831 d = fPimpl->fFontManager.GetDescent(fontref, unichars);
832 } else {
833 a = fPimpl->fFontManager.GetAscent(fontref, text);
834 d = fPimpl->fFontManager.GetDescent(fontref, text);
835 }
836
837 return kTRUE;
838}
839
840
841//______________________________________________________________________________
843{
844 // Returns the current font magnification factor
845 return 0;
846}
847
848//______________________________________________________________________________
850{
851 // Set color index "cindex" for drawing lines.
853
855}
856
857
858//______________________________________________________________________________
860{
861 // Set line style.
863
865}
866
867
868//______________________________________________________________________________
870{
871 // Set the line width.
872
874
876}
877
878
879//______________________________________________________________________________
881{
882 // Set color index "cindex" for fill areas.
883
885
887}
888
889
890//______________________________________________________________________________
892{
893 // Set fill area style.
895
897}
898
899
900//______________________________________________________________________________
902{
903 // Set color index "cindex" for markers.
905
907}
908
909
910//______________________________________________________________________________
912{
913 // Set marker size index.
914 //
915 // markersize - the marker scale factor
917
919}
920
921
922//______________________________________________________________________________
924{
925 // Set marker style.
926
928
930}
931
932
933//______________________________________________________________________________
935{
936 // Set the text alignment.
937
939
941}
942
943//______________________________________________________________________________
945{
946 // Set the color index "cindex" for text.
947
949
951}
952
953
954//______________________________________________________________________________
956{
957 // Set the current text font number.
958
960
962}
963
964//______________________________________________________________________________
965Int_t TGQuartz::SetTextFont(char * /* fontName */, ETextSetMode /* mode */)
966{
967 Error("SetTextFont", "Direct TTF font setting not supported");
968 return 1;
969}
970
971//______________________________________________________________________________
973{
974 // Set the current text size to "textsize"
975
977
979}
980
981//______________________________________________________________________________
983{
984 // Set opacity of the current window. This image manipulation routine
985 // works by adding to a percent amount of neutral to each pixels RGB.
986 // Since it requires quite some additional color map entries is it
987 // only supported on displays with more than > 8 color planes (> 256
988 // colors).
989}
990
991//______________________________________________________________________________
992void TGQuartz::SetOpacityW(WinContext_t /* wctxt */, Int_t /* percent */)
993{
994}
995
996//______________________________________________________________________________
998{
999 att.Copy(GetAttFill(wctxt));
1000
1001 // TODO: remove this after transition done
1002 TAttFill::SetFillColor(att.GetFillColor());
1003 TAttFill::SetFillStyle(att.GetFillStyle());
1004}
1005
1006//______________________________________________________________________________
1008{
1009 att.Copy(GetAttLine(wctxt));
1010
1011 // TODO: remove this after transition done
1012 TAttLine::SetLineColor(att.GetLineColor());
1013 TAttLine::SetLineStyle(att.GetLineStyle());
1014 TAttLine::SetLineWidth(att.GetLineWidth());
1015}
1016
1017//______________________________________________________________________________
1019{
1020 att.Copy(GetAttMarker(wctxt));
1021
1022 // TODO: remove this after transition done
1023 TAttMarker::SetMarkerColor(att.GetMarkerColor());
1024 TAttMarker::SetMarkerSize(att.GetMarkerSize());
1025 TAttMarker::SetMarkerStyle(att.GetMarkerStyle());
1026}
1027
1028//______________________________________________________________________________
1030{
1031 att.Copy(GetAttText(wctxt));
1032
1033 // TODO: remove this after transition done
1034 TAttText::SetTextAlign(att.GetTextAlign());
1035 TAttText::SetTextAngle(att.GetTextAngle());
1036 TAttText::SetTextColor(att.GetTextColor());
1037 TAttText::SetTextSize(att.GetTextSize());
1038 TAttText::SetTextFont(att.GetTextFont());
1039}
1040
1041//TTF related part.
1042
1043//______________________________________________________________________________
1045{
1046 //This function is a "remake" of TGX11FFT::DrawImage.
1047
1048 //I'm using this code to reproduce the same text as generated by TGX11TTF.
1049 //It's quite sloppy, as in original version. I tried to make it not so ugly and
1050 //more or less readable.
1051
1052 auto pixmap = (QuartzPixmap *)_pixmap;
1053 auto source = (FT_Bitmap *) _source;
1054 assert(pixmap != nil && "DrawFTGlyph, pixmap parameter is nil");
1055 assert(source != nil && "DrawFTGlyph, source parameter is null");
1056
1058 ColorStruct_t col[5];
1059 // background kClear, i.e. transparent, we take as background color
1060 // the average of the rgb values of all pixels covered by this character
1061 if (back == ULong_t(-1)) {
1062 const UInt_t maxDots = TMath::Min((UInt_t) 50000, source->width * source->rows);
1063
1064 //In original code, they first have to extract
1065 //pixels and call XQueryColors.
1066 //I have only one loop here.
1067 ULong_t r = 0, g = 0, b = 0;
1068 UInt_t dotCnt = 0;
1069 for (unsigned y = 0; y < source->rows; y++) {
1070 for (unsigned x = 0; x < source->width; x++) {
1071 if (x + bx < pixmap.fWidth && y + by < pixmap.fHeight) {
1072 const unsigned char * const pixels = pixmap.fData + (y + by) * pixmap.fWidth * 4 + (x + bx) * 4;
1073 r += UShort_t(pixels[0] / 255. * 0xffff);
1074 g += UShort_t(pixels[1] / 255. * 0xffff);
1075 b += UShort_t(pixels[2] / 255. * 0xffff);
1076 if (++dotCnt >= maxDots)
1077 break;
1078 }
1079 }
1080 }
1081
1082 if (dotCnt > 0) {
1083 r /= dotCnt;
1084 g /= dotCnt;
1085 b /= dotCnt;
1086 }
1087
1088 col[0].fRed = (UShort_t) r;
1089 col[0].fGreen = (UShort_t) g;
1090 col[0].fBlue = (UShort_t) b;
1091 } else {
1092 // request background color
1093 col[0].fPixel = back;
1094 TGCocoa::QueryColor(kNone, col[0]);
1095 }
1096
1097 // request foreground color
1098 col[4].fPixel = fore;
1099 TGCocoa::QueryColor(kNone, col[4]);//calculate fRed/fGreen/fBlue triple from fPixel.
1100
1101 // interpolate between fore and background colors
1102 for (int x = 3; x > 0; --x) {
1103 col[x].fRed = (col[4].fRed * x + col[0].fRed * (4 - x)) / 4;
1104 col[x].fGreen = (col[4].fGreen * x + col[0].fGreen * (4 - x)) / 4;
1105 col[x].fBlue = (col[4].fBlue * x + col[0].fBlue * (4 - x)) / 4;
1106 TGCocoa::AllocColor(kNone, col[x]);//Calculate fPixel from fRed/fGreen/fBlue triplet.
1107 }
1108
1109 // put smoothed character, character pixmap values are an index
1110 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
1111 const unsigned char *s = source->buffer;
1112 for (unsigned y = 0; y < source->rows; ++y) {
1113 for (unsigned x = 0; x < source->width; ++x) {
1114 unsigned char d = (((*s++ & 0xff) + 10) * 5) / 256;
1115 if (d > 4)
1116 d = 4;
1117 if (d > 0) {
1118 const UChar_t pixel[] = {UChar_t(double(col[d].fRed) / 0xffff * 255),
1119 UChar_t(double(col[d].fGreen) / 0xffff * 255),
1120 UChar_t(double(col[d].fBlue) / 0xffff * 255), 255};
1121 [pixmap putPixel : pixel X : bx + x Y : by + y];
1122 }
1123 }
1124 }
1125 } else {
1126 // no smoothing, just put character using foreground color
1127 unsigned char rgba[4] = {};
1128 rgba[3] = 255;
1130 unsigned char d = 0;
1131
1132 const unsigned char *row = source->buffer;
1133 for (unsigned y = 0; y < source->rows; ++y) {
1134 unsigned n = 0;
1135 const unsigned char *s = row;
1136 for (unsigned x = 0; x < source->width; ++x) {
1137 if (!n)
1138 d = *s++;
1139
1140 if (TESTBIT(d,7 - n))
1141 [pixmap putPixel : rgba X : bx + x Y : by + y];
1142
1143 if (++n == kBitsPerByte)
1144 n = 0;
1145 }
1146
1147 row += source->pitch;
1148 }
1149 }
1150}
1151
1152//Aux. functions.
1153
1154//______________________________________________________________________________
1156{
1157 if (gEnv) {
1158 const TString value(TString(gEnv->GetValue("Cocoa.EnableAntiAliasing", "auto")).Strip());
1159 if (value == "auto") {
1160 [[NSScreen mainScreen] backingScaleFactor] > 1. ? fUseAA = true : fUseAA = false;
1161 } else if (value == "no")
1162 fUseAA = false;
1163 else {
1164 assert(value == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1165 fUseAA = true;
1166 }
1167 const TString valuefa(TString(gEnv->GetValue("Cocoa.EnableFillAreaAntiAliasing", "auto")).Strip());
1168 if (valuefa == "auto") {
1170 } else if (valuefa == "no")
1171 fUseFAAA = false;
1172 else {
1173 assert(valuefa == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1174 fUseFAAA = true;
1175 }
1176 }
1177}
1178
1179//______________________________________________________________________________
1181{
1182 // attributes stored in direct drawable (view) and not in underlying pixmap
1183 auto drawable = (NSObject<X11Drawable> *) wctxt;
1184 if (!drawable || !drawable.attFill)
1185 return *this;
1186 return *drawable.attFill;
1187}
1188
1189//______________________________________________________________________________
1191{
1192 // attributes stored in direct drawable (view) and not in underlying pixmap
1193 auto drawable = (NSObject<X11Drawable> *) wctxt;
1194 if (!drawable || !drawable.attLine)
1195 return *this;
1196 return *drawable.attLine;
1197}
1198
1199//______________________________________________________________________________
1201{
1202 // attributes stored in direct drawable (view) and not in underlying pixmap
1203 auto drawable = (NSObject<X11Drawable> *) wctxt;
1204 if (!drawable || !drawable.attMarker)
1205 return *this;
1206 return *drawable.attMarker;
1207}
1208
1209//______________________________________________________________________________
1211{
1212 // attributes stored in direct drawable (view) and not in underlying pixmap
1213 auto drawable = (NSObject<X11Drawable> *) wctxt;
1214 if (!drawable || !drawable.attText)
1215 return *this;
1216 return *drawable.attText;
1217}
1218
1219//______________________________________________________________________________
1220void *TGQuartz::GetPixmapDrawable(void *drawable0, const char *calledFrom) const
1221{
1222 assert(calledFrom != 0 && "GetDrawableChecked, calledFrom parameter is null");
1223
1224 if (!drawable0)
1225 return nullptr;
1226
1227 auto drawable = (NSObject<X11Drawable> *) drawable0;
1228 if (!drawable.fIsPixmap) {
1229 //TPad/TCanvas ALWAYS draw only into a pixmap.
1230 if ([drawable isKindOfClass : [QuartzView class]]) {
1231 QuartzView *view = (QuartzView *)drawable;
1232 if (!view.fBackBuffer) {
1233 Error(calledFrom, "Selected window is not double buffered");
1234 return nullptr;
1235 }
1236
1237 drawable = view.fBackBuffer;
1238 } else {
1239 Error(calledFrom, "Selected drawable is neither a pixmap, nor a double buffered window");
1240 return nullptr;
1241 }
1242 }
1243
1244 if (!drawable.fContext) {
1245 Error(calledFrom, "Context is null");
1246 return nullptr;
1247 }
1248
1249 return drawable;
1250}
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
Handle_t Drawable_t
Drawable handle.
Definition GuiTypes.h:32
const Handle_t kNone
Definition GuiTypes.h:89
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Style_t
Style number (short)
Definition RtypesCore.h:96
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:54
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
constexpr ULong_t kBitsPerByte
Definition RtypesCore.h:130
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
short Width_t
Line width (short)
Definition RtypesCore.h:98
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
short Font_t
Font number (short)
Definition RtypesCore.h:95
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
short SCoord_t
Screen coordinates (short)
Definition RtypesCore.h:100
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define TESTBIT(n, i)
Definition Rtypes.h:94
const Float_t kScale
Definition TASImage.cxx:135
#define X(type, name)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
const Float_t kScale
Definition TGQuartz.mm:49
std::vector< UniChar > quartz_get_greek_unicars(const char *text)
Definition TGQuartz.mm:443
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t GetWindowSize
Option_t Option_t cindex
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t mgn
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t markerstyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char bitmap
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t textsize
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t width
Option_t Option_t style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:148
#define gROOT
Definition TROOT.h:417
Fill Area Attributes class.
Definition TAttFill.h:21
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
Line Attributes class.
Definition TAttLine.h:21
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:46
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
Marker Attributes class.
Definition TAttMarker.h:21
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:41
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:35
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:43
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:48
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
Text Attributes class.
Definition TAttText.h:21
virtual Float_t GetTextSize() const
Return the text size.
Definition TAttText.h:39
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:48
virtual Font_t GetTextFont() const
Return the text font.
Definition TAttText.h:38
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition TAttText.h:49
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:50
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:52
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:53
TColorGradient extends basic TColor.
The color creation and management class.
Definition TColor.h:22
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:503
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D.
Definition TGCocoa.h:57
Bool_t AllocColor(Colormap_t cmap, ColorStruct_t &color) override
Allocates a read-only colormap entry corresponding to the closest RGB value supported by the hardware...
Definition TGCocoa.mm:2978
std::unique_ptr< ROOT::MacOSX::Details::CocoaPrivate > fPimpl
!
Definition TGCocoa.h:451
void QueryColor(Colormap_t cmap, ColorStruct_t &color) override
Returns the current RGB value for the pixel in the "color" structure.
Definition TGCocoa.mm:2988
WinContext_t GetSelectedContext()
Definition TGCocoa.mm:693
Drawable_t fSelectedDrawable
Definition TGCocoa.h:449
ULong_t GetPixel(Color_t cindex) override
Returns pixel value associated to specified ROOT color number "cindex".
Definition TGCocoa.mm:3003
void SetLineWidth(Width_t width) override
Set the line width.
Definition TGQuartz.mm:869
TAttMarker & GetAttMarker(WinContext_t wctxt)
Definition TGQuartz.mm:1200
bool fUseFAAA
Definition TGQuartz.h:109
void SetAttLine(WinContext_t wctxt, const TAttLine &att) override
Set line attributes for specified window.
Definition TGQuartz.mm:1007
void DrawFTGlyph(void *pixmap, void *source, ULong_t fore, ULong_t back, Int_t bx, Int_t by)
Definition TGQuartz.mm:1044
void SetMarkerColor(Color_t cindex) override
Set the marker color.
Definition TGQuartz.mm:901
void SetFillStyle(Style_t style) override
Set the fill area style.
Definition TGQuartz.mm:891
void SetOpacity(Int_t percent) override
Sets opacity of the current window.
Definition TGQuartz.mm:982
void SetFillColor(Color_t cindex) override
Set the fill area color.
Definition TGQuartz.mm:880
void DrawPolyLine(Int_t n, TPoint *xy) override
Draws a line through all points in the list.
Definition TGQuartz.mm:354
Float_t GetTextMagnitude() override
Returns the current font magnification factor.
Definition TGQuartz.mm:842
void SetAttText(WinContext_t wctxt, const TAttText &att) override
Set text attributes for specified window.
Definition TGQuartz.mm:1029
void SetAA()
Definition TGQuartz.mm:1155
void DrawFillArea(Int_t n, TPoint *xy) override
Fills area described by the polygon.
Definition TGQuartz.mm:242
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:504
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draws a line.
Definition TGQuartz.mm:300
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:944
Bool_t GetTextExtentA(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const char *mess) override
Returns the size of the specified character string "mess" for font and size.
Definition TGQuartz.mm:710
void SetMarkerStyle(Style_t markerstyle) override
Set the marker style.
Definition TGQuartz.mm:923
bool fUseAA
Definition TGQuartz.h:108
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:174
void SetAttFill(WinContext_t wctxt, const TAttFill &att) override
Set fill attributes for specified window.
Definition TGQuartz.mm:997
std::vector< TPoint > fConvertedPoints
Definition TGQuartz.h:100
void SetTextAlign(Short_t talign=11) override
Set the text alignment.
Definition TGQuartz.mm:934
TAttText & GetAttText(WinContext_t wctxt)
Definition TGQuartz.mm:1210
void SetLineColor(Color_t cindex) override
Set the line color.
Definition TGQuartz.mm:849
void SetTextFont(Font_t fontnumber) override
Set the text font.
Definition TGQuartz.mm:955
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override
Set marker attributes for specified window.
Definition TGQuartz.mm:1018
void GetTextExtent(UInt_t &w, UInt_t &h, char *text) override
Returns the size of the specified character string "mess".
Definition TGQuartz.mm:683
Int_t GetFontAscent() const override
Returns the ascent of the current font (in pixels).
Definition TGQuartz.mm:743
void SetMarkerSize(Float_t markersize) override
Set the marker size.
Definition TGQuartz.mm:911
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:249
void DrawLinesSegmentsW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw line segments on specified window.
Definition TGQuartz.mm:368
void SetTextSize(Float_t textsize) override
Set the text size.
Definition TGQuartz.mm:972
Bool_t GetFontAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const char *mess) override
Returns ascent/descent for specified character string "mess" with font and size.
Definition TGQuartz.mm:815
void DrawPolyMarkerW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly marker on specified window.
Definition TGQuartz.mm:375
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:256
void DrawPolyLineW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly line on specified window.
Definition TGQuartz.mm:313
void SetLineStyle(Style_t linestyle) override
Set the line style.
Definition TGQuartz.mm:859
TAttFill & GetAttFill(WinContext_t wctxt)
Definition TGQuartz.mm:1180
Int_t GetFontDescent() const override
Returns the descent of the current font (in pixels.
Definition TGQuartz.mm:779
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:102
void SetOpacityW(WinContext_t wctxt, Int_t percent) override
Set opactity for specified window.
Definition TGQuartz.mm:992
void DrawPolyMarker(Int_t n, TPoint *xy) override
Draws "n" markers with the current attributes at position [x,y].
Definition TGQuartz.mm:429
void * GetPixmapDrawable(void *drawable0, const char *calledFrom) const
Definition TGQuartz.mm:1220
void DrawFillAreaW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw fill area on specified window.
Definition TGQuartz.mm:180
TAttLine & GetAttLine(WinContext_t wctxt)
Definition TGQuartz.mm:1190
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
Dynamic handle to work with freetype 2 library.
Definition TTF.h:119
static Bool_t Init()
Definition TTF.cxx:587
static Bool_t GetSmoothing()
Definition TTF.cxx:602
static void SetSmoothing(Bool_t state)
Definition TTF.cxx:616
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
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
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