1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "icon.h"
19 #include "wx/bitmap.h"
21 class WXDLLEXPORT wxIconRefData
: public wxBitmapRefData
23 friend class WXDLLEXPORT wxBitmap
;
24 friend class WXDLLEXPORT wxIcon
;
33 #define M_ICONDATA ((wxIconRefData *)m_refData)
34 #define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
37 class WXDLLEXPORT wxIcon
: public wxBitmap
39 DECLARE_DYNAMIC_CLASS(wxIcon
)
45 inline wxIcon(const wxIcon
& icon
) { Ref(icon
); }
46 inline wxIcon(const wxIcon
* icon
) { /* UnRef(); */ if (icon
) Ref(*icon
); }
48 wxIcon(const char bits
[], int width
, int height
);
49 wxIcon(const wxString
& name
, long flags
= wxBITMAP_TYPE_ICO_RESOURCE
,
50 int desiredWidth
= -1, int desiredHeight
= -1);
53 bool LoadFile(const wxString
& name
, long flags
= wxBITMAP_TYPE_ICO_RESOURCE
,
54 int desiredWidth
= -1, int desiredHeight
= -1);
56 inline wxIcon
& operator = (const wxIcon
& icon
) { if (*this == icon
) return (*this); Ref(icon
); return *this; }
57 inline bool operator == (const wxIcon
& icon
) { return m_refData
== icon
.m_refData
; }
58 inline bool operator != (const wxIcon
& icon
) { return m_refData
!= icon
.m_refData
; }
60 void SetHICON(WXHICON ico
);
61 inline WXHICON
GetHICON(void) const { return (M_ICONDATA
? M_ICONDATA
->m_hIcon
: 0); }
63 virtual bool Ok(void) const { return (m_refData
!= NULL
&& M_ICONDATA
->m_hIcon
) ; }
65 bool FreeResource(bool force
= FALSE
);
68 // TODO: Put these in separate, private header
70 class WXDLLEXPORT wxICOFileHandler
: public wxBitmapHandler
72 DECLARE_DYNAMIC_CLASS(wxICOFileHandler
)
74 inline wxICOFileHandler(void)
76 m_name
= "ICO icon file";
78 m_type
= wxBITMAP_TYPE_ICO
;
81 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
82 int desiredWidth
= -1, int desiredHeight
= -1);
85 class WXDLLEXPORT wxICOResourceHandler
: public wxBitmapHandler
87 DECLARE_DYNAMIC_CLASS(wxICOResourceHandler
)
89 inline wxICOResourceHandler(void)
91 m_name
= "ICO resource";
93 m_type
= wxBITMAP_TYPE_ICO_RESOURCE
;
96 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
97 int desiredWidth
= -1, int desiredHeight
= -1);