Mercurial > fife-parpg
comparison engine/core/gui/widgets/widgets.i @ 697:ecaa4d98f05f tip
Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
* Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring.
* GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass.
* The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class.
* The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged.
* Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Sat, 18 Jun 2011 00:28:40 -1000 |
parents | e201abd8c807 |
children |
comparison
equal
deleted
inserted
replaced
696:e201abd8c807 | 697:ecaa4d98f05f |
---|---|
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 * | |
7 * modify it under the terms of the GNU Lesser General Public * | |
8 * License as published by the Free Software Foundation; either * | |
9 * version 2.1 of the License, or (at your option) any later version. * | |
10 * * | |
11 * This library 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 GNU * | |
14 * Lesser General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU Lesser General Public * | |
17 * License along with this library; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 %module fife | |
23 %{ | |
24 #include <guichan.hpp> | |
25 #include <guichan/mouseevent.hpp> | |
26 #include "gui/widgets/utf8textfield.h" | |
27 #include "gui/widgets/utf8textbox.h" | |
28 #include "gui/widgets/twobutton.h" | |
29 #include "gui/widgets/togglebutton.h" | |
30 #include "gui/widgets/clicklabel.h" | |
31 #include "gui/widgets/icon2.hpp" | |
32 #include "gui/widgets/percentagebar.hpp" | |
33 %} | |
34 | |
35 namespace gcn { | |
36 class Font; | |
37 class Image; | |
38 class ActionListener; | |
39 class MouseListener; | |
40 class KeyListener; | |
41 | |
42 %nodefaultctor; | |
43 class Graphics { | |
44 public: | |
45 enum Alignment { | |
46 LEFT = 0, | |
47 CENTER, | |
48 RIGHT | |
49 }; | |
50 }; | |
51 %clearnodefaultctor; | |
52 | |
53 | |
54 class Color { | |
55 public: | |
56 Color(); | |
57 Color(int color); | |
58 Color(int r, int g, int b, int a = 255); | |
59 Color operator+(const Color& color) const; | |
60 Color operator-(const Color& color) const; | |
61 Color operator*(float value) const; | |
62 bool operator==(const Color& color) const; | |
63 bool operator!=(const Color& color) const; | |
64 int r; | |
65 int g; | |
66 int b; | |
67 int a; | |
68 }; | |
69 | |
70 class Widget { | |
71 public: | |
72 /* Widget(); */ | |
73 /* virtual ~Widget(); */ | |
74 virtual void setWidth(int width); | |
75 virtual int getWidth() const; | |
76 virtual void setHeight(int height); | |
77 virtual int getHeight() const; | |
78 virtual void setSize(int width, int height); | |
79 virtual void setX(int x); | |
80 virtual int getX() const; | |
81 virtual void setY(int y); | |
82 virtual int getY() const; | |
83 virtual void setPosition(int x, int y); | |
84 virtual void setFrameSize(unsigned int frameSize); | |
85 virtual unsigned int getFrameSize() const; | |
86 virtual void setFocusable(bool focusable); | |
87 virtual bool isFocusable() const; | |
88 virtual bool isFocused() const; | |
89 virtual void setEnabled(bool enabled); | |
90 virtual bool isEnabled() const; | |
91 virtual void setVisible(bool visible); | |
92 virtual bool isVisible() const; | |
93 virtual void setBaseColor(const Color& color); | |
94 virtual const Color& getBaseColor() const; | |
95 virtual void setForegroundColor(const Color& color); | |
96 virtual const Color& getForegroundColor() const; | |
97 virtual void setBackgroundColor(const Color& color); | |
98 virtual const Color& getBackgroundColor() const; | |
99 virtual void setSelectionColor(const Color& color); | |
100 virtual const Color& getSelectionColor() const; | |
101 virtual void requestFocus(); | |
102 virtual void requestMoveToTop(); | |
103 virtual void requestMoveToBottom(); | |
104 virtual void setActionEventId(const std::string& actionEventId); | |
105 virtual const std::string& getActionEventId() const; | |
106 virtual void getAbsolutePosition(int& x, int& y) const; | |
107 Font *getFont() const; | |
108 static void setGlobalFont(Font* font); | |
109 virtual void setFont(Font* font); | |
110 virtual bool isTabInEnabled() const; | |
111 virtual void setTabInEnabled(bool enabled); | |
112 virtual bool isTabOutEnabled() const; | |
113 virtual void setTabOutEnabled(bool enabled); | |
114 virtual void requestModalFocus(); | |
115 virtual void requestModalMouseInputFocus(); | |
116 virtual void releaseModalFocus(); | |
117 virtual void releaseModalMouseInputFocus(); | |
118 virtual bool isModalFocused() const; | |
119 virtual bool isModalMouseInputFocused() const; | |
120 virtual Widget *getWidgetAt(int x, int y); | |
121 virtual void moveToTop(Widget* widget) { }; | |
122 virtual void moveToBottom(Widget* widget) { }; | |
123 virtual void focusNext() { }; | |
124 virtual void focusPrevious() { }; | |
125 virtual void addActionListener(ActionListener* actionListener); | |
126 virtual void removeActionListener(ActionListener* actionListener); | |
127 virtual void addMouseListener(MouseListener* actionListener); | |
128 virtual void removeMouseListener(MouseListener* actionListener); | |
129 virtual void addKeyListener(KeyListener* actionListener); | |
130 virtual void removeKeyListener(KeyListener* actionListener); | |
131 /* protected: */ | |
132 virtual void draw(Graphics* graphics) = 0; | |
133 }; | |
134 | |
135 %feature("notabstract") Container; | |
136 class Container: public Widget { | |
137 public: | |
138 Container(); | |
139 virtual ~Container(); | |
140 virtual void setOpaque(bool opaque); | |
141 virtual bool isOpaque() const; | |
142 virtual void add(Widget* widget); | |
143 virtual void add(Widget* widget, int x, int y); | |
144 virtual void remove(Widget* widget); | |
145 virtual void clear(); | |
146 }; | |
147 | |
148 %feature("notabstract") CheckBox; | |
149 class CheckBox: public Widget { | |
150 public: | |
151 CheckBox(); | |
152 virtual ~CheckBox(); | |
153 virtual bool isSelected() const; | |
154 virtual void setSelected(bool marked); | |
155 virtual const std::string &getCaption() const; | |
156 virtual void setCaption(const std::string& caption); | |
157 virtual void adjustSize(); | |
158 }; | |
159 | |
160 %feature("notabstract") UTF8TextField; | |
161 %rename(TextField) UTF8TextField; | |
162 class UTF8TextField: public Widget { | |
163 public: | |
164 UTF8TextField(); | |
165 UTF8TextField(const std::string& text); | |
166 virtual void setText(const std::string& text); | |
167 virtual const std::string& getText() const; | |
168 virtual void adjustSize(); | |
169 virtual void adjustHeight(); | |
170 virtual void setCaretPosition(unsigned int position); | |
171 virtual unsigned int getCaretPosition() const; | |
172 }; | |
173 | |
174 %feature("notabstract") Button; | |
175 class Button: public Widget { | |
176 public: | |
177 Button(); | |
178 Button(const std::string& caption); | |
179 virtual void setCaption(const std::string& caption); | |
180 virtual const std::string& getCaption() const; | |
181 virtual void setAlignment(Graphics::Alignment alignment); | |
182 virtual Graphics::Alignment getAlignment() const; | |
183 virtual void adjustSize(); | |
184 /*virtual bool isPressed() const;*/ | |
185 }; | |
186 | |
187 %feature("notabstract") TwoButton; | |
188 class TwoButton: public Widget { | |
189 public: | |
190 TwoButton(Image *up_image = 0, Image *down_image = 0, Image *hover_image = 0, const char * caption = ""); | |
191 ~TwoButton(); | |
192 virtual void setCaption(const std::string& caption); | |
193 virtual const std::string& getCaption() const; | |
194 virtual void setAlignment(Graphics::Alignment alignment); | |
195 virtual Graphics::Alignment getAlignment() const; | |
196 void setUpImage(Image* image); | |
197 void setDownImage(Image* image); | |
198 void setHoverImage(Image* image); | |
199 void setDownOffset(int x, int y); | |
200 int getDownXOffset(); | |
201 int getDownYOffset(); | |
202 }; | |
203 | |
204 %feature("notabstract") ToggleButton; | |
205 class ToggleButton: public Widget { | |
206 public: | |
207 ToggleButton(Image *up_image = 0, Image *down_image = 0, Image *hover_image = 0, const char * caption = "", const char * group = ""); | |
208 ~ToggleButton(); | |
209 virtual void setCaption(const std::string& caption); | |
210 virtual const std::string& getCaption() const; | |
211 virtual void setAlignment(Graphics::Alignment alignment); | |
212 virtual Graphics::Alignment getAlignment() const; | |
213 void setSpacing(unsigned int spacing); | |
214 unsigned int getSpacing() const; | |
215 void setUpImage(Image* image); | |
216 void setDownImage(Image* image); | |
217 void setHoverImage(Image* image); | |
218 void setDownOffset(int x, int y); | |
219 int getDownXOffset() const; | |
220 int getDownYOffset() const; | |
221 bool isToggled() const; | |
222 void setToggled(bool toggled); | |
223 void setGroup(const std::string &group); | |
224 const std::string &getGroup() const; | |
225 }; | |
226 | |
227 %feature("notabstract") ScrollArea; | |
228 class ScrollArea: public Widget { | |
229 public: | |
230 ScrollArea(); | |
231 ScrollArea(Widget *content); | |
232 ScrollArea(Widget *content,ScrollArea::ScrollPolicy hPolicy,ScrollArea::ScrollPolicy vPolicy); | |
233 virtual ~ScrollArea(); | |
234 virtual void setContent(Widget* widget); | |
235 virtual Widget* getContent(); | |
236 virtual void setHorizontalScrollPolicy(ScrollArea::ScrollPolicy hPolicy); | |
237 virtual ScrollArea::ScrollPolicy getHorizontalScrollPolicy(); | |
238 virtual void setVerticalScrollPolicy(ScrollArea::ScrollPolicy vPolicy); | |
239 virtual ScrollArea::ScrollPolicy getVerticalScrollPolicy(); | |
240 virtual void setScrollPolicy(ScrollArea::ScrollPolicy hPolicy, ScrollArea::ScrollPolicy vPolicy); | |
241 virtual void setVerticalScrollAmount(int vScroll); | |
242 virtual int getVerticalScrollAmount(); | |
243 virtual void setHorizontalScrollAmount(int hScroll); | |
244 virtual int getHorizontalScrollAmount(); | |
245 virtual void setScrollAmount(int hScroll, int vScroll); | |
246 virtual int getHorizontalMaxScroll(); | |
247 virtual int getVerticalMaxScroll(); | |
248 virtual void setScrollbarWidth(int width); | |
249 virtual int getScrollbarWidth(); | |
250 virtual void setLeftButtonScrollAmount(int amount); | |
251 virtual void setRightButtonScrollAmount(int amount); | |
252 virtual void setUpButtonScrollAmount(int amount); | |
253 virtual void setDownButtonScrollAmount(int amount); | |
254 virtual int getLeftButtonScrollAmount(); | |
255 virtual int getRightButtonScrollAmount(); | |
256 virtual int getUpButtonScrollAmount(); | |
257 virtual int getDownButtonScrollAmount(); | |
258 enum ScrollPolicy | |
259 { | |
260 SHOW_ALWAYS, | |
261 SHOW_NEVER, | |
262 SHOW_AUTO | |
263 }; | |
264 }; | |
265 | |
266 | |
267 %feature("notabstract") UTF8TextBox; | |
268 %rename(TextBox) UTF8TextBox; | |
269 class UTF8TextBox: public Widget { | |
270 public: | |
271 UTF8TextBox(); | |
272 UTF8TextBox(const std::string& text); | |
273 virtual void setText(const std::string& text); | |
274 virtual std::string getText() const; | |
275 virtual const std::string& getTextRow(int row) const; | |
276 virtual void setTextRow(int row, const std::string& text); | |
277 virtual unsigned int getNumberOfRows() const; | |
278 virtual unsigned int getCaretPosition() const; | |
279 virtual void setCaretPosition(unsigned int position); | |
280 virtual unsigned int getCaretRow() const; | |
281 virtual void setCaretRow(int row); | |
282 virtual unsigned int getCaretColumn() const; | |
283 virtual void setCaretColumn(int column); | |
284 virtual void setCaretRowColumn(int row, int column); | |
285 virtual void scrollToCaret(); | |
286 virtual bool isEditable() const; | |
287 virtual void setEditable(bool editable); | |
288 virtual void addRow(const std::string row); | |
289 virtual bool isOpaque(); | |
290 virtual void setOpaque(bool opaque); | |
291 }; | |
292 | |
293 %feature("director") ListModel; | |
294 class ListModel | |
295 { | |
296 public: | |
297 virtual ~ListModel() { } | |
298 virtual int getNumberOfElements() = 0; | |
299 virtual std::string getElementAt(int i) = 0; | |
300 }; | |
301 | |
302 %feature("notabstract") ListBox; | |
303 class ListBox: public Widget { | |
304 public: | |
305 ListBox(); | |
306 ListBox(ListModel *listModel); | |
307 virtual ~ListBox() { } | |
308 virtual int getSelected(); | |
309 virtual void setSelected(int selected); | |
310 virtual void setListModel(ListModel *listModel); | |
311 virtual ListModel *getListModel(); | |
312 virtual void adjustSize(); | |
313 virtual bool isWrappingEnabled(); | |
314 virtual void setWrappingEnabled(bool wrapping); | |
315 }; | |
316 | |
317 %feature("notabstract") DropDown; | |
318 class DropDown: public Widget { | |
319 public: | |
320 DropDown(ListModel *listModel = NULL, | |
321 ScrollArea *scrollArea = NULL, | |
322 ListBox *listBox = NULL); | |
323 virtual ~DropDown(); | |
324 virtual int getSelected(); | |
325 virtual void setSelected(int selected); | |
326 virtual void setListModel(ListModel *listModel); | |
327 virtual ListModel *getListModel(); | |
328 virtual void adjustHeight(); | |
329 virtual void setBaseColor(const Color& color); | |
330 virtual const Color& getBaseColor() const; | |
331 virtual void setForegroundColor(const Color& color); | |
332 virtual const Color& getForegroundColor() const; | |
333 virtual void setBackgroundColor(const Color& color); | |
334 virtual const Color& getBackgroundColor() const; | |
335 virtual void setSelectionColor(const Color& color); | |
336 virtual const Color& getSelectionColor() const; | |
337 }; | |
338 | |
339 %feature("notabstract") RadioButton; | |
340 class RadioButton: public Widget { | |
341 public: | |
342 RadioButton(); | |
343 RadioButton(const std::string &caption, | |
344 const std::string &group, | |
345 bool marked=false); | |
346 virtual ~RadioButton(); | |
347 virtual bool isSelected() const; | |
348 virtual void setSelected(bool marked); | |
349 virtual const std::string &getCaption() const; | |
350 virtual void setCaption(const std::string caption); | |
351 virtual void setGroup(const std::string &group); | |
352 virtual const std::string &getGroup() const; | |
353 virtual void adjustSize(); | |
354 }; | |
355 | |
356 %feature("notabstract") Slider; | |
357 class Slider: public Widget { | |
358 public: | |
359 Slider(double scaleEnd = 1.0); | |
360 Slider(double scaleStart, double scaleEnd); | |
361 virtual ~Slider() { } | |
362 virtual void setScale(double scaleStart, double scaleEnd); | |
363 virtual double getScaleStart() const; | |
364 virtual void setScaleStart(double scaleStart); | |
365 virtual double getScaleEnd() const; | |
366 virtual void setScaleEnd(double scaleEnd); | |
367 virtual double getValue() const; | |
368 virtual void setValue(double value); | |
369 virtual void setMarkerLength(int length); | |
370 virtual int getMarkerLength() const; | |
371 virtual void setOrientation(Slider::Orientation orientation); | |
372 virtual Slider::Orientation getOrientation() const; | |
373 virtual void setStepLength(double length); | |
374 virtual double getStepLength() const; | |
375 enum Orientation | |
376 { | |
377 HORIZONTAL = 0, | |
378 VERTICAL | |
379 }; | |
380 }; | |
381 | |
382 %feature("notabstract") Window; | |
383 class Window: public Container { | |
384 public: | |
385 Window(); | |
386 Window(const std::string& caption); | |
387 virtual ~Window(); | |
388 virtual void setCaption(const std::string& caption); | |
389 virtual const std::string& getCaption() const; | |
390 virtual void setAlignment(Graphics::Alignment alignment); | |
391 virtual Graphics::Alignment getAlignment() const; | |
392 virtual void setPadding(unsigned int padding); | |
393 virtual unsigned int getPadding() const; | |
394 virtual void setTitleBarHeight(unsigned int height); | |
395 virtual unsigned int getTitleBarHeight(); | |
396 virtual void setMovable(bool movable); | |
397 virtual bool isMovable() const; | |
398 virtual void setOpaque(bool opaque); | |
399 virtual bool isOpaque(); | |
400 virtual void resizeToContent(); | |
401 }; | |
402 | |
403 %feature("notabstract") ClickLabel; | |
404 %rename(Label) ClickLabel; | |
405 class ClickLabel: public Widget { | |
406 public: | |
407 ClickLabel(); | |
408 ClickLabel(const std::string& caption); | |
409 virtual ~ClickLabel(); | |
410 virtual void setCaption(const std::string& caption); | |
411 virtual const std::string& getCaption() const; | |
412 bool isTextWrapping() const; | |
413 void setTextWrapping(bool); | |
414 virtual void setWidth(int width); | |
415 virtual void adjustSize(); | |
416 }; | |
417 | |
418 %feature("notabstract") Icon2; | |
419 %rename(Icon) Icon2; | |
420 class Icon2: public Widget { | |
421 public: | |
422 Icon2(Image* image); | |
423 virtual ~Icon2(); | |
424 void setImage(Image* image); | |
425 }; | |
426 | |
427 %feature("notabstract") PercentageBar; | |
428 class PercentageBar: public Widget { | |
429 public: | |
430 PercentageBar(); | |
431 virtual ~PercentageBar(); | |
432 virtual void setForegroundImage(Image* image); | |
433 virtual void setOrientation(PercentageBar::Orientation orientation); | |
434 virtual PercentageBar::Orientation getOrientation() const; | |
435 virtual int getValue() const; | |
436 virtual void setValue(int value); | |
437 | |
438 enum Orientation | |
439 { | |
440 HORIZONTAL = 0, | |
441 VERTICAL | |
442 }; | |
443 }; | |
444 } | |
445 | |
446 | |
447 |