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 std::vector<TPoint> pnts;
207
208 //Convert points to bottom-left system:
209 ConvertPointsROOTToCocoa(n, xy, pnts, drawable);
210
212 //AA flag is not a part of a state.
214
215 if (drawable.fScaleFactor > 1.) {
216 // The CTM will be restored by 'ctxGuard'.
217 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
218 }
219
220 const TColor * const fillColor = gROOT->GetColor(attfill.GetFillColor());
221 if (!fillColor) {
222 Error("DrawFillAreaW", "Could not find TColor for index %d", attfill.GetFillColor());
223 return;
224 }
225
226 if (const TColorGradient * const gradient = dynamic_cast<const TColorGradient *>(fillColor)) {
227 Quartz::DrawPolygonWithGradientFill(ctx, gradient, CGSizeMake(drawable.fWidth, drawable.fHeight),
228 pnts.size(), pnts.data(), kFALSE);//kFALSE == don't draw a shadow.
229 } else {
230 unsigned patternIndex = 0;
232 Error("DrawFillAreaW", "SetFillAreaParameters failed");
233 return;
234 }
235
236 // kFALSE - do not draw shadows.
237 // last argument - fill style
238 Quartz::DrawFillArea(ctx, pnts.size(), pnts.data(), kFALSE, attfill);
239 }
240}
241
242
243//______________________________________________________________________________
248
249
250//______________________________________________________________________________
251void TGQuartz::DrawCellArray(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/,
252 Int_t /*nx*/, Int_t /*ny*/, Int_t */*ic*/)
253{
254 //Noop.
255}
256
257//______________________________________________________________________________
259{
260 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
261 if (!drawable0)
262 return;
263
264 if ([drawable0 isDirectDraw]) {
265 if (!drawable0.fIsPixmap) {
266 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
267 if (!view) {
268 ::Warning("DrawLineW", "Invalid view/window for XOR-mode");
269 return;
270 }
271
272 [view.fQuartzWindow addXorLine: view : x1 : y1 : x2 : y2];
273 }
274
275 return;
276 }
277
278 auto &attline = GetAttLine(wctxt);
279
280 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawLineW");
281 if (!drawable)
282 return;
283
284 CGContextRef ctx = drawable.fContext;
286 //AA flag is not a part of a state.
288
289 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
290 Error("DrawLineW", "Could not set line color for index %d", int(attline.GetLineColor()));
291 return;
292 }
293
294 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
295 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
296
298 X11::LocalYROOTToCocoa(drawable, y2));
299}
300
301//______________________________________________________________________________
303{
304 // Draw a line.
305 // x1,y1 : begin of line
306 // x2,y2 : end of line
307
308 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawLine, bad drawable is selected");
309
311}
312
313
314//______________________________________________________________________________
316{
317 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
318 if (!drawable0)
319 return;
320
321 auto &attline = GetAttLine(wctxt);
322
323 //Some checks first.
324 if ([drawable0 isDirectDraw]) {
325 if (!drawable0.fIsPixmap) {
326 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
327 if (!view) {
328 ::Warning("DrawPolyLineW", "Invalid view/window for XOR-mode");
329 return;
330 }
331
332 [view.fQuartzWindow addXorPolyLine: view : n : xy : attline ];
333 }
334
335 return;
336 }
337
338 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawPolyLineW");
339 if (!drawable)
340 return;
341
342 CGContextRef ctx = drawable.fContext;
344 //AA flag is not a part of a state.
346
347 if (!Quartz::SetLineColor(ctx, attline.GetLineColor())) {
348 Error("DrawPolyLineW", "Could not find TColor for index %d", attline.GetLineColor());
349 return;
350 }
351
352 Quartz::SetLineStyle(ctx, attline.GetLineStyle());
353 Quartz::SetLineWidth(ctx, attline.GetLineWidth());
354
355 std::vector<TPoint> pnts;
356
357 //Convert to bottom-left-corner system.
358 ConvertPointsROOTToCocoa(n, xy, pnts, drawable);
359
360 if (drawable.fScaleFactor > 1.)
361 CGContextScaleCTM(ctx, 1. / drawable.fScaleFactor, 1. / drawable.fScaleFactor);
362
363 Quartz::DrawPolyLine(ctx, pnts.size(), pnts.data());
364
365 // CTM (current transformation matrix) is restored by 'ctxGuard's dtor.
366}
367
368//______________________________________________________________________________
370{
371 //Comment from TVirtualX:
372 // Draw a line through all points.
373 // n : number of points
374 // xy : list of points
375 //End of comment.
376
377 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "DrawPolyLine, bad drawable is selected");
378
380}
381
382//______________________________________________________________________________
384{
385 for(Int_t i = 0; i < 2*n; i += 2)
386 DrawPolyLineW(wctxt, 2, &xy[i]);
387}
388
389//______________________________________________________________________________
391{
392 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
393 if (!drawable0)
394 return;
395
396 auto &attmark = GetAttMarker(wctxt);
397
398 if ([drawable0 isDirectDraw]) {
399 if (!drawable0.fIsPixmap) {
400 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(drawable0.fID).fContentView;
401 if (!view) {
402 ::Warning("DrawPolyMarkerW", "Invalid view/window for XOR-mode");
403 return;
404 }
405
406 [view.fQuartzWindow addXorMarker: view : n : xy : attmark ];
407 }
408
409 return;
410 }
411 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawPolyMarkerW");
412 if (!drawable)
413 return;
414
415 std::vector<TPoint> pnts;
416
417 ConvertPointsROOTToCocoa(n, xy, pnts, drawable);
418
419 CGContextRef ctx = drawable.fContext;
421 //AA flag is not a part of a state.
423
424 Quartz::DrawPolyMarker(ctx, pnts.size(), pnts.data(), attmark, drawable.fScaleFactor);
425}
426
427//______________________________________________________________________________
429{
430 //Comment from TVirtualX:
431 // Draw PolyMarker
432 // n : number of points
433 // xy : list of points
434 //End of comment.
435
437}
438
439
440//______________________________________________________________________________
441
442std::vector<UniChar> quartz_get_greek_unicars(const char *text)
443{
444 //This is a hack. Correct way is to extract glyphs from symbol.ttf,
445 //find correct mapping, place this glyphs. This requires manual layout though (?),
446 //and as usually, I have to many things to do, may be, one day I'll fix text rendering also.
447 //This hack work only on MacOSX 10.7.3, does not work on iOS and I'm not sure about future/previous
448 //versions of MacOSX.
449 std::vector<UniChar> unichars(std::strlen(text));
450 for (std::size_t i = 0; i < unichars.size(); ++i)
451 unichars[i] = 0xF000 + (unsigned char)text[i];
452 return unichars;
453}
454
455//______________________________________________________________________________
457 const char *text, ETextMode /* mode */)
458{
459 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
460 if (!drawable0)
461 return;
462
463 if ([drawable0 isDirectDraw])
464 return;
465
466 if (!text || !text[0])//Can this ever happen? TPad::PaintText does not check this.
467 return;
468
469 auto &atttext = GetAttText(wctxt);
470
471 if (atttext.GetTextSize() < 1.5)//Do not draw anything, or CoreText will create some small (but not of size 0 font).
472 return;
473
474 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawTextW");
475 if (!drawable)
476 return;
477
478 CGContextRef ctx = drawable.fContext;
480
481 //Before any core text drawing operations, reset text matrix.
483
484 try {
485 if (CTFontRef currentFont = fPimpl->fFontManager.SelectFont(atttext.GetTextFont(), kScale * atttext.GetTextSize())) {
486 const unsigned fontIndex = atttext.GetTextFont() / 10;
487 if (fontIndex == 12 || fontIndex == 15) {
488 //Greek and math symbols.
491 ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y), atttext);
492 } else {
493 const Quartz::TextLine ctLine(text, currentFont, atttext.GetTextColor());
494 ctLine.DrawLine(ctx, x, X11::LocalYROOTToCocoa(drawable, y), atttext);
495 }
496 }
497 } catch (const std::exception &e) {
498 Error("DrawTextW", "Exception from Quartz::TextLine: %s", e.what());
499 }
500}
501
502//______________________________________________________________________________
508
509//______________________________________________________________________________
511 const wchar_t *text, ETextMode mode)
512{
513 if (!text || !*text)
514 return;
515
516 if (!TTFhandle::Init()) {
517 Error("DrawTextW", "wchar_t string to draw, but TTF initialization failed");
518 return;
519 }
520
521 auto drawable0 = (NSObject<X11Drawable> * const) wctxt;
522 if (!drawable0)
523 return;
524
525 if ([drawable0 isDirectDraw])
526 return;
527
528 auto drawable = (NSObject<X11Drawable> * const) GetPixmapDrawable(drawable0, "DrawTextW");
529 if (!drawable)
530 return;
531
532
533 //Do not draw anything, or CoreText will create some small (but not of size 0 font).
534 auto &att = GetAttText(wctxt);
535
536 if (att.GetTextSize() < 1.5)//Do not draw anything, or CoreText will create some small (but not of size 0 font).
537 return;
538
540
542
543 ttf.SetTextFont(att.GetTextFont());
544 ttf.SetTextSize(att.GetTextSize());
545 ttf.SetRotationMatrix(angle);
546 ttf.PrepareString(text);
547 ttf.LayoutGlyphs();
548
549 Int_t txalh = att.GetTextAlign() / 10;
550 Int_t txalv = att.GetTextAlign() % 10;
551 FT_Vector align_vect; ///< alignment vector
552
553 // const EAlign align = EAlign(fTextAlign);
554 // vertical alignment
555 if (txalv == 3) // align == kTLeft || align == kTCenter || align == kTRight)
556 align_vect.y = ttf.GetAscent();
557 else if (txalv == 2) // if (align == kMLeft || align == kMCenter || align == kMRight) {
558 align_vect.y = ttf.GetAscent() / 2;
559 else
560 align_vect.y = 0;
561
562 // horizontal alignment
563 if (txalh == 3) // align == kTRight || align == kMRight || align == kBRight) {
564 align_vect.x = ttf.GetWidth();
565 else if (txalh == 2) // (align == kTCenter || align == kMCenter || align == kBCenter) {
566 align_vect.x = ttf.GetWidth() / 2;
567 else
568 align_vect.x = 0;
569
570 FT_Vector_Transform(&align_vect, ttf.GetRotMatrix());
571 //This shift is from the original code.
572 align_vect.x = align_vect.x >> 6;
573 align_vect.y = align_vect.y >> 6;
574
575
576 //This code is a modified (for Quartz) version of TG11TTF text drawing
577
579 if ([drawable isKindOfClass : [QuartzPixmap class]])
580 dstPixmap = (QuartzPixmap *)drawable;
581 else if ([drawable isKindOfClass : [QuartzView class]] || [drawable isKindOfClass : [QuartzWindow class]])
582 dstPixmap = ((NSObject<X11Window> *)drawable).fBackBuffer;
583
584 if (!dstPixmap) {
585 //I can not read pixels from a window (I can, but this is too slow and unreliable).
586 Error("DrawTextW", "fSelectedDrawable is neither QuartzPixmap nor a double buffered window");
587 return;
588 }
589
590 //Comment from TGX11TTF:
591 // compute the size and position of the XImage that will contain the text
592 const Int_t xOff = TMath::Max(0, (Int_t) -ttf.GetBox().xMin);
593 const Int_t yOff = TMath::Max(0, (Int_t) -ttf.GetBox().yMin);
594
595 const Int_t w = ttf.GetBox().xMax + xOff;
596 const Int_t h = ttf.GetBox().yMax + yOff;
597
598 // If w or h is 0, very likely the string is only blank characters
599 if (w <= 0 || h <= 0)
600 return;
601
602 const Int_t x1 = x - xOff - align_vect.x;
603 const Int_t y1 = y + yOff + align_vect.y - h;
604
605 UInt_t width = 0, height = 0;
606 Int_t xy = 0;
607
609
610 // If string falls outside window, there is probably no need to draw it.
612 return;
613
614 //By default, all pixels are set to 0 (all components, that's what code in TGX11TTF also does here).
616 if (!pixmap.Get()) {
617 Error("DrawTextW", "pixmap creation failed");
618 return;
619 }
620
621 const unsigned char defaultBackgroundPixel[] = {255, 255, 255, 255};
623 if (mode == kClear) {
624 //For this mode, TGX11TTF does some work to: a) preserve pixels under symbols
625 //b) calculate (interpolate) pixel for glyphs.
626
627 X11::Rectangle bbox(x1, y1, w, h);
628 //We already check IsVisible, so, in principle, bbox at least has intersection with
629 //the current selected drawable.
631 arrayGuard.Reset([dstPixmap readColorBits : bbox]);
632
633 if (!arrayGuard.Get()) {
634 Error("DrawTextW", "problem with reading background pixels");
635 return;
636 }
637
638 // This is copy & paste from TGX11TTF:
639 const Int_t xo = x1 < 0 ? -x1 : 0;
640 const Int_t yo = y1 < 0 ? -y1 : 0;
641
642 for (int yp = 0; yp < int(bbox.fHeight) && yo + yp < h; ++yp) {
643 const unsigned char *srcBase = arrayGuard.Get() + bbox.fWidth * yp * 4;
644 for (int xp = 0; xp < int(bbox.fWidth) && xo + xp < w; ++xp) {
645 const unsigned char * const pixel = srcBase + xp * 4;
646 [pixmap.Get() putPixel : pixel X : xo + xp Y : yo + yp];
647 }
648 }
649 } else {
650 //Find background color and set for all pixels.
652 }
653
654 CGContextRef ctx = drawable.fContext;
656
657 CGContextSetRGBStrokeColor(ctx, 0., 0., 1., 1.);
658 // paint the glyphs in the pixmap.
659 for (UInt_t n = 0; n < ttf.GetNumGlyphs(); ++n) {
660 if (auto bitmap = ttf.GetGlyphBitmap(n)) {
661 const Int_t bx = bitmap->left + xOff;
662 const Int_t by = h - bitmap->top - yOff;
663
664 DrawFTGlyph(pixmap.Get(), &bitmap->bitmap, TGCocoa::GetPixel(att.GetTextColor()),
665 mode == kClear ? ULong_t(-1) : 0xffffff, bx, by);
666 }
667 }
668
669 const X11::Rectangle copyArea(0, 0, w, h);
670 const X11::Point dstPoint(x1, y1);
672}
673
674//______________________________________________________________________________
680
681//______________________________________________________________________________
683{
684 // Returns the size of the specified character string "mess".
685 //
686 // w - the text width
687 // h - the text height
688 // text - the string
689
690 w = h = 0;
691
692 if (!text || !*text)
693 return;
694
695 auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize());
696 if (!fontref)
697 return;
698 const unsigned fontIndex = GetTextFont() / 10;
699 if (fontIndex == 12 || fontIndex == 15) {
700 //Greek and math symbols.
702 fPimpl->fFontManager.GetTextBounds(fontref, w, h, unichars);
703 } else {
704 fPimpl->fFontManager.GetTextBounds(fontref, w, h, text);
705 }
706}
707
708//______________________________________________________________________________
710{
711 if (!text || !*text) {
712 w = h = 0;
713 return kTRUE;
714 }
715
716 auto fontref = fPimpl->fFontManager.SelectFont(font, kScale * size);
717 if (!fontref)
718 return kFALSE;
719
720 const unsigned fontIndex = font / 10;
721 if (fontIndex == 12 || fontIndex == 15) {
722 //Greek and math symbols.
724 fPimpl->fFontManager.GetTextBounds(fontref, w, h, unichars);
725 } else {
726 fPimpl->fFontManager.GetTextBounds(fontref, w, h, text);
727 }
728
729 return kTRUE;
730}
731
732//______________________________________________________________________________
734{
735 // do not handle wchar, pad painter will switch to TTF
736 w = h = 0;
737 return kFALSE;
738}
739
740
741//______________________________________________________________________________
743{
744 // Returns the ascent of the current font (in pixels).
745 // The ascent of a font is the distance from the baseline
746 // to the highest position characters extend to.
747 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
748 return Int_t(fPimpl->fFontManager.GetAscent(fontref));
749
750 return 0;
751}
752
753//______________________________________________________________________________
755{
756 // Returns the ascent of the current font (in pixels).
757 // The ascent of a font is the distance from the baseline
758 // to the highest position characters extend to.
759
760 //In case of any problem we can always resort to the old version:
761 if (!text || !*text)
762 return GetFontAscent();
763
764 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
765 const unsigned fontIndex = GetTextFont() / 10;
766 if (fontIndex == 12 || fontIndex == 15) {
767 //Greek and math symbols.
769 return Int_t(fPimpl->fFontManager.GetAscent(fontref, unichars));
770 } else
771 return Int_t(fPimpl->fFontManager.GetAscent(fontref, text));
772 }
773
774 return 0;
775}
776
777//______________________________________________________________________________
779{
780 // Returns the descent of the current font (in pixels.
781 // The descent is the distance from the base line
782 // to the lowest point characters extend to.
783 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize()))
784 return Int_t(fPimpl->fFontManager.GetDescent(fontref));
785
786 return 0;
787}
788
789//______________________________________________________________________________
791{
792 // Returns the descent of the current font (in pixels.
793 // The descent is the distance from the base line
794 // to the lowest point characters extend to.
795
796 //That's how it's tested in ROOT:
797 if (!text || !*text)
798 return GetFontDescent();
799
800 if (auto fontref = fPimpl->fFontManager.SelectFont(GetTextFont(), kScale*GetTextSize())) {
801 const unsigned fontIndex = GetTextFont() / 10;
802 if (fontIndex == 12 || fontIndex == 15) {
803 //Greek and math symbols.
805 return Int_t(fPimpl->fFontManager.GetDescent(fontref, unichars));
806 } else
807 return Int_t(fPimpl->fFontManager.GetDescent(fontref, text));
808 }
809
810 return 0;
811}
812
813//______________________________________________________________________________
815{
816 a = d = 0;
817
818 auto fontref = fPimpl->fFontManager.SelectFont(font, kScale * size);
819 if (!fontref)
820 return kFALSE;
821
822 const unsigned fontIndex = font / 10;
823 if (!text || !*text) {
824 a = fPimpl->fFontManager.GetAscent(fontref);
825 d = fPimpl->fFontManager.GetDescent(fontref);
826 } else if (fontIndex == 12 || fontIndex == 15) {
827 //Greek and math symbols.
829 a = fPimpl->fFontManager.GetAscent(fontref, unichars);
830 d = fPimpl->fFontManager.GetDescent(fontref, unichars);
831 } else {
832 a = fPimpl->fFontManager.GetAscent(fontref, text);
833 d = fPimpl->fFontManager.GetDescent(fontref, text);
834 }
835
836 return kTRUE;
837}
838
839
840//______________________________________________________________________________
842{
843 // Returns the current font magnification factor
844 return 0;
845}
846
847//______________________________________________________________________________
849{
850 // Set color index "cindex" for drawing lines.
852
854}
855
856
857//______________________________________________________________________________
859{
860 // Set line style.
862
864}
865
866
867//______________________________________________________________________________
869{
870 // Set the line width.
871
873
875}
876
877
878//______________________________________________________________________________
880{
881 // Set color index "cindex" for fill areas.
882
884
886}
887
888
889//______________________________________________________________________________
891{
892 // Set fill area style.
894
896}
897
898
899//______________________________________________________________________________
901{
902 // Set color index "cindex" for markers.
904
906}
907
908
909//______________________________________________________________________________
911{
912 // Set marker size index.
913 //
914 // markersize - the marker scale factor
916
918}
919
920
921//______________________________________________________________________________
923{
924 // Set marker style.
925
927
929}
930
931
932//______________________________________________________________________________
934{
935 // Set the text alignment.
936
938
940}
941
942//______________________________________________________________________________
944{
945 // Set the color index "cindex" for text.
946
948
950}
951
952
953//______________________________________________________________________________
955{
956 // Set the current text font number.
957
959
961}
962
963//______________________________________________________________________________
964Int_t TGQuartz::SetTextFont(char * /* fontName */, ETextSetMode /* mode */)
965{
966 Error("SetTextFont", "Direct TTF font setting not supported");
967 return 1;
968}
969
970//______________________________________________________________________________
972{
973 // Set the current text size to "textsize"
974
976
978}
979
980//______________________________________________________________________________
982{
983 // Set opacity of the current window. This image manipulation routine
984 // works by adding to a percent amount of neutral to each pixels RGB.
985 // Since it requires quite some additional color map entries is it
986 // only supported on displays with more than > 8 color planes (> 256
987 // colors).
988}
989
990//______________________________________________________________________________
991void TGQuartz::SetOpacityW(WinContext_t /* wctxt */, Int_t /* percent */)
992{
993}
994
995//______________________________________________________________________________
997{
998 att.Copy(GetAttFill(wctxt));
999
1000 // TODO: remove this after transition done
1001 TAttFill::SetFillColor(att.GetFillColor());
1002 TAttFill::SetFillStyle(att.GetFillStyle());
1003}
1004
1005//______________________________________________________________________________
1007{
1008 att.Copy(GetAttLine(wctxt));
1009
1010 // TODO: remove this after transition done
1011 TAttLine::SetLineColor(att.GetLineColor());
1012 TAttLine::SetLineStyle(att.GetLineStyle());
1013 TAttLine::SetLineWidth(att.GetLineWidth());
1014}
1015
1016//______________________________________________________________________________
1018{
1019 att.Copy(GetAttMarker(wctxt));
1020
1021 // TODO: remove this after transition done
1022 TAttMarker::SetMarkerColor(att.GetMarkerColor());
1023 TAttMarker::SetMarkerSize(att.GetMarkerSize());
1024 TAttMarker::SetMarkerStyle(att.GetMarkerStyle());
1025}
1026
1027//______________________________________________________________________________
1029{
1030 att.Copy(GetAttText(wctxt));
1031
1032 // TODO: remove this after transition done
1033 TAttText::SetTextAlign(att.GetTextAlign());
1034 TAttText::SetTextAngle(att.GetTextAngle());
1035 TAttText::SetTextColor(att.GetTextColor());
1036 TAttText::SetTextSize(att.GetTextSize());
1037 TAttText::SetTextFont(att.GetTextFont());
1038}
1039
1040//TTF related part.
1041
1042//______________________________________________________________________________
1044{
1045 //This function is a "remake" of TGX11FFT::DrawImage.
1046
1047 //I'm using this code to reproduce the same text as generated by TGX11TTF.
1048 //It's quite sloppy, as in original version. I tried to make it not so ugly and
1049 //more or less readable.
1050
1051 auto pixmap = (QuartzPixmap *)_pixmap;
1052 auto source = (FT_Bitmap *) _source;
1053 assert(pixmap != nil && "DrawFTGlyph, pixmap parameter is nil");
1054 assert(source != nil && "DrawFTGlyph, source parameter is null");
1055
1057 ColorStruct_t col[5];
1058 // background kClear, i.e. transparent, we take as background color
1059 // the average of the rgb values of all pixels covered by this character
1060 if (back == ULong_t(-1)) {
1061 const UInt_t maxDots = TMath::Min((UInt_t) 50000, source->width * source->rows);
1062
1063 //In original code, they first have to extract
1064 //pixels and call XQueryColors.
1065 //I have only one loop here.
1066 ULong_t r = 0, g = 0, b = 0;
1067 UInt_t dotCnt = 0;
1068 for (unsigned y = 0; y < source->rows; y++) {
1069 for (unsigned x = 0; x < source->width; x++) {
1070 if (x + bx < pixmap.fWidth && y + by < pixmap.fHeight) {
1071 const unsigned char * const pixels = pixmap.fData + (y + by) * pixmap.fWidth * 4 + (x + bx) * 4;
1072 r += UShort_t(pixels[0] / 255. * 0xffff);
1073 g += UShort_t(pixels[1] / 255. * 0xffff);
1074 b += UShort_t(pixels[2] / 255. * 0xffff);
1075 if (++dotCnt >= maxDots)
1076 break;
1077 }
1078 }
1079 }
1080
1081 if (dotCnt > 0) {
1082 r /= dotCnt;
1083 g /= dotCnt;
1084 b /= dotCnt;
1085 }
1086
1087 col[0].fRed = (UShort_t) r;
1088 col[0].fGreen = (UShort_t) g;
1089 col[0].fBlue = (UShort_t) b;
1090 } else {
1091 // request background color
1092 col[0].fPixel = back;
1093 TGCocoa::QueryColor(kNone, col[0]);
1094 }
1095
1096 // request foreground color
1097 col[4].fPixel = fore;
1098 TGCocoa::QueryColor(kNone, col[4]);//calculate fRed/fGreen/fBlue triple from fPixel.
1099
1100 // interpolate between fore and background colors
1101 for (int x = 3; x > 0; --x) {
1102 col[x].fRed = (col[4].fRed * x + col[0].fRed * (4 - x)) / 4;
1103 col[x].fGreen = (col[4].fGreen * x + col[0].fGreen * (4 - x)) / 4;
1104 col[x].fBlue = (col[4].fBlue * x + col[0].fBlue * (4 - x)) / 4;
1105 TGCocoa::AllocColor(kNone, col[x]);//Calculate fPixel from fRed/fGreen/fBlue triplet.
1106 }
1107
1108 // put smoothed character, character pixmap values are an index
1109 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
1110 const unsigned char *s = source->buffer;
1111 for (unsigned y = 0; y < source->rows; ++y) {
1112 for (unsigned x = 0; x < source->width; ++x) {
1113 unsigned char d = (((*s++ & 0xff) + 10) * 5) / 256;
1114 if (d > 4)
1115 d = 4;
1116 if (d > 0) {
1117 const UChar_t pixel[] = {UChar_t(double(col[d].fRed) / 0xffff * 255),
1118 UChar_t(double(col[d].fGreen) / 0xffff * 255),
1119 UChar_t(double(col[d].fBlue) / 0xffff * 255), 255};
1120 [pixmap putPixel : pixel X : bx + x Y : by + y];
1121 }
1122 }
1123 }
1124 } else {
1125 // no smoothing, just put character using foreground color
1126 unsigned char rgba[4] = {};
1127 rgba[3] = 255;
1129 unsigned char d = 0;
1130
1131 const unsigned char *row = source->buffer;
1132 for (unsigned y = 0; y < source->rows; ++y) {
1133 unsigned n = 0;
1134 const unsigned char *s = row;
1135 for (unsigned x = 0; x < source->width; ++x) {
1136 if (!n)
1137 d = *s++;
1138
1139 if (TESTBIT(d,7 - n))
1140 [pixmap putPixel : rgba X : bx + x Y : by + y];
1141
1142 if (++n == kBitsPerByte)
1143 n = 0;
1144 }
1145
1146 row += source->pitch;
1147 }
1148 }
1149}
1150
1151//Aux. functions.
1152
1153//______________________________________________________________________________
1155{
1156 if (gEnv) {
1157 const TString value(TString(gEnv->GetValue("Cocoa.EnableAntiAliasing", "auto")).Strip());
1158 if (value == "auto") {
1159 [[NSScreen mainScreen] backingScaleFactor] > 1. ? fUseAA = true : fUseAA = false;
1160 } else if (value == "no")
1161 fUseAA = false;
1162 else {
1163 assert(value == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1164 fUseAA = true;
1165 }
1166 const TString valuefa(TString(gEnv->GetValue("Cocoa.EnableFillAreaAntiAliasing", "auto")).Strip());
1167 if (valuefa == "auto") {
1169 } else if (valuefa == "no")
1170 fUseFAAA = false;
1171 else {
1172 assert(valuefa == "yes" && "SetAA, value must be 'yes', 'no' or 'auto'");
1173 fUseFAAA = true;
1174 }
1175 }
1176}
1177
1178//______________________________________________________________________________
1180{
1181 // attributes stored in direct drawable (view) and not in underlying pixmap
1182 auto drawable = (NSObject<X11Drawable> *) wctxt;
1183 if (!drawable || !drawable.attFill)
1184 return *this;
1185 return *drawable.attFill;
1186}
1187
1188//______________________________________________________________________________
1190{
1191 // attributes stored in direct drawable (view) and not in underlying pixmap
1192 auto drawable = (NSObject<X11Drawable> *) wctxt;
1193 if (!drawable || !drawable.attLine)
1194 return *this;
1195 return *drawable.attLine;
1196}
1197
1198//______________________________________________________________________________
1200{
1201 // attributes stored in direct drawable (view) and not in underlying pixmap
1202 auto drawable = (NSObject<X11Drawable> *) wctxt;
1203 if (!drawable || !drawable.attMarker)
1204 return *this;
1205 return *drawable.attMarker;
1206}
1207
1208//______________________________________________________________________________
1210{
1211 // attributes stored in direct drawable (view) and not in underlying pixmap
1212 auto drawable = (NSObject<X11Drawable> *) wctxt;
1213 if (!drawable || !drawable.attText)
1214 return *this;
1215 return *drawable.attText;
1216}
1217
1218//______________________________________________________________________________
1219void *TGQuartz::GetPixmapDrawable(void *drawable0, const char *calledFrom) const
1220{
1221 assert(calledFrom != 0 && "GetDrawableChecked, calledFrom parameter is null");
1222
1223 if (!drawable0)
1224 return nullptr;
1225
1226 auto drawable = (NSObject<X11Drawable> *) drawable0;
1227 if (!drawable.fIsPixmap) {
1228 //TPad/TCanvas ALWAYS draw only into a pixmap.
1229 if ([drawable isKindOfClass : [QuartzView class]]) {
1230 QuartzView *view = (QuartzView *)drawable;
1231 if (!view.fBackBuffer) {
1232 Error(calledFrom, "Selected window is not double buffered");
1233 return nullptr;
1234 }
1235
1236 drawable = view.fBackBuffer;
1237 } else {
1238 Error(calledFrom, "Selected drawable is neither a pixmap, nor a double buffered window");
1239 return nullptr;
1240 }
1241 }
1242
1243 if (!drawable.fContext) {
1244 Error(calledFrom, "Context is null");
1245 return nullptr;
1246 }
1247
1248 return drawable;
1249}
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:126
const Float_t kScale
Definition TGQuartz.mm:49
std::vector< UniChar > quartz_get_greek_unicars(const char *text)
Definition TGQuartz.mm:442
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 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
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:511
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:868
TAttMarker & GetAttMarker(WinContext_t wctxt)
Definition TGQuartz.mm:1199
bool fUseFAAA
Definition TGQuartz.h:105
void SetAttLine(WinContext_t wctxt, const TAttLine &att) override
Set line attributes for specified window.
Definition TGQuartz.mm:1006
void DrawFTGlyph(void *pixmap, void *source, ULong_t fore, ULong_t back, Int_t bx, Int_t by)
Definition TGQuartz.mm:1043
void SetMarkerColor(Color_t cindex) override
Set the marker color.
Definition TGQuartz.mm:900
void SetFillStyle(Style_t style) override
Set the fill area style.
Definition TGQuartz.mm:890
void SetOpacity(Int_t percent) override
Sets opacity of the current window.
Definition TGQuartz.mm:981
void SetFillColor(Color_t cindex) override
Set the fill area color.
Definition TGQuartz.mm:879
void DrawPolyLine(Int_t n, TPoint *xy) override
Draws a line through all points in the list.
Definition TGQuartz.mm:369
Float_t GetTextMagnitude() override
Returns the current font magnification factor.
Definition TGQuartz.mm:841
void SetAttText(WinContext_t wctxt, const TAttText &att) override
Set text attributes for specified window.
Definition TGQuartz.mm:1028
void SetAA()
Definition TGQuartz.mm:1154
void DrawFillArea(Int_t n, TPoint *xy) override
Fills area described by the polygon.
Definition TGQuartz.mm:244
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:503
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draws a line.
Definition TGQuartz.mm:302
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:456
void SetTextColor(Color_t cindex) override
Set the text color.
Definition TGQuartz.mm:943
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:709
void SetMarkerStyle(Style_t markerstyle) override
Set the marker style.
Definition TGQuartz.mm:922
bool fUseAA
Definition TGQuartz.h:104
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:996
void SetTextAlign(Short_t talign=11) override
Set the text alignment.
Definition TGQuartz.mm:933
TAttText & GetAttText(WinContext_t wctxt)
Definition TGQuartz.mm:1209
void SetLineColor(Color_t cindex) override
Set the line color.
Definition TGQuartz.mm:848
void SetTextFont(Font_t fontnumber) override
Set the text font.
Definition TGQuartz.mm:954
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override
Set marker attributes for specified window.
Definition TGQuartz.mm:1017
void GetTextExtent(UInt_t &w, UInt_t &h, char *text) override
Returns the size of the specified character string "mess".
Definition TGQuartz.mm:682
Int_t GetFontAscent() const override
Returns the ascent of the current font (in pixels).
Definition TGQuartz.mm:742
void SetMarkerSize(Float_t markersize) override
Set the marker size.
Definition TGQuartz.mm:910
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:251
void DrawLinesSegmentsW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw line segments on specified window.
Definition TGQuartz.mm:383
void SetTextSize(Float_t textsize) override
Set the text size.
Definition TGQuartz.mm:971
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:814
void DrawPolyMarkerW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly marker on specified window.
Definition TGQuartz.mm:390
void DrawLineW(WinContext_t wctxt, Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draw line on specified window.
Definition TGQuartz.mm:258
void DrawPolyLineW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly line on specified window.
Definition TGQuartz.mm:315
void SetLineStyle(Style_t linestyle) override
Set the line style.
Definition TGQuartz.mm:858
TAttFill & GetAttFill(WinContext_t wctxt)
Definition TGQuartz.mm:1179
Int_t GetFontDescent() const override
Returns the descent of the current font (in pixels.
Definition TGQuartz.mm:778
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:991
void DrawPolyMarker(Int_t n, TPoint *xy) override
Draws "n" markers with the current attributes at position [x,y].
Definition TGQuartz.mm:428
void * GetPixmapDrawable(void *drawable0, const char *calledFrom) const
Definition TGQuartz.mm:1219
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:1189
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1084
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1098
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 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, unsigned nPoints, const TPoint *marker, const TAttMarker &attmark, float scaleFactor)
Bool_t SetFillAreaParameters(CGContextRef ctx, unsigned *patternIndex, const TAttFill &attfill)
void DrawPolyLine(CGContextRef ctx, Int_t n, const TPoint *xy)
void DrawFillArea(CGContextRef ctx, Int_t n, TPoint *xy, Bool_t drawShadow, const TAttFill &attfill)
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
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