1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/msw/gdiimage.h"
21 // ---------------------------------------------------------------------------
23 // ---------------------------------------------------------------------------
25 // notice that although wxIconRefData inherits from wxBitmapRefData, it is not
26 // a valid wxBitmapRefData
27 class WXDLLIMPEXP_CORE wxIconRefData
: public wxGDIImageRefData
31 virtual ~wxIconRefData() { Free(); }
36 // ---------------------------------------------------------------------------
38 // ---------------------------------------------------------------------------
40 class WXDLLIMPEXP_CORE wxIcon
: public wxGDIImage
48 wxIcon(const char bits
[], int width
, int height
);
51 wxIcon(const char* const* data
) { CreateIconFromXpm(data
); }
53 wxIcon(char **data
) { CreateIconFromXpm(const_cast<const char* const*>(data
)); }
56 wxIcon(const wxString
& name
,
57 wxBitmapType type
= wxICON_DEFAULT_TYPE
,
58 int desiredWidth
= -1, int desiredHeight
= -1);
60 wxIcon(const wxIconLocation
& loc
);
64 virtual bool LoadFile(const wxString
& name
,
65 wxBitmapType type
= wxICON_DEFAULT_TYPE
,
66 int desiredWidth
= -1, int desiredHeight
= -1);
68 bool CreateFromHICON(WXHICON icon
);
70 // implementation only from now on
71 wxIconRefData
*GetIconData() const { return (wxIconRefData
*)m_refData
; }
73 void SetHICON(WXHICON icon
) { SetHandle((WXHANDLE
)icon
); }
74 WXHICON
GetHICON() const { return (WXHICON
)GetHandle(); }
76 // create from bitmap (which should have a mask unless it's monochrome):
77 // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
78 // ctors, assignment operators...), but it's ok to have such function
79 void CopyFromBitmap(const wxBitmap
& bmp
);
82 virtual wxGDIImageRefData
*CreateData() const
84 return new wxIconRefData
;
87 virtual wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
89 // create from XPM data
90 void CreateIconFromXpm(const char* const* data
);
93 DECLARE_DYNAMIC_CLASS(wxIcon
)