summaryrefslogtreecommitdiff
path: root/src/gui/widgets/widget.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-17 01:41:22 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-17 01:41:22 +0300
commit794ebb9ccd1b6605a03fee438abc1e4f2f7966c9 (patch)
tree9d89e6c1665cf6645d0e3673977ec150d357bd9d /src/gui/widgets/widget.h
parent3c02e309bbe285f9fb625f20f55533ff0b22b3cc (diff)
downloadmv-794ebb9ccd1b6605a03fee438abc1e4f2f7966c9.tar.gz
mv-794ebb9ccd1b6605a03fee438abc1e4f2f7966c9.tar.bz2
mv-794ebb9ccd1b6605a03fee438abc1e4f2f7966c9.tar.xz
mv-794ebb9ccd1b6605a03fee438abc1e4f2f7966c9.zip
improve widget.
Diffstat (limited to 'src/gui/widgets/widget.h')
-rw-r--r--src/gui/widgets/widget.h160
1 files changed, 79 insertions, 81 deletions
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
index 86bf0f773..beff5113b 100644
--- a/src/gui/widgets/widget.h
+++ b/src/gui/widgets/widget.h
@@ -148,7 +148,8 @@ class Widget : public Widget2
* @see setFrameSize, getFrameSize
* @since 0.8.0
*/
- virtual void drawFrame(Graphics* graphics);
+ virtual void drawFrame(Graphics* graphics)
+ { }
/**
* Sets the size of the widget's frame. The frame is not considered a part of
@@ -164,7 +165,8 @@ class Widget : public Widget2
* @see getFrameSize, drawFrame
* @since 0.8.0
*/
- void setFrameSize(unsigned int frameSize);
+ void setFrameSize(const unsigned int frameSize)
+ { mFrameSize = frameSize; }
/**
* Gets the size of the widget's frame. The frame is not considered a part of
@@ -180,7 +182,8 @@ class Widget : public Widget2
* @see setFrameSize, drawFrame
* @since 0.8.0
*/
- unsigned int getFrameSize() const A_WARN_UNUSED;
+ unsigned int getFrameSize() const A_WARN_UNUSED
+ { return mFrameSize; }
/**
* Called for all widgets in the gui each time Gui::logic is called.
@@ -210,7 +213,7 @@ class Widget : public Widget2
* setDimension, getDimensi
* @since 0.1.0
*/
- void setWidth(int width);
+ void setWidth(const int width);
/**
* Gets the width of the widget.
@@ -231,7 +234,7 @@ class Widget : public Widget2
* setDimension, getDimension
* @since 0.1.0
*/
- void setHeight(int height);
+ void setHeight(const int height);
/**
* Gets the height of the widget.
@@ -253,7 +256,7 @@ class Widget : public Widget2
* setDimension, getDimension
* @since 0.1.0
*/
- void setSize(int width, int height);
+ void setSize(const int width, const int height);
/**
* Sets the x coordinate of the widget. The coordinate is
@@ -263,7 +266,7 @@ class Widget : public Widget2
* @see getX, setY, getY, setPosition, setDimension, getDimension
* @since 0.1.0
*/
- void setX(int x);
+ void setX(const int x);
/**
* Gets the x coordinate of the widget. The coordinate is
@@ -284,7 +287,7 @@ class Widget : public Widget2
* @see setY, setX, getX, setPosition, setDimension, getDimension
* @since 0.1.0
*/
- void setY(int y);
+ void setY(const int y);
/**
* Gets the y coordinate of the widget. The coordinate is
@@ -306,7 +309,7 @@ class Widget : public Widget2
* @see setX, getX, setY, getY, setDimension, getDimension
* @since 0.1.0
*/
- void setPosition(int x, int y);
+ void setPosition(const int x, const int y);
/**
* Sets the dimension of the widget. The dimension is
@@ -326,7 +329,8 @@ class Widget : public Widget2
* @see getDimension, setX, getX, setY, getY, setPosition
* @since 0.1.0
*/
- const Rect& getDimension() const A_WARN_UNUSED;
+ const Rect& getDimension() const A_WARN_UNUSED
+ { return mDimension; }
/**
* Sets the widget to be fosusable, or not.
@@ -336,7 +340,7 @@ class Widget : public Widget2
* @see isFocusable
* @since 0.1.0
*/
- void setFocusable(bool focusable);
+ void setFocusable(const bool focusable);
/**
* Checks if a widget is focsable.
@@ -364,7 +368,8 @@ class Widget : public Widget2
* @see isEnabled
* @since 0.1.0
*/
- void setEnabled(bool enabled);
+ void setEnabled(const bool enabled)
+ { mEnabled = enabled; }
/**
* Checks if the widget is enabled. A disabled
@@ -402,7 +407,8 @@ class Widget : public Widget2
* @see getBaseColor
* @since 0.1.0
*/
- void setBaseColor(const Color& color);
+ void setBaseColor(const Color& color)
+ { mBaseColor = color; }
/**
* Gets the base color.
@@ -411,7 +417,8 @@ class Widget : public Widget2
* @see setBaseColor
* @since 0.1.0
*/
- const Color& getBaseColor() const A_WARN_UNUSED;
+ const Color& getBaseColor() const A_WARN_UNUSED
+ { return mBaseColor; }
/**
* Sets the foreground color.
@@ -420,7 +427,8 @@ class Widget : public Widget2
* @see getForegroundColor
* @since 0.1.0
*/
- void setForegroundColor(const Color& color);
+ void setForegroundColor(const Color& color)
+ { mForegroundColor = color; }
/**
* Gets the foreground color.
@@ -428,7 +436,8 @@ class Widget : public Widget2
* @see setForegroundColor
* @since 0.1.0
*/
- const Color& getForegroundColor() const A_WARN_UNUSED;
+ const Color& getForegroundColor() const A_WARN_UNUSED
+ { return mForegroundColor; }
/**
* Sets the background color.
@@ -437,7 +446,8 @@ class Widget : public Widget2
* @see setBackgroundColor
* @since 0.1.0
*/
- void setBackgroundColor(const Color& color);
+ void setBackgroundColor(const Color& color)
+ { mBackgroundColor = color; }
/**
* Gets the background color.
@@ -445,25 +455,8 @@ class Widget : public Widget2
* @see setBackgroundColor
* @since 0.1.0
*/
- const Color& getBackgroundColor() const A_WARN_UNUSED;
-
- /**
- * Sets the selection color.
- *
- * @param color The selection color.
- * @see getSelectionColor
- * @since 0.6.0
- */
- void setSelectionColor(const Color& color);
-
- /**
- * Gets the selection color.
- *
- * @return The selection color.
- * @see setSelectionColor
- * @since 0.6.0
- */
- const Color& getSelectionColor() const A_WARN_UNUSED;
+ const Color& getBackgroundColor() const A_WARN_UNUSED
+ { return mBackgroundColor; }
/**
* Requests focus for the widget. A widget will only recieve focus
@@ -492,7 +485,7 @@ class Widget : public Widget2
* @see _getFocusHandler
* @since 0.1.0
*/
- virtual void _setFocusHandler(FocusHandler* focusHandler);
+ virtual void _setFocusHandler(FocusHandler *const focusHandler);
/**
* Gets the focus handler used.
@@ -505,7 +498,8 @@ class Widget : public Widget2
* @see _setFocusHandler
* @since 0.1.0
*/
- virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED;
+ virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED
+ { return mFocusHandler; }
/**
* Adds an action listener to the widget. When an action event
@@ -516,7 +510,7 @@ class Widget : public Widget2
* @see removeActionListener
* @since 0.1.0
*/
- void addActionListener(ActionListener* actionListener);
+ void addActionListener(ActionListener *const actionListener);
/**
* Removes an added action listener from the widget.
@@ -525,7 +519,7 @@ class Widget : public Widget2
* @see addActionListener
* @since 0.1.0
*/
- void removeActionListener(ActionListener* actionListener);
+ void removeActionListener(ActionListener *const actionListener);
/**
* Adds a death listener to the widget. When a death event is
@@ -536,7 +530,7 @@ class Widget : public Widget2
* @see removeDeathListener
* @since 0.1.0
*/
- void addDeathListener(DeathListener* deathListener);
+ void addDeathListener(DeathListener *const deathListener);
/**
* Removes an added death listener from the widget.
@@ -545,7 +539,7 @@ class Widget : public Widget2
* @see addDeathListener
* @since 0.1.0
*/
- void removeDeathListener(DeathListener* deathListener);
+ void removeDeathListener(DeathListener *const deathListener);
/**
* Adds a mouse listener to the widget. When a mouse event is
@@ -556,7 +550,7 @@ class Widget : public Widget2
* @see removeMouseListener
* @since 0.1.0
*/
- void addMouseListener(MouseListener* mouseListener);
+ void addMouseListener(MouseListener *const mouseListener);
/**
* Removes an added mouse listener from the widget.
@@ -565,7 +559,7 @@ class Widget : public Widget2
* @see addMouseListener
* @since 0.1.0
*/
- void removeMouseListener(MouseListener* mouseListener);
+ void removeMouseListener(MouseListener *const mouseListener);
/**
* Adds a key listener to the widget. When a key event is
@@ -576,7 +570,7 @@ class Widget : public Widget2
* @see removeKeyListener
* @since 0.1.0
*/
- void addKeyListener(KeyListener* keyListener);
+ void addKeyListener(KeyListener *const keyListener);
/**
* Removes an added key listener from the widget.
@@ -585,7 +579,7 @@ class Widget : public Widget2
* @see addKeyListener
* @since 0.1.0
*/
- void removeKeyListener(KeyListener* keyListener);
+ void removeKeyListener(KeyListener *const keyListener);
/**
* Adds a focus listener to the widget. When a focus event is
@@ -596,7 +590,7 @@ class Widget : public Widget2
* @see removeFocusListener
* @since 0.7.0
*/
- void addFocusListener(FocusListener* focusListener);
+ void addFocusListener(FocusListener *const focusListener);
/**
* Removes an added focus listener from the widget.
@@ -605,7 +599,7 @@ class Widget : public Widget2
* @see addFocusListener
* @since 0.7.0
*/
- void removeFocusListener(FocusListener* focusListener);
+ void removeFocusListener(FocusListener *const focusListener);
/**
* Adds a widget listener to the widget. When a widget event is
@@ -616,7 +610,7 @@ class Widget : public Widget2
* @see removeWidgetListener
* @since 0.8.0
*/
- void addWidgetListener(WidgetListener* widgetListener);
+ void addWidgetListener(WidgetListener *const widgetListener);
/**
* Removes an added widget listener from the widget.
@@ -625,7 +619,7 @@ class Widget : public Widget2
* @see addWidgetListener
* @since 0.8.0
*/
- void removeWidgetListener(WidgetListener* widgetListener);
+ void removeWidgetListener(WidgetListener *const widgetListener);
/**
* Sets the action event identifier of the widget. The identifier is
@@ -639,7 +633,8 @@ class Widget : public Widget2
* @see getActionEventId
* @since 0.6.0
*/
- void setActionEventId(const std::string& actionEventId);
+ void setActionEventId(const std::string& actionEventId)
+ { mActionEventId = actionEventId; }
/**
* Gets the action event identifier of the widget.
@@ -648,7 +643,8 @@ class Widget : public Widget2
* @see setActionEventId
* @since 0.6.0
*/
- const std::string& getActionEventId() const;
+ const std::string& getActionEventId() const
+ { return mActionEventId; }
/**
* Gets the absolute position on the screen for the widget.
@@ -670,7 +666,8 @@ class Widget : public Widget2
* @see getParent
* @since 0.1.0
*/
- virtual void _setParent(Widget* parent);
+ virtual void _setParent(Widget* parent)
+ { mParent = parent; }
/**
* Gets the font set for the widget. If no font has been set,
@@ -690,7 +687,7 @@ class Widget : public Widget2
* @see getGlobalFont
* @since 0.1.0
*/
- static void setGlobalFont(Font* font);
+ static void setGlobalFont(Font *const font);
/**
* Sets the font for the widget. If NULL is passed, the global font
@@ -700,7 +697,7 @@ class Widget : public Widget2
* @see getFont
* @since 0.1.0
*/
- void setFont(Font* font);
+ void setFont(Font *const font);
/**
* Called when the font has changed. If the change is global,
@@ -732,7 +729,8 @@ class Widget : public Widget2
* @see setTabInEnabled
* @since 0.1.0
*/
- bool isTabInEnabled() const A_WARN_UNUSED;
+ bool isTabInEnabled() const A_WARN_UNUSED
+ { return mTabIn; }
/**
* Sets tab in enabled, or not. Tab in means that you can set focus
@@ -744,7 +742,8 @@ class Widget : public Widget2
* @see isTabInEnabled
* @since 0.1.0
*/
- void setTabInEnabled(bool enabled);
+ void setTabInEnabled(const bool enabled)
+ { mTabIn = enabled; }
/**
* Checks if tab out is enabled. Tab out means that you can lose
@@ -756,7 +755,8 @@ class Widget : public Widget2
* @see setTabOutEnabled
* @since 0.1.0
*/
- bool isTabOutEnabled() const A_WARN_UNUSED;
+ bool isTabOutEnabled() const A_WARN_UNUSED
+ { return mTabOut; }
/**
* Sets tab out enabled. Tab out means that you can lose
@@ -768,7 +768,8 @@ class Widget : public Widget2
* @see isTabOutEnabled
* @since 0.1.0
*/
- void setTabOutEnabled(bool enabled);
+ void setTabOutEnabled(const bool enabled)
+ { mTabOut = enabled; }
/**
* Requests modal focus. When a widget has modal focus, only that
@@ -842,7 +843,9 @@ class Widget : public Widget2
* if no widget is found.
* @since 0.6.0
*/
- virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED;
+ virtual Widget *getWidgetAt(int x A_UNUSED,
+ int y A_UNUSED) A_WARN_UNUSED
+ { return nullptr; }
/**
* Gets the mouse listeners of the widget.
@@ -912,7 +915,7 @@ class Widget : public Widget2
* @see getInternalFocusHandler
* @since 0.1.0
*/
- void setInternalFocusHandler(FocusHandler* internalFocusHandler);
+ void setInternalFocusHandler(FocusHandler *const internalFocusHandler);
/**
* Moves a widget to the top of this widget. The moved widget will be
@@ -1002,7 +1005,7 @@ class Widget : public Widget2
* @param rectangle The rectangle to be shown.
* @since 0.8.0
*/
- virtual void showPart(Rect rectangle);
+ virtual void showPart(const Rect &rectangle);
protected:
/**
@@ -1146,9 +1149,19 @@ class Widget : public Widget2
Color mBaseColor;
/**
- * Holds the selection color of the widget.
+ * Holds the dimension of the widget.
+ */
+ Rect mDimension;
+
+ /**
+ * Holds the action event of the widget.
+ */
+ std::string mActionEventId;
+
+ /**
+ * Holds the id of the widget.
*/
- Color mSelectionColor;
+ std::string mId;
/**
* Holds the focus handler used by the widget.
@@ -1168,9 +1181,9 @@ class Widget : public Widget2
Widget* mParent;
/**
- * Holds the dimension of the widget.
+ * Holds the font used by the widget.
*/
- Rect mDimension;
+ Font* mCurrentFont;
/**
* Holds the frame size of the widget.
@@ -1178,11 +1191,6 @@ class Widget : public Widget2
unsigned int mFrameSize;
/**
- * Holds the action event of the widget.
- */
- std::string mActionEventId;
-
- /**
* True if the widget focusable, false otherwise.
*/
bool mFocusable;
@@ -1208,16 +1216,6 @@ class Widget : public Widget2
bool mEnabled;
/**
- * Holds the id of the widget.
- */
- std::string mId;
-
- /**
- * Holds the font used by the widget.
- */
- Font* mCurrentFont;
-
- /**
* Holds the global font used by the widget.
*/
static Font* mGlobalFont;