]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_icon.i
Trim trailing spaces from key names when parsing
[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 class wxIcon : public wxGDIObject
24 {
25 public:
26 wxIcon(const wxString& name, wxBitmapType type,
27 int desiredWidth = -1, int desiredHeight = -1);
28 ~wxIcon();
29
30 // alternate constructors
31 %name(EmptyIcon) wxIcon();
32 %name(IconFromLocation) wxIcon(const wxIconLocation& loc);
33 %extend {
34 %name(IconFromBitmap) wxIcon(const wxBitmap& bmp) {
35 wxIcon* icon = new wxIcon();
36 icon->CopyFromBitmap(bmp);
37 return icon;
38 }
39 %name(IconFromXPMData) wxIcon(PyObject* listOfStrings) {
40 char** cArray = NULL;
41 wxIcon* icon;
42
43 cArray = ConvertListOfStrings(listOfStrings);
44 if (! cArray)
45 return NULL;
46 icon = new wxIcon(cArray);
47 delete [] cArray;
48 return icon;
49 }
50 }
51
52
53 #ifndef __WXMAC__
54 bool LoadFile(const wxString& name, wxBitmapType type);
55 #endif
56
57 // wxGDIImage methods
58 #ifdef __WXMSW__
59 long GetHandle();
60 %extend {
61 void SetHandle(long handle) { self->SetHandle((WXHANDLE)handle); }
62 }
63 #endif
64 bool Ok();
65 int GetWidth();
66 int GetHeight();
67 int GetDepth();
68 void SetWidth(int w);
69 void SetHeight(int h);
70 void SetDepth(int d);
71 #ifdef __WXMSW__
72 void SetSize(const wxSize& size);
73 #endif
74 void CopyFromBitmap(const wxBitmap& bmp);
75
76 %pythoncode { def __nonzero__(self): return self.Ok() }
77 };
78
79 //---------------------------------------------------------------------------
80
81 class wxIconLocation
82 {
83 public:
84 // ctor takes the name of the file where the icon is
85 %extend {
86 wxIconLocation(const wxString* filename = &wxPyEmptyString, int num = 0) {
87 #ifdef __WXMSW__
88 return new wxIconLocation(*filename, num);
89 #else
90 return new wxIconLocation(*filename);
91 #endif
92 }
93 }
94
95 ~wxIconLocation();
96
97
98 // returns True if this object is valid/initialized
99 bool IsOk() const;
100 %pythoncode { def __nonzero__(self): return self.Ok() }
101
102 // set/get the icon file name
103 void SetFileName(const wxString& filename);
104 const wxString& GetFileName() const;
105
106 %extend {
107 void SetIndex(int num) {
108 #ifdef __WXMSW__
109 self->SetIndex(num);
110 #else
111 // do nothing
112 #endif
113 }
114
115 int GetIndex() {
116 #ifdef __WXMSW__
117 return self->GetIndex();
118 #else
119 return -1;
120 #endif
121 }
122 }
123 };
124
125
126
127
128 //---------------------------------------------------------------------------
129
130 class wxIconBundle
131 {
132 public:
133 // default constructor
134 wxIconBundle();
135
136 // initializes the bundle with the icon(s) found in the file
137 %name(IconBundleFromFile) wxIconBundle( const wxString& file, long type );
138
139 // initializes the bundle with a single icon
140 %name(IconBundleFromIcon)wxIconBundle( const wxIcon& icon );
141
142 ~wxIconBundle();
143
144 // adds the icon to the collection, if the collection already
145 // contains an icon with the same width and height, it is
146 // replaced
147 void AddIcon( const wxIcon& icon );
148
149 // adds all the icons contained in the file to the collection,
150 // if the collection already contains icons with the same
151 // width and height, they are replaced
152 %name(AddIconFromFile)void AddIcon( const wxString& file, long type );
153
154 // returns the icon with the given size; if no such icon exists,
155 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
156 // returns the first icon in the bundle
157 const wxIcon& GetIcon( const wxSize& size ) const;
158 };
159
160 //---------------------------------------------------------------------------