summaryrefslogtreecommitdiff
path: root/src/guichan
diff options
context:
space:
mode:
Diffstat (limited to 'src/guichan')
-rw-r--r--src/guichan/cliprectangle.cpp12
-rw-r--r--src/guichan/gui.cpp2
-rw-r--r--src/guichan/include/guichan/widgets/radiobutton.hpp2
-rw-r--r--src/guichan/sdl/sdlimage.cpp6
-rw-r--r--src/guichan/widgets/container.cpp4
-rw-r--r--src/guichan/widgets/icon.cpp6
-rw-r--r--src/guichan/widgets/label.cpp10
-rw-r--r--src/guichan/widgets/radiobutton.cpp2
-rw-r--r--src/guichan/widgets/scrollarea.cpp129
-rw-r--r--src/guichan/widgets/slider.cpp20
-rw-r--r--src/guichan/widgets/tab.cpp2
-rw-r--r--src/guichan/widgets/textbox.cpp24
-rw-r--r--src/guichan/widgets/textfield.cpp16
13 files changed, 109 insertions, 126 deletions
diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp
index 42b33f203..e05736870 100644
--- a/src/guichan/cliprectangle.cpp
+++ b/src/guichan/cliprectangle.cpp
@@ -52,25 +52,25 @@
namespace gcn
{
- ClipRectangle::ClipRectangle()
+ ClipRectangle::ClipRectangle() :
+ xOffset(0),
+ yOffset(0)
{
x = 0;
y = 0;
width = 0;
height = 0;
- xOffset = 0;
- yOffset = 0;
}
ClipRectangle::ClipRectangle(int x0, int y0, int width0, int height0,
- int xOffset0, int yOffset0)
+ int xOffset0, int yOffset0) :
+ xOffset(xOffset0),
+ yOffset(yOffset0)
{
x = x0;
y = y0;
width = width0;
height = height0;
- xOffset = xOffset0;
- yOffset = yOffset0;
}
const ClipRectangle& ClipRectangle::operator=(const Rectangle& other)
diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp
index 9e0229f05..0a24d8b17 100644
--- a/src/guichan/gui.cpp
+++ b/src/guichan/gui.cpp
@@ -67,6 +67,7 @@ namespace gcn
mTop(nullptr),
mGraphics(nullptr),
mInput(nullptr),
+ mFocusHandler(new FocusHandler()),
mTabbing(true),
mShiftPressed(false),
mMetaPressed(false),
@@ -79,7 +80,6 @@ namespace gcn
mClickCount(1),
mLastMouseDragButton(0)
{
- mFocusHandler = new FocusHandler();
}
Gui::~Gui()
diff --git a/src/guichan/include/guichan/widgets/radiobutton.hpp b/src/guichan/include/guichan/widgets/radiobutton.hpp
index 06a42b5a5..fc9377787 100644
--- a/src/guichan/include/guichan/widgets/radiobutton.hpp
+++ b/src/guichan/include/guichan/widgets/radiobutton.hpp
@@ -127,7 +127,7 @@ namespace gcn
* @param caption The caption of the radio button.
* @see getCaption, adjustSize
*/
- void setCaption(const std::string caption);
+ void setCaption(const std::string &caption);
/**
* Sets the group the radio button should belong to. Note that
diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp
index cf8505c4e..f00db27f9 100644
--- a/src/guichan/sdl/sdlimage.cpp
+++ b/src/guichan/sdl/sdlimage.cpp
@@ -55,10 +55,10 @@
namespace gcn
{
- SDLImage::SDLImage(SDL_Surface* surface, bool autoFree)
+ SDLImage::SDLImage(SDL_Surface* surface, bool autoFree) :
+ mSurface(surface),
+ mAutoFree(autoFree)
{
- mAutoFree = autoFree;
- mSurface = surface;
}
SDLImage::~SDLImage()
diff --git a/src/guichan/widgets/container.cpp b/src/guichan/widgets/container.cpp
index b3edc0bcb..d6951f06a 100644
--- a/src/guichan/widgets/container.cpp
+++ b/src/guichan/widgets/container.cpp
@@ -56,9 +56,9 @@
namespace gcn
{
- Container::Container()
+ Container::Container() :
+ mOpaque(true)
{
- mOpaque = true;
}
Container::~Container()
diff --git a/src/guichan/widgets/icon.cpp b/src/guichan/widgets/icon.cpp
index d3d4d65ff..26139716d 100644
--- a/src/guichan/widgets/icon.cpp
+++ b/src/guichan/widgets/icon.cpp
@@ -64,11 +64,9 @@ namespace gcn
}
Icon::Icon(const std::string& filename) :
- mImage(nullptr),
- mInternalImage(false)
+ mImage(Image::load(filename)),
+ mInternalImage(true)
{
- mImage = Image::load(filename);
- mInternalImage = true;
setSize(mImage->getWidth(),
mImage->getHeight());
}
diff --git a/src/guichan/widgets/label.cpp b/src/guichan/widgets/label.cpp
index 03ca04576..3e0eecb3c 100644
--- a/src/guichan/widgets/label.cpp
+++ b/src/guichan/widgets/label.cpp
@@ -56,16 +56,14 @@
namespace gcn
{
- Label::Label()
+ Label::Label() : mAlignment(Graphics::LEFT)
{
- mAlignment = Graphics::LEFT;
}
- Label::Label(const std::string& caption)
+ Label::Label(const std::string& caption) :
+ mCaption(caption),
+ mAlignment(Graphics::LEFT)
{
- mCaption = caption;
- mAlignment = Graphics::LEFT;
-
setWidth(getFont()->getWidth(caption));
setHeight(getFont()->getHeight());
}
diff --git a/src/guichan/widgets/radiobutton.cpp b/src/guichan/widgets/radiobutton.cpp
index 7811ea558..c5c0b1ebd 100644
--- a/src/guichan/widgets/radiobutton.cpp
+++ b/src/guichan/widgets/radiobutton.cpp
@@ -123,7 +123,7 @@ namespace gcn
return mCaption;
}
- void RadioButton::setCaption(const std::string caption)
+ void RadioButton::setCaption(const std::string &caption)
{
mCaption = caption;
}
diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp
index 21f7b5930..a9d84dd98 100644
--- a/src/guichan/widgets/scrollarea.cpp
+++ b/src/guichan/widgets/scrollarea.cpp
@@ -55,84 +55,81 @@
namespace gcn
{
- ScrollArea::ScrollArea()
+ ScrollArea::ScrollArea() :
+ mVScroll(0),
+ mHScroll(0),
+ mScrollbarWidth(12),
+ mHPolicy(SHOW_AUTO),
+ mVPolicy(SHOW_AUTO),
+ mVBarVisible(false),
+ mHBarVisible(false),
+ mUpButtonPressed(false),
+ mDownButtonPressed(false),
+ mLeftButtonPressed(false),
+ mRightButtonPressed(false),
+ mUpButtonScrollAmount(10),
+ mDownButtonScrollAmount(10),
+ mLeftButtonScrollAmount(10),
+ mRightButtonScrollAmount(10),
+ mIsVerticalMarkerDragged(false),
+ mIsHorizontalMarkerDragged(false),
+ mHorizontalMarkerDragOffset(0),
+ mVerticalMarkerDragOffset(0),
+ mOpaque(true)
{
- mVScroll = 0;
- mHScroll = 0;
- mHPolicy = SHOW_AUTO;
- mVPolicy = SHOW_AUTO;
- mVBarVisible = false;
- mHBarVisible = false;
- mScrollbarWidth = 12;
- mUpButtonPressed = false;
- mDownButtonPressed = false;
- mLeftButtonPressed = false;
- mRightButtonPressed = false;
- mUpButtonScrollAmount = 10;
- mDownButtonScrollAmount = 10;
- mLeftButtonScrollAmount = 10;
- mRightButtonScrollAmount = 10;
- mIsVerticalMarkerDragged = false;
- mIsHorizontalMarkerDragged = false;
- mHorizontalMarkerDragOffset = 0;
- mVerticalMarkerDragOffset = 0;
- mOpaque = true;
-
addMouseListener(this);
}
- ScrollArea::ScrollArea(Widget *content)
+ ScrollArea::ScrollArea(Widget *content) :
+ mVScroll(0),
+ mHScroll(0),
+ mScrollbarWidth(12),
+ mHPolicy(SHOW_AUTO),
+ mVPolicy(SHOW_AUTO),
+ mVBarVisible(false),
+ mHBarVisible(false),
+ mUpButtonPressed(false),
+ mDownButtonPressed(false),
+ mLeftButtonPressed(false),
+ mRightButtonPressed(false),
+ mUpButtonScrollAmount(10),
+ mDownButtonScrollAmount(10),
+ mLeftButtonScrollAmount(10),
+ mRightButtonScrollAmount(10),
+ mIsVerticalMarkerDragged(false),
+ mIsHorizontalMarkerDragged(false),
+ mHorizontalMarkerDragOffset(0),
+ mVerticalMarkerDragOffset(0),
+ mOpaque(true)
{
- mVScroll = 0;
- mHScroll = 0;
- mHPolicy = SHOW_AUTO;
- mVPolicy = SHOW_AUTO;
- mVBarVisible = false;
- mHBarVisible = false;
- mScrollbarWidth = 12;
- mUpButtonPressed = false;
- mDownButtonPressed = false;
- mLeftButtonPressed = false;
- mRightButtonPressed = false;
- mUpButtonScrollAmount = 10;
- mDownButtonScrollAmount = 10;
- mLeftButtonScrollAmount = 10;
- mRightButtonScrollAmount = 10;
- mIsVerticalMarkerDragged = false;
- mIsHorizontalMarkerDragged = false;
- mHorizontalMarkerDragOffset = 0;
- mVerticalMarkerDragOffset = 0;
- mOpaque = true;
-
setContent(content);
addMouseListener(this);
}
ScrollArea::ScrollArea(Widget *content,
ScrollPolicy hPolicy,
- ScrollPolicy vPolicy)
+ ScrollPolicy vPolicy) :
+ mVScroll(0),
+ mHScroll(0),
+ mScrollbarWidth(12),
+ mHPolicy(hPolicy),
+ mVPolicy(vPolicy),
+ mVBarVisible(false),
+ mHBarVisible(false),
+ mUpButtonPressed(false),
+ mDownButtonPressed(false),
+ mLeftButtonPressed(false),
+ mRightButtonPressed(false),
+ mUpButtonScrollAmount(10),
+ mDownButtonScrollAmount(10),
+ mLeftButtonScrollAmount(10),
+ mRightButtonScrollAmount(10),
+ mIsVerticalMarkerDragged(false),
+ mIsHorizontalMarkerDragged(false),
+ mHorizontalMarkerDragOffset(0),
+ mVerticalMarkerDragOffset(0),
+ mOpaque(true)
{
- mVScroll = 0;
- mHScroll = 0;
- mHPolicy = hPolicy;
- mVPolicy = vPolicy;
- mScrollbarWidth = 12;
- mVBarVisible = false;
- mHBarVisible = false;
- mUpButtonPressed = false;
- mDownButtonPressed = false;
- mLeftButtonPressed = false;
- mRightButtonPressed = false;
- mUpButtonScrollAmount = 10;
- mDownButtonScrollAmount = 10;
- mLeftButtonScrollAmount = 10;
- mRightButtonScrollAmount = 10;
- mIsVerticalMarkerDragged = false;
- mIsHorizontalMarkerDragged = false;
- mHorizontalMarkerDragOffset = 0;
- mVerticalMarkerDragOffset = 0;
- mOpaque = true;
-
setContent(content);
addMouseListener(this);
}
diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp
index d7e8084cc..189ee6e7b 100644
--- a/src/guichan/widgets/slider.cpp
+++ b/src/guichan/widgets/slider.cpp
@@ -56,13 +56,11 @@
namespace gcn
{
- Slider::Slider(double scaleEnd)
+ Slider::Slider(double scaleEnd) :
+ mDragged(false),
+ mScaleStart(0),
+ mScaleEnd(scaleEnd)
{
- mDragged = false;
-
- mScaleStart = 0;
- mScaleEnd = scaleEnd;
-
setFocusable(true);
setFrameSize(1);
setOrientation(HORIZONTAL);
@@ -74,13 +72,11 @@ namespace gcn
addKeyListener(this);
}
- Slider::Slider(double scaleStart, double scaleEnd)
+ Slider::Slider(double scaleStart, double scaleEnd) :
+ mDragged(false),
+ mScaleStart(scaleStart),
+ mScaleEnd(scaleEnd)
{
- mDragged = false;
-
- mScaleStart = scaleStart;
- mScaleEnd = scaleEnd;
-
setFocusable(true);
setFrameSize(1);
setOrientation(HORIZONTAL);
diff --git a/src/guichan/widgets/tab.cpp b/src/guichan/widgets/tab.cpp
index 8afc248c5..fa70f1e08 100644
--- a/src/guichan/widgets/tab.cpp
+++ b/src/guichan/widgets/tab.cpp
@@ -59,10 +59,10 @@
namespace gcn
{
Tab::Tab() :
+ mLabel(new Label()),
mHasMouse(false),
mTabbedArea(nullptr)
{
- mLabel = new Label();
mLabel->setPosition(4, 4);
add(mLabel);
diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp
index 44fb5d718..fc133ba9b 100644
--- a/src/guichan/widgets/textbox.cpp
+++ b/src/guichan/widgets/textbox.cpp
@@ -58,15 +58,13 @@
namespace gcn
{
- TextBox::TextBox()
+ TextBox::TextBox() :
+ mCaretColumn(0),
+ mCaretRow(0),
+ mEditable(true),
+ mOpaque(true)
{
- mCaretColumn = 0;
- mCaretRow = 0;
- mEditable = true;
- mOpaque = true;
-
setText("");
-
setFocusable(true);
addMouseListener(this);
@@ -74,15 +72,13 @@ namespace gcn
adjustSize();
}
- TextBox::TextBox(const std::string& text)
+ TextBox::TextBox(const std::string& text) :
+ mCaretColumn(0),
+ mCaretRow(0),
+ mEditable(true),
+ mOpaque(true)
{
- mCaretColumn = 0;
- mCaretRow = 0;
- mEditable = true;
- mOpaque = true;
-
setText(text);
-
setFocusable(true);
addMouseListener(this);
diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp
index c0e89cf1c..b23722cc4 100644
--- a/src/guichan/widgets/textfield.cpp
+++ b/src/guichan/widgets/textfield.cpp
@@ -57,23 +57,21 @@
namespace gcn
{
- TextField::TextField()
+ TextField::TextField() :
+ mCaretPosition(0),
+ mXScroll(0)
{
- mCaretPosition = 0;
- mXScroll = 0;
-
setFocusable(true);
addMouseListener(this);
addKeyListener(this);
}
- TextField::TextField(const std::string& text)
+ TextField::TextField(const std::string& text) :
+ mText(text),
+ mCaretPosition(0),
+ mXScroll(0)
{
- mCaretPosition = 0;
- mXScroll = 0;
-
- mText = text;
adjustSize();
setFocusable(true);