]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/dcclient.cpp
e5b507cc92115a1373dff6c1be5e2a167d5b98e6
[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 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "dcclient.h"
12 #endif
13
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
16
17 #ifdef __BORLANDC__
18 #pragma hdrstop
19 #endif
20
21 #ifndef WX_PRECOMP
22 #include "wx/dcclient.h"
23 #include "wx/window.h"
24 #endif
25
26 #include <mgraph.hpp>
27
28 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
29 IMPLEMENT_DYNAMIC_CLASS(wxClientDC,wxWindowDC)
30 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
31
32 wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win)
33 {
34 MGLDevCtx *dc = win->GetPaintMGLDC();
35
36 if ( dc )
37 {
38 m_inPaintHandler = TRUE;
39
40 m_globalClippingRegion = win->GetUpdateRegion();
41 SetMGLDC(dc, FALSE);
42 }
43 else
44 {
45 m_inPaintHandler = FALSE;
46
47 // VS: we have to update here so that screen's content is up-to-date
48 // and blitting from wxWindowDC works as expected
49 win->Update();
50
51 dc = new MGLDevCtx(MGL_wmBeginPaint(win->GetHandle()));
52
53 MGLRegion clip;
54 dc->getClipRegion(clip);
55 m_globalClippingRegion = wxRegion(clip);
56 SetMGLDC(dc, TRUE);
57 // TRUE means that dtor will delete MGLDevCtx object
58 // but it won't destroy MGLDC returned by MGL_wmBeginPaint because
59 // ~MGLDevCtx() doesn't call destroy()
60 }
61 }
62
63 wxWindowDC::~wxWindowDC()
64 {
65 if ( !m_inPaintHandler )
66 {
67 GetMGLDC()->setDC(NULL);
68 MGL_wmEndPaint(m_wnd->GetHandle());
69 }
70 }
71
72 wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
73 {
74 wxRect r = m_wnd->GetClientRect();
75 m_globalClippingRegion.Intersect(r);
76 SetDeviceOrigin(r.x, r.y);
77 }