OWLNext 7.0
Borland's Object Windows Library for the modern age
|
GdiObject is the root, pseudo-abstract base class for ObjectWindows' GDI (Graphics Device Interface) wrappers. More...
#include <owl/gdiobjec.h>
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? | |
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.
TGdiObject encapsulates an HGDIOBJ.
Definition at line 72 of file gdiobjec.h.
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.
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.
|
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.
|
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.
|
staticprotected |
Definition at line 87 of file gdibase.cpp.
|
protected |
Definition at line 86 of file gdibase.cpp.
|
inline |
Returns the handle of the GDI object.
Definition at line 1020 of file gdiobjec.h.
References Handle.
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.
|
inline |
Returns the type of the GDI object.
Definition at line 1063 of file gdiobjec.h.
References GetGdiHandle().
|
inline |
Returns true if this represents a real GDI object.
Definition at line 1071 of file gdiobjec.h.
References GetObjectType().
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.
|
inline |
Typecasting operator that converts this GDI object handle to type HGDIOBJ.
Definition at line 1028 of file gdiobjec.h.
bool owl::TGdiObject::operator< | ( | const TGdiObject & | other | ) | const |
not implemented just to make happy STL
|
inline |
Returns true if the handles are equal. This is a binary compare.
Definition at line 1036 of file gdiobjec.h.
References Handle.
|
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().
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().
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.
|
static |
Searches for the given object handle.
Definition at line 119 of file gdiobjec.cpp.
References LOCKOBJECTBAG.
Increments by 1 the reference count of the object associated with the given handle.
Definition at line 178 of file gdiobjec.cpp.
References RefFind().
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.
|
protected |
|
protected |