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
); }
47 wxIcon(const char bits
[], int width
, int height
);
48 wxIcon(const wxString
& name
, long flags
= wxBITMAP_TYPE_ICO_RESOURCE
,
49 int desiredWidth
= -1, int desiredHeight
= -1);
52 bool LoadFile(const wxString
& name
, long flags
= wxBITMAP_TYPE_ICO_RESOURCE
,
53 int desiredWidth
= -1, int desiredHeight
= -1);
55 inline wxIcon
& operator = (const wxIcon
& icon
) { if (*this == icon
) return (*this); Ref(icon
); return *this; }
56 inline bool operator == (const wxIcon
& icon
) { return m_refData
== icon
.m_refData
; }
57 inline bool operator != (const wxIcon
& icon
) { return m_refData
!= icon
.m_refData
; }
59 void SetHICON(WXHICON ico
);
60 inline WXHICON
GetHICON(void) const { return (M_ICONDATA
? M_ICONDATA
->m_hIcon
: 0); }
62 virtual bool Ok(void) const { return (m_refData
!= NULL
&& M_ICONDATA
->m_hIcon
) ; }
64 bool FreeResource(bool force
= FALSE
);
67 // TODO: Put these in separate, private header
69 class WXDLLEXPORT wxICOFileHandler
: public wxBitmapHandler
71 DECLARE_DYNAMIC_CLASS(wxICOFileHandler
)
73 inline wxICOFileHandler(void)
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(void)
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);