]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/dcclient.cpp
Deprecate wxDC::{Begin,End}Drawing()
[wxWidgets.git] / src / mgl / dcclient.cpp
CommitLineData
32b8ec41 1/////////////////////////////////////////////////////////////////////////////
8f7b34a8 2// Name: dcclient.cpp
32b8ec41 3// Purpose:
8f7b34a8 4// Author: Vaclav Slavik
32b8ec41 5// RCS-ID: $Id$
c41c20a5 6// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
65571936 7// Licence: wxWindows licence
32b8ec41
VZ
8/////////////////////////////////////////////////////////////////////////////
9
a4bbc9f7
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
17#ifndef WX_PRECOMP
18 #include "wx/dcclient.h"
19 #include "wx/window.h"
20#endif
21
22#include <mgraph.hpp>
32b8ec41
VZ
23
24IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
32b8ec41 25IMPLEMENT_DYNAMIC_CLASS(wxClientDC,wxWindowDC)
7bdc1879 26IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
a4bbc9f7
VS
27
28wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win)
29{
7bdc1879 30 MGLDevCtx *dc = win->GetPaintMGLDC();
350d0064 31
7bdc1879
VS
32 if ( dc )
33 {
34 m_inPaintHandler = TRUE;
b8c0528d
VS
35
36 m_globalClippingRegion = win->GetUpdateRegion();
7bdc1879
VS
37 SetMGLDC(dc, FALSE);
38 }
39 else
40 {
41 m_inPaintHandler = FALSE;
350d0064 42
b8c0528d
VS
43 dc = new MGLDevCtx(MGL_wmBeginPaint(win->GetHandle()));
44
45 MGLRegion clip;
46 dc->getClipRegion(clip);
47 m_globalClippingRegion = wxRegion(clip);
48 SetMGLDC(dc, TRUE);
7bdc1879
VS
49 // TRUE means that dtor will delete MGLDevCtx object
50 // but it won't destroy MGLDC returned by MGL_wmBeginPaint because
51 // ~MGLDevCtx() doesn't call destroy()
52 }
a4bbc9f7
VS
53}
54
55wxWindowDC::~wxWindowDC()
56{
b8c0528d 57 if ( !m_inPaintHandler )
7bdc1879
VS
58 {
59 GetMGLDC()->setDC(NULL);
60 MGL_wmEndPaint(m_wnd->GetHandle());
61 }
a4bbc9f7
VS
62}
63
64wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
65{
66 wxRect r = m_wnd->GetClientRect();
b8c0528d 67 m_globalClippingRegion.Intersect(r);
79954978 68 SetClippingRegion(m_globalClippingRegion);
a4bbc9f7
VS
69 SetDeviceOrigin(r.x, r.y);
70}