OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TFont Class Reference

TFont derived from TGdiObject provides constructors for creating font objects from explicit information or indirectly. More...

#include <owl/gdiobjec.h>

Inheritance diagram for owl::TFont:
owl::TGdiObject owl::TGdiBase owl::TDefaultGuiFont owl::TGadgetWindowFont

Public Types

typedef HFONT THandle
 
- Public Types inherited from owl::TGdiObject
enum  TType { None , Pen , Brush , Font , Palette , Bitmap , TextBrush }
 This enumeration is used to store the object type in the struct TObjInfo. More...
 
typedef HGDIOBJ THandle
 TGdiObject encapsulates an HGDIOBJ.
 

Public Member Functions

 TFont (HFONT handle, TAutoDelete autoDelete=NoAutoDelete)
 TFont encapsulates an HFONT.
 
 TFont (const tstring &facename=tstring(), int height=0, int width=0, int escapement=0, int orientation=0, int weight=FW_NORMAL, uint8 pitchAndFamily=DEFAULT_PITCH|FF_DONTCARE, uint8 italic=false, uint8 underline=false, uint8 strikeout=false, uint8 charSet=1, uint8 outputPrecision=OUT_DEFAULT_PRECIS, uint8 clipPrecision=CLIP_DEFAULT_PRECIS, uint8 quality=DEFAULT_QUALITY)
 Creates a TFont object with the given values.
 
 TFont (int height, int width, int escapement=0, int orientation=0, int weight=FW_NORMAL, uint8 italic=false, uint8 underline=false, uint8 strikeout=false, uint8 charSet=1, uint8 outputPrecision=OUT_DEFAULT_PRECIS, uint8 clipPrecision=CLIP_DEFAULT_PRECIS, uint8 quality=DEFAULT_QUALITY, uint8 pitchAndFamily=DEFAULT_PITCH|FF_DONTCARE, const tstring &facename=tstring())
 Creates a TFont object with the given values.
 
 TFont (const LOGFONT &logFont)
 Creates a TFont object from the given LOGFONT.
 
 TFont (const TFont &src)
 Creates an object that shares the source object's font handle.
 
HFONT GetHandle () const
 Returns the handle of the font with type HFONT.
 
 operator HFONT () const
 Typecasting operator that converts this font's Handle to type HFONT (the data type representing the handle to a physical font).
 
 operator LOGFONT () const
 
TEXTMETRIC GetTextMetrics (TDC &dc) const
 Retrieves information about this font when selected in the specified dc.
 
void GetTextMetrics (TEXTMETRIC &tm, TDC &dc) const
 Retrieves information about this font when selected in the specified dc.
 
TEXTMETRIC GetTextMetrics () const
 Retrieves information about this font when selected in a screen DC.
 
void GetTextMetrics (TEXTMETRIC &tm) const
 Retrieves information about this font when selected in a screen DC.
 
int GetHeight () const
 Returns the height of the font.
 
int GetHeight (TDC &dc) const
 Returns the height of the font if selected into the DC.
 
int GetAveWidth () const
 Returns the average width of the characters in the font.
 
int GetAveWidth (TDC &dc) const
 Returns the average width of the characters in the font if selected into the DC.
 
int GetMaxWidth () const
 Returns the maximum width of the characters in the font.
 
int GetMaxWidth (TDC &dc) const
 Returns the maximum width of the characters in the font if selected into the DC.
 
TSize GetTextExtent (const tstring &text) const
 Returns the extent of a given string using this particular font.
 
TSize GetTextExtent (TDC &dc, const tstring &text) const
 Returns the extent of a given string using this particular font in a particular DC.
 
tstring GetFaceName () const
 Returns the font's name.
 
uint8 GetPitchAndFamily () const
 Returns the pitch and family flags for this logical font.
 
LOGFONT GetObject () const
 Returns information about this font object.
 
- Public Member Functions inherited from owl::TGdiObject
 ~TGdiObject ()
 Decrement the reference count on this object.
 
HGDIOBJ GetGdiHandle () const
 Returns the handle of the GDI object.
 
 operator HGDIOBJ () const
 Typecasting operator that converts this GDI object handle to type HGDIOBJ.
 
int GetObject (int count, void *object) const
 Retrieve the object's attributes into a buffer.
 
bool operator== (const TGdiObject &other) const
 Returns true if the handles are equal. This is a binary compare.
 
bool operator< (const TGdiObject &other) const
 not implemented just to make happy STL
 
bool IsGDIObject () const
 Returns true if this represents a real GDI object.
 
uint32 GetObjectType () const
 Returns the type of the GDI object.
 
auto IsHandleOwner () const -> bool
 Returns true if handle lifetime is managed.
 

Additional Inherited Members

- Static Public Member Functions inherited from owl::TGdiObject
static TObjInfo * RefFind (HANDLE object)
 Searches for the given object handle.
 
