1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/bitmap.h"
17 class WXDLLIMPEXP_CORE wxIcon
: public wxGDIObject
22 wxIcon(const char* const* data
);
23 wxIcon(const char bits
[], int width
, int height
);
24 wxIcon(const wxString
& name
, wxBitmapType flags
= wxICON_DEFAULT_TYPE
,
25 int desiredWidth
= -1, int desiredHeight
= -1);
26 wxIcon(const wxIconLocation
& loc
)
28 LoadFile(loc
.GetFileName(), wxBITMAP_TYPE_ICON
);
31 wxIcon(WXHICON icon
, const wxSize
& size
);
35 bool LoadFile(const wxString
& name
, wxBitmapType flags
= wxICON_DEFAULT_TYPE
,
36 int desiredWidth
= -1, int desiredHeight
= -1);
39 // create from bitmap (which should have a mask unless it's monochrome):
40 // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
41 // ctors, assignment operators...), but it's ok to have such function
42 void CopyFromBitmap(const wxBitmap
& bmp
);
45 int GetHeight() const;
48 void SetHeight(int h
);
50 void SetOk(bool isOk
);
52 wxSize
GetSize() const { return wxSize(GetWidth(), GetHeight()); }
54 WXHICON
GetHICON() const;
57 virtual wxGDIRefData
*CreateGDIRefData() const;
58 virtual wxGDIRefData
*CloneGDIRefData(const wxGDIRefData
*data
) const;
61 DECLARE_DYNAMIC_CLASS(wxIcon
)
63 bool LoadIconFromSystemResource(const wxString
& resourceName
, int desiredWidth
, int desiredHeight
);
64 bool LoadIconFromBundleResource(const wxString
& resourceName
, int desiredWidth
, int desiredHeight
);
65 bool LoadIconFromFile(const wxString
& filename
, int desiredWidth
, int desiredHeight
);
66 bool LoadIconAsBitmap(const wxString
& filename
, wxBitmapType flags
= wxICON_DEFAULT_TYPE
, int desiredWidth
= -1, int desiredHeight
= -1);
69 class WXDLLIMPEXP_CORE wxICONResourceHandler
: public wxBitmapHandler
72 wxICONResourceHandler()
74 SetName(wxT("ICON resource"));
75 SetExtension(wxEmptyString
);
76 SetType(wxBITMAP_TYPE_ICON_RESOURCE
);
79 virtual bool LoadFile(wxBitmap
*bitmap
,
82 int desiredWidth
= -1,
83 int desiredHeight
= -1);
85 // unhide the base class virtual
86 virtual bool LoadFile(wxBitmap
*bitmap
,
89 { return LoadFile(bitmap
, name
, flags
, -1, -1); }
92 DECLARE_DYNAMIC_CLASS(wxICONResourceHandler
)