]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dcmemory.cpp
3 // Purpose: wxMemoryDCImpl class
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
16 #include "wx/settings.h"
17 #include "wx/dcmemory.h"
18 #include "wx/dcclient.h"
22 #pragma message disable nosimpint
26 #pragma message enable nosimpint
29 #include "wx/motif/private.h"
30 #include "wx/motif/dcmemory.h"
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl
, wxWindowDCImpl
)
38 void wxMemoryDCImpl::Init()
41 m_display
= wxGetDisplay();
43 Display
* display
= (Display
*) m_display
;
46 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
47 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
48 gcvalues
.graphics_exposures
= False
;
49 gcvalues
.subwindow_mode
= IncludeInferiors
;
50 gcvalues
.line_width
= 1;
51 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
52 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
55 m_backgroundPixel
= gcvalues
.background
;
57 SetBrush (* wxWHITE_BRUSH
);
58 SetPen (* wxBLACK_PEN
);
59 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
62 wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC
*owner
, wxDC
* dc
)
63 : wxWindowDCImpl(owner
)
66 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
67 m_display
= ((wxWindowDCImpl
*)dc
->GetImpl())->GetDisplay();
69 m_display
= wxGetDisplay();
71 Display
* display
= (Display
*) m_display
;
74 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
75 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
76 gcvalues
.graphics_exposures
= False
;
77 gcvalues
.subwindow_mode
= IncludeInferiors
;
78 gcvalues
.line_width
= 1;
79 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
80 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
83 m_backgroundPixel
= gcvalues
.background
;
85 SetBrush (* wxWHITE_BRUSH
);
86 SetPen (* wxBLACK_PEN
);
89 wxMemoryDCImpl::~wxMemoryDCImpl(void)
93 void wxMemoryDCImpl::DoSelect( const wxBitmap
& bitmap
)
98 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
101 if (m_bitmap
.IsOk() && (bitmap
.GetDisplay() == m_display
))
103 m_pixmap
= m_bitmap
.GetDrawable();
104 Display
* display
= (Display
*) m_display
;
107 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
108 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
109 gcvalues
.graphics_exposures
= False
;
110 gcvalues
.subwindow_mode
= IncludeInferiors
;
111 gcvalues
.line_width
= 1;
112 m_gc
= (WXGC
) XCreateGC (display
, (Drawable
)m_pixmap
/* RootWindow (display, DefaultScreen (display)) */,
113 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
116 m_backgroundPixel
= gcvalues
.background
;
119 SetBrush (* wxWHITE_BRUSH
);
120 SetPen (* wxBLACK_PEN
);
125 m_pixmap
= (WXPixmap
) 0;
129 void wxMemoryDCImpl::DoGetSize( int *width
, int *height
) const
133 if (width
) (*width
) = m_bitmap
.GetWidth();
134 if (height
) (*height
) = m_bitmap
.GetHeight();
138 if (width
) (*width
) = 0;
139 if (height
) (*height
) = 0;