#include "wx/window.h"
#include "wx/dcmemory.h"
#include "wx/math.h"
+ #include "wx/image.h"
+ #include "wx/module.h"
#endif
-#include "wx/image.h"
-#include "wx/module.h"
#include "wx/fontutil.h"
#include "wx/x11/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
-wxWindowDC::wxWindowDC()
+void wxWindowDC::Init()
{
m_display = (WXDisplay *) NULL;
m_penGC = (WXGC *) NULL;
m_owner = (wxWindow *)NULL;
#if wxUSE_UNICODE
- m_context = (PangoContext *)NULL;
+ m_context = wxTheApp->GetPangoContext();
m_fontdesc = (PangoFontDescription *)NULL;
#endif
}
{
wxASSERT_MSG( window, wxT("DC needs a window") );
- m_display = (WXDisplay *) NULL;
- m_penGC = (WXGC *) NULL;
- m_brushGC = (WXGC *) NULL;
- m_textGC = (WXGC *) NULL;
- m_bgGC = (WXGC *) NULL;
- m_cmap = (WXColormap *) NULL;
- m_owner = (wxWindow *)NULL;
- m_isMemDC = false;
- m_isScreenDC = false;
+ Init();
+
m_font = window->GetFont();
m_window = (WXWindow*) window->GetMainWindow();
m_display = (WXDisplay *) wxGlobalDisplay();
#if wxUSE_UNICODE
- m_context = wxTheApp->GetPangoContext();
m_fontdesc = window->GetFont().GetNativeFontInfo()->description;
#endif
m_font = font;
- return;
-
#if wxUSE_UNICODE
m_fontdesc = font.GetNativeFontInfo()->description;
#endif
if (!m_window) return;
+ if (width <= 0)
+ width = 1;
+
+ if (height <= 0)
+ height = 1;
+
wxRect rect;
rect.x = XLOG2DEV(x);
rect.y = YLOG2DEV(y);
class wxDCModule : public wxModule
{
public:
- bool OnInit();
- void OnExit();
+ // we must be cleaned up before wxDisplayModule which closes the global
+ // display
+ wxDCModule()
+ {
+ AddDependency(wxClassInfo::FindClass(_T("wxX11DisplayModule")));
+ }
+
+ bool OnInit() { wxInitGCPool(); return true; }
+ void OnExit() { wxCleanUpGCPool(); }
private:
DECLARE_DYNAMIC_CLASS(wxDCModule)
IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
-bool wxDCModule::OnInit()
-{
- wxInitGCPool();
- return true;
-}
-
-void wxDCModule::OnExit()
-{
- wxCleanUpGCPool();
-}