]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/dcclient.cpp
Updated to new PyCrust
[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$
8f7b34a8 6// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
32b8ec41
VZ
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "dcclient.h"
12#endif
13
a4bbc9f7
VS
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>
32b8ec41
VZ
27
28IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
32b8ec41 29IMPLEMENT_DYNAMIC_CLASS(wxClientDC,wxWindowDC)
7bdc1879 30IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
a4bbc9f7
VS
31
32wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win)
33{
7bdc1879
VS
34 MGLDevCtx *dc = win->GetPaintMGLDC();
35 if ( dc )
36 {
37 m_inPaintHandler = TRUE;
b8c0528d
VS
38
39 m_globalClippingRegion = win->GetUpdateRegion();
7bdc1879
VS
40 SetMGLDC(dc, FALSE);
41 }
42 else
43 {
44 m_inPaintHandler = FALSE;
b8c0528d
VS
45
46 dc = new MGLDevCtx(MGL_wmBeginPaint(win->GetHandle()));
47
48 MGLRegion clip;
49 dc->getClipRegion(clip);
50 m_globalClippingRegion = wxRegion(clip);
51 SetMGLDC(dc, TRUE);
7bdc1879
VS
52 // TRUE means that dtor will delete MGLDevCtx object
53 // but it won't destroy MGLDC returned by MGL_wmBeginPaint because
54 // ~MGLDevCtx() doesn't call destroy()
55 }
a4bbc9f7
VS
56}
57
58wxWindowDC::~wxWindowDC()
59{
b8c0528d 60 if ( !m_inPaintHandler )
7bdc1879
VS
61 {
62 GetMGLDC()->setDC(NULL);
63 MGL_wmEndPaint(m_wnd->GetHandle());
64 }
a4bbc9f7
VS
65}
66
67wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
68{
69 wxRect r = m_wnd->GetClientRect();
b8c0528d 70 m_globalClippingRegion.Intersect(r);
a4bbc9f7
VS
71 SetDeviceOrigin(r.x, r.y);
72}