]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/iconbndl.h
Fix wrong tab order in wxAuiNotebook after dragging.
[wxWidgets.git] / include / wx / iconbndl.h
... / ...
CommitLineData
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
21class WXDLLIMPEXP_FWD_BASE wxInputStream;
22
23WX_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
28class WXDLLIMPEXP_CORE wxIconBundle : public wxGDIObject
29{
30public:
31 // Flags that determine what happens if GetIcon() doesn't find the icon of
32 // exactly the requested size.
33 enum
34 {
35 // Return invalid icon if exact size is not found.
36 FALLBACK_NONE = 0,
37
38 // Return the icon of the system icon size if exact size is not found.
39 // May be combined with other non-NONE enum elements to determine what
40 // happens if the system icon size is not found neither.
41 FALLBACK_SYSTEM = 1,
42
43 // Return the icon of closest larger size or, if there is no icon of
44 // larger size in the bundle, the closest icon of smaller size.
45 FALLBACK_NEAREST_LARGER = 2
46 };
47
48 // default constructor
49 wxIconBundle();
50
51 // initializes the bundle with the icon(s) found in the file
52#if wxUSE_STREAMS && wxUSE_IMAGE
53#if wxUSE_FFILE || wxUSE_FILE
54 wxIconBundle(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY);
55#endif // wxUSE_FFILE || wxUSE_FILE
56 wxIconBundle(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY);
57#endif // wxUSE_STREAMS && wxUSE_IMAGE
58
59 // initializes the bundle with a single icon
60 wxIconBundle(const wxIcon& icon);
61
62 // default copy ctor and assignment operator are OK
63
64 // adds all the icons contained in the file to the collection,
65 // if the collection already contains icons with the same
66 // width and height, they are replaced
67#if wxUSE_STREAMS && wxUSE_IMAGE
68#if wxUSE_FFILE || wxUSE_FILE
69 void AddIcon(const wxString& file, wxBitmapType type = wxBITMAP_TYPE_ANY);
70#endif // wxUSE_FFILE || wxUSE_FILE
71 void AddIcon(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY);
72#endif // wxUSE_STREAMS && wxUSE_IMAGE
73
74 // adds the icon to the collection, if the collection already
75 // contains an icon with the same width and height, it is
76 // replaced
77 void AddIcon(const wxIcon& icon);
78
79 // returns the icon with the given size; if no such icon exists,
80 // behavior is specified by the flags.
81 wxIcon GetIcon(const wxSize& size, int flags = FALLBACK_SYSTEM) const;
82
83 // equivalent to GetIcon(wxSize(size, size))
84 wxIcon GetIcon(wxCoord size = wxDefaultCoord,
85 int flags = FALLBACK_SYSTEM) const
86 { return GetIcon(wxSize(size, size), flags); }
87
88 // returns the icon exactly of the specified size or wxNullIcon if no icon
89 // of exactly given size are available
90 wxIcon GetIconOfExactSize(const wxSize& size) const;
91 wxIcon GetIconOfExactSize(wxCoord size) const
92 { return GetIconOfExactSize(wxSize(size, size)); }
93
94 // enumerate all icons in the bundle: don't use these functions if ti can
95 // be avoided, using GetIcon() directly is better
96
97 // return the number of available icons
98 size_t GetIconCount() const;
99
100 // return the icon at index (must be < GetIconCount())
101 wxIcon GetIconByIndex(size_t n) const;
102
103 // check if we have any icons at all
104 bool IsEmpty() const { return GetIconCount() == 0; }
105
106#if WXWIN_COMPATIBILITY_2_8
107#if wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE)
108 wxDEPRECATED( void AddIcon(const wxString& file, long type)
109 {
110 AddIcon(file, (wxBitmapType)type);
111 }
112 )
113
114 wxDEPRECATED_CONSTRUCTOR( wxIconBundle (const wxString& file, long type)
115 {
116 AddIcon(file, (wxBitmapType)type);
117 }
118 )
119#endif // wxUSE_STREAMS && wxUSE_IMAGE && (wxUSE_FFILE || wxUSE_FILE)
120#endif // WXWIN_COMPATIBILITY_2_8
121
122protected:
123 virtual wxGDIRefData *CreateGDIRefData() const;
124 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
125
126private:
127 // delete all icons
128 void DeleteIcons();
129
130 DECLARE_DYNAMIC_CLASS(wxIconBundle)
131};
132
133#endif // _WX_ICONBNDL_H_