]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/dcclient.cpp
added wxTreeEvent::GetKeyEvent() to allow to retrieve the key event flags from EVT_TR...
[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;
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 }
a4bbc9f7
VS
48}
49
50wxWindowDC::~wxWindowDC()
51{
7bdc1879
VS
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 }
a4bbc9f7
VS
64}
65
66wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
67{
68 wxRect r = m_wnd->GetClientRect();
69 SetClippingRegion(r);
70 SetDeviceOrigin(r.x, r.y);
71}