Logo ROOT   6.12/07
Reference Guide
QuartzText.h
Go to the documentation of this file.
1 // @(#)root/graf2d:$Id$
2 // Author: Timur Pocheptsov 26/01/2012
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_QuartzText
13 #define ROOT_QuartzText
14 
15 #include <vector>
16 
17 #include <Cocoa/Cocoa.h>
18 
19 #include "CocoaUtils.h"
20 #include "GuiTypes.h"
21 
22 
23 /////////////////////////////////////////////////
24 // //
25 // TextLine - wrapper class for a CoreText's //
26 // CTLine: hide all the API, calls, objects, //
27 // CoreFoundation objects required to draw //
28 // a simple line of text and be able to //
29 // calculate text metrics. //
30 // //
31 /////////////////////////////////////////////////
32 
33 namespace ROOT {
34 namespace Quartz {
35 
36 // Core Text's CTLine wrapper.
37 class TextLine {
38 public:
39  TextLine(const char *textLine, CTFontRef font);
40  TextLine(const std::vector<UniChar> &textLine, CTFontRef font);
41 
42  TextLine(const char *textLine, CTFontRef font, Color_t color);
43  TextLine(const std::vector<UniChar> &textLine, CTFontRef font, Color_t color);
44  TextLine(const char *textLine, CTFontRef font, const CGFloat *rgb);
45 
46  ~TextLine();
47 
48  void GetBounds(UInt_t &w, UInt_t &h)const;
49  void GetAscentDescent(Int_t &asc, Int_t &desc)const;
50 
51  void DrawLine(CGContextRef ctx)const;
52  void DrawLine(CGContextRef ctx, Double_t x, Double_t y)const;
53 private:
54  CTLineRef fCTLine; //Core Text line, created from Attributed string.
55  CTFontRef fCTFont; //A font used for this CTLine.
56 
57  void Init(const char *textLine, UInt_t nAttribs, CFStringRef *keys, CFTypeRef *values);
58  void Init(const std::vector<UniChar> &textLine, UInt_t nAttribs, CFStringRef *keys, CFTypeRef *values);
59 
60  TextLine(const TextLine &rhs);
61  TextLine &operator = (const TextLine &rhs);
62 };
63 
64 //Aux. function which extracts glyphs, calculates their positions, draws glyphs with manual layout (GUI text).
65 void DrawTextLineNoKerning(CGContextRef ctx, CTFontRef font, const std::vector<UniChar> &text, Int_t x, Int_t y);
66 
67 const extern CTFontOrientation defaultFontOrientation;
68 const extern CTFontOrientation horizontalFontOrientation;
69 const extern CTFontOrientation verticalFontOrientation;
70 
71 }
72 }
73 
74 #endif
void GetAscentDescent(Int_t &asc, Int_t &desc) const
Definition: QuartzText.mm:189
void GetBounds(UInt_t &w, UInt_t &h) const
Definition: QuartzText.mm:179
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
TH1 * h
Definition: legend2.C:5
int Int_t
Definition: RtypesCore.h:41
Double_t x[n]
Definition: legend1.C:17
const CTFontOrientation horizontalFontOrientation
Definition: QuartzText.mm:39
TextLine & operator=(const TextLine &rhs)
const CTFontOrientation defaultFontOrientation
Definition: QuartzText.mm:38
short Color_t
Definition: RtypesCore.h:79
unsigned int UInt_t
Definition: RtypesCore.h:42
TextLine(const char *textLine, CTFontRef font)
Definition: QuartzText.mm:75
double Double_t
Definition: RtypesCore.h:55
const CTFontOrientation verticalFontOrientation
Definition: QuartzText.mm:40
TText * text
Double_t y[n]
Definition: legend1.C:17
void DrawLine(CGContextRef ctx) const
Definition: QuartzText.mm:267
void DrawTextLineNoKerning(CGContextRef ctx, CTFontRef font, const std::vector< UniChar > &text, Int_t x, Int_t y)
Definition: QuartzText.mm:319
void Init(const char *textLine, UInt_t nAttribs, CFStringRef *keys, CFTypeRef *values)
Definition: QuartzText.mm:221