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:
@@ -18,13 +18,10 @@
|
|||||||
|
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
#define M_ICONDATA ((wxBitmapRefData *)m_refData)
|
|
||||||
#define M_ICONHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
|
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
class WXDLLEXPORT wxIcon: public wxBitmap
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxIcon)
|
DECLARE_DYNAMIC_CLASS(wxIcon);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxIcon();
|
wxIcon();
|
||||||
@@ -51,12 +48,12 @@ public:
|
|||||||
// ctors, assignment operators...), but it's ok to have such function
|
// ctors, assignment operators...), but it's ok to have such function
|
||||||
void CopyFromBitmap(const wxBitmap& bmp);
|
void CopyFromBitmap(const wxBitmap& bmp);
|
||||||
|
|
||||||
inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
|
inline wxIcon& operator = (const wxIcon& icon)
|
||||||
inline bool operator == (const wxIcon& icon) const { return m_refData == icon.m_refData; }
|
{ 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 bool operator != (const wxIcon& icon) const
|
||||||
|
{ return m_refData != icon.m_refData; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _WX_ICON_H_
|
||||||
// _WX_ICON_H_
|
|
||||||
|
@@ -443,6 +443,8 @@ bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name,
|
|||||||
int WXUNUSED(desiredHeight))
|
int WXUNUSED(desiredHeight))
|
||||||
{
|
{
|
||||||
// M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
|
// M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
|
||||||
|
if (!bitmap->GetRefData())
|
||||||
|
bitmap->SetRefData( new wxBitmapRefData() );
|
||||||
|
|
||||||
int hotX, hotY;
|
int hotX, hotY;
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
@@ -491,6 +493,9 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data,
|
|||||||
long WXUNUSED(flags),
|
long WXUNUSED(flags),
|
||||||
int width, int height, int WXUNUSED(depth))
|
int width, int height, int WXUNUSED(depth))
|
||||||
{
|
{
|
||||||
|
if (!bitmap->GetRefData())
|
||||||
|
bitmap->SetRefData( new wxBitmapRefData() );
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_width = width;
|
M_BITMAPHANDLERDATA->m_width = width;
|
||||||
M_BITMAPHANDLERDATA->m_height = height;
|
M_BITMAPHANDLERDATA->m_height = height;
|
||||||
M_BITMAPHANDLERDATA->m_depth = 1;
|
M_BITMAPHANDLERDATA->m_depth = 1;
|
||||||
@@ -585,6 +590,9 @@ bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name,
|
|||||||
int WXUNUSED(desiredWidth),
|
int WXUNUSED(desiredWidth),
|
||||||
int WXUNUSED(desiredHeight) )
|
int WXUNUSED(desiredHeight) )
|
||||||
{
|
{
|
||||||
|
if (!bitmap->GetRefData())
|
||||||
|
bitmap->SetRefData( new wxBitmapRefData() );
|
||||||
|
|
||||||
Display *dpy = (Display*) wxGetDisplay();
|
Display *dpy = (Display*) wxGetDisplay();
|
||||||
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
|
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
|
||||||
|
|
||||||
@@ -686,6 +694,9 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data,
|
|||||||
long WXUNUSED(flags),
|
long WXUNUSED(flags),
|
||||||
int width, int height, int WXUNUSED(depth))
|
int width, int height, int WXUNUSED(depth))
|
||||||
{
|
{
|
||||||
|
if (!bitmap->GetRefData())
|
||||||
|
bitmap->SetRefData( new wxBitmapRefData() );
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_width = width;
|
M_BITMAPHANDLERDATA->m_width = width;
|
||||||
M_BITMAPHANDLERDATA->m_height = height;
|
M_BITMAPHANDLERDATA->m_height = height;
|
||||||
M_BITMAPHANDLERDATA->m_depth = 1;
|
M_BITMAPHANDLERDATA->m_depth = 1;
|
||||||
|
@@ -14,24 +14,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
#include "wx/window.h"
|
|
||||||
|
|
||||||
#ifdef __VMS__
|
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap);
|
||||||
#pragma message disable nosimpint
|
|
||||||
#endif
|
|
||||||
#include <Xm/Xm.h>
|
|
||||||
#include <X11/cursorfont.h>
|
|
||||||
#ifdef __VMS__
|
|
||||||
#pragma message enable nosimpint
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/motif/private.h"
|
// ============================================================================
|
||||||
|
// Icons
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
// ============================================================================
|
||||||
|
|
||||||
/*
|
|
||||||
* Icons
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxIcon::wxIcon()
|
wxIcon::wxIcon()
|
||||||
{
|
{
|
||||||
@@ -76,8 +64,6 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
|||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
wxBitmapHandler *handler = FindHandler(type);
|
||||||
|
|
||||||
if ( handler )
|
if ( handler )
|
||||||
@@ -86,4 +72,3 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
|||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user