Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTextLayout Class Reference

Is used to keep track of string measurement information when using the text layout facilities.

It can be displayed with respect to any origin.

Definition at line 106 of file TGFont.h.

Public Member Functions

 TGTextLayout ()
 
virtual ~TGTextLayout ()
 destructor
 
Int_t CharBbox (Int_t index, Int_t *x, Int_t *y, Int_t *w, Int_t *h) const
 Use the information in the TGTextLayout token to return the bounding box for the character specified by index.
 
Int_t DistanceToText (Int_t x, Int_t y) const
 Computes the distance in pixels from the given point to the given text layout.
 
void DrawText (Drawable_t dst, GContext_t gc, Int_t x, Int_t y, Int_t firstChar, Int_t lastChar) const
 Use the information in the TGTextLayout object to display a multi-line, justified string of text.
 
Int_t IntersectText (Int_t x, Int_t y, Int_t w, Int_t h) const
 Determines whether a text layout lies entirely inside, entirely outside, or overlaps a given rectangle.
 
Int_t PointToChar (Int_t x, Int_t y) const
 Use the information in the TGTextLayout token to determine the character closest to the given point.
 
void ToPostscript (TString *dst) const
 Outputs the contents of a text layout in Postscript format.
 
void UnderlineChar (Drawable_t dst, GContext_t gc, Int_t x, Int_t y, Int_t underline) const
 Use the information in the TGTextLayout object to display an underline below an individual character.
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor.
 
 TObject (const TObject &object)
 TObject copy ctor.
 
virtual ~TObject ()
 TObject destructor.
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract.
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad.
 
virtual void Browse (TBrowser *b)
 Browse object. May be overridden for another default action.
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs.
 
virtual void Clear (Option_t *="")
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility.
 
virtual Int_t Compare (const TObject *obj) const
 Compare abstract method.
 
virtual void Copy (TObject &object) const
 Copy this to obj.
 
virtual void Delete (Option_t *option="")
 Delete this object.
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object.
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects.
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs.
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad).
 
virtual void Dump () const
 Dump contents of object on stdout.
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message.
 
virtual void Execute (const char *method, const char *params, Int_t *error=0)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=0)
 Execute method on this object with parameters stored in the TObjArray.
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py).
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message.
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes.
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes.
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object.
 
virtual const char * GetIconName () const
 Returns mime type name of object.
 
virtual const char * GetName () const
 Returns name of object.
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py).
 
virtual Option_tGetOption () const
 
virtual const char * GetTitle () const
 Returns title of object.
 
virtual UInt_t GetUniqueID () const
 Return the unique object id.
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out.
 
virtual ULong_t Hash () const
 Return hash value for this object.
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message.
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname".
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl.
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas.
 
void InvertBit (UInt_t f)
 
Bool_t IsDestructed () const
 IsDestructed.
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory).
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
virtual Bool_t IsSortable () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
virtual void ls (Option_t *option="") const
 The ls function lists the contents of a class on stdout.
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification.
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete.
 
void operator delete (void *ptr)
 Operator delete.
 
void operator delete[] (void *ptr)
 Operator delete [].
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator.
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself.
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list.
 
virtual void Print (Option_t *option="") const
 This method must be overridden when a class wants to print itself.
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory.
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list.
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename.
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out".
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f.
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object.
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id.
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message.
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message.
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Protected Member Functions

 TGTextLayout (const TGTextLayout &tlayout)=delete
 
void operator= (const TGTextLayout &tlayout)=delete
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected).
 
void MakeZombie ()
 

Protected Attributes

LayoutChunk_tfChunks
 Array of chunks. The actual size will be maxChunks.
 
const TGFontfFont
 The font used when laying out the text.
 
Int_t fNumChunks
 Number of chunks actually used in following array.
 
const char * fString
 The string that was laid out.
 
Int_t fWidth
 The maximum width of all lines in the text layout.
 

Friends

class TGFont
 

Additional Inherited Members

- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 ,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = BIT(0) , kOverwrite = BIT(1) , kWriteDelete = BIT(2) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = BIT(3) }
 
