From 71f88c02f79a1164430eec1de3e15edec011a15e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 25 Sep 2013 18:35:21 +0300 Subject: improve construcors in abstract classes. Also add some missing final to classes. --- src/gui/widgets/characterviewbase.h | 18 ++++++------- src/gui/widgets/layout.h | 32 +++++++++++------------ src/gui/widgets/setupitem.h | 52 ++++++++++++++++++------------------- src/gui/widgets/setuptab.h | 4 +-- src/gui/widgets/shortcutcontainer.h | 10 +++---- src/gui/widgets/tablemodel.h | 9 ++++--- src/gui/widgets/widget2.h | 26 +++++++++---------- src/gui/widgets/widgetgroup.h | 8 +++--- 8 files changed, 80 insertions(+), 79 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/characterviewbase.h b/src/gui/widgets/characterviewbase.h index 2c90bb1e6..8ef949b7c 100644 --- a/src/gui/widgets/characterviewbase.h +++ b/src/gui/widgets/characterviewbase.h @@ -33,15 +33,6 @@ class CharacterViewBase : public Container, public gcn::ActionListener { public: - CharacterViewBase(CharSelectDialog *const widget, const int padding) : - Container(widget), - gcn::ActionListener(), - mParent(widget), - mPadding(padding), - mSelected(0) - { - } - A_DELETE_COPY(CharacterViewBase) virtual ~CharacterViewBase() @@ -57,6 +48,15 @@ class CharacterViewBase : public Container, } protected: + CharacterViewBase(CharSelectDialog *const widget, const int padding) : + Container(widget), + gcn::ActionListener(), + mParent(widget), + mPadding(padding), + mSelected(0) + { + } + CharSelectDialog *mParent; int mPadding; int mSelected; diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 33930c69e..8a33f03f6 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -173,22 +173,6 @@ class LayoutCell FILL }; - LayoutCell(): - mWidget(nullptr), - mHPadding(0), - mVPadding(0), - mType(NONE) - { - mExtent[0] = 0; - mExtent[1] = 0; - mAlign[0] = 0; - mAlign[1] = 0; - mNbFill[0] = 0; - mNbFill[1] = 0; - mSize[0] = 0; - mSize[1] = 0; - } - virtual ~LayoutCell(); /** @@ -286,6 +270,22 @@ class LayoutCell }; private: + LayoutCell(): + mWidget(nullptr), + mHPadding(0), + mVPadding(0), + mType(NONE) + { + mExtent[0] = 0; + mExtent[1] = 0; + mAlign[0] = 0; + mAlign[1] = 0; + mNbFill[0] = 0; + mNbFill[1] = 0; + mSize[0] = 0; + mSize[1] = 0; + } + // Copy not allowed, as the cell may own an array. explicit LayoutCell(LayoutCell const &); LayoutCell &operator=(LayoutCell const &); diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 476a31ae4..9c5cc11e3 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -57,15 +57,6 @@ class SetupItem : public gcn::ActionListener, VNONE }; - SetupItem(const std::string &text, const std::string &description, - const std::string &keyName, SetupTabScroll *const parent, - const std::string &eventName, const bool mainConfig); - - SetupItem(const std::string &text, const std::string &description, - const std::string &keyName, SetupTabScroll *const parent, - const std::string &eventName, const std::string &def, - const bool mainConfig); - A_DELETE_COPY(SetupItem) ~SetupItem(); @@ -106,6 +97,15 @@ class SetupItem : public gcn::ActionListener, void rereadValue(); protected: + SetupItem(const std::string &text, const std::string &description, + const std::string &keyName, SetupTabScroll *const parent, + const std::string &eventName, const bool mainConfig); + + SetupItem(const std::string &text, const std::string &description, + const std::string &keyName, SetupTabScroll *const parent, + const std::string &eventName, const std::string &def, + const bool mainConfig); + std::string mText; std::string mDescription; @@ -427,6 +427,23 @@ class SetupItemSlider2 final : public SetupItem class SetupItemSliderList : public SetupItem { public: + A_DELETE_COPY(SetupItemSliderList) + + ~SetupItemSliderList(); + + void createControls(); + + void fromWidget() override; + + void toWidget() override; + + virtual void action(const gcn::ActionEvent &event) override; + + void apply(const std::string &eventName) override; + + virtual void addMoreControls() = 0; + + protected: SetupItemSliderList(const std::string &text, const std::string &description, const std::string &keyName, @@ -446,23 +463,6 @@ class SetupItemSliderList : public SetupItem const bool onTheFly = false, const bool mainConfig = true); - A_DELETE_COPY(SetupItemSliderList) - - ~SetupItemSliderList(); - - void createControls(); - - void fromWidget() override; - - void toWidget() override; - - virtual void action(const gcn::ActionEvent &event) override; - - void apply(const std::string &eventName) override; - - virtual void addMoreControls() = 0; - - protected: HorizontContainer *mHorizont; Label *mLabel; SliderList *mSlider; diff --git a/src/gui/widgets/setuptab.h b/src/gui/widgets/setuptab.h index 8e656234f..ab866ba28 100644 --- a/src/gui/widgets/setuptab.h +++ b/src/gui/widgets/setuptab.h @@ -40,8 +40,6 @@ class SetupTab : public Container, public gcn::WidgetListener { public: - explicit SetupTab(const Widget2 *const widget); - A_DELETE_COPY(SetupTab) const std::string &getName() const A_WARN_UNUSED @@ -60,6 +58,8 @@ class SetupTab : public Container, virtual void externalUpdated(); protected: + explicit SetupTab(const Widget2 *const widget); + /** * Sets the name displayed on the tab. Should be set in the * constructor of a subclass. diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 2f6a48bc4..60c1bb539 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -43,11 +43,6 @@ class ShortcutContainer : public gcn::Widget, public gcn::MouseListener { public: - /** - * Constructor. Initializes the shortcut container. - */ - ShortcutContainer(); - A_DELETE_COPY(ShortcutContainer) /** @@ -98,6 +93,11 @@ class ShortcutContainer : public gcn::Widget, { mRedraw = b; } protected: + /** + * Constructor. Initializes the shortcut container. + */ + ShortcutContainer(); + /** * Gets the index from the grid provided the point is in an item box. * diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h index 427b8bf3a..7d7daacb9 100644 --- a/src/gui/widgets/tablemodel.h +++ b/src/gui/widgets/tablemodel.h @@ -57,10 +57,6 @@ public: class TableModel { public: - TableModel() : - listeners() - { - } virtual ~TableModel() { } @@ -95,6 +91,11 @@ public: virtual void removeListener(TableModelListener *const listener); protected: + TableModel() : + listeners() + { + } + /** * Tells all listeners that the table is about to see an update */ diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index 9e164046b..0ab171b3e 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -29,19 +29,6 @@ class Widget2 { public: - Widget2() : - mPaletteOffset(0), - mForegroundColor2() - { - } - - explicit Widget2(const Widget2 *const widget) : - mPaletteOffset(widget ? widget->mPaletteOffset : 0), - mForegroundColor2() - { - checkPalette(); - } - virtual ~Widget2() { } @@ -91,6 +78,19 @@ class Widget2 } protected: + Widget2() : + mPaletteOffset(0), + mForegroundColor2() + { + } + + explicit Widget2(const Widget2 *const widget) : + mPaletteOffset(widget ? widget->mPaletteOffset : 0), + mForegroundColor2() + { + checkPalette(); + } + int mPaletteOffset; gcn::Color mForegroundColor2; }; diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 55507f316..308c8fb8a 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -33,10 +33,6 @@ class WidgetGroup : public Container, public gcn::ActionListener { public: - WidgetGroup(const Widget2 *const widget, - const std::string &group, const int height, - const int spacing); - A_DELETE_COPY(WidgetGroup) virtual void addButton(const std::string &tag); @@ -57,6 +53,10 @@ class WidgetGroup : public Container, const A_WARN_UNUSED = 0; protected: + WidgetGroup(const Widget2 *const widget, + const std::string &group, const int height, + const int spacing); + int mSpacing; int mCount; std::string mGroup; -- cgit v1.2.3-70-g09d2