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