21#include <Cocoa/Cocoa.h>
24# include FT_FREETYPE_H
61 assert(
nPoints != 0 &&
"ConvertPointsROOTToCocoa, nPoints parameter is 0");
62 assert(
xy != 0 &&
"ConvertPointsROOTToCocoa, xy parameter is null");
63 assert(drawable != 0 &&
"ConvertPointsROOTToCocoa, drawable parameter is null");
65 const auto scaleFactor = drawable.fScaleFactor;
88 Error(
"TGQuartz",
"TTF::Init() failed");
108 Error(
"TGQuartz",
"TTF::Init() failed");
128 ::Warning(
"DrawBoxW",
"Invalid view/window for XOR-mode");
172 Error(
"DrawBoxW",
"Can not find color for index %d",
int(
attline.GetLineColor()));
177 Error(
"DrawBoxW",
"SetFillAreaParameters failed");
228 if (drawable.fScaleFactor > 1.) {
235 Error(
"DrawFillAreaW",
"Could not find TColor for index %d",
attfill.GetFillColor());
245 Error(
"DrawFillAreaW",
"SetFillAreaParameters failed");
281 ::Warning(
"DrawLineW",
"Invalid view/window for XOR-mode");
303 Error(
"DrawLineW",
"Could not set line color for index %d",
int(
attline.GetLineColor()));
350 Error(
"DrawPolyLineW",
"Could not find TColor for index %d",
attline.GetLineColor());
360 if (drawable.fScaleFactor > 1.)
385 for(
Int_t i = 0; i < 2*
n; i += 2)
412 Error(
"DrawPolyMarker",
"Could not find TColor for index %d",
attmark.GetMarkerColor());
422 if (drawable.fScaleFactor > 1.)
472 if (
atttext.GetTextSize() < 1.5)
494 typedef std::vector<UniChar>::size_type size_type;
507 }
catch (
const std::exception &
e) {
508 Error(
"DrawTextW",
"Exception from Quartz::TextLine: %s",
e.what());
527 Error(
"DrawTextW",
"wchar_t string to draw, but TTF initialization failed");
565 typedef std::vector<UniChar>::size_type size_type;
605 typedef std::vector<UniChar>::size_type size_type;
646 typedef std::vector<UniChar>::size_type size_type;
790 Error(
"SetTextFont",
"TTF is not initialized");
857 Error(
"SetAttText",
"TTF is not initialized");
937 if (
x +
int(
w) <= 0 ||
x >=
int(
width))
980 Error(
"RenderTTFString",
"fSelectedDrawable is neither QuartzPixmap nor a double buffered window");
1001 Error(
"RenderTTFString",
"pixmap creation failed");
1018 Error(
"RenderTTFString",
"problem with reading background pixels");
1072 assert(
pixmap !=
nil &&
"DrawFTGlyphIntoPixmap, pixmap parameter is nil");
1073 assert(
source != 0 &&
"DrawFTGlyphIntoPixmap, source parameter is null");
1109 if (col[0].fRed ==
r && col[0].fGreen ==
g && col[0].fBlue ==
b) {
1122 if (
fore != col[4].fPixel || back != col[0].fPixel) {
1131 for (
int x = 3;
x > 0; --
x) {
1141 const unsigned char *s =
source->buffer;
1144 unsigned char d = *s++ & 0xff;
1145 d = ((
d + 10) * 5) / 256;
1148 if (
d &&
x < (
int)
source->width) {
1150 UChar_t(
double(col[
d].fGreen) / 0xffff * 255),
1151 UChar_t(
double(col[
d].fBlue) / 0xffff * 255), 255};
1158 unsigned char rgba[4] = {};
1161 unsigned char d = 0;
1163 const unsigned char *row =
source->buffer;
1166 const unsigned char *s = row;
1190 if (
value ==
"auto") {
1192 }
else if (
value ==
"no")
1195 assert(
value ==
"yes" &&
"SetAA, value must be 'yes', 'no' or 'auto'");
1204 assert(
valuefa ==
"yes" &&
"SetAA, value must be 'yes', 'no' or 'auto'");
1215 if (!drawable || !drawable.attFill)
1217 return *drawable.attFill;
1225 if (!drawable || !drawable.attLine)
1227 return *drawable.attLine;
1235 if (!drawable || !drawable.attMarker)
1237 return *drawable.attMarker;
1245 if (!drawable || !drawable.attText)
1247 return *drawable.attText;
1253 assert(
calledFrom != 0 &&
"GetDrawableChecked, calledFrom parameter is null");
1259 if (!drawable.fIsPixmap) {
1270 Error(
calledFrom,
"Selected drawable is neither a pixmap, nor a double buffered window");
1275 if (!drawable.fContext) {
Handle_t WinContext_t
Window drawing context.
Handle_t Drawable_t
Drawable handle.
short Style_t
Style number (short)
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
int Int_t
Signed integer 4 bytes (int)
short Color_t
Color number (short)
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
constexpr ULong_t kBitsPerByte
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
short Width_t
Line width (short)
float Float_t
Float 4 bytes (float)
short Font_t
Font number (short)
short Short_t
Signed Short integer 2 bytes (short)
short SCoord_t
Screen coordinates (short)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t markerstyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char bitmap
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t textsize
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t 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
Fill Area Attributes class.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual Size_t GetMarkerSize() const
Return the marker size.
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.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
virtual Float_t GetTextSize() const
Return the text size.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual Font_t GetTextFont() const
Return the text font.
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
TColorGradient extends basic TColor.
The color creation and management class.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D.
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...
std::unique_ptr< ROOT::MacOSX::Details::CocoaPrivate > fPimpl
!
void QueryColor(Colormap_t cmap, ColorStruct_t &color) override
Returns the current RGB value for the pixel in the "color" structure.
WinContext_t GetSelectedContext()
Drawable_t fSelectedDrawable
ULong_t GetPixel(Color_t cindex) override
Returns pixel value associated to specified ROOT color number "cindex".
void SetLineWidth(Width_t width) override
Set the line width.
TAttMarker & GetAttMarker(WinContext_t wctxt)
void SetAttLine(WinContext_t wctxt, const TAttLine &att) override
Set line attributes for specified window.
void SetMarkerColor(Color_t cindex) override
Set the marker color.
void SetFillStyle(Style_t style) override
Set the fill area style.
void SetOpacity(Int_t percent) override
Sets opacity of the current window.
void SetFillColor(Color_t cindex) override
Set the fill area color.
void DrawPolyLine(Int_t n, TPoint *xy) override
Draws a line through all points in the list.
Float_t GetTextMagnitude() override
Returns the current font magnification factor.
void SetAttText(WinContext_t wctxt, const TAttText &att) override
Set text attributes for specified window.
void DrawFillArea(Int_t n, TPoint *xy) override
Fills area described by the polygon.
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.
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draws a line.
Bool_t IsTTFStringVisible(WinContext_t wctxt, Int_t x, Int_t y, UInt_t w, UInt_t h)
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.
void SetTextColor(Color_t cindex) override
Set the text color.
void SetMarkerStyle(Style_t markerstyle) override
Set the marker style.
void DrawFTGlyphIntoPixmap(void *pixmap, FT_Bitmap *source, ULong_t fore, ULong_t back, Int_t bx, Int_t by)
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".
void SetAttFill(WinContext_t wctxt, const TAttFill &att) override
Set fill attributes for specified window.
std::vector< TPoint > fConvertedPoints
void SetTextAlign(Short_t talign=11) override
Set the text alignment.
TAttText & GetAttText(WinContext_t wctxt)
void SetLineColor(Color_t cindex) override
Set the line color.
void SetTextFont(Font_t fontnumber) override
Set the text font.
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override
Set marker attributes for specified window.
void RenderTTFString(WinContext_t wctxt, Int_t x, Int_t y, ETextMode mode)
void GetTextExtent(UInt_t &w, UInt_t &h, char *text) override
Returns the size of the specified character string "mess".
Int_t GetFontAscent() const override
Returns the ascent of the current font (in pixels).
void SetMarkerSize(Float_t markersize) override
Set the marker size.
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.
void DrawLinesSegmentsW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw line segments on specified window.
void SetTextSize(Float_t textsize) override
Set the text size.
void AlignTTFString(WinContext_t wctxt)
void DrawPolyMarkerW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly marker on specified window.
void DrawLineW(WinContext_t wctxt, Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Draw line on specified window.
void DrawPolyLineW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw poly line on specified window.
void SetLineStyle(Style_t linestyle) override
Set the line style.
TAttFill & GetAttFill(WinContext_t wctxt)
Int_t GetFontDescent() const override
Returns the descent of the current font (in pixels.
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.
void DrawPolyMarker(Int_t n, TPoint *xy) override
Draws "n" markers with the current attributes at position [x,y].
void * GetPixmapDrawable(void *drawable0, const char *calledFrom) const
void DrawFillAreaW(WinContext_t wctxt, Int_t n, TPoint *xy) override
Draw fill area on specified window.
TAttLine & GetAttLine(WinContext_t wctxt)
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
TTF helper class containing glyphs description.
static Bool_t IsInitialized()
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
static void Init()
Initialise the TrueType fonts interface.
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
static void SetTextFont(Font_t fontnumber)
Set specified font.
static TTGlyph * GetGlyphs()
static Int_t GetNumGlyphs()
static const FT_BBox & GetBox()
static Bool_t GetSmoothing()
static void SetTextSize(Float_t textsize)
Set current text size.
static FT_Matrix * GetRotMatrix()
QuartzPixmap * fBackBuffer
QuartzWindow * fQuartzWindow
void PixelToRGB(Pixel_t pixelColor, CGFloat *rgb)
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)
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)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
ULong_t fPixel
color pixel value (index in color table)
UShort_t fRed
red component (0..65535)
UShort_t fGreen
green component (0..65535)
UShort_t fBlue
blue component (0..65535)