aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/dialog.cpp13
-rw-r--r--gui/newgui.cpp5
-rw-r--r--gui/newgui.h2
-rw-r--r--gui/widget.cpp36
-rw-r--r--gui/widget.h3
5 files changed, 33 insertions, 26 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 401f84549d..ffa0b191e8 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -103,7 +103,7 @@ void Dialog::drawDialog() {
return;
g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor);
- g_gui.box(_x, _y, _w, _h);
+ g_gui.box(_x, _y, _w, _h, g_gui._color, g_gui._shadowcolor);
while (w) {
w->draw();
@@ -267,16 +267,7 @@ void Dialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
* in the local coordinate system, i.e. relative to the top left of the dialog.
*/
Widget *Dialog::findWidget(int x, int y) {
- Widget *w = _firstWidget;
- while (w) {
- // Stop as soon as we find a widget that contains the point (x,y)
- if (x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->_h)
- break;
- w = w->_next;
- }
- if (w)
- w = w->findWidget(x - w->_x, y - w->_y);
- return w;
+ return Widget::findWidgetInChain(_firstWidget, x, y);
}
ButtonWidget *Dialog::addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey) {
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 0a9b44074c..c46b3664f8 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -285,10 +285,7 @@ NewGuiColor *NewGui::getBasePtr(int x, int y) {
return _screen + x + y * _screenPitch;
}
-void NewGui::box(int x, int y, int width, int height, bool inverted) {
- NewGuiColor colorA = inverted ? _shadowcolor : _color;
- NewGuiColor colorB = inverted ? _color : _shadowcolor;
-
+void NewGui::box(int x, int y, int width, int height, NewGuiColor colorA, NewGuiColor colorB) {
hLine(x + 1, y, x + width - 2, colorA);
hLine(x, y + 1, x + width - 1, colorA);
vLine(x, y + 1, y + height - 2, colorA);
diff --git a/gui/newgui.h b/gui/newgui.h
index 7cec44d567..ac0c454df0 100644
--- a/gui/newgui.h
+++ b/gui/newgui.h
@@ -128,7 +128,7 @@ public:
// Drawing primitives
NewGuiColor *getBasePtr(int x, int y);
- void box(int x, int y, int width, int height, bool inverted = false);
+ void box(int x, int y, int width, int height, NewGuiColor colorA, NewGuiColor colorB);
void line(int x, int y, int x2, int y2, NewGuiColor color);
void blendRect(int x, int y, int w, int h, NewGuiColor color, int level = 3);
void fillRect(int x, int y, int w, int h, NewGuiColor color);
diff --git a/gui/widget.cpp b/gui/widget.cpp
index b0ab5889b0..2a337b9dd2 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -19,9 +19,10 @@
*/
#include "stdafx.h"
-#include "widget.h"
-#include "dialog.h"
-#include "newgui.h"
+#include "common/util.h"
+#include "gui/widget.h"
+#include "gui/dialog.h"
+#include "gui/newgui.h"
Widget::Widget(GuiObject *boss, int x, int y, int w, int h)
@@ -39,8 +40,8 @@ void Widget::draw() {
return;
// Account for our relative position in the dialog
- _x += _boss->_x;
- _y += _boss->_y;
+ _x += _boss->getAbsX();
+ _y += _boss->getAbsY();
// Clear background (unless alpha blending is enabled)
if (_flags & WIDGET_CLEARBG)
@@ -48,7 +49,11 @@ void Widget::draw() {
// Draw border
if (_flags & WIDGET_BORDER) {
- gui->box(_x, _y, _w, _h, (_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER);
+ NewGuiColor colorA = gui->_color;
+ NewGuiColor colorB = gui->_shadowcolor;
+ if ((_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER)
+ SWAP(colorA, colorB);
+ gui->box(_x, _y, _w, _h, colorA, colorB);
_x += 4;
_y += 4;
_w -= 8;
@@ -69,10 +74,21 @@ void Widget::draw() {
// Flag the draw area as dirty
gui->addDirtyRect(_x, _y, _w, _h);
- _x -= _boss->_x;
- _y -= _boss->_y;
+ _x -= _boss->getAbsX();
+ _y -= _boss->getAbsY();
}
+Widget *Widget::findWidgetInChain(Widget *w, int x, int y) {
+ while (w) {
+ // Stop as soon as we find a widget that contains the point (x,y)
+ if (x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->_h)
+ break;
+ w = w->_next;
+ }
+ if (w)
+ w = w->findWidget(x - w->_x, y - w->_y);
+ return w;
+}
#pragma mark -
@@ -161,7 +177,7 @@ void CheckboxWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
// Draw the box
- gui->box(_x, _y, 14, 14);
+ gui->box(_x, _y, 14, 14, gui->_color, gui->_shadowcolor);
// If checked, draw cross inside the box
if (_state)
@@ -218,7 +234,7 @@ void SliderWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
// Draw the box
- gui->box(_x, _y, _w, _h);
+ gui->box(_x, _y, _w, _h, gui->_color, gui->_shadowcolor);
// Draw the 'bar'
gui->fillRect(_x + 2, _y + 2, valueToPos(_value), _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
diff --git a/gui/widget.h b/gui/widget.h
index 08e519558f..11722aacac 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -73,6 +73,9 @@ protected:
bool _hasFocus;
public:
+ static Widget *findWidgetInChain(Widget *start, int x, int y);
+
+public:
Widget(GuiObject *boss, int x, int y, int w, int h);
virtual ~Widget() {}