]> git.saurik.com Git - wxWidgets.git/blame - src/msw/dcclient.cpp
1. added wxTreeCtrl::SetItemBold and IsBold, updated the sample to show them
[wxWidgets.git] / src / msw / dcclient.cpp
CommitLineData
2bda0e17
KB
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
2bda0e17
KB
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"
83626bfa 27#include "wx/log.h"
2bda0e17
KB
28
29#include <windows.h>
30
31#if !USE_SHARED_LIBRARY
32IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxDC)
33IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
34IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxDC)
35#endif
36
37wxClientDC::wxClientDC(void)
38{
39 m_canvas = NULL;
40}
41
42wxClientDC::wxClientDC(wxWindow *the_canvas)
43{
44 m_canvas = the_canvas;
45// BeginDrawing();
46 m_hDC = (WXHDC) ::GetDC((HWND) the_canvas->GetHWND());
47}
48
49wxClientDC::~wxClientDC(void)
50{
51// EndDrawing();
52
53 if (m_canvas && (HDC) m_hDC)
54 {
55 SelectOldObjects(m_hDC);
56
57 ::ReleaseDC((HWND) m_canvas->GetHWND(), (HDC) m_hDC);
58 m_hDC = 0;
59 }
60}
61
62wxWindowDC::wxWindowDC(void)
63{
64 m_canvas = NULL;
65}
66
67wxWindowDC::wxWindowDC(wxWindow *the_canvas)
68{
69 m_canvas = the_canvas;
70// m_hDC = (WXHDC) ::GetDCEx((HWND) the_canvas->GetHWND(), NULL, DCX_WINDOW);
71 m_hDC = (WXHDC) ::GetWindowDC((HWND) the_canvas->GetHWND() );
72 m_hDCCount ++;
73}
74
75wxWindowDC::~wxWindowDC(void)
76{
77 if (m_canvas && m_hDC)
78 {
79 SelectOldObjects(m_hDC);
80
81 ::ReleaseDC((HWND) m_canvas->GetHWND(), (HDC) m_hDC);
82 m_hDC = 0;
83 }
84 m_hDCCount --;
85}
86
87wxPaintDC::wxPaintDC(void)
88{
89 m_canvas = NULL;
90}
91
92static PAINTSTRUCT g_paintStruct;
93
94// Don't call Begin/EndPaint if it's already been called:
95// for example, if calling a base class OnPaint.
96
c085e333
VZ
97WXHDC wxPaintDC::ms_PaintHDC = 0;
98size_t wxPaintDC::ms_PaintCount = 0; // count of ms_PaintHDC usage
2bda0e17 99
83626bfa 100wxPaintDC::wxPaintDC(wxWindow *canvas)
2bda0e17 101{
83626bfa 102 wxCHECK_RET( canvas, "NULL canvas in wxPaintDC ctor" );
2bda0e17 103
83626bfa
VZ
104 m_canvas = canvas;
105 if ( ms_PaintCount > 0 ) {
106 // it means that we've already called BeginPaint and so we must just
107 // reuse the same HDC (BeginPaint shouldn't be called more than once)
108 wxASSERT( ms_PaintHDC );
109
110 m_hDC = ms_PaintHDC;
111 ms_PaintCount++;
112 }
113 else {
114 ms_PaintHDC =
115 m_hDC = (WXHDC)::BeginPaint((HWND)m_canvas->GetHWND(), &g_paintStruct);
116 ms_PaintCount = 1;
117 m_hDCCount++;
118 }
2bda0e17
KB
119}
120
83626bfa 121wxPaintDC::~wxPaintDC()
2bda0e17 122{
83626bfa
VZ
123 if ( m_hDC ) {
124 if ( !--ms_PaintCount ) {
125 ::EndPaint((HWND)m_canvas->GetHWND(), &g_paintStruct);
126 m_hDCCount--;
a0a302dc
JS
127 m_hDC = (WXHDC) NULL;
128 ms_PaintHDC = (WXHDC) NULL;
1c089c47 129 }
c085e333 130 else { }//: ms_PaintHDC still in use
83626bfa 131 }
2bda0e17 132}
81d66cf3 133