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