]>
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 /////////////////////////////////////////////////////////////////////////////
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
.line_width
= 1;
48 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
49 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
52 m_backgroundPixel
= (int) gcvalues
.background
;
54 // Get the current Font so we can set it back later
56 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
57 m_oldFont
= (WXFont
) valReturn
.font
;
58 SetBrush (* wxWHITE_BRUSH
);
59 SetPen (* wxBLACK_PEN
);
60 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
63 wxMemoryDC::wxMemoryDC( wxDC
* dc
)
66 if (dc
&& dc
->IsKindOf(CLASSINFO(wxWindowDC
)))
67 m_display
= ((wxWindowDC
*)dc
)->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
.line_width
= 1;
78 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
79 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
82 m_backgroundPixel
= (int) gcvalues
.background
;
84 // Get the current Font so we can set it back later
86 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
87 m_oldFont
= (WXFont
) valReturn
.font
;
88 SetBrush (* wxWHITE_BRUSH
);
89 SetPen (* wxBLACK_PEN
);
92 wxMemoryDC::~wxMemoryDC(void)
96 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
101 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
104 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
106 m_pixmap
= m_bitmap
.GetPixmap();
107 Display
* display
= (Display
*) m_display
;
110 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
111 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
112 gcvalues
.graphics_exposures
= False
;
113 gcvalues
.line_width
= 1;
114 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
115 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
,
118 m_backgroundPixel
= (int) gcvalues
.background
;
120 // Get the current Font so we can set it back later
122 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
123 m_oldFont
= (WXFont
) valReturn
.font
;
125 bool oldOpt
= GetOptimization();
126 SetOptimization(FALSE
);
128 SetBrush (* wxWHITE_BRUSH
);
129 SetPen (* wxBLACK_PEN
);
131 SetOptimization(oldOpt
);
138 m_pixmap
= (WXPixmap
) 0;
142 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
146 if (width
) (*width
) = m_bitmap
.GetWidth();
147 if (height
) (*height
) = m_bitmap
.GetHeight();
151 if (width
) (*width
) = 0;
152 if (height
) (*height
) = 0;