Make wxIcon more independent from wxBitmap implementation.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19941 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
70aac632a1
commit
59e034c034
@ -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_
|
||||
|
@ -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;
|
||||
|
@ -14,24 +14,12 @@
|
||||
#endif
|
||||
|
||||
#include "wx/icon.h"
|
||||
#include "wx/window.h"
|
||||
|
||||
#ifdef __VMS__
|
||||
#pragma message disable nosimpint
|
||||
#endif
|
||||
#include <Xm/Xm.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user