diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-26 21:29:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-08-26 21:29:59 +0300 |
commit | a33a8dc48761d7cb2b4c1c468e1e3b188bcbf709 (patch) | |
tree | 1b1e98a615e2c03641c99b66cb4667b56f7087c3 /src/guichan/widgets | |
parent | 012a10fd8153f3ddb775dde1e4dba4456f2aa9de (diff) | |
download | plus-a33a8dc48761d7cb2b4c1c468e1e3b188bcbf709.tar.gz plus-a33a8dc48761d7cb2b4c1c468e1e3b188bcbf709.tar.bz2 plus-a33a8dc48761d7cb2b4c1c468e1e3b188bcbf709.tar.xz plus-a33a8dc48761d7cb2b4c1c468e1e3b188bcbf709.zip |
Add const to some classes.
Diffstat (limited to 'src/guichan/widgets')
-rw-r--r-- | src/guichan/widgets/checkbox.cpp | 2 | ||||
-rw-r--r-- | src/guichan/widgets/dropdown.cpp | 6 | ||||
-rw-r--r-- | src/guichan/widgets/label.cpp | 2 | ||||
-rw-r--r-- | src/guichan/widgets/radiobutton.cpp | 2 | ||||
-rw-r--r-- | src/guichan/widgets/scrollarea.cpp | 29 | ||||
-rw-r--r-- | src/guichan/widgets/slider.cpp | 4 | ||||
-rw-r--r-- | src/guichan/widgets/tabbedarea.cpp | 8 | ||||
-rw-r--r-- | src/guichan/widgets/textbox.cpp | 2 | ||||
-rw-r--r-- | src/guichan/widgets/textfield.cpp | 3 |
9 files changed, 29 insertions, 29 deletions
diff --git a/src/guichan/widgets/checkbox.cpp b/src/guichan/widgets/checkbox.cpp index 413f8e6af..fe0bfbee4 100644 --- a/src/guichan/widgets/checkbox.cpp +++ b/src/guichan/widgets/checkbox.cpp @@ -118,7 +118,7 @@ namespace gcn void CheckBox::adjustSize() { - int height = getFont()->getHeight(); + const int height = getFont()->getHeight(); setHeight(height); setWidth(getFont()->getWidth(mCaption) + height + height / 2); diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp index 9f2180a72..0cd979adc 100644 --- a/src/guichan/widgets/dropdown.cpp +++ b/src/guichan/widgets/dropdown.cpp @@ -230,10 +230,10 @@ namespace gcn if (!mListBox) throw GCN_EXCEPTION("List box has been deleted."); - int listBoxHeight = mListBox->getHeight(); + const int listBoxHeight = mListBox->getHeight(); // We add 2 for the border - int h2 = getFont()->getHeight() + 2; + const int h2 = getFont()->getHeight() + 2; setHeight(h2); @@ -242,7 +242,7 @@ namespace gcn if (mDroppedDown && getParent()) { - int h = getParent()->getChildrenArea().height - getY(); + const int h = getParent()->getChildrenArea().height - getY(); if (listBoxHeight > h - h2 - 2) { diff --git a/src/guichan/widgets/label.cpp b/src/guichan/widgets/label.cpp index 3e0eecb3c..815bba741 100644 --- a/src/guichan/widgets/label.cpp +++ b/src/guichan/widgets/label.cpp @@ -91,7 +91,7 @@ namespace gcn void Label::draw(Graphics* graphics) { int textX; - int textY = getHeight() / 2 - getFont()->getHeight() / 2; + const int textY = getHeight() / 2 - getFont()->getHeight() / 2; switch (getAlignment()) { diff --git a/src/guichan/widgets/radiobutton.cpp b/src/guichan/widgets/radiobutton.cpp index 26bd7e44c..7f8d846d9 100644 --- a/src/guichan/widgets/radiobutton.cpp +++ b/src/guichan/widgets/radiobutton.cpp @@ -177,7 +177,7 @@ namespace gcn void RadioButton::adjustSize() { - int height = getFont()->getHeight(); + const int height = getFont()->getHeight(); setHeight(height); setWidth(getFont()->getWidth(getCaption()) + height + height / 2); diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp index 9668f9778..1251bc665 100644 --- a/src/guichan/widgets/scrollarea.cpp +++ b/src/guichan/widgets/scrollarea.cpp @@ -195,7 +195,7 @@ namespace gcn void ScrollArea::setVerticalScrollAmount(int vScroll) { - int max = getVerticalMaxScroll(); + const int max = getVerticalMaxScroll(); mVScroll = vScroll; @@ -213,7 +213,7 @@ namespace gcn void ScrollArea::setHorizontalScrollAmount(int hScroll) { - int max = getHorizontalMaxScroll(); + const int max = getHorizontalMaxScroll(); mHScroll = hScroll; @@ -241,7 +241,7 @@ namespace gcn if (!getContent()) return 0; - int value = getContent()->getWidth() - getChildrenArea().width + + const int value = getContent()->getWidth() - getChildrenArea().width + 2 * getContent()->getFrameSize(); if (value < 0) @@ -283,8 +283,8 @@ namespace gcn void ScrollArea::mousePressed(MouseEvent& mouseEvent) { - int x = mouseEvent.getX(); - int y = mouseEvent.getY(); + const int x = mouseEvent.getX(); + const int y = mouseEvent.getY(); if (getUpButtonDimension().isPointInRect(x, y)) { @@ -368,11 +368,11 @@ namespace gcn { if (mIsVerticalMarkerDragged) { - Rectangle barDim = getVerticalBarDimension(); + const Rectangle barDim = getVerticalBarDimension(); - int pos = mouseEvent.getY() - barDim.y + const int pos = mouseEvent.getY() - barDim.y - mVerticalMarkerDragOffset; - int length = getVerticalMarkerDimension().height; + const int length = getVerticalMarkerDimension().height; if ((barDim.height - length) > 0) { @@ -387,11 +387,11 @@ namespace gcn if (mIsHorizontalMarkerDragged) { - Rectangle barDim = getHorizontalBarDimension(); + const Rectangle barDim = getHorizontalBarDimension(); - int pos = mouseEvent.getX() - barDim.x + const int pos = mouseEvent.getX() - barDim.x - mHorizontalMarkerDragOffset; - int length = getHorizontalMarkerDimension().width; + const int length = getHorizontalMarkerDimension().width; if ((barDim.width - length) > 0) { @@ -464,13 +464,12 @@ namespace gcn void ScrollArea::checkPolicies() { - int w = getWidth(); - int h = getHeight(); + const int w = getWidth(); + const int h = getHeight(); mHBarVisible = false; mVBarVisible = false; - if (!getContent()) { mHBarVisible = (mHPolicy == SHOW_ALWAYS); @@ -616,7 +615,7 @@ namespace gcn Rectangle ScrollArea::getChildrenArea() { - Rectangle area = Rectangle(0, 0, + const Rectangle area = Rectangle(0, 0, mVBarVisible ? (getWidth() - mScrollbarWidth) : getWidth(), mHBarVisible ? (getHeight() - mScrollbarWidth) : getHeight()); diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp index 189ee6e7b..ed14f525a 100644 --- a/src/guichan/widgets/slider.cpp +++ b/src/guichan/widgets/slider.cpp @@ -209,7 +209,7 @@ namespace gcn else w = getHeight(); - double pos = v / (static_cast<double>(w) - getMarkerLength()); + const double pos = v / (static_cast<double>(w) - getMarkerLength()); return (1.0 - pos) * getScaleStart() + pos * getScaleEnd(); } @@ -221,7 +221,7 @@ namespace gcn else v = getHeight(); - int w = static_cast<int>((v - getMarkerLength()) + const int w = static_cast<int>((v - getMarkerLength()) * (value - getScaleStart()) / (getScaleEnd() - getScaleStart())); diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp index 6f4c4a2b9..7bd77e7cd 100644 --- a/src/guichan/widgets/tabbedarea.cpp +++ b/src/guichan/widgets/tabbedarea.cpp @@ -220,7 +220,7 @@ namespace gcn int x = 0; for (i = 0; i < sz; i++) { - Tab* tab = mTabs[i].first; + Tab *const tab = mTabs[i].first; tab->setPosition(x, maxTabHeight - tab->getHeight()); x += tab->getWidth(); } @@ -256,7 +256,7 @@ namespace gcn void TabbedArea::death(const Event& event) { - Tab* tab = dynamic_cast<Tab*>(event.getSource()); + Tab *const tab = dynamic_cast<Tab*>(event.getSource()); if (tab) removeTab(tab); @@ -266,8 +266,8 @@ namespace gcn void TabbedArea::action(const ActionEvent& actionEvent) { - Widget* source = actionEvent.getSource(); - Tab* tab = dynamic_cast<Tab*>(source); + Widget *const source = actionEvent.getSource(); + Tab *const tab = dynamic_cast<Tab*>(source); if (!tab) { diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp index 97256eb44..0640b6a2c 100644 --- a/src/guichan/widgets/textbox.cpp +++ b/src/guichan/widgets/textbox.cpp @@ -172,7 +172,7 @@ namespace gcn int width = 0; for (size_t i = 0, sz = mTextRows.size(); i < sz; ++i) { - int w = getFont()->getWidth(mTextRows[i]); + const int w = getFont()->getWidth(mTextRows[i]); if (width < w) width = w; } diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp index b74d2333f..2fffdc5f5 100644 --- a/src/guichan/widgets/textfield.cpp +++ b/src/guichan/widgets/textfield.cpp @@ -132,7 +132,8 @@ namespace gcn { if (isFocused()) { - int caretX = getFont()->getWidth(mText.substr(0, mCaretPosition)); + const int caretX = getFont()->getWidth( + mText.substr(0, mCaretPosition)); if (caretX - mXScroll >= getWidth() - 4) { |