1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIconBundle
4 // Author: Mattia barbon
8 // Copyright: (c) Mattia Barbon
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_ICONBNDL_H_
13 #define _WX_ICONBNDL_H_
15 #include "wx/gdiobj.h"
17 #include "wx/gdicmn.h"
20 WX_DECLARE_EXPORTED_OBJARRAY(wxIcon
, wxIconArray
);
22 // this class can't load bitmaps of type wxBITMAP_TYPE_ICO_RESOURCE,
23 // if you need them, you have to load them manually and call
24 // wxIconCollection::AddIcon
25 class WXDLLIMPEXP_CORE wxIconBundle
: public wxGDIObject
28 // default constructor
31 // initializes the bundle with the icon(s) found in the file
32 wxIconBundle(const wxString
& file
, wxBitmapType type
);
34 // initializes the bundle with a single icon
35 wxIconBundle(const wxIcon
& icon
);
37 // default copy ctor and assignment operator are OK
39 // adds all the icons contained in the file to the collection,
40 // if the collection already contains icons with the same
41 // width and height, they are replaced
42 void AddIcon(const wxString
& file
, wxBitmapType type
);
44 // adds the icon to the collection, if the collection already
45 // contains an icon with the same width and height, it is
47 void AddIcon(const wxIcon
& icon
);
49 // returns the icon with the given size; if no such icon exists,
50 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
51 // returns the first icon in the bundle
52 wxIcon
GetIcon(const wxSize
& size
) const;
54 // equivalent to GetIcon(wxSize(size, size))
55 wxIcon
GetIcon(wxCoord size
= wxDefaultCoord
) const
56 { return GetIcon(wxSize(size
, size
)); }
58 // returns the icon exactly of the specified size or wxNullIcon if no icon
59 // of exactly given size are available
60 wxIcon
GetIconOfExactSize(const wxSize
& size
) const;
61 wxIcon
GetIconOfExactSize(wxCoord size
) const
62 { return GetIconOfExactSize(wxSize(size
, size
)); }
64 // enumerate all icons in the bundle: don't use these functions if ti can
65 // be avoided, using GetIcon() directly is better
67 // return the number of available icons
68 size_t GetIconCount() const;
70 // return the icon at index (must be < GetIconCount())
71 wxIcon
GetIconByIndex(size_t n
) const;
73 // check if we have any icons at all
74 bool IsEmpty() const { return GetIconCount() == 0; }
76 #if WXWIN_COMPATIBILITY_2_8
77 wxDEPRECATED( void AddIcon(const wxString
& file
, long type
)
79 AddIcon(file
, (wxBitmapType
)type
);
83 wxDEPRECATED_CONSTRUCTOR( wxIconBundle (const wxString
& file
, long type
)
85 AddIcon(file
, (wxBitmapType
)type
);
88 #endif // WXWIN_COMPATIBILITY_2_8
91 virtual wxGDIRefData
*CreateGDIRefData() const;
92 virtual wxGDIRefData
*CloneGDIRefData(const wxGDIRefData
*data
) const;
98 DECLARE_DYNAMIC_CLASS(wxIconBundle
)
101 #endif // _WX_ICONBNDL_H_