]>
Commit | Line | Data |
---|---|---|
f618020a MB |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/iconbndl.h | |
3 | // Purpose: wxIconBundle | |
4 | // Author: Mattia barbon | |
5 | // Modified by: | |
6 | // Created: 23.03.02 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Mattia Barbon | |
65571936 | 9 | // Licence: wxWindows licence |
f618020a MB |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_ICONBNDL_H_ | |
13 | #define _WX_ICONBNDL_H_ | |
14 | ||
32f96f74 | 15 | #include "wx/dynarray.h" |
52734360 | 16 | #include "wx/gdiobj.h" |
f618020a MB |
17 | // for wxSize |
18 | #include "wx/gdicmn.h" | |
52734360 | 19 | #include "wx/icon.h" |
f618020a | 20 | |
b5dbe15d VS |
21 | class WXDLLIMPEXP_FWD_CORE wxIcon; |
22 | class WXDLLIMPEXP_FWD_BASE wxString; | |
f618020a | 23 | |
b5dbe15d | 24 | class WXDLLIMPEXP_FWD_CORE wxIconBundle; |
52734360 VZ |
25 | |
26 | WX_DECLARE_EXPORTED_OBJARRAY(wxIcon, wxIconArray); | |
f618020a MB |
27 | |
28 | // this class can't load bitmaps of type wxBITMAP_TYPE_ICO_RESOURCE, | |
29 | // if you need them, you have to load them manually and call | |
30 | // wxIconCollection::AddIcon | |
53a2db12 | 31 | class WXDLLIMPEXP_CORE wxIconBundle : public wxGDIObject |
f618020a MB |
32 | { |
33 | public: | |
34 | // default constructor | |
52734360 VZ |
35 | wxIconBundle(); |
36 | ||
f618020a | 37 | // initializes the bundle with the icon(s) found in the file |
e98e625c | 38 | wxIconBundle(const wxString& file, wxBitmapType type); |
52734360 | 39 | |
f618020a | 40 | // initializes the bundle with a single icon |
52734360 VZ |
41 | wxIconBundle(const wxIcon& icon); |
42 | ||
43 | // initializes the bundle from another icon bundle | |
44 | wxIconBundle(const wxIconBundle& icon); | |
f618020a | 45 | |
52734360 VZ |
46 | wxIconBundle& operator=(const wxIconBundle& ic) |
47 | { if ( this != &ic) Ref(ic); return *this; } | |
48 | ||
f618020a MB |
49 | |
50 | // adds all the icons contained in the file to the collection, | |
51 | // if the collection already contains icons with the same | |
52 | // width and height, they are replaced | |
e98e625c | 53 | void AddIcon(const wxString& file, wxBitmapType type); |
52734360 | 54 | |
f618020a MB |
55 | // adds the icon to the collection, if the collection already |
56 | // contains an icon with the same width and height, it is | |
57 | // replaced | |
52734360 | 58 | void AddIcon(const wxIcon& icon); |
f618020a MB |
59 | |
60 | // returns the icon with the given size; if no such icon exists, | |
61 | // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists, | |
62 | // returns the first icon in the bundle | |
52734360 VZ |
63 | wxIcon GetIcon(const wxSize& size) const; |
64 | ||
9b5933bc | 65 | // equivalent to GetIcon(wxSize(size, size)) |
52734360 | 66 | wxIcon GetIcon(wxCoord size = wxDefaultCoord) const |
9b5933bc | 67 | { return GetIcon(wxSize(size, size)); } |
52734360 | 68 | |
9b5933bc VZ |
69 | // returns the icon exactly of the specified size or wxNullIcon if no icon |
70 | // of exactly given size are available | |
71 | wxIcon GetIconOfExactSize(const wxSize& size) const; | |
72 | wxIcon GetIconOfExactSize(wxCoord size) const | |
73 | { return GetIconOfExactSize(wxSize(size, size)); } | |
52734360 VZ |
74 | |
75 | // enumerate all icons in the bundle: don't use these functions if ti can | |
76 | // be avoided, using GetIcon() directly is better | |
77 | ||
78 | // return the number of available icons | |
79 | size_t GetIconCount() const; | |
80 | ||
81 | // return the icon at index (must be < GetIconCount()) | |
82 | wxIcon GetIconByIndex(size_t n) const; | |
83 | ||
f7186899 VZ |
84 | // check if we have any icons at all |
85 | bool IsEmpty() const { return GetIconCount() == 0; } | |
86 | ||
52734360 | 87 | protected: |
8f884a0d VZ |
88 | virtual wxGDIRefData *CreateGDIRefData() const; |
89 | virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const; | |
52734360 | 90 | |
f618020a MB |
91 | private: |
92 | // delete all icons | |
93 | void DeleteIcons(); | |
52734360 VZ |
94 | |
95 | DECLARE_DYNAMIC_CLASS(wxIconBundle) | |
f618020a MB |
96 | }; |
97 | ||
52734360 | 98 | #endif // _WX_ICONBNDL_H_ |