static void RefAdd (HANDLE handle, TType type)
 RefAdd adds a reference entry for the object with the given handle and type.
 
static void RefRemove (HANDLE handle)
 Removes the reference entry to the object with the given handle.
 
static void RefInc (HANDLE handle)
 Increments by 1 the reference count of the object associated with the given handle.
 
static void RefDec (HANDLE handle, bool wantDelete)
 Decrements this object's reference count by 1 and deletes the object when the reference count reaches zero.
 
static int RefCount (HANDLE handle)
 Returns this object's current reference count or -1 if the object is not found.
 
- Protected Member Functions inherited from owl::TGdiObject
 TGdiObject ()
 This default constructor sets Handle to 0 and ShouldDelete to true.
 
 TGdiObject (HANDLE handle, TAutoDelete autoDelete=NoAutoDelete)
 Create a wrapper for a given GDI object.
 
void CheckValid (uint resId=IDS_GDIFAILURE)
 
- Static Protected Member Functions inherited from owl::TGdiObject
static void _CheckValid (HANDLE handle, uint resId=IDS_GDIFAILURE)
 
- Protected Attributes inherited from owl::TGdiObject
HANDLE Handle
 GDI handle of this object.
 
bool ShouldDelete
 Should object delete GDI handle in dtor?
 

Detailed Description

TFont derived from TGdiObject provides constructors for creating font objects from explicit information or indirectly.

Definition at line 296 of file gdiobjec.h.

Member Typedef Documentation

◆ THandle

Definition at line 300 of file gdiobjec.h.

Constructor & Destructor Documentation

◆ TFont() [1/5]

owl::TFont::TFont ( HFONT handle,
TAutoDelete autoDelete = NoAutoDelete )

TFont encapsulates an HFONT.

Creates a TFont object and sets the Handle data member to the given borrowed handle.

The ShouldDelete data member defaults to false, ensuring that the borrowed handle will not be deleted when the C++ object is destroyed.

Definition at line 37 of file font.cpp.

References owl::TGdiObject::Font, owl::TGdiObject::Handle, owl::TGdiObject::RefAdd(), and owl::TGdiObject::ShouldDelete.

◆ TFont() [2/5]

owl::TFont::TFont ( const tstring & facename = tstring(),
int height = 0,
int width = 0,
int escapement = 0,
int orientation = 0,
int weight = FW_NORMAL,
uint8 pitchAndFamily = DEFAULT_PITCH|FF_DONTCARE,
uint8 italic = false,
uint8 underline = false,
uint8 strikeout = false,
uint8 charSet = 1,
uint8 outputPrecision = OUT_DEFAULT_PRECIS,
uint8 clipPrecision = CLIP_DEFAULT_PRECIS,
uint8 quality = DEFAULT_QUALITY )

Creates a TFont object with the given values.

Definition at line 48 of file font.cpp.

References _T, owl::TGdiObject::CheckValid(), owl::TGdiObject::Font, owl::TGdiObject::Handle, owl::TGdiObject::RefAdd(), and WARNX.

◆ TFont() [3/5]

owl::TFont::TFont ( int height,
int width,
int escapement = 0,
int orientation = 0,
int weight = FW_NORMAL,
uint8 italic = false,
uint8 underline = false,
uint8 strikeout = false,
uint8 charSet = 1,
uint8 outputPrecision = OUT_DEFAULT_PRECIS,
uint8 clipPrecision = CLIP_DEFAULT_PRECIS,
uint8 quality = DEFAULT_QUALITY,
uint8 pitchAndFamily = DEFAULT_PITCH|FF_DONTCARE,
const tstring & facename = tstring() )

Creates a TFont object with the given values.

The constructor parameter list and default values match the Windows API CreateFont call.

Definition at line 69 of file font.cpp.

References _T, owl::TGdiObject::CheckValid(), owl::TGdiObject::Font, owl::TGdiObject::Handle, owl::TGdiObject::RefAdd(), and WARNX.

◆ TFont() [4/5]

owl::TFont::TFont ( const LOGFONT & logFont)

Creates a TFont object from the given LOGFONT.

Definition at line 92 of file font.cpp.

References owl::TGdiObject::CheckValid(), owl::TGdiObject::Font, owl::TGdiObject::Handle, owl::TGdiObject::RefAdd(), and WARNX.

◆ TFont() [5/5]

owl::TFont::TFont ( const TFont & src)

Creates an object that shares the source object's font handle.

If the source object owns the underlying font handle, this object will share it, i.e. calling this constructor is equivalent to the call TFont (src.GetHandle(), true). If the source object does not own the handle, neither will this object, i.e. this constructor is equivalent to the call TFont (src.GetHandle(), false).

