diff --git a/include/wx/motif/icon.h b/include/wx/motif/icon.h index 9d58ceb389..c4700ea2be 100644 --- a/include/wx/motif/icon.h +++ b/include/wx/motif/icon.h @@ -18,13 +18,10 @@ #include "wx/bitmap.h" -#define M_ICONDATA ((wxBitmapRefData *)m_refData) -#define M_ICONHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData()) - // Icon class WXDLLEXPORT wxIcon: public wxBitmap { - DECLARE_DYNAMIC_CLASS(wxIcon) + DECLARE_DYNAMIC_CLASS(wxIcon); public: wxIcon(); @@ -51,12 +48,12 @@ public: // ctors, assignment operators...), but it's ok to have such function void CopyFromBitmap(const wxBitmap& bmp); - inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; } - inline bool operator == (const wxIcon& icon) const { return m_refData == icon.m_refData; } - inline bool operator != (const wxIcon& icon) const { return m_refData != icon.m_refData; } - - virtual bool Ok() const { return ((m_refData != NULL) && (M_ICONDATA->m_ok)); } + inline wxIcon& operator = (const wxIcon& icon) + { if (*this == icon) return (*this); Ref(icon); return *this; } + inline bool operator == (const wxIcon& icon) const + { return m_refData == icon.m_refData; } + inline bool operator != (const wxIcon& icon) const + { return m_refData != icon.m_refData; } }; -#endif -// _WX_ICON_H_ +#endif // _WX_ICON_H_ diff --git a/src/motif/bitmap.cpp b/src/motif/bitmap.cpp index ee5ee10630..21a9b7ae91 100644 --- a/src/motif/bitmap.cpp +++ b/src/motif/bitmap.cpp @@ -443,6 +443,8 @@ bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, int WXUNUSED(desiredHeight)) { // M_BITMAPHANDLERDATA->m_freePixmap = TRUE; + if (!bitmap->GetRefData()) + bitmap->SetRefData( new wxBitmapRefData() ); int hotX, hotY; unsigned int w, h; @@ -491,6 +493,9 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags), int width, int height, int WXUNUSED(depth)) { + if (!bitmap->GetRefData()) + bitmap->SetRefData( new wxBitmapRefData() ); + M_BITMAPHANDLERDATA->m_width = width; M_BITMAPHANDLERDATA->m_height = height; M_BITMAPHANDLERDATA->m_depth = 1; @@ -585,6 +590,9 @@ bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name, int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight) ) { + if (!bitmap->GetRefData()) + bitmap->SetRefData( new wxBitmapRefData() ); + Display *dpy = (Display*) wxGetDisplay(); M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy; @@ -686,6 +694,9 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags), int width, int height, int WXUNUSED(depth)) { + if (!bitmap->GetRefData()) + bitmap->SetRefData( new wxBitmapRefData() ); + M_BITMAPHANDLERDATA->m_width = width; M_BITMAPHANDLERDATA->m_height = height; M_BITMAPHANDLERDATA->m_depth = 1; diff --git a/src/motif/icon.cpp b/src/motif/icon.cpp index 56c10def1c..54edd5f3cb 100644 --- a/src/motif/icon.cpp +++ b/src/motif/icon.cpp @@ -14,24 +14,12 @@ #endif #include "wx/icon.h" -#include "wx/window.h" -#ifdef __VMS__ -#pragma message disable nosimpint -#endif -#include -#include -#ifdef __VMS__ -#pragma message enable nosimpint -#endif +IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap); -#include "wx/motif/private.h" - -IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) - -/* -* Icons -*/ +// ============================================================================ +// Icons +// ============================================================================ wxIcon::wxIcon() { @@ -75,9 +63,7 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, int desiredWidth, int desiredHeight) { UnRef(); - - m_refData = new wxBitmapRefData; - + wxBitmapHandler *handler = FindHandler(type); if ( handler ) @@ -86,4 +72,3 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, else return FALSE; } -