More palette fixes for the debugger (PromptWidget & DataGridWidget).

Fixed DebuggerParser::red() method so it always uses the same color,
regardless of NTSC/PAL/SECAM format.

Added Home/End/PgUp/PgDn navigation to TiaZoomWidget.

Added a 'Defaults' button to FileSnapDialog.

Made configurable the number of lines a mouse scrollwheel will move the
scrollbar.  This can be set by the '-mwheel' commandline argument, as well
as in UIDialog.

Removed some dead code in several debugger classes.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1347 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2007-08-15 17:43:51 +00:00
parent aceb1d1513
commit 037d675f60
24 changed files with 220 additions and 179 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Debugger.cxx,v 1.113 2007-08-14 19:49:20 stephena Exp $
// $Id: Debugger.cxx,v 1.114 2007-08-15 17:43:51 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -389,10 +389,11 @@ const string Debugger::valueToString(int value, BaseFormat outputBase)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::invIfChanged(int reg, int oldReg) {
const string Debugger::invIfChanged(int reg, int oldReg)
{
string ret;
bool changed = !(reg == oldReg);
bool changed = reg != oldReg;
if(changed) ret += "\177";
ret += valueToString(reg);
if(changed) ret += "\177";
@ -1038,12 +1039,6 @@ GUI::Rect Debugger::getTabBounds() const
return r;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::resizeDialog()
{
// cerr << "Debugger::resizeDialog()\n";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::addFunction(string name, string definition, Expression *exp, bool builtin) {
functions.insert(make_pair(name, exp));

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Debugger.hxx,v 1.89 2007-08-14 19:49:20 stephena Exp $
// $Id: Debugger.hxx,v 1.90 2007-08-15 17:43:51 stephena Exp $
//============================================================================
#ifndef DEBUGGER_HXX
@ -69,7 +69,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)();
for all debugging operations in Stella (parser, 6502 debugger, etc).
@author Stephen Anthony
@version $Id: Debugger.hxx,v 1.89 2007-08-14 19:49:20 stephena Exp $
@version $Id: Debugger.hxx,v 1.90 2007-08-15 17:43:51 stephena Exp $
*/
class Debugger : public DialogContainer
{
@ -301,12 +301,6 @@ class Debugger : public DialogContainer
*/
void setQuitState();
/**
Resize the debugger dialog based on the current dimensions from
getDialogBounds.
*/
void resizeDialog();
int step();
int trace();
void nextScanline(int lines);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerParser.cxx,v 1.99 2007-08-14 20:36:18 stephena Exp $
// $Id: DebuggerParser.cxx,v 1.100 2007-08-15 17:43:51 stephena Exp $
//============================================================================
#include <fstream>
@ -1357,27 +1357,6 @@ void DebuggerParser::executeZ()
debugger->cpuDebug().setZ(args[0]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "change resolution"
void DebuggerParser::executeResolution()
{
commandResult = "TODO - add functionality";
/*
int height = debugger->setHeight(args[0]);
commandResult = "height set to " + debugger->valueToString(height, kBASE_10) +
"\nExit debugger and reload ROM to take effect";
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// .hxx
// Table of RGB values for NTSC
// static const uInt32 ourNTSCPalette[256];
// .cxx
// const uInt32 Console::ourNTSCPalette[256] = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// List of all commands available to the parser
@ -1902,14 +1881,5 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
true,
{ kARG_BOOL, kARG_END_ARGS },
&DebuggerParser::executeZ
},
{
"resolution",
"Change resolution of debugger window",
true,
false,
{ kARG_WORD, kARG_END_ARGS },
&DebuggerParser::executeResolution
}
};

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerParser.hxx,v 1.49 2007-08-10 18:27:11 stephena Exp $
// $Id: DebuggerParser.hxx,v 1.50 2007-08-15 17:43:51 stephena Exp $
//============================================================================
#ifndef DEBUGGER_PARSER_HXX
@ -24,6 +24,7 @@ struct Command;
#include "bspf.hxx"
#include "Array.hxx"
#include "FrameBuffer.hxx"
typedef enum {
kBASE_16,
@ -63,8 +64,7 @@ class DebuggerParser
static inline string red(const string& msg = "")
{
// This is TIA color 0x34. The octal value is 0x80+(0x34>>1).
return "\232" + msg;
return char(kDbgChangedColor) + msg;
}
static inline string inverse(const string& msg = "")
{
@ -81,7 +81,7 @@ class DebuggerParser
private:
enum {
kNumCommands = 59,
kNumCommands = 58,
kMAX_ARG_TYPES = 10 // TODO: put in separate header file Command.hxx
};
@ -193,7 +193,6 @@ class DebuggerParser
void executeX();
void executeY();
void executeZ();
void executeResolution();
// List of commands available
static Command commands[kNumCommands];

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DataGridWidget.cxx,v 1.11 2007-07-31 15:46:20 stephena Exp $
// $Id: DataGridWidget.cxx,v 1.12 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -524,15 +524,15 @@ void DataGridWidget::drawWidget(bool hilite)
int color = kTextColor;
if(_changedList[pos])
{
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kTextColorEm);
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor);
if(_hiliteList[pos])
color = kHiliteColor;
color = kDbgColorHi;
else
color = kTextColorHi;
color = kDbgChangedTextColor;
}
else if(_hiliteList[pos])
color = kHiliteColor;
color = kDbgColorHi;
fb.drawString(_font, buffer, x, y, _colWidth, color);
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PromptWidget.cxx,v 1.20 2007-08-14 20:36:18 stephena Exp $
// $Id: PromptWidget.cxx,v 1.21 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -55,6 +55,7 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font,
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_WANTS_TAB | WIDGET_WANTS_RAWDATA;
_type = kPromptWidget;
_textcolor = kTextColor;
_bgcolor = kWidColor;
_kConsoleCharWidth = font.getMaxCharWidth();
@ -77,10 +78,6 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font,
_scrollBar->setTarget(this);
// Init colors
defaultTextColor = kTextColor;
defaultBGColor = kBGColor;
textColor = defaultTextColor;
bgColor = defaultBGColor;
_inverse = false;
// Init History
@ -119,12 +116,11 @@ void PromptWidget::drawWidget(bool hilite)
int c = buffer((start + line) * _lineWidth + column);
if(c & (1 << 17)) { // inverse video flag
fgcolor = bgColor;
fgcolor = _bgcolor;
bgcolor = (c & 0x1ffff) >> 8;
fb.fillRect(x, y, _kConsoleCharWidth, _kConsoleCharHeight, bgcolor);
} else {
fgcolor = c >> 8;
bgcolor = bgColor;
}
fb.drawChar(&instance()->consoleFont(), c & 0x7f, x, y, fgcolor);
x += _kConsoleCharWidth;
@ -526,6 +522,7 @@ void PromptWidget::loadConfig()
_promptStartPos = _promptEndPos = _currentPos;
_firstTime = false;
_exitedEarly = false;
// Take care of one-time debugger stuff
instance()->debugger().autoExec();
@ -730,9 +727,8 @@ void PromptWidget::historyScroll(int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::nextLine()
{
// reset colors every line, so I don't have to remember to do it myself
textColor = defaultTextColor;
bgColor = defaultBGColor;
// Reset colors every line, so I don't have to remember to do it myself
_textcolor = kTextColor;
_inverse = false;
int line = _currentPos / _lineWidth;
@ -807,17 +803,17 @@ void PromptWidget::putcharIntern(int c)
// don't print or advance cursor
// there are only 128 TIA colors, but
// OverlayColor contains 256 of them
textColor = (c & 0x7f) << 1;
_textcolor = (c & 0x7f) << 1;
}
else if(c < ' ') { // More colors (the regular GUI ones)
textColor = c + 0x100;
_textcolor = c + 0x100;
}
else if(c == 0x7f) { // toggle inverse video (DEL char)
_inverse = !_inverse;
}
else
{
buffer(_currentPos) = c | (textColor << 8) | (_inverse << 17);
buffer(_currentPos) = c | (_textcolor << 8) | (_inverse << 17);
_currentPos++;
if ((_scrollLine + 1) * _lineWidth == _currentPos)
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PromptWidget.hxx,v 1.11 2007-08-14 20:36:18 stephena Exp $
// $Id: PromptWidget.hxx,v 1.12 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -107,10 +107,6 @@ class PromptWidget : public Widget, public CommandSender
int _kConsoleCharWidth, _kConsoleCharHeight, _kConsoleLineHeight;
int defaultTextColor;
int defaultBGColor;
int textColor;
int bgColor;
bool _inverse;
bool _makeDirty;
bool _firstTime;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: RomListWidget.cxx,v 1.9 2007-01-01 18:04:44 stephena Exp $
// $Id: RomListWidget.cxx,v 1.10 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -112,8 +112,7 @@ void RomListWidget::drawWidget(bool hilite)
if (_highlightedItem == pos)
{
fb.frameRect(_x + l.left - 3, _y + 1 + _fontHeight * i,
_w - l.left, _fontHeight,
kHiliteColor);
_w - l.left, _fontHeight, kDbgColorHi);
}
// Draw the selected item inverted, on a highlighted background.

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TiaZoomWidget.cxx,v 1.12 2007-08-14 19:49:20 stephena Exp $
// $Id: TiaZoomWidget.cxx,v 1.13 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -34,8 +34,7 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font,
CommandSender(boss),
myMenu(NULL)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_WANTS_RAWDATA;
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_type = kTiaZoomWidget;
_bgcolor = _bgcolorhi = kDlgColor;
@ -147,30 +146,46 @@ void TiaZoomWidget::handleMouseDown(int x, int y, int button, int clickCount)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TiaZoomWidget::handleKeyDown(int ascii, int keycode, int modifiers)
bool TiaZoomWidget::handleEvent(Event::Type event)
{
bool handled = false;
bool handled = true;
switch(ascii)
switch(event)
{
case 256+17: // up arrow
case Event::UIUp:
myYCenter -= 4;
handled = true;
break;
case 256+18: // down arrow
case Event::UIDown:
myYCenter += 4;
handled = true;
break;
case 256+20: // left arrow
case Event::UILeft:
myXCenter -= 2;
handled = true;
break;
case 256+19: // right arrow
case Event::UIRight:
myXCenter += 2;
handled = true;
break;
case Event::UIPgUp:
myYCenter = 0;
break;
case Event::UIPgDown:
myYCenter = 260;
break;
case Event::UIHome:
myXCenter = 0;
break;
case Event::UIEnd:
myXCenter = 320;
break;
default:
handled = false;
break;
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TiaZoomWidget.hxx,v 1.7 2007-08-14 19:49:21 stephena Exp $
// $Id: TiaZoomWidget.hxx,v 1.8 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -41,7 +41,7 @@ class TiaZoomWidget : public Widget, public CommandSender
protected:
void handleMouseDown(int x, int y, int button, int clickCount);
bool handleKeyDown(int ascii, int keycode, int modifiers);
bool handleEvent(Event::Type event);
void handleCommand(CommandSender* sender, int cmd, int data, int id);
void drawWidget(bool hilite);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ToggleBitWidget.cxx,v 1.6 2007-01-01 18:04:44 stephena Exp $
// $Id: ToggleBitWidget.cxx,v 1.7 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -107,8 +107,8 @@ void ToggleBitWidget::drawWidget(bool hilite)
// Highlight changes
if(_changedList[pos])
{
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kTextColorEm);
fb.drawString(_font, buffer, x, y, _colWidth, kTextColorHi);
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor);
fb.drawString(_font, buffer, x, y, _colWidth, kDbgChangedTextColor);
}
else
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBuffer.hxx,v 1.89 2007-08-12 23:05:12 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.90 2007-08-15 17:43:51 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -70,12 +70,12 @@ enum {
kColor = 256,
kBGColor,
kShadowColor,
kHiliteColor,
kTextColor,
kTextColorHi,
kTextColorEm,
kDlgColor,
kWidColor,
kWidFrameColor,
kBtnColor,
kBtnColorHi,
kBtnTextColor,
@ -85,7 +85,9 @@ enum {
kScrollColorHi,
kSliderColor,
kSliderColorHi,
kWidFrameColor,
kDbgChangedColor,
kDbgChangedTextColor,
kDbgColorHi,
kNumColors
};
@ -98,7 +100,7 @@ enum {
All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.89 2007-08-12 23:05:12 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.90 2007-08-15 17:43:51 stephena Exp $
*/
class FrameBuffer
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OSystem.cxx,v 1.105 2007-08-12 23:05:12 stephena Exp $
// $Id: OSystem.cxx,v 1.106 2007-08-15 17:43:51 stephena Exp $
//============================================================================
#include <cassert>
@ -46,6 +46,7 @@
#include "bspf.hxx"
#include "OSystem.hxx"
#include "Widget.hxx"
#include "ScrollBarWidget.hxx"
#define MAX_ROM_SIZE 512 * 1024
@ -183,6 +184,9 @@ bool OSystem::create()
myDebugger = new Debugger(this);
#endif
// Set number of lines a mousewheel will scroll
ScrollBarWidget::setWheelLines(mySettings->getInt("mwheel"));
// Create the sound object; the sound subsystem isn't actually
// opened until needed, so this is non-blocking (on those systems
// that only have a single sound device (no hardware mixing)
@ -769,54 +773,57 @@ void OSystem::queryVideoHardware()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*
Palette is defined as follows:
// Base colors
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
// UI elements (dialog and widgets)
kDlgColor Dialog background
kWidColor Widget background
kWidFrameColor Border for currently selected widget
// Button colors
kBtnColor Normal button background
kBtnColorHi Highlighted button background
kBtnTextColor Normal button font color
kBtnTextColorHi Highlighted button font color
// Checkbox colors
kCheckColor Color of 'X' in checkbox
// Scrollbar colors
kScrollColor Normal scrollbar color
kScrollColorHi Highlighted scrollbar color
kWidFrameColor Border for currently selected widget
// Debugger colors
kDbgChangedColor Background color for changed cells
kDbgChangedTextColor Text color for changed cells
kDbgColorHi Highlighted color in debugger data cells
*/
uInt32 OSystem::ourGUIColors[kNumUIPalettes][kNumColors-256] = {
// Standard
{ 0x686868, // kColor
0x000000, // kBGColor
0x404040, // kShadowColor
0xc8c8ff, // kHiliteColor
0x000000, // kTextColor
0x62a108, // kTextColorHi
0xc80000, // kTextColorEm
0xc9af7c, // kDlgColor
0xf0f0cf, // kWidColor
0xac3410, // kBtnColor
0xd55941, // kBtnColorHi
0xffffff, // kBtnTextColor
0xffd652, // kBtnTextColorHi
0xac3410, // kCheckColor
0xac3410, // kScrollColor
0xd55941, // kScrollColorHi
0xac3410, // kSliderColor
0xd55941, // kSliderColorHi
0xc80000 // kWidFrameColor
{ 0x686868, 0x000000, 0x404040, 0x000000, 0x62a108, 0x9f0000,
0xc9af7c, 0xf0f0cf, 0xc80000,
0xac3410, 0xd55941, 0xffffff, 0xffd652,
0xac3410,
0xac3410, 0xd55941,
0xac3410, 0xd55941,
0xc80000, 0x00ff00, 0xc8c8ff
},
// Classic
{ 0x686868, 0x000000, 0x404040, 0xc8c8ff, 0x20a020, 0x00ff00, 0xc80000,
0x000000, 0x000000, 0x000000, 0x000000, 0x20a020, 0x00ff00, 0x20a020,
0x20a020, 0x00ff00, 0x20a020, 0x00ff00, 0xc80000 }
{ 0x686868, 0x000000, 0x404040, 0x20a020, 0x00ff00, 0xc80000,
0x000000, 0x000000, 0xc80000,
0x000000, 0x000000, 0x20a020, 0x00ff00,
0x20a020,
0x20a020, 0x00ff00,
0x20a020, 0x00ff00,
0xc80000, 0x00ff00, 0xc8c8ff
}
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Settings.cxx,v 1.122 2007-08-10 18:27:11 stephena Exp $
// $Id: Settings.cxx,v 1.123 2007-08-15 17:43:51 stephena Exp $
//============================================================================
#include <cassert>
@ -84,6 +84,7 @@ Settings::Settings(OSystem* osystem)
setInternal("debuggerres", "1030x690");
setInternal("launcherres", "400x300");
setInternal("uipalette", "0");
setInternal("mwheel", "4");
setInternal("autoslot", "false");
}
@ -307,6 +308,7 @@ void Settings::usage()
<< " -rominfo <rom> Display detailed information for the given ROM\n"
<< " -launcherres <WxH> The resolution to use in ROM launcher mode\n"
<< " -uipalette <1|2> Used the specified palette for UI elements\n"
<< " -mwheel <lines> Number of lines the mouse wheel will scroll in UI\n"
<< " -statedir <dir> Directory in which to save state files\n"
<< " -cheatfile <file> Full pathname of cheatfile database\n"
<< " -palettefile <file> Full pathname of user-defined palette file\n"

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: AboutDialog.cxx,v 1.20 2007-08-06 20:16:51 stephena Exp $
// $Id: AboutDialog.cxx,v 1.21 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// 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(),
"", kTextAlignCenter);
myTitle->setTextColor(kTextColorHi);
myTitle->setTextColor(kTextColorEm);
for(int i = 0; i < LINES_PER_PAGE; i++)
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FileSnapDialog.cxx,v 1.10 2007-08-07 14:38:51 stephena Exp $
// $Id: FileSnapDialog.cxx,v 1.11 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -120,11 +120,9 @@ FileSnapDialog::FileSnapDialog(
"Multiple snapshots");
wid.push_back(mySnapSingleCheckbox);
// Add focus widgets for Snapshot tab
addToFocusList(wid);
// Add OK & Cancel buttons
wid.clear();
b = addButton(font, 10, _h - 24, "Defaults", kDefaultsCmd);
wid.push_back(b);
#ifndef MAC_OSX
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd);
wid.push_back(b);
@ -140,7 +138,8 @@ FileSnapDialog::FileSnapDialog(
wid.push_back(b);
addOKWidget(b);
#endif
addBGroupToFocusList(wid);
addToFocusList(wid);
// Create file browser dialog
myBrowser = new BrowserDialog(this, font, 60, 20, 200, 200);
@ -182,6 +181,26 @@ void FileSnapDialog::saveConfig()
instance()->setConfigPaths();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::setDefaults()
{
const string& basedir = instance()->baseDir();
const string& romdir = "roms";
const string& statedir = basedir + BSPF_PATH_SEPARATOR + "state";
const string& cheatfile = basedir + BSPF_PATH_SEPARATOR + "stella.cht";
const string& palettefile = basedir + BSPF_PATH_SEPARATOR + "stella.pal";
const string& propsfile = basedir + BSPF_PATH_SEPARATOR + "stella.pro";
myRomPath->setEditString(romdir);
myStatePath->setEditString(statedir);
myCheatFile->setEditString(cheatfile);
myPaletteFile->setEditString(palettefile);
myPropsFile->setEditString(propsfile);
mySnapPath->setEditString(string(".") + BSPF_PATH_SEPARATOR);
mySnapSingleCheckbox->setState(true);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::openBrowser(const string& title, const string& startpath,
FilesystemNode::ListMode mode, int cmd)
@ -206,6 +225,10 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
sendCommand(kRomDirChosenCmd, 0, 0); // Let the boss know romdir has changed
break;
case kDefaultsCmd:
setDefaults();
break;
case kChooseRomDirCmd:
openBrowser("Select ROM directory:", myRomPath->getEditString(),
FilesystemNode::kListDirectoriesOnly, kRomDirChosenCmd);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FileSnapDialog.hxx,v 1.6 2007-08-07 14:38:51 stephena Exp $
// $Id: FileSnapDialog.hxx,v 1.7 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -42,12 +42,13 @@ class FileSnapDialog : public Dialog, public CommandSender
int x, int y, int w, int h);
~FileSnapDialog();
virtual void loadConfig();
virtual void saveConfig();
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
void handleCommand(CommandSender* sender, int cmd, int data, int id);
private:
void loadConfig();
void saveConfig();
void setDefaults();
void openBrowser(const string& title, const string& startpath,
FilesystemNode::ListMode mode, int cmd);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OptionsDialog.cxx,v 1.56 2007-08-10 18:27:11 stephena Exp $
// $Id: OptionsDialog.cxx,v 1.57 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -123,7 +123,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
#endif
myInputDialog = new InputDialog(myOSystem, parent, font, x, y, w, h);
w = 200; h = 135;
w = 200; h = 155;
myUIDialog = new UIDialog(myOSystem, parent, font, x, y, w, h);
w = 280; h = 170;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ScrollBarWidget.cxx,v 1.19 2007-08-13 19:45:42 stephena Exp $
// $Id: ScrollBarWidget.cxx,v 1.20 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -27,16 +27,12 @@
/*
* TODO:
* - Auto-repeat: if user clicks & holds on one of the arrows, then after a
* brief delay, it should start to contiously scroll
* - Allow for a horizontal scrollbar, too?
* - If there are less items than fit on one pages, no scrolling can be done
* and we thus should not highlight the arrows/slider.
* - Allow the mouse wheel to scroll more than one line at a time
*/
#define UP_DOWN_BOX_HEIGHT 10
#define WHEEL_LINES 4
// Up arrow
static unsigned int up_arrow[8] = {
@ -140,9 +136,9 @@ void ScrollBarWidget::handleMouseWheel(int x, int y, int direction)
return;
if(direction < 0)
_currentPos -= WHEEL_LINES;
_currentPos -= _WHEEL_LINES;
else
_currentPos += WHEEL_LINES;
_currentPos += _WHEEL_LINES;
// Make sure that _currentPos is still inside the bounds
checkBounds(old_pos);
@ -284,3 +280,7 @@ void ScrollBarWidget::drawWidget(bool hilite)
fb.hLine(_x + 2, y + 2, _x + _w - 3, kWidColor);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ScrollBarWidget::_WHEEL_LINES = 4;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: ScrollBarWidget.hxx,v 1.8 2007-01-01 18:04:54 stephena Exp $
// $Id: ScrollBarWidget.hxx,v 1.9 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -31,14 +31,6 @@
class ScrollBarWidget : public Widget, public CommandSender
{
protected:
typedef enum {
kNoPart,
kUpArrowPart,
kDownArrowPart,
kSliderPart,
kPageUpPart,
kPageDownPart
} Part;
public:
ScrollBarWidget(GuiObject* boss, const GUI::Font& font,
@ -56,21 +48,34 @@ class ScrollBarWidget : public Widget, public CommandSender
// should these accessors force a redraw?
void recalc();
static void setWheelLines(int lines) { _WHEEL_LINES = lines; }
private:
void drawWidget(bool hilite);
void checkBounds(int old_pos);
public:
int _numEntries;
int _entriesPerPage;
int _currentPos;
protected:
void drawWidget(bool hilite);
void checkBounds(int old_pos);
private:
typedef enum {
kNoPart,
kUpArrowPart,
kDownArrowPart,
kSliderPart,
kPageUpPart,
kPageDownPart
} Part;
protected:
Part _part;
Part _draggingPart;
int _sliderHeight;
int _sliderPos;
Part _draggingPart;
int _sliderDeltaMouseDownPos;
static int _WHEEL_LINES;
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TabWidget.cxx,v 1.28 2007-08-06 20:16:51 stephena Exp $
// $Id: TabWidget.cxx,v 1.29 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -273,7 +273,6 @@ void TabWidget::box(int x, int y, int width, int height,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::drawWidget(bool hilite)
{
//cerr << "TabWidget::drawWidget\n";
// The tab widget is strange in that it acts as both a widget (obviously)
// and a dialog (it contains other widgets). Because of the latter,
// it must assume responsibility for refreshing all its children.

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: UIDialog.cxx,v 1.6 2007-08-10 18:27:12 stephena Exp $
// $Id: UIDialog.cxx,v 1.7 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -28,6 +28,7 @@
#include "Dialog.hxx"
#include "UIDialog.hxx"
#include "GuiUtils.hxx"
#include "ScrollBarWidget.hxx"
#include "bspf.hxx"
@ -103,7 +104,23 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
myDebuggerHeightLabel->setFlags(WIDGET_CLEARBG);
ypos += lineHeight + 4;
// Number of lines a mouse wheel will scroll
myWheelLinesSlider = new SliderWidget(this, font, xpos, ypos, pwidth,
lineHeight, "Mouse wheel scroll: ",
lwidth, kWLinesChanged);
myWheelLinesSlider->setMinValue(1);
myWheelLinesSlider->setMaxValue(10);
myWheelLinesSlider->setStepValue(1);
wid.push_back(myWheelLinesSlider);
myWheelLinesLabel =
new StaticTextWidget(this, font,
xpos + myWheelLinesSlider->getWidth() + 4,
ypos + 1, 20, fontHeight, "", kTextAlignLeft);
myWheelLinesLabel->setFlags(WIDGET_CLEARBG);
ypos += lineHeight + 4;
// UI Palette
ypos += 1;
myPalettePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
"Interface Palette: ", lwidth);
myPalettePopup->appendEntry("Standard", 1);
@ -185,10 +202,15 @@ void UIDialog::loadConfig()
myDebuggerHeightSlider->setValue(h);
myDebuggerHeightLabel->setValue(h);
// Mouse wheel lines
int mw = instance()->settings().getInt("mwheel");
if(mw < 1 || mw > 10) mw = 1;
myWheelLinesSlider->setValue(mw);
myWheelLinesLabel->setValue(mw);
// UI palette
int i = instance()->settings().getInt("uipalette");
if(i < 1 || i > 2)
i = 1;
if(i < 1 || i > 2) i = 1;
myPalettePopup->setSelectedTag(i);
}
@ -203,6 +225,11 @@ void UIDialog::saveConfig()
instance()->settings().setSize("debuggerres",
myDebuggerWidthSlider->getValue(), myDebuggerHeightSlider->getValue());
// Mouse wheel lines
int mw = myWheelLinesSlider->getValue();
instance()->settings().setInt("mwheel", mw);
ScrollBarWidget::setWheelLines(mw);
// UI palette
instance()->settings().setInt("uipalette",
myPalettePopup->getSelectedTag());
@ -223,6 +250,9 @@ void UIDialog::setDefaults()
myDebuggerHeightSlider->setValue(690);
myDebuggerHeightLabel->setValue(690);
myWheelLinesSlider->setValue(4);
myWheelLinesLabel->setValue(4);
myPalettePopup->setSelectedTag(1);
_dirty = true;
@ -249,6 +279,10 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
myDebuggerHeightLabel->setValue(myDebuggerHeightSlider->getValue());
break;
case kWLinesChanged:
myWheelLinesLabel->setValue(myWheelLinesSlider->getValue());
break;
case kOKCmd:
saveConfig();
close();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: UIDialog.hxx,v 1.4 2007-08-10 18:27:12 stephena Exp $
// $Id: UIDialog.hxx,v 1.5 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -50,6 +50,9 @@ class UIDialog : public Dialog
SliderWidget* myDebuggerHeightSlider;
StaticTextWidget* myDebuggerHeightLabel;
SliderWidget* myWheelLinesSlider;
StaticTextWidget* myWheelLinesLabel;
PopUpWidget* myPalettePopup;
private:
@ -63,7 +66,8 @@ class UIDialog : public Dialog
kLWidthChanged = 'UIlw',
kLHeightChanged = 'UIlh',
kDWidthChanged = 'UIdw',
kDHeightChanged = 'UIdh'
kDHeightChanged = 'UIdh',
kWLinesChanged = 'UIsl'
};
};

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Widget.cxx,v 1.54 2007-08-12 23:05:12 stephena Exp $
// $Id: Widget.cxx,v 1.55 2007-08-15 17:43:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -246,7 +246,7 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
if(tmp->_hasFocus)
{
tmp->lostFocus();
fb.frameRect(x, y, w, h, kDlgColor); // FIXME - static issues
fb.frameRect(x, y, w, h, kDlgColor);
tmp->setDirty(); tmp->draw();
fb.addDirtyRect(x, y, w, h);