Mercurial > fife-parpg
comparison engine/core/gui/widgets/widgets.i @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 6387bbc0c2d5 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2008 by the FIFE team * | |
3 * http://www.fifengine.de * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE is free software; you can redistribute it and/or modify * | |
7 * it under the terms of the GNU General Public License as published by * | |
8 * the Free Software Foundation; either version 2 of the License, or * | |
9 * (at your option) any later version. * | |
10 * * | |
11 * This program is distributed in the hope that it will be useful, * | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 * GNU General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 %module fife | |
23 %{ | |
24 #include <guichan.hpp> | |
25 #include "gui/widgets/twobutton.h" | |
26 #include "gui/widgets/clicklabel.h" | |
27 #include "gui/widgets/icon2.hpp" | |
28 %} | |
29 | |
30 namespace gcn { | |
31 class Font; | |
32 class Image; | |
33 class ActionListener; | |
34 | |
35 %nodefaultctor; | |
36 class Graphics { | |
37 public: | |
38 enum Alignmnet { | |
39 LEFT = 0, | |
40 CENTER, | |
41 RIGHT | |
42 }; | |
43 }; | |
44 %clearnodefaultctor; | |
45 | |
46 | |
47 class Color { | |
48 public: | |
49 Color(); | |
50 Color(int color); | |
51 Color(int r, int g, int b, int a = 255); | |
52 Color operator+(const Color& color) const; | |
53 Color operator-(const Color& color) const; | |
54 Color operator*(float value) const; | |
55 bool operator==(const Color& color) const; | |
56 bool operator!=(const Color& color) const; | |
57 int r; | |
58 int g; | |
59 int b; | |
60 int a; | |
61 }; | |
62 | |
63 class Widget { | |
64 public: | |
65 /* Widget(); */ | |
66 /* virtual ~Widget(); */ | |
67 virtual void setWidth(int width); | |
68 virtual int getWidth() const; | |
69 virtual void setHeight(int height); | |
70 virtual int getHeight() const; | |
71 virtual void setSize(int width, int height); | |
72 virtual void setX(int x); | |
73 virtual int getX() const; | |
74 virtual void setY(int y); | |
75 virtual int getY() const; | |
76 virtual void setPosition(int x, int y); | |
77 virtual void setFrameSize(unsigned int frameSize); | |
78 virtual unsigned int getFrameSize() const; | |
79 virtual void setFocusable(bool focusable); | |
80 virtual bool isFocusable() const; | |
81 virtual bool isFocused() const; | |
82 virtual void setEnabled(bool enabled); | |
83 virtual bool isEnabled() const; | |
84 virtual void setVisible(bool visible); | |
85 virtual bool isVisible() const; | |
86 virtual void setBaseColor(const Color& color); | |
87 virtual const Color& getBaseColor() const; | |
88 virtual void setForegroundColor(const Color& color); | |
89 virtual const Color& getForegroundColor() const; | |
90 virtual void setBackgroundColor(const Color& color); | |
91 virtual const Color& getBackgroundColor() const; | |
92 virtual void requestFocus(); | |
93 virtual void requestMoveToTop(); | |
94 virtual void requestMoveToBottom(); | |
95 virtual void setActionEventId(const std::string& actionEventId); | |
96 virtual const std::string& getActionEventId() const; | |
97 virtual void getAbsolutePosition(int& x, int& y) const; | |
98 Font *getFont() const; | |
99 static void setGlobalFont(Font* font); | |
100 virtual void setFont(Font* font); | |
101 virtual bool isTabInEnabled() const; | |
102 virtual void setTabInEnabled(bool enabled); | |
103 virtual bool isTabOutEnabled() const; | |
104 virtual void setTabOutEnabled(bool enabled); | |
105 virtual void requestModalFocus(); | |
106 virtual void requestModalMouseInputFocus(); | |
107 virtual void releaseModalFocus(); | |
108 virtual void releaseModalMouseInputFocus(); | |
109 virtual bool isModalFocused() const; | |
110 virtual bool isModalMouseInputFocused() const; | |
111 virtual Widget *getWidgetAt(int x, int y); | |
112 virtual void moveToTop(Widget* widget) { }; | |
113 virtual void moveToBottom(Widget* widget) { }; | |
114 virtual void focusNext() { }; | |
115 virtual void focusPrevious() { }; | |
116 virtual void addActionListener(ActionListener* actionListener); | |
117 /* protected: */ | |
118 virtual void draw(Graphics* graphics) = 0; | |
119 }; | |
120 | |
121 %feature("notabstract") Container; | |
122 class Container: public Widget { | |
123 public: | |
124 Container(); | |
125 virtual ~Container(); | |
126 virtual void setOpaque(bool opaque); | |
127 virtual bool isOpaque() const; | |
128 virtual void add(Widget* widget); | |
129 virtual void add(Widget* widget, int x, int y); | |
130 virtual void remove(Widget* widget); | |
131 virtual void clear(); | |
132 }; | |
133 | |
134 %feature("notabstract") CheckBox; | |
135 class CheckBox: public Widget { | |
136 public: | |
137 CheckBox(); | |
138 virtual ~CheckBox(); | |
139 virtual bool isSelected() const; | |
140 virtual void setSelected(bool marked); | |
141 virtual const std::string &getCaption() const; | |
142 virtual void setCaption(const std::string& caption); | |
143 virtual void adjustSize(); | |
144 }; | |
145 | |
146 %feature("notabstract") TextField; | |
147 class TextField: public Widget { | |
148 public: | |
149 TextField(); | |
150 TextField(const std::string& text); | |
151 virtual void setText(const std::string& text); | |
152 virtual const std::string& getText() const; | |
153 virtual void adjustSize(); | |
154 virtual void adjustHeight(); | |
155 virtual void setCaretPosition(unsigned int position); | |
156 virtual unsigned int getCaretPosition() const; | |
157 }; | |
158 | |
159 %feature("notabstract") Button; | |
160 class Button: public Widget { | |
161 public: | |
162 Button(); | |
163 Button(const std::string& caption); | |
164 virtual void setCaption(const std::string& caption); | |
165 virtual const std::string& getCaption() const; | |
166 virtual void setAlignment(Graphics::Alignment alignment); | |
167 virtual Graphics::Alignment getAlignment() const; | |
168 virtual void adjustSize(); | |
169 /*virtual bool isPressed() const;*/ | |
170 }; | |
171 | |
172 | |
173 class TwoButton; | |
174 %feature("director") TwoButtonListener; | |
175 class TwoButtonListener { | |
176 public: | |
177 virtual ~TwoButtonListener(); | |
178 virtual void mouseEntered(TwoButton& btn) = 0; | |
179 virtual void mouseExited(TwoButton& btn) = 0; | |
180 }; | |
181 | |
182 %feature("notabstract") TwoButton; | |
183 class TwoButton: public Widget { | |
184 public: | |
185 TwoButton(Image *up_image = 0, Image *down_image = 0, Image *hover_image = 0, const char * caption = ""); | |
186 ~TwoButton(); | |
187 virtual void setCaption(const std::string& caption); | |
188 virtual const std::string& getCaption() const; | |
189 virtual void setAlignment(Graphics::Alignment alignment); | |
190 virtual Graphics::Alignment getAlignment() const; | |
191 void setUpImage(Image* image); | |
192 void setDownImage(Image* image); | |
193 void setHoverImage(Image* image); | |
194 void setDownOffset(int x, int y); | |
195 int getDownXOffset(); | |
196 int getDownYOffset(); | |
197 void setListener(TwoButtonListener* listener); | |
198 TwoButtonListener* getListener(); | |
199 | |
200 void setHelpText(const std::string& txt); | |
201 const std::string& getHelpText(); | |
202 }; | |
203 | |
204 %feature("notabstract") ScrollArea; | |
205 class ScrollArea: public Widget { | |
206 public: | |
207 ScrollArea(); | |
208 ScrollArea(Widget *content); | |
209 ScrollArea(Widget *content,ScrollArea::ScrollPolicy hPolicy,ScrollArea::ScrollPolicy vPolicy); | |
210 virtual ~ScrollArea(); | |
211 virtual void setContent(Widget* widget); | |
212 virtual Widget* getContent(); | |
213 virtual void setHorizontalScrollPolicy(ScrollArea::ScrollPolicy hPolicy); | |
214 virtual ScrollArea::ScrollPolicy getHorizontalScrollPolicy(); | |
215 virtual void setVerticalScrollPolicy(ScrollArea::ScrollPolicy vPolicy); | |
216 virtual ScrollArea::ScrollPolicy getVerticalScrollPolicy(); | |
217 virtual void setScrollPolicy(ScrollArea::ScrollPolicy hPolicy, ScrollArea::ScrollPolicy vPolicy); | |
218 virtual void setVerticalScrollAmount(int vScroll); | |
219 virtual int getVerticalScrollAmount(); | |
220 virtual void setHorizontalScrollAmount(int hScroll); | |
221 virtual int getHorizontalScrollAmount(); | |
222 virtual void setScrollAmount(int hScroll, int vScroll); | |
223 virtual int getHorizontalMaxScroll(); | |
224 virtual int getVerticalMaxScroll(); | |
225 virtual void setScrollbarWidth(int width); | |
226 virtual int getScrollbarWidth(); | |
227 virtual void setLeftButtonScrollAmount(int amount); | |
228 virtual void setRightButtonScrollAmount(int amount); | |
229 virtual void setUpButtonScrollAmount(int amount); | |
230 virtual void setDownButtonScrollAmount(int amount); | |
231 virtual int getLeftButtonScrollAmount(); | |
232 virtual int getRightButtonScrollAmount(); | |
233 virtual int getUpButtonScrollAmount(); | |
234 virtual int getDownButtonScrollAmount(); | |
235 enum ScrollPolicy | |
236 { | |
237 SHOW_ALWAYS, | |
238 SHOW_NEVER, | |
239 SHOW_AUTO | |
240 }; | |
241 }; | |
242 | |
243 | |
244 %feature("notabstract") TextBox; | |
245 class TextBox: public Widget { | |
246 public: | |
247 TextBox(); | |
248 TextBox(const std::string& text); | |
249 virtual void setText(const std::string& text); | |
250 virtual std::string getText() const; | |
251 virtual const std::string& getTextRow(int row) const; | |
252 virtual void setTextRow(int row, const std::string& text); | |
253 virtual unsigned int getNumberOfRows() const; | |
254 virtual unsigned int getCaretPosition() const; | |
255 virtual void setCaretPosition(unsigned int position); | |
256 virtual unsigned int getCaretRow() const; | |
257 virtual void setCaretRow(int row); | |
258 virtual unsigned int getCaretColumn() const; | |
259 virtual void setCaretColumn(int column); | |
260 virtual void setCaretRowColumn(int row, int column); | |
261 virtual void scrollToCaret(); | |
262 virtual bool isEditable() const; | |
263 virtual void setEditable(bool editable); | |
264 virtual void addRow(const std::string row); | |
265 virtual bool isOpaque(); | |
266 virtual void setOpaque(bool opaque); | |
267 }; | |
268 | |
269 %feature("director") ListModel; | |
270 class ListModel | |
271 { | |
272 public: | |
273 virtual ~ListModel() { } | |
274 virtual int getNumberOfElements() = 0; | |
275 virtual std::string getElementAt(int i) = 0; | |
276 }; | |
277 | |
278 %feature("notabstract") ListBox; | |
279 class ListBox: public Widget { | |
280 public: | |
281 ListBox(); | |
282 ListBox(ListModel *listModel); | |
283 virtual ~ListBox() { } | |
284 virtual int getSelected(); | |
285 virtual void setSelected(int selected); | |
286 virtual void setListModel(ListModel *listModel); | |
287 virtual ListModel *getListModel(); | |
288 virtual void adjustSize(); | |
289 virtual bool isWrappingEnabled(); | |
290 virtual void setWrappingEnabled(bool wrapping); | |
291 }; | |
292 | |
293 %feature("notabstract") DropDown; | |
294 class DropDown: public Widget { | |
295 public: | |
296 DropDown(ListModel *listModel = NULL, | |
297 ScrollArea *scrollArea = NULL, | |
298 ListBox *listBox = NULL); | |
299 virtual ~DropDown(); | |
300 virtual int getSelected(); | |
301 virtual void setSelected(int selected); | |
302 virtual void setListModel(ListModel *listModel); | |
303 virtual ListModel *getListModel(); | |
304 virtual void adjustHeight(); | |
305 }; | |
306 | |
307 %feature("notabstract") RadioButton; | |
308 class RadioButton: public Widget { | |
309 public: | |
310 RadioButton(); | |
311 RadioButton(const std::string &caption, | |
312 const std::string &group, | |
313 bool marked=false); | |
314 virtual ~RadioButton(); | |
315 virtual bool isSelected() const; | |
316 virtual void setSelected(bool marked); | |
317 virtual const std::string &getCaption() const; | |
318 virtual void setCaption(const std::string caption); | |
319 virtual void setGroup(const std::string &group); | |
320 virtual const std::string &getGroup() const; | |
321 virtual void adjustSize(); | |
322 }; | |
323 | |
324 %feature("notabstract") Slider; | |
325 class Slider: public Widget { | |
326 public: | |
327 Slider(double scaleEnd = 1.0); | |
328 Slider(double scaleStart, double scaleEnd); | |
329 virtual ~Slider() { } | |
330 virtual void setScale(double scaleStart, double scaleEnd); | |
331 virtual double getScaleStart() const; | |
332 virtual void setScaleStart(double scaleStart); | |
333 virtual double getScaleEnd() const; | |
334 virtual void setScaleEnd(double scaleEnd); | |
335 virtual double getValue() const; | |
336 virtual void setValue(double value); | |
337 virtual void setMarkerLength(int length); | |
338 virtual int getMarkerLength() const; | |
339 virtual void setOrientation(Slider::Orientation orientation); | |
340 virtual Slider::Orientation getOrientation() const; | |
341 virtual void setStepLength(double length); | |
342 virtual double getStepLength() const; | |
343 enum Orientation | |
344 { | |
345 HORIZONTAL = 0, | |
346 VERTICAL | |
347 }; | |
348 }; | |
349 | |
350 %feature("notabstract") Window; | |
351 class Window: public Container { | |
352 public: | |
353 Window(); | |
354 Window(const std::string& caption); | |
355 virtual ~Window(); | |
356 virtual void setCaption(const std::string& caption); | |
357 virtual const std::string& getCaption() const; | |
358 virtual void setAlignment(Graphics::Alignment alignment); | |
359 virtual Graphics::Alignment getAlignment() const; | |
360 virtual void setPadding(unsigned int padding); | |
361 virtual unsigned int getPadding() const; | |
362 virtual void setTitleBarHeight(unsigned int height); | |
363 virtual unsigned int getTitleBarHeight(); | |
364 virtual void setMovable(bool movable); | |
365 virtual bool isMovable() const; | |
366 virtual void setOpaque(bool opaque); | |
367 virtual bool isOpaque(); | |
368 virtual void resizeToContent(); | |
369 }; | |
370 | |
371 %feature("notabstract") ClickLabel; | |
372 %rename(Label) ClickLabel; | |
373 class ClickLabel: public Widget { | |
374 public: | |
375 ClickLabel(); | |
376 ClickLabel(const std::string& caption); | |
377 virtual ~ClickLabel(); | |
378 virtual void setCaption(const std::string& caption); | |
379 virtual const std::string& getCaption() const; | |
380 bool isTextWrapping() const; | |
381 void setTextWrapping(bool); | |
382 virtual void setWidth(int width); | |
383 virtual void adjustSize(); | |
384 }; | |
385 | |
386 %feature("notabstract") Icon2; | |
387 %rename(Icon) Icon2; | |
388 class Icon2: public Widget { | |
389 public: | |
390 Icon2(Image* image); | |
391 virtual ~Icon2(); | |
392 void setImage(Image* image); | |
393 }; | |
394 } | |
395 | |
396 | |
397 |