]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dcmemory.cpp
72c64deea89e55be29a2a4432cf1fddd75cedc16
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/dcmemory.cpp
3 // Purpose: wxMemoryDCImpl class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
17 #include "wx/settings.h"
18 #include "wx/dcmemory.h"
19 #include "wx/dcclient.h"
23 #pragma message disable nosimpint
27 #pragma message enable nosimpint
30 #include "wx/motif/private.h"
31 #include "wx/motif/dcmemory.h"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl
, wxWindowDCImpl
)
39 void wxMemoryDCImpl::Init()
42 m_display
= wxGetDisplay();
44 Display
* display
= (Display
*) m_display
;
47 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
48 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
49 gcvalues
.graphics_exposures
= False
;
50 gcvalues
.subwindow_mode
= IncludeInferiors
;
51 gcvalues
.line_width
= 1;
52 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
53 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
56 m_backgroundPixel
= gcvalues
.background
;
58 SetBrush (* wxWHITE_BRUSH
);
59 SetPen (* wxBLACK_PEN
);
60 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
63 wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC
*owner
, wxDC
* dc
)
64 : wxWindowDCImpl(owner
)
67 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
68 m_display
= ((wxWindowDCImpl
*)dc
->GetImpl())->GetDisplay();
70 m_display
= wxGetDisplay();
72 Display
* display
= (Display
*) m_display
;
75 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
76 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
77 gcvalues
.graphics_exposures
= False
;
78 gcvalues
.subwindow_mode
= IncludeInferiors
;
79 gcvalues
.line_width
= 1;
80 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
81 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
84 m_backgroundPixel
= gcvalues
.background
;
86 SetBrush (* wxWHITE_BRUSH
);
87 SetPen (* wxBLACK_PEN
);
90 wxMemoryDCImpl::~wxMemoryDCImpl(void)
94 void wxMemoryDCImpl::DoSelect( const wxBitmap
& bitmap
)
99 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
102 if (m_bitmap
.IsOk() && (bitmap
.GetDisplay() == m_display
))
104 m_pixmap
= m_bitmap
.GetDrawable();
105 Display
* display
= (Display
*) m_display
;
108 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
109 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
110 gcvalues
.graphics_exposures
= False
;
111 gcvalues
.subwindow_mode
= IncludeInferiors
;
112 gcvalues
.line_width
= 1;
113 m_gc
= (WXGC
) XCreateGC (display
, (Drawable
)m_pixmap
/* RootWindow (display, DefaultScreen (display)) */,
114 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
117 m_backgroundPixel
= gcvalues
.background
;
120 SetBrush (* wxWHITE_BRUSH
);
121 SetPen (* wxBLACK_PEN
);
126 m_pixmap
= (WXPixmap
) 0;
130 void wxMemoryDCImpl::DoGetSize( int *width
, int *height
) const
134 if (width
) (*width
) = m_bitmap
.GetWidth();
135 if (height
) (*height
) = m_bitmap
.GetHeight();
139 if (width
) (*width
) = 0;
140 if (height
) (*height
) = 0;