]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/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
24 #pragma message enable nosimpint
27 #include "wx/x11/private.h"
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC
, wxWindowDC
)
35 wxMemoryDC::wxMemoryDC(void)
38 m_display
= wxGetDisplay();
40 Display
* display
= (Display
*) m_display
;
43 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
44 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
45 gcvalues
.graphics_exposures
= False
;
46 gcvalues
.subwindow_mode
= IncludeInferiors
;
47 gcvalues
.line_width
= 1;
48 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
49 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
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::GetFont(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
.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
= (int) gcvalues
.background
;
85 // Get the current Font so we can set it back later
87 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
88 m_oldFont
= (WXFont
) valReturn
.font
;
89 SetBrush (* wxWHITE_BRUSH
);
90 SetPen (* wxBLACK_PEN
);
93 wxMemoryDC::~wxMemoryDC(void)
97 void wxMemoryDC::SelectObject( const wxBitmap
& bitmap
)
102 XFreeGC((Display
*) m_display
, (GC
) m_gc
);
105 if (m_bitmap
.Ok() && (bitmap
.GetDisplay() == m_display
))
107 m_pixmap
= m_bitmap
.GetPixmap();
108 Display
* display
= (Display
*) m_display
;
111 gcvalues
.foreground
= BlackPixel (display
, DefaultScreen (display
));
112 gcvalues
.background
= WhitePixel (display
, DefaultScreen (display
));
113 gcvalues
.graphics_exposures
= False
;
114 gcvalues
.subwindow_mode
= IncludeInferiors
;
115 gcvalues
.line_width
= 1;
116 m_gc
= (WXGC
) XCreateGC (display
, RootWindow (display
, DefaultScreen (display
)),
117 GCForeground
| GCBackground
| GCGraphicsExposures
| GCLineWidth
| GCSubwindowMode
,
120 m_backgroundPixel
= (int) gcvalues
.background
;
122 // Get the current Font so we can set it back later
124 XGetGCValues((Display
*) m_display
, (GC
) m_gc
, GCFont
, &valReturn
);
125 m_oldFont
= (WXFont
) valReturn
.font
;
127 bool oldOpt
= GetOptimization();
128 SetOptimization(FALSE
);
130 SetBrush (* wxWHITE_BRUSH
);
131 SetPen (* wxBLACK_PEN
);
133 SetOptimization(oldOpt
);
140 m_pixmap
= (WXPixmap
) 0;
144 void wxMemoryDC::DoGetSize( int *width
, int *height
) const
148 if (width
) (*width
) = m_bitmap
.GetWidth();
149 if (height
) (*height
) = m_bitmap
.GetHeight();
153 if (width
) (*width
) = 0;
154 if (height
) (*height
) = 0;