]> git.saurik.com Git - wxWidgets.git/blame - include/wx/iconbndl.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / iconbndl.h
CommitLineData
f618020a
MB
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/iconbndl.h
3// Purpose: wxIconBundle
4// Author: Mattia barbon
5// Modified by:
6// Created: 23.03.02
f618020a 7// Copyright: (c) Mattia Barbon
65571936 8// Licence: wxWindows licence
f618020a
MB
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_ICONBNDL_H_
12#define _WX_ICONBNDL_H_
13
52734360 14#include "wx/gdiobj.h"
b85b06e1 15#include "wx/gdicmn.h" // for wxSize
52734360 16#include "wx/icon.h"
f618020a 17
7105649b
VZ
18#include "wx/dynarray.h"
19
cee875e3
VS
20class WXDLLIMPEXP_FWD_BASE wxInputStream;
21
d2cb636a
PC
22WX_DECLARE_EXPORTED_OBJARRAY(wxIcon, wxIconArray);
23
f618020a
MB
24// this class can't load bitmaps of type wxBITMAP_TYPE_ICO_RESOURCE,
25// if you need them, you have to load them manually and call
26// wxIconCollection::AddIcon
53a2db12 27class WXDLLIMPEXP_CORE wxIconBundle : public wxGDIObject
f618020a
MB
28{
29public:
d928f019
VZ
30 // Flags that determine what happens if GetIcon() doesn't find the icon of
31 // exactly the requested size.
32 enum
33 {
34 // Return invalid icon if exact size is not found.
35 FALLBACK_NONE = 0,
36
37 // Return the icon of the system icon size if exact size is not found.
38 // May be combined with other non-NONE enum elements to determine what
39 // happens if the system icon size is not found neither.
40 FALLBACK_SYSTEM = 1,
41
42 // Return the icon of closest larger size or, if there is no icon of
43 // larger size in the bundle, the closest icon of smaller size.
44 FALLBACK_NEAREST_LARGER = 2
45 };
46
f618020a 47 // default constructor
52734360
VZ
48 wxIconBundle();
49
f618020a 50 // initializes the bundle with the icon(s) found in the file
e94be2b1 51#if wxUSE_STREAMS && wxUSE_IMAGE
89e1de64 52#if wxUSE_FFILE || wxUSE_FILE
b85b06e1 53 wxIconBundle(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY);
89e1de64 54#endif // wxUSE_FFILE || wxUSE_FILE
cee875e3 55 wxIconBundle(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY);
e94be2b1 56#endif // wxUSE_STREAMS && wxUSE_IMAGE
52734360 57
f618020a 58 // initializes the bundle with a single icon
52734360
VZ
59 wxIconBundle(const wxIcon& icon);
60
24af522c 61 // default copy ctor and assignment operator are OK
f618020a
MB
62
63 // adds all the icons contained in the file to the collection,
64 // if the collection already contains icons with the same
65 // width and height, they are replaced
e94be2b1 66#if wxUSE_STREAMS && wxUSE_IMAGE
89e1de64 67#if wxUSE_FFILE || wxUSE_FILE
b85b06e1 68 void AddIcon(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY);
89e1de64 69#endif // wxUSE_FFILE || wxUSE_FILE
cee875e3 70 void AddIcon(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY);
e94be2b1 71#endif // wxUSE_STREAMS && wxUSE_IMAGE
52734360 72
f618020a
MB
73 // adds the icon to the collection, if the collection already
74 // contains an icon with the same width and height, it is
75 // replaced
52734360 76 void AddIcon(const wxIcon& icon);
f618020a
MB
77
78 // returns the icon with the given size; if no such icon exists,
d928f019
VZ
79 // behavior is specified by the flags.
80 wxIcon GetIcon(const wxSize& size, int flags = FALLBACK_SYSTEM) const;
52734360 81
9b5933bc 82 // equivalent to GetIcon(wxSize(size, size))
d928f019
VZ
83 wxIcon GetIcon(wxCoord size = wxDefaultCoord,
84 int flags = FALLBACK_SYSTEM) const
85 { return GetIcon(wxSize(size, size), flags); }
52734360 86
9b5933bc
VZ
87 // returns the icon exactly of the specified size or wxNullIcon if no icon
88 // of exactly given size are available
89 wxIcon GetIconOfExactSize(const wxSize& size) const;
90 wxIcon GetIconOfExactSize(wxCoord size) const
91 { return GetIconOfExactSize(wxSize(size, size)); }
52734360
VZ
92
93 // enumerate all icons in the bundle: don't use these functions if ti can
94 // be avoided, using GetIcon() directly is better
95
96 // return the number of available icons
97 size_t GetIconCount() const;
98
99 // return the icon at index (must be < GetIconCount())
100 wxIcon GetIconByIndex(size_t n) const;
101
f7186899
VZ
102 // check if we have any icons at all
103 bool IsEmpty() const { return GetIconCount() == 0; }
104
831b64f3 105#if WXWIN_COMPATIBILITY_2_8
89e1de64 106#if wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE)
0ddec397
VZ
107 wxDEPRECATED( void AddIcon(const wxString& file, long type)
108 {
1473d17f 109 AddIcon(file, (wxBitmapType)type);
0ddec397
VZ
110 }
111 )
70bf3295
SC
112
113 wxDEPRECATED_CONSTRUCTOR( wxIconBundle (const wxString& file, long type)
0ddec397
VZ
114 {
115 AddIcon(file, (wxBitmapType)type);
116 }
117 )
89e1de64 118#endif // wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE)
0ddec397
VZ
119#endif // WXWIN_COMPATIBILITY_2_8
120
52734360 121protected:
8f884a0d
VZ
122 virtual wxGDIRefData *CreateGDIRefData() const;
123 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
52734360 124
f618020a
MB
125private:
126 // delete all icons
127 void DeleteIcons();
52734360
VZ
128
129 DECLARE_DYNAMIC_CLASS(wxIconBundle)
f618020a
MB
130};
131
52734360 132#endif // _WX_ICONBNDL_H_