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