OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
dc.h
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/// Definition of GDI DC encapsulation classes:
7/// TDC, TWindowDC, TScreenDC, TDesktopDC, TClientDC, TPaintDC, TMetaFileDC,
8/// TCreatedDC, TIC, TMemoryDC, TDibDC, TPrintDC
9//----------------------------------------------------------------------------
10
11#if !defined(OWL_DC_H)
12#define OWL_DC_H
13
14#include <owl/private/defs.h>
15#if defined(BI_HAS_PRAGMA_ONCE)
16# pragma once
17#endif
18
19#include <owl/gdibase.h>
20#include <owl/geometry.h>
21
22
23namespace owl {
24
25class _OWLCLASS TPen;
26class _OWLCLASS TBrush;
27class _OWLCLASS TFont;
28class _OWLCLASS TBitmap;
29class _OWLCLASS TPalette;
30class _OWLCLASS TIcon;
31class _OWLCLASS TCursor;
32class _OWLCLASS TDib;
33class _OWLCLASS TRegion;
34class _OWLCLASS TMetaFilePict;
35class _OWLCLASS TEnhMetaFilePict;
36
37#include <owl/preclass.h>
38
39/// \addtogroup dc
40/// @{
41/// \class TDC
42// ~~~~~ ~~~
43/// TDC is the root class for GDI DC wrappers. Each TDC object inherits a Handle
44/// from TGdiBase and casts that Handle to an HDC using the HDC operator. Win API
45/// functions that take an HDC argument can therefore be called by a corresponding
46/// TDC member function without this explicit handle argument.
47///
48/// DC objects can be created directly with TDC constructors, or via the
49/// constructors of specialized subclasses (such as TWindowDC, TMemoryDC,
50/// TMetaFileDC, TDibDC, and TPrintDC) to get specific behavior. DC objects can be
51/// constructed with an already existing and borrowed HDC handle or from scratch by
52/// supplying device driver information, as with ::CreateDC. The class TCreateDC
53/// takes over much of the creation and deletion work from TDC.
54///
55/// TDC has four handles as protected data members: OrgBrush, OrgPen, OrgFont, and
56/// OrgPalette. These handles keep track of the stock GDI objects selected into each
57/// DC. As new GDI objects are selected with SelectObject or SelectPalette, these
58/// data members store the previous objects. The latter can be restored individually
59/// with RestoreBrush, RestorePen, and so on, or they can all be restored with
60/// RestoreObjects. When a TDC object is destroyed (via ~TDC::TDC), all the
61/// originally selected objects are restored. The data member TDC::ShouldDelete
62/// controls the deletion of the TDC object.
63//
64class _OWLCLASS TDC : protected TGdiBase {
65 public:
66 /// Which edge(s) to draw. ctor defaults to all 4
67 enum TFlag {
68 Left = 0x0001,
69 Top = 0x0002,
70 Right = 0x0004,
71 Bottom = 0x0008,
72 TopLeft = Top | Left,
73 TopRight = Top | Right,
74 BottomLeft = Bottom | Left,
75 BottomRight = Bottom | Right,
76 Rect = Top | Left | Bottom | Right,
77
78 Diagonal = 0x0010, ///< Draw diagonal edge (NotAvail intrnl)
79 Fill = 0x0800, ///< Fill in middle
80 Soft = 0x1000, ///< Soft edge look for buttons
81 Adjust = 0x2000, ///< Adjust passed rect to client (Not Applicable)
82 Flat = 0x4000, ///< Flat instead of 3d for use in non-3d windows
83 Mono = 0x8000 ///< Monochrome
84 };
85
86 /// Enumeration describing hilevel border styles
87 //
88 enum TStyle {
89 None, ///< No border painted at all
90 Plain, ///< Plain plain window frame
91 Raised, ///< Status field style raised
92 Recessed, ///< Status field style recessed
93 Embossed, ///< Grouping raised emboss bead
94 Grooved, ///< Grouping groove
95 ButtonUp, ///< Button in up position
96 ButtonDn, ///< Button in down position
97 WndRaised, ///< Raised window outer+inner edge
98 WndRecessed, ///< Input field & other window recessed
99 WellSet, ///< Well option set (auto grows + 1) // !CQ W4 cant do
100 ButtonUp3x, ///< Button in up position, Win 3.x style
101 ButtonDn3x ///< Button in down position, Win 3.x style
102 };
103// TUIBorder(const TRect& frame, TStyle style, uint flags = 0);
104
105 /// Enumeration describing the type of edge to be drawn
106 //
107 enum TEdge {
108 RaisedOuter = 0x01, ///< Raised outer edge only
109 SunkenOuter = 0x02, ///< Sunken outer edge only
110 RaisedInner = 0x04, ///< Raised inner edge only
111 SunkenInner = 0x08, ///< Sunken inner edge only
112 EdgeOuter = 0x03, ///< Mask for outer edge bits
113 EdgeInner = 0x0C, ///< Mask for inner edge bits
114 EdgeRaised = RaisedOuter | RaisedInner, ///< Both inner & outer raised
115 EdgeSunken = SunkenOuter | SunkenInner, ///< Both inner & outer sunken
116 EdgeEtched = SunkenOuter | RaisedInner, ///< Outer sunken, inner raised
117 EdgeBump = RaisedOuter | SunkenInner ///< Outer raised, inner sunken
118 };
119
120 // Constructors / destructor
121 //
122 TDC(HDC handle); ///< use an existing DC, doesn't auto delete it
123
124 TDC(); ///< for derived classes only
125
126 virtual ~TDC();
127
128 // Type Conversion Operators
129 //
130 operator HDC() const; ///< Must assume const is OK
131
132 /// Validation routine - used mainly for diagnostic purposes
133 //
134 bool IsDC() const;
135
136 // DC functions
137 //
138
139 void SetDC(HDC hdc) { Handle = hdc; } // DLN
140 bool GetDCOrg(TPoint& point) const;
141 virtual int SaveDC() const;
142 virtual bool RestoreDC(int savedDC = -1);
143 virtual int GetDeviceCaps(int index) const;
144 virtual bool ResetDC(const DEVMODE& devMode);
145
146 // Select GDI objects into this DC and restore them to original
147 //
148 void SelectObject(const TBrush& brush);
149 void SelectObject(const TPen& pen);
150 virtual void SelectObject(const TFont& font);
151 void SelectObject(const TPalette& palette, bool forceBackground=false);
152 void SelectObject(const TBitmap& bitmap);
153 virtual void SelectStockObject(int index);
154 void RestoreBrush();
155 void RestorePen();
156 virtual void RestoreFont();
157 void RestorePalette();
158 void RestoreBitmap();
159 void RestoreTextBrush();
160 void RestoreObjects();
161 HANDLE GetCurrentObject(uint objectType) const;
162
163 // Drawing tool functions
164 //
165 bool GetBrushOrg(TPoint& point) const;
166 bool SetBrushOrg(const TPoint& origin, TPoint * oldOrg=nullptr);
167 int EnumObjects(uint objectType, GOBJENUMPROC proc, void * data) const;
168
169 // Color and palette functions
170 //
171 TColor GetNearestColor(const TColor& color) const;
172 int RealizePalette();
173 void UpdateColors();
174 uint GetSystemPaletteEntries(int start, int num,
175 PALETTEENTRY * entries) const;
176 uint GetSystemPaletteUse() const;
177 int SetSystemPaletteUse(int usage);
178
179 // Drawing attribute functions
180 //
181 TColor GetBkColor() const;
182 virtual TColor SetBkColor(const TColor& color);
183 int GetBkMode() const;
184 int SetBkMode(int mode);
185 int GetPolyFillMode() const;
186 int SetPolyFillMode(int mode);
187 int GetROP2() const;
188 int SetROP2(int mode);
189 int GetStretchBltMode() const;
190 int SetStretchBltMode(int mode);
191 TColor GetTextColor() const;
192 virtual TColor SetTextColor(const TColor& color);
193
194 bool SetMiterLimit(float newLimit, float* oldLimit=nullptr);
195
196 // Viewport & window mapping functions
197 //
198 int GetMapMode() const;
199 virtual int SetMapMode(int mode);
200
201 bool SetWorldTransform(XFORM & xform);
202 bool ModifyWorldTransform(XFORM & xform, uint32 mode);
203
204 bool GetViewportOrg(TPoint& point) const;
205 TPoint GetViewportOrg() const;
206 virtual bool SetViewportOrg(const TPoint& origin, TPoint * oldOrg=nullptr);
207 virtual bool OffsetViewportOrg(const TPoint& delta, TPoint * oldOrg=nullptr);
208
209 bool GetViewportExt(TSize& extent) const;
210 TSize GetViewportExt() const;
211 virtual bool SetViewportExt(const TSize& extent, TSize * oldExtent=nullptr);
212 virtual bool ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom,
213 TSize * oldExtent=nullptr);
214
215 bool GetWindowOrg(TPoint& point) const;
216 TPoint GetWindowOrg() const;
217 bool SetWindowOrg(const TPoint& origin, TPoint * oldOrg=nullptr);
218 bool OffsetWindowOrg(const TPoint& delta, TPoint * oldOrg=nullptr);
219
220 bool GetWindowExt(TSize& extent) const;
221 TSize GetWindowExt() const;
222 virtual bool SetWindowExt(const TSize& extent, TSize * oldExtent=nullptr);
223 virtual bool ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom,
224 TSize * oldExtent=nullptr);
225
226 // Coordinate functions
227 //
228 bool DPtoLP(TPoint* points, int count = 1) const;
229 bool DPtoLP(TRect& rect) const;
230 bool LPtoDP(TPoint* points, int count = 1) const;
231 bool LPtoDP(TRect& rect) const;
232
233 // Clip & Update Rect & Rgn functions
234 //
235 int GetClipBox(TRect& rect) const;
236 TRect GetClipBox() const;
237 int ExcludeClipRect(const TRect& rect);
238 int ExcludeUpdateRgn(HWND wnd);
239 int IntersectClipRect(const TRect& rect);
240 int OffsetClipRgn(const TPoint& delta);
241 int SelectClipRgn(const TRegion& region);
242
243 //
244 /// Selects the given region as the current clipping region for the device context.
245 /// The default argument 0 has the effect of removing the device context's clipping region.
246 //
247 int SelectClipRgn(HRGN r = 0) {return ::SelectClipRgn(GetHDC(), r);}
248
249 //
250 /// Removes the device context's clipping region.
251 /// Has the same effect as calling SelectClipRgn with no argument (or NULL).
252 //
253 int RemoveClipRgn() {return SelectClipRgn();}
254
255 bool PtVisible(const TPoint& point) const;
256 bool RectVisible(const TRect& rect) const;
257 bool GetBoundsRect(TRect& bounds, uint16 flags) const;
258 uint SetBoundsRect(TRect& bounds, uint flags);
259 int GetClipRgn(TRegion& region) const;
260
261 // MetaFile functions
262 //
263 int EnumMetaFile(const TMetaFilePict& metaFile,
264 MFENUMPROC callback, void * data) const;
265 bool PlayMetaFile(const TMetaFilePict& metaFile);
266 void PlayMetaFileRecord(HANDLETABLE & handletable,
267 METARECORD & metaRecord, int count);
268 int EnumEnhMetaFile(const TEnhMetaFilePict& metaFile,
270 const TRect* rect) const;
271 bool PlayEnhMetaFile(const TEnhMetaFilePict& metaFile, const TRect* rect);
272 void PlayEnhMetaFileRecord(HANDLETABLE& handletable,
274
275 // Output functions- Current position
276 //
277 bool GetCurrentPosition(TPoint& point) const;
278 bool MoveTo(int x, int y);
279 bool MoveTo(const TPoint& point);
280 bool MoveTo(const TPoint& point, TPoint& oldPoint);
281
282 // Output functions- Icons & cursors
283 //
284 bool DrawIcon(int x, int y, const TIcon& icon);
285 bool DrawIcon(const TPoint& point, const TIcon& icon);
286 bool DrawCursor(int x, int y, const TCursor& cursor);
287 bool DrawCursor(const TPoint& point, const TCursor& cursor);
288 bool DrawIcon(int x, int y, const TIcon& icon, int w, int h,
289 int aniStep=0, HBRUSH bkBr=0, uint flags=DI_NORMAL);
290 bool DrawIcon(const TPoint& point, const TIcon& icon,
291 const TSize& size, int aniStep=0, HBRUSH bkBr=0,
292 uint flags=DI_NORMAL);
293 bool DrawCursor(int x, int y, const TCursor& cursor, int w, int h,
294 int aniStep=0, HBRUSH bkBr=0, uint flags=DI_NORMAL);
295 bool DrawCursor(const TPoint& point, const TCursor& cursor,
296 const TSize& size, int aniStep=0, HBRUSH bkBr=0,
297 uint flags=DI_NORMAL);
298
299 // Output functions- Rects
300 //
301 bool FrameRect(int x1, int y1, int x2, int y2, const TBrush& brush);
302 bool FrameRect(const TRect& rect, const TBrush& brush);
303 bool FillRect(int x1, int y1, int x2, int y2, const TBrush& brush);
304 bool FillRect(const TRect& rect, const TBrush& brush);
305 bool InvertRect(int x1, int y1, int x2, int y2);
306 bool InvertRect(const TRect& rect);
307 bool DrawFocusRect(int x1, int y1, int x2, int y2);
308 bool DrawFocusRect(const TRect& rect);
309
310 bool DrawEdge(const TRect& frame, uint edge, uint flags);
311 void PaintFrame(const TRect& fr, uint flags, const TColor& tlColor, const TColor& brColor);
312 // Filled rect using ExtTextOut, no dithered colors & uses or sets BkColor
313 //
314 bool TextRect(int x1, int y1, int x2, int y2);
315 bool TextRect(const TRect& rect);
316 bool TextRect(int x1, int y1, int x2, int y2, const TColor& color);
317 bool TextRect(const TRect& rect, const TColor& color);
318 bool FillSolidRect(const TRect& r, const TColor& color) {return TextRect(r,color);}
319
320 //
321 //
322 void OWLFastWindowFrame(TBrush &brush, TRect &r, int xWidth, int yWidth, uint32 rop = PATCOPY);
323
324 // Output functions- Regions
325 //
326 bool FrameRgn(const TRegion& region, const TBrush& brush, const TSize& brushSize);
327 bool FillRgn(const TRegion& region, const TBrush& brush);
328 bool InvertRgn(const TRegion& region);
329 bool PaintRgn(const TRegion& region);
330
331 // Output functions- Shapes
332 //
333 bool AngleArc(int x, int y, uint32 radius, float startAngle,
334 float sweepAngle);
335 bool AngleArc(const TPoint& center, uint32 radius, float startAngle,
336 float sweepAngle);
337 bool Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
338 int y4);
339 bool Arc(const TRect& r, const TPoint& start, const TPoint& end);
340 bool Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
341 int y4);
342 bool Chord(const TRect& R, const TPoint& Start, const TPoint& End);
343 bool Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4,
344 int y4);
345 bool Pie(const TRect& rect, const TPoint& start, const TPoint& end);
346 bool Ellipse(int x1, int y1, int x2, int y2);
347 bool Ellipse(const TPoint& p1, const TPoint& p2);
348 bool Ellipse(const TPoint& point, const TSize& size);
349 bool Ellipse(const TRect& rect);
350 bool LineTo(int x, int y);
351 bool LineTo(const TPoint& point);
352 bool Polyline(const TPoint* points, int count);
353 bool Polygon(const TPoint* points, int count);
354 bool PolyPolygon(const TPoint* points, const int* PolyCounts,
355 int count);
356 bool PolyPolyline(const TPoint* points, const int* PolyCounts,
357 int count);
358 bool PolyBezier(const TPoint* points, int count);
359 bool PolyBezierTo(const TPoint* points, int count);
360 bool PolyDraw(const TPoint* points, uint8* types, int count);
361 bool PolylineTo(const TPoint* points, int count);
362 bool Rectangle(int x1, int y1, int x2, int y2);
363 bool Rectangle(const TPoint& p1, const TPoint& p2);
364 bool Rectangle(const TPoint& point, const TSize& s);
365 bool Rectangle(const TRect& rect);
366 bool RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);
367 bool RoundRect(const TPoint& p1, const TPoint& p2, const TPoint& rad);
368 bool RoundRect(const TPoint& p, const TSize& s, const TPoint& rad);
369 bool RoundRect(const TRect& rect, const TPoint& rad);
370
371 // Output functions- bitmaps & blitting
372 //
373 TColor GetPixel(int x, int y) const;
374 TColor GetPixel(const TPoint& point) const;
375 TColor SetPixel(int x, int y, const TColor& color);
376 TColor SetPixel(const TPoint& p, const TColor& color);
377 bool BitBlt(int dstX, int dstY, int w, int h, const TDC& srcDC,
378 int srcX, int srcY, uint32 rop=SRCCOPY);
379 bool BitBlt(const TRect& dst, const TDC& srcDC,
380 const TPoint& src, uint32 rop=SRCCOPY);
381 bool PatBlt(int x, int y, int w, int h, uint32 rop=PATCOPY);
382 bool PatBlt(const TRect& dst, uint32 rop=PATCOPY);
383 bool ScrollDC(int x, int y, const TRect& scroll, const TRect& clip,
385 bool ScrollDC(const TPoint& delta, const TRect& scroll,
386 const TRect& clip, TRegion& updateRgn,
388 bool StretchBlt(int dstX, int dstY, int dstW, int dstH,
389 const TDC& srcDC, int srcX, int srcY, int srcW,
390 int srcH, uint32 rop=SRCCOPY);
391 bool StretchBlt(const TRect& dst, const TDC& srcDC,
392 const TRect& src, uint32 rop=SRCCOPY);
393 bool MaskBlt(const TRect& dst, const TDC& srcDC,
394 const TPoint& src, const TBitmap& maskBm,
396 bool PlgBlt(const TPoint* points, const TDC& srcDC,
397 const TRect& src, const TBitmap& maskBm,
398 const TPoint& maskPos);
399#if defined(OWL5_COMPAT)
400 bool PlgBlt(const TPoint& dst, const TDC& srcDC,
401 const TRect& src, const TBitmap& maskBm,
402 const TPoint& maskPos);
403#endif
404 bool TransparentBlt(const TRect& dst, const TDC& srcDC, const TRect& src, const TColor& transparent);
405 int GetDIBits(const TBitmap& bitmap, uint startScan, uint numScans,
406 void * bits, const BITMAPINFO & info,
407 uint16 usage);
408 int GetDIBits(const TBitmap& bitmap, TDib& dib);
409 int SetDIBits(TBitmap& bitmap, uint startScan, uint numScans,
410 const void * bits, const BITMAPINFO & Info,
411 uint16 usage);
412 int SetDIBits(TBitmap& bitmap, const TDib& dib);
413 int SetDIBitsToDevice(const TRect& dst, const TPoint& src,
415 const void * bits,
417 int SetDIBitsToDevice(const TRect& dst, const TPoint& src,
418 const TDib& dib);
419 int StretchDIBits(const TRect& dst, const TRect& src,
420 const void * bits,
421 const BITMAPINFO & bitsInfo,
423 int StretchDIBits(const TRect& dst, const TRect& src,
424 const TDib& dib, uint32 rop=SRCCOPY);
425
426 HBITMAP CreateDIBSection(const BITMAPINFO& info, uint usage, void** bits, HANDLE section=0, uint32 offset=0);
427
428 bool FloodFill(const TPoint& point, const TColor& color);
429 bool ExtFloodFill(const TPoint& point, const TColor& color, uint16 fillType);
430
431 // Output functions- text
432 //
433 virtual bool TextOut(int x, int y,
434 const tstring& str, int count = -1);
435
436 bool TextOut(const TPoint& p,
437 const tstring& str, int count = -1);
438
439 virtual bool ExtTextOut(int x, int y, uint16 options, const TRect* r,
440 const tstring& str, int count = -1, const int * dx = nullptr);
441
442 bool ExtTextOut(const TPoint& p, uint16 options, const TRect* r,
443 const tstring& str, int count = -1, const int * dx = nullptr);
444
445 virtual bool TabbedTextOut(const TPoint& p,
446 const tstring& str, int count,
447 int numPositions, const int* positions, int tabOrigin, TSize& size);
448
449 bool TabbedTextOut(const TPoint& p,
450 const tstring& str, int count,
451 int numPositions, const int* positions, int tabOrigin);
452
453 int DrawText(const tstring& str, int count, const TRect&, uint16 format = 0);
454
455 virtual int DrawText(const tstring& str, int count, TRect&, uint16 format = 0);
456
457 virtual int DrawTextEx(LPTSTR str, int count, TRect* = nullptr,
458 uint format=0, LPDRAWTEXTPARAMS = nullptr);
459
460 bool DrawFrameControl(TRect lpRect, UINT nType, UINT nState);
461
462 virtual bool GrayString(const TBrush& brush, GRAYSTRINGPROC outputFunc,
463 const tstring& str, int count, const TRect& r);
464
465 bool GetTextExtent(const tstring& str, int stringLen, TSize& size) const;
466
467 TSize GetTextExtent(const tstring& str, int stringLen) const;
468
469 bool GetTabbedTextExtent(const tstring& str, int stringLen,
470 int numPositions, const int * positions, TSize& size) const;
471
472 TSize GetTabbedTextExtent(const tstring& str, int stringLen,
473 int numPositions, const int * positions) const;
474
475 uint GetTextAlign() const;
476
477 uint SetTextAlign(uint flags);
478
479 int GetTextCharacterExtra() const;
480
481 int SetTextCharacterExtra(int extra);
482
483 bool SetTextJustification(int breakExtra, int breakCount);
484
485 int GetTextFaceLength() const;
486
487 int GetTextFace(int count, LPTSTR facename) const;
488
489 tstring GetTextFace() const;
490
491 bool GetTextMetrics(TEXTMETRIC & metrics) const;
492 TEXTMETRIC GetTextMetrics() const;
493
494 uint32 GetGlyphOutline(uint chr, uint format, GLYPHMETRICS & gm,
495 uint32 buffSize, void* buffer, const MAT2 & mat2);
496
497 int GetKerningPairs(int pairs, KERNINGPAIR * krnPair);
498
499 uint GetOutlineTextMetrics(uint data, OUTLINETEXTMETRIC & otm);
500
501 // Font functions
502 //
503 bool GetCharWidth(uint firstChar, uint lastChar, int* buffer);
504 uint32 SetMapperFlags(uint32 flag);
505 bool GetAspectRatioFilter(TSize& size) const;
507 void * data) const;
508
510 {return EnumFonts(facename.c_str(), callback, data);}
511
512 int EnumFontFamilies(LPCTSTR family,
513 FONTENUMPROC proc, void * data) const;
514
516 {return EnumFontFamilies(family.c_str(), proc, data);}
517
518 uint32 GetFontData(uint32 table, uint32 offset, void* buffer, long data);
519 bool GetCharABCWidths(uint firstChar, uint lastChar, ABC* abc);
520
521 // Path functions
522 //
523 bool BeginPath();
524 bool CloseFigure();
525 bool EndPath();
526 bool FlattenPath();
527 bool WidenPath();
528 bool FillPath();
529 bool StrokePath();
530 bool StrokeAndFillPath();
531 bool SelectClipPath(int mode);
532 HRGN PathToRegion();
533
534 // Override to implement a twin DC object, like TPrintPreviewDC
535 //
536 virtual HDC GetAttributeHDC() const;
537 HDC GetHDC() const;
538
539 protected:
540// TDC(); // For use by derived classes only
541 TDC(HDC handle, TAutoDelete autoDelete); //use an existing DC
542 void Init();
543
544 protected:
545 using TGdiBase::CheckValid; ///< make this function available to derivatives
546 using TGdiBase::Handle; ///< The handle of this DC. Uses the base class's handle (TGdiBase::Handle.)
547 using TGdiBase::ShouldDelete; ///< Should object delete the Handle in dtor?
548
550
551/// Handle to the original GDI brush object for this DC. Holds the previous brush
552/// object whenever a new brush is selected with SelectObject(brush).
553 HBRUSH OrgBrush;
554
555/// Handle to the original GDI pen object for this DC. Holds the previous pen object
556/// whenever a new pen is selected with SelectObject(pen).
557 HPEN OrgPen;
558
559/// Handle to the original GDI font object for this DC. Holds the previous font
560/// object whenever a new font is selected with SelectObject(font).
561 HFONT OrgFont;
562
563/// Handle to the original GDI palette object for this DC. Holds the previous
564/// palette object whenever a new palette is selected with SelectObject(palette).
565 HPALETTE OrgPalette;
566
567 HBITMAP OrgBitmap;
568
569/// The handle to the original GDI text brush object for this DC.
570/// Stores the previous text brush handle whenever a new brush is selected with
571/// SelectObject(text_brush).
572 HBRUSH OrgTextBrush;
573
574 private:
575 // Hidden to prevent accidental copying or assignment
576 //
577 TDC(const TDC&);
578 TDC& operator =(const TDC&);
579};
580
581//
582/// \class TWindowDC
583// ~~~~~ ~~~~~~~~~
584/// Derived from TDC, TWindowDC is a device context (DC) class that provides access
585/// to the entire area owned by a window. TWindowDC is the base class for any DC
586/// class that releases its handle when it is finished.
587//
588class _OWLCLASS TWindowDC : public TDC {
589 public:
591 ~TWindowDC();
592
593 protected:
594/// Holds a handle to the window owned by this device context.
596 TWindowDC(); // for derived classes
597
598 private:
599 TWindowDC(const TWindowDC&);
601};
602
603//
604/// \class TScreenDC
605// ~~~~~ ~~~~~~~~~
606/// Derived from TWindowDC, TScreenDC is a DC class that provides direct access to
607/// the screen bitmap. TScreenDC gets a DC for handle 0, which is for the whole
608/// screen with no clipping. Handle 0 paints on top of other windows.
609//
611 public:
612 TScreenDC();
613
614 private:
615 TScreenDC(const TScreenDC&);
617};
618
619//
620/// \class TDesktopDC
621// ~~~~~ ~~~~~~~~~~
622/// A DC class that provides access to the desktop window's client area which
623/// is the window behind all other windows.
624//
626 public:
627 TDesktopDC();
628
629 private:
630 TDesktopDC(const TDesktopDC&);
632};
633
634//
635/// \class TClientDC
636// ~~~~~ ~~~~~~~~~
637/// A device context class derived from TWindowDC, TClientDC provides access to the
638/// client area owned by a window.
639//
641 public:
643
644 private:
645 TClientDC(const TClientDC&);
647};
648
649//
650// \class TNCPaintDC
651// ~~~~~ ~~~~~~~~~
652/// A DC class that provides access to the non-client area owned by a window.
653//
655public:
656 //hPaintRgn is the WParam of WM_NCPAINT
658
659private:
660 TNCPaintDC(const TNCPaintDC&);
662};
663
664
665//
666/// \class TPaintDC
667// ~~~~~ ~~~~~~~~
668/// A DC class that wraps begin and end paint calls for use in an WM_PAINT
669/// response function.
670//
671class _OWLCLASS TPaintDC : public TDC {
672 public:
674 ~TPaintDC();
675
676/// The paint structure associated with this TPaintDC object.
678
679 protected:
680/// The associated window handle.
682
683 private:
684 TPaintDC(const TPaintDC&);
686};
687
688//
689/// \class TMetaFileDC
690// ~~~~~ ~~~~~~~~~~~
691/// A DC class that provides access to a DC with a metafile selected into it
692/// for drawing on (into).
693//
694class _OWLCLASS TMetaFileDC : public TDC {
695 public:
696 TMetaFileDC(LPCTSTR filename = nullptr);
698 TMetaFileDC(const TDC& dc, LPCTSTR filename = nullptr, TRect* rect = nullptr,
699 LPCTSTR description = nullptr);
700 TMetaFileDC(const TDC& dc, const tstring& filename, const TRect& rect, const tstring& appName, const tstring& picName);
701 ~TMetaFileDC();
702
703 HMETAFILE Close();
704
705 HENHMETAFILE CloseEnh();
706 bool Comment(uint bytes, const void* data);
707
708 bool IsEnhanced() const;
709
710 private:
711 bool Enhanced;
712
713 TMetaFileDC(const TMetaFileDC&);
715};
716
717//
718/// \class TCreatedDC
719// ~~~~~ ~~~~~~~~~~
720/// An abstract TDC class, TCreatedDC serves as the base for DCs that are created
721/// and deleted.
722/// See TDC for more information about DC objects.
723//
724class _OWLCLASS TCreatedDC : public TDC {
725 public:
726
728 TCreatedDC(const tstring& driver, const tstring& device = tstring{}, const DEVMODE* = nullptr);
729
730#if defined(OWL5_COMPAT)
731
733 TCreatedDC(const tstring& driver, const tstring& device, const tstring& output, const DEVMODE* = nullptr);
734
735#endif
736
737 TCreatedDC(HDC handle, TAutoDelete autoDelete); // use an existing DC
738 ~TCreatedDC();
739
740 protected:
741 TCreatedDC();
742
743 private:
744 TCreatedDC(const TCreatedDC&);
746};
747
748//
749/// \class TIC
750// ~~~~~ ~~~
751/// Derived from TCreatedDC, TIC is a device context (DC) class that provides a constructor
752/// for creating a DC object from explicit driver, device, and port names.
753//
754class _OWLCLASS TIC : public TCreatedDC {
755 public:
756
757 TIC(LPCTSTR driver, LPCTSTR device, const DEVMODE* initData = nullptr);
758 TIC(const tstring& driver, const tstring& device, const DEVMODE* = nullptr);
759
760#if defined(OWL5_COMPAT)
761
763 TIC(const tstring& driver, const tstring& device, const tstring& output, const DEVMODE* = nullptr);
764
765#endif
766
767 ~TIC();
768
769 private:
770 TIC(const TIC&);
771 TIC& operator =(const TIC&);
772};
773
774//
775/// \class TMemoryDC
776// ~~~~~ ~~~~~~~~~
777/// A device context (DC) class derived from TCreatedDC, TMemoryDC provides access to a
778/// memory DC.
779/// \note Important: In order to improve performance, ObjectWindows uses a cache for
780/// memory device contexts. A draw-back of the cache is you cannot assume that
781/// device contexts are initialized to the default system settings. (The cache may
782/// return a device context that has not been used.)
783//
785 public:
786 TMemoryDC();
787 TMemoryDC(const TDC& DC);
790 ~TMemoryDC();
791
792 protected:
793
795 TMemoryDC(const tstring& driver, const tstring& device = tstring{}, const DEVMODE* = nullptr);
796
797#if defined(OWL5_COMPAT)
798
800 TMemoryDC(const tstring& driver, const tstring& device, const tstring& output, const DEVMODE* = nullptr);
801
802#endif
803
804 private:
805 void Init();
806
807 TMemoryDC(const TMemoryDC&);
809};
810
811//
812/// \class TDibDC
813// ~~~~~ ~~~~~~
814/// A DC class that provides access to DIBs using DIBSection, WinG, or the
815/// DIB.DRV driver
816//
817class _OWLCLASS TDibDC : public TMemoryDC {
818 public:
819 TDibDC();
820 TDibDC(const TBitmap& bitmap);
821
822 uint GetDIBColorTable(uint start, uint entries, RGBQUAD * colors);
823 uint SetDIBColorTable(uint start, uint entries, const RGBQUAD * colors);
824
825 // Screen Update BitBlt's. DC for display must be the destination.
826 //
827 bool BitBltToScreen(TDC& dstDC, const TRect& dst, const TPoint& src) const;
828 bool BitBltToScreen(TDC& dstDC, int dstX, int dstY, int dstW, int dstH,
829 int srcX=0, int srcY=0) const;
830 bool StretchBltToScreen(TDC& dstDC, const TRect& dst, const TRect& src) const;
831 bool StretchBltToScreen(TDC& dstDC, int dstX, int dstY, int dstW, int dstH,
832 int srcX, int srcY, int srcW, int srcH) const;
833
834 private:
835 // prevent accidental copying of object
836 //
837 TDibDC(const TDibDC&);
838 TDibDC& operator =(const TDibDC&);
839};
840
841//
842/// \struct TBandInfo
843// ~~~~~~ ~~~~~~~~~
844/// Equivalent to BANDINFOSTRUCT
845//
846/// An ObjectWindows struct, TBandInfo is used to pass information to a printer
847/// driver that supports banding. TBandInfo is declared as follows:
848/// \code
849/// struct TBandInfo {
850/// bool HasGraphics;
851/// bool HasText;
852/// TRect GraphicsRect;
853/// }
854/// \endcode
855/// HasGraphics is true if graphics are (or are expected to be) on the page or in
856/// the band; otherwise, it is false.
857///
858/// HasText is true if text is (or is expected to be) on the page or in the band;
859/// otherwise, it is false.
860///
861/// GraphicsRect defines the bounding region for all graphics on the page.
862//
868
869//
870/// \class TPrintDC
871// ~~~~~ ~~~~~~~~
872/// A DC class that provides access to a printer
873//
875 public:
877 TPrintDC(const tstring& device, const DEVMODE* initData = nullptr);
878
879#if defined(OWL5_COMPAT)
880
882 TPrintDC(const tstring& driver, const tstring& device, const tstring& output, const DEVMODE* = nullptr);
883
884#endif
885
886 int Escape(int escape, int count=0, const void* inData=nullptr,
887 void* outData=nullptr);
888 int SetAbortProc(ABORTPROC proc);
889
890 int StartDoc(LPCTSTR docName, LPCTSTR output = nullptr);
891
893 {return StartDoc(docName.c_str(), output.empty() ? nullptr : output.c_str());}
894
895 int StartPage();
896 int BandInfo(TBandInfo& bandInfo);
897 int NextBand(TRect& rect);
898 int EndPage();
899 int EndDoc();
900 int AbortDoc();
901
902 uint QueryEscSupport(int escapeNum);
903 int SetCopyCount(int reqestCount, int& actualCount);
904
905#if defined(OWL5_COMPAT)
906
907 static uint32 DeviceCapabilities(LPCTSTR driver,
910 int capability, LPTSTR output=0,
912
913 static uint32 DeviceCapabilities(
914 const tstring& driver,
915 const tstring& device,
916 const tstring& port,
917 int capability,
918 LPTSTR output = 0,
919 LPDEVMODE devmode = 0);
920
921#endif
922
923 protected:
924 DOCINFO& GetDocInfo();
925 void SetDocInfo(const DOCINFO& docinfo);
926
928/// Holds the input and output file names used by TPrintDC::StartDoc. The DOCINFO
929/// structure is defined as follows:
930/// \code
931/// typedef struct {
932/// int cbSize; // size of the structure, bytes
933/// DocInfo lpszDocName; // document name <= 32 chars inc. final 0
934/// DocInfo lpszOutput; // output file name
935/// } DOCINFO;
936/// \endcode
937/// The lpszOutput field allows a print job to be redirected to a file. If this
938/// field is NULL, the output will go to the device for the specified DC.
939 DOCINFO DocInfo;
940
941 private:
942 TPrintDC(const TPrintDC&);
943 TPrintDC& operator =(const TPrintDC&);
944};
945/// @}
946
947#include <owl/posclass.h>
948
949} // OWL namespace
950
951//----------------------------------------------------------------------------
952// Inlines for DC classes
953//
954
955//
956// Get the GDI object headers so that we have access to conversion operators,
957// etc.
958//
959#include <owl/gdiobjec.h>
960#if !defined(OWL_METAFILE_H)
961# include <owl/metafile.h>
962#endif
963
964
965namespace owl {
966
967//
968/// Return the handle of the device context.
969//
970/// Typecasting operator. Converts a pointer to type HDC (the data type representing
971/// the handle to a DC).
972//
973inline TDC::operator HDC() const
974{
975 return HDC(Handle);
976}
977
978//
979/// Return the handle of the device context.
980//
981inline HDC TDC::GetHDC()const
982{
983 return HDC(Handle);
984}
985
986//
987/// Attempt to validate the device context handle and return true if the
988/// validation succeeded, or false otherwise.
989//
990inline bool TDC::IsDC() const
991{
992 return ::GetObjectType(GetHDC()) != 0;
993}
994
995//
996/// Obtains the final translation origin for this device context and places the
997/// value in point. This value specifies the offset used to translate device
998/// coordinates to client coordinates for points in an application window. Returns
999/// true if the call is successful; otherwise, returns false.
1000//
1001inline bool TDC::GetDCOrg(TPoint& point) const
1002{
1003 return ::GetDCOrgEx(GetAttributeHDC(), &point);
1004}
1005
1006//
1007/// Places in point the current brush origin of this DC. Returns true if successful;
1008/// otherwise, returns false.
1009//
1010inline bool TDC::GetBrushOrg(TPoint& point) const
1011{
1012 return ::GetBrushOrgEx(GetHDC(), &point);
1013}
1014
1015//
1016/// Sets the origin of the currently selected brush of this DC with the given origin
1017/// value. The previous origin is passed to oldOrg. Returns true if successful;
1018/// otherwise, returns false.
1019//
1021{
1022 return ::SetBrushOrgEx(GetHDC(), org.x, org.y, oldOrg);
1023}
1024
1025//
1026/// Enumerates the pen or brush objects available for this DC. The parameter
1027/// objectType can be either OBJ_BRUSH or OBJ_PEN. For each pen or brush found,
1028/// proc, a user-defined callback function, is called until there are no more
1029/// objects found or the callback function returns 0. proc is defined as:
1030/// \code
1031/// typedef int (CALLBACK* GOBJENUMPROC)(LPVOID, LPARAM);
1032/// \endcode
1033/// Parameter data specifies an application-defined value that is passed to proc.
1034//
1036{
1037 return ::EnumObjects(GetHDC(), objectType, proc, reinterpret_cast<LPARAM>(data));
1038}
1039
1040//
1041/// Returns the color nearest to the given Color argument for the current palette of
1042/// this DC.
1043//
1045{
1046 return ::GetNearestColor(GetAttributeHDC(), color);
1047}
1048
1049//
1050/// Maps to the system palette the logical palette entries selected into this DC.
1051/// Returns the number of entries in the logical palette that were mapped to the
1052/// system palette.
1053//
1055{
1056 return ::RealizePalette(GetHDC());
1057}
1058
1059//
1060/// Updates the client area of this DC by matching the current colors in the client
1061/// area to the system palette on a pixel-by-pixel basis.
1062//
1064{
1066}
1067
1068//
1069/// Retrieves a range of up to num palette entries, starting at start, from the
1070/// system palette to the entries array of PALETTEENTRY structures. Returns the
1071/// actual number of entries transferred.
1072//
1074{
1075 return ::GetSystemPaletteEntries(GetHDC(), start, num, entries);
1076}
1077
1078//
1079/// Determines whether this DC has access to the full system palette. Returns
1080/// SYSPAL_NOSTATIC or SYSPAL_STATIC.
1081//
1083{
1084 return ::GetSystemPaletteUse(GetHDC());
1085}
1086
1087//
1088/// Changes the usage of this DC's system palette. The usage argument can be
1089/// SYSPAL_NOSTATIC or SYSPAL_STATIC. Returns the previous usage value.
1090//
1092{
1093 return ::SetSystemPaletteUse(GetHDC(), usage);
1094}
1095
1096//
1097/// Returns the current background color of this DC.
1098//
1100{
1101 return ::GetBkColor(GetAttributeHDC());
1102}
1103
1104//
1105/// Returns the background mode of this DC, either OPAQUE or TRANSPARENT.
1106//
1107inline int TDC::GetBkMode() const
1108{
1109 return ::GetBkMode(GetAttributeHDC());
1110}
1111
1112//
1113/// Sets the background mode to the given mode argument, which can be either OPAQUE
1114/// or TRANSPARENT. Returns the previous background mode.
1115//
1116inline int TDC::SetBkMode(int mode)
1117{
1118 if (GetHDC() != GetAttributeHDC())
1119 ::SetBkMode(GetHDC(), mode);
1120 return ::SetBkMode(GetAttributeHDC(), mode);
1121}
1122
1123//
1124/// Returns the current polygon-filling mode for this DC, either ALTERNATE or
1125/// WINDING.
1126//
1127inline int TDC::GetPolyFillMode() const
1128{
1129 return ::GetPolyFillMode(GetAttributeHDC());
1130}
1131
1132//
1133/// Description
1134/// Sets the polygon-filling mode for this DC to the given mode value, either
1135/// ALTERNATE or WINDING. Returns the previous fill mode.
1136//
1137inline int TDC::SetPolyFillMode(int mode)
1138{
1139 if (GetHDC() != GetAttributeHDC())
1140 ::SetPolyFillMode(GetHDC(), mode);
1141 return ::SetPolyFillMode(GetAttributeHDC(), mode);
1142}
1143
1144//
1145/// Returns the current drawing (raster operation) mode of this DC.
1146//
1147inline int TDC::GetROP2() const
1148{
1149 return ::GetROP2(GetAttributeHDC());
1150}
1151
1152//
1153/// Sets the current foreground mix mode mode of this DC to the given mode value and
1154/// returns the previous mode. The mode argument determines how the brush, pen, and
1155/// existing screen image combine when filling and drawing. mode can be one of the
1156/// following values:
1157/// - \c \b R2_BLACK Pixel is always binary 0.
1158/// - \c \b R2_COPYPEN Pixel is the pen color.
1159/// - \c \b R2_MASKNOTPEN Pixel is a combination of the colors common to both the display
1160/// and the inverse of the pen.
1161/// - \c \b R2_MASKPEN Pixel is a combination of the colors common to both the pen and the
1162/// display.
1163/// - \c \b R2_MASKPENNOT Pixel is a combination of the colors common to both the pen and
1164/// the inverse of the display.
1165/// - \c \b R2_MERGEPEN Pixel is a combination of the pen color and the display color.
1166/// - \c \b R2_MERGENOTPEN Pixel is a combination of the display color and the inverse of
1167/// the pen color.
1168/// - \c \b R2_MERGEPENNOT Pixel is a combination of the pen color and the inverse of the
1169/// display color.
1170/// - \c \b R2_NOP Pixel remains unchanged.
1171/// - \c \b R2_NOT Pixel is the inverse of the display color.
1172/// - \c \b R2_NOTCOPYPEN Pixel is the inverse of the pen color.
1173/// - \c \b R2_NOTMASKPEN Pixel is the inverse of the R2_MASKPEN color.
1174/// - \c \b R2_NOTMERGEPEN Pixel is the inverse of the R2_MERGEPEN color.
1175/// - \c \b R2_NOTXORPEN Pixel is the inverse of the R2_XORPEN color.
1176/// - \c \b R2_WHITE Pixel is always binary 1.
1177/// - \c \b R2_XORPEN Pixel is a combination of the colors in the pen and in the display,
1178/// but not in both.
1179//
1180inline int TDC::SetROP2(int mode)
1181{
1182 if (GetHDC() != GetAttributeHDC())
1183 ::SetROP2(GetHDC(), mode);
1184 return ::SetROP2(GetAttributeHDC(), mode);
1185}
1186
1187//
1188/// Returns the current stretching mode for this DC: BLACKONWHITE, COLORONCOLOR, or
1189/// WHITEONBLACK. The stretching mode determines how bitmaps are stretched or
1190/// compressed by the StretchBlt function.
1191//
1192inline int TDC::GetStretchBltMode() const
1193{
1194 return ::GetStretchBltMode(GetAttributeHDC());
1195}
1196
1197//
1198/// Sets the stretching mode of this DC to the given mode value and returns the
1199/// previous mode. The mode argument (BLACKONWHITE, COLORONCOLOR, or WHITEONBLACK)
1200/// defines which scan lines or columns or both are eliminated by TDC::StretchBlt.
1201//
1202inline int TDC::SetStretchBltMode(int mode)
1203{
1204 if (GetHDC() != GetAttributeHDC())
1205 ::SetStretchBltMode(GetHDC(), mode);
1206 return ::SetStretchBltMode(GetAttributeHDC(), mode);
1207}
1208
1209//
1210/// Returns the current text color of this DC. The text color determines the color
1211/// displayed by TDC::TextOut and TDC::ExtTextOut.
1212//
1214{
1215 return ::GetTextColor(GetAttributeHDC());
1216}
1217
1218//
1219/// If successful, returns the current window mapping mode of this DC; otherwise,
1220/// returns 0. The mapping mode defines how logical coordinates are mapped to device
1221/// coordinates. It also controls the orientation of the device's x- and y-axes. The
1222/// mode values are shown in the following table:
1223/// - \c \b MM_ANISOTROPIC Logical units are mapped to arbitrary units with arbitrarily
1224/// scaled axes. SetWindowExtEx and SetViewportExtEx must be used to specify the
1225/// desired units, orientation, and scaling.
1226/// - \c \b MM_HIENGLISH Each logical unit is mapped to 0.001 inch. Positive x is to the
1227/// right; positive y is at the top.
1228/// - \c \b MM_HIMETRIC Each logical unit is mapped to 0.01 millimeter. Positive x is to the
1229/// right; positive y is at the top.
1230/// - \c \b MM_ISOTROPIC Logical units are mapped to arbitrary units with equally scaled
1231/// axes; that is, one unit along the x-axis is equal to one unit along the y-axis.
1232/// SetWindowExtEx and SetViewportExtEx must be used to specify the desired units
1233/// and the orientation of the axes. GDI makes adjustments as necessary to ensure
1234/// that the x and y units remain the same size (e.g., if you set the window extent,
1235/// the viewport is adjusted to keep the units isotropic).
1236/// - \c \b MM_LOENGLISH Each logical unit is mapped to 0.01 inch. Positive x is to the
1237/// right; positive y is at the top.
1238/// - \c \b MM_LOMETRIC Each logical unit is mapped to 0.1 millimeter. Positive x is to the
1239/// right; positive y is at the top.
1240/// - \c \b MM_TEXT Each logical unit is mapped to one device pixel. Positive x is to the
1241/// right; positive y is at the bottom.
1242/// - \c \b MM_TWIPS Each logical unit is mapped to one twentieth of a printer's point
1243/// (1/1440 inch). Positive x is to the right; positive y is at the top.
1244//
1245inline int TDC::GetMapMode() const
1246{
1247 return ::GetMapMode(GetAttributeHDC());
1248}
1249
1250
1251//
1252/// Sets the limit of miter joins to newLimit and puts the previous value in
1253/// oldLimit. Returns true if successful; otherwise, returns false.
1254//
1255inline bool TDC::SetMiterLimit(float newLimit, float* oldLimit)
1256{
1257 if (GetHDC() != GetAttributeHDC())
1259 return ::SetMiterLimit(GetAttributeHDC(), newLimit, oldLimit);
1260}
1261
1262//
1263/// Sets a two-dimensional linear transformation, given by the xform
1264/// structure, between world space and page space for this DC. Returns true if the
1265/// call is successful; otherwise, returns false.
1266//
1268{
1269 if (GetHDC() != GetAttributeHDC())
1271 return ::SetWorldTransform(GetAttributeHDC(), &xform);
1272}
1273
1274//
1275/// Changes the current world transformation for this DC using the given xform and
1276/// mode arguments. mode determines how the given XFORM structure is applied, as
1277/// listed below:
1278/// - \c \b MWT_IDENTITY Resets the current world transformation using the identity matrix.
1279/// If this mode is specified, the XFORM structure pointed to by lpXform is ignored.
1280/// - \c \b MWT_LEFTMULTIPLY Multiplies the current transformation by the data in the XFORM
1281/// structure. (The data in the XFORM structure becomes the left multiplicand, and
1282/// the data for the current transformation becomes the right multiplicand.)
1283/// - \c \b MWT_RIGHTMULTIPLY Multiplies the current transformation by the data in the XFORM
1284/// structure. (The data in the XFORM structure becomes the right multiplicand, and
1285/// the data for the current transformation becomes the left multiplicand.)
1286/// ModifyWorldTransform returns true if the call is successful; otherwise, it
1287/// returns false.
1288//
1290{
1291 if (GetHDC() != GetAttributeHDC())
1293 return ::ModifyWorldTransform(GetAttributeHDC(), &xform, mode);
1294}
1295
1296
1297//
1298/// The first version sets in the point argument the x- and y-extents (in
1299/// device-units) of this DC's viewport. It returns true if the call is successful;
1300/// otherwise, it returns false. The second version returns the x- and y-extents (in
1301/// device-units) of this DC's viewport.
1302//
1304{
1305 return ::GetViewportOrgEx(GetAttributeHDC(), &point);
1306}
1307
1308//
1309/// The first version sets in the point argument the x- and y-extents (in
1310/// device-units) of this DC's viewport. It returns true if the call is successful;
1311/// otherwise, it returns false. The second version returns the x- and y-extents (in
1312/// device-units) of this DC's viewport.
1313//
1315{
1316 TPoint point;
1318 return point;
1319}
1320
1321//
1322/// The first version retrieves this DC's current viewport's x- and y-extents (in
1323/// device units) and places the values in extent. This version returns true if the
1324/// call is successful; otherwise, it returns false. The second version returns only
1325/// these x- and y-extents.
1326/// The extent value determines the amount of stretching or compression needed in
1327/// the logical coordinate system to fit the device coordinate system. extent also
1328/// determines the relative orientation of the two coordinate systems.
1329//
1331{
1332 return ::GetViewportExtEx(GetAttributeHDC(), &extent);
1333}
1334
1335//
1336//
1337/// The first version retrieves this DC's current viewport's x- and y-extents (in
1338/// device units) and places the values in extent. This version returns true if the
1339/// call is successful; otherwise, it returns false. The second version returns only
1340/// these x- and y-extents.
1341/// The extent value determines the amount of stretching or compression needed in
1342/// the logical coordinate system to fit the device coordinate system. extent also
1343/// determines the relative orientation of the two coordinate systems.
1344//
1346{
1347 TSize extent;
1349 return extent;
1350}
1351
1352//
1353/// Places in point the x- and y-coordinates of the origin of the window associated
1354/// with this DC. Returns true if the call is successful; otherwise, returns false.
1355//
1356inline bool TDC::GetWindowOrg(TPoint& point) const
1357{
1358 return ::GetWindowOrgEx(GetAttributeHDC(), &point);
1359}
1360
1361//
1362/// Places in point the x- and y-coordinates of the origin of the window associated
1363/// with this DC. Returns true if the call is successful; otherwise, returns false.
1364//
1366{
1367 TPoint point;
1369 return point;
1370}
1371
1372//
1373/// Retrieves this DC's window current x- and y-extents (in device units). The first
1374/// version places the values in extent and returns true if the call is successful;
1375/// otherwise, it returns false. The second version returns the current extent
1376/// values. The extent value determines the amount of stretching or compression
1377/// needed in the logical coordinate system to fit the device coordinate system.
1378/// extent also determines the relative orientation of the two coordinate systems.
1379//
1380inline bool TDC::GetWindowExt(TSize& extent) const
1381{
1382 return ::GetWindowExtEx(GetAttributeHDC(), &extent);
1383}
1384
1385//
1386/// Retrieves this DC's window current x- and y-extents (in device units). The first
1387/// version places the values in extent and returns true if the call is successful;
1388/// otherwise, it returns false. The second version returns the current extent
1389/// values. The extent value determines the amount of stretching or compression
1390/// needed in the logical coordinate system to fit the device coordinate system.
1391/// extent also determines the relative orientation of the two coordinate systems.
1392//
1394{
1395 TSize extent;
1397 return extent;
1398}
1399
1400//
1401/// Converts each of the count points in the points array from device points to
1402/// logical points. The conversion depends on this DC's current mapping mode and the
1403/// settings of its window and viewport origins and extents. DPtoLP returns true if
1404/// the call is successful; otherwise, it returns false.
1405//
1406inline bool TDC::DPtoLP(TPoint* points, int count) const
1407{
1408 return ::DPtoLP(GetAttributeHDC(), points, count);
1409}
1410
1411//
1412inline bool TDC::DPtoLP(TRect& rect) const
1413{
1414 return ::DPtoLP(GetAttributeHDC(), reinterpret_cast<LPPOINT>(&rect), 2);
1415}
1416
1417//
1418/// Converts each of the count points in the points array from logical points to
1419/// device points. The conversion depends on this DC's current mapping mode and the
1420/// settings of its window and viewport origins and extents. Returns true if the
1421/// call is successful; otherwise, it returns false.
1422//
1423inline bool TDC::LPtoDP(TPoint* points, int count) const
1424{
1425 return ::LPtoDP(GetAttributeHDC(), points, count);
1426}
1427
1428//
1429/// Converts each of the count points in the points array from logical points to
1430/// device points. The conversion depends on this DC's current mapping mode and the
1431/// settings of its window and viewport origins and extents. Returns true if the
1432/// call is successful; otherwise, it returns false.
1433//
1434inline bool TDC::LPtoDP(TRect& rect) const
1435{
1436 return ::LPtoDP(GetAttributeHDC(), reinterpret_cast<LPPOINT>(&rect), 2);
1437}
1438
1439//
1440/// Places the current clip box size of this DC in rect. The clip box is defined as
1441/// the smallest rectangle bounding the current clipping boundary. The return value
1442/// indicates the clipping region's type as follows:
1443/// - \c \b COMPLEXREGION Clipping Region has overlapping borders.
1444/// - \c \b ERROR Invalid DC.
1445/// - \c \b NULLREGION Clipping region is empty.
1446/// - \c \b SIMPLEREGION Clipping region has no overlapping borders.
1447//
1448inline int TDC::GetClipBox(TRect& rect) const
1449{
1450 return ::GetClipBox(GetHDC(), &rect);
1451}
1452
1453//
1454/// Places the current clip box size of this DC in rect. The clip box is defined as
1455/// the smallest rectangle bounding the current clipping boundary. The return value
1456/// indicates the clipping region's type as follows:
1457/// - \c \b COMPLEXREGION Clipping Region has overlapping borders.
1458/// - \c \b ERROR Invalid DC.
1459/// - \c \b NULLREGION Clipping region is empty.
1460/// - \c \b SIMPLEREGION Clipping region has no overlapping borders.
1461//
1463{
1464 TRect rect;
1466 return rect;
1467}
1468
1469//
1470/// Creates a new clipping region for this DC. This new region consists of the
1471/// current clipping region minus the given rectangle, rect. The return value
1472/// indicates the new clipping region's type as follows:
1473/// - \c \b COMPLEXREGION Clipping Region has overlapping borders.
1474/// - \c \b ERROR Invalid DC.
1475/// - \c \b NULLREGION Clipping region is empty.
1476/// - \c \b SIMPLEREGION Clipping region has no overlapping borders.
1477//
1479{
1480 return ::ExcludeClipRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
1481}
1482
1483//
1484/// Prevents drawing within invalid areas of a window by excluding an updated region
1485/// of this DC's window from its clipping region. The return value indicates the
1486/// resulting clipping region's type as follows:
1487/// - \c \b COMPLEXREGION Clipping Region has overlapping borders.
1488/// - \c \b ERROR Invalid DC.
1489/// - \c \b NULLREGION Clipping region is empty.
1490/// - \c \b SIMPLEREGION Clipping region has no overlapping borders.
1491//
1493{
1494 return ::ExcludeUpdateRgn(GetHDC(), Wnd);
1495}
1496
1497//
1498/// Creates a new clipping region for this DC's window by forming the intersection
1499/// of the current region with the rectangle specified by rect. The return value
1500/// indicates the resulting clipping region's type as follows:
1501/// - \c \b COMPLEXREGION Clipping Region has overlapping borders.
1502/// - \c \b ERROR Invalid DC.
1503/// - \c \b NULLREGION Clipping region is empty.
1504/// - \c \b SIMPLEREGION Clipping region has no overlapping borders.
1505//
1507{
1508 return ::IntersectClipRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
1509}
1510
1511//
1512/// Moves the clipping region of this DC by the x- and y-offsets specified in delta.
1513/// The return value indicates the resulting clipping region's type as follows:
1514/// - \c \b COMPLEXREGION Clipping region has overlapping borders.
1515/// - \c \b ERROR Invalid DC.
1516/// - \c \b NULLREGION Clipping region is empty.
1517/// - \c \b SIMPLEREGION Clipping region has no overlapping borders.
1518//
1520{
1521 return ::OffsetClipRgn(GetHDC(), delta.x, delta.y);
1522}
1523
1524//
1525/// Selects the given region as the current clipping region for this DC. A copy of
1526/// the given region is used, letting you select the same region for other DC
1527/// objects. The return value indicates the new clipping region's type as follows:
1528/// - \c \b COMPLEXREGION Clipping Region has overlapping borders.
1529/// - \c \b ERROR Invalid DC.
1530/// - \c \b NULLREGION Clipping region is empty.
1531/// - \c \b SIMPLEREGION Clipping region has no overlapping borders.
1532//
1534{
1535 return ::SelectClipRgn(GetHDC(), region);
1536}
1537
1538//
1539/// Returns true if the given point lies within the clipping region of this DC;
1540/// otherwise, returns false.
1541//
1542inline bool TDC::PtVisible(const TPoint& point) const
1543{
1544 return ::PtVisible(GetHDC(), point.x, point.y);
1545}
1546
1547//
1548/// Returns true if any part of the given rectangle, rect, lies within the clipping
1549/// region of this DC; otherwise, returns false.
1550//
1551inline bool TDC::RectVisible(const TRect& rect) const
1552{
1553 return ::RectVisible(GetHDC(), &rect);
1554}
1555
1556//
1557/// Reports in bounds the current accumulated bounding rectangle of this DC or of
1558/// the Windows manager, depending on the value of flags. Returns true if the call
1559/// is successful; otherwise, returns false.
1560/// The flags argument can be DCB_RESET or DCB_WINDOWMGR or both. The flags value
1561/// work as follows:
1562/// - \c \b DCB_RESET Forces the bounding rectangle to be cleared after being set in bounds.
1563/// - \c \b DCB_WINDOWMGR Reports the Windows current bounding rectangle rather than that of
1564/// this DC.
1565///
1566/// There are two bounding-rectangle accumulations, one for Windows and one for the
1567/// application. GetBoundsRect returns screen coordinates for the Windows bounds,
1568/// and logical units for the application bounds. The Windows accumulated bounds can
1569/// be queried by an application but not altered. The application can both query and
1570/// alter the DC's accumulated bounds.
1571//
1572inline bool TDC::GetBoundsRect(TRect& bounds, uint16 flags) const
1573{
1574 return ::GetBoundsRect(GetHDC(), &bounds, flags);
1575}
1576
1577//
1578/// Controls the accumulation of bounding rectangle information for this DC.
1579/// Depending on the value of flags, the given bounds rectangle (possibly NULL) can
1580/// combine with or replace the existing accumulated rectangle. flags can be any
1581/// appropriate combination of the following values:
1582/// - \c \b DCB_ACCUMULATE Add bounds (rectangular union) to the current accumulated
1583/// rectangle.
1584/// - \c \b DCB_DISABLE Turn off bounds accumulation.
1585/// - \c \b DCB_ENABLE Turn on bounds accumulation (the default setting for bounds
1586/// accumulation is disabled).
1587/// - \c \b DCB_RESET Set the bounding rectangle to empty.
1588/// - \c \b DCB_SET Set the bounding rectangle to bounds.
1589///
1590/// There are two bounding-rectangle accumulations, one for Windows and one for the
1591/// application. The Windows-accumulated bounds can be queried by an application but
1592/// not altered. The application can both query and alter the DC's accumulated
1593/// bounds.
1594//
1596{
1597 return ::SetBoundsRect(GetHDC(), &bounds, flags);
1598}
1599
1600//
1601/// Retrieves this DC's current clip-region and, if successful, places a copy of it
1602/// in the region argument. You can alter this copy without affecting the current
1603/// clip-region. If the function succeeds and there is no clipping region for the
1604/// given device context, the return value is zero. If the function succeeds and
1605/// there is a clipping region for the given device context, the return value is 1.
1606/// If an error occurs, the return value is -1.
1607//
1609{
1610 return ::GetClipRgn(GetHDC(), (HRGN)region);
1611}
1612
1613//
1614/// Enumerates the GDI calls within the given metaFile. Each such call is retrieved
1615/// and passed to the given callback function, together with any client data from
1616/// data, until all calls have been processed or a callback function returns 0.
1617/// MFENUMPROC is defined as:
1618/// \code
1619/// typedef int (CALLBACK* MFENUMPROC)(HDC, HANDLETABLE *, METARECORD *, int,
1620/// LPARAM);
1621/// \endcode
1622//
1624 void * data) const
1625{
1626 return ::EnumMetaFile(GetHDC(), metafile, callback, reinterpret_cast<LPARAM>(data));
1627}
1628
1629//
1630/// Plays the contents of the given metaFile on this DC. The metafile can be played
1631/// any number of times. Returns true if the call is successful; otherwise, returns
1632/// false.
1633//
1635{
1636 return ::PlayMetaFile(GetHDC(), const_cast<TMetaFilePict&>(metafile));
1637}
1638
1639//
1640/// Plays the metafile record given in metaRecord to this DC by executing the GDI
1641/// function call contained in that record. Handletable specifies the object handle
1642/// table to be used. count specifies the number of handles in the table.
1643//
1649
1650//
1651/// Enumerate through the enhanced metafile records.
1652//
1654 void * data, const TRect* rect) const
1655{
1656 return ::EnumEnhMetaFile(GetHDC(), metafile, callback, data, rect);
1657}
1658
1659//
1660/// Play the enhanced metafile onto this device context.
1661//
1663{
1664 return ::PlayEnhMetaFile(GetHDC(), metafile, rect);
1665}
1666
1667//
1668/// Play one record from the enhanced metafile onto this DC.
1669//
1675
1676//
1677/// Reports in point the logical coordinates of this DC's current position. Returns
1678/// true if the call is successful; otherwise, returns false.
1679//
1681{
1682 return ::GetCurrentPositionEx(GetHDC(), &point);
1683}
1684
1685//
1686/// Moves the current position of this DC to the given x- and y-coordinates or to
1687/// the given point. The third version sets the previous current position in
1688/// oldPoint. Returns true if the call is successful; otherwise, returns false.
1689//
1690inline bool TDC::MoveTo(int x, int y)
1691{
1692 return ::MoveToEx(GetHDC(), x, y, nullptr);
1693}
1694
1695//
1696/// Moves the current position of this DC to the given x- and y-coordinates or to
1697/// the given point. The third version sets the previous current position in
1698/// oldPoint. Returns true if the call is successful; otherwise, returns false.
1699//
1700inline bool TDC::MoveTo(const TPoint& point)
1701{
1702 return ::MoveToEx(GetHDC(), point.x, point.y, nullptr);
1703}
1704
1705//
1706/// Moves the current position of this DC to the given x- and y-coordinates or to
1707/// the given point. The third version sets the previous current position in
1708/// oldPoint. Returns true if the call is successful; otherwise, returns false.
1709//
1711{
1712 return ::MoveToEx(GetHDC(), point.x, point.y, &OldPoint);
1713}
1714
1715//
1716/// Draws the given icon on this DC. The upper left corner of the drawn icon can be
1717/// specified by x- and y-coordinates or by the point argument. DrawIcon returns
1718/// true if the call is successful; otherwise, it returns false.
1719//
1720inline bool TDC::DrawIcon(int x, int y, const TIcon& icon)
1721{
1722 return ::DrawIcon(GetHDC(), x, y, icon);
1723}
1724
1725//
1726//
1727/// Draws the given icon on this DC. The upper left corner of the drawn icon can be
1728/// specified by x- and y-coordinates or by the point argument. DrawIcon returns
1729/// true if the call is successful; otherwise, it returns false.
1730//
1731inline bool TDC::DrawIcon(const TPoint& point, const TIcon& icon)
1732{
1733 return ::DrawIcon(GetHDC(), point.x, point.y, icon);
1734}
1735
1736//
1737inline bool TDC::DrawCursor(int x, int y, const TCursor& cursor)
1738{
1739 return ::DrawIcon(GetHDC(), x, y, HICON(HCURSOR(cursor)));
1740}
1741
1742//
1743inline bool TDC::DrawCursor(const TPoint& point, const TCursor& cursor)
1744{
1745 return ::DrawIcon(GetHDC(), point.x, point.y, HICON(HCURSOR(cursor)));
1746}
1747
1748//
1749inline bool TDC::DrawIcon(int x, int y, const TIcon& icon, int w, int h,
1750 int aniStep, HBRUSH bkBr, uint flags)
1751{
1752 return ::DrawIconEx(GetHDC(), x, y, icon, w, h, aniStep, bkBr, flags);
1753}
1754
1755inline bool TDC::DrawIcon(const TPoint& point, const TIcon& icon,
1756 const TSize& size, int aniStep, HBRUSH bkBr, uint flags)
1757{
1758 return ::DrawIconEx(GetHDC(), point.x, point.y, icon, size.cx, size.cy,
1759 aniStep, bkBr, flags);
1760}
1761
1762inline bool TDC::DrawCursor(int x, int y, const TCursor& cursor, int w, int h,
1763 int aniStep, HBRUSH bkBr, uint flags)
1764{
1765 return ::DrawIconEx(GetHDC(), x, y, HICON(HCURSOR(cursor)), w, h, aniStep,
1766 bkBr, flags);
1767}
1768
1769inline bool TDC::DrawCursor(const TPoint& point, const TCursor& cursor,
1770 const TSize& size, int aniStep, HBRUSH bkBr, uint flags)
1771{
1772 return ::DrawIconEx(GetHDC(), point.x, point.y, HICON(HCURSOR(cursor)),
1773 size.cx, size.cy, aniStep, bkBr, flags);
1774}
1775
1776//
1777/// Draws a border on this DC around the given rectangle, rect, using the given
1778/// brush, brush. The height and width of the border is one logical unit. Returns
1779/// true if the call is successful; otherwise, it returns false.
1780//
1781inline bool TDC::FrameRect(int x1, int y1, int x2, int y2, const TBrush& brush)
1782{
1783 TRect r(x1, y1, x2, y2);
1784 return ::FrameRect(GetHDC(), &r, brush);
1785}
1786
1787//
1788/// Draws a border on this DC around the given rectangle, rect, using the given
1789/// brush, brush. The height and width of the border is one logical unit. Returns
1790/// true if the call is successful; otherwise, it returns false.
1791//
1792inline bool TDC::FrameRect(const TRect& rect, const TBrush& brush)
1793{
1794 return ::FrameRect(GetHDC(), &rect, brush);
1795}
1796
1797//
1798/// Fills the given rectangle on this DC using the specified brush. The fill covers
1799/// the left and top borders but excludes the right and bottom borders. FillRect
1800/// returns true if the call is successful; otherwise, it returns false.
1801//
1802inline bool TDC::FillRect(int x1, int y1, int x2, int y2, const TBrush& brush)
1803{
1804 TRect r(x1, y1, x2, y2);
1805 return ::FillRect(GetHDC(), &r, brush);
1806}
1807
1808//
1809/// Fills the given rectangle on this DC using the specified brush. The fill covers
1810/// the left and top borders but excludes the right and bottom borders. FillRect
1811/// returns true if the call is successful; otherwise, it returns false.
1812//
1813inline bool TDC::FillRect(const TRect& rect, const TBrush& brush)
1814{
1815 return ::FillRect(GetHDC(), &rect, brush);
1816}
1817
1818//
1819/// Inverts the given rectangle, rect, on this DC. On monochrome displays,
1820/// black-and-white pixels are interchanged. On color displays, inversion depends on
1821/// how the colors are generated for particular displays. Calling InvertRect an even
1822/// number of times restores the original colors. InvertRect returns true if the
1823/// call is successful; otherwise, it returns false.
1824///
1825/// \note Rect must be normalized for inverRect
1826//
1827inline bool TDC::InvertRect(int x1, int y1, int x2, int y2)
1828{
1829 TRect r(x1, y1, x2, y2);
1830 ::InvertRect(GetHDC(), &r);
1831 return true;
1832}
1833
1834//
1835/// Inverts the given rectangle, rect, on this DC. On monochrome displays,
1836/// black-and-white pixels are interchanged. On color displays, inversion depends on
1837/// how the colors are generated for particular displays. Calling InvertRect an even
1838/// number of times restores the original colors. InvertRect returns true if the
1839/// call is successful; otherwise, it returns false.
1840//
1841inline bool TDC::InvertRect(const TRect& rect)
1842{
1844 return true;
1845}
1846
1847//
1848/// Draws the given rectangle on this DC in the style used to indicate focus.
1849/// Calling the function a second time with the same rect argument will remove the
1850/// rectangle from the display. A rectangle drawn with DrawFocusRect cannot be
1851/// scrolled. DrawFocusRect returns true if the call is successful; otherwise, it
1852/// returns false.
1853//
1854inline bool TDC::DrawFocusRect(int x1, int y1, int x2, int y2)
1855{
1856 TRect r(x1, y1, x2, y2);
1858 return true;
1859}
1860
1861//
1862/// Draws the given rectangle on this DC in the style used to indicate focus.
1863/// Calling the function a second time with the same rect argument will remove the
1864/// rectangle from the display. A rectangle drawn with DrawFocusRect cannot be
1865/// scrolled. DrawFocusRect returns true if the call is successful; otherwise, it
1866/// returns false.
1867//
1868inline bool TDC::DrawFocusRect(const TRect& rect)
1869{
1871 return true;
1872}
1873
1874//
1875/// Fills the given rectangle, clipping any text to the rectangle.
1876/// Returns true if the call is successful.
1877//
1878inline bool TDC::TextRect(int x1, int y1, int x2, int y2)
1879{
1880 TRect r(x1, y1, x2, y2);
1881 return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &r, nullptr, 0, nullptr);
1882}
1883
1884//
1885/// Fills the given rectangle, clipping any text to the rectangle.
1886/// Returns true if the call is successful.
1887//
1888inline bool TDC::TextRect(const TRect& rect)
1889{
1890 return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &rect, nullptr, 0, nullptr);
1891}
1892
1893//
1894/// Fills the given rectangle, clipping any text to the rectangle.
1895/// The given color is used to set to the background color before filling.
1896/// Returns true if the call is successful.
1897//
1898inline bool TDC::TextRect(int x1, int y1, int x2, int y2, const TColor& color)
1899{
1901 TRect r(x1, y1, x2, y2);
1902 return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &r, nullptr, 0, nullptr);
1903}
1904
1905//
1906/// Fills the given rectangle, clipping any text to the rectangle. If no color
1907/// argument is supplied, the current backgound color is used. If a color argument
1908/// is supplied, that color is set to the current background color which is then
1909/// used for filling. TextRect returns true if the call is successful; otherwise, it
1910/// returns false.
1911//
1912inline bool TDC::TextRect(const TRect& rect, const TColor& color)
1913{
1915 return ::ExtTextOut(GetHDC(), 0, 0, ETO_OPAQUE, &rect, nullptr, 0, nullptr);
1916}
1917
1918//
1919/// Draws a border on this DC around the given region, region, using the given
1920/// brush, brush. The width and height of the border is specified by the brushSize argument.
1921/// Returns true if the call is successful; otherwise, returns false.
1922//
1923inline bool TDC::FrameRgn(const TRegion& region, const TBrush& brush, const TSize& brushSize)
1924{
1925 return ::FrameRgn(GetHDC(), region, brush, brushSize.cx, brushSize.cy);
1926}
1927
1928//
1929/// Fills the given region on this DC using the specified brush. FillRgn returns
1930/// true if the call is successful; otherwise, it returns false.
1931//
1932inline bool TDC::FillRgn(const TRegion& region, const TBrush& brush)
1933{
1934 return ::FillRgn(GetHDC(), region, brush);
1935}
1936
1937//
1938/// Inverts the given region, on this DC. On monochrome displays, black-and-white
1939/// pixels are interchanged. On color displays, inversion depends on how the colors
1940/// are generated for particular displays. Calling InvertRegion an even number (n>=2
1941/// ) of times restores the original colors. Returns true if the call is successful;
1942/// otherwise, it returns false.
1943//
1944inline bool TDC::InvertRgn(const TRegion& region)
1945{
1946 return ::InvertRgn(GetHDC(), region);
1947}
1948
1949//
1950/// Paints the given rectangle using the currently selected brush for this DC. The
1951/// rectangle can be specified by its upper left coordinates (x, y), width w, and
1952/// height h, or by a single TRect argument. The raster-operation code, rop,
1953/// determines how the brush and surface color(s) are combined, as explained in the
1954/// following table:
1955/// - \c \b PATCOPY Copies pattern to destination bitmap.
1956/// - \c \b PATINVERT Combines destination bitmap with pattern using the Boolean OR
1957/// operator.
1958/// - \c \b DSTINVERT Inverts the destination bitmap.
1959/// - \c \b BLACKNESS Turns all output to binary 0s.
1960/// - \c \b WHITENESS Turns all output to binary 1s.
1961///
1962/// The allowed values of rop for this function are a limited subset of the full 256
1963/// ternary raster-operation codes; in particular, an operation code that refers to
1964/// a source cannot be used with PatBlt.
1965/// Not all devices support the PatBlt function, so applications should call
1966/// TDC::GetDeviceCaps to check the features supported by this DC.
1967/// PatBlt returns true if the call is successful; otherwise, returns false.
1968//
1969inline bool TDC::PaintRgn(const TRegion& region)
1970{
1971 return ::PaintRgn(GetHDC(), region);
1972}
1973
1974//
1975/// Draws a line segment and an arc on this DC using the currently
1976/// selected pen object. The line is drawn from the current position to the
1977/// beginning of the arc. The arc is that part of the circle (with the center at
1978/// logical coordinates (x, y) and positive radius, radius) starting at startAngle
1979/// and ending at (startAngle + sweepAngle). Both angles are measured in degrees,
1980/// counterclockwise from the x-axis (the default arc direction). The arc might
1981/// appear to be elliptical, depending on the current transformation and mapping
1982/// mode. AngleArc returns true if the figure is drawn successfully; otherwise, it
1983/// returns false. If successful, the current position is moved to the end point of
1984/// the arc.
1985//
1986inline bool TDC::AngleArc(int x, int y, uint32 radius, float startAngle, float sweepAngle)
1987{
1988 return ::AngleArc(GetHDC(), x, y, radius, startAngle, sweepAngle);
1989}
1990
1991//
1992/// Draws a line segment and an arc on this DC using the currently
1993/// selected pen object. The line is drawn from the current position to the
1994/// beginning of the arc. The arc is that part of the circle (with the center at
1995/// logical coordinates (x, y) and positive radius, radius) starting at startAngle
1996/// and ending at (startAngle + sweepAngle). Both angles are measured in degrees,
1997/// counterclockwise from the x-axis (the default arc direction). The arc might
1998/// appear to be elliptical, depending on the current transformation and mapping
1999/// mode. AngleArc returns true if the figure is drawn successfully; otherwise, it
2000/// returns false. If successful, the current position is moved to the end point of
2001/// the arc.
2002//
2003inline bool TDC::AngleArc(const TPoint& Center, uint32 radius, float StartAngle, float SweepAngle)
2004{
2005 return ::AngleArc(GetHDC(), Center.x, Center.y, radius, StartAngle, SweepAngle);
2006}
2007
2008//
2009/// Draws an elliptical arc on this DC using the currently selected pen object. The
2010/// center of the arc is the center of the bounding rectangle, specified either by
2011/// (x1, y1)/(x2, y2) or by the rectangle r. The starting/ending points of the arc
2012/// are specified either by (x3, y3)/(x4, y4) or by the points start and end. All
2013/// points are specified in logical coordinates. Arc returns true if the arc is
2014/// drawn successfully; otherwise, it returns false. The current position is neither
2015/// used nor altered by this call. The drawing direction default is
2016/// counterclockwise.
2017//
2018inline bool TDC::Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
2019{
2020 return ::Arc(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
2021}
2022
2023//
2024/// Draws an elliptical arc on this DC using the currently selected pen object. The
2025/// center of the arc is the center of the bounding rectangle, specified either by
2026/// (x1, y1)/(x2, y2) or by the rectangle r. The starting/ending points of the arc
2027/// are specified either by (x3, y3)/(x4, y4) or by the points start and end. All
2028/// points are specified in logical coordinates. Arc returns true if the arc is
2029/// drawn successfully; otherwise, it returns false. The current position is neither
2030/// used nor altered by this call. The drawing direction default is
2031/// counterclockwise.
2032//
2033inline bool TDC::Arc(const TRect& rect, const TPoint& start, const TPoint& end)
2034{
2035 return ::Arc(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
2036}
2037
2038//
2039/// Draws and fills a chord (a region bounded by the intersection of an ellipse and
2040/// a line segment) on this DC using the currently selected pen and brush objects.
2041/// The ellipse is specified by a bounding rectangle given either by (x1, y1)/(x2,
2042/// y2) or by the rectangle R. The starting/ending points of the chord are specified
2043/// either by (x3, y3)/(x4, y4) or by the points Start and End. Chord returns true
2044/// if the call is successful; otherwise, it returns false. The current position is
2045/// neither used nor altered by this call.
2046//
2047inline bool TDC::Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
2048{
2049 return ::Chord(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
2050}
2051
2052//
2053/// Draws and fills a chord (a region bounded by the intersection of an ellipse and
2054/// a line segment) on this DC using the currently selected pen and brush objects.
2055/// The ellipse is specified by a bounding rectangle given either by (x1, y1)/(x2,
2056/// y2) or by the rectangle R. The starting/ending points of the chord are specified
2057/// either by (x3, y3)/(x4, y4) or by the points Start and End. Chord returns true
2058/// if the call is successful; otherwise, it returns false. The current position is
2059/// neither used nor altered by this call.
2060//
2061inline bool TDC::Chord(const TRect& rect, const TPoint& start, const TPoint& end)
2062{
2063 return ::Chord(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
2064}
2065
2066//
2067/// Using the currently selected pen and brush objects, draws and fills a pie-shaped
2068/// wedge by drawing an elliptical arc whose center and end points are joined by
2069/// lines. The center of the ellipse is the center of the rectangle specified either
2070/// by (x1, y1)/(x2, y2) or by the rect argument. The starting/ending points of pie
2071/// are specified either by (x3, y3)/(x4, y4) or by the points Start and End.
2072/// Returns true if the call is successful; otherwise, returns false. The current
2073/// position is neither used nor altered by this call.
2074//
2075inline bool TDC::Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
2076{
2077 return ::Pie(GetHDC(), x1, y1, x2, y2, x3, y3, x4, y4);
2078}
2079
2080//
2081/// Using the currently selected pen and brush objects, draws and fills a pie-shaped
2082/// wedge by drawing an elliptical arc whose center and end points are joined by
2083/// lines. The center of the ellipse is the center of the rectangle specified either
2084/// by (x1, y1)/(x2, y2) or by the rect argument. The starting/ending points of pie
2085/// are specified either by (x3, y3)/(x4, y4) or by the points Start and End.
2086/// Returns true if the call is successful; otherwise, returns false. The current
2087/// position is neither used nor altered by this call.
2088//
2089inline bool TDC::Pie(const TRect& rect, const TPoint& start, const TPoint& end)
2090{
2091 return ::Pie(GetHDC(), rect.left, rect.top, rect.right, rect.bottom, start.x, start.y, end.x, end.y);
2092}
2093
2094//
2095/// Draws and fills an ellipse on this DC using the currently selected pen and brush
2096/// objects. The center of the ellipse is the center of the bounding rectangle
2097/// specified either by (x1, y1)/(x2, y2) or by the rect argument. Ellipse returns
2098/// true if the call is successful; otherwise, it returns false. The current
2099/// position is neither used nor altered by this call.
2100//
2101inline bool TDC::Ellipse(int x1, int y1, int x2, int y2)
2102{
2103 return ::Ellipse(GetHDC(), x1, y1, x2, y2);
2104}
2105
2106//
2107/// Draws and fills an ellipse on this DC using the currently selected pen and brush
2108/// objects. The center of the ellipse is the center of the bounding rectangle
2109/// specified either by (x1, y1)/(x2, y2) or by the rect argument. Ellipse returns
2110/// true if the call is successful; otherwise, it returns false. The current
2111/// position is neither used nor altered by this call.
2112//
2113inline bool TDC::Ellipse(const TPoint& p1, const TPoint& p2)
2114{
2115 return ::Ellipse(GetHDC(), p1.x, p1.y, p2.x, p2.y);
2116}
2117
2118//
2119/// Draws and fills an ellipse on this DC using the currently selected pen and brush
2120/// objects. The center of the ellipse is the center of the bounding rectangle
2121/// specified either by (x1, y1)/(x2, y2) or by the rect argument. Ellipse returns
2122/// true if the call is successful; otherwise, it returns false. The current
2123/// position is neither used nor altered by this call.
2124//
2125inline bool TDC::Ellipse(const TPoint& p, const TSize& s)
2126{
2127 return ::Ellipse(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy);
2128}
2129
2130//
2131/// Draws and fills an ellipse on this DC using the currently selected pen and brush
2132/// objects. The center of the ellipse is the center of the bounding rectangle
2133/// specified either by (x1, y1)/(x2, y2) or by the rect argument. Ellipse returns
2134/// true if the call is successful; otherwise, it returns false. The current
2135/// position is neither used nor altered by this call.
2136//
2137inline bool TDC::Ellipse(const TRect& rect)
2138{
2139 return ::Ellipse(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
2140}
2141
2142//
2143/// Draws a line on this DC using the current pen object. The line is drawn from the
2144/// current position up to, but not including, the given end point, which is
2145/// specified by (x, y) or by point. If the call is successful, LineTo returns true
2146/// and the current point is reset to point; otherwise, it returns false.
2147//
2148inline bool TDC::LineTo(int x, int y)
2149{
2150 return ::LineTo(GetHDC(), x, y);
2151}
2152
2153//
2154/// Draws a line on this DC using the current pen object. The line is drawn from the
2155/// current position up to, but not including, the given end point, which is
2156/// specified by (x, y) or by point. If the call is successful, LineTo returns true
2157/// and the current point is reset to point; otherwise, it returns false.
2158//
2159inline bool TDC::LineTo(const TPoint& point)
2160{
2161 return ::LineTo(GetHDC(), point.x, point.y);
2162}
2163
2164//
2165/// Using the current pen object, draws on this DC a count of line segments (there
2166/// must be at least 2). The points array specifies the sequence of points to be
2167/// connected. The current position is neither used nor altered by Polyline. Returns
2168/// true if the call is successful; otherwise, returns false.
2169//
2170inline bool TDC::Polyline(const TPoint* points, int count)
2171{
2172 return ::Polyline(GetHDC(), points, count);
2173}
2174
2175//
2176inline bool TDC::Polygon(const TPoint* points, int count)
2177{
2178 return ::Polygon(GetHDC(), const_cast<TPoint*>(points), count);
2179}
2180
2181//
2182/// Using the current pen and polygon-filling mode, draws and fills on this DC the
2183/// number of closed polygons indicated in count (which must be >= 2). The polygons
2184/// can overlap. The points array specifies the vertices of the polygons to be
2185/// drawn. PolyCounts is an array of count integers specifying the number of
2186/// vertices in each polygon. Each polygon must be a closed polygon. The current
2187/// position is neither used nor altered by Polygon. Returns true if the call is
2188/// successful; otherwise, returns false.
2189//
2190inline bool TDC::PolyPolygon(const TPoint* points, const int* polyCounts, int count)
2191{
2192 return ::PolyPolygon(GetHDC(), const_cast<TPoint*>(points), polyCounts, count); // API typecast
2193}
2194
2195//
2196/// Using the currently selected pen object, draws on this DC the number of
2197/// polylines (connected line segments) indicated in count. The resulting figures
2198/// are not filled. The PolyCounts array provides count integers specifying the
2199/// number of points (>= 2) in each polyline. The points array provides,
2200/// consecutively, each of the points to be connected. Returns true if the call is
2201/// successful; otherwise, returns false. The current position is neither used nor
2202/// altered by this call.
2203//
2204inline bool TDC::PolyPolyline(const TPoint* points, const int* polyCounts, int count)
2205{
2206 return ::PolyPolyline(GetHDC(), const_cast<TPoint*>(points), reinterpret_cast<const DWORD*>(polyCounts), count); // API typecast
2207}
2208
2209//
2210/// Draws one or more connected cubic Bezier splines through the points specified in
2211/// the points array using the currently selected pen object. The first spline is
2212/// drawn from the first to the fourth point of the array using the second and third
2213/// points as controls. Subsequent splines, if any, each require three additional
2214/// points in the array, since the previous end point is taken as the next spline's
2215/// start point. The count argument ( >= 4 ) specifies the total number of points
2216/// needed to specify the complete drawing. To draw n splines, count must be set to
2217/// (3n + 1). Returns true if the call is successful; otherwise, returns false. The
2218/// current position is neither used nor altered by this call. The resulting figure
2219/// is not filled.
2220//
2221inline bool TDC::PolyBezier(const TPoint* points, int count)
2222{
2223 return ::PolyBezier(GetHDC(), const_cast<TPoint*>(points), count);
2224}
2225
2226//
2227/// Draws one or more connected cubic Beziers splines through the points specified
2228/// in the points array using the currently selected pen object. The first spline is
2229/// drawn from the current position to the third point of the array using the first
2230/// and second points as controls. Subsequent splines, if any, each require three
2231/// additional points in the array, since the previous end point is taken as the
2232/// next spline's start point. The count argument ( >= 4 ) specifies the total
2233/// number of points needed to specify the complete drawing. To draw n splines,
2234/// count must be set to 3n. Returns true if the call is successful; otherwise,
2235/// returns false. The current position is moved to the end point of the final
2236/// Bezier curve. The resulting figure is not filled.
2237//
2238inline bool TDC::PolyBezierTo(const TPoint* points, int count)
2239{
2240 return ::PolyBezierTo(GetHDC(), const_cast<TPoint*>(points), count);
2241}
2242
2243//
2244/// Using the currently selected pen object, draws one or more possibly disjoint
2245/// sets of line segments or Bezier splines or both on this DC. The count points in
2246/// the points array provide the end points for each line segment or the end points
2247/// and control points for each Bezier spline or both. The count BYTEs in the types
2248/// array determine as follows how the corresponding point in points is to be
2249/// interpreted:
2250/// - \c \b PT_BEZIERTO This point is a control or end point for a Bezier spline.
2251/// PT_BEZIERTO types must appear in sets of three: the current position is the
2252/// Bezier start point; the first two PT_BEZIERTO points are the Bezier control
2253/// points; and the third PT_BEZIERTO point is the Bezier end point, which becomes
2254/// the new current point. An error occurs if the PT_BEZIERTO types do not appear in
2255/// sets of three. An end-point PT_BEZIERTO can be bit-wise OR'd with PT_CLOSEFIGURE
2256/// to indicate that the current figure is to be closed by drawing a spline from
2257/// this end point to the start point of the most recent disjoint figure.
2258/// - \c \b PT_CLOSEFIGURE Optional flag that can be bit-wise OR'd with PT_LINETO or
2259/// PT_BEZIERTO, as explained above. Closure updates the current point to the new
2260/// end point.
2261/// - \c \b PT_LINETO A line is drawn from the current position to this point, which then
2262/// becomes the new current point. PT_LINETO can be bit-wise OR'd with
2263/// PT_CLOSEFIGURE to indicate that the current figure is to be closed by drawing a
2264/// line segment from this point to the start point of the most recent disjoint
2265/// figure.
2266/// - \c \b PT_MOVETO This point starts a new (disjoint) figure and becomes the new current
2267/// point.
2268///
2269/// PolyDraw is an alternative to consecutive calls to MoveTo, LineTo, Polyline,
2270/// PolyBezier, and PolyBezierTo. If there is an active path invoked via BeginPath,
2271/// PolyDraw will add to this path.
2272/// Returns true if the call is successful; otherwise, returns false.
2273//
2274inline bool TDC::PolyDraw(const TPoint* points, uint8* types, int count)
2275{
2276 return ::PolyDraw(GetHDC(), const_cast<TPoint*>(points), types, count);
2277}
2278
2279//
2280/// Draws one or more connected line segments on this DC using the currently
2281/// selected pen object. The first line is drawn from the current position to the
2282/// first of the count points in the points array. Subsequent lines, if any, connect
2283/// the remaining points in the array, with each end point providing the start point
2284/// of the next segment. The final end point becomes the new current point. No
2285/// filling occurs even if a closed figure is drawn. Returns true if the call is
2286/// successful; otherwise, returns false.
2287//
2288inline bool TDC::PolylineTo(const TPoint* points, int count)
2289{
2290 return ::PolylineTo(GetHDC(), const_cast<TPoint*>(points), count);
2291}
2292
2293//
2294/// Draws and fills a rectangle of the given size on this DC with the current pen
2295/// and brush objects. The current position is neither used nor altered by this
2296/// call. Returns true if the call is successful; otherwise, returns false.
2297//
2298inline bool TDC::Rectangle(int x1, int y1, int x2, int y2)
2299{
2300 return ::Rectangle(GetHDC(), x1, y1, x2, y2);
2301}
2302
2303//
2304/// Draws and fills a rectangle of the given size on this DC with the current pen
2305/// and brush objects. The current position is neither used nor altered by this
2306/// call. Returns true if the call is successful; otherwise, returns false.
2307//
2308inline bool TDC::Rectangle(const TPoint& p1, const TPoint& p2)
2309{
2310 return ::Rectangle(GetHDC(), p1.x, p1.y, p2.x, p2.y);
2311}
2312
2313//
2314/// Draws and fills a rectangle of the given size on this DC with the current pen
2315/// and brush objects. The current position is neither used nor altered by this
2316/// call. Returns true if the call is successful; otherwise, returns false.
2317//
2318inline bool TDC::Rectangle(const TPoint& p, const TSize& s)
2319{
2320 return ::Rectangle(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy);
2321}
2322
2323//
2324/// Draws and fills a rectangle of the given size on this DC with the current pen
2325/// and brush objects. The current position is neither used nor altered by this
2326/// call. Returns true if the call is successful; otherwise, returns false.
2327//
2328inline bool TDC::Rectangle(const TRect& rect)
2329{
2330 return ::Rectangle(GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
2331}
2332
2333//
2334/// Draws and fills a rounded rectangle of the given size on this DC with the
2335/// current pen and brush objects. The current position is neither used nor altered
2336/// by this call. Returns true if the call is successful; otherwise, returns false.
2337//
2338inline bool TDC::RoundRect(int x1, int y1, int x2, int y2, int x3, int y3)
2339{
2340 return ::RoundRect(GetHDC(), x1, y1, x2, y2, x3, y3);
2341}
2342
2343//
2344/// Draws and fills a rounded rectangle of the given size on this DC with the
2345/// current pen and brush objects. The current position is neither used nor altered
2346/// by this call. Returns true if the call is successful; otherwise, returns false.
2347//
2348inline bool TDC::RoundRect(const TPoint& p1, const TPoint& p2, const TPoint& rad)
2349{
2350 return ::RoundRect(GetHDC(), p1.x, p1.y, p2.x, p2.y, rad.x, rad.y);
2351}
2352
2353//
2354/// Draws and fills a rounded rectangle of the given size on this DC with the
2355/// current pen and brush objects. The current position is neither used nor altered
2356/// by this call. Returns true if the call is successful; otherwise, returns false.
2357//
2358inline bool TDC::RoundRect(const TPoint& p, const TSize& s, const TPoint& rad)
2359{
2360 return ::RoundRect(GetHDC(), p.x, p.y, p.x+s.cx, p.y+s.cy, rad.x, rad.y);
2361}
2362
2363//
2364/// Draws and fills a rounded rectangle of the given size on this DC with the
2365/// current pen and brush objects. The current position is neither used nor altered
2366/// by this call. Returns true if the call is successful; otherwise, returns false.
2367//
2368inline bool TDC::RoundRect(const TRect& rect, const TPoint& rad)
2369{
2370 return ::RoundRect(GetHDC(), rect.left, rect.top, rect.right, rect.bottom,
2371 rad.x, rad.y);
2372}
2373
2374//
2375/// Returns the color of the pixel at the given location.
2376//
2377inline TColor TDC::GetPixel(int x, int y) const
2378{
2379 return ::GetPixel(GetHDC(), x, y);
2380}
2381
2382//
2383/// Returns the color of the pixel at the given location.
2384//
2385inline TColor TDC::GetPixel(const TPoint& point) const
2386{
2387 return ::GetPixel(GetHDC(), point.x, point.y);
2388}
2389
2390//
2391/// Sets the color of the pixel at the given location to the given color and returns
2392/// the pixel's previous color.
2393//
2394inline TColor TDC::SetPixel(int x, int y, const TColor& color)
2395{
2396 return ::SetPixel(GetHDC(), x, y, color);
2397}
2398
2399//
2400/// Sets the color of the pixel at the given location to the given color and returns
2401/// the pixel's previous color.
2402//
2404{
2405 return ::SetPixel(GetHDC(), point.x, point.y, color);
2406}
2407
2408//
2409/// Performs a bit-block transfer from srcDc (the given source DC) to this DC (the
2410/// destination DC). Color bits are copied from a source rectangle to a destination
2411/// rectangle. The location of the source rectangle is specified either by its upper
2412/// left-corner logical coordinates (srcX, srcY), or by the TPoint object, src. The
2413/// destination rectangle can be specified either by its upper left-corner logical
2414/// coordinates (dstX, dstY), width w, and height h, or by the TRect object, dst.
2415/// The destination rectangle has the same width and height as the source. The rop
2416/// argument specifies the raster operation used to combine the color data for each
2417/// pixel. See TDC::MaskBlt for a detailed list of rop codes.
2418/// When recording an enhanced metafile, an error occurs if the source DC identifies
2419/// the enhanced metafile DC.
2420//
2421inline bool TDC::BitBlt(int dstX, int dstY, int w, int h, const TDC& srcDC,
2422 int srcX, int srcY, uint32 rop)
2423{
2424 return ::BitBlt(GetHDC(), dstX, dstY, w, h, srcDC, srcX, srcY, rop);
2425}
2426
2427//
2428/// Performs a bit-block transfer from srcDc (the given source DC) to this DC (the
2429/// destination DC). Color bits are copied from a source rectangle to a destination
2430/// rectangle. The location of the source rectangle is specified either by its upper
2431/// left-corner logical coordinates (srcX, srcY), or by the TPoint object, src. The
2432/// destination rectangle can be specified either by its upper left-corner logical
2433/// coordinates (dstX, dstY), width w, and height h, or by the TRect object, dst.
2434/// The destination rectangle has the same width and height as the source. The rop
2435/// argument specifies the raster operation used to combine the color data for each
2436/// pixel. See TDC::MaskBlt for a detailed list of rop codes.
2437/// When recording an enhanced metafile, an error occurs if the source DC identifies
2438/// the enhanced metafile DC.
2439//
2440inline bool TDC::BitBlt(const TRect& dst, const TDC& srcDC, const TPoint& src,
2441 uint32 rop)
2442{
2443 return ::BitBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
2444 srcDC, src.x, src.y, rop);
2445}
2446
2447//
2448inline bool TDC::PatBlt(int x, int y, int w, int h, uint32 rop)
2449{
2450 return ::PatBlt(GetHDC(), x, y, w, h, rop);
2451}
2452
2453//
2454inline bool TDC::PatBlt(const TRect& dst, uint32 rop)
2455{
2456 return ::PatBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(), rop);
2457}
2458
2459//
2460/// Scrolls a rectangle of bits horizontally by x (or delta.x in the second version)
2461/// device-units, and vertically by y (or delta.y) device-units on this DC. The
2462/// scrolling and clipping rectangles are specified by scroll and clip. ScrollDC
2463/// provides data in the updateRgn argument telling you the region (not necessarily
2464/// rectangular) that was uncovered by the scroll. Similarly, ScrollDC reports in
2465/// updateRect the rectangle (in client coordinates) that bounds the scrolling
2466/// update region. This is the largest area that requires repainting.
2467/// Returns true if the call is successful; otherwise, returns false.
2468//
2469inline bool TDC::ScrollDC(int dx, int dy, const TRect& scroll, const TRect& clip,
2471{
2472 return ::ScrollDC(GetHDC(), dx, dy, &scroll, &clip, updateRgn, &updateRect);
2473}
2474
2475//
2476/// Scrolls a rectangle of bits horizontally by x (or delta.x in the second version)
2477/// device-units, and vertically by y (or delta.y) device-units on this DC. The
2478/// scrolling and clipping rectangles are specified by scroll and clip. ScrollDC
2479/// provides data in the updateRgn argument telling you the region (not necessarily
2480/// rectangular) that was uncovered by the scroll. Similarly, ScrollDC reports in
2481/// updateRect the rectangle (in client coordinates) that bounds the scrolling
2482/// update region. This is the largest area that requires repainting.
2483/// Returns true if the call is successful; otherwise, returns false.
2484///
2485inline bool TDC::ScrollDC(const TPoint& delta, const TRect& scroll, const TRect& clip,
2487{
2488 return ::ScrollDC(GetHDC(), delta.x, delta.y, &scroll, &clip, updateRgn, &updateRect);
2489}
2490
2491//
2492/// Copies a bitmap from the source DC to a destination rectangle on this DC
2493/// specified either by upper left-corner coordinates (dstX, dstY), width dstW, and
2494/// height dstH, or (in the second version) by a TRect object, dst. The source
2495/// bitmap is similarly specified with (srcX, srcY), srcW, and srcH, or by a TRect
2496/// object, src. StretchBlt stretches or compresses the source according to the
2497/// stretching mode currently set in this DC (the destination DC). The
2498/// raster-operation code, rop, specifies how the colors are combined in output
2499/// operations that involve a brush, a source bitmap, and a destination bitmap. The
2500/// rop codes are described in the entry for TDC::MaskBlt
2501//
2502inline bool TDC::StretchBlt(int dstX, int dstY, int dstW, int dstH,
2503 const TDC& srcDC, int srcX, int srcY, int srcW,
2504 int srcH, uint32 rop)
2505{
2506 return ::StretchBlt(GetHDC(), dstX, dstY, dstW, dstH,
2507 srcDC, srcX, srcY, srcW, srcH, rop);
2508}
2509
2510//
2511/// Copies a bitmap from the source DC to a destination rectangle on this DC
2512/// specified either by upper left-corner coordinates (dstX, dstY), width dstW, and
2513/// height dstH, or (in the second version) by a TRect object, dst. The source
2514/// bitmap is similarly specified with (srcX, srcY), srcW, and srcH, or by a TRect
2515/// object, src. StretchBlt stretches or compresses the source according to the
2516/// stretching mode currently set in this DC (the destination DC). The
2517/// raster-operation code, rop, specifies how the colors are combined in output
2518/// operations that involve a brush, a source bitmap, and a destination bitmap. The
2519/// rop codes are described in the entry for TDC::MaskBlt
2520//
2521inline bool TDC::StretchBlt(const TRect& dst, const TDC& srcDC,
2522 const TRect& src, uint32 rop)
2523{
2524 return ::StretchBlt(GetHDC(),
2525 dst.left, dst.top, dst.Width(), dst.Height(),
2526 srcDC, src.left, src.top,
2527 src.Width(), src.Height(), rop);
2528}
2529
2530//
2531/// Copies a bitmap from the given source DC to this DC. MaskBlt combines the color
2532/// data from source and destination bitmaps using the given mask and raster
2533/// operation. The srcDC argument specifies the DC from which the source bitmap will
2534/// be copied. The destination bitmap is given by the rectangle, dst. The source
2535/// bitmap has the same width and height as dst. The src argument specifies the
2536/// logical coordinates of the upper left corner of the source bitmap. The maskBm
2537/// argument specifies a monochrome mask bitmap. An error will occur if maskBm is
2538/// not monochrome. The maskPos argument gives the upper left corner coordinates of
2539/// the mask. The raster-operation code, rop, specifies how the source, mask, and
2540/// destination bitmaps combine to produce the new destination bitmap. The
2541/// raster-operation codes are as follows:
2542/// - \c \b BLACKNESS Fill dst with index-0 color of physical palette (default is black).
2543/// - \c \b DSTINVERT Invert dst.
2544/// - \c \b MERGECOPY Merge the colors of source with mask with Boolean AND.
2545/// - \c \b MERGEPAINT Merge the colors of inverted-source with the colors of dst using
2546/// Boolean OR.
2547/// - \c \b NOTSRCCOPY Copy inverted-source to dst.
2548/// - \c \b NOTSRCERASE Combine the colors of source and dst using Boolean OR, then invert
2549/// result.
2550/// - \c \b PATCOPY Copy mask to dst.
2551/// - \c \b PATINVERT Combine the colors of mask with the colors of dst using Boolean XOR.
2552/// - \c \b PATPAINT Combine the colors of mask with the colors of inverted-source using
2553/// Boolean OR, then combine the result with the colors of dst using Boolean OR.
2554/// - \c \b SRCAND Combine the colors of source and dst using the Boolean AND.
2555/// - \c \b SRCCOPY Copy source directly to dst.
2556/// - \c \b SRCERASE Combine the inverted colors of dst with the colors of source using
2557/// Boolean AND.
2558/// - \c \b SRCPAINT Combine the colors of source and dst using Boolean OR.
2559/// - \c \b WHITENESS Fill dst with index-1 color of physical palette (default is white).
2560///
2561/// If rop indicates an operation that excludes the source bitmap, the srcDC
2562/// argument must be 0. A value of 1 in the mask indicates that the destination and
2563/// source pixel colors should be combined using the high-order word of rop. A value
2564/// of 0 in the mask indicates that the destination and source pixel colors should
2565/// be combined using the low-order word of rop. If the mask rectangle is smaller
2566/// than dst, the mask pattern will be suitably duplicated.
2567/// When recording an enhanced metafile, an error occurs if the source DC identifies
2568/// the enhanced metafile DC.
2569/// If a rotation or shear transformation is in effect for the source DC when
2570/// MaskBlt is called, an error occurs. Other transformations are allowed. If
2571/// necessary, MaskBlt will adjust the destination and mask color formats to match
2572/// that of the source bitmaps. Before using MaskBlt, an application should call
2573/// GetDeviceCaps to determine if the source and destination DCs support MaskBlt.
2574/// MaskBlt returns true if the call is successful; otherwise, it returns false.
2575//
2576inline bool TDC::MaskBlt(const TRect& dst,
2577 const TDC& srcDC, const TPoint& src,
2578 const TBitmap& maskBm, const TPoint& maskPos,
2579 uint32 rop)
2580{
2581 return ::MaskBlt(GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
2582 srcDC, src.x, src.y, maskBm, maskPos.x, maskPos.y,
2583 rop);
2584}
2585
2586//
2587/// Performs a bit-block transfer from the given source DC to this DC.
2588/// Color bits are copied from the src rectangle on srcDC, the source DC, to the
2589/// parallelogram dst on this DC. The dst array specifies three points A,B, and C as
2590/// the corners of the destination parallelogram. The fourth point D is generated
2591/// internally from the vector equation D = B + C - A. The upper left corner of src
2592/// is mapped to A, the upper right corner to B, the lower left corner to C, and the
2593/// lower right corner to D. An optional monochrome bitmap can be specified by the
2594/// maskBm argument. (If maskBm specifies a valid monochrome bitmap, PlgBlt uses it
2595/// to mask the colorbits in the source rectangle. An error occurs if maskBm is not
2596/// a monochrome bitmap.) maskPos specifies the upper left corner coordinates of the
2597/// mask bitmap. With a valid maskBm, a value of 1 in the mask causes the source
2598/// color pixel to be copied to dst; a value of 0 in the mask indicates that the
2599/// corresponding color pixel in dst will not be changed. If the mask rectangle is
2600/// smaller than dst, the mask pattern will be suitably duplicated.
2601/// The destination coordinates are transformed according to this DC (the
2602/// destination DC). The source coordinates are transformed according to the source
2603/// DC. If a rotation or shear transformation is in effect for the source DC when
2604/// PlgBlt is called, an error occurs. Other transformations, such as scaling,
2605/// translation, and reflection are allowed. The stretching mode of this DC (the
2606/// destination DC) determines how PlgBlt will stretch or compress the pixels if
2607/// necessary. When recording an enhanced metafile, an error occurs if the source DC
2608/// identifies the enhanced metafile DC.
2609/// If necessary, PlgBlt adjusts the source color formats to match that of the
2610/// destination. An error occurs if the source and destination DCs are incompatible.
2611/// Before using PlgBlt, an application should call GetDeviceCaps to determine if
2612/// the source and destination DCs are compatible.
2613/// PlgBlt returns true if the call is successful; otherwise, it returns false.
2614//
2615inline bool TDC::PlgBlt(const TPoint* points,
2616 const TDC& srcDC, const TRect& src,
2617 const TBitmap& maskBm, const TPoint& maskPos)
2618{
2619 return ::PlgBlt(GetHDC(), const_cast<TPoint*>(points),
2620 srcDC, src.left, src.top, src.Width(), src.Height(),
2621 maskBm, maskPos.x, maskPos.y);
2622}
2623#if defined(OWL5_COMPAT)
2624inline bool TDC::PlgBlt(const TPoint& dst,
2625 const TDC& srcDC, const TRect& src,
2626 const TBitmap& maskBm, const TPoint& maskPos)
2627{
2628 return ::PlgBlt(GetHDC(), (TPoint*)&dst,
2629 srcDC, src.left, src.top, src.Width(), src.Height(),
2630 maskBm, maskPos.x, maskPos.y);
2631}
2632#endif
2633
2634//
2635/// Performs a bit-block transfer of the color data corresponding to a rectangle of pixels from
2636/// the specified source device context into a destination device context.
2637/// Returns true on success; otherwise false.
2638/// This function is a wrapper for the Windows API TransparentBlt function.
2639/// http://msdn.microsoft.com/en-us/library/dd145141
2640//
2641inline bool TDC::TransparentBlt(const TRect& dst, const TDC& srcDC, const TRect& src, const TColor& transparent)
2642{
2643 return ::TransparentBlt(GetHDC(),
2644 dst.X(), dst.Y(), dst.Width(), dst.Height(),
2645 srcDC.GetHDC(), src.X(), src.Y(), src.Width(), src.Height(),
2646 transparent.GetValue());
2647}
2648
2649//
2650/// The first version retrieves some or all of the bits from the given bitmap on
2651/// this DC and copies them to the bits buffer using the DIB (device-independent
2652/// bitmap) format specified by the BITMAPINFO argument, info. numScan scanlines of
2653/// the bitmap are retrieved, starting at scan line startScan. The usage argument
2654/// determines the format of the bmiColors member of the BITMAPINFO structure,
2655/// according to the following table:
2656/// - \c \b DIB_PAL_COLORS The color table is an array of 16-bit indexes into the current
2657/// logical palette.
2658/// - \c \b DIB_RGB_COLORS The color table contains literal RGB values.
2659/// - \c \b DIB_PAL_INDICES There is no color table for this bitmap. The DIB bits consist of
2660/// indexes into the system palette. No color translation occurs. Only the
2661/// BITMAPINFOHEADER portion of BITMAPINFO is filled in.
2662///
2663/// In the second version of GetDIBits, the bits are retrieved from bitmap and
2664/// placed in the dib.Bits data member of the given TDib argument. The BITMAPINFO
2665/// argument is supplied from dib.info.
2666/// GetDIBits returns true if the call is successful; otherwise, it returns false.
2667//
2669 void * bits, const BITMAPINFO & info,
2670 uint16 usage)
2671{
2672 return ::GetDIBits(GetHDC(), bitmap, startScan, numScans, bits,
2673 const_cast<BITMAPINFO*>(&info), usage);
2674}
2675
2676//
2677/// The first version retrieves some or all of the bits from the given bitmap on
2678/// this DC and copies them to the bits buffer using the DIB (device-independent
2679/// bitmap) format specified by the BITMAPINFO argument, info. numScan scanlines of
2680/// the bitmap are retrieved, starting at scan line startScan. The usage argument
2681/// determines the format of the bmiColors member of the BITMAPINFO structure,
2682/// according to the following table:
2683/// - \c \b DIB_PAL_COLORS The color table is an array of 16-bit indexes into the current
2684/// logical palette.
2685/// - \c \b DIB_RGB_COLORS The color table contains literal RGB values.
2686/// - \c \b DIB_PAL_INDICES There is no color table for this bitmap. The DIB bits consist of
2687/// indexes into the system palette. No color translation occurs. Only the
2688/// BITMAPINFOHEADER portion of BITMAPINFO is filled in.
2689///
2690/// In the second version of GetDIBits, the bits are retrieved from bitmap and
2691/// placed in the dib.Bits data member of the given TDib argument. The BITMAPINFO
2692/// argument is supplied from dib.info.
2693/// GetDIBits returns true if the call is successful; otherwise, it returns false.
2694//
2696{
2697 return ::GetDIBits(GetHDC(), bitmap, dib.StartScan(), dib.NumScans(),
2698 dib.GetBits(), dib.GetInfo(), dib.Usage());
2699}
2700
2701//
2702/// The first version sets the pixels in bitmap (the given destination bitmap on
2703/// this DC) from the source DIB (device-independent bitmap) color data found in the
2704/// byte array bits and the BITMAPINFO structure, Info. numScan scanlines are taken
2705/// from the DIB, starting at scanline startScan. The usage argument specifies how
2706/// the bmiColors member of BITMAPINFO is interpreted, as explained in
2707/// TDC::GetDIBits.
2708/// In the second version of SetDIBits, the pixels are set in bitmap from the given
2709/// source TDib argument.
2710/// SetDIBits returns true if the call is successful; otherwise, it returns false.
2711//
2713 const void * bits, const BITMAPINFO & info,
2714 uint16 usage)
2715{
2716 return ::SetDIBits(GetHDC(), bitmap, startScan, numScans,
2717 bits, const_cast<BITMAPINFO*>(&info), usage);
2718 // API typecast
2719}
2720
2721//
2722/// The first version sets the pixels in bitmap (the given destination bitmap on
2723/// this DC) from the source DIB (device-independent bitmap) color data found in the
2724/// byte array bits and the BITMAPINFO structure, Info. numScan scanlines are taken
2725/// from the DIB, starting at scanline startScan. The usage argument specifies how
2726/// the bmiColors member of BITMAPINFO is interpreted, as explained in
2727/// TDC::GetDIBits.
2728/// In the second version of SetDIBits, the pixels are set in bitmap from the given
2729/// source TDib argument.
2730/// SetDIBits returns true if the call is successful; otherwise, it returns false.
2731//
2733{
2734 return ::SetDIBits(GetHDC(), bitmap, dib.StartScan(), dib.NumScans(),
2735 dib.GetBits(), const_cast<BITMAPINFO*>(dib.GetInfo()), dib.Usage());
2736 // API typecast
2737}
2738
2739//
2740/// The first version sets the pixels in dst (the given destination rectangle on
2741/// this DC) from the source DIB (device-independent bitmap) color data found in the
2742/// byte array bits and the BITMAPINFO structure, bitsInfo. The DIB origin is
2743/// specified by the point src. numScan scanlines are taken from the DIB, starting
2744/// at scanline startScan. The usage argument determines how the bmiColors member of
2745/// BITMAPINFO is interpreted, as explained in TDC::GetDIBits.
2746/// In the second version of SetDIBitsToDevice, the pixels are set in dst from dib,
2747/// the given source TDib argument.
2748/// SetDIBitsToDevice returns true if the call is successful; otherwise, it returns
2749/// false.
2750//
2751inline int TDC::SetDIBitsToDevice(const TRect& dst, const TPoint& src,
2753 const void * bits,
2754 const BITMAPINFO & info, uint16 usage)
2755{
2756 return ::SetDIBitsToDevice(
2757 GetHDC(), dst.left, dst.top,
2758 dst.Width(), dst.Height(), src.x, src.y,
2760 const_cast<void*>(bits), const_cast<BITMAPINFO*>(&info), usage
2761 ); // API typecast
2762}
2763
2764//
2765/// The first version sets the pixels in dst (the given destination rectangle on
2766/// this DC) from the source DIB (device-independent bitmap) color data found in the
2767/// byte array bits and the BITMAPINFO structure, bitsInfo. The DIB origin is
2768/// specified by the point src. numScan scanlines are taken from the DIB, starting
2769/// at scanline startScan. The usage argument determines how the bmiColors member of
2770/// BITMAPINFO is interpreted, as explained in TDC::GetDIBits.
2771/// In the second version of SetDIBitsToDevice, the pixels are set in dst from dib,
2772/// the given source TDib argument.
2773/// SetDIBitsToDevice returns true if the call is successful; otherwise, it returns
2774/// false.
2775//
2776inline int TDC::SetDIBitsToDevice(const TRect& dst, const TPoint& src,
2777 const TDib& dib)
2778{
2779 return ::SetDIBitsToDevice(
2780 GetHDC(),
2781 dst.left, dst.top, dst.Width(), dst.Height(),
2782 src.x, src.y,
2783 dib.StartScan(), dib.NumScans(),
2784 const_cast<void*>(dib.GetBits()),
2785 const_cast<BITMAPINFO*>(dib.GetInfo()), dib.Usage()
2786 ); // API typecast
2787}
2788
2789//
2790/// Copies the color data from src, the source rectangle of pixels in the given DIB
2791/// (device-independent bitmap) on this DC, to dst, the destination rectangle. The
2792/// DIB bits and color data are specified in either the byte array bits and the
2793/// BITMAPINFO structure bitsInfo or in the TDib object, dib. The rows and columns
2794/// of color data are stretched or compressed to match the size of the destination
2795/// rectangle. The usage argument specifies how the bmiColors member of BITMAPINFO
2796/// is interpreted, as explained in TDC::GetDIBits The raster operation code, rop,
2797/// specifies how the source pixels, the current brush for this DC, and the
2798/// destination pixels are combined to produce the new image. See TDC::MaskBlt for a
2799/// detailed list of rop codes.
2800//
2801inline int TDC::StretchDIBits(const TRect& dst, const TRect& src,
2802 const void * bits,
2803 const BITMAPINFO & info,
2805{
2806 return ::StretchDIBits(
2807 GetHDC(), dst.left, dst.top, dst.Width(), dst.Height(),
2808 src.left, src.top, src.Width(), src.Height(),
2809 bits, const_cast<BITMAPINFO*>(&info), usage, rop
2810 );
2811 // API typecast
2812}
2813
2814//
2815/// Copies the color data from src, the source rectangle of pixels in the given DIB
2816/// (device-independent bitmap) on this DC, to dst, the destination rectangle. The
2817/// DIB bits and color data are specified in either the byte array bits and the
2818/// BITMAPINFO structure bitsInfo or in the TDib object, dib. The rows and columns
2819/// of color data are stretched or compressed to match the size of the destination
2820/// rectangle. The usage argument specifies how the bmiColors member of BITMAPINFO
2821/// is interpreted, as explained in TDC::GetDIBits The raster operation code, rop,
2822/// specifies how the source pixels, the current brush for this DC, and the
2823/// destination pixels are combined to produce the new image. See TDC::MaskBlt for a
2824/// detailed list of rop codes.
2825//
2826inline int TDC::StretchDIBits(const TRect& dst, const TRect& src,
2827 const TDib& dib, uint32 rop)
2828{
2829 return ::StretchDIBits(
2830 GetHDC(),
2831 dst.left, dst.top, dst.Width(), dst.Height(),
2832 src.left, src.top, src.Width(), src.Height(),
2833 dib.GetBits(),
2834 const_cast<BITMAPINFO*>(dib.GetInfo()),
2835 dib.Usage(), rop
2836 );
2837 // API typecast
2838}
2839
2840//
2841/// Create a fast DIB under Win32.
2842//
2844{
2845#ifdef WINELIB
2846 return ::CreateDIBSection(GetHDC(), const_cast<BITMAPINFO*>(&info), usage, bits, section, offset);
2847#else
2848 return ::CreateDIBSection(GetHDC(), &info, usage, bits, section, offset);
2849#endif
2850}
2851
2852//
2853/// Fills an area on this DC starting at point and using the currently selected
2854/// brush object. The color argument specifies the color of the boundary or of the
2855/// area to be filled. Returns true if the call is successful; otherwise, returns
2856/// false. FloodFill is maintained in the WIN32 API for compatibility with earlier
2857/// APIs. New WIN32 applications should use TDC::ExtFloodFill.
2858//
2859inline bool TDC::FloodFill(const TPoint& point, const TColor& color)
2860{
2861 return ::FloodFill(GetHDC(), point.x, point.y, color);
2862}
2863
2864//
2865/// Fills an area on this DC starting at point and using the currently selected
2866/// brush object. The color argument specifies the color of the boundary or of the
2867/// region to be filled. The fillType argument specifies the type of fill, as
2868/// follows:
2869/// - \c \b FLOODFILLBORDER The fill region is bounded by the given color. This style
2870/// coincides with the filling method used by FloodFill().
2871/// - \c \b FLOODFILLSURFACE The fill region is defined by the given color. Filling
2872/// continues outward in all directions as long as this color is encountered. Use
2873/// this style when filling regions with multicolored borders.
2874///
2875/// Not every device supports ExtFloodFill, so applications should test first with
2876/// TDC::GetDeviceCaps.
2877/// ExtFloodFill returns true if the call is successful; otherwise, it returns
2878/// false.
2879//
2881{
2882 return ::ExtFloodFill(GetHDC(), point.x, point.y, color, fillType);
2883}
2884
2885//
2886/// Draws up to count characters of the given null-terminated string in the current
2887/// font on this DC. If count is -1 (the default), the entire string is written.
2888/// The (x, y) or p arguments specify the logical coordinates of the reference point
2889/// that is used to align the first character, depending on the current
2890/// text-alignment mode. This mode can be inspected with TDC::GetTextAlign and
2891/// changed with TDC::SetTextAlign. By default, the current position is neither used
2892/// nor altered by TextOut. However, the align mode can be set to TA_UPDATECP, which
2893/// makes Windows use and update the current position. In this mode, TextOut ignores
2894/// the reference point argument(s).
2895/// TextOut returns true if the call is successful; otherwise, it returns false.
2896//
2897inline bool TDC::TextOut(const TPoint& p, const tstring& str, int count)
2898{
2899 return TextOut(p.x, p.y, str, count);
2900}
2901
2902//
2903/// Draws up to count characters of the given null-terminated string in the current
2904/// font on this DC. If count is -1, the whole string is written.
2905/// An optional rectangle r can be specified for clipping, opaquing, or both, as
2906/// determined by the options value. If options is set to ETO_CLIPPED, the rectangle
2907/// is used for clipping the drawn text. If options is set to ETO_OPAQUE, the
2908/// current background color is used to fill the rectangle. Both options can be used
2909/// if ETO_CLIPPED is OR'd with ETO_OPAQUE.
2910/// The (x, y) orp arguments specify the logical coordinates of the reference point
2911/// that is used to align the first character. The current text-alignment mode can
2912/// be inspected with TDC::GetTextAlign and changed with TDC::SetTextAlign. By
2913/// default, the current position is neither used nor altered by ExtTextOut.
2914/// However, if the align mode is set to TA_UPDATECP, ExtTextOut ignores the
2915/// reference point argument(s) and uses or updates the current position as the
2916/// reference point.
2917/// The dx argument is an optional array of values used to set the distances between
2918/// the origins (upper left corners) of adjacent character cells. For example, dx[i]
2919/// represents the number of logical units separating the origins of character cells
2920/// i and i+1. If dx is 0, ExtTextOut uses the default inter-character spacings.
2921/// ExtTextOut returns true if the call is successful; otherwise, it returns false.
2922//
2923inline bool TDC::ExtTextOut(const TPoint& p, uint16 options, const TRect* rect,
2924 const tstring& str, int count, const int * dx)
2925{
2926 return ExtTextOut(p.x, p.y, options, rect, str, count, dx);
2927}
2928
2929//
2930/// Draws up to count characters of the given null-terminated string in the current
2931/// font on this DC. If count is -1, the whole string is written.
2932/// Tabs are expanded according to the given arguments. The positions array
2933/// specifies numPositions tab stops given in device units. The tab stops must have
2934/// strictly increasing values in the array. If numPositions and positions are both
2935/// 0, tabs are expanded to eight times the average character width. If numPositions
2936/// is 1, all tab stops are taken to be positions[0] apart. tabOrigin specifies the
2937/// x-coordinate in logical units from which tab expansion will start.
2938/// The p argument specifies the logical coordinates of the reference point that is
2939/// used to align the first character depending on the current text-alignment mode.
2940/// This mode can be inspected with TDC::GetTextAlign and changed with
2941/// TDC::SetTextAlign. By default, the current position is neither used nor altered
2942/// by TabbedTextOut. However, if the align mode is set to TA_UPDATECP,
2943/// TabbedTextOut ignores the reference point argument(s) and uses/updates the
2944/// current position as the reference point.
2945/// The size argument in the second version of TabbedTextOut reports the dimensions
2946/// (size.y = height and size.x = width) of the string in logical units.
2947/// TabbedTextOut returns true if the call is successful; otherwise, it returns
2948/// false.
2949//
2950inline bool TDC::TabbedTextOut(const TPoint& p, const tstring& str, int count,
2951 int numPositions, const int* positions, int tabOrigin)
2952{
2953 TSize size;
2954 TabbedTextOut(p, str, count, numPositions, positions, tabOrigin, size);
2955 return true;
2956}
2957
2958//
2959/// Computes the extent (width and height) in logical units of the text line
2960/// consisting of stringLen characters from the null-terminated string. The extent
2961/// is calculated from the metrics of the current font or this DC, but ignores the
2962/// current clipping region. In the first version of GetTextExtent the extent is
2963/// returned in size; in the second version, the extent is the returned TSize
2964/// object. Width is size.cx and height is size.cy.
2965/// If kerning is being applied, the sum of the extents of the characters in a
2966/// string might not equal the extent of the string.
2967//
2968inline bool TDC::GetTextExtent(const tstring& str, int stringLen, TSize& size) const
2969{
2970 return ::GetTextExtentPoint32(GetAttributeHDC(), str.c_str(), stringLen, &size);
2971}
2972
2973//
2974/// Computes the extent (width and height) in logical units of the text line
2975/// consisting of stringLen characters from the null-terminated string. The extent
2976/// is calculated from the metrics of the current font or this DC, but ignores the
2977/// current clipping region. In the first version of GetTextExtent the extent is
2978/// returned in size; in the second version, the extent is the returned TSize
2979/// object. Width is size.cx and height is size.cy.
2980/// If kerning is being applied, the sum of the extents of the characters in a
2981/// string might not equal the extent of the string.
2982//
2983inline TSize TDC::GetTextExtent(const tstring& str, int stringLen) const
2984{
2985 TSize size;
2986 GetTextExtent(str, stringLen, size);
2987 return size;
2988}
2989
2990//
2991/// Computes the extent (width and height) in logical units of the text line
2992/// consisting of stringLen characters from the null-terminated string. The extent
2993/// is calculated from the metrics of the current font or this DC, but ignores the
2994/// current clipping region. In the first version of GetTabbedTextExtent, the extent
2995/// is returned in size; in the second version, the extent is the returned TSize
2996/// object. Width is size.x and width is size.y.
2997/// The width calculation includes the spaces implied by any tab codes in the
2998/// string. Such tab codes are interpreted using the numPositions and positions
2999/// arguments. The positions array specifies numPositions tab stops given in device
3000/// units. The tab stops must have strictly increasing values in the array. If
3001/// numPositions and positions are both 0, tabs are expanded to eight times the
3002/// average character width. If numPositions is 1, all tab stops are taken to be
3003/// positions[0] apart.
3004/// If kerning is being applied, the sum of the extents of the characters in a
3005/// string might not equal the extent of the string.
3006//
3007inline bool TDC::GetTabbedTextExtent(const tstring& str, int strLen,
3008 int numPositions, const int* positions, TSize& size) const
3009{
3011 const_cast<int*>(positions)));
3012 return true;
3013}
3014
3015//
3016/// Computes the extent (width and height) in logical units of the text line
3017/// consisting of stringLen characters from the null-terminated string. The extent
3018/// is calculated from the metrics of the current font or this DC, but ignores the
3019/// current clipping region. In the first version of GetTabbedTextExtent, the extent
3020/// is returned in size; in the second version, the extent is the returned TSize
3021/// object. Width is size.x and width is size.y.
3022/// The width calculation includes the spaces implied by any tab codes in the
3023/// string. Such tab codes are interpreted using the numPositions and positions
3024/// arguments. The positions array specifies numPositions tab stops given in device
3025/// units. The tab stops must have strictly increasing values in the array. If
3026/// numPositions and positions are both 0, tabs are expanded to eight times the
3027/// average character width. If numPositions is 1, all tab stops are taken to be
3028/// positions[0] apart.
3029/// If kerning is being applied, the sum of the extents of the characters in a
3030/// string might not equal the extent of the string.
3031//
3033 int numPositions, const int* positions) const
3034{
3036 const_cast<int*>(positions)));
3037}
3038
3039//
3040/// If successful, returns the current text-alignment flags for this DC; otherwise,
3041/// returns the value GDI_ERROR. The text-alignment flags determine how TDC::TextOut
3042/// and TDC::ExtTextOut align text strings in relation to the first character's
3043/// screen position. GetTextAlign returns certain combinations of the flags listed
3044/// in the following table:
3045/// - \c \b TA_BASELINE The reference point will be on the baseline of the text.
3046/// - \c \b TA_BOTTOM The reference point will be on the bottom edge of the bounding
3047/// rectangle.
3048/// - \c \b TA_TOP The reference point will be on the top edge of the bounding rectangle.
3049/// - \c \b TA_CENTER The reference point will be aligned horizontally with the center of
3050/// the bounding rectangle.
3051/// - \c \b TA_LEFT The reference point will be on the left edge of the bounding rectangle.
3052/// - \c \b TA_RIGHT The reference point will be on the right edge of the bounding
3053/// rectangle.
3054/// - \c \b TA_NOUPDATECP The current position is not updated after each text output call.
3055/// - \c \b TA_UPDATECP The current position is updated after each text output call.
3056///
3057/// When the current font has a vertical default baseline (as with Kanji) the
3058/// following values replace TA_BASELINE and TA_CENTER:
3059/// - \c \b VTA_BASELINE The reference point will be on the baseline of the text.
3060/// - \c \b VTA_CENTER The reference point will be aligned vertically with the center of
3061/// the bounding rectangle.
3062///
3063/// The text-alignment flags are not necessarily single bit-flags and might be equal
3064/// to 0. The flags must be examined in groups of the following related flags:
3065/// - \c \b TA_LEFT, TA_RIGHT, and TA_CENTER
3066/// - \c \b TA_BOTTOM, TA_TOP, and TA_BASELINE
3067/// - \c \b TA_NOUPDATECP and TA_UPDATECP
3068///
3069/// If the current font has a vertical default baseline (as with Kanji), these are
3070/// groups of related flags:
3071/// - \c \b TA_LEFT, TA_RIGHT, and VTA_BASELINE
3072/// - \c \b TA_BOTTOM, TA_TOP, and VTA_CENTER
3073/// - \c \b TA_NOUPDATECP and TA_UPDATECP
3074///
3075/// To verify that a particular flag is set in the return value of this function,
3076/// the application must perform the following steps:
3077/// - 1. Apply the bitwise OR operator to the flag and its related flags.
3078/// - 2. Apply the bitwise AND operator to the result and the return value.
3079/// - 3. Test for the equality of this result and the flag.
3080///
3081/// The following example shows a method for determining which horizontal alignment
3082/// flag is set:
3083/// \code
3084/// switch ((TA_LEFT | TA_RIGHT | TA_CENTER) & dc.GetTextAlign()) {
3085/// case TA_LEFT:
3086/// ...
3087/// case TA_RIGHT:
3088/// ...
3089/// case TA_CENTER:
3090/// ...
3091/// }
3092/// \endcode
3093//
3095{
3096 return ::GetTextAlign(GetAttributeHDC());
3097}
3098
3099//
3100/// Sets the text-alignment flags for this DC. If successful, SetTextAlign returns
3101/// the previous text-alignment flags; otherwise, it returns GDI_ERROR. The flag
3102/// values are as listed for the TDC::GetTextAlign function. The text-alignment
3103/// flags determine how TDC::TextOut and TDC::ExtTextOut align text strings in
3104/// relation to the first character's screen position.
3105//
3107{
3108 if (GetHDC() != GetAttributeHDC())
3109 ::SetTextAlign(GetHDC(), flags);
3110 return ::SetTextAlign(GetAttributeHDC(), flags);
3111}
3112
3113//
3114/// If successful, returns the current intercharacter spacing, in logical units, for
3115/// this DC; otherwise, returns INVALID_WIDTH.
3116//
3118{
3119 return ::GetTextCharacterExtra(GetAttributeHDC());
3120}
3121
3122//
3123/// If successful, sets the current intercharacter spacing to extra, in logical
3124/// units, for this DC, and returns the previous intercharacter spacing. Otherwise,
3125/// returns 0. If the current mapping mode is not MM_TEXT, the extra value is
3126/// transformed and rounded to the nearest pixel.
3127//
3129{
3130 if (GetHDC() != GetAttributeHDC())
3132 return ::SetTextCharacterExtra(GetAttributeHDC(), extra);
3133}
3134
3135//
3136/// When text strings are displayed using TDC::TextOut and TDC::ExtTextOut, sets the
3137/// number of logical units specified in breakExtra as the total extra space to be
3138/// added to the number of break characters specified in breakCount. The extra space
3139/// is distributed evenly between the break characters. The break character is
3140/// usually ASCII 32 (space), but some fonts define other characters.
3141/// TDC::GetTextMetrics can be used to retrieve the value of the break character.
3142/// If the current mapping mode is not MM_TEXT, the extra value is transformed and
3143/// rounded to the nearest pixel.
3144/// SetTextJustification returns true if the call is successful; otherwise, it
3145/// returns false.
3146//
3148{
3149 return ::SetTextJustification(GetAttributeHDC(), breakExtra, breakCount);
3150}
3151
3152//
3153/// Retrieves the length of the typeface name for the current font on this DC.
3154/// The length is the number of characters excluding null-termination.
3155//
3156inline int TDC::GetTextFaceLength() const
3157{
3158 return GetTextFace(0, nullptr) - 1;
3159}
3160
3161//
3162/// Retrieves the typeface name for the current font on this DC. Up to count
3163/// characters of this name are copied to facename. If successful, GetTextFace
3164/// returns the number of characters actually copied; otherwise, it returns 0.
3165//
3166inline int TDC::GetTextFace(int count, LPTSTR facename) const
3167{
3168 return ::GetTextFace(GetAttributeHDC(), count, facename);
3169}
3170
3171//
3172/// Fills the metrics structure with metrics data for the current font on this DC.
3173/// Returns true if the call is successful; otherwise, returns false.
3174//
3176{
3177 return ::GetTextMetrics(GetAttributeHDC(), &metrics);
3178}
3179
3180//
3181/// Retrieves TrueType metric and other data for the given character, chr, on this
3182/// DC and places it in gm and buffer. The format argument specifies the format of
3183/// the retrieved data as indicated in the following table. (A value of 0 simply
3184/// fills in the GLYPHMETRICS structure but does not return glyph-outline data.)
3185/// - \c \b 1 - Retrieves the glyph bitmap.
3186/// - \c \b 2 - Retrieves the curve data points in the rasterizer's native format and uses the
3187/// font's design units. With this value of format, the mat2 transformation argument
3188/// is ignored.
3189///
3190/// The gm argument specifies the GLYPHMETRICS structure that describes the
3191/// placement of the glyph in the character cell. buffSize specifies the size of
3192/// buffer that receives data about the outline character. If either buffSize or
3193/// buffer is 0, GetGlyphOutline returns the required buffer size. Applications can
3194/// rotate characters retrieved in bitmap format (format = 1) by specifying a 2 x 2
3195/// transformation matrix via the mat2 argument.
3196/// GetGlyphOutline returns a positive number if the call is successful; otherwise,
3197/// it returns GDI_ERROR.
3198//
3200 uint32 buffSize, void * buffer,
3201 const MAT2 & mat2)
3202{
3203 return ::GetGlyphOutline(GetAttributeHDC(), chr, format, &gm, buffSize,
3204 buffer, const_cast<MAT2*>(&mat2));
3205}
3206
3207//
3208/// Retrieves kerning pairs for the current font of this DC up to the number
3209/// specified in pairs and copies them into the krnPair array of KERNINGPAIR
3210/// structures. If successful, the function returns the actual number of pairs
3211/// retrieved. If the font has more than pairs kerning pairs, the call fails and
3212/// returns 0. The krnPair array must allow for at least pairs KERNINGPAIR
3213/// structures. If krnPair is set to 0, GetKerningPairs returns the total number of
3214/// kerning pairs for the current font.
3215//
3217{
3218 return ::GetKerningPairs(GetAttributeHDC(), pairs, krnPair);
3219}
3220
3221//
3222/// Retrieves metric information for TrueType fonts on this DC and copies it to the
3223/// given array of OUTLINETEXTMETRIC structures, otm. This structure contains a
3224/// TEXTMETRIC and several other metric members, as well as four string-pointer
3225/// members for holding family, face, style, and full font names. Since memory must
3226/// be allocated for these variable-length strings in addition to the font metric
3227/// data, you must pass (with the data argument) the total number of bytes required
3228/// for the retrieved data. If GetOutlineTextMetrics is called with otm = 0, the
3229/// function returns the total buffer size required. You can then assign this value
3230/// to data in subsequent calls.
3231/// Returns nonzero if the call is successful; otherwise, returns 0.
3232//
3233inline uint
3235{
3236 return ::GetOutlineTextMetrics(GetAttributeHDC(), data, &otm);
3237}
3238
3239//
3240/// Retrieves the widths in logical units for a consecutive sequence of characters
3241/// in the current font for this DC. The sequence is specified by the inclusive
3242/// range, firstChar to lastChar, and the widths are copied to the given buffer. If
3243/// a character in the range is not represented in the current font, the width of
3244/// the default character is assigned. Returns true if the call is successful;
3245/// otherwise, returns false.
3246//
3248{
3249 return ::GetCharWidth(GetAttributeHDC(), firstChar, lastChar, buffer);
3250}
3251
3252//
3253/// Alters the algorithm used by the font mapper when mapping logical fonts to
3254/// physical fonts on this DC. If successful, the function sets the current
3255/// font-mapping flag to flag and returns the previous mapping flag; otherwise
3256/// GDI_ERROR is returned. The mapping flag determines whether the font mapper will
3257/// attempt to match a font's aspect ratio to this DC's aspect ratio. If bit 0 of
3258/// flag is set to 1, the mapper selects only matching fonts. If no matching fonts
3259/// exist, a new aspect ratio is chosen and a font is retrieved to match this ratio.
3260//
3262{
3263 if (GetHDC() != GetAttributeHDC())
3265 return ::SetMapperFlags(GetAttributeHDC(), flag);
3266}
3267
3268//
3269/// Retrieves the setting of the current aspect-ratio filter for this DC.
3270//
3271inline bool TDC::GetAspectRatioFilter(TSize& size) const
3272{
3273 return ::GetAspectRatioFilterEx(GetAttributeHDC(), &size);
3274}
3275
3276//
3277/// Enumerates the fonts available on this DC for the given faceName. The font type,
3278/// LOGFONT, and TEXTMETRIC data retrieved for each available font is passed to the
3279/// user-defined callback function together with any optional, user-supplied data
3280/// placed in the data buffer. The callback function can process this data in any
3281/// way desired. Enumeration continues until there are no more fonts or until the
3282/// callback function returns 0. If faceName is 0, EnumFonts randomly selects and
3283/// enumerates one font of each available typeface. EnumFonts returns the last value
3284/// returned by the callback function. Note that OLDFONTENUMPROC is defined as
3285/// FONTENUMPROC for Win32 only. FONTENUMPROC is a pointer to a user-defined
3286/// function and has the following prototype:
3287/// \code
3288/// int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, uint32 dwType,
3289/// LPARAM lpData);
3290/// \endcode
3291/// where dwType specifies one of the following font types: DEVICE_FONTTYPE,
3292/// RASTER_FONTTYPE, or TRUETYPE_FONTTYPE.
3293//
3295{
3296 return ::EnumFonts(GetAttributeHDC(), faceName, callback, LPARAM(data));
3297}
3298
3299//
3300/// Retrieves the widths of consecutive characters in the range firstChar to
3301/// lastChar from the current TrueType font of this DC. The widths are reported in
3302/// the array abc of ABC structures. Returns true if the call is successful;
3303/// otherwise, returns false.
3304//
3306{
3307 return ::GetCharABCWidths(GetAttributeHDC(), firstChar, lastChar, abc);
3308}
3309
3310//
3311/// Enumerates the fonts available to this DC in the font family specified by
3312/// family. The given application-defined callback proc is called for each font in
3313/// the family or until proc returns 0, and is defined as:
3314/// \code
3315/// typedef int (CALLBACK* FONTENUMPROC)(CONST LOGFONT *, CONST TEXTMETRIC *, DWORD,
3316/// LPARAM);
3317/// \endcode
3318/// data lets you pass both application-specific data and font data to proc. If
3319/// successful, the call returns the last value returned by proc.
3320//
3322{
3323 return ::EnumFontFamilies(GetAttributeHDC(), familyName, callback, LPARAM(data));
3324}
3325
3326//
3327/// Retrieves font-metric information from a scalable TrueType font file (specified
3328/// by table and starting at offset into this table) and places it in the given
3329/// buffer. data specifies the size in bytes of the data to be retrieved. If the
3330/// call is successful, it returns the number of bytes set in buffer; otherwise, -1
3331/// is returned.
3332//
3334{
3335 return ::GetFontData(GetAttributeHDC(), table, offset, buffer, data);
3336}
3337
3338//
3339/// Opens a new path bracket for this DC and discards any previous
3340/// paths from this DC. Once a path bracket is open, an application can start
3341/// calling draw functions on this DC to define the points that lie within that
3342/// path. The draw functions that define points in a path are the following TDC
3343/// members: AngleArc, Arc, Chord, CloseFigure, Ellipse, ExtTextOut, LineTo,
3344/// MoveToEx, Pie, PolyBezier, PolyBezierTo, PolyDraw, Polygon, Polyline,
3345/// PolylineTo, PolyPolygon, PolyPolyline, Rectangle, RoundRect, and TextOut.
3346/// A path bracket can be closed by calling TDC::EndPath.
3347/// BeginPath returns true if the call is successful; otherwise, it returns false.
3348//
3349inline bool TDC::BeginPath()
3350{
3351 return ::BeginPath(GetHDC());
3352}
3353
3354//
3355/// Closes an open figure in this DC's open path bracket by drawing a
3356/// line from the current position to the first point of the figure (usually the
3357/// point specified by the most recent TDC::MoveTo call), and connecting the lines
3358/// using the current join style for this DC. If you close a figure with TDC::LineTo
3359/// instead of with CloseFigure, end caps (instead of a join) are used to create the
3360/// corner. The call fails if there is no open path bracket on this DC. Any line or
3361/// curve added to the path after a CloseFigure call starts a new figure. A figure
3362/// in a path remains open until it is explicitly closed with CloseFigure even if
3363/// its current position and start point happen to coincide.
3364/// CloseFigure returns true if the call is successful; otherwise, it returns false.
3365//
3366inline bool TDC::CloseFigure()
3367{
3368 return ::CloseFigure(GetHDC());
3369}
3370
3371//
3372/// Closes the path bracket and selects the path it defines into this
3373/// DC. Returns true if the call is successful; otherwise, returns false.
3374//
3375inline bool TDC::EndPath()
3376{
3377 return ::EndPath(GetHDC());
3378}
3379
3380//
3381/// Transforms any curves in the currently selected path of this DC.
3382/// All such curves are changed to sequences of linear segments. Returns true if the
3383/// call is successful; otherwise, returns false.
3384//
3385inline bool TDC::FlattenPath()
3386{
3387 return ::FlattenPath(GetHDC());
3388}
3389
3390//
3391/// Redefines the current, closed path on this DC as the area that
3392/// would be painted if the path were stroked with this DC's current pen. The
3393/// current pen must have been created under the following conditions:
3394/// If the TPen(int Style, int Width, TColor Color) constructor, or the TPen(const
3395/// LOGPEN* LogPen) constructor is used, the width of the pen in device units must
3396/// be greater than 1.
3397/// If the TPen(uint32 PenStyle, uint32 Width, const TBrush& Brush, uint32
3398/// StyleCount, LPDWORD pSTyle) constructor, or the TPen(uint32 PenStyle, uint32
3399/// Width, const LOGBRUSH& logBrush, uint32 StyleCount, LPDWORD pSTyle) constructor
3400/// is used, the pen must be a geometric pen.
3401/// Any Bezier curves in the path are converted to sequences of linear segments
3402/// approximating the widened curves, so no Bezier curves remain in the path after a
3403/// WidenPath call.
3404/// WidenPath returns true if the call is successful; otherwise, it returns false.
3405//
3406inline bool TDC::WidenPath()
3407{
3408 return ::WidenPath(GetHDC());
3409}
3410
3411//
3412/// Closes any open figures in the current path of this DC and fills
3413/// the path's interior using the current brush and polygon fill mode. After filling
3414/// the interior, FillPath discards the path from this DC.
3415/// FillPath returns true if the call is successful; otherwise, it returns false.
3416//
3417inline bool TDC::FillPath()
3418{
3419 return ::FillPath(GetHDC());
3420}
3421
3422//
3423/// Renders the current, closed path on this DC and uses the DC's
3424/// current pen.
3425//
3426inline bool TDC::StrokePath()
3427{
3428 return ::StrokePath(GetHDC());
3429}
3430
3431//
3432/// Closes any open figures in the current path of this DC, strokes the
3433/// outline of the path using the current pen, and fills its interior using the
3434/// current brush and polygon fill mode. Returns true if the call is successful;
3435/// otherwise, returns false.
3436//
3438{
3439 return ::StrokeAndFillPath(GetHDC());
3440}
3441
3442//
3443/// Selects the current path on this DC as a clipping region, combining any existing
3444/// clipping region using the specified mode as shown in the following table:
3445/// - \c \b RGN_AND The new clipping region includes the overlapping areas of the current
3446/// clipping region and the current path (intersection).
3447/// - \c \b RGN_COPY The new clipping region is the current path.
3448/// - \c \b RGN_DIFF The new clipping region includes the areas of the current clipping
3449/// region with those of the current path excluded.
3450/// - \c \b RGN_OR The new clipping region includes the combined areas of the current
3451/// clipping region and the current path (union).
3452/// - \c \b RGN_XOR The new clipping region includes the combined areas of the current
3453/// clipping region and the current path but without the overlapping areas.
3454///
3455/// Returns true if the call is successful; otherwise, returns false.
3456//
3457inline bool TDC::SelectClipPath(int mode)
3458{
3459 return ::SelectClipPath(GetHDC(), mode);
3460}
3461
3462//
3463/// If successful, returns a region created from the closed path in this DC;
3464/// otherwise, returns 0.
3465//
3467{
3468 return ::PathToRegion(GetHDC());
3469}
3470
3471//
3472/// Closes the metafile device context and returns a handle that identifies a Windows-format metafile.
3473//
3475{
3478//#if defined(__GNUC__)//JJH I didn't find better solution for this this
3479// TGdiBase::Handle = 0;
3480//#else
3481 Handle = nullptr;
3482//#endif
3483 return mf;
3484}
3485
3486//
3487/// Returns true if the device context contains an enhanced metafile.
3488//
3489inline bool TMetaFileDC::IsEnhanced() const
3490{
3491 return Enhanced;
3492}
3493
3494//
3495/// Closes the enhanced-metafile device context and returns a handle that identifies an enhanced-format metafile.
3496//
3498{
3501//#if defined(__GNUC__)//JJH I didn't find better solution for this this
3502// TGdiBase::Handle = 0;
3503//#else
3504 Handle = nullptr;
3505//#endif
3506 return emf;
3507}
3508
3509//
3510/// Inserts a comment record into the enhanced metafile.
3511//
3512inline bool TMetaFileDC::Comment(uint bytes, const void* data)
3513{
3514 if (IsEnhanced())
3515 {
3516 return ::GdiComment(GetHDC(), bytes, reinterpret_cast<const BYTE*>(data));
3517 }
3518 return false;
3519}
3520
3521
3522} // OWL namespace
3523
3524namespace owl {
3525//
3526/// Return the DOCINFO structure.
3527//
3529{
3530 return DocInfo;
3531}
3532
3533//
3534/// Sets the DOCINFO structure.
3535//
3537{
3538 DocInfo = docinfo;
3539}
3540
3541//
3542/// Allows applications to access the capabilities of a particular device that are
3543/// not directly available through the GDI of this DC. The Escape call is specified
3544/// by setting a mnemonic value in the escape argument. In Win32 the use of Escape
3545/// with certain escape values has been replaced by specific functions. The names of
3546/// these new functions are based on the corresponding escape mnemonic, as shown in
3547/// the following table:
3548/// - \c \b ABORTDOC Superseded by TPrintDC_AbortDoc in Win32.
3549/// - \c \b BANDINFO Obsolete in Win32. Because all printer drivers for Windows version 3.1
3550/// and later set the text flag in every band, this escape is useful only for older
3551/// printer drivers.
3552/// - \c \b BEGIN_PATH No changes for Win32. This escape is specific to PostScript
3553/// printers.
3554/// - \c \b CLIP_TO_PATH No changes for Win32. This escape is specific to PostScript
3555/// printers.
3556/// - \c \b DEVICEDATA Superseded in Win32. Applications should use the PASSTHROUGH escape
3557/// to achieve the same functionality.
3558/// - \c \b DRAFTMODE Superseded in Win32. Applications can achieve the same functionality
3559/// by setting the dmPrintQuality member of the DEVMODE structure to DMRES_DRAFT and
3560/// passing this structure to the CreateDC function.
3561/// - \c \b DRAWPATTERNRECT No changes for Win32.
3562/// - \c \b ENABLEDUPLEX Superseded in Win32. Applications can achieve the same
3563/// functionality by setting the dmDuplex member of the DEVMODE structure and
3564/// passing this structure to the CreateDC function.
3565/// - \c \b ENABLEPAIRKERNING No changes for Win32.
3566/// - \c \b ENABLERELATIVEWIDTHS No changes for Win32.
3567/// - \c \b ENDDOC Superseded by TPrintDC_EndDoc in Win32.
3568/// - \c \b END_PATH No changes for Win32. This escape is specific to PostScript printers.
3569/// - \c \b ENUMPAPERBINS Superseded in Win32. Applications can use
3570/// TPrintDC::DeviceCapabilities to achieve the same functionality.
3571/// - \c \b ENUMPAPERMETRICS Superseded in Win32. Applications can use
3572/// TPrintDC::DeviceCapabilities to achieve the same functionality.
3573/// - \c \b EPSPRINTING No changes for Win32. This escape is specific to PostScript
3574/// printers.
3575/// - \c \b EXT_DEVICE_CAPS Superseded in Win32. Applications can use TDC::GetDeviceCaps to
3576/// achieve the same functionality. This escape is specific to PostScript printers.
3577/// - \c \b EXTTEXTOUT Superseded in Win32. Applications can use TDC::ExtTextOut to achieve
3578/// the same functionality. This escape is not supported by the version 3.1 PCL
3579/// driver.
3580/// - \c \b FLUSHOUTPUT Removed for Win32.
3581/// - \c \b GETCOLORTABLE Removed for Win32.
3582/// - \c \b GETEXTENDEDTEXTMETRICS No changes for Win32. Support for this escape might
3583/// change in future versions of Windows.
3584/// - \c \b GETEXTENTTABLE Superseded in Win32. Applications can use ::GetCharWidth to
3585/// achieve the same functionality. This escape is not supported by the version 3.1
3586/// PCL or PostScript drivers.
3587/// - \c \b GETFACENAME No changes for Win32. This escape is specific to PostScript
3588/// printers.
3589/// - \c \b GETPAIRKERNTABLE No changes for Win32.
3590/// - \c \b GETPHYSPAGESIZE No changes for Win32. Support for this escape might change in
3591/// future versions of Windows.
3592/// - \c \b GETPRINTINGOFFSET No changes for Win32. Support for this escape might change in
3593/// future versions of Windows.
3594/// - \c \b GETSCALINGFACTOR No changes for Win32. Support for this escape might change in
3595/// future versions of Windows.
3596/// - \c \b GETSETPAPERBINS Superseded in Win32. Applications can achieve the same
3597/// functionality by calling TPrintDC::DeviceCapabilities to find the number of
3598/// paper bins, calling ::ExtDeviceMode to find the current bin, and then setting
3599/// the dmDefaultSource member of the DEVMODE structure and passing this structure
3600/// to the CreateDC function. GETSETPAPERBINS changes the paper bin only for the
3601/// current device context. A new device context will use the system-default paper
3602/// bin until the bin is explicitly changed for that device context.
3603/// - \c \b GETSETPAPERMETRICS Obsolete in Win32. Applications can use
3604/// TPrintDC::DeviceCapabilities and ::ExtDeviceMode to achieve the same
3605/// functionality.
3606/// - \c \b GETSETPAPERORIENT Obsolete in Win32. Applications can achieve the same
3607/// functionality by setting the dmOrientation member of the DEVMODE structure and
3608/// passing this structure to the CreateDC function. This escape is not supported by
3609/// the Windows 3.1 PCL driver.
3610/// - \c \b GETSETSCREENPARAMS No changes for Win32.
3611/// - \c \b GETTECHNOLOGY No changes for Win32. Support for this escape might change in
3612/// future versions of Windows. This escape is not supported by the Windows 3.1 PCL
3613/// driver.
3614/// - \c \b GETTRACKKERNTABLE No changes for Win32.
3615/// - \c \b GETVECTORBRUSHSIZE No changes for Win32. Support for this escape might change
3616/// in future versions of Windows.
3617/// - \c \b GETVECTORPENSIZE No changes for Win32. Support for this escape might change in
3618/// future versions of Windows.
3619/// - \c \b MFCOMMENT No changes for Win32.
3620/// - \c \b NEWFRAME No changes for Win32. Applications should use ::StartPage and
3621/// ::EndPage instead of this escape. Support for this escape might change in future
3622/// versions of Windows.
3623/// - \c \b NEXTBAND No changes for Win32. Support for this escape might change in future
3624/// versions of Windows.
3625/// - \c \b PASSTHROUGH No changes for Win32.
3626/// - \c \b QUERYESCAPESUPPORT No changes for Win32.
3627/// - \c \b RESTORE_CTM No changes for Win32. This escape is specific to PostScript
3628/// printers.
3629/// - \c \b SAVE_CTM No changes for Win32. This escape is specific to PostScript printers.
3630/// - \c \b SELECTPAPERSOURCE Obsolete in Win32. Applications can achieve the same
3631/// functionality by using TPrintDC::DeviceCapabilities.
3632/// - \c \b SETABORTPROC Superseded in Win32 by ::SetAbortProc. See TPrintDC::SetAbortProc.
3633/// - \c \b SETALLJUSTVALUES No changes for Win32. Support for this escape might change in
3634/// future versions of Windows. This escape is not supported by the Windows 3.1 PCL
3635/// driver.
3636/// - \c \b SET_ARC_DIRECTION No changes for Win32. This escape is specific to PostScript
3637/// printers.
3638/// - \c \b SET_BACKGROUND_COLOR No changes for Win32. Applications should use ::SetBkColor
3639/// instead of this escape. Support for this escape might change in future versions
3640/// of Windows.
3641/// - \c \b SET_BOUNDS No changes for Win32. This escape is specific to PostScript
3642/// printers.
3643/// - \c \b SETCOLORTABLE No changes for Win32. Support for this escape might change in
3644/// future versions of Windows.
3645/// - \c \b SETCOPYCOUNT Superseded in Win32. An application should call
3646/// TPrintDC::DeviceCapabilities, specifying DC_COPIES for the capability parameter,
3647/// to find the maximum number of copies the device can make. Then the application
3648/// can set the number of copies by passing to the CreateDC function a pointer to
3649/// the DEVMODE structure.
3650/// - \c \b SETKERNTRACK No changes for Win32.
3651/// - \c \b SETLINECAP No changes for Win32. This escape is specific to PostScript
3652/// printers.
3653/// - \c \b SETLINEJOIN No changes for Win32. This escape is specific to PostScript
3654/// printers.
3655/// - \c \b SETMITERLIMIT No changes for Win32. This escape is specific to PostScript
3656/// printers.
3657/// - \c \b SET_POLY_MODE No changes for Win32. This escape is specific to PostScript
3658/// printers.
3659/// - \c \b SET_SCREEN_ANGLE No changes for Win32.
3660/// - \c \b SET_SPREAD No changes for Win32.
3661/// - \c \b STARTDOC Superseded in Win32. Applications should call ::StartDoc instead of
3662/// this escape.
3663/// - \c \b TRANSFORM_CTM No changes for Win32. This escape is specific to PostScript
3664/// printers.
3665///
3666/// Escape calls are translated and sent to the printer device driver. The inData
3667/// buffer lets you supply any data needed for the escape. You must set count to the
3668/// size (in bytes) of the inData buffer. If no input data is required, inData and
3669/// count should be set to the default value of 0. Similarly, you must supply an
3670/// outData buffer for those Escape calls that retrieve data. If the escape does not
3671/// supply output, set outData to the default value of 0.
3672//
3673inline int TPrintDC::Escape(int esc, int count, const void* inData, void* outData)
3674{
3675 return ::Escape(GetHDC(), esc, count, reinterpret_cast<LPCSTR>(inData), outData);
3676 // API type cast
3677}
3678
3679//
3680/// Establishes the user-defined proc as the printer-abort function for this
3681/// printer. This function is called by TPrintDC::AbortDoc to cancel a print job
3682/// during spooling.
3683/// SetAbortProc returns a positive (nonzero) value if successful; otherwise it
3684/// returns a negative (nonzero) value.
3685//
3687{
3688 return ::SetAbortProc(GetHDC(), proc);
3689}
3690
3691//
3692/// Starts a print job for the named document on this printer DC. If successful,
3693/// StartDoc returns a positive value, the job ID for the document. If the call
3694/// fails, the value SP_ERROR is returned. Detailed error information can be
3695/// obtained by calling GetLastError.
3696/// This function replaces the earlier ::Escape call with value STARTDOC.
3697//
3699{
3700 DocInfo.lpszDocName = const_cast<LPTSTR>(docName);
3701 DocInfo.lpszOutput = const_cast<LPTSTR>(output);
3702
3703#if (WINVER >= 0x0400) //sga added
3704 DocInfo.lpszDatatype = nullptr; //sga added
3705#endif //sga added
3706
3707 return ::StartDoc(GetHDC(), &DocInfo);
3708}
3709
3710//
3711/// Prepares this device to accept data. The system disables ::ResetDC between calls
3712/// to StartPage and EndPage, so that applications cannot change the device mode
3713/// except at page boundaries. If successful, StartPage returns a positive value;
3714/// otherwise, a negative or zero value is returned.
3715//
3717{
3718 // Only call if not banding
3719 return ::StartPage(GetHDC());
3720}
3721
3722//
3723/// Retrieves information about the banding capabilities of this device, and copies
3724/// it to the given bandInfo structure.
3725/// If successful, returns a positive value; otherwise the return value is
3726/// a system error code.
3727//
3729{
3730 return Escape(BANDINFO, sizeof(TBandInfo), nullptr, reinterpret_cast<LPTSTR>(&bandInfo));
3731}
3732
3733//
3734/// Tells this printer's device driver that the application has finished writing to
3735/// a band. The device driver sends the completed band to the Print Manager and
3736/// copies the coordinates of the next band in the rectangle specified by rect.
3737/// If successful, NextBand returns a positive value; otherwise the return value is
3738/// a system error code. Possible failure values are listed below:
3739/// - \c \b SP_ERROR General error.
3740/// - \c \b SP_APPABORT Job terminated because the application's print-canceling function
3741/// returned 0.
3742/// - \c \b SP_USERABORT User terminated the job.
3743/// - \c \b SP_OUTOFDISK Insufficient disk space for spooling.
3744/// - \c \b SP_OUTOFMEMORY Insufficient memory for spooling.
3745//
3747{
3748 return Escape(NEXTBAND, 0, nullptr, reinterpret_cast<void*>(&rect));
3749}
3750
3751//
3752/// Tells this printer's device driver that the application has finished writing to
3753/// a page. If successful, EndPage returns a positive value; otherwise a negative
3754/// or zero value is returned. Possible failure values are listed below:
3755/// - \c \b SP_ERROR General error.
3756/// - \c \b SP_APPABORT Job terminated because the application's print-canceling function
3757/// returned 0.
3758/// - \c \b SP_USERABORT User terminated the job.
3759/// - \c \b SP_OUTOFDISK Insufficient disk space for spooling.
3760/// - \c \b SP_OUTOFMEMORY Insufficient memory for spooling.
3761//
3763{
3764 // Only call if not banding
3765 RestoreObjects(); // Make sure this TDC stays in sync with HDC
3766 return ::EndPage(GetHDC());
3767}
3768
3769//
3770/// Aborts the current print job on this printer and erases everything drawn since
3771/// the last call to StartDoc. AbortDoc calls the user-defined function set with
3772/// TPrintDC::SetAbortProc to abort a print job because of error or user
3773/// intervention. TPrintDC::EndDoc should be used to terminate a successfully
3774/// completed print job.
3775/// If successful, AbortDoc returns a positive or zero value; otherwise a negative
3776/// value is returned.
3777//
3779{
3780 return ::AbortDoc(GetHDC());
3781}
3782
3783//
3784/// Ends the current print job on this printer. EndDoc should be called immediately
3785/// after a successfully completed print job. TPrintDC::AbortDoc should be used to
3786/// terminate a print job because of error or user intervention.
3787/// If successful, EndDoc returns a positive or zero value; otherwise a negative
3788/// value is returned.
3789//
3791{
3792 return ::EndDoc(GetHDC());
3793}
3794
3795
3796//
3797/// Returns true if the escape specified by escapeNum is implemented on this device;
3798/// otherwise false.
3799//
3801{
3802 return Escape(QUERYESCSUPPORT, sizeof(int), &escapeNum);
3803}
3804
3805//
3806/// Sets requestCount to the number of uncollated copies of each page that this
3807/// printer should print. The actual number of copies to be printed is copied to
3808/// actualCount. The actual count will be less than the requested count if the
3809/// latter exceeds the maximum allowed for this device. SetCopyCount returns 1 if
3810/// successful; otherwise, it returns 0.
3811//
3813{
3814 return Escape(SETCOPYCOUNT, sizeof(int), &reqestCopies, &actualCopies);
3815}
3816
3817} // OWL namespace
3818
3819
3820#endif // OWL_DC_H
#define PRECONDITION(condition)
Definition checks.h:227
TBitmap is the GDI bitmap class derived from TGdiObject.
Definition gdiobjec.h:510
The GDI Brush class is derived from TGdiObject.
Definition gdiobjec.h:180
A device context class derived from TWindowDC, TClientDC provides access to the client area owned by ...
Definition dc.h:640
Class wrapper for management of color values.
Definition color.h:245
An abstract TDC class, TCreatedDC serves as the base for DCs that are created and deleted.
Definition dc.h:724
TCursor, derived from TGdiBase, represents the GDI cursor object class.
Definition gdiobjec.h:730
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
int GetBkMode() const
Returns the background mode of this DC, either OPAQUE or TRANSPARENT.
Definition dc.h:1107
int GetTextFaceLength() const
Retrieves the length of the typeface name for the current font on this DC.
Definition dc.h:3156
HBITMAP CreateDIBSection(const BITMAPINFO &info, uint usage, void **bits, HANDLE section=0, uint32 offset=0)
Create a fast DIB under Win32.
Definition dc.h:2843
bool FrameRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Draws a border on this DC around the given rectangle, rect, using the given brush,...
Definition dc.h:1781
uint SetTextAlign(uint flags)
Sets the text-alignment flags for this DC.
Definition dc.h:3106
int ExcludeUpdateRgn(HWND wnd)
Prevents drawing within invalid areas of a window by excluding an updated region of this DC's window ...
Definition dc.h:1492
bool FillSolidRect(const TRect &r, const TColor &color)
Definition dc.h:318
int OffsetClipRgn(const TPoint &delta)
Moves the clipping region of this DC by the x- and y-offsets specified in delta.
Definition dc.h:1519
TStyle
Enumeration describing hilevel border styles.
Definition dc.h:88
@ ButtonDn
Button in down position.
Definition dc.h:96
@ Recessed
Status field style recessed.
Definition dc.h:92
@ WndRecessed
Input field & other window recessed.
Definition dc.h:98
@ WellSet
Well option set (auto grows + 1) // !CQ W4 cant do.
Definition dc.h:99
@ Grooved
Grouping groove.
Definition dc.h:94
@ WndRaised
Raised window outer+inner edge.
Definition dc.h:97
@ None
No border painted at all.
Definition dc.h:89
@ ButtonUp
Button in up position.
Definition dc.h:95
@ Raised
Status field style raised.
Definition dc.h:91
@ Embossed
Grouping raised emboss bead.
Definition dc.h:93
@ Plain
Plain plain window frame.
Definition dc.h:90
@ ButtonUp3x
Button in up position, Win 3.x style.
Definition dc.h:100
TEdge
Enumeration describing the type of edge to be drawn.
Definition dc.h:107
TColor GetBkColor() const
Returns the current background color of this DC.
Definition dc.h:1099
virtual bool TextOut(int x, int y, const tstring &str, int count=-1)
Draws up to count characters of the given null-terminated string in the current font on this DC.
Definition dc.cpp:574
int EnumFonts(const tstring &facename, OLDFONTENUMPROC callback, void *data) const
Definition dc.h:509
TPoint GetWindowOrg() const
Places in point the x- and y-coordinates of the origin of the window associated with this DC.
Definition dc.h:1365
void SetDC(HDC hdc)
Definition dc.h:139
bool Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
Draws an elliptical arc on this DC using the currently selected pen object.
Definition dc.h:2018
bool GetCharWidth(uint firstChar, uint lastChar, int *buffer)
Retrieves the widths in logical units for a consecutive sequence of characters in the current font fo...
Definition dc.h:3247
bool MoveTo(int x, int y)
Moves the current position of this DC to the given x- and y-coordinates or to the given point.
Definition dc.h:1690
int ExcludeClipRect(const TRect &rect)
Creates a new clipping region for this DC.
Definition dc.h:1478
int EnumFontFamilies(const tstring &family, FONTENUMPROC proc, void *data) const
Definition dc.h:515
bool Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
Draws and fills a chord (a region bounded by the intersection of an ellipse and a line segment) on th...
Definition dc.h:2047
bool PlayEnhMetaFile(const TEnhMetaFilePict &metaFile, const TRect *rect)
Play the enhanced metafile onto this device context.
Definition dc.h:1662
bool StrokeAndFillPath()
Closes any open figures in the current path of this DC, strokes the outline of the path using the cur...
Definition dc.h:3437
bool FloodFill(const TPoint &point, const TColor &color)
Fills an area on this DC starting at point and using the currently selected brush object.
Definition dc.h:2859
bool FlattenPath()
Transforms any curves in the currently selected path of this DC.
Definition dc.h:3385
bool InvertRgn(const TRegion &region)
Inverts the given region, on this DC.
Definition dc.h:1944
bool FrameRgn(const TRegion &region, const TBrush &brush, const TSize &brushSize)
Draws a border on this DC around the given region, region, using the given brush, brush.
Definition dc.h:1923
bool PolylineTo(const TPoint *points, int count)
Draws one or more connected line segments on this DC using the currently selected pen object.
Definition dc.h:2288
bool SetBrushOrg(const TPoint &origin, TPoint *oldOrg=nullptr)
Sets the origin of the currently selected brush of this DC with the given origin value.
Definition dc.h:1020
bool FillRgn(const TRegion &region, const TBrush &brush)
Fills the given region on this DC using the specified brush.
Definition dc.h:1932
bool PolyBezierTo(const TPoint *points, int count)
Draws one or more connected cubic Beziers splines through the points specified in the points array us...
Definition dc.h:2238
bool GetBrushOrg(TPoint &point) const
Places in point the current brush origin of this DC.
Definition dc.h:1010
bool PaintRgn(const TRegion &region)
Paints the given rectangle using the currently selected brush for this DC.
Definition dc.h:1969
TColor SetPixel(int x, int y, const TColor &color)
Sets the color of the pixel at the given location to the given color and returns the pixel's previous...
Definition dc.h:2394
bool DrawCursor(int x, int y, const TCursor &cursor)
Definition dc.h:1737
bool SetWorldTransform(XFORM &xform)
Sets a two-dimensional linear transformation, given by the xform structure, between world space and p...
Definition dc.h:1267
int GetPolyFillMode() const
Returns the current polygon-filling mode for this DC, either ALTERNATE or WINDING.
Definition dc.h:1127
TSize GetViewportExt() const
The first version retrieves this DC's current viewport's x- and y-extents (in device units) and place...
Definition dc.h:1345
TEXTMETRIC GetTextMetrics() const
Functional style overload.
Definition dc.cpp:382
bool PtVisible(const TPoint &point) const
Returns true if the given point lies within the clipping region of this DC; otherwise,...
Definition dc.h:1542
bool TransparentBlt(const TRect &dst, const TDC &srcDC, const TRect &src, const TColor &transparent)
Performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the speci...
Definition dc.h:2641
bool GetTextExtent(const tstring &str, int stringLen, TSize &size) const
Computes the extent (width and height) in logical units of the text line consisting of stringLen char...
Definition dc.h:2968
int SetDIBitsToDevice(const TRect &dst, const TPoint &src, uint startScan, uint numScans, const void *bits, const BITMAPINFO &bitsInfo, uint16 usage)
The first version sets the pixels in dst (the given destination rectangle on this DC) from the source...
Definition dc.h:2751
bool GetAspectRatioFilter(TSize &size) const
Retrieves the setting of the current aspect-ratio filter for this DC.
Definition dc.h:3271
bool FillRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Fills the given rectangle on this DC using the specified brush.
Definition dc.h:1802
bool PolyPolygon(const TPoint *points, const int *PolyCounts, int count)
Using the current pen and polygon-filling mode, draws and fills on this DC the number of closed polyg...
Definition dc.h:2190
bool BeginPath()
Opens a new path bracket for this DC and discards any previous paths from this DC.
Definition dc.h:3349
int SetSystemPaletteUse(int usage)
Changes the usage of this DC's system palette.
Definition dc.h:1091
int GetTextCharacterExtra() const
If successful, returns the current intercharacter spacing, in logical units, for this DC; otherwise,...
Definition dc.h:3117
int RemoveClipRgn()
Removes the device context's clipping region.
Definition dc.h:253
bool GetDCOrg(TPoint &point) const
Obtains the final translation origin for this device context and places the value in point.
Definition dc.h:1001
bool DPtoLP(TPoint *points, int count=1) const
Converts each of the count points in the points array from device points to logical points.
Definition dc.h:1406
int GetKerningPairs(int pairs, KERNINGPAIR *krnPair)
Retrieves kerning pairs for the current font of this DC up to the number specified in pairs and copie...
Definition dc.h:3216
bool Polyline(const TPoint *points, int count)
Using the current pen object, draws on this DC a count of line segments (there must be at least 2).
Definition dc.h:2170
TFlag
Which edge(s) to draw. ctor defaults to all 4.
Definition dc.h:67
int EnumObjects(uint objectType, GOBJENUMPROC proc, void *data) const
Enumerates the pen or brush objects available for this DC.
Definition dc.h:1035
int SetDIBits(TBitmap &bitmap, uint startScan, uint numScans, const void *bits, const BITMAPINFO &Info, uint16 usage)
The first version sets the pixels in bitmap (the given destination bitmap on this DC) from the source...
Definition dc.h:2712
bool WidenPath()
Redefines the current, closed path on this DC as the area that would be painted if the path were stro...
Definition dc.h:3406
bool SetTextJustification(int breakExtra, int breakCount)
When text strings are displayed using TDC::TextOut and TDC::ExtTextOut, sets the number of logical un...
Definition dc.h:3147
bool SetMiterLimit(float newLimit, float *oldLimit=nullptr)
Sets the limit of miter joins to newLimit and puts the previous value in oldLimit.
Definition dc.h:1255
int EnumFonts(LPCTSTR faceName, OLDFONTENUMPROC callback, void *data) const
Enumerates the fonts available on this DC for the given faceName.
Definition dc.h:3294
int EnumEnhMetaFile(const TEnhMetaFilePict &metaFile, ENHMFENUMPROC callback, void *data, const TRect *rect) const
Enumerate through the enhanced metafile records.
Definition dc.h:1653
virtual bool ExtTextOut(int x, int y, uint16 options, const TRect *r, const tstring &str, int count=-1, const int *dx=nullptr)
Draws up to count characters of the given null-terminated string in the current font on this DC.
Definition dc.cpp:603
int SetROP2(int mode)
Sets the current foreground mix mode mode of this DC to the given mode value and returns the previous...
Definition dc.h:1180
bool LPtoDP(TPoint *points, int count=1) const
Converts each of the count points in the points array from logical points to device points.
Definition dc.h:1423
bool TextRect(int x1, int y1, int x2, int y2)
Fills the given rectangle, clipping any text to the rectangle.
Definition dc.h:1878
bool DrawFocusRect(int x1, int y1, int x2, int y2)
Draws the given rectangle on this DC in the style used to indicate focus.
Definition dc.h:1854
virtual HDC GetAttributeHDC() const
Returns the attributes of the DC object.
Definition dc.cpp:81
uint SetBoundsRect(TRect &bounds, uint flags)
Controls the accumulation of bounding rectangle information for this DC.
Definition dc.h:1595
tstring GetTextFace() const
Definition dc.cpp:855
virtual TColor SetBkColor(const TColor &color)
Sets the current background color of this DC to the given color value or the nearest available.
Definition dc.cpp:405
int IntersectClipRect(const TRect &rect)
Creates a new clipping region for this DC's window by forming the intersection of the current region ...
Definition dc.h:1506
void UpdateColors()
Updates the client area of this DC by matching the current colors in the client area to the system pa...
Definition dc.h:1063
TSize GetWindowExt() const
Retrieves this DC's window current x- and y-extents (in device units).
Definition dc.h:1393
uint32 GetGlyphOutline(uint chr, uint format, GLYPHMETRICS &gm, uint32 buffSize, void *buffer, const MAT2 &mat2)
Retrieves TrueType metric and other data for the given character, chr, on this DC and places it in gm...
Definition dc.h:3199
bool Rectangle(int x1, int y1, int x2, int y2)
Draws and fills a rectangle of the given size on this DC with the current pen and brush objects.
Definition dc.h:2298
virtual bool TabbedTextOut(const TPoint &p, const tstring &str, int count, int numPositions, const int *positions, int tabOrigin, TSize &size)
Draws up to count characters of the given null-terminated string in the current font on this DC.
Definition dc.cpp:634
bool Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
Using the currently selected pen and brush objects, draws and fills a pie-shaped wedge by drawing an ...
Definition dc.h:2075
TPoint GetViewportOrg() const
The first version sets in the point argument the x- and y-extents (in device-units) of this DC's view...
Definition dc.h:1314
int SelectClipRgn(const TRegion &region)
Selects the given region as the current clipping region for this DC.
Definition dc.h:1533
bool RectVisible(const TRect &rect) const
Returns true if any part of the given rectangle, rect, lies within the clipping region of this DC; ot...
Definition dc.h:1551
uint GetOutlineTextMetrics(uint data, OUTLINETEXTMETRIC &otm)
Retrieves metric information for TrueType fonts on this DC and copies it to the given array of OUTLIN...
Definition dc.h:3234
int GetClipRgn(TRegion &region) const
Retrieves this DC's current clip-region and, if successful, places a copy of it in the region argumen...
Definition dc.h:1608
bool LineTo(int x, int y)
Draws a line on this DC using the current pen object.
Definition dc.h:2148
void RestoreObjects()
Restores all the original GDI objects to this DC.
Definition dc.cpp:298
bool FillPath()
Closes any open figures in the current path of this DC and fills the path's interior using the curren...
Definition dc.h:3417
TColor GetPixel(int x, int y) const
Returns the color of the pixel at the given location.
Definition dc.h:2377
int GetStretchBltMode() const
Returns the current stretching mode for this DC: BLACKONWHITE, COLORONCOLOR, or WHITEONBLACK.
Definition dc.h:1192
bool GetTabbedTextExtent(const tstring &str, int stringLen, int numPositions, const int *positions, TSize &size) const
Computes the extent (width and height) in logical units of the text line consisting of stringLen char...
Definition dc.h:3007
uint GetSystemPaletteEntries(int start, int num, PALETTEENTRY *entries) const
Retrieves a range of up to num palette entries, starting at start, from the system palette to the ent...
Definition dc.h:1073
int GetDIBits(const TBitmap &bitmap, uint startScan, uint numScans, void *bits, const BITMAPINFO &info, uint16 usage)
The first version retrieves some or all of the bits from the given bitmap on this DC and copies them ...
Definition dc.h:2668
bool PolyDraw(const TPoint *points, uint8 *types, int count)
Using the currently selected pen object, draws one or more possibly disjoint sets of line segments or...
Definition dc.h:2274
int SetPolyFillMode(int mode)
Description Sets the polygon-filling mode for this DC to the given mode value, either ALTERNATE or WI...
Definition dc.h:1137
bool ModifyWorldTransform(XFORM &xform, uint32 mode)
Changes the current world transformation for this DC using the given xform and mode arguments.
Definition dc.h:1289
HRGN PathToRegion()
If successful, returns a region created from the closed path in this DC; otherwise,...
Definition dc.h:3466
bool BitBlt(int dstX, int dstY, int w, int h, const TDC &srcDC, int srcX, int srcY, uint32 rop=SRCCOPY)
Performs a bit-block transfer from srcDc (the given source DC) to this DC (the destination DC).
Definition dc.h:2421
bool PlgBlt(const TPoint *points, const TDC &srcDC, const TRect &src, const TBitmap &maskBm, const TPoint &maskPos)
Performs a bit-block transfer from the given source DC to this DC.
Definition dc.h:2615
bool StrokePath()
Renders the current, closed path on this DC and uses the DC's current pen.
Definition dc.h:3426
bool PolyBezier(const TPoint *points, int count)
Draws one or more connected cubic Bezier splines through the points specified in the points array usi...
Definition dc.h:2221
bool DrawIcon(int x, int y, const TIcon &icon)
Draws the given icon on this DC.
Definition dc.h:1720
TColor GetNearestColor(const TColor &color) const
Returns the color nearest to the given Color argument for the current palette of this DC.
Definition dc.h:1044
int EnumMetaFile(const TMetaFilePict &metaFile, MFENUMPROC callback, void *data) const
Enumerates the GDI calls within the given metaFile.
Definition dc.h:1623
bool Ellipse(int x1, int y1, int x2, int y2)
Draws and fills an ellipse on this DC using the currently selected pen and brush objects.
Definition dc.h:2101
uint32 SetMapperFlags(uint32 flag)
Alters the algorithm used by the font mapper when mapping logical fonts to physical fonts on this DC.
Definition dc.h:3261
bool SelectClipPath(int mode)
Selects the current path on this DC as a clipping region, combining any existing clipping region usin...
Definition dc.h:3457
TColor GetTextColor() const
Returns the current text color of this DC.
Definition dc.h:1213
bool ExtFloodFill(const TPoint &point, const TColor &color, uint16 fillType)
Fills an area on this DC starting at point and using the currently selected brush object.
Definition dc.h:2880
void PlayEnhMetaFileRecord(HANDLETABLE &handletable, ENHMETARECORD &metaRecord, uint count)
Play one record from the enhanced metafile onto this DC.
Definition dc.h:1670
uint GetTextAlign() const
If successful, returns the current text-alignment flags for this DC; otherwise, returns the value GDI...
Definition dc.h:3094
int EnumFontFamilies(LPCTSTR family, FONTENUMPROC proc, void *data) const
Enumerates the fonts available to this DC in the font family specified by family.
Definition dc.h:3321
bool StretchBlt(int dstX, int dstY, int dstW, int dstH, const TDC &srcDC, int srcX, int srcY, int srcW, int srcH, uint32 rop=SRCCOPY)
Copies a bitmap from the source DC to a destination rectangle on this DC specified either by upper le...
Definition dc.h:2502
int SelectClipRgn(HRGN r=0)
Selects the given region as the current clipping region for the device context.
Definition dc.h:247
bool PlayMetaFile(const TMetaFilePict &metaFile)
Plays the contents of the given metaFile on this DC.
Definition dc.h:1634
int RealizePalette()
Maps to the system palette the logical palette entries selected into this DC.
Definition dc.h:1054
int SetBkMode(int mode)
Sets the background mode to the given mode argument, which can be either OPAQUE or TRANSPARENT.
Definition dc.h:1116
bool IsDC() const
Validation routine - used mainly for diagnostic purposes.
Definition dc.h:990
uint32 GetFontData(uint32 table, uint32 offset, void *buffer, long data)
Retrieves font-metric information from a scalable TrueType font file (specified by table and starting...
Definition dc.h:3333
int StretchDIBits(const TRect &dst, const TRect &src, const void *bits, const BITMAPINFO &bitsInfo, uint16 usage, uint32 rop=SRCCOPY)
Copies the color data from src, the source rectangle of pixels in the given DIB (device-independent b...
Definition dc.h:2801
bool InvertRect(int x1, int y1, int x2, int y2)
Inverts the given rectangle, rect, on this DC.
Definition dc.h:1827
bool GetCharABCWidths(uint firstChar, uint lastChar, ABC *abc)
Retrieves the widths of consecutive characters in the range firstChar to lastChar from the current Tr...
Definition dc.h:3305
bool ScrollDC(int x, int y, const TRect &scroll, const TRect &clip, TRegion &updateRgn, TRect &updateRect)
Scrolls a rectangle of bits horizontally by x (or delta.x in the second version) device-units,...
Definition dc.h:2469
bool PatBlt(int x, int y, int w, int h, uint32 rop=PATCOPY)
Definition dc.h:2448
bool GetCurrentPosition(TPoint &point) const
Reports in point the logical coordinates of this DC's current position.
Definition dc.h:1680
bool PolyPolyline(const TPoint *points, const int *PolyCounts, int count)
Using the currently selected pen object, draws on this DC the number of polylines (connected line seg...
Definition dc.h:2204
HANDLE Handle
< make this function available to derivatives
Definition gdibase.h:81
bool RoundRect(int x1, int y1, int x2, int y2, int x3, int y3)
Draws and fills a rounded rectangle of the given size on this DC with the current pen and brush objec...
Definition dc.h:2338
TRect GetClipBox() const
Places the current clip box size of this DC in rect.
Definition dc.h:1462
int SetStretchBltMode(int mode)
Sets the stretching mode of this DC to the given mode value and returns the previous mode.
Definition dc.h:1202
uint GetSystemPaletteUse() const
Determines whether this DC has access to the full system palette.
Definition dc.h:1082
bool MaskBlt(const TRect &dst, const TDC &srcDC, const TPoint &src, const TBitmap &maskBm, const TPoint &maskPos, uint32 rop=SRCCOPY)
Copies a bitmap from the given source DC to this DC.
Definition dc.h:2576
bool EndPath()
Closes the path bracket and selects the path it defines into this DC.
Definition dc.h:3375
bool CloseFigure()
Closes an open figure in this DC's open path bracket by drawing a line from the current position to t...
Definition dc.h:3366
HDC GetHDC() const
Return the handle of the device context.
Definition dc.h:981
int SetTextCharacterExtra(int extra)
If successful, sets the current intercharacter spacing to extra, in logical units,...
Definition dc.h:3128
void PlayMetaFileRecord(HANDLETABLE &handletable, METARECORD &metaRecord, int count)
Plays the metafile record given in metaRecord to this DC by executing the GDI function call contained...
Definition dc.h:1644
bool AngleArc(int x, int y, uint32 radius, float startAngle, float sweepAngle)
Draws a line segment and an arc on this DC using the currently selected pen object.
Definition dc.h:1986
int GetMapMode() const
If successful, returns the current window mapping mode of this DC; otherwise, returns 0.
Definition dc.h:1245
bool Polygon(const TPoint *points, int count)
Definition dc.h:2176
int GetROP2() const
Returns the current drawing (raster operation) mode of this DC.
Definition dc.h:1147
bool GetBoundsRect(TRect &bounds, uint16 flags) const
Reports in bounds the current accumulated bounding rectangle of this DC or of the Windows manager,...
Definition dc.h:1572
A DC class that provides access to the desktop window's client area which is the window behind all ot...
Definition dc.h:625
A DC class that provides access to DIBs using DIBSection, WinG, or the DIB.DRV driver.
Definition dc.h:817
Pseudo-GDI object Device Independent Bitmap (DIB) class.
Definition gdiobjec.h:795
TEnhMetaFilePict is a class that encapsulates the enhanced metafile.
Definition metafile.h:148
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
Root and abstract class for Windows object wrappers.
Definition gdibase.h:79
Derived from TCreatedDC, TIC is a device context (DC) class that provides a constructor for creating ...
Definition dc.h:754
TIcon, derived from TGdiObject, represents the GDI object icon class.
Definition gdiobjec.h:670
A device context (DC) class derived from TCreatedDC, TMemoryDC provides access to a memory DC.
Definition dc.h:784
A DC class that provides access to a DC with a metafile selected into it for drawing on (into).
Definition dc.h:694
HMETAFILE Close()
Closes the metafile device context and returns a handle that identifies a Windows-format metafile.
Definition dc.h:3474
bool Comment(uint bytes, const void *data)
Inserts a comment record into the enhanced metafile.
Definition dc.h:3512
HENHMETAFILE CloseEnh()
Closes the enhanced-metafile device context and returns a handle that identifies an enhanced-format m...
Definition dc.h:3497
bool IsEnhanced() const
Returns true if the device context contains an enhanced metafile.
Definition dc.h:3489
TMetaFilePict is a support class used with TMetaFileDC to simplify metafile operations,...
Definition metafile.h:80
A DC class that provides access to the non-client area owned by a window.
Definition dc.h:654
A DC class that wraps begin and end paint calls for use in an WM_PAINT response function.
Definition dc.h:671
PAINTSTRUCT Ps
The paint structure associated with this TPaintDC object.
Definition dc.h:677
HWND Wnd
The associated window handle.
Definition dc.h:681
TPalette is the GDI Palette class derived from TGdiObject.
Definition gdiobjec.h:413
TPen is derived from TGdiObject.
Definition gdiobjec.h:138
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
A DC class that provides access to a printer.
Definition dc.h:874
int AbortDoc()
Aborts the current print job on this printer and erases everything drawn since the last call to Start...
Definition dc.h:3778
uint QueryEscSupport(int escapeNum)
Returns true if the escape specified by escapeNum is implemented on this device; otherwise false.
Definition dc.h:3800
void SetDocInfo(const DOCINFO &docinfo)
Sets the DOCINFO structure.
Definition dc.h:3536
int StartPage()
Prepares this device to accept data.
Definition dc.h:3716
int Escape(int escape, int count=0, const void *inData=nullptr, void *outData=nullptr)
Allows applications to access the capabilities of a particular device that are not directly available...
Definition dc.h:3673
int StartDoc(LPCTSTR docName, LPCTSTR output=nullptr)
Starts a print job for the named document on this printer DC.
Definition dc.h:3698
DOCINFO & GetDocInfo()
Return the DOCINFO structure.
Definition dc.h:3528
int SetAbortProc(ABORTPROC proc)
Establishes the user-defined proc as the printer-abort function for this printer.
Definition dc.h:3686
int StartDoc(const tstring &docName, const tstring &output=tstring{})
Definition dc.h:892
int EndDoc()
Ends the current print job on this printer.
Definition dc.h:3790
int SetCopyCount(int reqestCount, int &actualCount)
Sets requestCount to the number of uncollated copies of each page that this printer should print.
Definition dc.h:3812
int BandInfo(TBandInfo &bandInfo)
Retrieves information about the banding capabilities of this device, and copies it to the given bandI...
Definition dc.h:3728
int NextBand(TRect &rect)
Tells this printer's device driver that the application has finished writing to a band.
Definition dc.h:3746
int EndPage()
Tells this printer's device driver that the application has finished writing to a page.
Definition dc.h:3762
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
TRegion, derived from TGdiObject, represents GDI abstract shapes or regions.
Definition gdiobjec.h:581
Derived from TWindowDC, TScreenDC is a DC class that provides direct access to the screen bitmap.
Definition dc.h:610
The tagSIZE struct is defined as.
Definition geometry.h:234
Derived from TDC, TWindowDC is a device context (DC) class that provides access to the entire area ow...
Definition dc.h:588
HWND Wnd
Holds a handle to the window owned by this device context.
Definition dc.h:595
Definition of base most abstract GDI object class, and associated exception class.
Definition of abstract GDI object class and derived classes.
Classes for window system geometry.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
@ NoAutoDelete
Definition gdibase.h:70
Definition of TMetafilePict, a MetaFile wrapper class.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned char uint8
Definition number.h:32
unsigned long uint32
Definition number.h:34
int esc(const tchar **)
Definition regexp.cpp:549
unsigned short uint16
Definition number.h:33
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338
bool SetViewportExt(HDC hdc, int w, int h)
Definition preview.cpp:22
bool SetWindowExt(HDC hdc, int w, int h)
Definition preview.cpp:20
bool SetWindowOrg(HDC hdc, int w, int h)
Definition preview.cpp:21
bool SetViewportOrg(HDC hdc, int x, int y)
Definition preview.cpp:23
Equivalent to BANDINFOSTRUCT.
Definition dc.h:863
bool HasText
Definition dc.h:865
TRect GraphicsRect
Definition dc.h:866
bool HasGraphics
Definition dc.h:864