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

GdiObject is the root, pseudo-abstract base class for ObjectWindows' GDI (Graphics Device Interface) wrappers. More...

#include <owl/gdiobjec.h>

Inheritance diagram for owl::TGdiObject:
owl::TGdiBase owl::TBitmap owl::TBrush owl::TFont owl::TPalette owl::TPen owl::TBtnBitmap owl::TDiBitmap owl::THatch8x8Brush owl::TDefaultGuiFont owl::TGadgetWindowFont owl::THalftonePalette owl::TIdentityPalette

Public Types

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

 ~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.
 

Static Public Member Functions

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

 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

static void _CheckValid (HANDLE handle, uint resId=IDS_GDIFAILURE)
 

Protected Attributes

HANDLE Handle
 GDI handle of this object.
 
bool ShouldDelete
 Should object delete GDI handle in dtor?
 

Detailed Description

GdiObject is the root, pseudo-abstract base class for ObjectWindows' GDI (Graphics Device Interface) wrappers.

The TGdiOject-based classes let you work with a GDI handle and construct a C++ object with an aliased handle. Some GDI objects are also based on TGdiObject for handle management. Generally, the TGdiObject-based class hierarchy handles all GDI objects apart from the DC (Device Context) objects handled by the TDC-based tree.

The five DC selectable classes (TPen, TBrush, TFont, TPalette, and TBitmap), and the TIcon, TCursor, TDib, and TRegion classes, are all derived directly from TGdiObject.

TGdiObject maintains the GDI handle and a ShouldDelete flag that determines if and when the handle and object should be destroyed. Protected constructors are provided for use by the derived classes: one for borrowed handles, and one for normal use.

Definition at line 68 of file gdiobjec.h.

Member Typedef Documentation

◆ THandle

TGdiObject encapsulates an HGDIOBJ.

Definition at line 72 of file gdiobjec.h.

Member Enumeration Documentation

◆ TType

This enumeration is used to store the object type in the struct TObjInfo.

This internal structure is used to track object reference counts during debugging sessions.

Enumerator
None 
Pen 
Brush 
Font 
Palette 
Bitmap 
TextBrush 

Definition at line 103 of file gdiobjec.h.

Constructor & Destructor Documentation

◆ ~TGdiObject()

owl::TGdiObject::~TGdiObject ( )

Decrement the reference count on this object.

If ShouldDelete is false no action is taken. Otherwise, the reference count for the object's handle is decremented, and if it reaches zero, the handle is is deleted.

Definition at line 301 of file gdiobjec.cpp.

References Handle, RefDec(), ShouldDelete, and TRACEX.

◆ TGdiObject() [1/2]

owl::TGdiObject::TGdiObject ( )
protected

This default constructor sets Handle to 0 and ShouldDelete to true.

This constructor is intended for use by derived classes that must set the Handle member.

Definition at line 273 of file gdiobjec.cpp.

References TRACEX.

◆ TGdiObject() [2/2]

owl::TGdiObject::TGdiObject ( HANDLE handle,
TAutoDelete autoDelete = NoAutoDelete )
protected

Create a wrapper for a given GDI object.

This constructor is intended for use by derived classes only. The Handle data member is "borrowed" from an existing handle given by the argument handle The ShouldDelete data member defaults to false ensuring that the borrowed handle will not be deleted when the object is destroyed.

Definition at line 287 of file gdiobjec.cpp.

References TRACEX.

Member Function Documentation

◆ _CheckValid()

void owl::TGdiBase::_CheckValid ( HANDLE handle,
uint resId = IDS_GDIFAILURE )
staticprotected

Definition at line 87 of file gdibase.cpp.

◆ CheckValid()

void owl::TGdiBase::CheckValid ( uint resId = IDS_GDIFAILURE)
protected

Definition at line 86 of file gdibase.cpp.

◆ GetGdiHandle()

HGDIOBJ owl::TGdiObject::GetGdiHandle ( ) const
inline

Returns the handle of the GDI object.

Definition at line 1020 of file gdiobjec.h.

References Handle.

◆ GetObject()

int owl::TGdiObject::GetObject ( int count,
void * object ) const
inline

Retrieve the object's attributes into a buffer.

