Add wxDEPRECATED_MSG() and use it in a couple of places.
[wxWidgets.git] / include / wx / iconbndl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/iconbndl.h
3 // Purpose: wxIconBundle
4 // Author: Mattia barbon
5 // Modified by:
6 // Created: 23.03.02
7 // Copyright: (c) Mattia Barbon
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_ICONBNDL_H_
12 #define _WX_ICONBNDL_H_
13
14 #include "wx/gdiobj.h"
15 #include "wx/gdicmn.h" // for wxSize
16 #include "wx/icon.h"
17
18 #include "wx/dynarray.h"
19
20 class WXDLLIMPEXP_FWD_BASE wxInputStream;
21
22 WX_DECLARE_EXPORTED_OBJARRAY(wxIcon, wxIconArray);
23
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
28 {
29 public:
30 // Flags that determine what happens if GetIcon() doesn't find the icon of
31 // exactly the requested size.
32 enum
33 {
34 // Return invalid icon if exact size is not found.
35 FALLBACK_NONE = 0,
36
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.
40 FALLBACK_SYSTEM = 1,
41
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
45 };
46
47 // default constructor
48 wxIconBundle();
49
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
57
58 // initializes the bundle with a single icon
59 wxIconBundle(const wxIcon& icon);
60
61 // default copy ctor and assignment operator are OK
62
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
72
73 // adds the icon to the collection, if the collection already
74 // contains an icon with the same width and height, it is
75 // replaced
76 void AddIcon(const wxIcon& icon);
77
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;
81
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); }
86
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)); }
92
93 // enumerate all icons in the bundle: don't use these functions if ti can
94 // be avoided, using GetIcon() directly is better
95
96 // return the number of available icons
97 size_t GetIconCount() const;
98
99 // return the icon at index (must be < GetIconCount())
100 wxIcon GetIconByIndex(size_t n) const;
101
102 // check if we have any icons at all
103 bool IsEmpty() const { return GetIconCount() == 0; }
104
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)
108 {
109 AddIcon(file, (wxBitmapType)type);
110 }
111 )
112
113 wxDEPRECATED_CONSTRUCTOR( wxIconBundle (const wxString& file, long type)
114 {
115 AddIcon(file, (wxBitmapType)type);
116 }
117 )
118 #endif // wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE)
119 #endif // WXWIN_COMPATIBILITY_2_8
120
121 protected:
122 virtual wxGDIRefData *CreateGDIRefData() const;
123 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
124
125 private:
126 // delete all icons
127 void DeleteIcons();
128
129 DECLARE_DYNAMIC_CLASS(wxIconBundle)
130 };
131
132 #endif // _WX_ICONBNDL_H_