1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 #include "wx/msw/gdiimage.h"
20 // ---------------------------------------------------------------------------
22 // ---------------------------------------------------------------------------
24 // notice that although wxIconRefData inherits from wxBitmapRefData, it is not
25 // a valid wxBitmapRefData
26 class WXDLLIMPEXP_CORE wxIconRefData
: public wxGDIImageRefData
30 virtual ~wxIconRefData() { Free(); }
35 // ---------------------------------------------------------------------------
37 // ---------------------------------------------------------------------------
39 class WXDLLIMPEXP_CORE wxIcon
: public wxGDIImage
47 wxIcon(const char bits
[], int width
, int height
);
50 wxIcon(const char* const* data
) { CreateIconFromXpm(data
); }
52 wxIcon(char **data
) { CreateIconFromXpm(const_cast<const char* const*>(data
)); }
55 wxIcon(const wxString
& name
,
56 wxBitmapType type
= wxICON_DEFAULT_TYPE
,
57 int desiredWidth
= -1, int desiredHeight
= -1);
59 wxIcon(const wxIconLocation
& loc
);
63 virtual bool LoadFile(const wxString
& name
,
64 wxBitmapType type
= wxICON_DEFAULT_TYPE
,
65 int desiredWidth
= -1, int desiredHeight
= -1);
67 bool CreateFromHICON(WXHICON icon
);
69 // implementation only from now on
70 wxIconRefData
*GetIconData() const { return (wxIconRefData
*)m_refData
; }
72 void SetHICON(WXHICON icon
) { SetHandle((WXHANDLE
)icon
); }
73 WXHICON
GetHICON() const { return (WXHICON
)GetHandle(); }
75 // create from bitmap (which should have a mask unless it's monochrome):
76 // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
77 // ctors, assignment operators...), but it's ok to have such function
78 void CopyFromBitmap(const wxBitmap
& bmp
);
81 virtual wxGDIImageRefData
*CreateData() const
83 return new wxIconRefData
;
86 virtual wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
88 // create from XPM data
89 void CreateIconFromXpm(const char* const* data
);
92 DECLARE_DYNAMIC_CLASS(wxIcon
)