summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-10 16:27:16 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-10 16:55:22 +0300
commitf6482585eb8d9fd514b38dd214d83acd3985dc76 (patch)
treeb70094dd1886f2a842364c9f2940b7b81acace79 /src
parent9b84665e4d2a3c069179cde38f32ce023b37542a (diff)
downloadManaVerse-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.gz
ManaVerse-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.bz2
ManaVerse-f6482585eb8d9fd514b38dd214d83acd3985dc76.tar.xz
ManaVerse-f6482585eb8d9fd514b38dd214d83acd3985dc76.zip
Add theme option to hide scrollbar buttons.
Also improve scrollbar speed.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/scrollarea.cpp355
-rw-r--r--src/gui/widgets/scrollarea.h19
-rw-r--r--src/guichan/include/guichan/widgets/scrollarea.hpp60
-rw-r--r--src/guichan/widgets/scrollarea.cpp316
4 files changed, 356 insertions, 394 deletions
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index ce67794a2..cfc9a8938 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -32,6 +32,7 @@
int ScrollArea::instances = 0;
float ScrollArea::mAlpha = 1.0;
+bool ScrollArea::mShowButtons = true;
ImageRect ScrollArea::background;
ImageRect ScrollArea::vMarker;
ImageRect ScrollArea::vMarkerHi;
@@ -166,6 +167,7 @@ void ScrollArea::init(std::string skinName)
rect.grid[f]->incRef();
buttons[f][i] = rect.grid[f];
}
+ mShowButtons = (skin->getOption("showbuttons", 1) == 1);
}
else
{
@@ -257,16 +259,22 @@ void ScrollArea::draw(gcn::Graphics *graphics)
mVertexes->clear();
if (mVBarVisible)
{
- calcButton(graphics, UP);
- calcButton(graphics, DOWN);
+ if (mShowButtons)
+ {
+ calcButton(graphics, UP);
+ calcButton(graphics, DOWN);
+ }
calcVBar(graphics);
calcVMarker(graphics);
}
if (mHBarVisible)
{
- calcButton(graphics, LEFT);
- calcButton(graphics, RIGHT);
+ if (mShowButtons)
+ {
+ calcButton(graphics, LEFT);
+ calcButton(graphics, RIGHT);
+ }
calcHBar(graphics);
calcHMarker(graphics);
}
@@ -277,16 +285,22 @@ void ScrollArea::draw(gcn::Graphics *graphics)
{
if (mVBarVisible)
{
- drawButton(graphics, UP);
- drawButton(graphics, DOWN);
+ if (mShowButtons)
+ {
+ drawButton(graphics, UP);
+ drawButton(graphics, DOWN);
+ }
drawVBar(graphics);
drawVMarker(graphics);
}
if (mHBarVisible)
{
- drawButton(graphics, LEFT);
- drawButton(graphics, RIGHT);
+ if (mShowButtons)
+ {
+ drawButton(graphics, LEFT);
+ drawButton(graphics, RIGHT);
+ }
drawHBar(graphics);
drawHMarker(graphics);
}
@@ -331,9 +345,9 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics)
BLOCK_START("ScrollArea::drawFrame")
if (mOpaque)
{
- const int bs = getFrameSize();
- const int w = getWidth() + bs * 2;
- const int h = getHeight() + bs * 2;
+ const int bs = mFrameSize;
+ const int w = mDimension.width + bs * 2;
+ const int h = mDimension.height + bs * 2;
updateCalcFlag(graphics);
@@ -538,7 +552,7 @@ void ScrollArea::drawVMarker(gcn::Graphics *const graphics)
{
const gcn::Rectangle &dim = getVerticalMarkerDimension();
- if ((mHasMouse) && (mX > (getWidth() - mScrollbarWidth)))
+ if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth)))
{
static_cast<Graphics*>(graphics)->
drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi);
@@ -554,7 +568,7 @@ void ScrollArea::calcVMarker(gcn::Graphics *const graphics)
{
const gcn::Rectangle &dim = getVerticalMarkerDimension();
- if ((mHasMouse) && (mX > (getWidth() - mScrollbarWidth)))
+ if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth)))
{
static_cast<Graphics*>(graphics)->calcWindow(
mVertexes, dim.x, dim.y, dim.width, dim.height, vMarkerHi);
@@ -570,7 +584,7 @@ void ScrollArea::drawHMarker(gcn::Graphics *const graphics)
{
const gcn::Rectangle dim = getHorizontalMarkerDimension();
- if ((mHasMouse) && (mY > (getHeight() - mScrollbarWidth)))
+ if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth)))
{
static_cast<Graphics*>(graphics)->
drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi);
@@ -586,7 +600,7 @@ void ScrollArea::calcHMarker(gcn::Graphics *const graphics)
{
const gcn::Rectangle dim = getHorizontalMarkerDimension();
- if ((mHasMouse) && (mY > (getHeight() - mScrollbarWidth)))
+ if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth)))
{
static_cast<Graphics*>(graphics)->calcWindow(
mVertexes, dim.x, dim.y, dim.width, dim.height, vMarkerHi);
@@ -617,8 +631,9 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event A_UNUSED)
void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED)
{
mRedraw = true;
- const unsigned int frameSize = 2 * getFrameSize();
- getContent()->setSize(getWidth() - frameSize, getHeight() - frameSize);
+ const unsigned int frameSize = 2 * mFrameSize;
+ getContent()->setSize(mDimension.width - frameSize,
+ mDimension.height - frameSize);
}
void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED)
@@ -628,7 +643,74 @@ void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED)
void ScrollArea::mousePressed(gcn::MouseEvent& event)
{
- gcn::ScrollArea::mousePressed(event);
+ const int x = event.getX();
+ const int y = event.getY();
+
+ if (getUpButtonDimension().isPointInRect(x, y))
+ {
+ setVerticalScrollAmount(mVScroll
+ - mUpButtonScrollAmount);
+ mUpButtonPressed = true;
+ }
+ else if (getDownButtonDimension().isPointInRect(x, y))
+ {
+ setVerticalScrollAmount(mVScroll
+ + mDownButtonScrollAmount);
+ mDownButtonPressed = true;
+ }
+ else if (getLeftButtonDimension().isPointInRect(x, y))
+ {
+ setHorizontalScrollAmount(getHorizontalScrollAmount()
+ - mLeftButtonScrollAmount);
+ mLeftButtonPressed = true;
+ }
+ else if (getRightButtonDimension().isPointInRect(x, y))
+ {
+ setHorizontalScrollAmount(getHorizontalScrollAmount()
+ + mRightButtonScrollAmount);
+ mRightButtonPressed = true;
+ }
+ else if (getVerticalMarkerDimension().isPointInRect(x, y))
+ {
+ mIsHorizontalMarkerDragged = false;
+ mIsVerticalMarkerDragged = true;
+
+ mVerticalMarkerDragOffset = y - getVerticalMarkerDimension().y;
+ }
+ else if (getVerticalBarDimension().isPointInRect(x, y))
+ {
+ if (y < getVerticalMarkerDimension().y)
+ {
+ setVerticalScrollAmount(mVScroll
+ - static_cast<int>(getChildrenArea().height * 0.95));
+ }
+ else
+ {
+ setVerticalScrollAmount(mVScroll
+ + static_cast<int>(getChildrenArea().height * 0.95));
+ }
+ }
+ else if (getHorizontalMarkerDimension().isPointInRect(x, y))
+ {
+ mIsHorizontalMarkerDragged = true;
+ mIsVerticalMarkerDragged = false;
+
+ mHorizontalMarkerDragOffset = x - getHorizontalMarkerDimension().x;
+ }
+ else if (getHorizontalBarDimension().isPointInRect(x, y))
+ {
+ if (x < getHorizontalMarkerDimension().x)
+ {
+ setHorizontalScrollAmount(getHorizontalScrollAmount()
+ - static_cast<int>(getChildrenArea().width * 0.95));
+ }
+ else
+ {
+ setHorizontalScrollAmount(getHorizontalScrollAmount()
+ + static_cast<int>(getChildrenArea().width * 0.95));
+ }
+ }
+
if (event.getButton() == gcn::MouseEvent::LEFT)
{
mClickX = event.getX();
@@ -690,3 +772,240 @@ void ScrollArea::mouseReleased(gcn::MouseEvent& event)
}
gcn::ScrollArea::mouseReleased(event);
}
+
+void ScrollArea::mouseDragged(gcn::MouseEvent &event)
+{
+ if (mIsVerticalMarkerDragged)
+ {
+ const gcn::Rectangle barDim = getVerticalBarDimension();
+
+ const int pos = event.getY() - barDim.y
+ - mVerticalMarkerDragOffset;
+ const int length = getVerticalMarkerDimension().height;
+
+ if ((barDim.height - length) > 0)
+ {
+ setVerticalScrollAmount((getVerticalMaxScroll() * pos)
+ / (barDim.height - length));
+ }
+ else
+ {
+ setVerticalScrollAmount(0);
+ }
+ }
+
+ if (mIsHorizontalMarkerDragged)
+ {
+ const gcn::Rectangle barDim = getHorizontalBarDimension();
+
+ const int pos = event.getX() - barDim.x
+ - mHorizontalMarkerDragOffset;
+ const int length = getHorizontalMarkerDimension().width;
+
+ if ((barDim.width - length) > 0)
+ {
+ setHorizontalScrollAmount((getHorizontalMaxScroll() * pos)
+ / (barDim.width - length));
+ }
+ else
+ {
+ setHorizontalScrollAmount(0);
+ }
+ }
+
+ event.consume();
+}
+
+gcn::Rectangle ScrollArea::getVerticalBarDimension() const
+{
+ if (!mVBarVisible)
+ return gcn::Rectangle(0, 0, 0, 0);
+
+ const int height = mVBarVisible ? mScrollbarWidth : 0;
+ if (mHBarVisible)
+ {
+ return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ height,
+ mScrollbarWidth,
+ mDimension.height - height - height - mScrollbarWidth);
+ }
+
+ return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ height,
+ mScrollbarWidth,
+ mDimension.height - height - height);
+}
+
+gcn::Rectangle ScrollArea::getHorizontalBarDimension() const
+{
+ if (!mHBarVisible)
+ return gcn::Rectangle(0, 0, 0, 0);
+
+ const int width = mHBarVisible ? mScrollbarWidth : 0;
+ if (mVBarVisible)
+ {
+ return gcn::Rectangle(width,
+ mDimension.height - mScrollbarWidth,
+ mDimension.width - width - width - mScrollbarWidth,
+ mScrollbarWidth);
+ }
+
+ return gcn::Rectangle(width,
+ mDimension.height - mScrollbarWidth,
+ mDimension.width - width - width,
+ mScrollbarWidth);
+}
+
+gcn::Rectangle ScrollArea::getVerticalMarkerDimension()
+{
+ if (!mVBarVisible)
+ return gcn::Rectangle(0, 0, 0, 0);
+
+ int length, pos;
+ int height;
+ const int h2 = mVBarVisible ? mScrollbarWidth : 0;
+ const gcn::Widget *content;
+ if (!mWidgets.empty())
+ content = *mWidgets.begin();
+ else
+ content = nullptr;
+
+ if (mHBarVisible)
+ height = mDimension.height - 2 * h2 - mScrollbarWidth;
+ else
+ height = mDimension.height - 2 * h2;
+
+ if (content && content->getHeight() != 0)
+ {
+ length = (height * getChildrenArea().height)
+ / content->getHeight();
+ }
+ else
+ {
+ length = height;
+ }
+
+ if (length < mScrollbarWidth)
+ length = mScrollbarWidth;
+
+ if (length > height)
+ length = height;
+
+ if (getVerticalMaxScroll() != 0)
+ {
+ pos = ((height - length) * mVScroll)
+ / getVerticalMaxScroll();
+ }
+ else
+ {
+ pos = 0;
+ }
+
+ return gcn::Rectangle(mDimension.width - mScrollbarWidth, h2 + pos,
+ mScrollbarWidth, length);
+}
+
+gcn::Rectangle ScrollArea::getHorizontalMarkerDimension()
+{
+ if (!mHBarVisible)
+ return gcn::Rectangle(0, 0, 0, 0);
+
+ int length, pos;
+ int width;
+ const int w2 = mHBarVisible ? mScrollbarWidth : 0;
+ const gcn::Widget *content;
+ if (!mWidgets.empty())
+ content = *mWidgets.begin();
+ else
+ content = nullptr;
+
+ if (mVBarVisible)
+ width = mDimension.width - 2 * w2 - mScrollbarWidth;
+ else
+ width = mDimension.width - w2 - mScrollbarWidth;
+
+ if (content && content->getWidth() != 0)
+ {
+ length = (width * getChildrenArea().width)
+ / content->getWidth();
+ }
+ else
+ {
+ length = width;
+ }
+
+ if (length < mScrollbarWidth)
+ length = mScrollbarWidth;
+
+ if (length > width)
+ length = width;
+
+ if (getHorizontalMaxScroll() != 0)
+ {
+ pos = ((width - length) * getHorizontalScrollAmount())
+ / getHorizontalMaxScroll();
+ }
+ else
+ {
+ pos = 0;
+ }
+
+ return gcn::Rectangle(w2 + pos, mDimension.height - mScrollbarWidth,
+ length, mScrollbarWidth);
+}
+
+gcn::Rectangle ScrollArea::getUpButtonDimension() const
+{
+ if (!mVBarVisible)
+ return gcn::Rectangle(0, 0, 0, 0);
+
+ return gcn::Rectangle(mDimension.width - mScrollbarWidth, 0,
+ mScrollbarWidth, mScrollbarWidth);
+}
+
+gcn::Rectangle ScrollArea::getDownButtonDimension() const
+{
+ if (!mVBarVisible)
+ return gcn::Rectangle(0, 0, 0, 0);
+
+ if (mVBarVisible && mHBarVisible)
+ {
+ return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ mDimension.height - mScrollbarWidth*2,
+ mScrollbarWidth,
+ mScrollbarWidth);
+ }
+
+ return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ mDimension.height - mScrollbarWidth,
+ mScrollbarWidth,
+ mScrollbarWidth);
+}
+
+gcn::Rectangle ScrollArea::getLeftButtonDimension() const
+{
+ if (!mHBarVisible)
+ return gcn::Rectangle(0, 0, 0, 0);
+
+ return gcn::Rectangle(0, mDimension.height - mScrollbarWidth,
+ mScrollbarWidth, mScrollbarWidth);
+}
+
+gcn::Rectangle ScrollArea::getRightButtonDimension() const
+{
+ if (!mHBarVisible)
+ return gcn::Rectangle(0, 0, 0, 0);
+
+ if (mVBarVisible && mHBarVisible)
+ {
+ return gcn::Rectangle(mDimension.width - mScrollbarWidth*2,
+ mDimension.height - mScrollbarWidth,
+ mScrollbarWidth,
+ mScrollbarWidth);
+ }
+
+ return gcn::Rectangle(mDimension.width - mScrollbarWidth,
+ mDimension.height - mScrollbarWidth,
+ mScrollbarWidth,
+ mScrollbarWidth);
+}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 58df259ba..3a552ee75 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -120,10 +120,28 @@ class ScrollArea final : public gcn::ScrollArea,
void mouseReleased(gcn::MouseEvent& event) override;
+ void mouseDragged(gcn::MouseEvent &event);
+
void widgetResized(const gcn::Event &event) override;
void widgetMoved(const gcn::Event &event) override;
+ gcn::Rectangle getVerticalBarDimension() const;
+
+ gcn::Rectangle getHorizontalBarDimension() const;
+
+ gcn::Rectangle getVerticalMarkerDimension();
+
+ gcn::Rectangle getHorizontalMarkerDimension();
+
+ gcn::Rectangle getUpButtonDimension() const;
+
+ gcn::Rectangle getDownButtonDimension() const;
+
+ gcn::Rectangle getLeftButtonDimension() const;
+
+ gcn::Rectangle getRightButtonDimension() const;
+
protected:
enum BUTTON_DIR
{
@@ -155,6 +173,7 @@ class ScrollArea final : public gcn::ScrollArea,
static int instances;
static float mAlpha;
+ static bool mShowButtons;
static ImageRect background;
static ImageRect vMarker;
static ImageRect vMarkerHi;
diff --git a/src/guichan/include/guichan/widgets/scrollarea.hpp b/src/guichan/include/guichan/widgets/scrollarea.hpp
index 92f68000e..32a3f8f5b 100644
--- a/src/guichan/include/guichan/widgets/scrollarea.hpp
+++ b/src/guichan/include/guichan/widgets/scrollarea.hpp
@@ -351,12 +351,8 @@ namespace gcn
// Inherited from MouseListener
- virtual void mousePressed(MouseEvent& mouseEvent) override;
-
virtual void mouseReleased(MouseEvent& mouseEvent) override;
- virtual void mouseDragged(MouseEvent& mouseEvent) override;
-
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent) override;
@@ -432,62 +428,6 @@ namespace gcn
virtual void checkPolicies();
/**
- * Gets the up button dimension.
- *
- * @return the dimension of the up button.
- */
- Rectangle getUpButtonDimension() const;
-
- /**
- * Gets the down button dimension.
- *
- * @return the dimension of the down button.
- */
- Rectangle getDownButtonDimension() const;
-
- /**
- * Gets the left button dimension.
- *
- * @return the dimension of the left button.
- */
- Rectangle getLeftButtonDimension() const;
-
- /**
- * Gets the right button dimension.
- *
- * @return the dimension of the right button.
- */
- Rectangle getRightButtonDimension() const;
-
- /**
- * Gets the vertical scrollbar dimension.
- *
- * @return the dimension of the vertical scrollbar.
- */
- Rectangle getVerticalBarDimension() const;
-
- /**
- * Gets the horizontal scrollbar dimension.
- *
- * @return the dimension of the horizontal scrollbar.
- */
- Rectangle getHorizontalBarDimension() const;
-
- /**
- * Gets the vertical marker dimension.
- *
- * @return the dimension of the vertical marker.
- */
- Rectangle getVerticalMarkerDimension();
-
- /**
- * Gets the horizontal marker dimension.
- *
- * @return the dimension of the horizontal marker.
- */
- Rectangle getHorizontalMarkerDimension();
-
- /**
* Holds the vertical scroll amount.
*/
int mVScroll;
diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp
index c286d26e6..67154fbad 100644
--- a/src/guichan/widgets/scrollarea.cpp
+++ b/src/guichan/widgets/scrollarea.cpp
@@ -287,77 +287,6 @@ namespace gcn
return mScrollbarWidth;
}
- void ScrollArea::mousePressed(MouseEvent& mouseEvent)
- {
- const int x = mouseEvent.getX();
- const int y = mouseEvent.getY();
-
- if (getUpButtonDimension().isPointInRect(x, y))
- {
- setVerticalScrollAmount(getVerticalScrollAmount()
- - mUpButtonScrollAmount);
- mUpButtonPressed = true;
- }
- else if (getDownButtonDimension().isPointInRect(x, y))
- {
- setVerticalScrollAmount(getVerticalScrollAmount()
- + mDownButtonScrollAmount);
- mDownButtonPressed = true;
- }
- else if (getLeftButtonDimension().isPointInRect(x, y))
- {
- setHorizontalScrollAmount(getHorizontalScrollAmount()
- - mLeftButtonScrollAmount);
- mLeftButtonPressed = true;
- }
- else if (getRightButtonDimension().isPointInRect(x, y))
- {
- setHorizontalScrollAmount(getHorizontalScrollAmount()
- + mRightButtonScrollAmount);
- mRightButtonPressed = true;
- }
- else if (getVerticalMarkerDimension().isPointInRect(x, y))
- {
- mIsHorizontalMarkerDragged = false;
- mIsVerticalMarkerDragged = true;
-
- mVerticalMarkerDragOffset = y - getVerticalMarkerDimension().y;
- }
- else if (getVerticalBarDimension().isPointInRect(x, y))
- {
- if (y < getVerticalMarkerDimension().y)
- {
- setVerticalScrollAmount(getVerticalScrollAmount()
- - static_cast<int>(getChildrenArea().height * 0.95));
- }
- else
- {
- setVerticalScrollAmount(getVerticalScrollAmount()
- + static_cast<int>(getChildrenArea().height * 0.95));
- }
- }
- else if (getHorizontalMarkerDimension().isPointInRect(x, y))
- {
- mIsHorizontalMarkerDragged = true;
- mIsVerticalMarkerDragged = false;
-
- mHorizontalMarkerDragOffset = x - getHorizontalMarkerDimension().x;
- }
- else if (getHorizontalBarDimension().isPointInRect(x, y))
- {
- if (x < getHorizontalMarkerDimension().x)
- {
- setHorizontalScrollAmount(getHorizontalScrollAmount()
- - static_cast<int>(getChildrenArea().width * 0.95));
- }
- else
- {
- setHorizontalScrollAmount(getHorizontalScrollAmount()
- + static_cast<int>(getChildrenArea().width * 0.95));
- }
- }
- }
-
void ScrollArea::mouseReleased(MouseEvent& mouseEvent)
{
mUpButtonPressed = false;
@@ -370,49 +299,6 @@ namespace gcn
mouseEvent.consume();
}
- void ScrollArea::mouseDragged(MouseEvent& mouseEvent)
- {
- if (mIsVerticalMarkerDragged)
- {
- const Rectangle barDim = getVerticalBarDimension();
-
- const int pos = mouseEvent.getY() - barDim.y
- - mVerticalMarkerDragOffset;
- const int length = getVerticalMarkerDimension().height;
-
- if ((barDim.height - length) > 0)
- {
- setVerticalScrollAmount((getVerticalMaxScroll() * pos)
- / (barDim.height - length));
- }
- else
- {
- setVerticalScrollAmount(0);
- }
- }
-
- if (mIsHorizontalMarkerDragged)
- {
- const Rectangle barDim = getHorizontalBarDimension();
-
- const int pos = mouseEvent.getX() - barDim.x
- - mHorizontalMarkerDragOffset;
- const int length = getHorizontalMarkerDimension().width;
-
- if ((barDim.width - length) > 0)
- {
- setHorizontalScrollAmount((getHorizontalMaxScroll() * pos)
- / (barDim.width - length));
- }
- else
- {
- setHorizontalScrollAmount(0);
- }
- }
-
- mouseEvent.consume();
- }
-
void ScrollArea::draw(Graphics *graphics A_UNUSED)
{
}
@@ -565,62 +451,6 @@ namespace gcn
}
}
- Rectangle ScrollArea::getUpButtonDimension() const
- {
- if (!mVBarVisible)
- return Rectangle(0, 0, 0, 0);
-
- return Rectangle(getWidth() - mScrollbarWidth, 0,
- mScrollbarWidth, mScrollbarWidth);
- }
-
- Rectangle ScrollArea::getDownButtonDimension() const
- {
- if (!mVBarVisible)
- return Rectangle(0, 0, 0, 0);
-
- if (mVBarVisible && mHBarVisible)
- {
- return Rectangle(getWidth() - mScrollbarWidth,
- getHeight() - mScrollbarWidth*2,
- mScrollbarWidth,
- mScrollbarWidth);
- }
-
- return Rectangle(getWidth() - mScrollbarWidth,
- getHeight() - mScrollbarWidth,
- mScrollbarWidth,
- mScrollbarWidth);
- }
-
- Rectangle ScrollArea::getLeftButtonDimension() const
- {
- if (!mHBarVisible)
- return Rectangle(0, 0, 0, 0);
-
- return Rectangle(0, getHeight() - mScrollbarWidth,
- mScrollbarWidth, mScrollbarWidth);
- }
-
- Rectangle ScrollArea::getRightButtonDimension() const
- {
- if (!mHBarVisible)
- return Rectangle(0, 0, 0, 0);
-
- if (mVBarVisible && mHBarVisible)
- {
- return Rectangle(getWidth() - mScrollbarWidth*2,
- getHeight() - mScrollbarWidth,
- mScrollbarWidth,
- mScrollbarWidth);
- }
-
- return Rectangle(getWidth() - mScrollbarWidth,
- getHeight() - mScrollbarWidth,
- mScrollbarWidth,
- mScrollbarWidth);
- }
-
Rectangle ScrollArea::getChildrenArea()
{
const Rectangle area = Rectangle(0, 0,
@@ -633,152 +463,6 @@ namespace gcn
return area;
}
- Rectangle ScrollArea::getVerticalBarDimension() const
- {
- if (!mVBarVisible)
- return Rectangle(0, 0, 0, 0);
-
- if (mHBarVisible)
- {
- return Rectangle(getWidth() - mScrollbarWidth,
- getUpButtonDimension().height,
- mScrollbarWidth,
- getHeight()
- - getUpButtonDimension().height
- - getDownButtonDimension().height
- - mScrollbarWidth);
- }
-
- return Rectangle(getWidth() - mScrollbarWidth,
- getUpButtonDimension().height,
- mScrollbarWidth,
- getHeight()
- - getUpButtonDimension().height
- - getDownButtonDimension().height);
- }
-
- Rectangle ScrollArea::getHorizontalBarDimension() const
- {
- if (!mHBarVisible)
- return Rectangle(0, 0, 0, 0);
-
- if (mVBarVisible)
- {
- return Rectangle(getLeftButtonDimension().width,
- getHeight() - mScrollbarWidth,
- getWidth()
- - getLeftButtonDimension().width
- - getRightButtonDimension().width
- - mScrollbarWidth,
- mScrollbarWidth);
- }
-
- return Rectangle(getLeftButtonDimension().width,
- getHeight() - mScrollbarWidth,
- getWidth()
- - getLeftButtonDimension().width
- - getRightButtonDimension().width,
- mScrollbarWidth);
- }
-
- Rectangle ScrollArea::getVerticalMarkerDimension()
- {
- if (!mVBarVisible)
- return Rectangle(0, 0, 0, 0);
-
- int length, pos;
- int height;
-
- if (mHBarVisible)
- {
- height = getHeight() - getUpButtonDimension().height
- - getDownButtonDimension().height - mScrollbarWidth;
- }
- else
- {
- height = getHeight() - getUpButtonDimension().height
- - getDownButtonDimension().height;
- }
-
- if (getContent() && getContent()->getHeight() != 0)
- {
- length = (height * getChildrenArea().height)
- / getContent()->getHeight();
- }
- else
- {
- length = height;
- }
-
- if (length < mScrollbarWidth)
- length = mScrollbarWidth;
-
- if (length > height)
- length = height;
-
- if (getVerticalMaxScroll() != 0)
- {
- pos = ((height - length) * getVerticalScrollAmount())
- / getVerticalMaxScroll();
- }
- else
- {
- pos = 0;
- }
-
- return Rectangle(getWidth() - mScrollbarWidth,
- getUpButtonDimension().height + pos, mScrollbarWidth, length);
- }
-
- Rectangle ScrollArea::getHorizontalMarkerDimension()
- {
- if (!mHBarVisible)
- return Rectangle(0, 0, 0, 0);
-
- int length, pos;
- int width;
-
- if (mVBarVisible)
- {
- width = getWidth() - getLeftButtonDimension().width
- - getRightButtonDimension().width - mScrollbarWidth;
- }
- else
- {
- width = getWidth() - getLeftButtonDimension().width
- - getRightButtonDimension().width;
- }
-
- if (getContent() && getContent()->getWidth() != 0)
- {
- length = (width * getChildrenArea().width)
- / getContent()->getWidth();
- }
- else
- {
- length = width;
- }
-
- if (length < mScrollbarWidth)
- length = mScrollbarWidth;
-
- if (length > width)
- length = width;
-
- if (getHorizontalMaxScroll() != 0)
- {
- pos = ((width - length) * getHorizontalScrollAmount())
- / getHorizontalMaxScroll();
- }
- else
- {
- pos = 0;
- }
-
- return Rectangle(getLeftButtonDimension().width + pos,
- getHeight() - mScrollbarWidth, length, mScrollbarWidth);
- }
-
void ScrollArea::showWidgetPart(Widget* widget, Rectangle area)
{
if (widget != getContent())