1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIconBundle
4 // Author: Mattia barbon
7 // Copyright: (c) Mattia Barbon
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_ICONBNDL_H_
12 #define _WX_ICONBNDL_H_
14 #include "wx/gdiobj.h"
15 #include "wx/gdicmn.h" // for wxSize
18 #include "wx/dynarray.h"
20 class WXDLLIMPEXP_FWD_BASE wxInputStream
;
22 WX_DECLARE_EXPORTED_OBJARRAY(wxIcon
, wxIconArray
);
24 // this class can't load bitmaps of type wxBITMAP_TYPE_ICO_RESOURCE,
25 // if you need them, you have to load them manually and call
26 // wxIconCollection::AddIcon
27 class WXDLLIMPEXP_CORE wxIconBundle
: public wxGDIObject
30 // Flags that determine what happens if GetIcon() doesn't find the icon of
31 // exactly the requested size.
34 // Return invalid icon if exact size is not found.
37 // Return the icon of the system icon size if exact size is not found.
38 // May be combined with other non-NONE enum elements to determine what
39 // happens if the system icon size is not found neither.
42 // Return the icon of closest larger size or, if there is no icon of
43 // larger size in the bundle, the closest icon of smaller size.
44 FALLBACK_NEAREST_LARGER
= 2
47 // default constructor
50 // initializes the bundle with the icon(s) found in the file
51 #if wxUSE_STREAMS && wxUSE_IMAGE
52 #if wxUSE_FFILE || wxUSE_FILE
53 wxIconBundle(const wxString
& file
, wxBitmapType type
= wxBITMAP_TYPE_ANY
);
54 #endif // wxUSE_FFILE || wxUSE_FILE
55 wxIconBundle(wxInputStream
& stream
, wxBitmapType type
= wxBITMAP_TYPE_ANY
);
56 #endif // wxUSE_STREAMS && wxUSE_IMAGE
58 // initializes the bundle with a single icon
59 wxIconBundle(const wxIcon
& icon
);
61 // default copy ctor and assignment operator are OK
63 // adds all the icons contained in the file to the collection,
64 // if the collection already contains icons with the same
65 // width and height, they are replaced
66 #if wxUSE_STREAMS && wxUSE_IMAGE
67 #if wxUSE_FFILE || wxUSE_FILE
68 void AddIcon(const wxString
& file
, wxBitmapType type
= wxBITMAP_TYPE_ANY
);
69 #endif // wxUSE_FFILE || wxUSE_FILE
70 void AddIcon(wxInputStream
& stream
, wxBitmapType type
= wxBITMAP_TYPE_ANY
);
71 #endif // wxUSE_STREAMS && wxUSE_IMAGE
73 // adds the icon to the collection, if the collection already
74 // contains an icon with the same width and height, it is
76 void AddIcon(const wxIcon
& icon
);
78 // returns the icon with the given size; if no such icon exists,
79 // behavior is specified by the flags.
80 wxIcon
GetIcon(const wxSize
& size
, int flags
= FALLBACK_SYSTEM
) const;
82 // equivalent to GetIcon(wxSize(size, size))
83 wxIcon
GetIcon(wxCoord size
= wxDefaultCoord
,
84 int flags
= FALLBACK_SYSTEM
) const
85 { return GetIcon(wxSize(size
, size
), flags
); }
87 // returns the icon exactly of the specified size or wxNullIcon if no icon
88 // of exactly given size are available
89 wxIcon
GetIconOfExactSize(const wxSize
& size
) const;
90 wxIcon
GetIconOfExactSize(wxCoord size
) const
91 { return GetIconOfExactSize(wxSize(size
, size
)); }
93 // enumerate all icons in the bundle: don't use these functions if ti can
94 // be avoided, using GetIcon() directly is better
96 // return the number of available icons
97 size_t GetIconCount() const;
99 // return the icon at index (must be < GetIconCount())
100 wxIcon
GetIconByIndex(size_t n
) const;
102 // check if we have any icons at all
103 bool IsEmpty() const { return GetIconCount() == 0; }
105 #if WXWIN_COMPATIBILITY_2_8
106 #if wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE)
107 wxDEPRECATED( void AddIcon(const wxString
& file
, long type
)
109 AddIcon(file
, (wxBitmapType
)type
);
113 wxDEPRECATED_CONSTRUCTOR( wxIconBundle (const wxString
& file
, long type
)
115 AddIcon(file
, (wxBitmapType
)type
);
118 #endif // wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE)
119 #endif // WXWIN_COMPATIBILITY_2_8
122 virtual wxGDIRefData
*CreateGDIRefData() const;
123 virtual wxGDIRefData
*CloneGDIRefData(const wxGDIRefData
*data
) const;
129 DECLARE_DYNAMIC_CLASS(wxIconBundle
)
132 #endif // _WX_ICONBNDL_H_