Yet more in-game GUI changes. It's getting close to compiling, but no

idea on if it will actually work :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@379 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-03-11 23:36:30 +00:00
parent 4e129001cd
commit bed46fe840
9 changed files with 449 additions and 779 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: FrameBuffer.cxx,v 1.18 2005-03-10 22:59:40 stephena Exp $ // $Id: FrameBuffer.cxx,v 1.19 2005-03-11 23:36:30 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -218,7 +218,7 @@ void FrameBuffer::update()
uInt32 y = myHeight - height - LINEOFFSET/2; uInt32 y = myHeight - height - LINEOFFSET/2;
// Draw the bounded box and text // Draw the bounded box and text
drawBoundedBox(x, y+1, width, height-2); box(x, y+1, width, height-2, 0, 0); // FIXME
drawText(x + XBOXOFFSET/2, LINEOFFSET/2 + y, myMessageText); drawText(x + XBOXOFFSET/2, LINEOFFSET/2 + y, myMessageText);
myMessageTime--; myMessageTime--;
@ -320,7 +320,7 @@ inline void FrameBuffer::drawMainMenu()
// Draw the bounded box and text, leaving a little room for arrows // Draw the bounded box and text, leaving a little room for arrows
xpos = x + XBOXOFFSET; xpos = x + XBOXOFFSET;
drawBoundedBox(x-2, y-2, width+3, height+3); box(x-2, y-2, width+3, height+3, 0, 0); //FIXME
for(i = 0; i < myMainMenuItems; i++) for(i = 0; i < myMainMenuItems; i++)
drawText(xpos, LINEOFFSET*i + y + YBOXOFFSET, ourMainMenu[i].action); drawText(xpos, LINEOFFSET*i + y + YBOXOFFSET, ourMainMenu[i].action);
@ -341,7 +341,7 @@ inline void FrameBuffer::drawRemapMenu()
y = (myHeight >> 1) - (height >> 1); y = (myHeight >> 1) - (height >> 1);
// Draw the bounded box and text, leaving a little room for arrows // Draw the bounded box and text, leaving a little room for arrows
drawBoundedBox(x-2, y-2, width+3, height+3); box(x-2, y-2, width+3, height+3, 0, 0); //FIXME
for(Int32 i = myRemapMenuLowIndex; i < myRemapMenuHighIndex; i++) for(Int32 i = myRemapMenuLowIndex; i < myRemapMenuHighIndex; i++)
{ {
ypos = LINEOFFSET*(i-myRemapMenuLowIndex) + y + YBOXOFFSET; ypos = LINEOFFSET*(i-myRemapMenuLowIndex) + y + YBOXOFFSET;
@ -392,7 +392,7 @@ inline void FrameBuffer::drawInfoMenu()
// Draw the bounded box and text // Draw the bounded box and text
xpos = x + XBOXOFFSET; xpos = x + XBOXOFFSET;
drawBoundedBox(x, y, width, height); box(x, y, width, height, 0, 0); //FIXME
for(i = 0; i < 9; i++) for(i = 0; i < 9; i++)
drawText(xpos, LINEOFFSET*i + y + YBOXOFFSET, ourPropertiesInfo[i]); drawText(xpos, LINEOFFSET*i + y + YBOXOFFSET, ourPropertiesInfo[i]);
} }
@ -1117,3 +1117,18 @@ void FrameBuffer::setWindowIcon()
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
#endif #endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor colorA, OverlayColor colorB)
{
hLine(x + 1, y, x + w - 2, colorA);
hLine(x, y + 1, x + w - 1, colorA);
vLine(x, y + 1, y + h - 2, colorA);
vLine(x + 1, y, y + h - 1, colorA);
hLine(x + 1, y + h - 2, x + w - 1, colorB);
hLine(x + 1, y + h - 1, x + w - 2, colorB);
vLine(x + w - 1, y + 1, y + h - 2, colorB);
vLine(x + w - 2, y + 1, y + h - 1, colorB);
}

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.17 2005-02-27 23:41:19 stephena Exp $ // $Id: FrameBuffer.hxx,v 1.18 2005-03-11 23:36:30 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_HXX #ifndef FRAMEBUFFER_HXX
@ -30,16 +30,24 @@
class Console; class Console;
class OSystem; class OSystem;
typedef uInt32 OverlayColor;
// Text alignment modes for drawString()
enum TextAlignment {
kTextAlignLeft,
kTextAlignCenter,
kTextAlignRight
};
/** /**
This class encapsulates the MediaSource and is the basis for the video This class encapsulates the MediaSource and is the basis for the video
display in Stella. All graphics ports should derive from this class for display in Stella. All graphics ports should derive from this class for
platform-specific video stuff. platform-specific video stuff.
FIXME This class also implements a MAME-like user interface where Stella settings All GUI elements (ala ScummVM) are drawn here as well.
can be changed.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.17 2005-02-27 23:41:19 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.18 2005-03-11 23:36:30 stephena Exp $
*/ */
class FrameBuffer class FrameBuffer
{ {
@ -216,6 +224,34 @@ FIXME
*/ */
void setupPalette(); void setupPalette();
/**
Colors to use for the various GUI elements
*/
OverlayColor color, shadowcolor;
OverlayColor bgcolor;
OverlayColor textcolor;
OverlayColor textcolorhi;
/**
This routine should be called to draw a rectangular box with sides
at the specified coordinates.
@param x The x coordinate
@param y The y coordinate
@param w The width of the box
@param h The height of the box
@param colorA FIXME
@param colorB FIXME
*/
void box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor colorA, OverlayColor colorB);
/**
Indicate that the specified area should be redrawn.
Currently this is a null-op.
*/
void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) {}
public: public:
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// The following methods are system-specific and must be implemented // The following methods are system-specific and must be implemented
@ -232,15 +268,6 @@ FIXME
*/ */
virtual bool createScreen() = 0; virtual bool createScreen() = 0;
/**
This routine is called to map a given r,g,b triple to the screen palette.
@param r The red component of the color.
@param g The green component of the color.
@param b The blue component of the color.
*/
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b) = 0;
/** /**
Switches between the filtering options in the video subsystem. Switches between the filtering options in the video subsystem.
*/ */
@ -252,35 +279,6 @@ FIXME
*/ */
virtual void drawMediaSource() = 0; virtual void drawMediaSource() = 0;
/**
This routine should be called to draw a rectangular box with sides
at the specified coordinates.
@param x The x coordinate
@param y The y coordinate
@param w The width of the box
@param h The height of the box
*/
virtual void drawBoundedBox(uInt32 x, uInt32 y, uInt32 w, uInt32 h) = 0;
/**
This routine should be called to draw text at the specified coordinates.
@param x The x coordinate
@param y The y coordinate
@param message The message text
*/
virtual void drawText(uInt32 x, uInt32 y, const string& message) = 0;
/**
This routine should be called to draw character 'c' at the specified coordinates.
@param x The x coordinate
@param y The y coordinate
@param c The character to draw
*/
virtual void drawChar(uInt32 x, uInt32 y, uInt32 c) = 0;
/** /**
This routine is called before any drawing is done (per-frame). This routine is called before any drawing is done (per-frame).
*/ */
@ -299,6 +297,115 @@ FIXME
*/ */
virtual void scanline(uInt32 row, uInt8* data) = 0; virtual void scanline(uInt32 row, uInt8* data) = 0;
/**
This routine is called to map a given r,g,b triple to the screen palette.
@param r The red component of the color.
@param g The green component of the color.
@param b The blue component of the color.
*/
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b) = 0;
/**
This routine should be called to draw a horizontal line.
@param x The first x coordinate
@param y The y coordinate
@param x2 The second x coordinate
@param color The color of the line
*/
virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color) = 0;
/**
This routine should be called to draw a vertical line.
@param x The x coordinate
@param y The first y coordinate
@param y2 The second y coordinate
@param color The color of the line
*/
virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color);
/**
This routine should be called to draw a blended rectangle.
@param x The x coordinate
@param y The y coordinate
@param w The width of the box
@param h The height of the box
@param color FIXME
@param level FIXME
*/
virtual void blendRect(int x, int y, int w, int h,
OverlayColor color, int level = 3) = 0;
/**
This routine should be called to draw a filled rectangle.
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
@param color The color of the area
*/
virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor color) = 0;
/**
This routine should be called to draw a framed rectangle.
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
@param color The color of the surrounding frame
*/
virtual void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor color) = 0;
/**
This routine should be called to draw the specified string.
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
@param color The color of the surrounding frame
*/
virtual void drawString(const string& str, Int32 x, Int32 y, Int32 w,
OverlayColor color, TextAlignment align = kTextAlignLeft,
Int32 deltax = 0, bool useEllipsis = true) = 0;
/* FIXME
void drawChar(byte c, int x, int y, OverlayColor color, const Graphics::Font *font = 0);
int getStringWidth(const String &str);
int getCharWidth(byte c);
void drawBitmap(uint32 *bitmap, int x, int y, OverlayColor color, int h = 8);
*/
/**
This routine should be called to draw text at the specified coordinates.
@param x The x coordinate
@param y The y coordinate
@param message The message text
*/
virtual void drawText(uInt32 x, uInt32 y, const string& message) = 0;
/**
This routine should be called to draw character 'c' at the specified coordinates.
@param x The x coordinate
@param y The y coordinate
@param c The character to draw
*/
virtual void drawChar(uInt32 x, uInt32 y, uInt32 c) = 0;
#if 0 #if 0
FIXME FIXME
/** /**

View File

@ -13,18 +13,20 @@
// 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.2 2005-03-10 22:59:40 stephena Exp $ // $Id: Dialog.cxx,v 1.3 2005-03-11 23:36:30 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
//============================================================================ //============================================================================
#include <SDL.h>
#include <ctype.h> #include <ctype.h>
#include "stdafx.h" #include "OSystem.hxx"
#include "newgui.h" #include "FrameBuffer.hxx"
#include "dialog.h" #include "Menu.hxx"
#include "widget.h" #include "Dialog.hxx"
#include "Widget.hxx"
/* /*
* TODO list * TODO list
@ -35,8 +37,8 @@
* ... * ...
*/ */
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dialog::Dialog(uInt16 x, uInt16 y, uInt16 w, uInt16 h) Dialog::Dialog(OSystem* instance, uInt16 x, uInt16 y, uInt16 w, uInt16 h)
: GuiObject(x, y, w, h), : GuiObject(instance, x, y, w, h),
_mouseWidget(0), _mouseWidget(0),
_focusedWidget(0), _focusedWidget(0),
_visible(false) _visible(false)
@ -51,13 +53,13 @@ Dialog::~Dialog()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Dialog::runModal() int Dialog::runModal() // FIXME
{ {
// Open up // Open up
open(); open();
// Start processing events // Start processing events
g_gui.runLoop(); // g_gui.runLoop();
// Return the result code // Return the result code
return _result; return _result;
@ -70,7 +72,7 @@ void Dialog::open()
_result = 0; _result = 0;
_visible = true; _visible = true;
g_gui.openDialog(this); instance()->menu().addDialog(this);
// Search for the first objects that wantsFocus() (if any) and give it the focus // Search for the first objects that wantsFocus() (if any) and give it the focus
while(w && !w->wantsFocus()) while(w && !w->wantsFocus())
@ -87,7 +89,7 @@ void Dialog::open()
void Dialog::close() void Dialog::close()
{ {
_visible = false; _visible = false;
g_gui.closeTopDialog(); instance()->menu().removeDialog();
if (_mouseWidget) { if (_mouseWidget) {
_mouseWidget->handleMouseLeft(0); _mouseWidget->handleMouseLeft(0);
@ -110,7 +112,7 @@ void Dialog::releaseFocus()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::draw() void Dialog::draw()
{ {
g_gui._needRedraw = true; instance()->frameBuffer().refresh();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -119,8 +121,10 @@ void Dialog::drawDialog()
if(!isVisible()) if(!isVisible())
return; return;
g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor); FrameBuffer& fb = instance()->frameBuffer();
g_gui.box(_x, _y, _w, _h, g_gui._color, g_gui._shadowcolor);
fb.blendRect(_x, _y, _w, _h, fb.bgcolor);
fb.box(_x, _y, _w, _h, fb.color, fb.shadowcolor);
// Draw all children // Draw all children
Widget* w = _firstWidget; Widget* w = _firstWidget;
@ -131,7 +135,7 @@ void Dialog::drawDialog()
} }
// Flag the draw area as dirty // Flag the draw area as dirty
g_gui.addDirtyRect(_x, _y, _w, _h); fb.addDirtyRect(_x, _y, _w, _h);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -201,7 +205,7 @@ void Dialog::handleMouseWheel(int x, int y, int direction)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) void Dialog::handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers)
{ {
if(_focusedWidget) if(_focusedWidget)
if (_focusedWidget->handleKeyDown(ascii, keycode, modifiers)) if (_focusedWidget->handleKeyDown(ascii, keycode, modifiers))
@ -214,7 +218,7 @@ void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers)
ascii = toupper(ascii); ascii = toupper(ascii);
while(w) while(w)
{ {
if(w->_type == kButtonWidget && ascii == toupper(((ButtonWidget *)w)->_hotkey)) if(0)//FIXME - don't let it access a protected variable w->_type == kButtonWidget && ascii == toupper(((ButtonWidget *)w)->_hotkey))
{ {
// The hotkey for widget w was pressed. We fake a mouse click into the // The hotkey for widget w was pressed. We fake a mouse click into the
// button by invoking the appropriate methods. // button by invoking the appropriate methods.
@ -236,7 +240,7 @@ void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) void Dialog::handleKeyUp(uInt16 ascii, Int32 keycode, Int32 modifiers)
{ {
// Focused widget receives keyup events // Focused widget receives keyup events
if(_focusedWidget) if(_focusedWidget)
@ -298,7 +302,7 @@ void Dialog::handleTickle()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleCommand(CommandSender* sender, uint32 cmd, uint32 data) void Dialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data)
{ {
switch(cmd) switch(cmd)
{ {
@ -319,8 +323,8 @@ Widget* Dialog::findWidget(int x, int y)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget* Dialog::addButton(int x, int y, const string &label, ButtonWidget* Dialog::addButton(Int32 x, Int32 y, const string& label,
uint32 cmd, char hotkey) uInt32 cmd, char hotkey)
{ {
return new ButtonWidget(this, x, y, kButtonWidth, 16, label, cmd, hotkey); return new ButtonWidget(this, x, y, kButtonWidth, 16, label, cmd, hotkey);
} }

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.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $ // $Id: Dialog.hxx,v 1.3 2005-03-11 23:36:30 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
@ -22,7 +22,7 @@
#ifndef DIALOG_HXX #ifndef DIALOG_HXX
#define DIALOG_HXX #define DIALOG_HXX
#include <SDL.h> class OSystem;
#include "Command.hxx" #include "Command.hxx"
#include "Widget.hxx" #include "Widget.hxx"
@ -30,16 +30,21 @@
#include "bspf.hxx" #include "bspf.hxx"
// Some "common" commands sent to handleCommand()
enum {
kCloseCmd = 'clos'
};
/** /**
This is the base class for all dialog boxes. This is the base class for all dialog boxes.
@author Stephen Anthony @author Stephen Anthony
@version $Id: Dialog.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $ @version $Id: Dialog.hxx,v 1.3 2005-03-11 23:36:30 stephena Exp $
*/ */
class Dialog class Dialog : public GuiObject
{ {
public: public:
Dialog(uInt16 x, uInt16 y, uInt16 w, uInt16 h); Dialog(OSystem* instance, uInt16 x, uInt16 y, uInt16 w, uInt16 h);
virtual ~Dialog(); virtual ~Dialog();
@ -51,8 +56,8 @@ class Dialog
virtual void drawDialog(); virtual void drawDialog();
virtual void handleKeyDown(SDLKey key, SDLMod mod); virtual void handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers);
virtual void handleKeyUp(SDLKey key, SDLMod mod); virtual void handleKeyUp(uInt16 ascii, Int32 keycode, Int32 modifiers);
protected: protected:
virtual void open(); virtual void open();

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: GuiObject.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $ // $Id: GuiObject.hxx,v 1.3 2005-03-11 23:36:30 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
@ -22,6 +22,7 @@
#ifndef GUI_OBJECT_HXX #ifndef GUI_OBJECT_HXX
#define GUI_OBJECT_HXX #define GUI_OBJECT_HXX
class OSystem;
class Widget; class Widget;
#include "Command.hxx" #include "Command.hxx"
@ -31,20 +32,23 @@ class Widget;
This is the base class for all GUI objects/widgets. This is the base class for all GUI objects/widgets.
@author Stephen Anthony @author Stephen Anthony
@version $Id: GuiObject.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $ @version $Id: GuiObject.hxx,v 1.3 2005-03-11 23:36:30 stephena Exp $
*/ */
class GuiObject : public CommandReceiver class GuiObject : public CommandReceiver
{ {
friend class Widget; friend class Widget;
public: public:
GuiObject(int x, int y, int w, int h) GuiObject(OSystem* osystem, int x, int y, int w, int h)
: _x(x), : myOSystem(osystem),
_x(x),
_y(y), _y(y),
_w(w), _w(w),
_h(h), _h(h),
_firstWidget(0) { } _firstWidget(0) { }
OSystem* instance() { return myOSystem; }
virtual Int16 getAbsX() const { return _x; } virtual Int16 getAbsX() const { return _x; }
virtual Int16 getAbsY() const { return _y; } virtual Int16 getAbsY() const { return _y; }
virtual Int16 getChildX() const { return getAbsX(); } virtual Int16 getChildX() const { return getAbsX(); }
@ -56,6 +60,8 @@ class GuiObject : public CommandReceiver
virtual void draw() = 0; virtual void draw() = 0;
protected: protected:
OSystem* myOSystem;
Int16 _x, _y; Int16 _x, _y;
uInt16 _w, _h; uInt16 _w, _h;

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: Menu.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $ // $Id: Menu.hxx,v 1.3 2005-03-11 23:36:30 stephena Exp $
//============================================================================ //============================================================================
#ifndef MENU_HXX #ifndef MENU_HXX
@ -23,6 +23,8 @@ class Dialog;
class OSystem; class OSystem;
class OptionsDialog; class OptionsDialog;
#include <SDL.h>
#include "Stack.hxx" #include "Stack.hxx"
#include "bspf.hxx" #include "bspf.hxx"
@ -35,7 +37,7 @@ typedef FixedStack<Dialog *> DialogStack;
a stack, and handles their events. a stack, and handles their events.
@author Stephen Anthony @author Stephen Anthony
@version $Id: Menu.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $ @version $Id: Menu.hxx,v 1.3 2005-03-11 23:36:30 stephena Exp $
*/ */
class Menu class Menu
{ {

View File

@ -13,60 +13,22 @@
// 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: OptionsDialog.cxx,v 1.1 2005-03-10 22:59:40 stephena Exp $ // $Id: OptionsDialog.cxx,v 1.2 2005-03-11 23:36:30 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
//============================================================================ //============================================================================
#include "stdafx.h" #include "OSystem.hxx"
#include "Menu.hxx"
#include "common/config-manager.h" #include "Dialog.hxx"
#include "Widget.hxx"
#include "gui/chooser.h" #include "Control.hxx"
#include "gui/newgui.h" #include "OptionsDialog.hxx"
#include "gui/ListWidget.h"
#include "scumm/dialogs.h"
#include "scumm/sound.h"
#include "scumm/scumm.h"
#include "scumm/imuse.h"
#include "scumm/imuse_digi/dimuse.h"
#include "scumm/player_v2.h"
#include "scumm/verbs.h"
#include "sound/mididrv.h"
#include "sound/mixer.h"
#ifndef DISABLE_HELP
#include "scumm/help.h"
#endif
#ifdef _WIN32_WCE
#include "backends/wince/CEKeysDialog.h"
#endif
/* FIXME
// Now create all the dialogs attached to each menu button
myVideoDialog = new VideoDialog(myOSystem);
myAudioDialog = new AudioDialog(myOSystem);
myEventMappingDialog = new EventMappingDialog(myOSystem);
myMiscDialog = new MiscDialog(myOSystem);
myGameInfoDialog = new GameInfoDialog(myOSystem);
myHelpDialog = new HelpDialog(myOSystem);
*/
/* FIXME
delete myVideoDialog;
delete myAudioDialog;
delete myEventMappingDialog;
delete myMiscDialog;
delete myGameInfoDialog;
delete myHelpDialog;
*/
#include "bspf.hxx"
/*
using GUI::CommandSender; using GUI::CommandSender;
using GUI::StaticTextWidget; using GUI::StaticTextWidget;
using GUI::kButtonWidth; using GUI::kButtonWidth;
@ -77,219 +39,17 @@ using GUI::WIDGET_ENABLED;
typedef GUI::OptionsDialog GUI_OptionsDialog; typedef GUI::OptionsDialog GUI_OptionsDialog;
typedef GUI::ChooserDialog GUI_ChooserDialog; typedef GUI::ChooserDialog GUI_ChooserDialog;
*/
namespace Scumm {
struct ResString {
int num;
char string[80];
};
#ifdef __PALM_OS__
static ResString *string_map_table_v7;
static ResString *string_map_table_v6;
static ResString *string_map_table_v5;
#else
static ResString string_map_table_v7[] = {
{96, "game name and version"}, //that's how it's supposed to be
{77, "Select a game to LOAD"},
{76, "Name your SAVE game"},
{70, "save"}, //boot8
{71, "load"}, //boot9
{72, "play"}, //boot10
{73, "cancel"}, //boot11
{74, "quit"}, //boot12
{75, "ok"}, //boot13
{85, "game paused"}, // boot3
{96, "the dig v1.0"},
/* this is the almost complete string map for v7
{63, "how may I serve you?"},
{64, "the dig v1.0"}, //(game name/version)
{67, "text display only"},
{68, "c:\\dig"}, //boot007 (save path ?)
{69, "the dig"}, //boot21 (game name)
{70, "save"}, //boot8
{71, "load"}, //boot9
{72, "play"}, //boot10
{73, "cancel"}, //boot11
{74, "quit"}, //boot12
{75, "ok"}, //boot13
{76, "name your save game"}, //boot19
{77, "select a game to load"}, //boot20
{78, "you must enter a name"},//boot14
{79, "saving '%s'"}, //boot17
{80, "loading '%s'"}, //boot18
{81, "the game was NOT saved"}, //boot15
{82, "the game was NOT loaded"}, //boot16
{83, "how may I serve you?"},
{84, "how may I serve you?"},
{85, "game paused"}, // boot3
{86, "Are you sure you want to restart"},
{87, "Are you sure you want to quit?"}, //boot05
{89, "how may I serve you?"},
{90, "music"}, //boot22
{91, "voice"}, //boot23
{92, "sfx"}, //boot24
{93, "disabled"}, //boot25
{94, "text speed"}, //boot26
{95, "text display"}, //boot27
{96, "the dig v1.0"},*/
};
static ResString string_map_table_v6[] = {
{117, "How may I serve you?"},
{109, "Select a game to LOAD"},
{108, "Name your SAVE game"},
{96, "Save"},
{97, "Load"},
{98, "Play"},
{99, "Cancel"},
{100, "Quit"},
{101, "OK"},
{93, "Game paused"},
{210, "Game version"}
};
static ResString string_map_table_v5[] = {
{28, "How may I serve you?"},
{20, "Select a game to LOAD"},
{19, "Name your SAVE game"},
{7, "Save"},
{8, "Load"},
{9, "Play"},
{10, "Cancel"},
{11, "Quit"},
{12, "OK"},
{4, "Game paused"}
};
#endif
#pragma mark -
const Common::String ScummDialog::queryResString(int stringno) {
byte buf[256];
byte *result;
if (stringno == 0)
return String();
if (_vm->_version >= 7)
result = _vm->getStringAddressVar(string_map_table_v7[stringno - 1].num);
else if (_vm->_version == 6)
result = _vm->getStringAddressVar(string_map_table_v6[stringno - 1].num);
else if (_vm->_version == 5)
result = _vm->getStringAddress(string_map_table_v5[stringno - 1].num);
else
// TODO: For V8 games, maybe grab the strings from the language file?
return string_map_table_v5[stringno - 1].string;
if (result && *result == '/') {
_vm->translateText(result, buf);
result = buf;
}
if (!result || *result == '\0') { // Gracelessly degrade to english :)
return string_map_table_v5[stringno - 1].string;
}
// Convert to a proper string (take care of FF codes)
byte chr;
String tmp;
while ((chr = *result++)) {
if (chr == 0xFF) {
result += 3;
} else if (chr != '@') {
tmp += chr;
}
}
return tmp;
}
#pragma mark -
enum { enum {
kSaveCmd = 'SAVE', kVidCmd = 'VIDO',
kLoadCmd = 'LOAD', kAudCmd = 'AUDO',
kPlayCmd = 'PLAY', kEMapCmd = 'EMAP',
kOptionsCmd = 'OPTN', kMiscCmd = 'MISC',
kInfoCmd = 'INFO',
kHelpCmd = 'HELP', kHelpCmd = 'HELP',
kAboutCmd = 'ABOU',
kQuitCmd = 'QUIT'
}; };
class SaveLoadChooser : public GUI::ChooserDialog {
typedef Common::String String;
typedef Common::StringList StringList;
protected:
bool _saveMode;
public:
SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode);
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
const String &getResultString() const;
};
SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode)
: GUI::ChooserDialog(title, buttonLabel, 182), _saveMode(saveMode) {
_list->setEditable(saveMode);
_list->setNumberingMode(saveMode ? GUI::kListNumberingOne : GUI::kListNumberingZero);
}
const Common::String &SaveLoadChooser::getResultString() const {
return _list->getSelectedString();
}
void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
int selItem = _list->getSelected();
switch (cmd) {
case GUI::kListItemActivatedCmd:
case GUI::kListItemDoubleClickedCmd:
if (selItem >= 0) {
if (_saveMode || !getResultString().isEmpty()) {
setResult(selItem);
close();
}
}
break;
case GUI::kListSelectionChangedCmd:
if (_saveMode) {
_list->startEditMode();
}
// Disable button if nothing is selected, or (in load mode) if an empty
// list item is selected. We allow choosing an empty item in save mode
// because we then just assign a default name.
_chooseButton->setEnabled(selItem >= 0 && (_saveMode || !getResultString().isEmpty()));
_chooseButton->draw();
break;
default:
GUI_ChooserDialog::handleCommand(sender, cmd, data);
}
}
Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode) {
// Get savegame names
Common::StringList l;
char name[32];
uint i = saveMode ? 1 : 0;
bool avail_saves[81];
scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves));
for (; i < ARRAYSIZE(avail_saves); i++) {
if (avail_saves[i])
scumm->getSavegameName(i, name);
else
name[0] = 0;
l.push_back(name);
}
return l;
}
enum { enum {
kRowHeight = 18, kRowHeight = 18,
kBigButtonWidth = 90, kBigButtonWidth = 90,
@ -298,341 +58,84 @@ enum {
}; };
#define addBigButton(label, cmd, hotkey) \ #define addBigButton(label, cmd, hotkey) \
new GUI::ButtonWidget(this, x, y, kBigButtonWidth, 16, label, cmd, hotkey); y += kRowHeight new ButtonWidget(this, x, y, kBigButtonWidth, 16, label, cmd, hotkey); y += kRowHeight
MainMenuDialog::MainMenuDialog(ScummEngine *scumm) OptionsDialog::OptionsDialog(OSystem* osystem)
: ScummDialog(scumm, (320 - kMainMenuWidth) / 2, (200 - kMainMenuHeight)/2, kMainMenuWidth, kMainMenuHeight) { : Dialog(osystem, (320 - kMainMenuWidth) / 2, (200 - kMainMenuHeight)/2, kMainMenuWidth, kMainMenuHeight)
{
int y = 7; int y = 7;
const int x = (_w - kBigButtonWidth) / 2; const int x = (_w - kBigButtonWidth) / 2;
addBigButton("Resume", kPlayCmd, 'P'); addBigButton("Video", kVidCmd, 'V');
y += 5; y += 5;
addBigButton("Load", kLoadCmd, 'L'); addBigButton("Audio", kAudCmd, 'A');
addBigButton("Save", kSaveCmd, 'S'); addBigButton("Event Remapping", kEMapCmd, 'E');
y += 5; y += 5;
addBigButton("Options", kOptionsCmd, 'O'); addBigButton("Misc", kMiscCmd, 'M');
#ifndef DISABLE_HELP addBigButton("Game Info", kInfoCmd, 'I');
addBigButton("Help", kHelpCmd, 'H'); addBigButton("Help", kHelpCmd, 'H');
#endif
addBigButton("About", kAboutCmd, 'A');
y += 5; y += 5;
addBigButton("Quit", kQuitCmd, 'Q'); /*
// Now create all the dialogs attached to each menu button
// myVideoDialog = new VideoDialog(myOSystem);
// Create the sub dialog(s) myAudioDialog = new AudioDialog(myOSystem);
// myEventMappingDialog = new EventMappingDialog(myOSystem);
_aboutDialog = new GUI::AboutDialog(); myMiscDialog = new MiscDialog(myOSystem);
#ifndef DISABLE_HELP myGameInfoDialog = new GameInfoDialog(myOSystem);
_helpDialog = new HelpDialog(scumm); myHelpDialog = new HelpDialog(myOSystem);
#endif */
_saveDialog = new SaveLoadChooser("Save game:", "Save", true);
_loadDialog = new SaveLoadChooser("Load game:", "Load", false);
} }
MainMenuDialog::~MainMenuDialog() { OptionsDialog::~OptionsDialog()
delete _aboutDialog; {
#ifndef DISABLE_HELP /* FIXME
delete _helpDialog; delete myVideoDialog;
#endif delete myAudioDialog;
delete _saveDialog; delete myEventMappingDialog;
delete _loadDialog; delete myMiscDialog;
delete myGameInfoDialog;
delete myHelpDialog;
*/
} }
void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { void OptionsDialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data)
switch (cmd) { {
case kSaveCmd: switch(cmd)
save(); {
case kVidCmd:
// instance()->menu().addDialog(myVideoDialog);
cerr << "push VideoDialog to top of stack\n";
break; break;
case kLoadCmd:
load(); case kAudCmd:
// instance()->menu().addDialog(myAudioDialog);
cerr << "push AudioDialog to top of stack\n";
break; break;
case kPlayCmd:
close(); case kEMapCmd:
// instance()->menu().addDialog(myEventMappingDialog);
cerr << "push EventMappingDialog to top of stack\n";
break; break;
case kOptionsCmd:
_vm->optionsDialog(); case kMiscCmd:
// instance()->menu().addDialog(myMiscDialog);
cerr << "push MiscDialog to top of stack\n";
break; break;
case kAboutCmd:
_aboutDialog->runModal(); case kInfoCmd:
// instance()->menu().addDialog(myGameInfoDialog);
cerr << "push GameInfoDialog to top of stack\n";
break; break;
#ifndef DISABLE_HELP
case kHelpCmd: case kHelpCmd:
_helpDialog->runModal(); // instance()->menu().addDialog(myHelpDialog);
break; cerr << "push HelpDialog to top of stack\n";
#endif
case kQuitCmd:
_vm->_quit = true;
close();
break; break;
default: default:
ScummDialog::handleCommand(sender, cmd, data); Dialog::handleCommand(sender, cmd, data);
} }
} }
void MainMenuDialog::save() {
int idx;
_saveDialog->setList(generateSavegameList(_vm, true));
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
idx = _saveDialog->runModal();
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
if (idx >= 0) {
const String &result = _saveDialog->getResultString();
char buffer[20];
const char *str;
if (result.isEmpty()) {
// If the user was lazy and entered no save name, come up with a default name.
sprintf(buffer, "Save %d", idx + 1);
str = buffer;
} else
str = result.c_str();
_vm->requestSave(idx + 1, str);
close();
}
}
void MainMenuDialog::load() {
int idx;
_loadDialog->setList(generateSavegameList(_vm, false));
idx = _loadDialog->runModal();
if (idx >= 0) {
_vm->requestLoad(idx);
close();
}
}
#pragma mark -
enum {
kOKCmd = 'ok '
};
enum {
kKeysCmd = 'KEYS'
};
#ifndef _WIN32_WCE
ConfigDialog::ConfigDialog(ScummEngine *scumm)
: GUI::OptionsDialog("", 40, 30, 240, 124), _vm(scumm) {
#else
ConfigDialog::ConfigDialog(ScummEngine *scumm)
: GUI::OptionsDialog("", 40, 30, 240, 124 + 4), _vm(scumm) {
#endif
//
// Add the buttons
//
#ifdef _WIN32_WCE
addButton(_w - kButtonWidth - 8, _h - 24 - 4, "OK", GUI::OptionsDialog::kOKCmd, 'O');
addButton(_w - 2 * kButtonWidth - 12, _h - 24 - 4, "Cancel", kCloseCmd, 'C');
addButton(_w - 3 * kButtonWidth - 16, _h - 24 - 4, "Keys", kKeysCmd, 'K');
#else
addButton(_w - kButtonWidth-8, _h - 24, "OK", GUI::OptionsDialog::kOKCmd, 'O');
addButton(_w - 2 * kButtonWidth-12, _h - 24, "Cancel", kCloseCmd, 'C');
#endif
//
// Sound controllers
//
int yoffset = 8;
yoffset = addVolumeControls(this, yoffset);
//
// Some misc options
//
subtitlesCheckbox = new GUI::CheckboxWidget(this, 15, 78, 200, 16, "Show subtitles", 0, 'S');
//
// Create the sub dialog(s)
//
#ifdef _WIN32_WCE
_keysDialog = new CEKeysDialog();
#endif
}
ConfigDialog::~ConfigDialog() {
#ifdef _WIN32_WCE
delete _keysDialog;
#endif
}
void ConfigDialog::open() {
GUI_OptionsDialog::open();
// update checkboxes, too
subtitlesCheckbox->setState(ConfMan.getBool("subtitles"));
}
void ConfigDialog::close() {
if (getResult()) {
// Subtitles
ConfMan.set("subtitles", subtitlesCheckbox->getState(), _domain);
// Sync with current setting
if (_vm->_version >= 7)
_vm->VAR(_vm->VAR_VOICE_MODE) = subtitlesCheckbox->getState();
}
GUI_OptionsDialog::close();
_vm->setupVolumes();
}
void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kKeysCmd:
#ifdef _WIN32_WCE
_keysDialog->runModal();
#endif
break;
default:
GUI_OptionsDialog::handleCommand (sender, cmd, data);
}
}
#ifndef DISABLE_HELP
#pragma mark -
enum {
kNextCmd = 'NEXT',
kPrevCmd = 'PREV'
};
HelpDialog::HelpDialog(ScummEngine *scumm)
: ScummDialog(scumm, 5, 5, 310, 190) {
_page = 1;
_numPages = ScummHelp::numPages(scumm->_gameId);
_prevButton = addButton(10, 170, "Previous", kPrevCmd, 'P');
_nextButton = addButton(90, 170, "Next", kNextCmd, 'N');
addButton(210, 170, "Close", kCloseCmd, 'C');
_prevButton->clearFlags(WIDGET_ENABLED);
_title = new StaticTextWidget(this, 10, 5, 290, 16, "", kTextAlignCenter);
for (int i = 0; i < HELP_NUM_LINES; i++) {
_key[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, 16, "", kTextAlignLeft);
_dsc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 210, 16, "", kTextAlignLeft);
}
displayKeyBindings();
}
void HelpDialog::displayKeyBindings() {
String titleStr, *keyStr, *dscStr;
ScummHelp::updateStrings(_vm->_gameId, _vm->_version, _page, titleStr, keyStr, dscStr);
_title->setLabel(titleStr);
for (int i = 0; i < HELP_NUM_LINES; i++) {
_key[i]->setLabel(keyStr[i]);
_dsc[i]->setLabel(dscStr[i]);
}
delete [] keyStr;
delete [] dscStr;
}
void HelpDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kNextCmd:
_page++;
if (_page >= _numPages) {
_nextButton->clearFlags(WIDGET_ENABLED);
}
if (_page >= 2) {
_prevButton->setFlags(WIDGET_ENABLED);
}
displayKeyBindings();
draw();
break;
case kPrevCmd:
_page--;
if (_page <= _numPages) {
_nextButton->setFlags(WIDGET_ENABLED);
}
if (_page <= 1) {
_prevButton->clearFlags(WIDGET_ENABLED);
}
displayKeyBindings();
draw();
break;
default:
ScummDialog::handleCommand(sender, cmd, data);
}
}
#endif
#pragma mark -
InfoDialog::InfoDialog(ScummEngine *scumm, int res)
: ScummDialog(scumm, 0, 80, 0, 16) { // dummy x and w
setInfoText(queryResString (res));
}
InfoDialog::InfoDialog(ScummEngine *scumm, const String& message)
: ScummDialog(scumm, 0, 80, 0, 16) { // dummy x and w
setInfoText(message);
}
void InfoDialog::setInfoText(const String& message) {
int width = g_gui.getStringWidth(message) + 16;
_x = (_vm->_screenWidth - width) >> 1;
_w = width;
new StaticTextWidget(this, 4, 4, _w - 8, _h, message, kTextAlignCenter);
}
#pragma mark -
PauseDialog::PauseDialog(ScummEngine *scumm, int res)
: InfoDialog(scumm, res) {
}
void PauseDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
if (ascii == ' ') // Close pause dialog if space key is pressed
close();
else
ScummDialog::handleKeyDown(ascii, keycode, modifiers);
}
ConfirmDialog::ConfirmDialog(ScummEngine *scumm, const String& message)
: InfoDialog(scumm, message) {
}
void ConfirmDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
if (tolower(ascii) == 'n') {
setResult(0);
close();
} else if (tolower(ascii) == 'y') {
setResult(1);
close();
} else
ScummDialog::handleKeyDown(ascii, keycode, modifiers);
}
} // End of namespace Scumm
#ifdef __PALM_OS__
#include "scumm_globals.h"
_GINIT(Dialogs)
_GSETPTR(Scumm::string_map_table_v7, GBVARS_STRINGMAPTABLEV7_INDEX, Scumm::ResString, GBVARS_SCUMM)
_GSETPTR(Scumm::string_map_table_v6, GBVARS_STRINGMAPTABLEV6_INDEX, Scumm::ResString, GBVARS_SCUMM)
_GSETPTR(Scumm::string_map_table_v5, GBVARS_STRINGMAPTABLEV5_INDEX, Scumm::ResString, GBVARS_SCUMM)
_GEND
_GRELEASE(Dialogs)
_GRELEASEPTR(GBVARS_STRINGMAPTABLEV7_INDEX, GBVARS_SCUMM)
_GRELEASEPTR(GBVARS_STRINGMAPTABLEV6_INDEX, GBVARS_SCUMM)
_GRELEASEPTR(GBVARS_STRINGMAPTABLEV5_INDEX, GBVARS_SCUMM)
_GEND
#endif

View File

@ -13,21 +13,24 @@
// 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.2 2005-03-10 22:59:40 stephena Exp $ // $Id: Widget.cxx,v 1.3 2005-03-11 23:36:30 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
//============================================================================ //============================================================================
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "Dialog.hxx" #include "Dialog.hxx"
#include "Command.hxx"
#include "GuiObject.hxx" #include "GuiObject.hxx"
#include "bspf.hxx" #include "bspf.hxx"
#include "Widget.hxx" #include "Widget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Widget::Widget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h) Widget::Widget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h)
: GuiObject(x, y, w, h), : GuiObject(boss->instance(), x, y, w, h),
_type(0), _type(0),
_boss(boss), _boss(boss),
_id(0), _id(0),
@ -48,12 +51,12 @@ Widget::~Widget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Widget::draw() void Widget::draw()
{ {
FrameBuffer* fb = _boss->instance().frameBuffer(); FrameBuffer& fb = _boss->instance()->frameBuffer();
if(!isVisible() || !_boss->isVisible()) if(!isVisible() || !_boss->isVisible())
return; return;
int oldX = _x, oldY = _y; Int32 oldX = _x, oldY = _y;
// Account for our relative position in the dialog // Account for our relative position in the dialog
_x = getAbsX(); _x = getAbsX();
@ -61,15 +64,15 @@ 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)
gui->fillRect(_x, _y, _w, _h, gui->_bgcolor); fb.fillRect(_x, _y, _w, _h, fb.bgcolor);
// Draw border // Draw border
if(_flags & WIDGET_BORDER) { if(_flags & WIDGET_BORDER) {
OverlayColor colorA = gui->_color; OverlayColor colorA = fb.color;
OverlayColor colorB = gui->_shadowcolor; OverlayColor colorB = fb.shadowcolor;
if((_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER) if((_flags & WIDGET_INV_BORDER) == WIDGET_INV_BORDER)
SWAP(colorA, colorB); ; //FIXME - add swap function SWAP(colorA, colorB);
gui->box(_x, _y, _w, _h, colorA, colorB); fb.box(_x, _y, _w, _h, colorA, colorB);
_x += 4; _x += 4;
_y += 4; _y += 4;
_w -= 8; _w -= 8;
@ -88,7 +91,7 @@ void Widget::draw()
} }
// Flag the draw area as dirty // Flag the draw area as dirty
gui->addDirtyRect(_x, _y, _w, _h); fb.addDirtyRect(_x, _y, _w, _h);
_x = oldX; _x = oldX;
_y = oldY; _y = oldY;
@ -103,7 +106,7 @@ void Widget::draw()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Widget* Widget::findWidgetInChain(Widget *w, int x, int y) Widget* Widget::findWidgetInChain(Widget *w, Int32 x, Int32 y)
{ {
while(w) while(w)
{ {
@ -120,9 +123,10 @@ Widget* Widget::findWidgetInChain(Widget *w, int x, int y)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, StaticTextWidget::StaticTextWidget(GuiObject *boss, Int32 x, Int32 y, Int32 w, Int32 h,
const string& text, TextAlignment align) const string& text, TextAlignment align)
: Widget(boss, x, y, w, h), _align(align) : Widget(boss, x, y, w, h),
_align(align)
{ {
_flags = WIDGET_ENABLED; _flags = WIDGET_ENABLED;
_type = kStaticTextWidget; _type = kStaticTextWidget;
@ -130,7 +134,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StaticTextWidget::setValue(int value) void StaticTextWidget::setValue(Int32 value)
{ {
char buf[256]; char buf[256];
sprintf(buf, "%d", value); sprintf(buf, "%d", value);
@ -140,14 +144,14 @@ void StaticTextWidget::setValue(int value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StaticTextWidget::drawWidget(bool hilite) void StaticTextWidget::drawWidget(bool hilite)
{ {
NewGui *gui = &g_gui; FrameBuffer& fb = _boss->instance()->frameBuffer();
gui->drawString(_label, _x, _y, _w, fb.drawString(_label, _x, _y, _w,
isEnabled() ? gui->_textcolor : gui->_color, _align); isEnabled() ? fb.textcolor : fb.color, _align);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, ButtonWidget::ButtonWidget(GuiObject *boss, Int32 x, Int32 y, Int32 w, Int32 h,
const string& label, uint32 cmd, uint8 hotkey) const string& label, Int32 cmd, uInt8 hotkey)
: StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), : StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter),
CommandSender(boss), CommandSender(boss),
_cmd(cmd), _cmd(cmd),
@ -158,7 +162,7 @@ ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) void ButtonWidget::handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount)
{ {
if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
sendCommand(_cmd, 0); sendCommand(_cmd, 0);
@ -167,15 +171,17 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::drawWidget(bool hilite) void ButtonWidget::drawWidget(bool hilite)
{ {
NewGui *gui = &g_gui; int kLineHeight = 10; //FIXME
gui->drawString(_label, _x, _y + (_h - kLineHeight)/2 + 1, _w,
!isEnabled() ? gui->_color : FrameBuffer& fb = _boss->instance()->frameBuffer();
hilite ? gui->_textcolorhi : gui->_textcolor, _align); fb.drawString(_label, _x, _y + (_h - kLineHeight)/2 + 1, _w,
!isEnabled() ? fb.color :
hilite ? fb.textcolorhi : fb.textcolor, _align);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* 8x8 checkbox bitmap */ /* 8x8 checkbox bitmap */
static uint32 checked_img[8] = static uInt32 checked_img[8] =
{ {
0x00000000, 0x00000000,
0x01000010, 0x01000010,
@ -188,8 +194,8 @@ static uint32 checked_img[8] =
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, CheckboxWidget::CheckboxWidget(GuiObject *boss, Int32 x, Int32 y, Int32 w, Int32 h,
const string& label, uint32 cmd, uint8 hotkey) const string& label, Int32 cmd, uInt8 hotkey)
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
_state(false) _state(false)
{ {
@ -198,7 +204,7 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) void CheckboxWidget::handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount)
{ {
if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
toggleState(); toggleState();
@ -219,26 +225,27 @@ void CheckboxWidget::setState(bool state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::drawWidget(bool hilite) void CheckboxWidget::drawWidget(bool hilite)
{ {
NewGui *gui = &g_gui; FrameBuffer& fb = _boss->instance()->frameBuffer();
// Draw the box // Draw the box
gui->box(_x, _y, 14, 14, gui->_color, gui->_shadowcolor); fb.box(_x, _y, 14, 14, fb.color, fb.shadowcolor);
// If checked, draw cross inside the box // If checked, draw cross inside the box
if(_state) if(_state)
gui->drawBitmap(checked_img, _x + 3, _y + 3, ; // FIXME - change bitmap to be a character in the font set, then draw that
isEnabled() ? gui->_textcolor : gui->_color); // fb.drawBitmap(checked_img, _x + 3, _y + 3,
// isEnabled() ? fb.textcolor : fb.color);
else else
gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor); fb.fillRect(_x + 2, _y + 2, 10, 10, fb.bgcolor);
// Finally draw the label // Finally draw the label
gui->drawString(_label, _x + 20, _y + 3, _w, fb.drawString(_label, _x + 20, _y + 3, _w,
isEnabled() ? gui->_textcolor : gui->_color); isEnabled() ? fb.textcolor : fb.color);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, SliderWidget::SliderWidget(GuiObject *boss, Int32 x, Int32 y, Int32 w, Int32 h,
const string& label, uint labelWidth, uint32 cmd, uint8 hotkey) const string& label, Int32 labelWidth, Int32 cmd, uInt8 hotkey)
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), : ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
_value(0), _value(0),
_oldValue(0), _oldValue(0),
@ -252,13 +259,13 @@ SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::handleMouseMoved(int x, int y, int button) void SliderWidget::handleMouseMoved(Int32 x, Int32 y, Int32 button)
{ {
// TODO: when the mouse is dragged outside the widget, the slider should // TODO: when the mouse is dragged outside the widget, the slider should
// snap back to the old value. // snap back to the old value.
if(isEnabled() && _isDragging && x >= (int)_labelWidth) if(isEnabled() && _isDragging && x >= (int)_labelWidth)
{ {
int newValue = posToValue(x - _labelWidth); Int32 newValue = posToValue(x - _labelWidth);
if(newValue < _valueMin) if(newValue < _valueMin)
newValue = _valueMin; newValue = _valueMin;
@ -275,7 +282,7 @@ void SliderWidget::handleMouseMoved(int x, int y, int button)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount) void SliderWidget::handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCount)
{ {
if(isEnabled()) if(isEnabled())
{ {
@ -285,7 +292,7 @@ void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount) void SliderWidget::handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount)
{ {
if(isEnabled() && _isDragging) if(isEnabled() && _isDragging)
sendCommand(_cmd, _value); sendCommand(_cmd, _value);
@ -296,30 +303,30 @@ void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::drawWidget(bool hilite) void SliderWidget::drawWidget(bool hilite)
{ {
NewGui *gui = &g_gui; FrameBuffer& fb = _boss->instance()->frameBuffer();
// Draw the label, if any // Draw the label, if any
if(_labelWidth > 0) if(_labelWidth > 0)
gui->drawString(_label, _x, _y + 2, _labelWidth, fb.drawString(_label, _x, _y + 2, _labelWidth,
isEnabled() ? gui->_textcolor : gui->_color, kTextAlignRight); isEnabled() ? fb.textcolor : fb.color, kTextAlignRight);
// Draw the box // Draw the box
gui->box(_x + _labelWidth, _y, _w - _labelWidth, _h, gui->_color, gui->_shadowcolor); fb.box(_x + _labelWidth, _y, _w - _labelWidth, _h, fb.color, fb.shadowcolor);
// Draw the 'bar' // Draw the 'bar'
gui->fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4, fb.fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4,
!isEnabled() ? gui->_color : !isEnabled() ? fb.color :
hilite ? gui->_textcolorhi : gui->_textcolor); hilite ? fb.textcolorhi : fb.textcolor);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int SliderWidget::valueToPos(int value) Int32 SliderWidget::valueToPos(Int32 value)
{ {
return ((_w - _labelWidth - 4) * (value - _valueMin) / (_valueMax - _valueMin)); return ((_w - _labelWidth - 4) * (value - _valueMin) / (_valueMax - _valueMin));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int SliderWidget::posToValue(int pos) Int32 SliderWidget::posToValue(Int32 pos)
{ {
return (pos) * (_valueMax - _valueMin) / (_w - _labelWidth - 4) + _valueMin; return (pos) * (_valueMax - _valueMin) / (_w - _labelWidth - 4) + _valueMin;
} }

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.2 2005-03-10 22:59:40 stephena Exp $ // $Id: Widget.hxx,v 1.3 2005-03-11 23:36:30 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
@ -24,6 +24,7 @@
class Dialog; class Dialog;
#include "FrameBuffer.hxx"
#include "GuiObject.hxx" #include "GuiObject.hxx"
#include "bspf.hxx" #include "bspf.hxx"
@ -39,31 +40,48 @@ enum {
WIDGET_RETAIN_FOCUS = 1 << 9 WIDGET_RETAIN_FOCUS = 1 << 9
}; };
enum {
kStaticTextWidget ='TEXT',
kEditTextWidget = 'EDIT',
kButtonWidget = 'BTTN',
kCheckboxWidget = 'CHKB',
kSliderWidget = 'SLDE',
kListWidget = 'LIST',
kScrollBarWidget = 'SCRB',
kPopUpWidget = 'POPU',
kTabWidget = 'TABW'
};
enum {
kButtonWidth = 72,
kButtonHeight = 16
};
/** /**
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.2 2005-03-10 22:59:40 stephena Exp $ @version $Id: Widget.hxx,v 1.3 2005-03-11 23:36:30 stephena Exp $
*/ */
class Widget : public GuiObject class Widget : public GuiObject
{ {
friend class Dialog; friend class Dialog;
public: public:
Widget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h); Widget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h);
virtual ~Widget(); virtual ~Widget();
virtual Int16 getAbsX() const { return _x + _boss->getChildX(); } virtual Int16 getAbsX() const { return _x + _boss->getChildX(); }
virtual Int16 getAbsY() const { return _y + _boss->getChildY(); } virtual Int16 getAbsY() const { return _y + _boss->getChildY(); }
virtual void handleMouseDown(uInt32 x, uInt32 y, uInt32 button, uInt32 clickCount) {} virtual void handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCount) {}
virtual void handleMouseUp(uInt32 x, uInt32 y, uInt32 button, uInt32 clickCount) {} virtual void handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount) {}
virtual void handleMouseEntered(uInt32 button) {} virtual void handleMouseEntered(Int32 button) {}
virtual void handleMouseLeft(uInt32 button) {} virtual void handleMouseLeft(Int32 button) {}
virtual void handleMouseMoved(uInt32 x, uInt32 y, uInt32 button) {} virtual void handleMouseMoved(Int32 x, Int32 y, Int32 button) {}
virtual void handleMouseWheel(uInt32 x, uInt32 y, uInt32 direction) {} virtual void handleMouseWheel(Int32 x, Int32 y, Int32 direction) {}
virtual bool handleKeyDown(uInt16 ascii, int keycode, int modifiers) { return false; } virtual bool handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers) { return false; }
virtual bool handleKeyUp(uInt16 ascii, int keycode, int modifiers) { return false; } virtual bool handleKeyUp(uInt16 ascii, Int32 keycode, Int32 modifiers) { return false; }
virtual void handleTickle() {} virtual void handleTickle() {}
void draw(); void draw();
@ -71,9 +89,9 @@ class Widget : public GuiObject
void lostFocus() { _hasFocus = false; lostFocusWidget(); } void lostFocus() { _hasFocus = false; lostFocusWidget(); }
virtual bool wantsFocus() { return false; }; virtual bool wantsFocus() { return false; };
void setFlags(int flags) { _flags |= flags; } void setFlags(Int32 flags) { _flags |= flags; }
void clearFlags(int flags) { _flags &= ~flags; } void clearFlags(Int32 flags) { _flags &= ~flags; }
uInt32 getFlags() const { return _flags; } Int32 getFlags() const { return _flags; }
void setEnabled(bool e) { if (e) setFlags(WIDGET_ENABLED); else clearFlags(WIDGET_ENABLED); } void setEnabled(bool e) { if (e) setFlags(WIDGET_ENABLED); else clearFlags(WIDGET_ENABLED); }
bool isEnabled() const { return _flags & WIDGET_ENABLED; } bool isEnabled() const { return _flags & WIDGET_ENABLED; }
@ -85,16 +103,16 @@ class Widget : public GuiObject
virtual void receivedFocusWidget() {} virtual void receivedFocusWidget() {}
virtual void lostFocusWidget() {} virtual void lostFocusWidget() {}
virtual Widget* findWidget(uInt32 x, uInt32 y) { return this; } virtual Widget* findWidget(Int32 x, Int32 y) { return this; }
void releaseFocus() { assert(_boss); _boss->releaseFocus(); } void releaseFocus() { assert(_boss); _boss->releaseFocus(); }
// By default, delegate unhandled commands to the boss // By default, delegate unhandled commands to the boss
void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data) void handleCommand(CommandSender* sender, Int32 cmd, Int32 data)
{ assert(_boss); _boss->handleCommand(sender, cmd, data); } { assert(_boss); _boss->handleCommand(sender, cmd, data); }
protected: protected:
uInt32 _type; Int32 _type;
GuiObject* _boss; GuiObject* _boss;
Widget* _next; Widget* _next;
uInt16 _id; uInt16 _id;
@ -102,7 +120,7 @@ class Widget : public GuiObject
bool _hasFocus; bool _hasFocus;
public: public:
static Widget* findWidgetInChain(Widget* start, uInt32 x, uInt32 y); static Widget* findWidgetInChain(Widget* start, Int32 x, Int32 y);
}; };
@ -110,9 +128,10 @@ class Widget : public GuiObject
class StaticTextWidget : public Widget class StaticTextWidget : public Widget
{ {
public: public:
StaticTextWidget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h, StaticTextWidget(GuiObject* boss,
const string& text); Int32 x, Int32 y, Int32 w, Int32 h,
void setValue(uInt32 value); const string& text, TextAlignment align);
void setValue(Int32 value);
void setLabel(const string& label) { _label = label; } void setLabel(const string& label) { _label = label; }
const string& getLabel() const { return _label; } const string& getLabel() const { return _label; }
@ -121,22 +140,24 @@ class StaticTextWidget : public Widget
protected: protected:
string _label; string _label;
TextAlignment _align;
}; };
/* ButtonWidget */ /* ButtonWidget */
class ButtonWidget : public StaticTextWidget class ButtonWidget : public StaticTextWidget, public CommandSender
{ {
public: public:
ButtonWidget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h, ButtonWidget(GuiObject* boss,
const string& label, uInt32 cmd = 0, uInt8 hotkey = 0); Int32 x, Int32 y, Int32 w, Int32 h,
const string& label, Int32 cmd = 0, uInt8 hotkey = 0);
void setCmd(uInt32 cmd) { _cmd = cmd; } void setCmd(Int32 cmd) { _cmd = cmd; }
uInt32 getCmd() const { return _cmd; } Int32 getCmd() const { return _cmd; }
void handleMouseUp(uInt32 x, uInt32 y, uInt32 button, uInt32 clickCount); void handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount);
void handleMouseEntered(uInt32 button) { setFlags(WIDGET_HILITED); draw(); } void handleMouseEntered(Int32 button) { setFlags(WIDGET_HILITED); draw(); }
void handleMouseLeft(uInt32 button) { clearFlags(WIDGET_HILITED); draw(); } void handleMouseLeft(Int32 button) { clearFlags(WIDGET_HILITED); draw(); }
protected: protected:
void drawWidget(bool hilite); void drawWidget(bool hilite);
@ -151,12 +172,12 @@ class ButtonWidget : public StaticTextWidget
class CheckboxWidget : public ButtonWidget class CheckboxWidget : public ButtonWidget
{ {
public: public:
CheckboxWidget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h, CheckboxWidget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h,
const string& label, uInt32 cmd = 0, uInt8 hotkey = 0); const string& label, Int32 cmd = 0, uInt8 hotkey = 0);
void handleMouseUp(uInt32 x, uInt32 y, uInt32 button, uInt32 clickCount); void handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount);
virtual void handleMouseEntered(uInt32 button) {} virtual void handleMouseEntered(Int32 button) {}
virtual void handleMouseLeft(uInt32 button) {} virtual void handleMouseLeft(Int32 button) {}
void setState(bool state); void setState(bool state);
void toggleState() { setState(!_state); } void toggleState() { setState(!_state); }
@ -174,32 +195,32 @@ class CheckboxWidget : public ButtonWidget
class SliderWidget : public ButtonWidget class SliderWidget : public ButtonWidget
{ {
public: public:
SliderWidget(GuiObject *boss, int x, int y, int w, int h, const string& label = "", SliderWidget(GuiObject *boss, Int32 x, Int32 y, Int32 w, Int32 h, const string& label = "",
uInt32 labelWidth = 0, uInt32 cmd = 0, uInt8 hotkey = 0); Int32 labelWidth = 0, Int32 cmd = 0, uInt8 hotkey = 0);
void setValue(uInt32 value) { _value = value; } void setValue(Int32 value) { _value = value; }
uInt32 getValue() const { return _value; } Int32 getValue() const { return _value; }
void setMinValue(uInt32 value) { _valueMin = value; } void setMinValue(Int32 value) { _valueMin = value; }
uInt32 getMinValue() const { return _valueMin; } Int32 getMinValue() const { return _valueMin; }
void setMaxValue(uInt32 value) { _valueMax = value; } void setMaxValue(Int32 value) { _valueMax = value; }
uInt32 getMaxValue() const { return _valueMax; } Int32 getMaxValue() const { return _valueMax; }
void handleMouseMoved(uInt32 x, uInt32 y, uInt32 button); void handleMouseMoved(Int32 x, Int32 y, Int32 button);
void handleMouseDown(uInt32 x, uInt32 y, uInt32 button, uInt32 clickCount); void handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCount);
void handleMouseUp(uInt32 x, uInt32 y, uInt32 button, uInt32 clickCount); void handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount);
protected: protected:
void drawWidget(bool hilite); void drawWidget(bool hilite);
uInt32 valueToPos(uInt32 value); Int32 valueToPos(Int32 value);
uInt32 posToValue(uInt32 pos); Int32 posToValue(Int32 pos);
protected: protected:
uInt32 _value, _oldValue; Int32 _value, _oldValue;
uInt32 _valueMin, _valueMax; Int32 _valueMin, _valueMax;
bool _isDragging; bool _isDragging;
uInt32 _labelWidth; Int32 _labelWidth;
}; };
#endif #endif