1 /***************************************************************************
2  *   Copyright (C) 2017-2019 by the fifechan team                               *
3  *   https://github.com/fifengine/fifechan                                 *
4  *   This file is part of fifechan.                                        *
5  *                                                                         *
6  *   fifechan 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 /*      _______   __   __   __   ______   __   __   _______   __   __
23  *     / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___  /\ /  |\/ /\
24  *    / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
25  *   / / /__   / / // / // / // / /    / ___  / // ___  / // /| ' / /
26  *  / /_// /\ / /_// / // / // /_/_   / / // / // /\_/ / // / |  / /
27  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
28  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
29  *
30  * Copyright (c) 2004 - 2008 Olof Naess�n and Per Larsson
31  *
32  *
33  * Per Larsson a.k.a finalman
34  * Olof Naess�n a.k.a jansem/yakslem
35  *
36  * Visit: http://guichan.sourceforge.net
37  *
38  * License: (BSD)
39  * Redistribution and use in source and binary forms, with or without
40  * modification, are permitted provided that the following conditions
41  * are met:
42  * 1. Redistributions of source code must retain the above copyright
43  *    notice, this list of conditions and the following disclaimer.
44  * 2. Redistributions in binary form must reproduce the above copyright
45  *    notice, this list of conditions and the following disclaimer in
46  *    the documentation and/or other materials provided with the
47  *    distribution.
48  * 3. Neither the name of Guichan nor the names of its contributors may
49  *    be used to endorse or promote products derived from this software
50  *    without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
58  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
59  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
60  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
61  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
62  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63  */
64 
65 #ifndef FCN_WIDGET_HPP
66 #define FCN_WIDGET_HPP
67 
68 #include <list>
69 #include <string>
70 
71 #include "fifechan/color.hpp"
72 #include "fifechan/rectangle.hpp"
73 #include "fifechan/size.hpp"
74 #include "fifechan/widgetlistener.hpp"
75 
76 namespace fcn
77 {
78     class ActionListener;
79     class DeathListener;
80     class DefaultFont;
81     class FocusHandler;
82     class FocusListener;
83     class Font;
84     class Graphics;
85     class KeyInput;
86     class KeyListener;
87     class MouseInput;
88     class MouseListener;
89     class VisibilityEventHandler;
90     class WidgetListener;
91 
92     /**
93      * Abstract class for widgets of Guichan. It contains basic functions
94      * every widget should have.
95      *
96      * NOTE: Functions begining with underscore "_" should not
97      *       be overloaded unless you know what you are doing.
98      *
99      * @author Olof Naess�n
100      * @author Per Larsson
101      */
102     class FCN_CORE_DECLSPEC Widget
103     {
104     public:
105         /**
106          * Selection mode.
107          */
108         enum SelectionMode
109         {
110             Selection_None = 0,
111             Selection_Border = 1,
112             Selection_Background = 2
113         };
114 
115         /**
116          * Constructor. Resets member variables. Noteable, a widget is not
117          * focusable as default, therefore, widgets that are supposed to be
118          * focusable should overide this default in their own constructor.
119          */
120         Widget();
121 
122         /**
123          * Default destructor.
124          */
125         virtual ~Widget();
126 
127         /**
128          * Draws the widget. The call to draw is initiated by the widget's
129          * parent. The graphics object is set up so that all drawing is relative
130          * to the widget, i.e coordinate (0,0) is the top left corner of the widget.
131          * It is not possible to draw outside of a widget's dimension. If a widget
132          * has children, the parent's draw function will always be called before
133          * the children's draw functions are called.
134          *
135          * NOTE: A widget with children won't draw its children unless the
136          *       children area given by Widget::getChildrenArea returns a
137          *       none empty rectangle inside the widgets dimension. The children
138          *       area is considered relative to the widget's position.
139          *
140          * @param graphics A graphics object to draw with.
141          * @see getChildrenArea, drawOutline, drawBorder
142          */
143         virtual void draw(Graphics* graphics) = 0;
144 
145         /**
146          * Called when a widget is given a chance to draw a outline around itself.
147          * The outline is not considered as part of the widget, it only allows a outline
148          * to be drawn around the widget, thus a outline will never be included when
149          * calculating if a widget should receive events from user input. Also
150          * a widget's outline will never be included when calculating a widget's
151          * position.
152          *
153          * The size of the outline is calculated using the widget's outline size.
154          * If a widget has a outline size of 10 pixels than the area the drawOutline
155          * function can draw to will be the size of the widget with an additional
156          * extension of 10 pixels in each direction.
157          *
158          * An example when drawOutline is a useful function is if a widget needs
159          * a glow around itself.
160          *
161          * @param graphics A graphics object to draw with.
162          * @see setOutlineSize, getOutlineSize
163          */
164         virtual void drawOutline(Graphics* graphics);
165 
166         /**
167          * Called when a widget have a border.
168          *
169          * @param graphics A graphics object to draw with.
170          * @see setBorderSize, getBorderSize
171          */
172         virtual void drawBorder(Graphics* graphics);
173 
174         /**
175          * Called when a widget is "active" and the selection mode is Frame or FrameWithBackground.
176          * Currently the size of the border is used, so it will replace the border with the frame.
177          *
178          * @param graphics A graphics object to draw with.
179          * @see setSelectionMode, getSelectionMode, setSelectionColor, getSelectionColor
180          */
181         virtual void drawSelectionFrame(Graphics* graphics);
182 
183         /**
184          * Sets the size of the widget's outline. The outline is not considered as part of
185          * the widget, it only allows a outline to be drawn around the widget, thus a outline
186          * will never be included when calculating if a widget should receive events
187          * from user input. Also a widget's outline will never be included when calculating
188          * a widget's position.
189          *
190          * A outline size of 0 means that the widget has no outline. The default outline size
191          * is 0.
192          *
193          * @param size The size of the widget's outline.
194          * @see getOutlineSize, drawOutline
195          */
196         void setOutlineSize(unsigned int size);
197 
198         /**
199          * Gets the size of the widget's outline. The outline is not considered as part of
200          * the widget, it only allows a outline to be drawn around the widget, thus a outline
201          * will never be included when calculating if a widget should receive events
202          * from user input. Also a widget's outline will never be included when calculating
203          * a widget's position.
204          *
205          * A outline size of 0 means that the widget has no outline. The default outline size
206          * is 0.
207          *
208          * @return The size of the widget's outline.
209          * @see setOutlineSize, drawOutline
210          */
211         unsigned int getOutlineSize() const;
212 
213         /**
214          * Sets the size of the widget's border. The border is considered as part of
215          * the widget.
216          *
217          * A border size of 0 means that the widget has no border. The default border size
218          * is 0.
219          *
220          * @param size The size of the widget's border.
221          * @see getBorderSize, drawBorder
222          */
223         void setBorderSize(unsigned int size);
224 
225         /**
226          * Gets the size of the widget's border. The border is considered as part of
227          * the widget.
228          *
229          * A border size of 0 means that the widget has no border. The default border size
230          * is 0.
231          *
232          * @return The size of the widget's border.
233          * @see setBorderSize, drawBorder
234          */
235         unsigned int getBorderSize() const;
236 
237         /**
238          * Sets all 4 margins to one value.
239          * The margin clears an area around an element (outside the border).
240          * The margin does not have a background color, and is completely transparent.
241          * It is also possible to use negative values, to overlap content.
242 
243          * @param margin The margin of the widget.
244          * @see setMarginTop, setMarginRight, setMarginBottom, setMarginRight
245          */
246         void setMargin(int margin);
247 
248         /**
249          * Sets the top margin.
250          * The margin clears an area around an element (outside the border).
251          * The margin does not have a background color, and is completely transparent.
252          * It is also possible to use negative values, to overlap content.
253 
254          * @param margin The top margin of the widget.
255          * @see getMarginTop
256          */
257         void setMarginTop(int margin);
258 
259         /**
260          * Gets the top margin.
261          * The margin clears an area around an element (outside the border).
262          * The margin does not have a background color, and is completely transparent.
263          * It is also possible to use negative values, to overlap content.
264 
265          * @return The top margin of the widget.
266          * @see setMarginTop
267          */
268         int getMarginTop() const;
269 
270         /**
271          * Sets the right margin.
272          * The margin clears an area around an element (outside the border).
273          * The margin does not have a background color, and is completely transparent.
274          * It is also possible to use negative values, to overlap content.
275 
276          * @param margin The right margin of the widget.
277          * @see getMarginRight
278          */
279         void setMarginRight(int margin);
280 
281         /**
282          * Gets the right margin.
283          * The margin clears an area around an element (outside the border).
284          * The margin does not have a background color, and is completely transparent.
285          * It is also possible to use negative values, to overlap content.
286 
287          * @return The right margin of the widget.
288          * @see setMarginRight
289          */
290         int getMarginRight() const;
291 
292         /**
293          * Sets the bottom margin.
294          * The margin clears an area around an element (outside the border).
295          * The margin does not have a background color, and is completely transparent.
296          * It is also possible to use negative values, to overlap content.
297 
298          * @param margin The bottom margin of the widget.
299          * @see getMarginBottom
300          */
301         void setMarginBottom(int margin);
302 
303         /**
304          * Gets the bottom margin.
305          * The margin clears an area around an element (outside the border).
306          * The margin does not have a background color, and is completely transparent.
307          * It is also possible to use negative values, to overlap content.
308 
309          * @return The bottom margin of the widget.
310          * @see setMarginBottom
311          */
312         int getMarginBottom() const;
313 
314         /**
315          * Sets the left margin.
316          * The margin clears an area around an element (outside the border).
317          * The margin does not have a background color, and is completely transparent.
318          * It is also possible to use negative values, to overlap content.
319 
320          * @param margin The left margin of the widget.
321          * @see getMarginLeft
322          */
323         void setMarginLeft(int margin);
324 
325         /**
326          * Gets the left margin.
327          * The margin clears an area around an element (outside the border).
328          * The margin does not have a background color, and is completely transparent.
329          * It is also possible to use negative values, to overlap content.
330 
331          * @return The left margin of the widget.
332          * @see setMarginLeft
333          */
334         int getMarginLeft() const;
335 
336         /**
337          * Sets all 4 paddings to one value.
338          * The padding clears an area around the content (inside the border) of
339          * an element. The padding is affected by the background color of the element.
340 
341          * @param padding The top padding of the widget.
342          * @see setPaddingTop, setPaddingRight, setPaddingBottom, setPaddingLeft
343          */
344         void setPadding(unsigned int padding);
345 
346         /**
347          * Sets the top padding.
348          * The padding clears an area around the content (inside the border) of
349          * an element. The padding is affected by the background color of the element.
350 
351          * @param padding The top padding of the widget.
352          * @see getPaddingTop
353          */
354         void setPaddingTop(unsigned int padding);
355 
356         /**
357          * Gets the top padding.
358          * The padding clears an area around the content (inside the border) of
359          * an element. The padding is affected by the background color of the element.
360 
361          * @return The top padding of the widget.
362          * @see setPaddingTop
363          */
364         unsigned int getPaddingTop() const;
365 
366         /**
367          * Sets the right padding.
368          * The padding clears an area around the content (inside the border) of
369          * an element. The padding is affected by the background color of the element.
370 
371          * @param padding The right padding of the widget.
372          * @see getPaddingRight
373          */
374         void setPaddingRight(unsigned int padding);
375 
376         /**
377          * Gets the right padding.
378          * The padding clears an area around the content (inside the border) of
379          * an element. The padding is affected by the background color of the element.
380 
381          * @return The right padding of the widget.
382          * @see setPaddingRight
383          */
384         unsigned int getPaddingRight() const;
385 
386         /**
387          * Sets the bottom padding.
388          * The padding clears an area around the content (inside the border) of
389          * an element. The padding is affected by the background color of the element.
390 
391          * @param padding The bottom padding of the widget.
392          * @see getPaddingBottom
393          */
394         void setPaddingBottom(unsigned int padding);
395 
396         /**
397          * Gets the bottom padding.
398          * The padding clears an area around the content (inside the border) of
399          * an element. The padding is affected by the background color of the element.
400 
401          * @return The bottom padding of the widget.
402          * @see setPaddingBottom
403          */
404         unsigned int getPaddingBottom() const;
405 
406         /**
407          * Sets the left padding.
408          * The padding clears an area around the content (inside the border) of
409          * an element. The padding is affected by the background color of the element.
410 
411          * @param padding The left padding of the widget.
412          * @see getPaddingLeft
413          */
414         void setPaddingLeft(unsigned int padding);
415 
416         /**
417          * Gets the left padding.
418          * The padding clears an area around the content (inside the border) of
419          * an element. The padding is affected by the background color of the element.
420 
421          * @return The left padding of the widget.
422          * @see setPaddingLeft
423          */
424         unsigned int getPaddingLeft() const;
425 
426         /**
427          * Called for all widgets in the gui each time Gui::logic is called.
428          * You can do logic stuff here like playing an animation.
429          *
430          * @see Gui::logic
431          */
logic()432         virtual void logic() { }
433 
434         /**
435          * Gets the widget's parent container.
436          *
437          * @return The widget's parent container. NULL if the widget
438          *         has no parent.
439          */
440         virtual Widget* getParent() const;
441 
442         /**
443          * Gets the top widget, or top parent, of this widget.
444          *
445          * @return The top widget, or top parent, for this widget. NULL if no top widget
446          *         exists (this widget doesn't have a parent).
447          */
448         virtual Widget* getTop() const;
449 
450         /**
451          * Sets the width of the widget.
452          *
453          * @param width The width of the widget.
454          * @see getWidth, setHeight, getHeight, setSize,
455          *      setDimension, getDimension
456          */
457         void setWidth(int width);
458 
459         /**
460          * Gets the width of the widget.
461          *
462          * @return The width of the widget.
463          * @see setWidth, setHeight, getHeight, setSize,
464          *      setDimension, getDimension
465          */
466         int getWidth() const;
467 
468         /**
469          * Sets the height of the widget.
470          *
471          * @param height The height of the widget.
472          * @see getHeight, setWidth, getWidth, setSize,
473          *      setDimension, getDimension
474          */
475         void setHeight(int height);
476 
477         /**
478          * Gets the height of the widget.
479          *
480          * @return The height of the widget.
481          * @see setHeight, setWidth, getWidth, setSize,
482          *      setDimension, getDimension
483          */
484         int getHeight() const;
485 
486         /**
487          * Sets the size of the widget.
488          *
489          * @param width The width of the widget.
490          * @param height The height of the widget.
491          * @see setWidth, setHeight, getWidth, getHeight,
492          *      setDimension, getDimension
493          */
494         void setSize(int width, int height);
495 
496         /**
497          * Sets the x coordinate of the widget. The coordinate is
498          * relateive to the widget's parent.
499          *
500          * @param x The x coordinate of the widget.
501          * @see getX, setY, getY, setPosition, setDimension, getDimension
502          */
503         void setX(int x);
504 
505         /**
506          * Gets the x coordinate of the widget. The coordinate is
507          * relative to the widget's parent.
508          *
509          * @return The x coordinate of the widget.
510          * @see setX, setY, getY, setPosition, setDimension, getDimension
511          */
512         int getX() const;
513 
514         /**
515          * Sets the y coordinate of the widget. The coordinate is
516          * relative to the widget's parent.
517          *
518          * @param y The y coordinate of the widget.
519          * @see setY, setX, getX, setPosition, setDimension, getDimension
520          */
521         void setY(int y);
522 
523         /**
524          * Gets the y coordinate of the widget. The coordinate is
525          * relative to the widget's parent.
526          *
527          * @return The y coordinate of the widget.
528          * @see setY, setX, getX, setPosition, setDimension, getDimension
529          */
530         int getY() const;
531 
532         /**
533          * Sets position of the widget. The position is relative
534          * to the widget's parent.
535          *
536          * @param x The x coordinate of the widget.
537          * @param y The y coordinate of the widget.
538          * @see setX, getX, setY, getY, setDimension, getDimension
539          */
540         void setPosition(int x, int y);
541 
542         /**
543          * Sets the dimension of the widget. The dimension is
544          * relative to the widget's parent.
545          *
546          * @param dimension The dimension of the widget.
547          * @see getDimension, setX, getX, setY, getY, setPosition
548          */
549         void setDimension(const Rectangle& dimension);
550 
551         /**
552          * Gets the dimension of the widget. The dimension is
553          * relative to the widget's parent.
554          *
555          * @return The dimension of the widget.
556          * @see getDimension, setX, getX, setY, getY, setPosition
557          */
558         const Rectangle& getDimension() const;
559 
560         /**
561          * Gets how many childs the widget have.
562          *
563          * @return The children count of the widget.
564          */
565         unsigned int getChildrenCount() const;
566 
567         /**
568          * Gets how many visible childs the widget have.
569          *
570          * @return The visible children count of the widget.
571          */
572         unsigned int getVisibleChildrenCount() const;
573 
574         /**
575          * Sets the minimal dimension of the widget.
576          *
577          * @param size The minimal size of the widget.
578          * @see getMinSize
579          */
580         void setMinSize(const Size& size);
581 
582         /**
583          * Gets the minimal dimension of the widget.
584          *
585          * @return The minimal size of the widget.
586          * @see setMinSize
587          */
588         const Size& getMinSize() const;
589 
590         /**
591          * Sets the maximal dimension of the widget.
592          *
593          * @param size The maximal size of the widget.
594          * @see getMaxSize
595          */
596         void setMaxSize(const Size& size);
597 
598         /**
599          * Gets the maximal dimension of the widget.
600          *
601          * @return The maximal size of the widget.
602          * @see setMaxSize
603          */
604         const Size& getMaxSize() const;
605 
606         /**
607          * Sets the dimension of the widget to a fixed size.
608          * To disable it, provide a size with negative values.
609          *
610          * @param size The fixed size of the widget.
611          * @see getFixedSize, isFixedSize
612          */
613         void setFixedSize(const Size& size);
614 
615         /**
616          * Gets the fixed size of the widget.
617          *
618          * @return The fixed size of the widget.
619          * @see setFixedSize, isFixedSize
620          */
621         const Size& getFixedSize() const;
622 
623         /**
624          * Gets if the widget use a fixed size.
625          *
626          * @return True if the widget use a fixed size, otherwise false.
627          * @see setFixedSize, getFixedSize
628          */
629         bool isFixedSize() const;
630 
631         /**
632          * Sets the widget to be fosusable, or not.
633          *
634          * @param focusable True if the widget should be focusable,
635          *                  false otherwise.
636          * @see isFocusable
637          */
638         void setFocusable(bool focusable);
639 
640          /**
641          * Checks if a widget is focsable.
642          *
643          * @return True if the widget should be focusable, false otherwise.
644          * @see setFocusable
645          */
646         bool isFocusable() const;
647 
648         /**
649          * Checks if the widget is focused.
650          *
651          * @return True if the widget is focused, false otherwise.
652          */
653         virtual bool isFocused() const;
654 
655         /**
656          * Sets the widget to enabled, or not. A disabled
657          * widget will never recieve mouse or key events.
658          *
659          * @param enabled True if widget should be enabled,
660          *                false otherwise.
661          * @see isEnabled
662          */
663         void setEnabled(bool enabled);
664 
665         /**
666          * Checks if the widget is enabled. A disabled
667          * widget will never recieve mouse or key events.
668          *
669          * @return True if widget is enabled, false otherwise.
670          * @see setEnabled
671          */
672         bool isEnabled() const;
673 
674         /**
675          * Sets the widget to be visible, or not.
676          *
677          * @param visible True if widget should be visible, false otherwise.
678          * @see isVisible
679          */
680         void setVisible(bool visible);
681 
682         /**
683          * Checks if the widget is visible.
684          *
685          * @return True if widget is be visible, false otherwise.
686          * @see setVisible
687          */
688         bool isVisible() const;
689 
690         /**
691          * Checks if the widget setting is visible.
692          *
693          * @return True if widget setting is be visible, false otherwise.
694          */
695         bool isSetVisible() const;
696 
697         /**
698          * Sets the base color of the widget.
699          *
700          * @param color The baseground color.
701          * @see getBaseColor
702          */
703         void setBaseColor(const Color& color);
704 
705         /**
706          * Gets the base color.
707          *
708          * @return The base color.
709          * @see setBaseColor
710          */
711         const Color& getBaseColor() const;
712 
713         /**
714          * Sets the foreground color.
715          *
716          * @param color The foreground color.
717          * @see getForegroundColor
718          */
719         void setForegroundColor(const Color& color);
720 
721         /**
722          * Gets the foreground color.
723          *
724          * @see setForegroundColor
725          */
726         const Color& getForegroundColor() const;
727 
728         /**
729          * Sets the background color.
730          *
731          * @param color The background Color.
732          * @see setBackgroundColor
733          */
734         void setBackgroundColor(const Color& color);
735 
736         /**
737          * Gets the background color.
738          *
739          * @see setBackgroundColor
740          */
741         const Color& getBackgroundColor() const;
742 
743         /**
744          * Sets the selection color.
745          *
746          * @param color The selection color.
747          * @see getSelectionColor
748          */
749         void setSelectionColor(const Color& color);
750 
751         /**
752          * Gets the selection color.
753          *
754          * @return The selection color.
755          * @see setSelectionColor
756          */
757         const Color& getSelectionColor() const;
758 
759         /**
760          * Sets the outline color.
761          *
762          * @param color The outline color.
763          * @see getOutlineColor
764          */
765         void setOutlineColor(const Color& color);
766 
767         /**
768          * Gets the outline color.
769          *
770          * @return The outline color.
771          * @see setOutlineColor
772          */
773         const Color& getOutlineColor() const;
774 
775         /**
776          * Sets the border color.
777          *
778          * @param color The border color.
779          * @see getBorderColor
780          */
781         void setBorderColor(const Color& color);
782 
783         /**
784          * Gets the border color.
785          *
786          * @return The border color.
787          * @see setBorderColor
788          */
789         const Color& getBorderColor() const;
790 
791         /**
792          * Sets the selection mode.
793          *
794          * @param mode The selection mode that is used when the widget is "active".
795          * @see getSelectionMode
796          */
797         void setSelectionMode(SelectionMode mode);
798 
799         /**
800          * Gets the selection mode.
801          *
802          * @return The selection mode that is used when the widget is "active".
803          * @see setSelectionMode
804          */
805         SelectionMode getSelectionMode() const;
806 
807         /**
808          * Requests focus for the widget. A widget will only recieve focus
809          * if it is focusable.
810          *
811          */
812         virtual void requestFocus();
813 
814         /**
815          * Requests a move to the top in the parent widget.
816          *
817          */
818         virtual void requestMoveToTop();
819 
820         /**
821          * Requests a move to the bottom in the parent widget.
822          *
823          */
824         virtual void requestMoveToBottom();
825 
826         /**
827          * Called whenever a widget should draw itself. The function will
828          * set up clip areas and call the draw function for this widget
829          * and for all its children.
830          *
831          * WARNING: This function is used internally and should not
832          *          be called or overloaded unless you know what you
833          *          are doing.
834          */
835         virtual void _draw(Graphics* graphics);
836 
837          /**
838          * Called whenever a widget should perform logic. The function will
839          * call the logic function for this widget and for all its children.
840          *
841          * WARNING: This function is used internally and should not
842          *          be called or overloaded unless you know what you
843          *          are doing.
844          */
845         virtual void _logic();
846 
847         /**
848          * Sets the focus handler to be used.
849          *
850          * WARNING: This function is used internally and should not
851          *          be called or overloaded unless you know what you
852          *          are doing.
853          *
854          * @param focusHandler The focus handler to use.
855          * @see _getFocusHandler
856          */
857         virtual void _setFocusHandler(FocusHandler* focusHandler);
858 
859         /**
860          * Gets the focus handler used.
861          *
862          * WARNING: This function is used internally and should not
863          *          be called or overloaded unless you know what you
864          *          are doing.
865          *
866          * @return The focus handler used.
867          * @see _setFocusHandler
868          */
869         virtual FocusHandler* _getFocusHandler();
870 
871         /**
872          * Adds an action listener to the widget. When an action event
873          * is fired by the widget the action listeners of the widget
874          * will get notified.
875          *
876          * @param actionListener The action listener to add.
877          * @see removeActionListener
878          */
879         void addActionListener(ActionListener* actionListener);
880 
881         /**
882          * Removes an added action listener from the widget.
883          *
884          * @param actionListener The action listener to remove.
885          * @see addActionListener
886          */
887         void removeActionListener(ActionListener* actionListener);
888 
889         /**
890          * Adds a death listener to the widget. When a death event is
891          * fired by the widget the death listeners of the widget will
892          * get notified.
893          *
894          * @param deathListener The death listener to add.
895          * @see removeDeathListener
896          */
897         void addDeathListener(DeathListener* deathListener);
898 
899         /**
900          * Removes an added death listener from the widget.
901          *
902          * @param deathListener The death listener to remove.
903          * @see addDeathListener
904          */
905         void removeDeathListener(DeathListener* deathListener);
906 
907         /**
908          * Adds a mouse listener to the widget. When a mouse event is
909          * fired by the widget the mouse listeners of the widget will
910          * get notified.
911          *
912          * @param mouseListener The mouse listener to add.
913          * @see removeMouseListener
914          */
915         void addMouseListener(MouseListener* mouseListener);
916 
917         /**
918          * Removes an added mouse listener from the widget.
919          *
920          * @param mouseListener The mouse listener to remove.
921          * @see addMouseListener
922          */
923         void removeMouseListener(MouseListener* mouseListener);
924 
925         /**
926          * Adds a key listener to the widget. When a key event is
927          * fired by the widget the key listeners of the widget will
928          * get notified.
929          *
930          * @param keyListener The key listener to add.
931          * @see removeKeyListener
932          */
933         void addKeyListener(KeyListener* keyListener);
934 
935         /**
936          * Removes an added key listener from the widget.
937          *
938          * @param keyListener The key listener to remove.
939          * @see addKeyListener
940          */
941         void removeKeyListener(KeyListener* keyListener);
942 
943         /**
944          * Adds a focus listener to the widget. When a focus event is
945          * fired by the widget the key listeners of the widget will
946          * get notified.
947          *
948          * @param focusListener The focus listener to add.
949          * @see removeFocusListener
950          */
951         void addFocusListener(FocusListener* focusListener);
952 
953         /**
954          * Removes an added focus listener from the widget.
955          *
956          * @param focusListener The focus listener to remove.
957          * @see addFocusListener
958          */
959         void removeFocusListener(FocusListener* focusListener);
960 
961         /**
962          * Adds a widget listener to the widget. When a widget event is
963          * fired by the widget the key listeners of the widget will
964          * get notified.
965          *
966          * @param widgetListener The widget listener to add.
967          * @see removeWidgetListener
968          */
969         void addWidgetListener(WidgetListener* widgetListener);
970 
971         /**
972          * Removes an added widget listener from the widget.
973          *
974          * @param widgetListener The widget listener to remove.
975          * @see addWidgetListener
976          */
977         void removeWidgetListener(WidgetListener* widgetListener);
978 
979         /**
980          * Sets the action event identifier of the widget. The identifier is
981          * used to be able to identify which action has occured.
982          *
983          * NOTE: An action event identifier should not be used to identify a
984          *       certain widget but rather a certain event in your application.
985          *       Several widgets can have the same action event identifer.
986          *
987          * @param actionEventId The action event identifier.
988          * @see getActionEventId
989          */
990         void setActionEventId(const std::string& actionEventId);
991 
992         /**
993          * Gets the action event identifier of the widget.
994          *
995          * @return The action event identifier of the widget.
996          * @see setActionEventId
997          */
998         const std::string& getActionEventId() const;
999 
1000         /**
1001          * Gets the absolute position on the screen for the widget.
1002          *
1003          * @param x The absolute x coordinate will be stored in this parameter.
1004          * @param y The absolute y coordinate will be stored in this parameter.
1005          */
1006         virtual void getAbsolutePosition(int& x, int& y) const;
1007 
1008         /**
1009          * Sets the parent of the widget. A parent must be a BasicContainer.
1010          *
1011          * WARNING: This function is used internally and should not
1012          *          be called or overloaded unless you know what you
1013          *          are doing.
1014          *
1015          * @param parent The parent of the widget.
1016          * @see getParent
1017          */
1018         virtual void _setParent(Widget* parent);
1019 
1020         /**
1021          * Gets the font set for the widget. If no font has been set,
1022          * the global font will be returned. If no global font has been set,
1023          * the default font will be returend.
1024          *
1025          * @return The font set for the widget.
1026          * @see setFont, setGlobalFont
1027          */
1028         Font *getFont() const;
1029 
1030         /**
1031          * Sets the global font to be used by default for all widgets.
1032          *
1033          * @param font The global font.
1034          * @see getGlobalFont
1035          */
1036         static void setGlobalFont(Font* font);
1037 
1038         /**
1039          * Sets the font for the widget. If NULL is passed, the global font
1040          * will be used.
1041          *
1042          * @param font The font to set for the widget.
1043          * @see getFont
1044          */
1045         void setFont(Font* font);
1046 
1047         /**
1048          * Called when the font has changed. If the change is global,
1049          * this function will only be called if the widget doesn't have a
1050          * font already set.
1051          *
1052          */
fontChanged()1053         virtual void fontChanged() { }
1054 
1055         /**
1056          * Checks if a widget exists or not, that is if it still exists
1057          * an instance of the object.
1058          *
1059          * @param widget The widget to check.
1060          * @return True if an instance of the widget exists, false otherwise.
1061          */
1062         static bool widgetExists(const Widget* widget);
1063 
1064         /**
1065          * Checks if tab in is enabled. Tab in means that you can set focus
1066          * to this widget by pressing the tab button. If tab in is disabled
1067          * then the focus handler will skip this widget and focus the next
1068          * in its focus order.
1069          *
1070          * @return True if tab in is enabled, false otherwise.
1071          * @see setTabInEnabled
1072          */
1073         bool isTabInEnabled() const;
1074 
1075         /**
1076          * Sets tab in enabled, or not. Tab in means that you can set focus
1077          * to this widget by pressing the tab button. If tab in is disabled
1078          * then the FocusHandler will skip this widget and focus the next
1079          * in its focus order.
1080          *
1081          * @param enabled True if tab in should be enabled, false otherwise.
1082          * @see isTabInEnabled
1083          */
1084         void setTabInEnabled(bool enabled);
1085 
1086         /**
1087          * Checks if tab out is enabled. Tab out means that you can lose
1088          * focus to this widget by pressing the tab button. If tab out is
1089          * disabled then the FocusHandler ignores tabbing and focus will
1090          * stay with this widget.
1091          *
1092          * @return True if tab out is enabled, false otherwise.
1093          * @see setTabOutEnabled
1094          */
1095         bool isTabOutEnabled() const;
1096 
1097         /**
1098          * Sets tab out enabled. Tab out means that you can lose
1099          * focus to this widget by pressing the tab button. If tab out is
1100          * disabled then the FocusHandler ignores tabbing and focus will
1101          * stay with this widget.
1102          *
1103          * @param enabled True if tab out should be enabled, false otherwise.
1104          * @see isTabOutEnabled
1105          */
1106         void setTabOutEnabled(bool enabled);
1107 
1108         /**
1109          * Checks if a widget is modal focusable.
1110          *
1111          * @return True if no other widget is modal focused, false otherwise.
1112          * @see requestModalFocus, releaseModalFocus
1113          */
1114         virtual bool isModalFocusable() const;
1115 
1116         /**
1117          * Checks if a widget is modal mouse input focusable.
1118          *
1119          * @return True if no other widget is modal mouse input focused, false otherwise.
1120          * @see requestModalMouseInputFocus, releaseModalMouseInputFocus
1121          */
1122         virtual bool isModalMouseInputFocusable() const;
1123 
1124         /**
1125          * Requests modal focus. When a widget has modal focus, only that
1126          * widget and it's children may recieve input.
1127          *
1128          * @throws Exception if another widget already has modal focus.
1129          * @see releaseModalFocus, isModalFocused
1130          */
1131         virtual void requestModalFocus();
1132 
1133         /**
1134          * Requests modal mouse input focus. When a widget has modal input focus
1135          * that widget will be the only widget receiving input even if the input
1136          * occurs outside of the widget and no matter what the input is.
1137          *
1138          * @throws Exception if another widget already has modal focus.
1139          * @see releaseModalMouseInputFocus, isModalMouseInputFocused
1140          */
1141         virtual void requestModalMouseInputFocus();
1142 
1143         /**
1144          * Releases modal focus. Modal focus will only be released if the
1145          * widget has modal focus.
1146          *
1147          * @see requestModalFocus, isModalFocused
1148          */
1149         virtual void releaseModalFocus();
1150 
1151         /**
1152          * Releases modal mouse input focus. Modal mouse input focus will only
1153          * be released if the widget has modal mouse input focus.
1154          *
1155          * @see requestModalMouseInputFocus, isModalMouseInputFocused
1156          */
1157         virtual void releaseModalMouseInputFocus();
1158 
1159         /**
1160          * Checks if the widget or it's parent has modal focus.
1161          *
1162          * @return True if the widget has modal focus, false otherwise.
1163          * @see requestModalFocus, releaseModalFocus
1164          */
1165         virtual bool isModalFocused() const;
1166 
1167         /**
1168          * Checks if the widget or it's parent has modal mouse input focus.
1169          *
1170          * @return True if the widget has modal mouse input focus, false
1171          *         otherwise.
1172          * @see requestModalMouseInputFocus, releaseModalMouseInputFocus
1173          */
1174         virtual bool isModalMouseInputFocused() const;
1175 
1176         /**
1177          * Gets a widget at a certain position in the widget.
1178          * This function is used to decide which gets mouse input,
1179          * thus it can be overloaded to change that behaviour.
1180          *
1181          * NOTE: This always returns NULL if the widget is not
1182          *       a container.
1183          *
1184          * @param x The x coordinate of the widget to get.
1185          * @param y The y coordinate of the widget to get.
1186          * @param exclude Widget to exclude from search, if NULL
1187          *            no widgets get excluded.
1188          * @return The widget at the specified coodinate, NULL
1189          *         if no widget is found.
1190          */
1191         virtual Widget *getWidgetAt(int x, int y, Widget* exclude = NULL);
1192 
1193         /**
1194          * Gets all widgets inside a certain area of the widget.
1195          *
1196          * NOTE: This always returns an emtpy list if the widget is not
1197          *       a container.
1198          *
1199          * @param area The area to check.
1200          * @param ignore If supplied, this widget will be ignored.
1201          * @return A list of widgets. An empty list if no widgets was found.
1202          */
1203         virtual std::list<Widget*> getWidgetsIn(const Rectangle& area,
1204                                                 Widget* ignore = NULL);
1205 
1206         /**
1207          * Gets the mouse listeners of the widget.
1208          *
1209          * @return The mouse listeners of the widget.
1210          */
1211         virtual const std::list<MouseListener*>& _getMouseListeners();
1212 
1213         /**
1214          * Gets the key listeners of the widget.
1215          *
1216          * @return The key listeners of the widget.
1217          */
1218         virtual const std::list<KeyListener*>& _getKeyListeners();
1219 
1220         /**
1221          * Gets the focus listeners of the widget.
1222          *
1223          * @return The focus listeners of the widget.
1224          */
1225         virtual const std::list<FocusListener*>& _getFocusListeners();
1226 
1227         /**
1228          * Gets the area of the widget occupied by the widget's children.
1229          * By default this method returns an empty rectangle as not all
1230          * widgets are containers. If you want to make a container this
1231          * method should return the area where the children resides. This
1232          * method is used when drawing children of a widget when computing
1233          * clip rectangles for the children.
1234          *
1235          * NOTE: The returned rectangle should be relative to the widget,
1236          *       i.e a rectangle with x and y coordinate (0,0) and with
1237          *       width and height the same as the widget will let the
1238          *       children draw themselves in the whole widget.
1239          *
1240          * An example of a widget that overloads this method is ScrollArea.
1241          * A ScrollArea has a view of its contant and that view is the
1242          * children area. The size of a ScrollArea's children area might
1243          * vary depending on if the scroll bars of the ScrollArea is shown
1244          * or not.
1245          *
1246          * @return The area of the widget occupied by the widget's children.
1247          */
1248         virtual Rectangle getChildrenArea();
1249 
1250         /**
1251          * Gets the internal focus handler used.
1252          *
1253          * @return the internalFocusHandler used. If no internal focus handler
1254          *         is used, NULL will be returned.
1255          * @see setInternalFocusHandler
1256          */
1257         virtual FocusHandler* _getInternalFocusHandler();
1258 
1259         /**
1260          * Sets the internal focus handler. An internal focus handler is
1261          * needed if both a widget in the widget and the widget itself
1262          * should be foucsed at the same time.
1263          *
1264          * @param focusHandler The internal focus handler to be used.
1265          * @see getInternalFocusHandler
1266          */
1267         void setInternalFocusHandler(FocusHandler* internalFocusHandler);
1268 
1269         /**
1270          * Moves a widget to the top of this widget. The moved widget will be
1271          * drawn above all other widgets in this widget.
1272          *
1273          * This method is safe to call at any time.
1274          *
1275          * @param widget The widget to move to the top.
1276          * @see moveToBottom
1277          */
1278         virtual void moveToTop(Widget* widget);
1279 
1280         /**
1281          * Moves a widget in this widget to the bottom of this widget.
1282          * The moved widget will be drawn below all other widgets in this widget.
1283          *
1284          * This method is safe to call at any time.
1285          *
1286          * @param widget The widget to move to the bottom.
1287          * @see moveToTop
1288          */
1289         virtual void moveToBottom(Widget* widget);
1290 
1291         /**
1292          * Focuses the next widget in the widget.
1293          *
1294          * @see moveToBottom
1295          */
1296         virtual void focusNext();
1297 
1298         /**
1299          * Focuses the previous widget in the widget.
1300          *
1301          * @see moveToBottom
1302          */
1303         virtual void focusPrevious();
1304 
1305         /**
1306          * Tries to show a specific part of a widget by moving it. Used if the
1307          * widget should act as a container.
1308          *
1309          * @param widget The target widget.
1310          * @param area The area to show.
1311          */
1312         virtual void showWidgetPart(Widget* widget, Rectangle area);
1313 
1314         /**
1315          * Sets an id of a widget. An id can be useful if a widget needs to be
1316          * identified in a container. For example, if widgets are created by an
1317          * XML document, a certain widget can be retrieved given that the widget
1318          * has an id.
1319          *
1320          * @param id The id to set to the widget.
1321          * @see getId, BasicContainer::findWidgetById
1322          */
1323         void setId(const std::string& id);
1324 
1325         /**
1326          * Gets the id of a widget. An id can be useful if a widget needs to be
1327          * identified in a container. For example, if widgets are created by an
1328          * XML document, a certain widget can be retrieved given that the widget
1329          * has an id.
1330          *
1331          * @param id The id to set to the widget.
1332          * @see setId, BasicContainer::findWidgetById
1333          */
1334         const std::string& getId() const;
1335 
1336         /**
1337          * Shows a certain part of a widget in the widget's parent.
1338          * Used when widgets want a specific part to be visible in
1339          * its parent. An example is a TextArea that wants a specific
1340          * part of its text to be visible when a TextArea is a child
1341          * of a ScrollArea.
1342          *
1343          * @param rectangle The rectangle to be shown.
1344          */
1345         virtual void showPart(Rectangle rectangle);
1346 
1347         /**
1348          * Sets the visibility event handler to be used.
1349          *
1350          * WARNING: This function is used internally and should not
1351          *          be called unless you know what you
1352          *          are doing.
1353          *
1354          * FIXME We don't like the visibility handler being static
1355          *        but we leave it as is for the moment, until we
1356          *        come up a better solution.
1357          *
1358          * @param visibilityEventHandler The visibility event handler to be used.
1359          */
1360         static void _setVisibilityEventHandler(VisibilityEventHandler* visibilityEventHandler);
1361 
1362         /**
1363          * Gets the visibility event handler of this widget.
1364          *
1365          * WARNING: This function is used internally and should not
1366          *          be called unless you know what you
1367          *          are doing.
1368          *
1369          * FIXME  We don't like the visibility handler being static
1370          *        but we leave it as is for the moment, until we
1371          *        come up a better solution.
1372          */
1373         static VisibilityEventHandler* _getVisibilityEventHandler();
1374 
1375         static void _setGuiDeathListener(DeathListener* deathListener);
1376         static DeathListener* _getGuiDeathListener();
1377 
1378         /**
1379          * Sets the widget to vertical expandable.
1380          *
1381          * @param expand True if the widget can be vertical expanded, otherwise false.
1382          * @see isVerticalExpand
1383          */
1384         void setVerticalExpand(bool expand);
1385 
1386         /**
1387          * Gets if widget is vertical expandable.
1388          *
1389          * @return True if the widget can be vertical expanded, otherwise false.
1390          * @see setVerticalExpand
1391          */
1392         bool isVerticalExpand() const;
1393 
1394         /**
1395          * Sets the widget to horizontal expandable.
1396          *
1397          * @param expand True if the widget can be horizontal expanded, otherwise false.
1398          * @see isHorizontalExpand
1399          */
1400         void setHorizontalExpand(bool expand);
1401 
1402         /**
1403          * Gets if widget is horizontal expandable.
1404          *
1405          * @return True if the widget can be horizontal expanded, otherwise false.
1406          * @see setHorizontalExpand
1407          */
1408         bool isHorizontalExpand() const;
1409 
1410         /**
1411          * Execute the layouting.
1412          * In case you want to relayout a visible widget. This function will
1413          * automatically perform the layout adaption from the widget.
1414          *
1415          * @param top If true the layout adaption starts from the top-most layouted widget.
1416          */
1417         virtual void adaptLayout(bool top=true);
1418 
1419         /**
1420          * Resizes the widget's size to fit the content exactly,
1421          * calls recursively all childs.
1422          *
1423          * @param recursiv If true all child widgets also get the call.
1424          */
resizeToContent(bool recursiv=true)1425         virtual void resizeToContent(bool recursiv=true) {}
1426 
1427         /**
1428          * Resizes the widget's size to fit the content exactly.
1429          */
adjustSize()1430         virtual void adjustSize() {}
1431 
1432         /**
1433          * Expands the child widgets to the size of this widget,
1434          * calls recursively all childs.
1435          *
1436          * @param recursiv If true all child widgets also get the call.
1437          */
expandContent(bool recursiv=true)1438         virtual void expandContent(bool recursiv=true) {}
1439 
1440         /**
1441          * Helper function to decide if we need to layout.
1442          */
isLayouted()1443         virtual bool isLayouted() { return false; }
1444 
1445         void getLastPosition(int& x, int& y) const;
1446         void setLastPosition(int x, int y);
1447         bool isLastPositionSet() const;
1448 
1449     protected:
1450         /**
1451          * Distributes an action event to all action listeners
1452          * of the widget.
1453          *
1454          */
1455         void distributeActionEvent();
1456 
1457         /**
1458          * Distributes resized events to all of the widget's listeners.
1459          *
1460          */
1461         void distributeResizedEvent();
1462 
1463         /**
1464          * Distributes moved events to all of the widget's listeners.
1465          *
1466          */
1467         void distributeMovedEvent();
1468 
1469         /**
1470          * Distributes hidden events to all of the widget's listeners.
1471          *
1472          */
1473         void distributeHiddenEvent();
1474 
1475         /**
1476          * Distributes shown events to all of the widget's listeners.
1477          *
1478          */
1479         void distributeShownEvent();
1480 
1481         /**
1482          * Distributes ancestor moved events to all of the widget's listeners.
1483          * All children will also distribute the same event.
1484          *
1485          * @param ancestor Ancestor widget that was moved.
1486          */
1487         void distributeAncestorMovedEvent(Widget* ancestor);
1488 
1489         /**
1490          * Distributes ancestor hidden events to all of the widget's listeners.
1491          * All children will also distribute the same event.
1492          *
1493          * @param ancestor Ancestor widget that was hidden.
1494          */
1495         void distributeAncestorHiddenEvent(Widget* ancestor);
1496 
1497         /**
1498          * Distributes ancestor shown events to all of the widget's listeners.
1499          * All children will also distribute the same event.
1500          *
1501          * @param ancestor Ancestor widget that was shown.
1502          */
1503         void distributeAncestorShownEvent(Widget* ancestor);
1504 
1505         /**
1506          * Adds a child to the widget.
1507          *
1508          * THIS METHOD IS NOT SAFE TO CALL INSIDE A WIDGETS LOGIC FUNCTION
1509          * INSIDE ANY LISTER FUNCTIONS!
1510          *
1511          * @param widget The widget to add.
1512          * @see remove, clear
1513          */
1514         void add(Widget* widget);
1515 
1516         /**
1517          * Removes a child from the widget.
1518          *
1519          * THIS METHOD IS NOT SAFE TO CALL INSIDE A WIDGETS LOGIC FUNCTION
1520          * INSIDE ANY LISTER FUNCTIONS!
1521          *
1522          * @param widget The widget to remove.
1523          * @see add, clear
1524          */
1525         virtual void remove(Widget* widget);
1526 
1527         /**
1528          * Clears the widget from all its children.
1529          *
1530          * THIS METHOD IS NOT SAFE TO CALL INSIDE A WIDGETS LOGIC FUNCTION
1531          * INSIDE ANY LISTER FUNCTIONS!
1532          *
1533          * @see remove, clear
1534          */
1535         virtual void clear();
1536 
1537         /**
1538          * Finds a widget given an id. This function can be useful
1539          * when implementing a GUI generator for Guichan, such as
1540          * the ability to create a Guichan GUI from an XML file.
1541          *
1542          * @param id The id to find a widget by.
1543          * @return The widget with the corrosponding id,
1544          *         NULL of no widget is found.
1545          *
1546          */
1547         virtual Widget* findWidgetById(const std::string& id);
1548 
1549         /**
1550          * Resizes the widget to fit it's children exactly.
1551          *
1552          */
1553         void resizeToChildren();
1554 
1555         /**
1556          * Checks the size against the size constraints. Used by setDimension.
1557          *
1558          */
1559         void calculateSize();
1560 
1561         /**
1562          * Gets the children of the widget.
1563          *
1564          * @return A list of the widgets children.
1565          */
1566         const std::list<Widget*>& getChildren() const;
1567 
1568         /**
1569          * Holds the mouse listeners of the widget.
1570          */
1571         std::list<MouseListener*> mMouseListeners;
1572 
1573         /**
1574          * Holds the key listeners of the widget.
1575          */
1576         std::list<KeyListener*> mKeyListeners;
1577 
1578         /**
1579          * Holds the action listeners of the widget.
1580          */
1581         std::list<ActionListener*> mActionListeners;
1582 
1583         /**
1584          * Holds the death listeners of the widget.
1585          */
1586         std::list<DeathListener*> mDeathListeners;
1587 
1588         /**
1589          * Holds the focus listeners of the widget.
1590          */
1591         std::list<FocusListener*> mFocusListeners;
1592 
1593         /**
1594          * Holds the widget listeners of the widget.
1595          */
1596         std::list<WidgetListener*> mWidgetListeners;
1597 
1598         /**
1599          * Holds the foreground color of the widget.
1600          */
1601         Color mForegroundColor;
1602 
1603         /**
1604          * Holds the background color of the widget.
1605          */
1606         Color mBackgroundColor;
1607 
1608         /**
1609          * Holds the base color of the widget.
1610          */
1611         Color mBaseColor;
1612 
1613         /**
1614          * Holds the selection color of the widget.
1615          */
1616         Color mSelectionColor;
1617 
1618         /**
1619          * Holds the outline color of the widget.
1620          */
1621         Color mOutlineColor;
1622 
1623         /**
1624          * Holds the border color of the widget.
1625          */
1626         Color mBorderColor;
1627 
1628         /**
1629          * Holds the focus handler used by the widget.
1630          */
1631         FocusHandler* mFocusHandler;
1632 
1633         /**
1634          * Holds the focus handler used by the widget. NULL
1635          * if no internal focus handler is used.
1636          */
1637         FocusHandler* mInternalFocusHandler;
1638 
1639         /**
1640          * Holds the parent of the widget. NULL if the widget
1641          * has no parent.
1642          */
1643         Widget* mParent;
1644 
1645         /**
1646          * Holds the dimension of the widget.
1647          */
1648         Rectangle mDimension;
1649 
1650         /**
1651          * Holds the offset dimension of the widget.
1652          */
1653         Rectangle mOffsetRect;
1654 
1655         /**
1656          * Holds the outline size of the widget.
1657          */
1658         unsigned int mOutlineSize;
1659 
1660         /**
1661          * Holds the border size of the widget.
1662          */
1663         unsigned int mBorderSize;
1664 
1665         /**
1666          * Holds the selection mode.
1667          */
1668         SelectionMode mSelectionMode;
1669 
1670         /**
1671          * Holds the top margin of the widget.
1672          */
1673         int mMarginTop;
1674 
1675         /**
1676          * Holds the top right of the widget.
1677          */
1678         int mMarginRight;
1679 
1680         /**
1681          * Holds the bottom margin of the widget.
1682          */
1683         int mMarginBottom;
1684 
1685         /**
1686          * Holds the left margin of the widget.
1687          */
1688         int mMarginLeft;
1689 
1690         /**
1691          * Holds the top padding of the widget.
1692          */
1693         unsigned int mPaddingTop;
1694 
1695         /**
1696          * Holds the right padding of the widget.
1697          */
1698         unsigned int mPaddingRight;
1699 
1700         /**
1701          * Holds the bottom padding of the widget.
1702          */
1703         unsigned int mPaddingBottom;
1704 
1705         /**
1706          * Holds the left padding of the widget.
1707          */
1708         unsigned int mPaddingLeft;
1709 
1710         /**
1711          * Holds the action event of the widget.
1712          */
1713         std::string mActionEventId;
1714 
1715         /**
1716          * True if the widget focusable, false otherwise.
1717          */
1718         bool mFocusable;
1719 
1720         /**
1721          * True if the widget visible, false otherwise.
1722          */
1723         bool mVisible;
1724 
1725         /**
1726          * True if the widget has tab in enabled, false otherwise.
1727          */
1728         bool mTabIn;
1729 
1730         /**
1731          * True if the widget has tab in enabled, false otherwise.
1732          */
1733         bool mTabOut;
1734 
1735         /**
1736          * True if the widget is enabled, false otherwise.
1737          */
1738         bool mEnabled;
1739 
1740         /**
1741          * Holds the id of the widget.
1742          */
1743         std::string mId;
1744 
1745         /**
1746          * Holds the font used by the widget.
1747          */
1748         Font* mCurrentFont;
1749 
1750         /**
1751          * Holds the min size.
1752          */
1753         Size mMinSize;
1754 
1755         /**
1756          * Holds the min size.
1757          */
1758         Size mMaxSize;
1759 
1760         /**
1761          * Holds the fixed size.
1762          */
1763         Size mFixedSize;
1764 
1765         /**
1766          * True if the widget used a fixed size.
1767          */
1768         bool mIsFixedSize;
1769 
1770         /**
1771          * True if the widget can be vertical expanded.
1772          */
1773         bool mVExpand;
1774 
1775         /**
1776          * True if the widget can be horizontal expanded.
1777          */
1778         bool mHExpand;
1779 
1780         /**
1781          * Holds the default font used by the widget.
1782          */
1783         static DefaultFont mDefaultFont;
1784 
1785         /**
1786          * Holds the global font used by the widget.
1787          */
1788         static Font* mGlobalFont;
1789 
1790         /**
1791          * Holds a list of all instances of widgets.
1792          */
1793         static std::list<Widget*> mWidgetInstances;
1794 
1795         /**
1796          * Holds the visibility event handler used by the widgets.
1797          *
1798          * FIXME We don't like the visibility handler being static
1799          *        but we leave it as is for the moment, until we
1800          *        come up a better solution.
1801          */
1802         static VisibilityEventHandler* mVisibilityEventHandler;
1803 
1804         static DeathListener* mGuiDeathListener;
1805 
1806         /**
1807          * Holds all children of the widget.
1808          */
1809         std::list<Widget*> mChildren;
1810 
1811         int mLastX;
1812         int mLastY;
1813     };
1814 }
1815 
1816 #endif // end FCN_WIDGET_HPP
1817