]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_icon.i
More bakfile changes needed for bmpcbox. Rebaked.
[wxWidgets.git] / wxPython / src / _icon.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _icon.i
3 // Purpose: SWIG interface for wxIcon and related classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7-July-1997
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17 %{
18 #include <wx/iconbndl.h>
19 %}
20 //---------------------------------------------------------------------------
21
22
23 MustHaveApp(wxIcon);
24
25 class wxIcon : public wxGDIObject
26 {
27 public:
28 wxIcon(const wxString& name, wxBitmapType type,
29 int desiredWidth = -1, int desiredHeight = -1);
30 ~wxIcon();
31
32 // alternate constructors
33 %RenameCtor(EmptyIcon, wxIcon());
34 %RenameCtor(IconFromLocation, wxIcon(const wxIconLocation& loc));
35 %extend {
36 %RenameCtor(IconFromBitmap, wxIcon(const wxBitmap& bmp))
37 {
38 wxIcon* icon = new wxIcon();
39 icon->CopyFromBitmap(bmp);
40 return icon;
41 }
42 %RenameCtor(IconFromXPMData, wxIcon(PyObject* listOfStrings))
43 {
44 char** cArray = NULL;
45 wxIcon* icon;
46
47 cArray = ConvertListOfStrings(listOfStrings);
48 if (! cArray)
49 return NULL;
50 icon = new wxIcon(cArray);
51 delete [] cArray;
52 return icon;
53 }
54 }
55
56
57 #ifndef __WXMAC__
58 bool LoadFile(const wxString& name, wxBitmapType type);
59 #endif
60
61 // wxGDIImage methods
62 #ifdef __WXMSW__
63 long GetHandle();
64 %extend {
65 void SetHandle(long handle) { self->SetHandle((WXHANDLE)handle); }
66 }
67 #endif
68 bool Ok();
69 int GetWidth();
70 int GetHeight();
71 int GetDepth();
72 void SetWidth(int w);
73 void SetHeight(int h);
74 void SetDepth(int d);
75 #ifdef __WXMSW__
76 void SetSize(const wxSize& size);
77 #endif
78 void CopyFromBitmap(const wxBitmap& bmp);
79
80 %pythoncode { def __nonzero__(self): return self.Ok() }
81
82 %property(Depth, GetDepth, SetDepth, doc="See `GetDepth` and `SetDepth`");
83 %property(Height, GetHeight, SetHeight, doc="See `GetHeight` and `SetHeight`");
84 %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
85
86 };
87
88 //---------------------------------------------------------------------------
89
90 class wxIconLocation
91 {
92 public:
93 // ctor takes the name of the file where the icon is
94 %extend {
95 wxIconLocation(const wxString* filename = &wxPyEmptyString, int num = 0) {
96 #ifdef __WXMSW__
97 return new wxIconLocation(*filename, num);
98 #else
99 return new wxIconLocation(*filename);
100 #endif
101 }
102 }
103
104 ~wxIconLocation();
105
106
107 // returns True if this object is valid/initialized
108 bool IsOk() const;
109 %pythoncode { def __nonzero__(self): return self.Ok() }
110
111 // set/get the icon file name
112 void SetFileName(const wxString& filename);
113 const wxString& GetFileName() const;
114
115 %extend {
116 void SetIndex(int num) {
117 #ifdef __WXMSW__
118 self->SetIndex(num);
119 #else
120 // do nothing
121 #endif
122 }
123
124 int GetIndex() {
125 #ifdef __WXMSW__
126 return self->GetIndex();
127 #else
128 return -1;
129 #endif
130 }
131 }
132
133 %property(FileName, GetFileName, SetFileName, doc="See `GetFileName` and `SetFileName`");
134 %property(Index, GetIndex, SetIndex, doc="See `GetIndex` and `SetIndex`");
135
136 };
137
138
139
140
141 //---------------------------------------------------------------------------
142
143 class wxIconBundle
144 {
145 public:
146 // default constructor
147 wxIconBundle();
148
149 // initializes the bundle with the icon(s) found in the file
150 %RenameCtor(IconBundleFromFile, wxIconBundle( const wxString& file, long type ));
151
152 // initializes the bundle with a single icon
153 %RenameCtor(IconBundleFromIcon, wxIconBundle( const wxIcon& icon ));
154
155 ~wxIconBundle();
156
157 // adds the icon to the collection, if the collection already
158 // contains an icon with the same width and height, it is
159 // replaced
160 void AddIcon( const wxIcon& icon );
161
162 // adds all the icons contained in the file to the collection,
163 // if the collection already contains icons with the same
164 // width and height, they are replaced
165 %Rename(AddIconFromFile,void, AddIcon( const wxString& file, long type ));
166
167 // returns the icon with the given size; if no such icon exists,
168 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
169 // returns the first icon in the bundle
170 const wxIcon& GetIcon( const wxSize& size ) const;
171
172 %property(Icon, GetIcon, doc="See `GetIcon`");
173 };
174
175 //---------------------------------------------------------------------------