]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/dcclient.cpp
removed empty block
[wxWidgets.git] / src / mgl / dcclient.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dcclient.cpp
3 // Purpose:
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
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>
23
24 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
25 IMPLEMENT_DYNAMIC_CLASS(wxClientDC,wxWindowDC)
26 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
27
28 wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win)
29 {
30 MGLDevCtx *dc = win->GetPaintMGLDC();
31
32 if ( dc )
33 {
34 m_inPaintHandler = TRUE;
35
36 m_globalClippingRegion = win->GetUpdateRegion();
37 SetMGLDC(dc, FALSE);
38 }
39 else
40 {
41 m_inPaintHandler = FALSE;
42
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);
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 }
53 }
54
55 wxWindowDC::~wxWindowDC()
56 {
57 if ( !m_inPaintHandler )
58 {
59 GetMGLDC()->setDC(NULL);
60 MGL_wmEndPaint(m_wnd->GetHandle());
61 }
62 }
63
64 wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
65 {
66 wxRect r = m_wnd->GetClientRect();
67 m_globalClippingRegion.Intersect(r);
68 SetClippingRegion(m_globalClippingRegion);
69 SetDeviceOrigin(r.x, r.y);
70 }