]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
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: | |
f87da722 | 26 | wxIcon(const wxString& name, wxBitmapType type, |
d14a1e28 RD |
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__ | |
f87da722 | 54 | bool LoadFile(const wxString& name, wxBitmapType type); |
d14a1e28 RD |
55 | #endif |
56 | ||
57 | // wxGDIImage methods | |
58 | #ifdef __WXMSW__ | |
59 | long GetHandle(); | |
60 | void SetHandle(long handle); | |
61 | #endif | |
62 | bool Ok(); | |
63 | int GetWidth(); | |
64 | int GetHeight(); | |
65 | int GetDepth(); | |
66 | void SetWidth(int w); | |
67 | void SetHeight(int h); | |
68 | void SetDepth(int d); | |
69 | #ifdef __WXMSW__ | |
70 | void SetSize(const wxSize& size); | |
71 | #endif | |
72 | void CopyFromBitmap(const wxBitmap& bmp); | |
73 | ||
74 | %pythoncode { def __nonzero__(self): return self.Ok() } | |
75 | }; | |
76 | ||
77 | //--------------------------------------------------------------------------- | |
78 | ||
79 | class wxIconLocation | |
80 | { | |
81 | public: | |
82 | // ctor takes the name of the file where the icon is | |
83 | %extend { | |
84 | wxIconLocation(const wxString* filename = &wxPyEmptyString, int num = 0) { | |
85 | #ifdef __WXMSW__ | |
86 | return new wxIconLocation(*filename, num); | |
87 | #else | |
88 | return new wxIconLocation(*filename); | |
89 | #endif | |
90 | } | |
91 | } | |
92 | ||
93 | ~wxIconLocation(); | |
94 | ||
95 | ||
dd9f7fea | 96 | // returns True if this object is valid/initialized |
d14a1e28 RD |
97 | bool IsOk() const; |
98 | %pythoncode { def __nonzero__(self): return self.Ok() } | |
99 | ||
100 | // set/get the icon file name | |
101 | void SetFileName(const wxString& filename); | |
102 | const wxString& GetFileName() const; | |
103 | ||
104 | %extend { | |
105 | void SetIndex(int num) { | |
106 | #ifdef __WXMSW__ | |
107 | self->SetIndex(num); | |
108 | #else | |
109 | // do nothing | |
110 | #endif | |
111 | } | |
112 | ||
113 | int GetIndex() { | |
114 | #ifdef __WXMSW__ | |
115 | return self->GetIndex(); | |
116 | #else | |
117 | return -1; | |
118 | #endif | |
119 | } | |
120 | } | |
121 | }; | |
122 | ||
123 | ||
124 | ||
125 | ||
126 | //--------------------------------------------------------------------------- | |
127 | ||
128 | class wxIconBundle | |
129 | { | |
130 | public: | |
131 | // default constructor | |
132 | wxIconBundle(); | |
133 | ||
134 | // initializes the bundle with the icon(s) found in the file | |
135 | %name(IconBundleFromFile) wxIconBundle( const wxString& file, long type ); | |
136 | ||
137 | // initializes the bundle with a single icon | |
138 | %name(IconBundleFromIcon)wxIconBundle( const wxIcon& icon ); | |
139 | ||
140 | ~wxIconBundle(); | |
141 | ||
142 | // adds the icon to the collection, if the collection already | |
143 | // contains an icon with the same width and height, it is | |
144 | // replaced | |
145 | void AddIcon( const wxIcon& icon ); | |
146 | ||
147 | // adds all the icons contained in the file to the collection, | |
148 | // if the collection already contains icons with the same | |
149 | // width and height, they are replaced | |
150 | %name(AddIconFromFile)void AddIcon( const wxString& file, long type ); | |
151 | ||
152 | // returns the icon with the given size; if no such icon exists, | |
153 | // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists, | |
154 | // returns the first icon in the bundle | |
155 | const wxIcon& GetIcon( const wxSize& size ) const; | |
156 | }; | |
157 | ||
158 | //--------------------------------------------------------------------------- |