Note
This contructor does not create a new font. To duplicate the underlying font instead call TFont (src.GetObject()), which will invoke TFont (const LOGFONT&).

Definition at line 128 of file font.cpp.

References _T, owl::TGdiObject::CheckValid(), owl::TGdiObject::Font, owl::TGdiObject::Handle, owl::TGdiObject::RefAdd(), owl::TGdiObject::ShouldDelete, and WARNX.

Member Function Documentation

◆ GetAveWidth() [1/2]

int owl::TFont::GetAveWidth ( ) const
inline

Returns the average width of the characters in the font.

Definition at line 1189 of file gdiobjec.h.

References GetTextMetrics().

◆ GetAveWidth() [2/2]

int owl::TFont::GetAveWidth ( TDC & dc) const
inline

Returns the average width of the characters in the font if selected into the DC.

Definition at line 1197 of file gdiobjec.h.

References GetTextMetrics().

◆ GetFaceName()

tstring owl::TFont::GetFaceName ( ) const

Returns the font's name.

Throws TXGdi on failure.

Definition at line 218 of file font.cpp.

References GetObject().

◆ GetHandle()

HFONT owl::TFont::GetHandle ( ) const
inline

Returns the handle of the font with type HFONT.

Definition at line 1142 of file gdiobjec.h.

References owl::TGdiObject::GetGdiHandle().

◆ GetHeight() [1/2]

int owl::TFont::GetHeight ( ) const
inline

Returns the height of the font.

Definition at line 1173 of file gdiobjec.h.

References GetTextMetrics().

◆ GetHeight() [2/2]

int owl::TFont::GetHeight ( TDC & dc) const
inline

Returns the height of the font if selected into the DC.

Definition at line 1181 of file gdiobjec.h.

References GetTextMetrics().

◆ GetMaxWidth() [1/2]

int owl::TFont::GetMaxWidth ( ) const
inline

Returns the maximum width of the characters in the font.

Definition at line 1205 of file gdiobjec.h.

References GetTextMetrics().

◆ GetMaxWidth() [2/2]

int owl::TFont::GetMaxWidth ( TDC & dc) const
inline

Returns the maximum width of the characters in the font if selected into the DC.

Definition at line 1214 of file gdiobjec.h.

References GetTextMetrics().

◆ GetObject()

LOGFONT owl::TFont::GetObject ( ) const

Returns information about this font object.

Throws TXGdi on failure.

Definition at line 238 of file font.cpp.

References owl::TGdiObject::GetObject(), and owl::TGdiObject::Handle.

◆ GetPitchAndFamily()

uint8 owl::TFont::GetPitchAndFamily ( ) const

Returns the pitch and family flags for this logical font.

Throws TXGdi on failure.

Definition at line 228 of file font.cpp.

References GetObject().

◆ GetTextExtent() [1/2]

TSize owl::TFont::GetTextExtent ( const tstring & text) const

Returns the extent of a given string using this particular font.

Definition at line 194 of file font.cpp.

References GetTextExtent().

◆ GetTextExtent() [2/2]

TSize owl::TFont::GetTextExtent ( TDC & dc,
const tstring & text ) const

Returns the extent of a given string using this particular font in a particular DC.

Definition at line 205 of file font.cpp.

References owl::TDC::GetTextExtent(), owl::TDC::RestoreFont(), and owl::TDC::SelectObject().

◆ GetTextMetrics() [1/4]

TEXTMETRIC owl::TFont::GetTextMetrics ( ) const

Retrieves information about this font when selected in a screen DC.

Definition at line 182 of file font.cpp.

References GetTextMetrics().

◆ GetTextMetrics() [2/4]

TEXTMETRIC owl::TFont::GetTextMetrics ( TDC & dc) const

Retrieves information about this font when selected in the specified dc.

Definition at line 161 of file font.cpp.

References GetTextMetrics().

◆ GetTextMetrics() [3/4]

void owl::TFont::GetTextMetrics ( TEXTMETRIC & tm) const

Retrieves information about this font when selected in a screen DC.

Definition at line 172 of file font.cpp.

References GetTextMetrics().

◆ GetTextMetrics() [4/4]

void owl::TFont::GetTextMetrics ( TEXTMETRIC & tm,
TDC & dc ) const

Retrieves information about this font when selected in the specified dc.

Definition at line 150 of file font.cpp.

References owl::TDC::GetTextMetrics(), owl::TDC::RestoreFont(), and owl::TDC::SelectObject().

◆ operator HFONT()

owl::TFont::operator HFONT ( ) const
inline

Typecasting operator that converts this font's Handle to type HFONT (the data type representing the handle to a physical font).

Definition at line 1151 of file gdiobjec.h.

◆ operator LOGFONT()

owl::TFont::operator LOGFONT ( ) const
inline

Definition at line 337 of file gdiobjec.h.


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