summaryrefslogtreecommitdiff
path: root/src/guichan/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-05 21:48:30 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-05 21:48:30 +0300
commit6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed (patch)
tree79a54d4c838c85df29b1b95702b71a95c43ceb5a /src/guichan/widgets
parentd1bb1b375d657f0821ccfebf18fa1c3873314690 (diff)
downloadManaVerse-6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed.tar.gz
ManaVerse-6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed.tar.bz2
ManaVerse-6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed.tar.xz
ManaVerse-6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed.zip
Improve constructors in some classes.
Diffstat (limited to 'src/guichan/widgets')
-rw-r--r--src/guichan/widgets/button.cpp34
-rw-r--r--src/guichan/widgets/checkbox.cpp15
-rw-r--r--src/guichan/widgets/container.cpp1
-rw-r--r--src/guichan/widgets/dropdown.cpp33
-rw-r--r--src/guichan/widgets/icon.cpp3
-rw-r--r--src/guichan/widgets/label.cpp5
-rw-r--r--src/guichan/widgets/listbox.cpp10
-rw-r--r--src/guichan/widgets/radiobutton.cpp6
-rw-r--r--src/guichan/widgets/scrollarea.cpp6
-rw-r--r--src/guichan/widgets/slider.cpp6
-rw-r--r--src/guichan/widgets/tab.cpp2
-rw-r--r--src/guichan/widgets/tabbedarea.cpp8
-rw-r--r--src/guichan/widgets/textbox.cpp6
-rw-r--r--src/guichan/widgets/textfield.cpp6
-rw-r--r--src/guichan/widgets/window.cpp30
15 files changed, 117 insertions, 54 deletions
diff --git a/src/guichan/widgets/button.cpp b/src/guichan/widgets/button.cpp
index f30c890b4..69affd4b7 100644
--- a/src/guichan/widgets/button.cpp
+++ b/src/guichan/widgets/button.cpp
@@ -59,12 +59,16 @@
namespace gcn
{
- Button::Button()
- : mHasMouse(false),
- mKeyPressed(false),
- mMousePressed(false),
- mAlignment(Graphics::CENTER),
- mSpacing(4)
+ Button::Button() :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
+ FocusListener(),
+ mHasMouse(false),
+ mKeyPressed(false),
+ mMousePressed(false),
+ mAlignment(Graphics::CENTER),
+ mSpacing(4)
{
setFocusable(true);
adjustSize();
@@ -75,13 +79,17 @@ namespace gcn
addFocusListener(this);
}
- Button::Button(const std::string& caption)
- : mCaption(caption),
- mHasMouse(false),
- mKeyPressed(false),
- mMousePressed(false),
- mAlignment(Graphics::CENTER),
- mSpacing(4)
+ Button::Button(const std::string& caption) :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
+ FocusListener(),
+ mCaption(caption),
+ mHasMouse(false),
+ mKeyPressed(false),
+ mMousePressed(false),
+ mAlignment(Graphics::CENTER),
+ mSpacing(4)
{
setFocusable(true);
adjustSize();
diff --git a/src/guichan/widgets/checkbox.cpp b/src/guichan/widgets/checkbox.cpp
index fe0bfbee4..58710409b 100644
--- a/src/guichan/widgets/checkbox.cpp
+++ b/src/guichan/widgets/checkbox.cpp
@@ -58,19 +58,24 @@
namespace gcn
{
- CheckBox::CheckBox()
+ CheckBox::CheckBox() :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
+ mSelected(false)
{
- setSelected(false);
-
setFocusable(true);
addMouseListener(this);
addKeyListener(this);
}
- CheckBox::CheckBox(const std::string &caption, bool selected)
+ CheckBox::CheckBox(const std::string &caption, bool selected) :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
+ mSelected(selected)
{
setCaption(caption);
- setSelected(selected);
setFocusable(true);
addMouseListener(this);
diff --git a/src/guichan/widgets/container.cpp b/src/guichan/widgets/container.cpp
index d6951f06a..ec61338c8 100644
--- a/src/guichan/widgets/container.cpp
+++ b/src/guichan/widgets/container.cpp
@@ -57,6 +57,7 @@ namespace gcn
{
Container::Container() :
+ BasicContainer(),
mOpaque(true)
{
}
diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp
index c446b869d..39248ab73 100644
--- a/src/guichan/widgets/dropdown.cpp
+++ b/src/guichan/widgets/dropdown.cpp
@@ -59,29 +59,26 @@ namespace gcn
{
DropDown::DropDown(ListModel *const listModel,
ScrollArea *const scrollArea,
- ListBox *const listBox)
+ ListBox *const listBox) :
+ ActionListener(),
+ BasicContainer(),
+ KeyListener(),
+ MouseListener(),
+ FocusListener(),
+ SelectionListener(),
+ mDroppedDown(false),
+ mPushed(false),
+ mFoldedUpHeight(0),
+ mInternalScrollArea(!scrollArea),
+ mScrollArea(mInternalScrollArea ? new ScrollArea : scrollArea),
+ mInternalListBox(!listBox),
+ mListBox(mInternalListBox ? new ListBox() : listBox),
+ mIsDragged(false)
{
setWidth(100);
setFocusable(true);
- mDroppedDown = false;
- mPushed = false;
- mIsDragged = false;
setInternalFocusHandler(&mInternalFocusHandler);
-
- mInternalScrollArea = (!scrollArea);
- mInternalListBox = (!listBox);
-
- if (mInternalScrollArea)
- mScrollArea = new ScrollArea();
- else
- mScrollArea = scrollArea;
-
- if (mInternalListBox)
- mListBox = new ListBox();
- else
- mListBox = listBox;
-
mScrollArea->setContent(mListBox);
add(mScrollArea);
diff --git a/src/guichan/widgets/icon.cpp b/src/guichan/widgets/icon.cpp
index b0d277fbd..a030e2413 100644
--- a/src/guichan/widgets/icon.cpp
+++ b/src/guichan/widgets/icon.cpp
@@ -57,6 +57,7 @@
namespace gcn
{
Icon::Icon() :
+ Widget(),
mImage(nullptr),
mInternalImage(false)
{
@@ -64,6 +65,7 @@ namespace gcn
}
Icon::Icon(const std::string& filename) :
+ Widget(),
mImage(Image::load(filename)),
mInternalImage(true)
{
@@ -72,6 +74,7 @@ namespace gcn
}
Icon::Icon(const Image *const image) :
+ Widget(),
mImage(image),
mInternalImage(false)
{
diff --git a/src/guichan/widgets/label.cpp b/src/guichan/widgets/label.cpp
index 815bba741..aebbd0472 100644
--- a/src/guichan/widgets/label.cpp
+++ b/src/guichan/widgets/label.cpp
@@ -56,11 +56,14 @@
namespace gcn
{
- Label::Label() : mAlignment(Graphics::LEFT)
+ Label::Label() :
+ Widget(),
+ mAlignment(Graphics::LEFT)
{
}
Label::Label(const std::string& caption) :
+ Widget(),
mCaption(caption),
mAlignment(Graphics::LEFT)
{
diff --git a/src/guichan/widgets/listbox.cpp b/src/guichan/widgets/listbox.cpp
index 3f6565785..66ddf8315 100644
--- a/src/guichan/widgets/listbox.cpp
+++ b/src/guichan/widgets/listbox.cpp
@@ -61,6 +61,9 @@
namespace gcn
{
ListBox::ListBox() :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mSelected(-1),
mListModel(nullptr),
mWrappingEnabled(false)
@@ -73,13 +76,16 @@ namespace gcn
}
ListBox::ListBox(ListModel *listModel) :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mSelected(-1),
+ mListModel(listModel),
mWrappingEnabled(false)
{
setWidth(100);
- setListModel(listModel);
+ adjustSize();
setFocusable(true);
-
addMouseListener(this);
addKeyListener(this);
}
diff --git a/src/guichan/widgets/radiobutton.cpp b/src/guichan/widgets/radiobutton.cpp
index 7f8d846d9..9f19b00a7 100644
--- a/src/guichan/widgets/radiobutton.cpp
+++ b/src/guichan/widgets/radiobutton.cpp
@@ -60,6 +60,9 @@ namespace gcn
RadioButton::GroupMap RadioButton::mGroupMap;
RadioButton::RadioButton() :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mSelected(false),
mCaption(""),
mGroup("")
@@ -74,6 +77,9 @@ namespace gcn
RadioButton::RadioButton(const std::string &caption,
const std::string &group,
bool selected) :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mSelected(false),
mGroup("")
{
diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp
index f8bd11334..6fa2db863 100644
--- a/src/guichan/widgets/scrollarea.cpp
+++ b/src/guichan/widgets/scrollarea.cpp
@@ -56,6 +56,8 @@
namespace gcn
{
ScrollArea::ScrollArea() :
+ BasicContainer(),
+ MouseListener(),
mVScroll(0),
mHScroll(0),
mScrollbarWidth(12),
@@ -81,6 +83,8 @@ namespace gcn
}
ScrollArea::ScrollArea(Widget *const content) :
+ BasicContainer(),
+ MouseListener(),
mVScroll(0),
mHScroll(0),
mScrollbarWidth(12),
@@ -109,6 +113,8 @@ namespace gcn
ScrollArea::ScrollArea(Widget *content,
ScrollPolicy hPolicy,
ScrollPolicy vPolicy) :
+ BasicContainer(),
+ MouseListener(),
mVScroll(0),
mHScroll(0),
mScrollbarWidth(12),
diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp
index a9e9bed31..790560c7c 100644
--- a/src/guichan/widgets/slider.cpp
+++ b/src/guichan/widgets/slider.cpp
@@ -57,6 +57,9 @@
namespace gcn
{
Slider::Slider(const double scaleEnd) :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mDragged(false),
mScaleStart(0),
mScaleEnd(scaleEnd)
@@ -73,6 +76,9 @@ namespace gcn
}
Slider::Slider(const double scaleStart, const double scaleEnd) :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mDragged(false),
mScaleStart(scaleStart),
mScaleEnd(scaleEnd)
diff --git a/src/guichan/widgets/tab.cpp b/src/guichan/widgets/tab.cpp
index fa70f1e08..04d3dbb83 100644
--- a/src/guichan/widgets/tab.cpp
+++ b/src/guichan/widgets/tab.cpp
@@ -59,6 +59,8 @@
namespace gcn
{
Tab::Tab() :
+ BasicContainer(),
+ MouseListener(),
mLabel(new Label()),
mHasMouse(false),
mTabbedArea(nullptr)
diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp
index 7bd77e7cd..35d401426 100644
--- a/src/guichan/widgets/tabbedarea.cpp
+++ b/src/guichan/widgets/tabbedarea.cpp
@@ -63,16 +63,20 @@
namespace gcn
{
TabbedArea::TabbedArea() :
+ ActionListener(),
+ BasicContainer(),
+ KeyListener(),
+ MouseListener(),
mSelectedTab(nullptr),
+ mTabContainer(new Container()),
+ mWidgetContainer(new Container()),
mOpaque(false)
{
setFocusable(true);
addKeyListener(this);
addMouseListener(this);
- mTabContainer = new Container();
mTabContainer->setOpaque(false);
- mWidgetContainer = new Container();
add(mTabContainer);
add(mWidgetContainer);
diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp
index 0640b6a2c..ad5338069 100644
--- a/src/guichan/widgets/textbox.cpp
+++ b/src/guichan/widgets/textbox.cpp
@@ -59,6 +59,9 @@
namespace gcn
{
TextBox::TextBox() :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mCaretColumn(0),
mCaretRow(0),
mEditable(true),
@@ -73,6 +76,9 @@ namespace gcn
}
TextBox::TextBox(const std::string& text) :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mCaretColumn(0),
mCaretRow(0),
mEditable(true),
diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp
index 2fffdc5f5..5434d341c 100644
--- a/src/guichan/widgets/textfield.cpp
+++ b/src/guichan/widgets/textfield.cpp
@@ -58,6 +58,9 @@
namespace gcn
{
TextField::TextField() :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mCaretPosition(0),
mXScroll(0)
{
@@ -68,6 +71,9 @@ namespace gcn
}
TextField::TextField(const std::string& text) :
+ Widget(),
+ MouseListener(),
+ KeyListener(),
mText(text),
mCaretPosition(0),
mXScroll(0)
diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp
index 1a2279811..e82758e5f 100644
--- a/src/guichan/widgets/window.cpp
+++ b/src/guichan/widgets/window.cpp
@@ -58,28 +58,32 @@
namespace gcn
{
Window::Window() :
+ Container(),
+ MouseListener(),
+ mAlignment(Graphics::CENTER),
+ mPadding(2),
+ mTitleBarHeight(16),
+ mMovable(true),
+ mOpaque(true),
mMoved(false)
{
- setFrameSize(1);
- setPadding(2);
- setTitleBarHeight(16);
- setAlignment(Graphics::CENTER);
+ mFrameSize = 1;
addMouseListener(this);
- setMovable(true);
- setOpaque(true);
}
Window::Window(const std::string& caption) :
+ Container(),
+ MouseListener(),
+ mCaption(caption),
+ mAlignment(Graphics::CENTER),
+ mPadding(2),
+ mTitleBarHeight(16),
+ mMovable(true),
+ mOpaque(true),
mMoved(false)
{
- setCaption(caption);
- setFrameSize(1);
- setPadding(2);
- setTitleBarHeight(16);
- setAlignment(Graphics::CENTER);
+ mFrameSize = 1;
addMouseListener(this);
- setMovable(true);
- setOpaque(true);
}
Window::~Window()