OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
createdc.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Implementation of classes TCreatedDC, and TIC
7//----------------------------------------------------------------------------
8#include <owl/pch.h>
9#include <owl/dc.h>
10
11namespace owl {
12
15
16//
17/// Creates a device context (DC) for the given device. DC objects can be
18/// constructed either by borrowing an existing HDC handle or by supplying device
19/// and driver information.
20//
22:
23 TDC()
24{
25 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TCreatedDC constructed @") << (void*)this);
26}
27
28//
29/// Creates a device context (DC) object for the device specified by driver
30/// (driver name) and device (device name). The optional initData argument provides
31/// a DEVMODE structure containing device-specific initialization data for this DC.
32/// Pass `nullptr` for initData to use the default initializations specified by the user.
33//
35 : TDC{}
36{
38 CheckValid();
39 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TCreatedDC constructed @") << static_cast<void*>(this)
40 << _T(" with driver ") << (driver ? driver : _T("NULL")));
41}
42
43//
44/// String-aware overload
45//
49
50#if defined(OWL5_COMPAT)
51
52//
53/// Creates a device context (DC) object for the device specified by driver
54/// (driver name), device (device name), and output (the name of the file or device
55/// [port] for the physical output medium). The optional initData argument provides
56/// a DEVMODE structure containing device-specific initialization data for this DC.
57/// initData must be 0 (the default) if the device is to use any default
58/// initializations specified by the user.
59//
62:
63 TDC()
64{
66 CheckValid();
67 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TCreatedDC constructed @") << (void*)this <<
68 _T(" with driver ") << (driver ? driver : _T("NULL")));
69}
70
71//
72/// String-aware overload
73//
75:
76 TDC()
77{
79 driver.empty() ? 0 : driver.c_str(),
80 device.empty() ? 0 : device.c_str(),
81 output.empty() ? 0 : output.c_str(),
82 initData);
83 CheckValid();
84 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TCreatedDC constructed @") << (void*)this <<
85 _T(" with driver ") << driver);
86}
87
88#endif
89
90//
91/// Creates a DC object using an existing DC.
92//
94:
96{
97 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TCreatedDC constructed @") << (void*)this <<
98 _T(" with handle ") << static_cast<void*>(handle));
99}
100
101//
102/// Destructor
103/// Calls RestoreObjects clears any nonzero OrgXXX data members. If ShouldDelete is
104/// true the destructor deletes this DC.
105//
107{
109 if (ShouldDelete && Handle)
111 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TCreatedDC destructed @") << (void*)this);
112}
113
114//
115/// Creates a device information context (IC) for the device specified by driver
116/// (driver name) and device (device name). The optional initData argument provides
117/// a DEVMODE structure containing device-specific initialization data for this DC.
118/// Pass `nullptr` for initData to use the default initializations specified by the user.
119//
121 : TCreatedDC{}
122{
123 Handle = static_cast<HANDLE>(::CreateIC(driver, device, nullptr, initData));
124 CheckValid();
125 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TIC constructed @") << static_cast<void*>(this)
126 << _T(" with driver ") << (driver ? driver : _T("NULL")));
127}
128
129//
130/// String-aware overload
131//
133 : TIC{driver.empty() ? nullptr : driver.c_str(), device.empty() ? nullptr : device.c_str(), initData}
134{}
135
136#if defined(OWL5_COMPAT)
137
138//
139/// Creates a DC object with the given driver, device, and port names and
140/// initialization values.
141//
144:
145 TCreatedDC()
146{
148 CheckValid();
149 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TIC constructed @") << (void*)this <<
150 _T(" with driver ") << (driver ? driver : _T("NULL")));
151}
152
153//
154/// String-aware overload
155//
156TIC::TIC(const tstring& driver, const tstring& device, const tstring& output, const DEVMODE* initData)
157:
158 TCreatedDC()
159{
160 HDC h = ::CreateIC(
161 driver.empty() ? 0 : driver.c_str(),
162 device.empty() ? 0 : device.c_str(),
163 output.empty() ? 0 : output.c_str(),
164 initData);
166 CheckValid();
167 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TIC constructed @") << (void*)this <<
168 _T(" with driver ") << driver);
169}
170
171#endif
172
173//
174//
175//
177{
178 TRACEX(OwlGDI, OWL_CDLEVEL, _T("TIC destructed @") << (void*)this);
179}
180
181} // OWL namespace
182/* ========================================================================== */
#define DIAG_DECLARE_GROUP(group)
Definition checks.h:404
#define TRACEX(group, level, message)
Definition checks.h:263
An abstract TDC class, TCreatedDC serves as the base for DCs that are created and deleted.
Definition dc.h:724
TCreatedDC()
Creates a device context (DC) for the given device.
Definition createdc.cpp:21
~TCreatedDC()
Destructor Calls RestoreObjects clears any nonzero OrgXXX data members.
Definition createdc.cpp:106
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
void RestoreObjects()
Restores all the original GDI objects to this DC.
Definition dc.cpp:298
void CheckValid(uint resId=IDS_GDIFAILURE)
Definition gdibase.cpp:49
bool ShouldDelete
< The handle of this DC. Uses the base class's handle (TGdiBase::Handle.)
Definition gdibase.h:82
HANDLE Handle
< make this function available to derivatives
Definition gdibase.h:81
Derived from TCreatedDC, TIC is a device context (DC) class that provides a constructor for creating ...
Definition dc.h:754
TIC(LPCTSTR driver, LPCTSTR device, const DEVMODE *initData=nullptr)
Creates a device information context (IC) for the device specified by driver (driver name) and device...
Definition createdc.cpp:120
#define _T(x)
Definition cygwin.h:51
Definition of GDI DC encapsulation classes: TDC, TWindowDC, TScreenDC, TDesktopDC,...
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
OWL_DIAGINFO
Definition animctrl.cpp:14
std::string tstring
Definition defs.h:79
#define OWL_CDLEVEL
Definition defs.h:171
#define STATIC_CAST(targetType, object)
Definition defs.h:271