]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/dcclient.cpp
Removed my buggy bug-fix
[wxWidgets.git] / src / msw / dcclient.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcclient.cpp
3// Purpose: wxClientDC class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "dcclient.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#endif
25
26#include "wx/dcclient.h"
27#include "wx/log.h"
28
29#include <windows.h>
30
31#if !USE_SHARED_LIBRARY
32IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
33IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
34IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
35#endif
36
37/*
38 * wxWindowDC
39 */
40
41wxWindowDC::wxWindowDC(void)
42{
43 m_canvas = NULL;
44}
45
46wxWindowDC::wxWindowDC(wxWindow *the_canvas)
47{
48 m_canvas = the_canvas;
49// m_hDC = (WXHDC) ::GetDCEx((HWND) the_canvas->GetHWND(), NULL, DCX_WINDOW);
50 m_hDC = (WXHDC) ::GetWindowDC((HWND) the_canvas->GetHWND() );
51 m_hDCCount ++;
52
53 SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
54}
55
56wxWindowDC::~wxWindowDC(void)
57{
58 if (m_canvas && m_hDC)
59 {
60 SelectOldObjects(m_hDC);
61
62 ::ReleaseDC((HWND) m_canvas->GetHWND(), (HDC) m_hDC);
63 m_hDC = 0;
64 }
65 m_hDCCount --;
66}
67
68/*
69 * wxClientDC
70 */
71
72wxClientDC::wxClientDC(void)
73{
74 m_canvas = NULL;
75}
76
77wxClientDC::wxClientDC(wxWindow *the_canvas)
78{
79 m_canvas = the_canvas;
80// BeginDrawing();
81 m_hDC = (WXHDC) ::GetDC((HWND) the_canvas->GetHWND());
82
83 SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
84}
85
86wxClientDC::~wxClientDC(void)
87{
88// EndDrawing();
89
90 if (m_canvas && (HDC) m_hDC)
91 {
92 SelectOldObjects(m_hDC);
93
94 ::ReleaseDC((HWND) m_canvas->GetHWND(), (HDC) m_hDC);
95 m_hDC = 0;
96 }
97}
98
99/*
100 * wxPaintDC
101 */
102
103wxPaintDC::wxPaintDC(void)
104{
105 m_canvas = NULL;
106}
107
108static PAINTSTRUCT g_paintStruct;
109
110// Don't call Begin/EndPaint if it's already been called:
111// for example, if calling a base class OnPaint.
112
113WXHDC wxPaintDC::ms_PaintHDC = 0;
114size_t wxPaintDC::ms_PaintCount = 0; // count of ms_PaintHDC usage
115
116wxPaintDC::wxPaintDC(wxWindow *canvas)
117{
118 wxCHECK_RET( canvas, "NULL canvas in wxPaintDC ctor" );
119
120 m_canvas = canvas;
121 if ( ms_PaintCount > 0 ) {
122 // it means that we've already called BeginPaint and so we must just
123 // reuse the same HDC (BeginPaint shouldn't be called more than once)
124 wxASSERT( ms_PaintHDC );
125
126 m_hDC = ms_PaintHDC;
127 ms_PaintCount++;
128 }
129 else {
130 ms_PaintHDC =
131 m_hDC = (WXHDC)::BeginPaint((HWND)m_canvas->GetHWND(), &g_paintStruct);
132 ms_PaintCount = 1;
133 m_hDCCount++;
134 }
135
136 SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
137}
138
139wxPaintDC::~wxPaintDC()
140{
141 if ( m_hDC ) {
142 if ( !--ms_PaintCount ) {
143 ::EndPaint((HWND)m_canvas->GetHWND(), &g_paintStruct);
144 m_hDCCount--;
145 m_hDC = (WXHDC) NULL;
146 ms_PaintHDC = (WXHDC) NULL;
147 }
148 else { }//: ms_PaintHDC still in use
149 }
150}
151