]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/mgl/dcclient.cpp | |
3 | // Purpose: | |
4 | // Author: Vaclav Slavik | |
5 | // RCS-ID: $Id$ | |
6 | // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | // For compilers that support precompilation, includes "wx.h". | |
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #ifdef __BORLANDC__ | |
14 | #pragma hdrstop | |
15 | #endif | |
16 | ||
17 | #include "wx/dcclient.h" | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/window.h" | |
21 | #endif | |
22 | ||
23 | #include <mgraph.hpp> | |
24 | ||
25 | IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) | |
26 | IMPLEMENT_DYNAMIC_CLASS(wxClientDC,wxWindowDC) | |
27 | IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC) | |
28 | ||
29 | wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win) | |
30 | { | |
31 | MGLDevCtx *dc = win->GetPaintMGLDC(); | |
32 | ||
33 | if ( dc ) | |
34 | { | |
35 | m_inPaintHandler = TRUE; | |
36 | ||
37 | m_globalClippingRegion = win->GetUpdateRegion(); | |
38 | SetMGLDC(dc, FALSE); | |
39 | } | |
40 | else | |
41 | { | |
42 | m_inPaintHandler = FALSE; | |
43 | ||
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); | |
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 | } | |
54 | } | |
55 | ||
56 | wxWindowDC::~wxWindowDC() | |
57 | { | |
58 | if ( !m_inPaintHandler ) | |
59 | { | |
60 | GetMGLDC()->setDC(NULL); | |
61 | MGL_wmEndPaint(m_wnd->GetHandle()); | |
62 | } | |
63 | } | |
64 | ||
65 | wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win) | |
66 | { | |
67 | wxRect r = m_wnd->GetClientRect(); | |
68 | m_globalClippingRegion.Intersect(r); | |
69 | SetClippingRegion(m_globalClippingRegion); | |
70 | SetDeviceOrigin(r.x, r.y); | |
71 | } |