From a9f700b0a31c8bf2de7c2adf78a0e2b36f4edfbc Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 17 Apr 2005 11:47:44 +0000 Subject: Allow usage of ScrollBarWidget with a non-standard width svn-id: r17650 --- gui/ListWidget.cpp | 4 ++-- gui/ScrollBarWidget.cpp | 6 +++--- gui/ScrollBarWidget.h | 2 +- gui/console.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index f6b3526184..a6cf672f6d 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -28,7 +28,7 @@ namespace GUI { ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h) - : EditableWidget(boss, x, y, w - kScrollBarWidth, h), CommandSender(boss) { + : EditableWidget(boss, x, y, w - kDefaultScrollBarWidth, h), CommandSender(boss) { _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE; _type = kListWidget; _editMode = false; @@ -36,7 +36,7 @@ ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h) _entriesPerPage = (_h - 2) / kLineHeight; _currentPos = 0; _selectedItem = -1; - _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kScrollBarWidth, _h); + _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kDefaultScrollBarWidth, _h); _scrollBar->setTarget(this); _currentKeyDown = 0; diff --git a/gui/ScrollBarWidget.cpp b/gui/ScrollBarWidget.cpp index edcee76ff8..50c66cb63d 100644 --- a/gui/ScrollBarWidget.cpp +++ b/gui/ScrollBarWidget.cpp @@ -26,7 +26,7 @@ namespace GUI { -#define UP_DOWN_BOX_HEIGHT 10 +#define UP_DOWN_BOX_HEIGHT (_w+1) // Up arrow static uint32 up_arrow[8] = { @@ -215,13 +215,13 @@ void ScrollBarWidget::drawWidget(bool hilite) { // Up arrow gui->frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, gui->_color); - gui->drawBitmap(up_arrow, _x + 1, _y, + gui->drawBitmap(up_arrow, _x + 1 + (_w - 8) / 2, _y + (_w - 8) / 2, isSinglePage ? gui->_color : (hilite && _part == kUpArrowPart) ? gui->_textcolorhi : gui->_textcolor); // Down arrow gui->frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, gui->_color); - gui->drawBitmap(down_arrow, _x + 1, bottomY - UP_DOWN_BOX_HEIGHT, + gui->drawBitmap(down_arrow, _x + 1 + (_w - 8) / 2, bottomY - UP_DOWN_BOX_HEIGHT + (_w - 8) / 2, isSinglePage ? gui->_color : (hilite && _part == kDownArrowPart) ? gui->_textcolorhi : gui->_textcolor); diff --git a/gui/ScrollBarWidget.h b/gui/ScrollBarWidget.h index 3bf6d1d009..dd132096c5 100644 --- a/gui/ScrollBarWidget.h +++ b/gui/ScrollBarWidget.h @@ -26,7 +26,7 @@ namespace GUI { enum { - kScrollBarWidth = 9 + kDefaultScrollBarWidth = 9 }; diff --git a/gui/console.cpp b/gui/console.cpp index 9e5abe6b2e..badbce2cee 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -74,7 +74,7 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) _slideTime = 0; // Add scrollbar - _scrollBar = new ScrollBarWidget(this, _w - kScrollBarWidth - 1, 0, kScrollBarWidth, _h); + _scrollBar = new ScrollBarWidget(this, _w - kDefaultScrollBarWidth - 1, 0, kDefaultScrollBarWidth, _h); _scrollBar->setTarget(this); // Init callback @@ -98,13 +98,13 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) void ConsoleDialog::reflowLayout() { // Calculate the real width/height (rounded to char/line multiples) _w = (uint16)(_widthPercent * g_system->getOverlayWidth()); -// _w = (_widthPercent * g_system->getOverlayWidth() - kScrollBarWidth - 2) / kConsoleCharWidth; -// _w = _w * kConsoleCharWidth + kScrollBarWidth + 2; +// _w = (_widthPercent * g_system->getOverlayWidth() - kDefaultScrollBarWidth - 2) / kConsoleCharWidth; +// _w = _w * kConsoleCharWidth + kDefaultScrollBarWidth + 2; _h = (uint16)((_heightPercent * g_system->getOverlayHeight() - 2) / kConsoleLineHeight); _h = _h * kConsoleLineHeight + 2; // Calculate depending values - _lineWidth = (_w - kScrollBarWidth - 2) / kConsoleCharWidth; + _lineWidth = (_w - kDefaultScrollBarWidth - 2) / kConsoleCharWidth; _linesPerPage = (_h - 2) / kConsoleLineHeight; } -- cgit v1.2.3