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 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 // compatible (even if incorrect) behaviour by default: derive wxIcon from
25 #ifndef wxICON_IS_BITMAP
26 #define wxICON_IS_BITMAP 1
30 #include "wx/bitmap.h"
32 #define wxIconRefDataBase wxBitmapRefData
33 #define wxIconBase wxBitmap
35 #include "wx/msw/gdiimage.h"
37 #define wxIconRefDataBase wxGDIImageRefData
38 #define wxIconBase wxGDIImage
41 // ---------------------------------------------------------------------------
43 // ---------------------------------------------------------------------------
45 // notice that although wxIconRefData inherits from wxBitmapRefData, it is not
46 // a valid wxBitmapRefData
47 class WXDLLEXPORT wxIconRefData
: public wxIconRefDataBase
51 virtual ~wxIconRefData() { Free(); }
56 // ---------------------------------------------------------------------------
58 // ---------------------------------------------------------------------------
60 class WXDLLEXPORT wxIcon
: public wxIconBase
68 wxIcon(const wxIcon
& icon
) { Ref(icon
); }
71 wxIcon(const char bits
[], int width
, int height
);
73 wxIcon(const char **data
) { CreateIconFromXpm(data
); }
74 wxIcon(char **data
) { CreateIconFromXpm((const char **)data
); }
76 wxIcon(const wxString
& name
,
77 long type
= wxBITMAP_TYPE_ICO_RESOURCE
,
78 int desiredWidth
= -1, int desiredHeight
= -1);
82 virtual bool LoadFile(const wxString
& name
,
83 long type
= wxBITMAP_TYPE_ICO_RESOURCE
,
84 int desiredWidth
= -1, int desiredHeight
= -1);
86 wxIcon
& operator = (const wxIcon
& icon
)
87 { if ( *this != icon
) Ref(icon
); return *this; }
88 bool operator == (const wxIcon
& icon
) const
89 { return m_refData
== icon
.m_refData
; }
90 bool operator != (const wxIcon
& icon
) const
91 { return m_refData
!= icon
.m_refData
; }
93 wxIconRefData
*GetIconData() const { return (wxIconRefData
*)m_refData
; }
95 void SetHICON(WXHICON icon
) { SetHandle((WXHANDLE
)icon
); }
96 WXHICON
GetHICON() const { return (WXHICON
)GetHandle(); }
99 virtual wxGDIImageRefData
*CreateData() const
101 return new wxIconRefData
;
104 // create from XPM data
105 void CreateIconFromXpm(const char **data
);
107 // create from bitmap (which should have a mask unless it's monochrome)
108 void CopyFromBitmap(const wxBitmap
& bmp
);
111 DECLARE_DYNAMIC_CLASS(wxIcon
)