First pass at making the UI look a little nicer. For now, the colours

are hard-coded, but the infrastructure is there to make this modifiable
from the UI (at some point after the next release).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1339 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2007-08-06 20:16:51 +00:00
parent f6105adeec
commit 2c21d4b0de
16 changed files with 156 additions and 63 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: DebuggerDialog.cxx,v 1.19 2007-06-21 12:27:00 stephena Exp $ // $Id: DebuggerDialog.cxx,v 1.20 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -215,7 +215,7 @@ void DebuggerDialog::addStatusArea()
font.getLineHeight(), ""); font.getLineHeight(), "");
myMessageBox->setEditable(false); myMessageBox->setEditable(false);
myMessageBox->clearFlags(WIDGET_RETAIN_FOCUS); myMessageBox->clearFlags(WIDGET_RETAIN_FOCUS);
myMessageBox->setColor(kTextColorEm); myMessageBox->setTextColor(kTextColorEm);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.hxx,v 1.87 2007-06-20 16:33:22 stephena Exp $ // $Id: FrameBuffer.hxx,v 1.88 2007-08-06 20:16:51 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_HXX #ifndef FRAMEBUFFER_HXX
@ -74,6 +74,15 @@ enum {
kTextColor, kTextColor,
kTextColorHi, kTextColorHi,
kTextColorEm, kTextColorEm,
kDlgColor,
kListColor,
kBtnColor,
kBtnColorHi,
kBtnFntColor,
kBtnFntColorHi,
kScrollColor,
kScrollColorHi,
kWidColor,
kNumColors kNumColors
}; };
@ -86,7 +95,7 @@ enum {
All GUI elements (ala ScummVM) are drawn here as well. All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.87 2007-06-20 16:33:22 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.88 2007-08-06 20:16:51 stephena Exp $
*/ */
class FrameBuffer class FrameBuffer
{ {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.cxx,v 1.100 2007-07-27 13:49:16 stephena Exp $ // $Id: OSystem.cxx,v 1.101 2007-08-06 20:16:51 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -764,21 +764,64 @@ void OSystem::queryVideoHardware()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* /*
Palette is defined as follows: kColor
kColor
kBGColor kBGColor
kShadowColor kShadowColor
kHiliteColor kHiliteColor
kTextColor kTextColor
kTextColorHi kTextColorHi
kTextColorEm kTextColorEm
Palette is defined as follows:
kColor TODO
kBGColor TODO
kShadowColor Item is disabled
kHiliteColor Highlighted color in debugger data cells
kTextColor Normal text color
kTextColorHi Highlighted text color
kTextColorEm TODO
kDlgColor Dialog background
kListColor File list background
kBtnColor Normal button background
kBtnColorHi Highlighted button background
kBtnFntColor Normal button font color
kBtnFntColorHi Highlighted button font color
kScrollColor Normal scrollbar color
kScrollColorHi Highlighted scrollbar color
kWidColor Border for currently selected widget
*/ */
uInt32 OSystem::ourGUIColors[kNumUIPalettes][kNumColors-256] = { uInt32 OSystem::ourGUIColors[kNumUIPalettes][kNumColors-256] = {
// Normal mode // Normal mode
{ 0x686868, 0x000000, 0x404040, 0xc8c8ff, 0x20a020, 0x00ff00, 0xc80000 }, { 0x686868, // kColor
0x000000, // kBGColor
0x606060, // kShadowColor
0xc8c8ff, // kHiliteColor
0x000000, // kTextColor
0x62a108, // kTextColorHi
0xc80000, // kTextColorEm
0xe69d10, // kDlgColor
0xffffde, // kListColor
0xac3410, // kBtnColor
0xd55941, // kBtnColorHi
0xffffff, // kBtnFntColor
0xffd652, // kBtnFntColorHi
0x000000, // kScrollColor
0x000000, // kScrollColorHi
0xc80000 // kWidColor
},
/* { 0x686868, 0xffe69c, 0x404040, 0xc8c8ff, 0x000000, 0x62a108, 0xc80000 }, */
// GP2X // GP2X
{ 0x686868, 0x000000, 0x404040, 0xc8c8ff, 0x20a020, 0x0000ff, 0xc80000 } { 0x686868, 0x000000, 0x404040, 0xc8c8ff, 0x20a020, 0x0000ff, 0xc80000,
// Others to be added ... 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000,
0x000000, 0x000000 }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: AboutDialog.cxx,v 1.19 2007-07-19 16:21:39 stephena Exp $ // $Id: AboutDialog.cxx,v 1.20 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -54,7 +54,7 @@ AboutDialog::AboutDialog(OSystem* osystem, DialogContainer* parent,
myTitle = new StaticTextWidget(this, font, 5, 5, w - 10, font.getFontHeight(), myTitle = new StaticTextWidget(this, font, 5, 5, w - 10, font.getFontHeight(),
"", kTextAlignCenter); "", kTextAlignCenter);
myTitle->setColor(kTextColorHi); myTitle->setTextColor(kTextColorHi);
for(int i = 0; i < LINES_PER_PAGE; i++) for(int i = 0; i < LINES_PER_PAGE; i++)
{ {
@ -232,7 +232,7 @@ void AboutDialog::displayInfo()
} }
myDesc[i]->setAlign(align); myDesc[i]->setAlign(align);
myDesc[i]->setColor(color); myDesc[i]->setTextColor(color);
myDesc[i]->setLabel(str); myDesc[i]->setLabel(str);
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CheckListWidget.cxx,v 1.14 2007-07-31 15:46:21 stephena Exp $ // $Id: CheckListWidget.cxx,v 1.15 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -61,13 +61,13 @@ void CheckListWidget::setStyle(CheckStyle style)
{ {
_checkList[i]->drawBox(true); _checkList[i]->drawBox(true);
_checkList[i]->setFill(false); _checkList[i]->setFill(false);
_checkList[i]->setColor(kTextColor); _checkList[i]->setTextColor(kTextColor);
} }
else if(style == kSolidFill) else if(style == kSolidFill)
{ {
_checkList[i]->drawBox(false); _checkList[i]->drawBox(false);
_checkList[i]->setFill(true); _checkList[i]->setFill(true);
_checkList[i]->setColor(kTextColorEm); _checkList[i]->setTextColor(kTextColorEm);
} }
} }
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Dialog.cxx,v 1.55 2007-01-24 21:36:38 stephena Exp $ // $Id: Dialog.cxx,v 1.56 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -230,7 +230,7 @@ void Dialog::drawDialog()
// cerr << "Dialog::drawDialog()\n"; // cerr << "Dialog::drawDialog()\n";
FrameBuffer& fb = instance()->frameBuffer(); FrameBuffer& fb = instance()->frameBuffer();
fb.fillRect(_x+1, _y+1, _w-2, _h-2, kBGColor); fb.fillRect(_x+1, _y+1, _w-2, _h-2, kDlgColor);
fb.box(_x, _y, _w, _h, kColor, kShadowColor); fb.box(_x, _y, _w, _h, kColor, kShadowColor);
// Make all child widget dirty // Make all child widget dirty

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EditTextWidget.cxx,v 1.17 2007-01-01 18:04:52 stephena Exp $ // $Id: EditTextWidget.cxx,v 1.18 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -83,7 +83,7 @@ void EditTextWidget::drawWidget(bool hilite)
// Draw the text // Draw the text
adjustOffset(); adjustOffset();
fb.drawString(_font, _editString, _x + 2, _y + 2, getEditRect().width(), fb.drawString(_font, _editString, _x + 2, _y + 2, getEditRect().width(),
_color, kTextAlignLeft, -_editScrollOffset, false); _textcolor, kTextAlignLeft, -_editScrollOffset, false);
// Draw the caret // Draw the caret
drawCaret(); drawCaret();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EditableWidget.cxx,v 1.21 2007-01-01 18:04:52 stephena Exp $ // $Id: EditableWidget.cxx,v 1.22 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -36,6 +36,11 @@ EditableWidget::EditableWidget(GuiObject* boss, const GUI::Font& font,
_caretInverse = false; _caretInverse = false;
_editScrollOffset = 0; _editScrollOffset = 0;
_bgcolor = kListColor;
_bgcolorhi = kListColor;
_textcolor = kTextColor;
_textcolorhi = kTextColor;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventMappingWidget.cxx,v 1.19 2007-01-01 18:04:52 stephena Exp $ // $Id: EventMappingWidget.cxx,v 1.20 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -129,7 +129,7 @@ void EventMappingWidget::startRemapping()
buf << "Select action for '" buf << "Select action for '"
<< instance()->eventHandler().actionAtIndex(myActionSelected, myEventMode) << instance()->eventHandler().actionAtIndex(myActionSelected, myEventMode)
<< "' event"; << "' event";
myKeyMapping->setColor(kTextColorEm); myKeyMapping->setTextColor(kTextColorEm);
myKeyMapping->setLabel(buf.str()); myKeyMapping->setLabel(buf.str());
// Make sure that this widget receives all raw data, before any // Make sure that this widget receives all raw data, before any
@ -183,7 +183,7 @@ void EventMappingWidget::drawKeyMapping()
ostringstream buf; ostringstream buf;
buf << "Action: " buf << "Action: "
<< instance()->eventHandler().keyAtIndex(myActionSelected, myEventMode); << instance()->eventHandler().keyAtIndex(myActionSelected, myEventMode);
myKeyMapping->setColor(kTextColor); myKeyMapping->setTextColor(kTextColor);
myKeyMapping->setLabel(buf.str()); myKeyMapping->setLabel(buf.str());
} }
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: InputTextDialog.cxx,v 1.16 2007-01-01 18:04:53 stephena Exp $ // $Id: InputTextDialog.cxx,v 1.17 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -80,7 +80,7 @@ InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
xpos = 10; xpos = 10;
myTitle = new StaticTextWidget(this, font, xpos, ypos, _w - 2*xpos, fontHeight, myTitle = new StaticTextWidget(this, font, xpos, ypos, _w - 2*xpos, fontHeight,
"", kTextAlignCenter); "", kTextAlignCenter);
myTitle->setColor(kTextColorEm); myTitle->setTextColor(kTextColorEm);
ButtonWidget* b; ButtonWidget* b;
#ifndef MAC_OSX #ifndef MAC_OSX

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: ListWidget.cxx,v 1.47 2007-01-01 18:04:53 stephena Exp $ // $Id: ListWidget.cxx,v 1.48 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -46,6 +46,10 @@ ListWidget::ListWidget(GuiObject* boss, const GUI::Font& font,
{ {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_type = kListWidget; _type = kListWidget;
_bgcolor = kListColor;
_bgcolorhi = kListColor;
_textcolor = kTextColor;
_textcolorhi = kTextColor;
_cols = w / _fontWidth; _cols = w / _fontWidth;
_rows = h / _fontHeight; _rows = h / _fontHeight;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: PopUpWidget.cxx,v 1.33 2007-06-21 12:27:00 stephena Exp $ // $Id: PopUpWidget.cxx,v 1.34 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -86,7 +86,7 @@ void PopUpDialog::drawDialog()
// The last entry may be empty. Fill it with black. // The last entry may be empty. Fill it with black.
if(_twoColumns && (count & 1)) if(_twoColumns && (count & 1))
fb.fillRect(_x + 1 + _w / 2, _y + 1 + _popUpBoss->_fontHeight * (_entriesPerColumn - 1), fb.fillRect(_x + 1 + _w / 2, _y + 1 + _popUpBoss->_fontHeight * (_entriesPerColumn - 1),
_w / 2 - 1, _popUpBoss->_fontHeight, kBGColor); _w / 2 - 1, _popUpBoss->_fontHeight, _popUpBoss->_bgcolor);
_dirty = false; _dirty = false;
fb.addDirtyRect(_x, _y, _w, _h); fb.addDirtyRect(_x, _y, _w, _h);
@ -242,7 +242,7 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite)
} }
else else
fb.drawString(_popUpBoss->font(), name, x + 1, y + 2, w - 2, fb.drawString(_popUpBoss->font(), name, x + 1, y + 2, w - 2,
hilite ? kBGColor : kTextColor); hilite ? _popUpBoss->_textcolorhi : _popUpBoss->_textcolor);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -430,6 +430,10 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
{ {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS; _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_type = kPopUpWidget; _type = kPopUpWidget;
_bgcolor = kDlgColor;
_bgcolorhi = kListColor;
_textcolor = kTextColor;
_textcolorhi = kTextColor;
_selectedItem = -1; _selectedItem = -1;
@ -553,7 +557,7 @@ void PopUpWidget::drawWidget(bool hilite)
// Draw the label, if any // Draw the label, if any
if (_labelWidth > 0) if (_labelWidth > 0)
fb.drawString(_font, _label, _x, _y + myTextY, _labelWidth, fb.drawString(_font, _label, _x, _y + myTextY, _labelWidth,
isEnabled() ? kTextColor : kColor, kTextAlignRight); isEnabled() ? _textcolor : kColor, kTextAlignRight);
// Draw a thin frame around us. // Draw a thin frame around us.
fb.hLine(x, _y, x + w - 1, kColor); fb.hLine(x, _y, x + w - 1, kColor);
@ -561,6 +565,9 @@ void PopUpWidget::drawWidget(bool hilite)
fb.vLine(x, _y, _y+_h-1, kColor); fb.vLine(x, _y, _y+_h-1, kColor);
fb.vLine(x + w - 1, _y, _y +_h - 1, kShadowColor); fb.vLine(x + w - 1, _y, _y +_h - 1, kShadowColor);
// Fill the background
fb.fillRect(x + 1, _y + 1, w - 2, _h - 2, kListColor);
// Draw an arrow pointing down at the right end to signal this is a dropdown/popup // Draw an arrow pointing down at the right end to signal this is a dropdown/popup
fb.drawBitmap(up_down_arrows, x+w - 10, _y + myArrowsY, fb.drawBitmap(up_down_arrows, x+w - 10, _y + myArrowsY,
!isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor); !isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: ProgressDialog.cxx,v 1.8 2007-01-01 18:04:54 stephena Exp $ // $Id: ProgressDialog.cxx,v 1.9 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -53,7 +53,7 @@ ProgressDialog::ProgressDialog(GuiObject* boss, const GUI::Font& font,
xpos = fontWidth; ypos = lineHeight; xpos = fontWidth; ypos = lineHeight;
myMessage = new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight, myMessage = new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight,
message, kTextAlignCenter); message, kTextAlignCenter);
myMessage->setColor(kTextColorEm); myMessage->setTextColor(kTextColorEm);
xpos = fontWidth; ypos += 2 * lineHeight; xpos = fontWidth; ypos += 2 * lineHeight;
mySlider = new SliderWidget(this, font, xpos, ypos, lwidth, lineHeight, "", 0, 0); mySlider = new SliderWidget(this, font, xpos, ypos, lwidth, lineHeight, "", 0, 0);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TabWidget.cxx,v 1.27 2007-01-24 20:48:54 stephena Exp $ // $Id: TabWidget.cxx,v 1.28 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -39,6 +39,10 @@ TabWidget::TabWidget(GuiObject* boss, const GUI::Font& font,
{ {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG; _flags = WIDGET_ENABLED | WIDGET_CLEARBG;
_type = kTabWidget; _type = kTabWidget;
_bgcolor = kDlgColor;
_bgcolorhi = kDlgColor;
_textcolor = kTextColor;
_textcolorhi = kTextColor;
_tabHeight = font.getLineHeight() + 4; _tabHeight = font.getLineHeight() + 4;
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Widget.cxx,v 1.50 2007-07-31 15:46:21 stephena Exp $ // $Id: Widget.cxx,v 1.51 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -41,7 +41,10 @@ Widget::Widget(GuiObject* boss, const GUI::Font& font,
_id(-1), _id(-1),
_flags(0), _flags(0),
_hasFocus(false), _hasFocus(false),
_color(kTextColor) _bgcolor(kBGColor),
_bgcolorhi(kBGColor),
_textcolor(kTextColor),
_textcolorhi(kTextColorHi)
{ {
// Insert into the widget list of the boss // Insert into the widget list of the boss
_next = _boss->_firstWidget; _next = _boss->_firstWidget;
@ -81,7 +84,8 @@ void Widget::draw()
// Clear background (unless alpha blending is enabled) // Clear background (unless alpha blending is enabled)
if(_flags & WIDGET_CLEARBG) if(_flags & WIDGET_CLEARBG)
fb.fillRect(_x, _y, _w, _h, kBGColor); fb.fillRect(_x, _y, _w, _h,
(_flags & WIDGET_HILITED) ? _bgcolorhi : _bgcolor);
// Draw border // Draw border
if(_flags & WIDGET_BORDER) { if(_flags & WIDGET_BORDER) {
@ -239,7 +243,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
if(tmp->_hasFocus) if(tmp->_hasFocus)
{ {
tmp->lostFocus(); tmp->lostFocus();
fb.frameRect(x, y, w, h, kBGColor); fb.frameRect(x, y, w, h, kDlgColor); // FIXME - static issues
tmp->setDirty(); tmp->draw(); tmp->setDirty(); tmp->draw();
fb.addDirtyRect(x, y, w, h); fb.addDirtyRect(x, y, w, h);
@ -278,7 +282,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
w = rect.width(), h = rect.height(); w = rect.width(), h = rect.height();
tmp->receivedFocus(); tmp->receivedFocus();
fb.frameRect(x, y, w, h, kTextColorEm, kDashLine); fb.frameRect(x, y, w, h, kWidColor, kDashLine);
tmp->setDirty(); tmp->draw(); tmp->setDirty(); tmp->draw();
fb.addDirtyRect(x, y, w, h); fb.addDirtyRect(x, y, w, h);
@ -300,11 +304,16 @@ void Widget::setDirtyInChain(Widget* start)
StaticTextWidget::StaticTextWidget(GuiObject *boss, const GUI::Font& font, StaticTextWidget::StaticTextWidget(GuiObject *boss, const GUI::Font& font,
int x, int y, int w, int h, int x, int y, int w, int h,
const string& text, TextAlignment align) const string& text, TextAlignment align)
: Widget(boss, font, x, y, w, h), : Widget(boss, font, x, y, w, h),
_align(align) _align(align)
{ {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG; _flags = WIDGET_ENABLED | WIDGET_CLEARBG;
_type = kStaticTextWidget; _type = kStaticTextWidget;
_bgcolor = kDlgColor;
_bgcolorhi = kDlgColor;
_textcolor = kTextColor;
_textcolorhi = kTextColor;
_label = text; _label = text;
} }
@ -330,7 +339,7 @@ void StaticTextWidget::drawWidget(bool hilite)
{ {
FrameBuffer& fb = _boss->instance()->frameBuffer(); FrameBuffer& fb = _boss->instance()->frameBuffer();
fb.drawString(_font, _label, _x, _y, _w, fb.drawString(_font, _label, _x, _y, _w,
isEnabled() ? _color : kColor, _align); isEnabled() ? _textcolor : kColor, _align);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -344,6 +353,10 @@ ButtonWidget::ButtonWidget(GuiObject *boss, const GUI::Font& font,
{ {
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG; _flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
_type = kButtonWidget; _type = kButtonWidget;
_bgcolor = kBtnColor;
_bgcolorhi = kBtnColorHi;
_textcolor = kBtnFntColor;
_textcolorhi = kBtnFntColorHi;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -392,7 +405,7 @@ void ButtonWidget::drawWidget(bool hilite)
{ {
FrameBuffer& fb = _boss->instance()->frameBuffer(); FrameBuffer& fb = _boss->instance()->frameBuffer();
fb.drawString(_font, _label, _x, _y + (_h - _fontHeight)/2 + 1, _w, fb.drawString(_font, _label, _x, _y + (_h - _fontHeight)/2 + 1, _w,
!isEnabled() ? kColor : hilite ? kTextColorHi : _color, _align); !isEnabled() ? kColor : hilite ? _textcolorhi : _textcolor, _align);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -417,7 +430,6 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, const GUI::Font& font,
_state(false), _state(false),
_editable(true), _editable(true),
_holdFocus(true), _holdFocus(true),
_fillRect(false),
_drawBox(true), _drawBox(true),
_fillColor(kColor), _fillColor(kColor),
_boxY(0), _boxY(0),
@ -425,6 +437,10 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, const GUI::Font& font,
{ {
_flags = WIDGET_ENABLED; _flags = WIDGET_ENABLED;
_type = kCheckboxWidget; _type = kCheckboxWidget;
_bgcolor = kListColor;
_bgcolorhi = kBtnColorHi;
_textcolor = kBtnFntColor;
_textcolorhi = kBtnFntColorHi;
if(label == "") if(label == "")
_w = 14; _w = 14;
@ -479,22 +495,16 @@ void CheckboxWidget::drawWidget(bool hilite)
if(_drawBox) if(_drawBox)
fb.box(_x, _y + _boxY, 14, 14, kColor, kShadowColor); fb.box(_x, _y + _boxY, 14, 14, kColor, kShadowColor);
// If checked, draw cross inside the box // Do we draw a square or cross?
if(_state) int checked = !isEnabled() ? kColor : _state ? _bgcolorhi : _bgcolor;
{ fb.fillRect(_x + 2, _y + _boxY + 2, 10, 10, checked);
if(_fillRect)
fb.fillRect(_x + 2, _y + _boxY + 2, 10, 10, if(!_fillRect && isEnabled() && _state) // draw a cross
isEnabled() ? _color : kColor); fb.drawBitmap(checked_img, _x + 3, _y + _boxY + 3, _textcolor);
else
fb.drawBitmap(checked_img, _x + 3, _y + _boxY + 3,
isEnabled() ? _color : kColor);
}
else
fb.fillRect(_x + 2, _y + _boxY + 2, 10, 10, kBGColor);
// Finally draw the label // Finally draw the label
fb.drawString(_font, _label, _x + 20, _y + _textY, _w, fb.drawString(_font, _label, _x + 20, _y + _textY, _w,
isEnabled() ? _color : kColor); isEnabled() ? kTextColor : kColor);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -511,6 +521,10 @@ SliderWidget::SliderWidget(GuiObject *boss, const GUI::Font& font,
{ {
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG; _flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
_type = kSliderWidget; _type = kSliderWidget;
_bgcolor = kDlgColor;
_bgcolorhi = kDlgColor;
_textcolor = kBtnColor;
_textcolorhi = kBtnColorHi;
if(!_label.empty() && _labelWidth == 0) if(!_label.empty() && _labelWidth == 0)
_labelWidth = _font->getStringWidth(_label); _labelWidth = _font->getStringWidth(_label);
@ -625,7 +639,7 @@ void SliderWidget::drawWidget(bool hilite)
// Draw the label, if any // Draw the label, if any
if(_labelWidth > 0) if(_labelWidth > 0)
fb.drawString(_font, _label, _x, _y + 2, _labelWidth, fb.drawString(_font, _label, _x, _y + 2, _labelWidth,
isEnabled() ? _color : kColor, kTextAlignRight); isEnabled() ? kTextColor : kColor, kTextAlignRight);
// Draw the box // Draw the box
fb.box(_x + _labelWidth, _y, _w - _labelWidth, _h, kColor, kShadowColor); fb.box(_x + _labelWidth, _y, _w - _labelWidth, _h, kColor, kShadowColor);
@ -633,7 +647,7 @@ void SliderWidget::drawWidget(bool hilite)
// Draw the 'bar' // Draw the 'bar'
fb.fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4, fb.fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4,
!isEnabled() ? kColor : !isEnabled() ? kColor :
hilite ? kTextColorHi : _color); hilite ? _textcolorhi : _textcolor);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Widget.hxx,v 1.54 2007-06-20 16:33:23 stephena Exp $ // $Id: Widget.hxx,v 1.55 2007-08-06 20:16:51 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -88,7 +88,7 @@ enum {
This is the base class for all widgets. This is the base class for all widgets.
@author Stephen Anthony @author Stephen Anthony
@version $Id: Widget.hxx,v 1.54 2007-06-20 16:33:23 stephena Exp $ @version $Id: Widget.hxx,v 1.55 2007-08-06 20:16:51 stephena Exp $
*/ */
class Widget : public GuiObject class Widget : public GuiObject
{ {
@ -138,9 +138,13 @@ class Widget : public GuiObject
void setID(int id) { _id = id; } void setID(int id) { _id = id; }
int getID() { return _id; } int getID() { return _id; }
void setColor(int color) { _color = color; }
virtual const GUI::Font* font() { return _font; } virtual const GUI::Font* font() { return _font; }
void setTextColor(int color) { _textcolor = color; }
void setTextColorHi(int color) { _textcolorhi = color; }
void setBGColor(int color) { _bgcolor = color; }
void setBGColorHi(int color) { _bgcolorhi = color; }
virtual void loadConfig() {} virtual void loadConfig() {}
protected: protected:
@ -165,9 +169,12 @@ class Widget : public GuiObject
int _id; int _id;
int _flags; int _flags;
bool _hasFocus; bool _hasFocus;
int _color;
int _fontWidth; int _fontWidth;
int _fontHeight; int _fontHeight;
int _bgcolor;
int _bgcolorhi;
int _textcolor;
int _textcolorhi;
public: public:
static Widget* findWidgetInChain(Widget* start, int x, int y); static Widget* findWidgetInChain(Widget* start, int x, int y);