diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-07-16 11:37:34 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-07-16 11:37:34 +0000 |
commit | d9aa17b843253b05278e10f804a48ab036fb6119 (patch) | |
tree | 1f495c38d3484eaad3d7d97816c518e1466f3fc9 /src/gui/scrollarea.cpp | |
parent | eb1fcf549a7a165624189276fd30af01a42ec0cb (diff) | |
download | mana-client-d9aa17b843253b05278e10f804a48ab036fb6119.tar.gz mana-client-d9aa17b843253b05278e10f804a48ab036fb6119.tar.bz2 mana-client-d9aa17b843253b05278e10f804a48ab036fb6119.tar.xz mana-client-d9aa17b843253b05278e10f804a48ab036fb6119.zip |
Added generic Scrollarea::drawButton function that is called by the specific ones
Diffstat (limited to 'src/gui/scrollarea.cpp')
-rw-r--r-- | src/gui/scrollarea.cpp | 113 |
1 files changed, 54 insertions, 59 deletions
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 03234dca..cfefe898 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -27,14 +27,7 @@ int ScrollArea::instances = 0; ImageRect ScrollArea::background; ImageRect ScrollArea::vMarker; -Image *ScrollArea::hscroll_left_default; -Image *ScrollArea::hscroll_right_default; -Image *ScrollArea::vscroll_down_default; -Image *ScrollArea::vscroll_up_default; -Image *ScrollArea::hscroll_left_pressed; -Image *ScrollArea::hscroll_right_pressed; -Image *ScrollArea::vscroll_down_pressed; -Image *ScrollArea::vscroll_up_pressed; +Image *ScrollArea::buttons[4][2]; ScrollArea::ScrollArea(): gcn::ScrollArea() @@ -59,14 +52,14 @@ ScrollArea::~ScrollArea() delete vMarker.grid[a]; } - hscroll_left_default->decRef(); - hscroll_right_default->decRef(); - vscroll_down_default->decRef(); - vscroll_up_default->decRef(); - hscroll_left_pressed->decRef(); - hscroll_right_pressed->decRef(); - vscroll_down_pressed->decRef(); - vscroll_up_pressed->decRef(); + buttons[UP][0]->decRef(); + buttons[UP][1]->decRef(); + buttons[DOWN][0]->decRef(); + buttons[DOWN][1]->decRef(); + buttons[LEFT][0]->decRef(); + buttons[LEFT][1]->decRef(); + buttons[RIGHT][0]->decRef(); + buttons[RIGHT][1]->decRef(); } } @@ -114,22 +107,22 @@ void ScrollArea::init() vscroll->decRef(); - hscroll_left_default = + buttons[UP][0] = + resman->getImage("graphics/gui/vscroll_up_default.png"); + buttons[DOWN][0] = + resman->getImage("graphics/gui/vscroll_down_default.png"); + buttons[LEFT][0] = resman->getImage("graphics/gui/hscroll_left_default.png"); - hscroll_right_default = + buttons[RIGHT][0] = resman->getImage("graphics/gui/hscroll_right_default.png"); - vscroll_down_default = - resman->getImage("graphics/gui/vscroll_down_default.png"); - vscroll_up_default = - resman->getImage("graphics/gui/vscroll_up_default.png"); - hscroll_left_pressed = + buttons[UP][1] = + resman->getImage("graphics/gui/vscroll_up_pressed.png"); + buttons[DOWN][1] = + resman->getImage("graphics/gui/vscroll_down_pressed.png"); + buttons[LEFT][1] = resman->getImage("graphics/gui/hscroll_left_pressed.png"); - hscroll_right_pressed = + buttons[RIGHT][1] = resman->getImage("graphics/gui/hscroll_right_pressed.png"); - vscroll_down_pressed = - resman->getImage("graphics/gui/vscroll_down_pressed.png"); - vscroll_up_pressed = - resman->getImage("graphics/gui/vscroll_up_pressed.png"); } instances++; @@ -247,51 +240,53 @@ bool ScrollArea::isOpaque() return opaque; } +void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir) +{ + int x, y, state = 0; + gcn::Rectangle dim; + + getAbsolutePosition(x,y); + + switch(dir) { + case UP: + state = mUpButtonPressed ? 1 : 0; + dim = getUpButtonDimension(); + break; + case DOWN: + state = mDownButtonPressed ? 1 : 0; + dim = getDownButtonDimension(); + break; + case LEFT: + state = mLeftButtonPressed ? 1 : 0; + dim = getLeftButtonDimension(); + break; + case RIGHT: + state = mRightButtonPressed ? 1 : 0; + dim = getRightButtonDimension(); + break; + } + + buttons[dir][state]->draw(screen, x + dim.x, y + dim.y); +} + void ScrollArea::drawUpButton(gcn::Graphics *graphics) { - gcn::Rectangle dim = getUpButtonDimension(); - int x, y; - getAbsolutePosition(x, y); - if (mUpButtonPressed) - vscroll_up_pressed->draw(screen, x + dim.x, y + dim.y); - else - vscroll_up_default->draw(screen, x + dim.x, y + dim.y); + drawButton(graphics, UP); } void ScrollArea::drawDownButton(gcn::Graphics *graphics) { - gcn::Rectangle dim = getDownButtonDimension(); - int x, y; - getAbsolutePosition(x, y); - if (mDownButtonPressed) - vscroll_down_pressed->draw(screen, x + dim.x, y + dim.y); - else - vscroll_down_default->draw(screen, x + dim.x, y + dim.y); - + drawButton(graphics, DOWN); } void ScrollArea::drawLeftButton(gcn::Graphics *graphics) { - gcn::Rectangle dim = getLeftButtonDimension(); - int x, y; - getAbsolutePosition(x, y); - if (mLeftButtonPressed) - hscroll_left_pressed->draw(screen, x + dim.x, y + dim.y); - else - hscroll_left_default->draw(screen, x + dim.x, y + dim.y); - + drawButton(graphics, LEFT); } void ScrollArea::drawRightButton(gcn::Graphics *graphics) { - gcn::Rectangle dim = getRightButtonDimension(); - int x, y; - getAbsolutePosition(x, y); - if (mRightButtonPressed) - hscroll_right_pressed->draw(screen, x + dim.x, y + dim.y); - else - hscroll_right_default->draw(screen, x + dim.x, y + dim.y); - + drawButton(graphics, RIGHT); } void ScrollArea::drawVBar(gcn::Graphics *graphics) |