1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/bitmap.h"
17 class WXDLLEXPORT wxIconRefData
: public wxBitmapRefData
19 friend class WXDLLEXPORT wxBitmap
;
20 friend class WXDLLEXPORT wxIcon
;
29 #define M_ICONDATA ((wxIconRefData *)m_refData)
30 #define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
33 class WXDLLEXPORT wxIcon
: public wxBitmap
35 DECLARE_DYNAMIC_CLASS(wxIcon
)
41 inline wxIcon(const wxIcon
& icon
) { Ref(icon
); }
43 wxIcon(const char bits
[], int width
, int height
);
44 wxIcon(const wxString
& name
, long flags
= wxBITMAP_TYPE_ICO_RESOURCE
,
45 int desiredWidth
= -1, int desiredHeight
= -1);
48 bool LoadFile(const wxString
& name
, long flags
= wxBITMAP_TYPE_ICO_RESOURCE
,
49 int desiredWidth
= -1, int desiredHeight
= -1);
51 inline wxIcon
& operator = (const wxIcon
& icon
) { if (*this == icon
) return (*this); Ref(icon
); return *this; }
52 inline bool operator == (const wxIcon
& icon
) { return m_refData
== icon
.m_refData
; }
53 inline bool operator != (const wxIcon
& icon
) { return m_refData
!= icon
.m_refData
; }
55 void SetHICON(WXHICON ico
);
56 inline WXHICON
GetHICON() const { return (M_ICONDATA
? M_ICONDATA
->m_hIcon
: 0); }
58 virtual bool Ok() const { return (m_refData
!= NULL
) ; }
60 // supress virtual function hiding warning
61 virtual bool LoadFile( const wxString
& name
62 ,long type
= wxBITMAP_TYPE_BMP_RESOURCE
64 { return(wxBitmap::LoadFile(name
, type
)); };
67 // Example handlers. TODO: write your own handlers for relevant types.
69 class WXDLLEXPORT wxICOFileHandler
: public wxBitmapHandler
71 DECLARE_DYNAMIC_CLASS(wxICOFileHandler
)
73 inline wxICOFileHandler()
75 m_name
= "ICO icon file";
77 m_type
= wxBITMAP_TYPE_ICO
;
80 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
81 int desiredWidth
= -1, int desiredHeight
= -1);
84 class WXDLLEXPORT wxICOResourceHandler
: public wxBitmapHandler
86 DECLARE_DYNAMIC_CLASS(wxICOResourceHandler
)
88 inline wxICOResourceHandler()
90 m_name
= "ICO resource";
92 m_type
= wxBITMAP_TYPE_ICO_RESOURCE
;
95 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
96 int desiredWidth
= -1, int desiredHeight
= -1);