| focushandler.hpp | | focushandler.hpp | |
| | | | |
| skipping to change at line 62 | | skipping to change at line 62 | |
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | |
| * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| */ | | */ | |
| | | | |
| #ifndef GCN_FOCUSHANDLER_HPP | | #ifndef GCN_FOCUSHANDLER_HPP | |
| #define GCN_FOCUSHANDLER_HPP | | #define GCN_FOCUSHANDLER_HPP | |
| | | | |
| #include <vector> | | #include <vector> | |
| | | | |
|
| | | #include "guichan/event.hpp" | |
| #include "guichan/platform.hpp" | | #include "guichan/platform.hpp" | |
| | | | |
| namespace gcn | | namespace gcn | |
| { | | { | |
| class Widget; | | class Widget; | |
| | | | |
| /** | | /** | |
| * Used to keep track of widget focus. You will probably not have | | * Used to keep track of widget focus. You will probably not have | |
| * to use the FocusHandler directly to handle focus. Widget has | | * to use the FocusHandler directly to handle focus. Widget has | |
| * functions for handling focus which uses a FocusHandler. Use them | | * functions for handling focus which uses a FocusHandler. Use them | |
| * instead. | | * instead. | |
| * | | * | |
| * @see Widget::isFocused | | * @see Widget::isFocused | |
| * @see Widget::requestFocus | | * @see Widget::requestFocus | |
| * @see Widget::setFocusable | | * @see Widget::setFocusable | |
| * @see Widget::isFocusable | | * @see Widget::isFocusable | |
|
| * @see Widget::gotFocus | | * @see FocusListener | |
| * @see Widget::lostFocus | | | |
| */ | | */ | |
| class GCN_CORE_DECLSPEC FocusHandler | | class GCN_CORE_DECLSPEC FocusHandler | |
| { | | { | |
| public: | | public: | |
| | | | |
| /** | | /** | |
| * Constructor. | | * Constructor. | |
| */ | | */ | |
| FocusHandler(); | | FocusHandler(); | |
| | | | |
| /** | | /** | |
| * Destructor. | | * Destructor. | |
| */ | | */ | |
| virtual ~FocusHandler() { }; | | virtual ~FocusHandler() { }; | |
| | | | |
| /** | | /** | |
|
| * Sets focus to a widget. Widget::lostFocus and | | * Sets focus to a widget. A focus event will also be sent to the w | |
| * Widget::gotFocus will be called. | | idget's | |
| | | * focus listeners. | |
| * | | * | |
| * @param widget the widget to focus. | | * @param widget the widget to focus. | |
| */ | | */ | |
| virtual void requestFocus(Widget* widget); | | virtual void requestFocus(Widget* widget); | |
| | | | |
| /** | | /** | |
| * Sets modal focus to a widget. | | * Sets modal focus to a widget. | |
| * | | * | |
| * @param widget the Widget to focus modal. | | * @param widget the Widget to focus modal. | |
| * @throws Exception when another widget already has modal focus. | | * @throws Exception when another widget already has modal focus. | |
| | | | |
| skipping to change at line 200 | | skipping to change at line 200 | |
| virtual void add(Widget* widget); | | virtual void add(Widget* widget); | |
| | | | |
| /** | | /** | |
| * Removes a widget from the FocusHandler. | | * Removes a widget from the FocusHandler. | |
| * | | * | |
| * @param widget the widget to remove. | | * @param widget the widget to remove. | |
| */ | | */ | |
| virtual void remove(Widget* widget); | | virtual void remove(Widget* widget); | |
| | | | |
| /** | | /** | |
|
| * Focuses nothing. | | * Focuses nothing. A focus event will also be sent to the focused | |
| | | widget's | |
| | | * focus listeners if a widget has focus. | |
| */ | | */ | |
| virtual void focusNone(); | | virtual void focusNone(); | |
| | | | |
| /** | | /** | |
| * Focuses the next Widget which allows tab in unless current focus
ed | | * Focuses the next Widget which allows tab in unless current focus
ed | |
| * Widget disallows tab out. | | * Widget disallows tab out. | |
| */ | | */ | |
| virtual void tabNext(); | | virtual void tabNext(); | |
| | | | |
| /** | | /** | |
| * Focuses the previous Widget which allows tab in unless current f
ocused | | * Focuses the previous Widget which allows tab in unless current f
ocused | |
| * Widget disallows tab out. | | * Widget disallows tab out. | |
| */ | | */ | |
| virtual void tabPrevious(); | | virtual void tabPrevious(); | |
| | | | |
| /** | | /** | |
|
| * Applies the changes. | | * Gets the widget being dragged. | |
| | | * | |
| | | * @return the widget being dragged. | |
| */ | | */ | |
|
| virtual void applyChanges(); | | virtual Widget* getDraggedWidget(); | |
| | | | |
| | | /** | |
| | | * Sets the widget being dragged. | |
| | | * | |
| | | * @param draggedWidget the widget being dragged. | |
| | | */ | |
| | | virtual void setDraggedWidget(Widget* draggedWidget); | |
| | | | |
| | | /** | |
| | | * Gets the last widget with the mouse. | |
| | | * | |
| | | * @return the last widget with the mouse. | |
| | | */ | |
| | | virtual Widget* getLastWidgetWithMouse(); | |
| | | | |
| | | /** | |
| | | * Sets the last widget with the mouse. | |
| | | * | |
| | | * @param lastWidgetWithMouse the last widget with the mouse. | |
| | | */ | |
| | | virtual void setLastWidgetWithMouse(Widget* lastWidgetWithMouse); | |
| | | | |
| | | /** | |
| | | * Gets the last widget with modal focus. | |
| | | * | |
| | | * @return the last widget with modal focus. | |
| | | */ | |
| | | virtual Widget* getLastWidgetWithModalFocus(); | |
| | | | |
| | | /** | |
| | | * Sets the last widget with modal focus. | |
| | | * | |
| | | * @param lastWidgetWithModalFocus the last widget with modal focus | |
| | | . | |
| | | */ | |
| | | virtual void setLastWidgetWithModalFocus(Widget* lastWidgetWithModa | |
| | | lFocus); | |
| | | | |
| | | /** | |
| | | * Gets the last widget with modal mouse input focus. | |
| | | * | |
| | | * @return the last widget with modal mouse input focus. | |
| | | */ | |
| | | virtual Widget* getLastWidgetWithModalMouseInputFocus(); | |
| | | | |
| | | /** | |
| | | * Sets the last widget with modal mouse input focus. | |
| | | * | |
| | | * @param lastMouseWithModalMouseInputFocus the last widget with m | |
| | | odal mouse input focus. | |
| | | */ | |
| | | virtual void setLastWidgetWithModalMouseInputFocus(Widget* lastWidg | |
| | | etWithModalMouseInputFocus); | |
| | | | |
| | | /** | |
| | | * Gets the last widget pressed. | |
| | | * | |
| | | * @return the last widget pressed. | |
| | | */ | |
| | | virtual Widget* getLastWidgetPressed(); | |
| | | | |
| | | /** | |
| | | * Sets the last widget pressed. | |
| | | * | |
| | | * @param lastWidgetPressed the last widget pressed. | |
| | | */ | |
| | | virtual void setLastWidgetPressed(Widget* lastWidgetPressed); | |
| | | | |
| protected: | | protected: | |
|
| | | /** | |
| | | * Distributes a focus lost event. | |
| | | * | |
| | | * @param focusEvent the event to distribute. | |
| | | * @author Olof Naess | |
| | | * @since 0.7.0 | |
| | | */ | |
| | | virtual void distributeFocusLostEvent(const Event& focusEvent); | |
| | | | |
| | | /** | |
| | | * Distributes a focus gained event. | |
| | | * | |
| | | * @param focusEvent the event to distribute. | |
| | | * @author Olof Naess | |
| | | * @since 0.7.0 | |
| | | */ | |
| | | virtual void distributeFocusGainedEvent(const Event& focusEvent); | |
| | | | |
| typedef std::vector<Widget*> WidgetVector; | | typedef std::vector<Widget*> WidgetVector; | |
| typedef WidgetVector::iterator WidgetIterator; | | typedef WidgetVector::iterator WidgetIterator; | |
| WidgetVector mWidgets; | | WidgetVector mWidgets; | |
| | | | |
| Widget* mFocusedWidget; | | Widget* mFocusedWidget; | |
|
| Widget* mToBeFocused; | | | |
| Widget* mModalFocusedWidget; | | Widget* mModalFocusedWidget; | |
| Widget* mModalMouseInputFocusedWidget; | | Widget* mModalMouseInputFocusedWidget; | |
|
| | | | |
| | | Widget* mDraggedWidget; | |
| | | Widget* mLastWidgetWithMouse; | |
| | | Widget* mLastWidgetWithModalFocus; | |
| | | Widget* mLastWidgetWithModalMouseInputFocus; | |
| | | Widget* mLastWidgetPressed; | |
| }; | | }; | |
| } | | } | |
| | | | |
| #endif // end GCN_FOCUSHANDLER_HPP | | #endif // end GCN_FOCUSHANDLER_HPP | |
| | | | |
End of changes. 9 change blocks. |
| 8 lines changed or deleted | | 103 lines changed or added | |
|
| widget.hpp | | widget.hpp | |
| | | | |
| skipping to change at line 73 | | skipping to change at line 73 | |
| #include "guichan/color.hpp" | | #include "guichan/color.hpp" | |
| #include "guichan/rectangle.hpp" | | #include "guichan/rectangle.hpp" | |
| | | | |
| namespace gcn | | namespace gcn | |
| { | | { | |
| class ActionListener; | | class ActionListener; | |
| class BasicContainer; | | class BasicContainer; | |
| class DeathListener; | | class DeathListener; | |
| class DefaultFont; | | class DefaultFont; | |
| class FocusHandler; | | class FocusHandler; | |
|
| | | class FocusListener; | |
| class Font; | | class Font; | |
| class Graphics; | | class Graphics; | |
| class KeyInput; | | class KeyInput; | |
| class KeyListener; | | class KeyListener; | |
| class MouseInput; | | class MouseInput; | |
| class MouseListener; | | class MouseListener; | |
| | | | |
| /** | | /** | |
| * Widget base class. Contains basic widget functions every widget shou
ld | | * Widget base class. Contains basic widget functions every widget shou
ld | |
| * have. Widgets should inherit from this class and implements it's | | * have. Widgets should inherit from this class and implements it's | |
| | | | |
| skipping to change at line 96 | | skipping to change at line 97 | |
| * be overloaded unless you know what you are doing | | * be overloaded unless you know what you are doing | |
| * | | * | |
| * @author Olof Naess | | * @author Olof Naess | |
| * @author Per Larsson. | | * @author Per Larsson. | |
| */ | | */ | |
| class GCN_CORE_DECLSPEC Widget | | class GCN_CORE_DECLSPEC Widget | |
| { | | { | |
| public: | | public: | |
| /** | | /** | |
| * Constructor. Resets member variables. Noteable, a widget is not | | * Constructor. Resets member variables. Noteable, a widget is not | |
|
| * focusable as default, therefore, Widgets that are supposed to be | | * focusable as default, therefore, widgets that are supposed to be | |
| * focusable should overide this default in their own constructor. | | * focusable should overide this default in their own constructor. | |
| */ | | */ | |
| Widget(); | | Widget(); | |
| | | | |
| /** | | /** | |
| * Default destructor. | | * Default destructor. | |
| */ | | */ | |
| virtual ~Widget(); | | virtual ~Widget(); | |
| | | | |
| /** | | /** | |
|
| * Draws the Widget. It is called by the parent widget when it is t | | * Draws the widget. It is called by the parent widget when it is t | |
| ime | | ime | |
| * for the Widget to draw itself. The graphics object is set up so | | * for the widget to draw itself. The graphics object is set up so | |
| * that all drawing is relative to the Widget, i.e coordinate (0,0) | | * that all drawing is relative to the widget, i.e coordinate (0,0) | |
| is | | is | |
| * the top-left corner of the Widget. It is not possible to draw | | * the top-left corner of the widget. It is not possible to draw | |
| * outside of a Widgets dimension. | | * outside of a widgets dimension. | |
| * | | * | |
| * @param graphics a Graphics object to draw with. | | * @param graphics a Graphics object to draw with. | |
| */ | | */ | |
| virtual void draw(Graphics* graphics) = 0; | | virtual void draw(Graphics* graphics) = 0; | |
| | | | |
| /** | | /** | |
|
| * Draws the Widget border. A border is drawn around a Widget. | | * Draws the widget border. A border is drawn around a widget. | |
| * The width and height of the border is therefore the Widgets | | * The width and height of the border is therefore the widgets | |
| * height+2*bordersize. Think of a painting that has a certain size
, | | * height+2*bordersize. Think of a painting that has a certain size
, | |
| * the border surrounds the painting. | | * the border surrounds the painting. | |
| * | | * | |
| * @param graphics a Graphics object to draw with. | | * @param graphics a Graphics object to draw with. | |
| */ | | */ | |
| virtual void drawBorder(Graphics* graphics) { } | | virtual void drawBorder(Graphics* graphics) { } | |
| | | | |
| /** | | /** | |
|
| * Called for all Widgets in the gui each time Gui::logic is called
. | | * Called for all widgets in the gui each time Gui::logic is called
. | |
| * You can do logic stuff here like playing an animation. | | * You can do logic stuff here like playing an animation. | |
| * | | * | |
| * @see Gui | | * @see Gui | |
| */ | | */ | |
| virtual void logic() { } | | virtual void logic() { } | |
| | | | |
| /** | | /** | |
|
| * Gets the Widget parent container. | | * Gets the widget parent container. | |
| * | | * | |
|
| * @return the Widget parent container. Returns NULL if the Widget | | * @return the widget parent container. Returns NULL if the widget | |
| * has no parent. | | * has no parent. | |
| */ | | */ | |
| virtual Widget* getParent() const; | | virtual Widget* getParent() const; | |
| | | | |
| /** | | /** | |
|
| * Sets the width of the Widget in pixels. | | * Sets the width of the widget in pixels. | |
| * | | * | |
|
| * @param width the Widget width in pixels. | | * @param width the widget width in pixels. | |
| */ | | */ | |
| virtual void setWidth(int width); | | virtual void setWidth(int width); | |
| | | | |
| /** | | /** | |
|
| * Gets the width of the Widget in pixels. | | * Gets the width of the widget in pixels. | |
| * | | * | |
|
| * @return the Widget with in pixels. | | * @return the widget with in pixels. | |
| */ | | */ | |
| virtual int getWidth() const; | | virtual int getWidth() const; | |
| | | | |
| /** | | /** | |
|
| * Sets the height of the Widget in pixels. | | * Sets the height of the widget in pixels. | |
| * | | * | |
|
| * @param height the Widget height in pixels. | | * @param height the widget height in pixels. | |
| */ | | */ | |
| virtual void setHeight(int height); | | virtual void setHeight(int height); | |
| | | | |
| /** | | /** | |
|
| * Gets the height of the Widget in pixels. | | * Gets the height of the widget in pixels. | |
| * | | * | |
|
| * @return the Widget height in pixels. | | * @return the widget height in pixels. | |
| */ | | */ | |
| virtual int getHeight() const; | | virtual int getHeight() const; | |
| | | | |
| /** | | /** | |
|
| * Sets the size of the Widget. | | * Sets the size of the widget. | |
| * | | * | |
| * @param width the width. | | * @param width the width. | |
| * @param height the height. | | * @param height the height. | |
| */ | | */ | |
| virtual void setSize(int width, int height); | | virtual void setSize(int width, int height); | |
| | | | |
| /** | | /** | |
|
| * Set the Widget x coordinate. It is relateive to it's parent. | | * Set the widget x coordinate. It is relateive to it's parent. | |
| * | | * | |
|
| * @param x the Widget x coordinate. | | * @param x the widget x coordinate. | |
| */ | | */ | |
| virtual void setX(int x); | | virtual void setX(int x); | |
| | | | |
| /** | | /** | |
|
| * Gets the Widget x coordinate. It is relative to it's parent. | | * Gets the widget x coordinate. It is relative to it's parent. | |
| * | | * | |
|
| * @return the Widget x coordinate. | | * @return the widget x coordinate. | |
| */ | | */ | |
| virtual int getX() const; | | virtual int getX() const; | |
| | | | |
| /** | | /** | |
|
| * Set the Widget y coordinate. It is relative to it's parent. | | * Set the widget y coordinate. It is relative to it's parent. | |
| * | | * | |
|
| * @param y the Widget y coordinate. | | * @param y the widget y coordinate. | |
| */ | | */ | |
| virtual void setY(int y); | | virtual void setY(int y); | |
| | | | |
| /** | | /** | |
|
| * Gets the Widget y coordinate. It is relative to it's parent. | | * Gets the widget y coordinate. It is relative to it's parent. | |
| * | | * | |
|
| * @return the Widget y coordinate. | | * @return the widget y coordinate. | |
| */ | | */ | |
| virtual int getY() const; | | virtual int getY() const; | |
| | | | |
| /** | | /** | |
|
| * Sets the Widget position. It is relative to it's parent. | | * Sets the widget position. It is relative to it's parent. | |
| * | | * | |
|
| * @param x the Widget x coordinate. | | * @param x the widget x coordinate. | |
| * @param y the Widgets y coordinate. | | * @param y the widgets y coordinate. | |
| */ | | */ | |
| virtual void setPosition(int x, int y); | | virtual void setPosition(int x, int y); | |
| | | | |
| /** | | /** | |
|
| * Sets the dimension of the Widget. It is relative to it's parent. | | * Sets the dimension of the widget. It is relative to it's parent. | |
| * | | * | |
|
| * @param dimension the Widget dimension. | | * @param dimension the widget dimension. | |
| */ | | */ | |
| virtual void setDimension(const Rectangle& dimension); | | virtual void setDimension(const Rectangle& dimension); | |
| | | | |
| /** | | /** | |
| * Sets the size of the border, or the width if you so like. The si
ze | | * Sets the size of the border, or the width if you so like. The si
ze | |
|
| * is the number of pixels that the border extends outside the Widg
et. | | * is the number of pixels that the border extends outside the widg
et. | |
| * Border size = 0 means no border. | | * Border size = 0 means no border. | |
| * | | * | |
| * @param borderSize the size of the border. | | * @param borderSize the size of the border. | |
| * @see drawBorder | | * @see drawBorder | |
| */ | | */ | |
| virtual void setBorderSize(unsigned int borderSize); | | virtual void setBorderSize(unsigned int borderSize); | |
| | | | |
| /** | | /** | |
| * Gets the size of the border, or the width if you so like. The si
ze | | * Gets the size of the border, or the width if you so like. The si
ze | |
|
| * is the number of pixels that the border extends outside the Widg
et. | | * is the number of pixels that the border extends outside the widg
et. | |
| * Border size = 0 means no border. | | * Border size = 0 means no border. | |
| * | | * | |
| * @return the size of the border. | | * @return the size of the border. | |
| * @see drawBorder | | * @see drawBorder | |
| */ | | */ | |
| virtual unsigned int getBorderSize() const; | | virtual unsigned int getBorderSize() const; | |
| | | | |
| /** | | /** | |
|
| * Gets the dimension of the Widget. It is relative to it's parent. | | * Gets the dimension of the widget. It is relative to it's parent. | |
| * | | * | |
| * @return the widget dimension. | | * @return the widget dimension. | |
| */ | | */ | |
| virtual const Rectangle& getDimension() const; | | virtual const Rectangle& getDimension() const; | |
| | | | |
| /** | | /** | |
|
| * Sets a Widgets focusability. | | * Sets a widgets focusability. | |
| * | | * | |
|
| * @param focusable true if the Widget should be focusable. | | * @param focusable true if the widget should be focusable. | |
| */ | | */ | |
| virtual void setFocusable(bool focusable); | | virtual void setFocusable(bool focusable); | |
| | | | |
| /** | | /** | |
|
| * Checks whether the Widget is focusable. | | * Checks whether the widget is focusable. | |
| * | | * | |
| * @return true if the widget is focusable. | | * @return true if the widget is focusable. | |
| */ | | */ | |
| virtual bool isFocusable() const; | | virtual bool isFocusable() const; | |
| | | | |
| /** | | /** | |
|
| * Checks if the Widget is focused. | | * Checks if the widget is focused. | |
| * | | * | |
| * @return true if the widget currently has focus. | | * @return true if the widget currently has focus. | |
| */ | | */ | |
| virtual bool isFocused() const; | | virtual bool isFocused() const; | |
| | | | |
| /** | | /** | |
|
| * Sets the Widget to be disabled or enabled. A disabled | | * Sets the widget to be disabled or enabled. A disabled | |
| * Widget will never recieve mouse or key input. | | * widget will never recieve mouse or key input. | |
| * | | * | |
|
| * @param enabled true if Widget is enabled. | | * @param enabled true if widget is enabled. | |
| */ | | */ | |
| virtual void setEnabled(bool enabled); | | virtual void setEnabled(bool enabled); | |
| | | | |
| /** | | /** | |
|
| * Checks if a Widget is disabled or not. | | * Checks if a widget is disabled or not. | |
| * | | * | |
|
| * @return true if the Widget should be enabled. | | * @return true if the widget should be enabled. | |
| */ | | */ | |
| virtual bool isEnabled() const; | | virtual bool isEnabled() const; | |
| | | | |
| /** | | /** | |
|
| * Called if the Widget looses focus. | | * Sets the widget to be visible. | |
| */ | | | |
| virtual void focusLost() { }; | | | |
| | | | |
| /** | | | |
| * Called if the Widget recieves focus. | | | |
| */ | | | |
| virtual void focusGained() { }; | | | |
| | | | |
| /** | | | |
| * Sets the Widget to be visible. | | | |
| * | | * | |
|
| * @param visible true if the Widget should be visiable. | | * @param visible true if the widget should be visiable. | |
| */ | | */ | |
| virtual void setVisible(bool visible); | | virtual void setVisible(bool visible); | |
| | | | |
| /** | | /** | |
|
| * Checks if the Widget is visible. | | * Checks if the widget is visible. | |
| * | | * | |
|
| * @return true if the Widget is visible. | | * @return true if the widget is visible. | |
| */ | | */ | |
| virtual bool isVisible() const; | | virtual bool isVisible() const; | |
| | | | |
| /** | | /** | |
| * Sets the base color. The base color is the background | | * Sets the base color. The base color is the background | |
|
| * color for many Widgets like the Button and Contianer Widgets. | | * color for many widgets like the Button and Contianer widgets. | |
| * | | * | |
|
| * @param color the baseground Color. | | * @param color the baseground color. | |
| */ | | */ | |
| virtual void setBaseColor(const Color& color); | | virtual void setBaseColor(const Color& color); | |
| | | | |
| /** | | /** | |
| * Gets the base color. | | * Gets the base color. | |
| * | | * | |
|
| * @return the foreground Color. | | * @return the foreground color. | |
| */ | | */ | |
| virtual const Color& getBaseColor() const; | | virtual const Color& getBaseColor() const; | |
| | | | |
| /** | | /** | |
| * Sets the foreground color. | | * Sets the foreground color. | |
| * | | * | |
|
| * @param color the foreground Color. | | * @param color the foreground color. | |
| */ | | */ | |
| virtual void setForegroundColor(const Color& color); | | virtual void setForegroundColor(const Color& color); | |
| | | | |
| /** | | /** | |
| * Gets the foreground color. | | * Gets the foreground color. | |
| * | | * | |
|
| * @return the foreground Color. | | * @return the foreground color. | |
| */ | | */ | |
| virtual const Color& getForegroundColor() const; | | virtual const Color& getForegroundColor() const; | |
| | | | |
| /** | | /** | |
| * Sets the background color. | | * Sets the background color. | |
| * | | * | |
| * @param color the background Color. | | * @param color the background Color. | |
| */ | | */ | |
| virtual void setBackgroundColor(const Color& color); | | virtual void setBackgroundColor(const Color& color); | |
| | | | |
| /** | | /** | |
| * Gets the background color. | | * Gets the background color. | |
| * | | * | |
|
| * @return the background Color. | | * @return the background color. | |
| */ | | */ | |
| virtual const Color& getBackgroundColor() const; | | virtual const Color& getBackgroundColor() const; | |
| | | | |
| /** | | /** | |
|
| * Requests focus for the Widget. A Widget will only recieve focus | | * Sets the selection color. | |
| | | * | |
| | | * @param color the selection color. | |
| | | */ | |
| | | virtual void setSelectionColor(const Color& color); | |
| | | | |
| | | /** | |
| | | * Gets the selection color. | |
| | | * | |
| | | * @return the selection color. | |
| | | */ | |
| | | virtual const Color& getSelectionColor() const; | |
| | | | |
| | | /** | |
| | | * Requests focus for the widget. A widget will only recieve focus | |
| * if it is focusable. | | * if it is focusable. | |
| */ | | */ | |
| virtual void requestFocus(); | | virtual void requestFocus(); | |
| | | | |
| /** | | /** | |
|
| * Requests a move to the top in the parent Widget. | | * Requests a move to the top in the parent widget. | |
| */ | | */ | |
| virtual void requestMoveToTop(); | | virtual void requestMoveToTop(); | |
| | | | |
| /** | | /** | |
|
| * Requests a move to the bottom in the parent Widget. | | * Requests a move to the bottom in the parent widget. | |
| */ | | */ | |
| virtual void requestMoveToBottom(); | | virtual void requestMoveToBottom(); | |
| | | | |
| /** | | /** | |
| * Sets the FocusHandler to be used. | | * Sets the FocusHandler to be used. | |
| * | | * | |
| * WARNING: This function is used internally and should not | | * WARNING: This function is used internally and should not | |
| * be called or overloaded unless you know what you | | * be called or overloaded unless you know what you | |
| * are doing. | | * are doing. | |
| * | | * | |
| | | | |
| skipping to change at line 391 | | skipping to change at line 396 | |
| * | | * | |
| * WARNING: This function is used internally and should not | | * WARNING: This function is used internally and should not | |
| * be called or overloaded unless you know what you | | * be called or overloaded unless you know what you | |
| * are doing. | | * are doing. | |
| * | | * | |
| * @return the FocusHandler used. | | * @return the FocusHandler used. | |
| */ | | */ | |
| virtual FocusHandler* _getFocusHandler(); | | virtual FocusHandler* _getFocusHandler(); | |
| | | | |
| /** | | /** | |
|
| * Adds an ActionListener to the Widget. When an action is triggere | | * Adds an ActionListener to the widget. When an action is triggere | |
| d | | d | |
| * by the Widget, the action function in all the Widget's | | * by the widget, the action function in all the widget's | |
| * ActionListeners will be called. | | * ActionListeners will be called. | |
| * | | * | |
| * @param actionListener the ActionListener to add. | | * @param actionListener the ActionListener to add. | |
| */ | | */ | |
| virtual void addActionListener(ActionListener* actionListener); | | virtual void addActionListener(ActionListener* actionListener); | |
| | | | |
| /** | | /** | |
|
| * Removes an added ActionListener from the Widget. | | * Removes an added ActionListener from the widget. | |
| * | | * | |
| * @param actionListener the ActionListener to remove. | | * @param actionListener the ActionListener to remove. | |
| */ | | */ | |
| virtual void removeActionListener(ActionListener* actionListener); | | virtual void removeActionListener(ActionListener* actionListener); | |
| | | | |
| /** | | /** | |
|
| * Adds a DeathListener to the Widget. When the widget dies | | * Adds a DeathListener to the widget. When the widget dies | |
| * the death function in all the Widget's DeathListeners will be ca | | * the death function in all the widget's DeathListeners will be ca | |
| lled. | | lled. | |
| * | | * | |
| * @param actionListener the DeathListener to add. | | * @param actionListener the DeathListener to add. | |
| */ | | */ | |
| virtual void addDeathListener(DeathListener* deathListener); | | virtual void addDeathListener(DeathListener* deathListener); | |
| | | | |
| /** | | /** | |
|
| * Removes an added DeathListener from the Widget. | | * Removes an added DeathListener from the widget. | |
| * | | * | |
| * @param deathListener the DeathListener to remove. | | * @param deathListener the DeathListener to remove. | |
| */ | | */ | |
| virtual void removeDeathListener(DeathListener* deathListener); | | virtual void removeDeathListener(DeathListener* deathListener); | |
| | | | |
| /** | | /** | |
|
| * Adds a MouseListener to the Widget. When a mouse message is | | * Adds a MouseListener to the widget. When a mouse message is | |
| * recieved, it will be sent to the Widget's MouseListeners. | | * recieved, it will be sent to the widget's MouseListeners. | |
| * | | * | |
| * @param mouseListener the MouseListener to add. | | * @param mouseListener the MouseListener to add. | |
| */ | | */ | |
| virtual void addMouseListener(MouseListener* mouseListener); | | virtual void addMouseListener(MouseListener* mouseListener); | |
| | | | |
| /** | | /** | |
|
| * Removes an added MouseListener from the Widget. | | * Removes an added MouseListener from the widget. | |
| * | | * | |
| * @param mouseListener the MouseListener to remove. | | * @param mouseListener the MouseListener to remove. | |
| */ | | */ | |
| virtual void removeMouseListener(MouseListener* mouseListener); | | virtual void removeMouseListener(MouseListener* mouseListener); | |
| | | | |
| /** | | /** | |
|
| * Adds a KeyListener to the Widget. When a key message is recieved | | * Adds a KeyListener to the widget. When a key message is recieved | |
| , | | , | |
| * it will be sent to the Widget's KeyListeners. | | * it will be sent to the widget's KeyListeners. | |
| * | | * | |
| * @param keyListener the KeyListener to add. | | * @param keyListener the KeyListener to add. | |
| */ | | */ | |
| virtual void addKeyListener(KeyListener* keyListener); | | virtual void addKeyListener(KeyListener* keyListener); | |
| | | | |
| /** | | /** | |
|
| * Removes an added KeyListener from the Widget. | | * Removes an added KeyListener from the widget. | |
| * | | * | |
| * @param keyListener the KeyListener to remove. | | * @param keyListener the KeyListener to remove. | |
| */ | | */ | |
| virtual void removeKeyListener(KeyListener* keyListener); | | virtual void removeKeyListener(KeyListener* keyListener); | |
| | | | |
|
| | | /** | |
| | | * Adds a FocusListener to the widget. When a focus event is reciev | |
| | | ed, | |
| | | * it will be sent to the widget's FocusListeners. | |
| | | * | |
| | | * @param focusListener the FocusListener to add. | |
| | | * @author Olof Naess | |
| | | * @since 0.7.0 | |
| | | */ | |
| | | virtual void addFocusListener(FocusListener* focusListener); | |
| | | | |
| /** | | /** | |
|
| * Sets the action event identifier of the Widget. The identifier i | | * Removes an added FocusListener from the widget. | |
| s | | * | |
| | | * @param focusListener the FocusListener to remove. | |
| | | * @author Olof Naess | |
| | | * @since 0.7.0 | |
| | | */ | |
| | | virtual void removeFocusListener(FocusListener* FocusListener); | |
| | | | |
| | | /** | |
| | | * Sets the action event identifier of the widget. The identifier i | |
| | | s | |
| * used to be able to identify which action has occured. | | * used to be able to identify which action has occured. | |
| * | | * | |
| * NOTE: An action event identifier should not be used to identify
a | | * NOTE: An action event identifier should not be used to identify
a | |
|
| * certain Widget but rather a certain event in your applicat | | * certain widget but rather a certain event in your applicat | |
| ion. | | ion. | |
| * Several Widgets can have the same action event identifer. | | * Several widgets can have the same action event identifer. | |
| * | | * | |
| * @param actionEventId the action event identifier. | | * @param actionEventId the action event identifier. | |
| * @since 0.6.0 | | * @since 0.6.0 | |
| */ | | */ | |
| virtual void setActionEventId(const std::string& actionEventId); | | virtual void setActionEventId(const std::string& actionEventId); | |
| | | | |
| /** | | /** | |
| * Gets the action event identifier. | | * Gets the action event identifier. | |
| * | | * | |
| * @return the action event identifier. | | * @return the action event identifier. | |
| */ | | */ | |
| virtual const std::string& getActionEventId() const; | | virtual const std::string& getActionEventId() const; | |
| | | | |
| /** | | /** | |
|
| * Gets the absolute position on the screen for the Widget. | | * Gets the absolute position on the screen for the widget. | |
| * | | * | |
| * @param x absolute x coordinate will be stored in this parameter. | | * @param x absolute x coordinate will be stored in this parameter. | |
| * @param y absolute y coordinate will be stored in this parameter. | | * @param y absolute y coordinate will be stored in this parameter. | |
| */ | | */ | |
| virtual void getAbsolutePosition(int& x, int& y) const; | | virtual void getAbsolutePosition(int& x, int& y) const; | |
| | | | |
| /** | | /** | |
|
| * Sets the parent of the Widget. A parent must be a BasicContainer
. | | * Sets the parent of the widget. A parent must be a BasicContainer
. | |
| * | | * | |
| * WARNING: This function is used internally and should not | | * WARNING: This function is used internally and should not | |
| * be called or overloaded unless you know what you | | * be called or overloaded unless you know what you | |
| * are doing. | | * are doing. | |
| * | | * | |
| * @param parent the parent BasicContainer.. | | * @param parent the parent BasicContainer.. | |
| */ | | */ | |
| virtual void _setParent(Widget* parent); | | virtual void _setParent(Widget* parent); | |
| | | | |
| /** | | /** | |
| * Gets the font used. If no font has been set, the global font wil
l | | * Gets the font used. If no font has been set, the global font wil
l | |
| * be returned instead. If no global font has been set, the default | | * be returned instead. If no global font has been set, the default | |
| * font will be returend. | | * font will be returend. | |
| * ugly default. | | * ugly default. | |
| * | | * | |
| * @return the used Font. | | * @return the used Font. | |
| */ | | */ | |
| Font *getFont() const; | | Font *getFont() const; | |
| | | | |
| /** | | /** | |
|
| * Sets the global font to be used by default for all Widgets. | | * Sets the global font to be used by default for all widgets. | |
| * | | * | |
| * @param font the global Font. | | * @param font the global Font. | |
| */ | | */ | |
| static void setGlobalFont(Font* font); | | static void setGlobalFont(Font* font); | |
| | | | |
| /** | | /** | |
| * Sets the font. If font is NULL, the global font will be used. | | * Sets the font. If font is NULL, the global font will be used. | |
| * | | * | |
| * @param font the Font. | | * @param font the Font. | |
| */ | | */ | |
| virtual void setFont(Font* font); | | virtual void setFont(Font* font); | |
| | | | |
| /** | | /** | |
| * Called when the font has changed. If the change is global, | | * Called when the font has changed. If the change is global, | |
|
| * this function will only be called if the Widget don't have a | | * this function will only be called if the widget don't have a | |
| * font already set. | | * font already set. | |
| */ | | */ | |
| virtual void fontChanged() { } | | virtual void fontChanged() { } | |
| | | | |
| /** | | /** | |
|
| * Checks whether a Widget exists or not, that is if it still exist
s | | * Checks whether a widget exists or not, that is if it still exist
s | |
| * an instance of the object. | | * an instance of the object. | |
| * | | * | |
|
| * @param widget the Widget to check. | | * @param widget the widget to check. | |
| */ | | */ | |
| static bool widgetExists(const Widget* widget); | | static bool widgetExists(const Widget* widget); | |
| | | | |
| /** | | /** | |
| * Check if tab in is enabled. Tab in means that you can set focus | | * Check if tab in is enabled. Tab in means that you can set focus | |
|
| * to this Widget by pressing the tab button. If tab in is disabled | | * to this widget by pressing the tab button. If tab in is disabled | |
| * then the FocusHandler will skip this widget and focus the next | | * then the FocusHandler will skip this widget and focus the next | |
| * in its focus order. | | * in its focus order. | |
| * | | * | |
| * @return true if tab in is enabled. | | * @return true if tab in is enabled. | |
| */ | | */ | |
| virtual bool isTabInEnabled() const; | | virtual bool isTabInEnabled() const; | |
| | | | |
| /** | | /** | |
| * Sets tab in enabled. Tab in means that you can set focus | | * Sets tab in enabled. Tab in means that you can set focus | |
|
| * to this Widget by pressing the tab button. If tab in is disabled | | * to this widget by pressing the tab button. If tab in is disabled | |
| * then the FocusHandler will skip this widget and focus the next | | * then the FocusHandler will skip this widget and focus the next | |
| * in its focus order. | | * in its focus order. | |
| * | | * | |
| * @param enabled true if tab in should be enabled. | | * @param enabled true if tab in should be enabled. | |
| */ | | */ | |
| virtual void setTabInEnabled(bool enabled); | | virtual void setTabInEnabled(bool enabled); | |
| | | | |
| /** | | /** | |
| * Checks if tab out is enabled. Tab out means that you can lose | | * Checks if tab out is enabled. Tab out means that you can lose | |
|
| * focus to this Widget by pressing the tab button. If tab out is | | * focus to this widget by pressing the tab button. If tab out is | |
| * disabled then the FocusHandler ignores tabbing and focus will | | * disabled then the FocusHandler ignores tabbing and focus will | |
|
| * stay with this Widget. | | * stay with this widget. | |
| * | | * | |
| * @return true if tab out is enabled. | | * @return true if tab out is enabled. | |
| */ | | */ | |
| virtual bool isTabOutEnabled() const; | | virtual bool isTabOutEnabled() const; | |
| | | | |
| /** | | /** | |
| * Sets tab out enabled. Tab out means that you can lose | | * Sets tab out enabled. Tab out means that you can lose | |
|
| * focus to this Widget by pressing the tab button. If tab out is | | * focus to this widget by pressing the tab button. If tab out is | |
| * disabled then the FocusHandler ignores tabbing and focus will | | * disabled then the FocusHandler ignores tabbing and focus will | |
|
| * stay with this Widget. | | * stay with this widget. | |
| * | | * | |
| * @param enabled true if tab out should be enabled. | | * @param enabled true if tab out should be enabled. | |
| */ | | */ | |
| virtual void setTabOutEnabled(bool enabled); | | virtual void setTabOutEnabled(bool enabled); | |
| | | | |
| /** | | /** | |
| * Requests modal focus. When a widget has modal focus, only that | | * Requests modal focus. When a widget has modal focus, only that | |
| * widget and it's children may recieve input. | | * widget and it's children may recieve input. | |
| * | | * | |
| * @throws Exception if another widget already has modal focus. | | * @throws Exception if another widget already has modal focus. | |
| | | | |
| skipping to change at line 646 | | skipping to change at line 670 | |
| | | | |
| /** | | /** | |
| * Gets the key listeners of the widget. | | * Gets the key listeners of the widget. | |
| * | | * | |
| * @return the key listeners of the widget. | | * @return the key listeners of the widget. | |
| * @since 0.6.0 | | * @since 0.6.0 | |
| */ | | */ | |
| virtual const std::list<KeyListener*>& _getKeyListeners(); | | virtual const std::list<KeyListener*>& _getKeyListeners(); | |
| | | | |
| /** | | /** | |
|
| | | * Gets the focus listeners of the widget. | |
| | | * | |
| | | * @return the focus listeners of the widget. | |
| | | * @since 0.7.0 | |
| | | */ | |
| | | virtual const std::list<FocusListener*>& _getFocusListeners(); | |
| | | | |
| | | /** | |
| * Gets the subarea of the widget that the children occupy. | | * Gets the subarea of the widget that the children occupy. | |
| * | | * | |
| * @return the subarea as a Rectangle. | | * @return the subarea as a Rectangle. | |
| */ | | */ | |
| virtual Rectangle getChildrenArea(); | | virtual Rectangle getChildrenArea(); | |
| | | | |
| /** | | /** | |
| * Gets the internal FocusHandler used. | | * Gets the internal FocusHandler used. | |
| * | | * | |
| * @return the internalFocusHandler used. If no internal FocusHandl
er | | * @return the internalFocusHandler used. If no internal FocusHandl
er | |
| | | | |
| skipping to change at line 669 | | skipping to change at line 701 | |
| | | | |
| /** | | /** | |
| * Sets the internal FocusHandler. An internal focushandler is | | * Sets the internal FocusHandler. An internal focushandler is | |
| * needed if both a widget in the widget and the widget itself | | * needed if both a widget in the widget and the widget itself | |
| * should be foucsed at the same time. | | * should be foucsed at the same time. | |
| * | | * | |
| * @param focusHandler the FocusHandler to be used. | | * @param focusHandler the FocusHandler to be used. | |
| */ | | */ | |
| virtual void setInternalFocusHandler(FocusHandler* focusHandler); | | virtual void setInternalFocusHandler(FocusHandler* focusHandler); | |
| | | | |
|
| /** | | /** | |
| * Moves a Widget to the top of this widget. The moved widget will | | * Moves a widget to the top of this widget. The moved widget will | |
| be | | be | |
| * drawn above all other widgets in this widget. | | * drawn above all other widgets in this widget. | |
| * | | * | |
|
| * @param widget the Widget to move. | | * @param widget the widget to move. | |
| */ | | */ | |
| virtual void moveToTop(Widget* widget) { }; | | virtual void moveToTop(Widget* widget) { }; | |
| | | | |
| /** | | /** | |
| * Moves a widget in this widget to the bottom of this widget. | | * Moves a widget in this widget to the bottom of this widget. | |
| * The moved widget will be drawn below all other widgets in this w
idget. | | * The moved widget will be drawn below all other widgets in this w
idget. | |
| * | | * | |
|
| * @param widget the Widget to move. | | * @param widget the widget to move. | |
| */ | | */ | |
| virtual void moveToBottom(Widget* widget) { }; | | virtual void moveToBottom(Widget* widget) { }; | |
| | | | |
| /** | | /** | |
|
| * Focuses the next Widget in the widget. | | * Focuses the next widget in the widget. | |
| */ | | */ | |
| virtual void focusNext() { }; | | virtual void focusNext() { }; | |
| | | | |
| /** | | /** | |
|
| * Focuses the previous Widget in the widget. | | * Focuses the previous widget in the widget. | |
| */ | | */ | |
| virtual void focusPrevious() { }; | | virtual void focusPrevious() { }; | |
| | | | |
| /** | | /** | |
|
| * Tries to show a specific part of a Widget by moving it. Used if
the | | * Tries to show a specific part of a widget by moving it. Used if
the | |
| * widget should act as a container. | | * widget should act as a container. | |
| * | | * | |
|
| * @param widget the target Widget. | | * @param widget the target widget. | |
| * @param area the area to show. | | * @param area the area to show. | |
| */ | | */ | |
| virtual void showWidgetPart(Widget* widget, Rectangle area) { }; | | virtual void showWidgetPart(Widget* widget, Rectangle area) { }; | |
| | | | |
| protected: | | protected: | |
| /** | | /** | |
|
| * Generates an action to the Widget's ActionListeners. | | * Generates an action to the widget's ActionListeners. | |
| */ | | */ | |
| void generateAction(); | | void generateAction(); | |
| | | | |
| typedef std::list<MouseListener*> MouseListenerList; | | typedef std::list<MouseListener*> MouseListenerList; | |
| typedef MouseListenerList::iterator MouseListenerIterator; | | typedef MouseListenerList::iterator MouseListenerIterator; | |
| MouseListenerList mMouseListeners; | | MouseListenerList mMouseListeners; | |
| | | | |
| typedef std::list<KeyListener*> KeyListenerList; | | typedef std::list<KeyListener*> KeyListenerList; | |
| KeyListenerList mKeyListeners; | | KeyListenerList mKeyListeners; | |
| typedef KeyListenerList::iterator KeyListenerIterator; | | typedef KeyListenerList::iterator KeyListenerIterator; | |
| | | | |
| typedef std::list<ActionListener*> ActionListenerList; | | typedef std::list<ActionListener*> ActionListenerList; | |
| ActionListenerList mActionListeners; | | ActionListenerList mActionListeners; | |
| typedef ActionListenerList::iterator ActionListenerIterator; | | typedef ActionListenerList::iterator ActionListenerIterator; | |
| | | | |
| typedef std::list<DeathListener*> DeathListenerList; | | typedef std::list<DeathListener*> DeathListenerList; | |
| DeathListenerList mDeathListeners; | | DeathListenerList mDeathListeners; | |
| typedef DeathListenerList::iterator DeathListenerIterator; | | typedef DeathListenerList::iterator DeathListenerIterator; | |
| | | | |
|
| | | typedef std::list<FocusListener*> FocusListenerList; | |
| | | FocusListenerList mFocusListeners; | |
| | | typedef FocusListenerList::iterator FocusListenerIterator; | |
| | | | |
| Color mForegroundColor; | | Color mForegroundColor; | |
| Color mBackgroundColor; | | Color mBackgroundColor; | |
| Color mBaseColor; | | Color mBaseColor; | |
|
| | | Color mSelectionColor; | |
| FocusHandler* mFocusHandler; | | FocusHandler* mFocusHandler; | |
| FocusHandler* mInternalFocusHandler; | | FocusHandler* mInternalFocusHandler; | |
| Widget* mParent; | | Widget* mParent; | |
| Rectangle mDimension; | | Rectangle mDimension; | |
| unsigned int mBorderSize; | | unsigned int mBorderSize; | |
| std::string mActionEventId; | | std::string mActionEventId; | |
| bool mFocusable; | | bool mFocusable; | |
| bool mVisible; | | bool mVisible; | |
| bool mTabIn; | | bool mTabIn; | |
| bool mTabOut; | | bool mTabOut; | |
| | | | |
End of changes. 86 change blocks. |
| 112 lines changed or deleted | | 150 lines changed or added | |
|