Obtains information about this GDI object and places it in the object buffer. If the call succeeds and object is not 0, GetObject returns the number of bytes copied to the object buffer. If the call succeeds and object is 0, GetObject returns the number of bytes needed in the object buffer for the type of object being queried. Depending on what type of GDI object is derived, this function retrieves a LOGPEN, LOGBRUSH, LOGFONT, or BITMAP structure through object.

Definition at line 1051 of file gdiobjec.h.

References Handle.

◆ GetObjectType()

uint32 owl::TGdiObject::GetObjectType ( ) const
inline

Returns the type of the GDI object.

Definition at line 1063 of file gdiobjec.h.

References GetGdiHandle().

◆ IsGDIObject()

bool owl::TGdiObject::IsGDIObject ( ) const
inline

Returns true if this represents a real GDI object.

Definition at line 1071 of file gdiobjec.h.

References GetObjectType().

◆ IsHandleOwner()

auto owl::TGdiObject::IsHandleOwner ( ) const -> bool
inline

Returns true if handle lifetime is managed.

Note that many objects may share a handle. If a handle is owned, reference-counting is used to ensure that the handle is deleted when the last owner is destructed.

Definition at line 98 of file gdiobjec.h.

◆ operator HGDIOBJ()

owl::TGdiObject::operator HGDIOBJ ( ) const
inline

Typecasting operator that converts this GDI object handle to type HGDIOBJ.

Definition at line 1028 of file gdiobjec.h.

◆ operator<()

bool owl::TGdiObject::operator< ( const TGdiObject & other) const

not implemented just to make happy STL

◆ operator==()

bool owl::TGdiObject::operator== ( const TGdiObject & other) const
inline

Returns true if the handles are equal. This is a binary compare.

Definition at line 1036 of file gdiobjec.h.

References Handle.

◆ RefAdd()

void owl::TGdiObject::RefAdd ( HANDLE handle,
TGdiObject::TType type )
static

RefAdd adds a reference entry for the object with the given handle and type.

If the table already has a matching entry, no action is taken, otherwise the reference count is set to 1.

Definition at line 137 of file gdiobjec.cpp.

References LOCKOBJECTBAG, and RefFind().

◆ RefCount()

int owl::TGdiObject::RefCount ( HANDLE handle)
static

Returns this object's current reference count or -1 if the object is not found.

Definition at line 242 of file gdiobjec.cpp.

References RefFind().

◆ RefDec()

void owl::TGdiObject::RefDec ( HANDLE handle,
bool wantDelete )
static

Decrements this object's reference count by 1 and deletes the object when the reference count reaches zero.

A warning is issued if the deletion was supposed to happen but didn't. Likewise, a warning is issued if the deletion wasn't supposed to happen but did. The deleted object is also detached from the ObjInfoBag table.

You can vary the normal deletion strategy by setting wantDelete to true or false.

Definition at line 200 of file gdiobjec.cpp.

References owl::InUse(), LOCKOBJECTBAG, owl::TXGdi::Raise(), RefFind(), and TRACEX.

◆ RefFind()

TObjInfo * owl::TGdiObject::RefFind ( HANDLE handle)
static

Searches for the given object handle.

Returns
If found, the object's type and reference count are returned in the specified TObjInfo object. RefFind returns 0 if no match is found.

Definition at line 119 of file gdiobjec.cpp.

References LOCKOBJECTBAG.

◆ RefInc()

void owl::TGdiObject::RefInc ( HANDLE handle)
static

Increments by 1 the reference count of the object associated with the given handle.

Definition at line 178 of file gdiobjec.cpp.

References RefFind().

◆ RefRemove()

void owl::TGdiObject::RefRemove ( HANDLE handle)
static

Removes the reference entry to the object with the given handle.

If the given handle is not found, no action is taken.

Definition at line 163 of file gdiobjec.cpp.

References LOCKOBJECTBAG.

Member Data Documentation

◆ Handle

HANDLE owl::TGdiBase::Handle
protected

GDI handle of this object.

Definition at line 81 of file gdibase.h.

◆ ShouldDelete

bool owl::TGdiBase::ShouldDelete
protected

Should object delete GDI handle in dtor?

Definition at line 82 of file gdibase.h.


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