]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_icon.i
Don't steal VK_RETURN for wxEVT_COMMAND_LIST_ITEM_ACTIVATED if any of
[wxWidgets.git] / wxPython / src / _icon.i
CommitLineData
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
ab1f7d2a
RD
23MustHaveApp(wxIcon);
24
d14a1e28
RD
25class wxIcon : public wxGDIObject
26{
27public:
f87da722 28 wxIcon(const wxString& name, wxBitmapType type,
d14a1e28
RD
29 int desiredWidth = -1, int desiredHeight = -1);
30 ~wxIcon();
31
32 // alternate constructors
1b8c7ba6
RD
33 %RenameCtor(EmptyIcon, wxIcon());
34 %RenameCtor(IconFromLocation, wxIcon(const wxIconLocation& loc));
d14a1e28 35 %extend {
1b8c7ba6
RD
36 %RenameCtor(IconFromBitmap, wxIcon(const wxBitmap& bmp))
37 {
d14a1e28
RD
38 wxIcon* icon = new wxIcon();
39 icon->CopyFromBitmap(bmp);
40 return icon;
41 }
1b8c7ba6
RD
42 %RenameCtor(IconFromXPMData, wxIcon(PyObject* listOfStrings))
43 {
d14a1e28
RD
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__
f87da722 58 bool LoadFile(const wxString& name, wxBitmapType type);
d14a1e28
RD
59#endif
60
61 // wxGDIImage methods
62#ifdef __WXMSW__
63 long GetHandle();
a0c956e8
RD
64 %extend {
65 void SetHandle(long handle) { self->SetHandle((WXHANDLE)handle); }
66 }
d14a1e28 67#endif
6c2dd16f
RD
68 bool IsOk();
69 %pythoncode { Ok = IsOk }
d14a1e28
RD
70 int GetWidth();
71 int GetHeight();
72 int GetDepth();
73 void SetWidth(int w);
74 void SetHeight(int h);
75 void SetDepth(int d);
76#ifdef __WXMSW__
77 void SetSize(const wxSize& size);
78#endif
79 void CopyFromBitmap(const wxBitmap& bmp);
80
6c2dd16f 81 %pythoncode { def __nonzero__(self): return self.IsOk() }
76b8fa1d
RD
82
83 %property(Depth, GetDepth, SetDepth, doc="See `GetDepth` and `SetDepth`");
84 %property(Height, GetHeight, SetHeight, doc="See `GetHeight` and `SetHeight`");
85 %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
86
d14a1e28
RD
87};
88
89//---------------------------------------------------------------------------
90
91class wxIconLocation
92{
93public:
94 // ctor takes the name of the file where the icon is
95 %extend {
96 wxIconLocation(const wxString* filename = &wxPyEmptyString, int num = 0) {
97#ifdef __WXMSW__
98 return new wxIconLocation(*filename, num);
99#else
100 return new wxIconLocation(*filename);
101#endif
102 }
103 }
104
105 ~wxIconLocation();
106
107
dd9f7fea 108 // returns True if this object is valid/initialized
d14a1e28 109 bool IsOk() const;
6c2dd16f 110 %pythoncode { def __nonzero__(self): return self.IsOk() }
d14a1e28
RD
111
112 // set/get the icon file name
113 void SetFileName(const wxString& filename);
114 const wxString& GetFileName() const;
115
116 %extend {
117 void SetIndex(int num) {
118#ifdef __WXMSW__
119 self->SetIndex(num);
120#else
121 // do nothing
122#endif
123 }
124
125 int GetIndex() {
126#ifdef __WXMSW__
127 return self->GetIndex();
128#else
129 return -1;
130#endif
131 }
132 }
76b8fa1d
RD
133
134 %property(FileName, GetFileName, SetFileName, doc="See `GetFileName` and `SetFileName`");
135 %property(Index, GetIndex, SetIndex, doc="See `GetIndex` and `SetIndex`");
136
d14a1e28
RD
137};
138
139
140
141
142//---------------------------------------------------------------------------
143
144class wxIconBundle
145{
146public:
147 // default constructor
148 wxIconBundle();
149
150 // initializes the bundle with the icon(s) found in the file
1b8c7ba6 151 %RenameCtor(IconBundleFromFile, wxIconBundle( const wxString& file, long type ));
d14a1e28
RD
152
153 // initializes the bundle with a single icon
1b8c7ba6 154 %RenameCtor(IconBundleFromIcon, wxIconBundle( const wxIcon& icon ));
d14a1e28
RD
155
156 ~wxIconBundle();
157
158 // adds the icon to the collection, if the collection already
159 // contains an icon with the same width and height, it is
160 // replaced
161 void AddIcon( const wxIcon& icon );
162
163 // adds all the icons contained in the file to the collection,
164 // if the collection already contains icons with the same
165 // width and height, they are replaced
1b8c7ba6 166 %Rename(AddIconFromFile,void, AddIcon( const wxString& file, long type ));
d14a1e28
RD
167
168 // returns the icon with the given size; if no such icon exists,
169 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
170 // returns the first icon in the bundle
171 const wxIcon& GetIcon( const wxSize& size ) const;
76b8fa1d
RD
172
173 %property(Icon, GetIcon, doc="See `GetIcon`");
d14a1e28
RD
174};
175
176//---------------------------------------------------------------------------