enum  EStatusBits {
  kCanDelete = BIT(0) , kMustCleanup = BIT(3) , kIsReferenced = BIT(4) , kHasUUID = BIT(5) ,
  kCannotPick = BIT(6) , kNoContextMenu = BIT(8) , kInvalidObject = BIT(13)
}
 
- Static Public Member Functions inherited from TObject
static Longptr_t GetDtorOnly ()
 Return destructor only flag.
 
static Bool_t GetObjectStat ()
 Get status of object stat flag.
 
static void SetDtorOnly (void *obj)
 Set destructor only flag.
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable.
 
- Protected Types inherited from TObject
enum  { kOnlyPrepStep = BIT(3) }
 

#include <TGFont.h>

Inheritance diagram for TGTextLayout:
[legend]

Constructor & Destructor Documentation

◆ TGTextLayout() [1/2]

TGTextLayout::TGTextLayout ( const TGTextLayout tlayout)
protecteddelete

◆ TGTextLayout() [2/2]

TGTextLayout::TGTextLayout ( )
inline

Definition at line 121 of file TGFont.h.

◆ ~TGTextLayout()

TGTextLayout::~TGTextLayout ( )
virtual

destructor

Definition at line 900 of file TGFont.cxx.

Member Function Documentation

◆ CharBbox()

Int_t TGTextLayout::CharBbox ( Int_t  index,
Int_t x,
Int_t y,
Int_t w,
Int_t h 
) const

Use the information in the TGTextLayout token to return the bounding box for the character specified by index.

The width of the bounding box is the advance width of the character, and does not include and left- or right-bearing. Any character that extends partially outside of the text layout is considered to be truncated at the edge. Any character which is located completely outside of the text layout is considered to be zero-width and pegged against the edge.

The height of the bounding box is the line height for this font, extending from the top of the ascent to the bottom of the descent. Information about the actual height of the individual letter is not available.

A text layout that contains no characters is considered to contain a single zero-width placeholder character.

The return value is 0 if the index did not specify a character in the text layout, or non-zero otherwise. In that case, *bbox is filled with the bounding box of the character.

layout – Layout information, from a previous call to ComputeTextLayout(). index – The index of the character whose bbox is desired. x, y – Filled with the upper-left hand corner, in pixels, of the bounding box for the character specified by index, if non-NULL. w, h – Filled with the width and height of the bounding box for the character specified by index, if non-NULL.

Definition at line 1109 of file TGFont.cxx.

◆ DistanceToText()

Int_t TGTextLayout::DistanceToText ( Int_t  x,
Int_t  y 
) const

Computes the distance in pixels from the given point to the given text layout.

Non-displaying space characters that occur at the end of individual lines in the text layout are ignored for hit detection purposes.

The return value is 0 if the point (x, y) is inside the text layout. If the point isn't inside the text layout then the return value is the distance in pixels from the point to the text item.

x, y – Coordinates of point to check, with respect to the upper-left corner of the text layout (in pixels).

Definition at line 1191 of file TGFont.cxx.

◆ DrawText()

void TGTextLayout::DrawText ( Drawable_t  dst,
GContext_t  gc,
Int_t  x,
Int_t  y,
Int_t  firstChar,
Int_t  lastChar 
) const

Use the information in the TGTextLayout object to display a multi-line, justified string of text.

This procedure is useful for simple widgets that need to display single-font, multi-line text and want TGFont to handle the details.

dst – Window or pixmap in which to draw. gc – Graphics context to use for drawing text. x, y – Upper-left hand corner of rectangle in which to draw (pixels). firstChar – The index of the first character to draw from the given text item. 0 specfies the beginning. lastChar – The index just after the last character to draw from the given text item. A number < 0 means to draw all characters.

Definition at line 923 of file TGFont.cxx.

◆ IntersectText()

Int_t TGTextLayout::IntersectText ( Int_t  x,
Int_t  y,
Int_t  w,
Int_t  h 
) const

Determines whether a text layout lies entirely inside, entirely outside, or overlaps a given rectangle.

Non-displaying space characters that occur at the end of individual lines in the text layout are ignored for intersection calculations.

