-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCGdiDc.h
2008 lines (1705 loc) · 51 KB
/
CGdiDc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
///////////////////////////////////////////////////////////////////////////////
// CDC - The device context class
template <bool t_bManaged>
class CDCT
{
public:
// Data members
HDC m_hDC;
// Constructor/destructor/operators
CDCT(HDC hDC = NULL) : m_hDC(hDC)
{
}
~CDCT()
{
if (t_bManaged && (m_hDC != NULL))
::DeleteDC(Detach());
}
CDCT<t_bManaged>& operator =(HDC hDC)
{
Attach(hDC);
return *this;
}
void Attach(HDC hDC)
{
if (t_bManaged && (m_hDC != NULL) && (m_hDC != hDC))
::DeleteDC(m_hDC);
m_hDC = hDC;
}
HDC Detach()
{
HDC hDC = m_hDC;
m_hDC = NULL;
return hDC;
}
operator HDC() const { return m_hDC; }
bool IsNull() const { return (m_hDC == NULL); }
// Operations
HWND WindowFromDC() const
{
SASSERT(m_hDC != NULL);
return ::WindowFromDC(m_hDC);
}
HPEN GetCurrentPen() const
{
SASSERT(m_hDC != NULL);
return (HPEN)::GetCurrentObject(m_hDC, OBJ_PEN);
}
HBRUSH GetCurrentBrush() const
{
SASSERT(m_hDC != NULL);
return (HBRUSH)::GetCurrentObject(m_hDC, OBJ_BRUSH);
}
HPALETTE GetCurrentPalette() const
{
SASSERT(m_hDC != NULL);
return ((HPALETTE)::GetCurrentObject(m_hDC, OBJ_PAL));
}
HFONT GetCurrentFont() const
{
SASSERT(m_hDC != NULL);
return ((HFONT)::GetCurrentObject(m_hDC, OBJ_FONT));
}
HBITMAP GetCurrentBitmap() const
{
SASSERT(m_hDC != NULL);
return ((HBITMAP)::GetCurrentObject(m_hDC, OBJ_BITMAP));
}
HDC CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput, const DEVMODE* lpInitData)
{
SASSERT(m_hDC == NULL);
m_hDC = ::CreateDC(lpszDriverName, lpszDeviceName, lpszOutput, lpInitData);
return m_hDC;
}
HDC CreateCompatibleDC(HDC hDC = NULL)
{
SASSERT(m_hDC == NULL);
m_hDC = ::CreateCompatibleDC(hDC);
return m_hDC;
}
BOOL DeleteDC()
{
if (m_hDC == NULL)
return FALSE;
BOOL bRet = ::DeleteDC(m_hDC);
if (bRet)
m_hDC = NULL;
return bRet;
}
// Device-Context Functions
int SaveDC()
{
SASSERT(m_hDC != NULL);
return ::SaveDC(m_hDC);
}
BOOL RestoreDC(int nSavedDC)
{
SASSERT(m_hDC != NULL);
return ::RestoreDC(m_hDC, nSavedDC);
}
int GetDeviceCaps(int nIndex) const
{
SASSERT(m_hDC != NULL);
return ::GetDeviceCaps(m_hDC, nIndex);
}
UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags)
{
SASSERT(m_hDC != NULL);
return ::SetBoundsRect(m_hDC, lpRectBounds, flags);
}
UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags) const
{
SASSERT(m_hDC != NULL);
return ::GetBoundsRect(m_hDC, lpRectBounds, flags);
}
BOOL ResetDC(const DEVMODE* lpDevMode)
{
SASSERT(m_hDC != NULL);
return ::ResetDC(m_hDC, lpDevMode) != NULL;
}
// Drawing-Tool Functions
BOOL GetBrushOrg(LPPOINT lpPoint) const
{
SASSERT(m_hDC != NULL);
return ::GetBrushOrgEx(m_hDC, lpPoint);
}
BOOL SetBrushOrg(int x, int y, LPPOINT lpPoint = NULL)
{
SASSERT(m_hDC != NULL);
return ::SetBrushOrgEx(m_hDC, x, y, lpPoint);
}
BOOL SetBrushOrg(POINT point, LPPOINT lpPointRet = NULL)
{
SASSERT(m_hDC != NULL);
return ::SetBrushOrgEx(m_hDC, point.x, point.y, lpPointRet);
}
int EnumObjects(int nObjectType, int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData)
{
SASSERT(m_hDC != NULL);
#ifdef STRICT
return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, lpData);
#else
return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, (LPVOID)lpData);
#endif
}
// Type-safe selection helpers
HPEN SelectPen(HPEN hPen)
{
SASSERT(m_hDC != NULL);
SASSERT((hPen == NULL) || (::GetObjectType(hPen) == OBJ_PEN) || (::GetObjectType(hPen) == OBJ_EXTPEN));
return (HPEN)::SelectObject(m_hDC, hPen);
}
HBRUSH SelectBrush(HBRUSH hBrush)
{
SASSERT(m_hDC != NULL);
SASSERT((hBrush == NULL) || (::GetObjectType(hBrush) == OBJ_BRUSH));
return (HBRUSH)::SelectObject(m_hDC, hBrush);
}
HFONT SelectFont(HFONT m_hTitleFont)
{
SASSERT(m_hDC != NULL);
SASSERT((m_hTitleFont == NULL) || (::GetObjectType(m_hTitleFont) == OBJ_FONT));
return (HFONT)::SelectObject(m_hDC, m_hTitleFont);
}
HBITMAP SelectBitmap(HBITMAP hBitmap)
{
SASSERT(m_hDC != NULL);
SASSERT((hBitmap == NULL) || (::GetObjectType(hBitmap) == OBJ_BITMAP));
return (HBITMAP)::SelectObject(m_hDC, hBitmap);
}
int SelectRgn(HRGN hRgn) // special return for regions
{
SASSERT(m_hDC != NULL);
SASSERT((hRgn == NULL) || (::GetObjectType(hRgn) == OBJ_REGION));
return PtrToInt(::SelectObject(m_hDC, hRgn));
}
// Type-safe selection helpers for stock objects
HPEN SelectStockPen(int nPen)
{
SASSERT(m_hDC != NULL);
SASSERT((nPen == WHITE_PEN) || (nPen == BLACK_PEN) || (nPen == NULL_PEN) || (nPen == DC_PEN));
return SelectPen((HPEN)::GetStockObject(nPen));
}
HBRUSH SelectStockBrush(int nBrush)
{
SASSERT(((nBrush >= WHITE_BRUSH) && (nBrush <= HOLLOW_BRUSH)) || (nBrush == DC_BRUSH));
return SelectBrush((HBRUSH)::GetStockObject(nBrush));
}
HFONT SelectStockFont(int nFont)
{
SASSERT(((nFont >= OEM_FIXED_FONT) && (nFont <= SYSTEM_FIXED_FONT)) || (nFont == DEFAULT_GUI_FONT));
return SelectFont((HFONT)::GetStockObject(nFont));
}
HPALETTE SelectStockPalette(int nPalette, BOOL bForceBackground)
{
SASSERT(nPalette == DEFAULT_PALETTE); // the only one supported
return SelectPalette((HPALETTE)::GetStockObject(nPalette), bForceBackground);
}
// Color and Color Palette Functions
COLORREF GetNearestColor(COLORREF crColor) const
{
SASSERT(m_hDC != NULL);
return ::GetNearestColor(m_hDC, crColor);
}
HPALETTE SelectPalette(HPALETTE hPalette, BOOL bForceBackground)
{
SASSERT(m_hDC != NULL);
return ::SelectPalette(m_hDC, hPalette, bForceBackground);
}
UINT RealizePalette()
{
SASSERT(m_hDC != NULL);
return ::RealizePalette(m_hDC);
}
void UpdateColors()
{
SASSERT(m_hDC != NULL);
::UpdateColors(m_hDC);
}
// Drawing-Attribute Functions
COLORREF GetBkColor() const
{
SASSERT(m_hDC != NULL);
return ::GetBkColor(m_hDC);
}
int GetBkMode() const
{
SASSERT(m_hDC != NULL);
return ::GetBkMode(m_hDC);
}
int GetPolyFillMode() const
{
SASSERT(m_hDC != NULL);
return ::GetPolyFillMode(m_hDC);
}
int GetROP2() const
{
SASSERT(m_hDC != NULL);
return ::GetROP2(m_hDC);
}
int GetStretchBltMode() const
{
SASSERT(m_hDC != NULL);
return ::GetStretchBltMode(m_hDC);
}
COLORREF GetTextColor() const
{
SASSERT(m_hDC != NULL);
return ::GetTextColor(m_hDC);
}
COLORREF SetBkColor(COLORREF crColor)
{
SASSERT(m_hDC != NULL);
return ::SetBkColor(m_hDC, crColor);
}
int SetBkMode(int nBkMode)
{
SASSERT(m_hDC != NULL);
return ::SetBkMode(m_hDC, nBkMode);
}
int SetPolyFillMode(int nPolyFillMode)
{
SASSERT(m_hDC != NULL);
return ::SetPolyFillMode(m_hDC, nPolyFillMode);
}
int SetROP2(int nDrawMode)
{
SASSERT(m_hDC != NULL);
return ::SetROP2(m_hDC, nDrawMode);
}
int SetStretchBltMode(int nStretchMode)
{
SASSERT(m_hDC != NULL);
return ::SetStretchBltMode(m_hDC, nStretchMode);
}
COLORREF SetTextColor(COLORREF crColor)
{
SASSERT(m_hDC != NULL);
return ::SetTextColor(m_hDC, crColor);
}
BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust) const
{
SASSERT(m_hDC != NULL);
return ::GetColorAdjustment(m_hDC, lpColorAdjust);
}
BOOL SetColorAdjustment(const COLORADJUSTMENT* lpColorAdjust)
{
SASSERT(m_hDC != NULL);
return ::SetColorAdjustment(m_hDC, lpColorAdjust);
}
// Mapping Functions
int GetMapMode() const
{
SASSERT(m_hDC != NULL);
return ::GetMapMode(m_hDC);
}
BOOL GetViewportOrg(LPPOINT lpPoint) const
{
SASSERT(m_hDC != NULL);
return ::GetViewportOrgEx(m_hDC, lpPoint);
}
int SetMapMode(int nMapMode)
{
SASSERT(m_hDC != NULL);
return ::SetMapMode(m_hDC, nMapMode);
}
// Viewport Origin
BOOL SetViewportOrg(int x, int y, LPPOINT lpPoint = NULL)
{
SASSERT(m_hDC != NULL);
return ::SetViewportOrgEx(m_hDC, x, y, lpPoint);
}
BOOL SetViewportOrg(POINT point, LPPOINT lpPointRet = NULL)
{
SASSERT(m_hDC != NULL);
return SetViewportOrg(point.x, point.y, lpPointRet);
}
BOOL OffsetViewportOrg(int nWidth, int nHeight, LPPOINT lpPoint = NULL)
{
SASSERT(m_hDC != NULL);
return ::OffsetViewportOrgEx(m_hDC, nWidth, nHeight, lpPoint);
}
// Viewport Extent
BOOL GetViewportExt(LPSIZE lpSize) const
{
SASSERT(m_hDC != NULL);
return ::GetViewportExtEx(m_hDC, lpSize);
}
BOOL SetViewportExt(int x, int y, LPSIZE lpSize = NULL)
{
SASSERT(m_hDC != NULL);
return ::SetViewportExtEx(m_hDC, x, y, lpSize);
}
BOOL SetViewportExt(SIZE size, LPSIZE lpSizeRet = NULL)
{
SASSERT(m_hDC != NULL);
return SetViewportExt(size.cx, size.cy, lpSizeRet);
}
BOOL ScaleViewportExt(int xNum, int xDenom, int yNum, int yDenom, LPSIZE lpSize = NULL)
{
SASSERT(m_hDC != NULL);
return ::ScaleViewportExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize);
}
// Window Origin
BOOL GetWindowOrg(LPPOINT lpPoint) const
{
SASSERT(m_hDC != NULL);
return ::GetWindowOrgEx(m_hDC, lpPoint);
}
BOOL SetWindowOrg(int x, int y, LPPOINT lpPoint = NULL)
{
SASSERT(m_hDC != NULL);
return ::SetWindowOrgEx(m_hDC, x, y, lpPoint);
}
BOOL SetWindowOrg(POINT point, LPPOINT lpPointRet = NULL)
{
SASSERT(m_hDC != NULL);
return SetWindowOrg(point.x, point.y, lpPointRet);
}
BOOL OffsetWindowOrg(int nWidth, int nHeight, LPPOINT lpPoint = NULL)
{
SASSERT(m_hDC != NULL);
return ::OffsetWindowOrgEx(m_hDC, nWidth, nHeight, lpPoint);
}
// Window extent
BOOL GetWindowExt(LPSIZE lpSize) const
{
SASSERT(m_hDC != NULL);
return ::GetWindowExtEx(m_hDC, lpSize);
}
BOOL SetWindowExt(int x, int y, LPSIZE lpSize = NULL)
{
SASSERT(m_hDC != NULL);
return ::SetWindowExtEx(m_hDC, x, y, lpSize);
}
BOOL SetWindowExt(SIZE size, LPSIZE lpSizeRet = NULL)
{
SASSERT(m_hDC != NULL);
return SetWindowExt(size.cx, size.cy, lpSizeRet);
}
BOOL ScaleWindowExt(int xNum, int xDenom, int yNum, int yDenom, LPSIZE lpSize = NULL)
{
SASSERT(m_hDC != NULL);
return ::ScaleWindowExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize);
}
// Coordinate Functions
BOOL DPtoLP(LPPOINT lpPoints, int nCount = 1) const
{
SASSERT(m_hDC != NULL);
return ::DPtoLP(m_hDC, lpPoints, nCount);
}
BOOL DPtoLP(LPRECT lpRect) const
{
SASSERT(m_hDC != NULL);
return ::DPtoLP(m_hDC, (LPPOINT)lpRect, 2);
}
BOOL DPtoLP(LPSIZE lpSize) const
{
SIZE sizeWinExt = { 0, 0 };
if (!GetWindowExt(&sizeWinExt))
return FALSE;
SIZE sizeVpExt = { 0, 0 };
if (!GetViewportExt(&sizeVpExt))
return FALSE;
lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeWinExt.cx), abs(sizeVpExt.cx));
lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeWinExt.cy), abs(sizeVpExt.cy));
return TRUE;
}
BOOL LPtoDP(LPPOINT lpPoints, int nCount = 1) const
{
SASSERT(m_hDC != NULL);
return ::LPtoDP(m_hDC, lpPoints, nCount);
}
BOOL LPtoDP(LPRECT lpRect) const
{
SASSERT(m_hDC != NULL);
return ::LPtoDP(m_hDC, (LPPOINT)lpRect, 2);
}
BOOL LPtoDP(LPSIZE lpSize) const
{
SIZE sizeWinExt = { 0, 0 };
if (!GetWindowExt(&sizeWinExt))
return FALSE;
SIZE sizeVpExt = { 0, 0 };
if (!GetViewportExt(&sizeVpExt))
return FALSE;
lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeVpExt.cx), abs(sizeWinExt.cx));
lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeVpExt.cy), abs(sizeWinExt.cy));
return TRUE;
}
// Special Coordinate Functions (useful for dealing with metafiles and OLE)
#define HIMETRIC_INCH 2540 // HIMETRIC units per inch
void DPtoHIMETRIC(LPSIZE lpSize)
{
SASSERT(m_hDC != NULL);
int nMapMode = GetMapMode();
if ((nMapMode < MM_ISOTROPIC) && (nMapMode != MM_TEXT))
{
// when using a constrained map mode, map against physical inch
SetMapMode(MM_HIMETRIC);
DPtoLP(lpSize);
SetMapMode(nMapMode);
}
else
{
// map against logical inch for non-constrained mapping modes
int cxPerInch = GetDeviceCaps(LOGPIXELSX);
int cyPerInch = GetDeviceCaps(LOGPIXELSY);
SASSERT((cxPerInch != 0) && (cyPerInch != 0));
lpSize->cx = ::MulDiv(lpSize->cx, HIMETRIC_INCH, cxPerInch);
lpSize->cy = ::MulDiv(lpSize->cy, HIMETRIC_INCH, cyPerInch);
}
}
void HIMETRICtoDP(LPSIZE lpSize)
{
SASSERT(m_hDC != NULL);
int nMapMode = GetMapMode();
if ((nMapMode < MM_ISOTROPIC) && (nMapMode != MM_TEXT))
{
// when using a constrained map mode, map against physical inch
SetMapMode(MM_HIMETRIC);
LPtoDP(lpSize);
SetMapMode(nMapMode);
}
else
{
// map against logical inch for non-constrained mapping modes
int cxPerInch = GetDeviceCaps(LOGPIXELSX);
int cyPerInch = GetDeviceCaps(LOGPIXELSY);
SASSERT((cxPerInch != 0) && (cyPerInch != 0));
lpSize->cx = ::MulDiv(lpSize->cx, cxPerInch, HIMETRIC_INCH);
lpSize->cy = ::MulDiv(lpSize->cy, cyPerInch, HIMETRIC_INCH);
}
}
void LPtoHIMETRIC(LPSIZE lpSize)
{
LPtoDP(lpSize);
DPtoHIMETRIC(lpSize);
}
void HIMETRICtoLP(LPSIZE lpSize)
{
HIMETRICtoDP(lpSize);
DPtoLP(lpSize);
}
// Region Functions
BOOL FillRgn(HRGN hRgn, HBRUSH hBrush)
{
SASSERT(m_hDC != NULL);
return ::FillRgn(m_hDC, hRgn, hBrush);
}
BOOL FrameRgn(HRGN hRgn, HBRUSH hBrush, int nWidth, int nHeight)
{
SASSERT(m_hDC != NULL);
return ::FrameRgn(m_hDC, hRgn, hBrush, nWidth, nHeight);
}
BOOL InvertRgn(HRGN hRgn)
{
SASSERT(m_hDC != NULL);
return ::InvertRgn(m_hDC, hRgn);
}
BOOL PaintRgn(HRGN hRgn)
{
SASSERT(m_hDC != NULL);
return ::PaintRgn(m_hDC, hRgn);
}
// Clipping Functions
int GetClipBox(LPRECT lpRect) const
{
SASSERT(m_hDC != NULL);
return ::GetClipBox(m_hDC, lpRect);
}
int GetClipRgn(CRgn& region) const
{
SASSERT(m_hDC != NULL);
if (region.IsNull())
region.CreateRectRgn(0, 0, 0, 0);
int nRet = ::GetClipRgn(m_hDC, region);
if (nRet != 1)
region.DeleteObject();
return nRet;
}
BOOL PtVisible(int x, int y) const
{
SASSERT(m_hDC != NULL);
return ::PtVisible(m_hDC, x, y);
}
BOOL PtVisible(POINT point) const
{
SASSERT(m_hDC != NULL);
return ::PtVisible(m_hDC, point.x, point.y);
}
BOOL RectVisible(LPCRECT lpRect) const
{
SASSERT(m_hDC != NULL);
return ::RectVisible(m_hDC, lpRect);
}
int SelectClipRgn(HRGN hRgn)
{
SASSERT(m_hDC != NULL);
return ::SelectClipRgn(m_hDC, (HRGN)hRgn);
}
int ExcludeClipRect(int x1, int y1, int x2, int y2)
{
SASSERT(m_hDC != NULL);
return ::ExcludeClipRect(m_hDC, x1, y1, x2, y2);
}
int ExcludeClipRect(LPCRECT lpRect)
{
SASSERT(m_hDC != NULL);
return ::ExcludeClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
}
int ExcludeUpdateRgn(HWND hWnd)
{
SASSERT(m_hDC != NULL);
return ::ExcludeUpdateRgn(m_hDC, hWnd);
}
int IntersectClipRect(int x1, int y1, int x2, int y2)
{
SASSERT(m_hDC != NULL);
return ::IntersectClipRect(m_hDC, x1, y1, x2, y2);
}
int IntersectClipRect(LPCRECT lpRect)
{
SASSERT(m_hDC != NULL);
return ::IntersectClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
}
int OffsetClipRgn(int x, int y)
{
SASSERT(m_hDC != NULL);
return ::OffsetClipRgn(m_hDC, x, y);
}
int OffsetClipRgn(SIZE size)
{
SASSERT(m_hDC != NULL);
return ::OffsetClipRgn(m_hDC, size.cx, size.cy);
}
int SelectClipRgn(HRGN hRgn, int nMode)
{
SASSERT(m_hDC != NULL);
return ::ExtSelectClipRgn(m_hDC, hRgn, nMode);
}
// Line-Output Functions
BOOL GetCurrentPosition(LPPOINT lpPoint) const
{
SASSERT(m_hDC != NULL);
return ::GetCurrentPositionEx(m_hDC, lpPoint);
}
BOOL MoveTo(int x, int y, LPPOINT lpPoint = NULL)
{
SASSERT(m_hDC != NULL);
return ::MoveToEx(m_hDC, x, y, lpPoint);
}
BOOL MoveTo(POINT point, LPPOINT lpPointRet = NULL)
{
SASSERT(m_hDC != NULL);
return MoveTo(point.x, point.y, lpPointRet);
}
BOOL LineTo(int x, int y)
{
SASSERT(m_hDC != NULL);
return ::LineTo(m_hDC, x, y);
}
BOOL LineTo(POINT point)
{
SASSERT(m_hDC != NULL);
return LineTo(point.x, point.y);
}
BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
SASSERT(m_hDC != NULL);
return ::Arc(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
}
BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
{
SASSERT(m_hDC != NULL);
return ::Arc(m_hDC, lpRect->left, lpRect->top,
lpRect->right, lpRect->bottom, ptStart.x, ptStart.y,
ptEnd.x, ptEnd.y);
}
BOOL Polyline(const POINT* lpPoints, int nCount)
{
SASSERT(m_hDC != NULL);
return ::Polyline(m_hDC, lpPoints, nCount);
}
BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle)
{
SASSERT(m_hDC != NULL);
return ::AngleArc(m_hDC, x, y, nRadius, fStartAngle, fSweepAngle);
}
BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
SASSERT(m_hDC != NULL);
return ::ArcTo(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
}
BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
{
SASSERT(m_hDC != NULL);
return ArcTo(lpRect->left, lpRect->top, lpRect->right,
lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
}
int GetArcDirection() const
{
SASSERT(m_hDC != NULL);
return ::GetArcDirection(m_hDC);
}
int SetArcDirection(int nArcDirection)
{
SASSERT(m_hDC != NULL);
return ::SetArcDirection(m_hDC, nArcDirection);
}
BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount)
{
SASSERT(m_hDC != NULL);
return ::PolyDraw(m_hDC, lpPoints, lpTypes, nCount);
}
BOOL PolylineTo(const POINT* lpPoints, int nCount)
{
SASSERT(m_hDC != NULL);
return ::PolylineTo(m_hDC, lpPoints, nCount);
}
BOOL PolyPolyline(const POINT* lpPoints,
const DWORD* lpPolyPoints, int nCount)
{
SASSERT(m_hDC != NULL);
return ::PolyPolyline(m_hDC, lpPoints, lpPolyPoints, nCount);
}
BOOL PolyBezier(const POINT* lpPoints, int nCount)
{
SASSERT(m_hDC != NULL);
return ::PolyBezier(m_hDC, lpPoints, nCount);
}
BOOL PolyBezierTo(const POINT* lpPoints, int nCount)
{
SASSERT(m_hDC != NULL);
return ::PolyBezierTo(m_hDC, lpPoints, nCount);
}
// Simple Drawing Functions
BOOL FillRect(LPCRECT lpRect, HBRUSH hBrush)
{
SASSERT(m_hDC != NULL);
return ::FillRect(m_hDC, lpRect, hBrush);
}
BOOL FillRect(LPCRECT lpRect, int nColorIndex)
{
SASSERT(m_hDC != NULL);
return ::FillRect(m_hDC, lpRect, (HBRUSH)LongToPtr(nColorIndex + 1));
}
BOOL FrameRect(LPCRECT lpRect, HBRUSH hBrush)
{
SASSERT(m_hDC != NULL);
return ::FrameRect(m_hDC, lpRect, hBrush);
}
BOOL InvertRect(LPCRECT lpRect)
{
SASSERT(m_hDC != NULL);
return ::InvertRect(m_hDC, lpRect);
}
BOOL DrawIcon(int x, int y, HICON hIcon)
{
SASSERT(m_hDC != NULL);
return ::DrawIcon(m_hDC, x, y, hIcon);
}
BOOL DrawIcon(POINT point, HICON hIcon)
{
SASSERT(m_hDC != NULL);
return ::DrawIcon(m_hDC, point.x, point.y, hIcon);
}
BOOL DrawIconEx(int x, int y, HICON hIcon, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
{
SASSERT(m_hDC != NULL);
return ::DrawIconEx(m_hDC, x, y, hIcon, cxWidth, cyWidth, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
}
BOOL DrawIconEx(POINT point, HICON hIcon, SIZE size, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
{
SASSERT(m_hDC != NULL);
return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
}
BOOL DrawState(POINT pt, SIZE size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL)
{
SASSERT(m_hDC != NULL);
return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hBitmap, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_BITMAP);
}
BOOL DrawState(POINT pt, SIZE size, HICON hIcon, UINT nFlags, HBRUSH hBrush = NULL)
{
SASSERT(m_hDC != NULL);
return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_ICON);
}
BOOL DrawState(POINT pt, SIZE size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE, int nTextLen = 0, HBRUSH hBrush = NULL)
{
SASSERT(m_hDC != NULL);
return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags | (bPrefixText ? DST_PREFIXTEXT : DST_TEXT));
}
BOOL DrawState(POINT pt, SIZE size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL)
{
SASSERT(m_hDC != NULL);
return ::DrawState(m_hDC, hBrush, lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_COMPLEX);
}
// Ellipse and Polygon Functions
BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
SASSERT(m_hDC != NULL);
return ::Chord(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
}
BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
{
SASSERT(m_hDC != NULL);
return ::Chord(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
}
void DrawFocusRect(LPCRECT lpRect)
{
SASSERT(m_hDC != NULL);
::DrawFocusRect(m_hDC, lpRect);
}
BOOL Ellipse(int x1, int y1, int x2, int y2)
{
SASSERT(m_hDC != NULL);
return ::Ellipse(m_hDC, x1, y1, x2, y2);
}
BOOL Ellipse(LPCRECT lpRect)
{
SASSERT(m_hDC != NULL);
return ::Ellipse(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
}
BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
SASSERT(m_hDC != NULL);
return ::Pie(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
}
BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
{
SASSERT(m_hDC != NULL);
return ::Pie(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
}
BOOL Polygon(const POINT* lpPoints, int nCount)
{
SASSERT(m_hDC != NULL);
return ::Polygon(m_hDC, lpPoints, nCount);
}
BOOL PolyPolygon(const POINT* lpPoints, const INT* lpPolyCounts, int nCount)
{
SASSERT(m_hDC != NULL);
return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount);
}
BOOL Rectangle(int x1, int y1, int x2, int y2)
{
SASSERT(m_hDC != NULL);
return ::Rectangle(m_hDC, x1, y1, x2, y2);
}
BOOL Rectangle(LPCRECT lpRect)
{
SASSERT(m_hDC != NULL);
return ::Rectangle(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
}
BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3)
{
SASSERT(m_hDC != NULL);
return ::RoundRect(m_hDC, x1, y1, x2, y2, x3, y3);
}
BOOL RoundRect(LPCRECT lpRect, POINT point)
{
SASSERT(m_hDC != NULL);
return ::RoundRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, point.x, point.y);
}
// Bitmap Functions
BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop)
{
SASSERT(m_hDC != NULL);
return ::PatBlt(m_hDC, x, y, nWidth, nHeight, dwRop);
}
BOOL BitBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC,
int xSrc, int ySrc, DWORD dwRop)
{
SASSERT(m_hDC != NULL);
return ::BitBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, dwRop);
}
BOOL StretchBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop)
{
SASSERT(m_hDC != NULL);
return ::StretchBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, dwRop);
}
COLORREF GetPixel(int x, int y) const
{
SASSERT(m_hDC != NULL);
return ::GetPixel(m_hDC, x, y);
}
COLORREF GetPixel(POINT point) const
{
SASSERT(m_hDC != NULL);
return ::GetPixel(m_hDC, point.x, point.y);
}
COLORREF SetPixel(int x, int y, COLORREF crColor)
{
SASSERT(m_hDC != NULL);
return ::SetPixel(m_hDC, x, y, crColor);
}
COLORREF SetPixel(POINT point, COLORREF crColor)
{
SASSERT(m_hDC != NULL);
return ::SetPixel(m_hDC, point.x, point.y, crColor);
}
BOOL FloodFill(int x, int y, COLORREF crColor)
{
SASSERT(m_hDC != NULL);
return ::FloodFill(m_hDC, x, y, crColor);
}