2002-07-05 16:56:53 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2002-2006 The ScummVM project
|
2002-07-05 16:56:53 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-07-05 16:56:53 +00:00
|
|
|
*
|
2006-02-11 10:08:56 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-07-05 16:56:53 +00:00
|
|
|
*/
|
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2003-11-02 18:57:20 +00:00
|
|
|
#include "common/util.h"
|
2005-05-11 19:30:30 +00:00
|
|
|
#include "graphics/fontman.h"
|
2003-11-02 18:57:20 +00:00
|
|
|
#include "gui/widget.h"
|
|
|
|
#include "gui/dialog.h"
|
2006-03-24 14:15:45 +00:00
|
|
|
#include "gui/eval.h"
|
2003-11-02 18:57:20 +00:00
|
|
|
#include "gui/newgui.h"
|
2002-07-05 16:56:53 +00:00
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2003-11-02 14:50:53 +00:00
|
|
|
Widget::Widget(GuiObject *boss, int x, int y, int w, int h)
|
|
|
|
: GuiObject(x, y, w, h), _type(0), _boss(boss),
|
2006-01-27 15:43:23 +00:00
|
|
|
_id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW), _hasFocus(false) {
|
2006-03-07 05:39:52 +00:00
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget::Widget(GuiObject *boss, String name)
|
|
|
|
: GuiObject(name), _type(0), _boss(boss),
|
|
|
|
_id(0), _flags(0), _hints(THEME_HINT_FIRST_DRAW), _hasFocus(false) {
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Widget::init() {
|
2002-07-05 16:56:53 +00:00
|
|
|
// Insert into the widget list of the boss
|
|
|
|
_next = _boss->_firstWidget;
|
|
|
|
_boss->_firstWidget = this;
|
2006-01-28 23:03:39 +00:00
|
|
|
// HACK: we enable background saving for all widgets by default for now
|
|
|
|
_hints = THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND;
|
2002-07-05 16:56:53 +00:00
|
|
|
}
|
|
|
|
|
2006-04-19 01:05:28 +00:00
|
|
|
void Widget::resize(int x, int y, int w, int h) {
|
|
|
|
_x = x;
|
|
|
|
_y = y;
|
|
|
|
_w = w;
|
|
|
|
_h = h;
|
|
|
|
}
|
|
|
|
|
2003-11-07 14:50:32 +00:00
|
|
|
Widget::~Widget() {
|
|
|
|
delete _next;
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void Widget::draw() {
|
2003-11-02 02:18:16 +00:00
|
|
|
NewGui *gui = &g_gui;
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-09-08 16:00:13 +00:00
|
|
|
if (!isVisible() || !_boss->isVisible())
|
2002-07-05 16:56:53 +00:00
|
|
|
return;
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-02 22:31:20 +00:00
|
|
|
int oldX = _x, oldY = _y;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
|
|
|
// Account for our relative position in the dialog
|
2003-11-02 22:31:20 +00:00
|
|
|
_x = getAbsX();
|
|
|
|
_y = getAbsY();
|
2002-07-07 13:14:34 +00:00
|
|
|
|
2002-07-10 16:49:45 +00:00
|
|
|
// Clear background (unless alpha blending is enabled)
|
2006-01-27 15:43:23 +00:00
|
|
|
//if (_flags & WIDGET_CLEARBG)
|
|
|
|
// gui->fillRect(_x, _y, _w, _h, gui->_bgcolor);
|
2002-07-07 13:14:34 +00:00
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
// Draw border
|
|
|
|
if (_flags & WIDGET_BORDER) {
|
2006-01-27 15:43:23 +00:00
|
|
|
gui->theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _hints, Theme::kWidgetBackgroundBorder);
|
2002-07-05 16:56:53 +00:00
|
|
|
_x += 4;
|
|
|
|
_y += 4;
|
2002-07-15 12:59:56 +00:00
|
|
|
_w -= 8;
|
2003-11-01 22:21:18 +00:00
|
|
|
_h -= 8;
|
2002-07-05 16:56:53 +00:00
|
|
|
}
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
// Now perform the actual widget draw
|
2002-09-21 Matt Hargett <matt@use.net>
* scumm.dsp, scummvm.dsp, simon.dsp: Turn on warning as errors. Generate
PDBs on all builds.
* gameDetector.cpp, newgui.cpp, widget.cpp, actor.cpp,
dialogs.cpp, resource.cpp, saveload.cpp, scumm_renderer.cpp:
Fix warnings where possible. One pragma added to eliminate
warning of unknown pragmas.
* string.cpp: If unknown escape sequence, print warning.
svn-id: r4998
2002-09-22 03:53:53 +00:00
|
|
|
drawWidget((_flags & WIDGET_HILITED) ? true : false);
|
2002-07-07 13:14:34 +00:00
|
|
|
|
2002-07-08 00:10:11 +00:00
|
|
|
// Restore x/y
|
2002-07-05 16:56:53 +00:00
|
|
|
if (_flags & WIDGET_BORDER) {
|
|
|
|
_x -= 4;
|
|
|
|
_y -= 4;
|
2002-07-15 12:59:56 +00:00
|
|
|
_w += 8;
|
2003-11-01 22:21:18 +00:00
|
|
|
_h += 8;
|
2002-07-05 16:56:53 +00:00
|
|
|
}
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2003-11-02 22:31:20 +00:00
|
|
|
_x = oldX;
|
|
|
|
_y = oldY;
|
|
|
|
|
|
|
|
// Draw all children
|
|
|
|
Widget *w = _firstWidget;
|
|
|
|
while (w) {
|
|
|
|
w->draw();
|
|
|
|
w = w->_next;
|
|
|
|
}
|
2006-01-27 15:43:23 +00:00
|
|
|
|
|
|
|
clearHints(THEME_HINT_FIRST_DRAW);
|
2002-07-05 16:56:53 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 18:57:20 +00:00
|
|
|
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;
|
|
|
|
}
|
2003-11-02 14:50:53 +00:00
|
|
|
|
2006-04-19 01:05:28 +00:00
|
|
|
Widget *Widget::findWidgetInChain(Widget *w, const char *name) {
|
|
|
|
while (w) {
|
|
|
|
if (w->_name == name) {
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
w = w->_next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-07 13:41:36 +00:00
|
|
|
bool Widget::isVisible() const {
|
|
|
|
if (g_gui.evaluator()->getVar(_name + ".visible") == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return !(_flags & WIDGET_INVISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2006-03-09 01:08:25 +00:00
|
|
|
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, TextAlignment align)
|
|
|
|
: Widget(boss, x, y, w, h), _align(align) {
|
|
|
|
_ws = g_gui.getWidgetSize();
|
2003-11-07 15:05:14 +00:00
|
|
|
_flags = WIDGET_ENABLED;
|
2002-07-08 11:55:55 +00:00
|
|
|
_type = kStaticTextWidget;
|
2005-04-16 17:53:18 +00:00
|
|
|
_label = text;
|
2002-07-10 22:49:41 +00:00
|
|
|
}
|
|
|
|
|
2006-03-24 01:24:26 +00:00
|
|
|
StaticTextWidget::StaticTextWidget(GuiObject *boss, String name, const String &text)
|
|
|
|
: Widget(boss, name) {
|
2006-03-08 01:42:02 +00:00
|
|
|
_ws = g_gui.getWidgetSize();
|
2006-03-07 05:39:52 +00:00
|
|
|
_flags = WIDGET_ENABLED;
|
|
|
|
_type = kStaticTextWidget;
|
|
|
|
_label = text;
|
2006-03-24 01:24:26 +00:00
|
|
|
|
|
|
|
_align = (Graphics::TextAlignment)g_gui.evaluator()->getVar(name + ".align");
|
|
|
|
|
|
|
|
if (_align == EVAL_UNDEF_VAR)
|
|
|
|
_align = kTextAlignLeft;
|
2006-03-07 05:39:52 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void StaticTextWidget::setValue(int value) {
|
2002-08-31 13:42:07 +00:00
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "%d", value);
|
|
|
|
_label = buf;
|
2002-07-27 00:05:46 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 17:53:18 +00:00
|
|
|
void StaticTextWidget::setLabel(const String &label) {
|
|
|
|
_label = label;
|
|
|
|
// TODO: We should automatically redraw when the label is changed.
|
|
|
|
// The following doesn't quite work when we are using tabs, plus it
|
|
|
|
// is rather clumsy to force a full redraw for a single static text.
|
|
|
|
// However, as long as we do blending, it might be the only way.
|
|
|
|
//_boss->draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StaticTextWidget::setAlign(TextAlignment align) {
|
|
|
|
_align = align;
|
|
|
|
// TODO: We should automatically redraw when the alignment is changed.
|
|
|
|
// See setLabel() for more insights.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void StaticTextWidget::drawWidget(bool hilite) {
|
2006-01-27 15:43:23 +00:00
|
|
|
g_gui.theme()->drawText(Common::Rect(_x, _y, _x+_w, _y+_h), _label,
|
|
|
|
isEnabled() ? Theme::kStateEnabled : Theme::kStateDisabled,
|
|
|
|
g_gui.theme()->convertAligment(_align));
|
2002-07-05 16:56:53 +00:00
|
|
|
}
|
|
|
|
|
2006-04-19 01:05:28 +00:00
|
|
|
void StaticTextWidget::handleScreenChanged() {
|
|
|
|
Widget::handleScreenChanged();
|
|
|
|
_ws = g_gui.getWidgetSize();
|
|
|
|
}
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2005-05-11 19:30:30 +00:00
|
|
|
ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey, WidgetSize ws)
|
2006-03-09 01:08:25 +00:00
|
|
|
: StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss),
|
2003-03-06 19:52:54 +00:00
|
|
|
_cmd(cmd), _hotkey(hotkey) {
|
2006-01-27 15:43:23 +00:00
|
|
|
_flags = WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG;
|
2002-07-08 11:55:55 +00:00
|
|
|
_type = kButtonWidget;
|
2002-07-05 16:56:53 +00:00
|
|
|
}
|
|
|
|
|
2006-03-08 01:42:02 +00:00
|
|
|
ButtonWidget::ButtonWidget(GuiObject *boss, String name, const String &label, uint32 cmd, uint8 hotkey)
|
2006-03-24 01:24:26 +00:00
|
|
|
: StaticTextWidget(boss, name, label), CommandSender(boss),
|
2006-03-07 05:39:52 +00:00
|
|
|
_cmd(cmd), _hotkey(hotkey) {
|
|
|
|
_flags = WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG;
|
|
|
|
_type = kButtonWidget;
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
2002-10-01 23:11:19 +00:00
|
|
|
if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
|
2002-07-12 16:24:11 +00:00
|
|
|
sendCommand(_cmd, 0);
|
|
|
|
}
|
2002-07-07 23:37:47 +00:00
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void ButtonWidget::drawWidget(bool hilite) {
|
2006-01-27 15:43:23 +00:00
|
|
|
g_gui.theme()->drawButton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, isEnabled() ? (hilite ? Theme::kStateHighlight : Theme::kStateEnabled) : Theme::kStateDisabled);
|
2002-10-19 01:22:41 +00:00
|
|
|
}
|
|
|
|
|
2002-07-07 23:37:47 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2005-05-11 19:30:30 +00:00
|
|
|
CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey, WidgetSize ws)
|
2005-05-18 10:30:52 +00:00
|
|
|
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey, ws), _state(false) {
|
2002-07-07 23:37:47 +00:00
|
|
|
_flags = WIDGET_ENABLED;
|
2002-07-08 11:55:55 +00:00
|
|
|
_type = kCheckboxWidget;
|
2002-07-07 23:37:47 +00:00
|
|
|
}
|
|
|
|
|
2006-03-08 01:42:02 +00:00
|
|
|
CheckboxWidget::CheckboxWidget(GuiObject *boss, String name, const String &label, uint32 cmd, uint8 hotkey)
|
|
|
|
: ButtonWidget(boss, name, label, cmd, hotkey), _state(false) {
|
|
|
|
_flags = WIDGET_ENABLED;
|
|
|
|
_type = kCheckboxWidget;
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
2002-10-19 01:22:41 +00:00
|
|
|
if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) {
|
|
|
|
toggleState();
|
2002-07-07 23:37:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-03 23:33:40 +00:00
|
|
|
void CheckboxWidget::setState(bool state) {
|
|
|
|
if (_state != state) {
|
|
|
|
_state = state;
|
|
|
|
_flags ^= WIDGET_INV_BORDER;
|
|
|
|
draw();
|
|
|
|
}
|
2003-11-07 16:01:51 +00:00
|
|
|
sendCommand(_cmd, _state);
|
2003-11-03 23:33:40 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void CheckboxWidget::drawWidget(bool hilite) {
|
2006-01-27 15:43:23 +00:00
|
|
|
g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state,
|
2006-02-01 15:11:39 +00:00
|
|
|
isEnabled() ? (hilite ? Theme::kStateHighlight : Theme::kStateEnabled) : Theme::kStateDisabled);
|
2002-07-07 23:37:47 +00:00
|
|
|
}
|
2002-07-08 13:52:50 +00:00
|
|
|
|
|
|
|
#pragma mark -
|
2002-07-08 22:11:47 +00:00
|
|
|
|
2005-05-18 10:24:02 +00:00
|
|
|
SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd)
|
|
|
|
: Widget(boss, x, y, w, h), CommandSender(boss),
|
2005-05-18 15:58:39 +00:00
|
|
|
_cmd(cmd), _value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false) {
|
2002-07-10 16:49:45 +00:00
|
|
|
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
|
2002-07-08 13:52:50 +00:00
|
|
|
_type = kSliderWidget;
|
|
|
|
}
|
|
|
|
|
2006-03-08 01:42:02 +00:00
|
|
|
SliderWidget::SliderWidget(GuiObject *boss, String name, uint32 cmd)
|
|
|
|
: Widget(boss, name), CommandSender(boss),
|
|
|
|
_cmd(cmd), _value(0), _oldValue(0), _valueMin(0), _valueMax(100), _isDragging(false) {
|
|
|
|
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
|
|
|
|
_type = kSliderWidget;
|
|
|
|
}
|
|
|
|
|
2002-12-12 23:21:29 +00:00
|
|
|
void SliderWidget::handleMouseMoved(int x, int y, int button) {
|
2005-05-18 10:24:02 +00:00
|
|
|
if (isEnabled() && _isDragging && x >= 0) {
|
|
|
|
int newValue = posToValue(x);
|
2002-07-26 23:29:43 +00:00
|
|
|
if (newValue < _valueMin)
|
|
|
|
newValue = _valueMin;
|
|
|
|
else if (newValue > _valueMax)
|
|
|
|
newValue = _valueMax;
|
2002-07-16 12:01:03 +00:00
|
|
|
|
|
|
|
if (newValue != _value) {
|
2005-07-30 21:11:48 +00:00
|
|
|
_value = newValue;
|
2002-07-10 22:49:41 +00:00
|
|
|
draw();
|
2002-07-27 00:05:46 +00:00
|
|
|
sendCommand(_cmd, _value); // FIXME - hack to allow for "live update" in sound dialog
|
2002-07-10 22:49:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-27 14:16:14 +00:00
|
|
|
void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount) {
|
2002-10-01 23:11:19 +00:00
|
|
|
if (isEnabled()) {
|
2002-12-12 23:21:29 +00:00
|
|
|
_isDragging = true;
|
|
|
|
handleMouseMoved(x, y, button);
|
2002-07-27 00:05:46 +00:00
|
|
|
}
|
2002-07-13 18:32:09 +00:00
|
|
|
}
|
|
|
|
|
2002-07-27 14:16:14 +00:00
|
|
|
void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
2002-10-01 23:11:19 +00:00
|
|
|
if (isEnabled() && _isDragging) {
|
2002-07-27 00:05:46 +00:00
|
|
|
sendCommand(_cmd, _value);
|
2002-07-26 00:41:07 +00:00
|
|
|
}
|
2002-07-16 12:01:03 +00:00
|
|
|
_isDragging = false;
|
2002-07-13 18:32:09 +00:00
|
|
|
}
|
2002-07-26 23:29:43 +00:00
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void SliderWidget::drawWidget(bool hilite) {
|
2006-01-27 15:43:23 +00:00
|
|
|
g_gui.theme()->drawSlider(Common::Rect(_x, _y, _x+_w, _y+_h), valueToPos(_value),
|
|
|
|
isEnabled() ? (hilite ? Theme::kStateHighlight : Theme::kStateEnabled) : Theme::kStateDisabled);
|
2002-07-26 23:29:43 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
int SliderWidget::valueToPos(int value) {
|
2005-05-18 10:24:02 +00:00
|
|
|
return ((_w - 4) * (value - _valueMin) / (_valueMax - _valueMin));
|
2002-07-26 23:29:43 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
int SliderWidget::posToValue(int pos) {
|
2005-05-18 10:24:02 +00:00
|
|
|
return (pos) * (_valueMax - _valueMin) / (_w - 4) + _valueMin;
|
2002-07-26 23:29:43 +00:00
|
|
|
}
|
2003-11-10 23:40:48 +00:00
|
|
|
|
2005-05-08 22:38:29 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
GraphicsWidget::GraphicsWidget(GuiObject *boss, int x, int y, int w, int h)
|
2006-03-14 02:19:38 +00:00
|
|
|
: Widget(boss, x, y, w, h), _gfx(), _transparency(false) {
|
|
|
|
_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
|
|
|
|
_type = kGraphicsWidget;
|
|
|
|
// HACK: Don't save the background. We want to be sure that redrawing
|
|
|
|
// the widget updates the screen, even when there isn't any image
|
|
|
|
// to draw.
|
|
|
|
_hints &= ~THEME_HINT_SAVE_BACKGROUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
GraphicsWidget::GraphicsWidget(GuiObject *boss, String name)
|
|
|
|
: Widget(boss, name), _gfx(), _transparency(false) {
|
2005-07-30 21:11:48 +00:00
|
|
|
_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
|
2005-05-08 22:38:29 +00:00
|
|
|
_type = kGraphicsWidget;
|
2006-02-24 21:51:41 +00:00
|
|
|
// HACK: Don't save the background. We want to be sure that redrawing
|
|
|
|
// the widget updates the screen, even when there isn't any image
|
|
|
|
// to draw.
|
|
|
|
_hints &= ~THEME_HINT_SAVE_BACKGROUND;
|
2005-05-08 22:38:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GraphicsWidget::~GraphicsWidget() {
|
|
|
|
_gfx.free();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
|
|
|
|
_gfx.free();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-08 23:39:37 +00:00
|
|
|
if (!gfx || !gfx->pixels)
|
2005-05-08 22:38:29 +00:00
|
|
|
return;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-08 22:38:29 +00:00
|
|
|
// TODO: add conversion to OverlayColor
|
|
|
|
_gfx.create(gfx->w, gfx->h, gfx->bytesPerPixel);
|
|
|
|
memcpy(_gfx.pixels, gfx->pixels, gfx->h * gfx->pitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsWidget::drawWidget(bool hilite) {
|
2006-01-27 15:43:23 +00:00
|
|
|
if (sizeof(OverlayColor) == _gfx.bytesPerPixel && _gfx.pixels) {
|
2006-03-14 02:19:38 +00:00
|
|
|
g_gui.theme()->drawSurface(Common::Rect(_x, _y, _x+_w, _y+_h), _gfx, Theme::kStateEnabled, _transparency);
|
2006-01-27 15:43:23 +00:00
|
|
|
}
|
2005-05-08 22:38:29 +00:00
|
|
|
}
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
} // End of namespace GUI
|