]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMemoryDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dcmemory.h"
16 #include "wx/dcmemory.h"
17 #include "wx/settings.h"
21 #pragma message disable nosimpint
25 #pragma message enable nosimpint
28 #include "wx/motif/private.h"
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxWindowDC
)
36 wxMemoryDC::wxMemoryDC(void)
39 m_display
= wxGetDisplay();
41 Display
* display
= (Display
*) m_display
;
44 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
45 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
46 gcvalues
.graphics_exposures
= False
;
47 gcvalues
.subwindow_mode
= IncludeInferiors
;
48 gcvalues
.line_width
= 1;
49 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
50 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
53 m_backgroundPixel
= (int) gcvalues
.background
;
55 // Get the current Font so we can set it back later
57 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
58 m_oldFont
= (WXFont
) valReturn
.font
;
59 SetBrush (* wxWHITE_BRUSH
);
60 SetPen (* wxBLACK_PEN
);
61 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
64 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
67 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
68 m_display
= ((wxWindowDC
*)dc
)->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
= (int) gcvalues
.background
;
86 // Get the current Font so we can set it back later
88 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
89 m_oldFont
= (WXFont
) valReturn
.font
;
90 SetBrush (* wxWHITE_BRUSH
);
91 SetPen (* wxBLACK_PEN
);
94 wxMemoryDC::~wxMemoryDC(void)
98 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
103 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
106 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
108 m_pixmap
= m_bitmap
.GetDrawable();
109 Display
* display
= (Display
*) m_display
;
112 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
113 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
114 gcvalues
.graphics_exposures
= False
;
115 gcvalues
.subwindow_mode
= IncludeInferiors
;
116 gcvalues
.line_width
= 1;
117 m_gc
= (WXGC
) XCreateGC (display
, (Drawable
)m_pixmap
/* RootWindow (display, DefaultScreen (display)) */,
118 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
121 m_backgroundPixel
= (int) gcvalues
.background
;
124 // Get the current Font so we can set it back later
126 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
127 m_oldFont
= (WXFont
) valReturn
.font
;
129 bool oldOpt
= GetOptimization();
130 SetOptimization(FALSE
);
132 SetBrush (* wxWHITE_BRUSH
);
133 SetPen (* wxBLACK_PEN
);
135 SetOptimization(oldOpt
);
141 m_pixmap
= (WXPixmap
) 0;
145 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
149 if (width
) (*width
) = m_bitmap
.GetWidth();
150 if (height
) (*height
) = m_bitmap
.GetHeight();
154 if (width
) (*width
) = 0;
155 if (height
) (*height
) = 0;