]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_icon.i
memory dc must have bitmap selected into it before it can be used for measuring
[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
RD
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
83//---------------------------------------------------------------------------
84
85class wxIconLocation
86{
87public:
88 // ctor takes the name of the file where the icon is
89 %extend {
90 wxIconLocation(const wxString* filename = &wxPyEmptyString, int num = 0) {
91#ifdef __WXMSW__
92 return new wxIconLocation(*filename, num);
93#else
94 return new wxIconLocation(*filename);
95#endif
96 }
97 }
98
99 ~wxIconLocation();
100
101
dd9f7fea 102 // returns True if this object is valid/initialized
d14a1e28
RD
103 bool IsOk() const;
104 %pythoncode { def __nonzero__(self): return self.Ok() }
105
106 // set/get the icon file name
107 void SetFileName(const wxString& filename);
108 const wxString& GetFileName() const;
109
110 %extend {
111 void SetIndex(int num) {
112#ifdef __WXMSW__
113 self->SetIndex(num);
114#else
115 // do nothing
116#endif
117 }
118
119 int GetIndex() {
120#ifdef __WXMSW__
121 return self->GetIndex();
122#else
123 return -1;
124#endif
125 }
126 }
127};
128
129
130
131
132//---------------------------------------------------------------------------
133
134class wxIconBundle
135{
136public:
137 // default constructor
138 wxIconBundle();
139
140 // initializes the bundle with the icon(s) found in the file
1b8c7ba6 141 %RenameCtor(IconBundleFromFile, wxIconBundle( const wxString& file, long type ));
d14a1e28
RD
142
143 // initializes the bundle with a single icon
1b8c7ba6 144 %RenameCtor(IconBundleFromIcon, wxIconBundle( const wxIcon& icon ));
d14a1e28
RD
145
146 ~wxIconBundle();
147
148 // adds the icon to the collection, if the collection already
149 // contains an icon with the same width and height, it is
150 // replaced
151 void AddIcon( const wxIcon& icon );
152
153 // adds all the icons contained in the file to the collection,
154 // if the collection already contains icons with the same
155 // width and height, they are replaced
1b8c7ba6 156 %Rename(AddIconFromFile,void, AddIcon( const wxString& file, long type ));
d14a1e28
RD
157
158 // returns the icon with the given size; if no such icon exists,
159 // returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
160 // returns the first icon in the bundle
161 const wxIcon& GetIcon( const wxSize& size ) const;
162};
163
164//---------------------------------------------------------------------------