]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/dcclient.cpp
wxSizer::Fit() now sets client size
[wxWidgets.git] / src / mgl / dcclient.cpp
CommitLineData
32b8ec41 1/////////////////////////////////////////////////////////////////////////////
ed4b0fdc 2// Name: src/mgl/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
ed4b0fdc
WS
17#include "wx/dcclient.h"
18
a4bbc9f7 19#ifndef WX_PRECOMP
a4bbc9f7
VS
20 #include "wx/window.h"
21#endif
22
23#include <mgraph.hpp>
32b8ec41
VZ
24
25IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
32b8ec41 26IMPLEMENT_DYNAMIC_CLASS(wxClientDC,wxWindowDC)
7bdc1879 27IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
a4bbc9f7
VS
28
29wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win)
30{
7bdc1879 31 MGLDevCtx *dc = win->GetPaintMGLDC();
350d0064 32
7bdc1879
VS
33 if ( dc )
34 {
35 m_inPaintHandler = TRUE;
b8c0528d
VS
36
37 m_globalClippingRegion = win->GetUpdateRegion();
7bdc1879
VS
38 SetMGLDC(dc, FALSE);
39 }
40 else
41 {
42 m_inPaintHandler = FALSE;
ed4b0fdc 43
b8c0528d
VS
44 dc = new MGLDevCtx(MGL_wmBeginPaint(win->GetHandle()));
45
46 MGLRegion clip;
47 dc->getClipRegion(clip);
48 m_globalClippingRegion = wxRegion(clip);
49 SetMGLDC(dc, TRUE);
7bdc1879
VS
50 // TRUE means that dtor will delete MGLDevCtx object
51 // but it won't destroy MGLDC returned by MGL_wmBeginPaint because
52 // ~MGLDevCtx() doesn't call destroy()
53 }
a4bbc9f7
VS
54}
55
56wxWindowDC::~wxWindowDC()
57{
b8c0528d 58 if ( !m_inPaintHandler )
7bdc1879
VS
59 {
60 GetMGLDC()->setDC(NULL);
61 MGL_wmEndPaint(m_wnd->GetHandle());
62 }
a4bbc9f7
VS
63}
64
65wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
66{
67 wxRect r = m_wnd->GetClientRect();
b8c0528d 68 m_globalClippingRegion.Intersect(r);
79954978 69 SetClippingRegion(m_globalClippingRegion);
a4bbc9f7
VS
70 SetDeviceOrigin(r.x, r.y);
71}