]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: iconbndl.h | |
e54c96f1 | 3 | // Purpose: interface of wxIconBundle |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
9 | /** | |
10 | @class wxIconBundle | |
7c913512 | 11 | |
427c415b FM |
12 | This class contains multiple copies of an icon in different sizes. |
13 | It is typically used in wxDialog::SetIcons and wxTopLevelWindow::SetIcons. | |
7c913512 | 14 | |
23324ae1 | 15 | @library{wxcore} |
427c415b | 16 | @category{gdi} |
7c913512 | 17 | |
23324ae1 | 18 | @stdobjects |
65874118 | 19 | ::wxNullIconBundle |
23324ae1 FM |
20 | */ |
21 | class wxIconBundle : public wxGDIObject | |
22 | { | |
23 | public: | |
d928f019 VZ |
24 | /** |
25 | The elements of this enum determine what happens if GetIcon() doesn't | |
26 | find the icon of exactly the requested size. | |
27 | ||
28 | @since 2.9.4 | |
29 | */ | |
30 | enum | |
31 | { | |
32 | /// Return invalid icon if exact size is not found. | |
33 | FALLBACK_NONE = 0, | |
34 | ||
35 | /// Return the icon of the system icon size if exact size is not found. | |
36 | /// May be combined with other non-NONE enum elements to determine what | |
37 | /// happens if the system icon size is not found neither. | |
38 | FALLBACK_SYSTEM = 1, | |
39 | ||
40 | /// Return the icon of closest larger size or, if there is no icon of | |
41 | /// larger size in the bundle, the closest icon of smaller size. | |
42 | FALLBACK_NEAREST_LARGER = 2 | |
43 | }; | |
44 | ||
45 | ||
23324ae1 | 46 | /** |
427c415b | 47 | Default ctor. |
23324ae1 FM |
48 | */ |
49 | wxIconBundle(); | |
427c415b FM |
50 | |
51 | /** | |
52 | Initializes the bundle with the icon(s) found in the file. | |
53 | */ | |
cee875e3 VS |
54 | wxIconBundle(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY); |
55 | ||
56 | /** | |
57 | Initializes the bundle with the icon(s) found in the stream. | |
58 | ||
50b1e15e VZ |
59 | Notice that the @a stream must be seekable, at least if it contains |
60 | more than one icon. The stream pointer is positioned after the last | |
61 | icon read from the stream when this function returns. | |
62 | ||
cee875e3 VS |
63 | @since 2.9.0 |
64 | */ | |
65 | wxIconBundle(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY); | |
427c415b FM |
66 | |
67 | /** | |
68 | Initializes the bundle with a single icon. | |
69 | */ | |
7c913512 | 70 | wxIconBundle(const wxIcon& icon); |
427c415b FM |
71 | |
72 | /** | |
73 | Copy constructor. | |
74 | */ | |
7c913512 | 75 | wxIconBundle(const wxIconBundle& ic); |
23324ae1 FM |
76 | |
77 | /** | |
78 | Destructor. | |
79 | */ | |
adaaa686 | 80 | virtual ~wxIconBundle(); |
23324ae1 | 81 | |
427c415b | 82 | /** |
cee875e3 VS |
83 | Adds all the icons contained in the file to the bundle; if the |
84 | collection already contains icons with the same width and height, they | |
85 | are replaced by the new ones. | |
86 | */ | |
87 | void AddIcon(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY); | |
88 | ||
89 | /** | |
90 | Adds all the icons contained in the stream to the bundle; if the | |
91 | collection already contains icons with the same width and height, they | |
92 | are replaced by the new ones. | |
93 | ||
50b1e15e VZ |
94 | Notice that, as well as in the constructor loading the icon bundle from |
95 | stream, the @a stream must be seekable, at least if more than one icon | |
96 | is to be loaded from it. | |
97 | ||
cee875e3 | 98 | @since 2.9.0 |
427c415b | 99 | */ |
cee875e3 | 100 | void AddIcon(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY); |
427c415b | 101 | |
23324ae1 FM |
102 | /** |
103 | Adds the icon to the collection; if the collection already | |
104 | contains an icon with the same width and height, it is | |
105 | replaced by the new one. | |
106 | */ | |
7c913512 | 107 | void AddIcon(const wxIcon& icon); |
23324ae1 | 108 | |
23324ae1 | 109 | /** |
d928f019 VZ |
110 | Returns the icon with the given size. |
111 | ||
112 | If @a size is ::wxDefaultSize, it is interpreted as the standard system | |
113 | icon size, i.e. the size returned by wxSystemSettings::GetMetric() for | |
114 | @c wxSYS_ICON_X and @c wxSYS_ICON_Y. | |
115 | ||
116 | If the bundle contains an icon with exactly the requested size, it's | |
117 | always returned. Otherwise, the behaviour depends on the flags. If only | |
118 | ::FALLBACK_NONE is given, the function returns an invalid icon. If | |
119 | ::FALLBACK_SYSTEM is given, it tries to find the icon of standard | |
120 | system size, regardless of the size passed as parameter. Otherwise, or | |
121 | if the icon system size is not found neither, but | |
122 | ::FALLBACK_NEAREST_LARGER flag is specified, the function returns the | |
123 | smallest icon of the size larger than the requested one or, if this | |
124 | fails too, just the icon closest to the specified size. | |
427c415b | 125 | |
d928f019 | 126 | The @a flags parameter is available only since wxWidgets 2.9.4. |
23324ae1 | 127 | */ |
d928f019 | 128 | wxIcon GetIcon(const wxSize& size, int flags = FALLBACK_SYSTEM) const; |
427c415b FM |
129 | |
130 | /** | |
131 | Same as @code GetIcon( wxSize( size, size ) ) @endcode. | |
132 | */ | |
d928f019 VZ |
133 | wxIcon GetIcon(wxCoord size = wxDefaultCoord, |
134 | int flags = FALLBACK_SYSTEM) const; | |
23324ae1 FM |
135 | |
136 | /** | |
427c415b | 137 | Returns the icon with exactly the given size or ::wxNullIcon if this |
23324ae1 FM |
138 | size is not available. |
139 | */ | |
328f5751 | 140 | wxIcon GetIconOfExactSize(const wxSize& size) const; |
23324ae1 | 141 | |
6f9921e1 RD |
142 | /** |
143 | return the number of available icons | |
144 | */ | |
145 | size_t GetIconCount() const; | |
146 | ||
147 | /** | |
148 | return the icon at index (must be < GetIconCount()) | |
149 | */ | |
150 | wxIcon GetIconByIndex(size_t n) const; | |
151 | ||
23324ae1 | 152 | /** |
427c415b FM |
153 | Returns @true if the bundle doesn't contain any icons, @false otherwise |
154 | (in which case a call to GetIcon() with default parameter should return | |
155 | a valid icon). | |
23324ae1 | 156 | */ |
328f5751 | 157 | bool IsEmpty() const; |
23324ae1 FM |
158 | |
159 | /** | |
427c415b | 160 | Assignment operator, using @ref overview_refcount "reference counting". |
23324ae1 | 161 | */ |
43c48e1e | 162 | wxIconBundle& operator=(const wxIconBundle& ic); |
23324ae1 | 163 | |
23324ae1 | 164 | }; |
e54c96f1 FM |
165 | |
166 | ||
167 | /** | |
65874118 | 168 | An empty wxIconBundle. |
e54c96f1 FM |
169 | */ |
170 | wxIconBundle wxNullIconBundle; | |
171 | ||
172 |