The return value is -1 if the text layout is entirely outside of the rectangle, 0 if it overlaps, and 1 if it is entirely inside of the rectangle.

x, y – Upper-left hand corner, in pixels, of rectangular area to compare with text layout. Coordinates are with respect to the upper-left hand corner of the text layout itself. w, h – The width and height of the above rectangular area, in pixels.

Definition at line 1257 of file TGFont.cxx.

◆ operator=()

void TGTextLayout::operator= ( const TGTextLayout tlayout)
protecteddelete

◆ PointToChar()

Int_t TGTextLayout::PointToChar ( Int_t  x,
Int_t  y 
) const

Use the information in the TGTextLayout token to determine the character closest to the given point.

The point must be specified with respect to the upper-left hand corner of the text layout, which is considered to be located at (0, 0).

Any point whose y-value is less that 0 will be considered closest to the first character in the text layout; any point whose y-value is greater than the height of the text layout will be considered closest to the last character in the text layout.

Any point whose x-value is less than 0 will be considered closest to the first character on that line; any point whose x-value is greater than the width of the text layout will be considered closest to the last character on that line.

The return value is the index of the character that was closest to the point. Given a text layout with no characters, the value 0 will always be returned, referring to a hypothetical zero-width placeholder character.

Definition at line 1003 of file TGFont.cxx.

◆ ToPostscript()

void TGTextLayout::ToPostscript ( TString result) const

Outputs the contents of a text layout in Postscript format.

The set of lines in the text layout will be rendered by the user supplied Postscript function. The function should be of the form:

justify x y string  function  --

Justify is -1, 0, or 1, depending on whether the following string should be left, center, or right justified, x and y is the location for the origin of the string, string is the sequence of characters to be printed, and function is the name of the caller-provided function; the function should leave nothing on the stack.

The meaning of the origin of the string (x and y) depends on the justification. For left justification, x is where the left edge of the string should appear. For center justification, x is where the center of the string should appear. And for right justification, x is where the right edge of the string should appear. This behavior is necessary because, for example, right justified text on the screen is justified with screen metrics. The same string needs to be justified with printer metrics on the printer to appear in the correct place with respect to other similarly justified strings. In all circumstances, y is the location of the baseline for the string.

result is modified to hold the Postscript code that will render the text layout.

Definition at line 1334 of file TGFont.cxx.

◆ UnderlineChar()

void TGTextLayout::UnderlineChar ( Drawable_t  dst,
GContext_t  gc,
Int_t  x,
Int_t  y,
Int_t  underline 
) const

Use the information in the TGTextLayout object to display an underline below an individual character.

This procedure does not draw the text, just the underline.

This procedure is useful for simple widgets that need to display single-font, multi-line text with an individual character underlined and want TGFont to handle the details. To display larger amounts of underlined text, construct and use an underlined font.

dst – Window or pixmap in which to draw. gc – Graphics context to use for drawing text. x, y – Upper-left hand corner of rectangle in which to draw (pixels). underline – Index of the single character to underline, or -1 for no underline.

Definition at line 970 of file TGFont.cxx.

Friends And Related Symbol Documentation

◆ TGFont

friend class TGFont
friend

Definition at line 108 of file TGFont.h.

Member Data Documentation

◆ fChunks

LayoutChunk_t* TGTextLayout::fChunks
protected

Array of chunks. The actual size will be maxChunks.

Definition at line 115 of file TGFont.h.

◆ fFont

const TGFont* TGTextLayout::fFont
protected

The font used when laying out the text.

Definition at line 111 of file TGFont.h.

◆ fNumChunks

Int_t TGTextLayout::fNumChunks
protected

Number of chunks actually used in following array.

Definition at line 114 of file TGFont.h.

◆ fString

const char* TGTextLayout::fString
protected

The string that was laid out.

Definition at line 112 of file TGFont.h.

◆ fWidth

Int_t TGTextLayout::fWidth
protected

The maximum width of all lines in the text layout.

Definition at line 113 of file TGFont.h.

Libraries for TGTextLayout:

The documentation for this class was generated from the following files: