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 // ---------------------------------------------------------------------------
23 // ---------------------------------------------------------------------------
24 class WXDLLEXPORT wxIconRefData
: public wxBitmapRefData
26 friend class WXDLLEXPORT wxBitmap
;
27 friend class WXDLLEXPORT wxIcon
;
37 #define M_ICONDATA ((wxIconRefData *)m_refData)
38 #define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
40 // ---------------------------------------------------------------------------
42 // ---------------------------------------------------------------------------
43 class WXDLLEXPORT wxIcon
: public wxBitmap
45 DECLARE_DYNAMIC_CLASS(wxIcon
)
51 wxIcon(const wxIcon
& icon
) { Ref(icon
); }
53 wxIcon(const char bits
[], int width
, int height
);
54 wxIcon(const wxString
& name
, long flags
= wxBITMAP_TYPE_ICO_RESOURCE
,
55 int desiredWidth
= -1, int desiredHeight
= -1);
58 bool LoadFile(const wxString
& name
, long flags
= wxBITMAP_TYPE_ICO_RESOURCE
,
59 int desiredWidth
= -1, int desiredHeight
= -1);
61 wxIcon
& operator = (const wxIcon
& icon
)
62 { if (*this == icon
) return (*this); Ref(icon
); return *this; }
63 bool operator == (const wxIcon
& icon
) const
64 { return m_refData
== icon
.m_refData
; }
65 bool operator != (const wxIcon
& icon
) const
66 { return m_refData
!= icon
.m_refData
; }
68 void SetHICON(WXHICON ico
);
69 WXHICON
GetHICON() const { return (M_ICONDATA
? M_ICONDATA
->m_hIcon
: 0); }
71 bool Ok() const { return (m_refData
!= NULL
&& M_ICONDATA
->m_hIcon
!= 0) ; }
73 bool FreeResource(bool force
= FALSE
);
76 // TODO: Put these in separate, private header
78 class WXDLLEXPORT wxICOFileHandler
: public wxBitmapHandler
80 DECLARE_DYNAMIC_CLASS(wxICOFileHandler
)
85 m_name
= "ICO icon file";
87 m_type
= wxBITMAP_TYPE_ICO
;
90 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
91 int desiredWidth
= -1, int desiredHeight
= -1);
94 class WXDLLEXPORT wxICOResourceHandler
: public wxBitmapHandler
96 DECLARE_DYNAMIC_CLASS(wxICOResourceHandler
)
99 wxICOResourceHandler()
101 m_name
= "ICO resource";
103 m_type
= wxBITMAP_TYPE_ICO_RESOURCE
;
106 virtual bool LoadFile(wxBitmap
*bitmap
, const wxString
& name
, long flags
,
107 int desiredWidth
= -1, int desiredHeight
= -1);