]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/dcclient.cpp
added at least some stderr support to wxMGL which suffers badly from MGL's hostile...
[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 if ( dc )
36 {
37 m_inPaintHandler = TRUE;
38 SetMGLDC(dc, FALSE);
39 }
40 else
41 {
42 m_inPaintHandler = FALSE;
43 SetMGLDC(new MGLDevCtx(MGL_wmBeginPaint(m_wnd->GetHandle())), TRUE);
44 // TRUE means that dtor will delete MGLDevCtx object
45 // but it won't destroy MGLDC returned by MGL_wmBeginPaint because
46 // ~MGLDevCtx() doesn't call destroy()
47 }
48 }
49
50 wxWindowDC::~wxWindowDC()
51 {
52 if ( m_inPaintHandler )
53 {
54 // This is neccessary so that subsequently created wxPaintDCs won't get
55 // confused about clipping. Another reason is that the same MGL dc is reused
56 // for wxEraseEvent, wxNcPaintEvent and wxPaintEvent
57 DestroyClippingRegion();
58 }
59 else
60 {
61 GetMGLDC()->setDC(NULL);
62 MGL_wmEndPaint(m_wnd->GetHandle());
63 }
64 }
65
66 wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
67 {
68 wxRect r = m_wnd->GetClientRect();
69 SetClippingRegion(r);
70 SetDeviceOrigin(r.x, r.y);
71 }