mirror of https://github.com/stella-emu/stella.git
More work on implementing an in-game GUI.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@378 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
5489ca7248
commit
4e129001cd
|
@ -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: makefile,v 1.62 2005-02-27 23:41:17 stephena Exp $
|
## $Id: makefile,v 1.63 2005-03-10 22:59:39 stephena Exp $
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
@ -41,7 +41,7 @@ OPTIMIZATIONS =
|
||||||
|
|
||||||
### to build on SMP (or distcc-based) machines
|
### to build on SMP (or distcc-based) machines
|
||||||
### change to number of CPU's you have
|
### change to number of CPU's you have
|
||||||
NUMBER_CPU = 3
|
NUMBER_CPU = 1
|
||||||
|
|
||||||
##============================================================================
|
##============================================================================
|
||||||
## All done, type make to get a list of frontends
|
## All done, type make to get a list of frontends
|
||||||
|
@ -61,9 +61,10 @@ SMP =
|
||||||
SRC = ..
|
SRC = ..
|
||||||
CORE = $(SRC)/emucore
|
CORE = $(SRC)/emucore
|
||||||
COMMON = $(SRC)/common
|
COMMON = $(SRC)/common
|
||||||
|
GUI = $(SRC)/gui
|
||||||
|
|
||||||
INCLUDES = -I. -I$(CORE) -I$(CORE)/m6502/src \
|
INCLUDES = -I. -I$(CORE) -I$(CORE)/m6502/src \
|
||||||
-I$(CORE)/m6502/src/bspf/src -I$(COMMON) -I$(SRC)/unix -I$(SRC)/win32
|
-I$(CORE)/m6502/src/bspf/src -I$(COMMON) -I$(GUI) -I$(SRC)/unix -I$(SRC)/win32
|
||||||
|
|
||||||
## set some sane optimizations if none have been provided
|
## set some sane optimizations if none have been provided
|
||||||
ifndef OPTIMIZATIONS
|
ifndef OPTIMIZATIONS
|
||||||
|
@ -152,7 +153,7 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \
|
||||||
Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \
|
Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \
|
||||||
Props.o PropsSet.o Random.o Sound.o Switches.o Settings.o TIA.o \
|
Props.o PropsSet.o Random.o Sound.o Switches.o Settings.o TIA.o \
|
||||||
Serializer.o Deserializer.o TIASound.o EventHandler.o FrameBuffer.o \
|
Serializer.o Deserializer.o TIASound.o EventHandler.o FrameBuffer.o \
|
||||||
OSystem.o \
|
OSystem.o Menu.o Widget.o Dialog.o OptionsDialog.o\
|
||||||
$(M6502_OBJS)
|
$(M6502_OBJS)
|
||||||
|
|
||||||
stella: $(CORE_OBJS) $(OBJS)
|
stella: $(CORE_OBJS) $(OBJS)
|
||||||
|
@ -350,3 +351,15 @@ NullDev.o: $(CORE)/m6502/src/NullDev.cxx $(CORE)/m6502/src/NullDev.hxx
|
||||||
|
|
||||||
System.o: $(CORE)/m6502/src/System.cxx $(CORE)/m6502/src/System.hxx
|
System.o: $(CORE)/m6502/src/System.cxx $(CORE)/m6502/src/System.hxx
|
||||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/System.cxx
|
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/System.cxx
|
||||||
|
|
||||||
|
Menu.o: $(GUI)/Menu.cxx $(GUI)/Menu.hxx
|
||||||
|
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Menu.cxx
|
||||||
|
|
||||||
|
Widget.o: $(GUI)/Widget.cxx $(GUI)/Widget.hxx
|
||||||
|
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Widget.cxx
|
||||||
|
|
||||||
|
Dialog.o: $(GUI)/Dialog.cxx $(GUI)/Dialog.hxx
|
||||||
|
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Dialog.cxx
|
||||||
|
|
||||||
|
OptionsDialog.o: $(GUI)/OptionsDialog.cxx $(GUI)/OptionsDialog.hxx
|
||||||
|
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/OptionsDialog.cxx
|
||||||
|
|
|
@ -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: EventHandler.cxx,v 1.35 2005-02-27 23:41:18 stephena Exp $
|
// $Id: EventHandler.cxx,v 1.36 2005-03-10 22:59:40 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
#include "Sound.hxx"
|
#include "Sound.hxx"
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
|
#include "Menu.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
#ifdef SNAPSHOT_SUPPORT
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
|
@ -111,14 +112,14 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
||||||
if(myState == S_EMULATE)
|
if(myState == S_EMULATE)
|
||||||
{
|
{
|
||||||
myState = S_MENU;
|
myState = S_MENU;
|
||||||
myOSystem->frameBuffer().showMenu(true); // FIXME - move this into gui class
|
myOSystem->frameBuffer().refresh();
|
||||||
myOSystem->sound().mute(true);
|
myOSystem->sound().mute(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(myState == S_MENU)
|
else if(myState == S_MENU)
|
||||||
{
|
{
|
||||||
myState = S_EMULATE;
|
myState = S_EMULATE;
|
||||||
myOSystem->frameBuffer().showMenu(false); // FIXME - move this into gui class
|
myOSystem->frameBuffer().refresh();
|
||||||
myOSystem->sound().mute(false);
|
myOSystem->sound().mute(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -137,11 +138,11 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_MENU:
|
case S_MENU:
|
||||||
//FIXME myOSystem->gui().menu().handleKeyEvent(key, mod, state);
|
myOSystem->menu().handleKeyEvent(key, mod, state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_BROWSER:
|
case S_BROWSER:
|
||||||
//FIXME myOSystem->gui().browser().handleKeyEvent(key, mod, state);
|
//FIXME myOSystem->browser().handleKeyEvent(key, mod, state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_DEBUGGER:
|
case S_DEBUGGER:
|
||||||
|
@ -209,6 +210,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 state)
|
||||||
{
|
{
|
||||||
myExitGameFlag = true;
|
myExitGameFlag = true;
|
||||||
myOSystem->sound().mute(true);
|
myOSystem->sound().mute(true);
|
||||||
|
myOSystem->settings().saveConfig();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(event == Event::Quit)
|
else if(event == Event::Quit)
|
||||||
|
|
|
@ -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.17 2005-02-27 23:41:19 stephena Exp $
|
// $Id: FrameBuffer.cxx,v 1.18 2005-03-10 22:59:40 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
#include "Settings.hxx"
|
#include "Settings.hxx"
|
||||||
#include "MediaSrc.hxx"
|
#include "MediaSrc.hxx"
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
|
#include "Menu.hxx"
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
|
|
||||||
#include "stella.xpm" // The Stella icon
|
#include "stella.xpm" // The Stella icon
|
||||||
|
@ -231,15 +232,15 @@ void FrameBuffer::update()
|
||||||
|
|
||||||
case EventHandler::S_MENU: // FIXME - this whole thing will disappear into the gui().menu class
|
case EventHandler::S_MENU: // FIXME - this whole thing will disappear into the gui().menu class
|
||||||
{
|
{
|
||||||
// Only update the screen if it's been invalidated
|
// Only update the screen if it's been invalidated or the menus have changed
|
||||||
// or the menus have changed
|
|
||||||
if(theMenuChangedIndicator || theRedrawEntireFrameIndicator)
|
if(theMenuChangedIndicator || theRedrawEntireFrameIndicator)
|
||||||
{
|
{
|
||||||
drawMediaSource();
|
drawMediaSource();
|
||||||
|
|
||||||
// Then overlay any menu items
|
// Then overlay any menu items
|
||||||
// FIXME myOSystem->gui().menu().draw();
|
myOSystem->menu().draw();
|
||||||
|
|
||||||
|
/*
|
||||||
switch(myCurrentWidget)
|
switch(myCurrentWidget)
|
||||||
{
|
{
|
||||||
case W_NONE:
|
case W_NONE:
|
||||||
|
@ -256,7 +257,7 @@ void FrameBuffer::update()
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Now the screen is up to date
|
// Now the screen is up to date
|
||||||
theRedrawEntireFrameIndicator = false;
|
theRedrawEntireFrameIndicator = false;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: OSystem.cxx,v 1.4 2005-02-22 20:19:32 stephena Exp $
|
// $Id: OSystem.cxx,v 1.5 2005-03-10 22:59:40 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -25,18 +25,28 @@
|
||||||
#include "Settings.hxx"
|
#include "Settings.hxx"
|
||||||
#include "PropsSet.hxx"
|
#include "PropsSet.hxx"
|
||||||
#include "EventHandler.hxx"
|
#include "EventHandler.hxx"
|
||||||
|
#include "Menu.hxx"
|
||||||
|
//#include "Browser.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
OSystem::OSystem()
|
OSystem::OSystem()
|
||||||
|
: myMenu(NULL)
|
||||||
|
// myBrowser(NULL)
|
||||||
{
|
{
|
||||||
|
// Create gui-related classes
|
||||||
|
myMenu = new Menu(this);
|
||||||
|
// myBrowser = new Browser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
OSystem::~OSystem()
|
OSystem::~OSystem()
|
||||||
{
|
{
|
||||||
cerr << "OSystem::~OSystem()\n";
|
cerr << "OSystem::~OSystem()\n";
|
||||||
|
delete myMenu;
|
||||||
|
// delete myBrowser;
|
||||||
|
|
||||||
// Remove any game console that is currently attached
|
// Remove any game console that is currently attached
|
||||||
detachConsole();
|
detachConsole();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: OSystem.hxx,v 1.3 2005-02-22 18:41:12 stephena Exp $
|
// $Id: OSystem.hxx,v 1.4 2005-03-10 22:59:40 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef OSYSTEM_HXX
|
#ifndef OSYSTEM_HXX
|
||||||
|
@ -24,6 +24,8 @@ class FrameBuffer;
|
||||||
class Sound;
|
class Sound;
|
||||||
class Settings;
|
class Settings;
|
||||||
class PropertiesSet;
|
class PropertiesSet;
|
||||||
|
class Menu;
|
||||||
|
class Browser;
|
||||||
|
|
||||||
#include "Console.hxx"
|
#include "Console.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
@ -35,7 +37,7 @@ class PropertiesSet;
|
||||||
other objects belong.
|
other objects belong.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: OSystem.hxx,v 1.3 2005-02-22 18:41:12 stephena Exp $
|
@version $Id: OSystem.hxx,v 1.4 2005-03-10 22:59:40 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class OSystem
|
class OSystem
|
||||||
{
|
{
|
||||||
|
@ -98,6 +100,20 @@ class OSystem
|
||||||
*/
|
*/
|
||||||
void detachConsole(void) { delete myConsole; myConsole = NULL; }
|
void detachConsole(void) { delete myConsole; myConsole = NULL; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Adds the specified settings menu yo the system.
|
||||||
|
|
||||||
|
@param menu The menu object to add
|
||||||
|
*/
|
||||||
|
void attach(Menu* menu) { myMenu = menu; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Adds the specified ROM browser to the system.
|
||||||
|
|
||||||
|
@param browser The browser object to add
|
||||||
|
*/
|
||||||
|
void attach(Browser* browser) { myBrowser = browser; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the event handler of the system
|
Get the event handler of the system
|
||||||
|
|
||||||
|
@ -140,6 +156,20 @@ class OSystem
|
||||||
*/
|
*/
|
||||||
Console& console(void) const { return *myConsole; }
|
Console& console(void) const { return *myConsole; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the settings menu of the system.
|
||||||
|
|
||||||
|
@return The settings menu object
|
||||||
|
*/
|
||||||
|
Menu& menu(void) const { return *myMenu; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the ROM browser of the system.
|
||||||
|
|
||||||
|
@return The browser object
|
||||||
|
*/
|
||||||
|
Browser& browser(void) const { return *myBrowser; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the base directory for all configuration files
|
Set the base directory for all configuration files
|
||||||
*/
|
*/
|
||||||
|
@ -255,6 +285,12 @@ class OSystem
|
||||||
// Pointer to the (currently defined) Console object
|
// Pointer to the (currently defined) Console object
|
||||||
Console* myConsole;
|
Console* myConsole;
|
||||||
|
|
||||||
|
// Pointer to the Menu object
|
||||||
|
Menu* myMenu;
|
||||||
|
|
||||||
|
// Pointer to the Browser object
|
||||||
|
Browser* myBrowser;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string myBaseDir;
|
string myBaseDir;
|
||||||
string myStateDir;
|
string myStateDir;
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// SSSS tt lll lll
|
||||||
|
// SS SS tt ll ll
|
||||||
|
// SS tttttt eeee ll ll aaaa
|
||||||
|
// SSSS tt ee ee ll ll aa
|
||||||
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
|
// SS SS tt ee ll ll aa aa
|
||||||
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
|
//
|
||||||
|
// Copyright (c) 1995-2005 by Bradford W. Mott
|
||||||
|
//
|
||||||
|
// See the file "license" for information on usage and redistribution of
|
||||||
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
//
|
||||||
|
// $Id: Command.hxx,v 1.1 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#ifndef COMMAND_HXX
|
||||||
|
#define COMMAND_HXX
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allows base GUI objects to send and receive commands.
|
||||||
|
|
||||||
|
@author Stephen Anthony
|
||||||
|
@version $Id: Command.hxx,v 1.1 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
*/
|
||||||
|
class CommandReceiver;
|
||||||
|
class CommandSender;
|
||||||
|
|
||||||
|
class CommandReceiver
|
||||||
|
{
|
||||||
|
friend class CommandSender;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CommandSender
|
||||||
|
{
|
||||||
|
// TODO - allow for multiple targets, i.e. store targets in a list
|
||||||
|
// and add methods addTarget/removeTarget.
|
||||||
|
public:
|
||||||
|
CommandSender(CommandReceiver* target)
|
||||||
|
: _target(target) {}
|
||||||
|
|
||||||
|
void setTarget(CommandReceiver* target) { _target = target; }
|
||||||
|
CommandReceiver* getTarget() const { return _target; }
|
||||||
|
|
||||||
|
virtual void sendCommand(uInt32 cmd, uInt32 data)
|
||||||
|
{
|
||||||
|
if(_target && cmd)
|
||||||
|
_target->handleCommand(this, cmd, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CommandReceiver* _target;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,22 +1,23 @@
|
||||||
/* ScummVM - Scumm Interpreter
|
//============================================================================
|
||||||
* Copyright (C) 2002-2004 The ScummVM project
|
//
|
||||||
*
|
// SSSS tt lll lll
|
||||||
* This program is free software; you can redistribute it and/or
|
// SS SS tt ll ll
|
||||||
* modify it under the terms of the GNU General Public License
|
// SS tttttt eeee ll ll aaaa
|
||||||
* as published by the Free Software Foundation; either version 2
|
// SSSS tt ee ee ll ll aa
|
||||||
* of the License, or (at your option) any later version.
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
*
|
// SS SS tt ee ll ll aa aa
|
||||||
* This program is distributed in the hope that it will be useful,
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
//
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// Copyright (c) 1995-2005 by Bradford W. Mott
|
||||||
* GNU General Public License for more details.
|
//
|
||||||
*
|
// See the file "license" for information on usage and redistribution of
|
||||||
* You should have received a copy of the GNU General Public License
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
* along with this program; if not, write to the Free Software
|
//
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// $Id: Dialog.cxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
*
|
//
|
||||||
* $Header: /home/stephena/STELLA_CVS-to-SVN/stella/src/gui/Dialog.cxx,v 1.1 2005-02-27 23:41:19 stephena Exp $
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
*/
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
@ -25,8 +26,6 @@
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
|
||||||
namespace GUI {
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO list
|
* TODO list
|
||||||
* - add some sense of the window being "active" (i.e. in front) or not. If it
|
* - add some sense of the window being "active" (i.e. in front) or not. If it
|
||||||
|
@ -35,13 +34,25 @@ namespace GUI {
|
||||||
* like we have for class Widget?
|
* like we have for class Widget?
|
||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Dialog::Dialog(uInt16 x, uInt16 y, uInt16 w, uInt16 h)
|
||||||
|
: GuiObject(x, y, w, h),
|
||||||
|
_mouseWidget(0),
|
||||||
|
_focusedWidget(0),
|
||||||
|
_visible(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Dialog::~Dialog() {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Dialog::~Dialog()
|
||||||
|
{
|
||||||
delete _firstWidget;
|
delete _firstWidget;
|
||||||
_firstWidget = 0;
|
_firstWidget = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Dialog::runModal() {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
int Dialog::runModal()
|
||||||
|
{
|
||||||
// Open up
|
// Open up
|
||||||
open();
|
open();
|
||||||
|
|
||||||
|
@ -52,7 +63,9 @@ int Dialog::runModal() {
|
||||||
return _result;
|
return _result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::open() {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::open()
|
||||||
|
{
|
||||||
Widget* w = _firstWidget;
|
Widget* w = _firstWidget;
|
||||||
|
|
||||||
_result = 0;
|
_result = 0;
|
||||||
|
@ -60,17 +73,19 @@ void Dialog::open() {
|
||||||
g_gui.openDialog(this);
|
g_gui.openDialog(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())
|
||||||
w = w->_next;
|
w = w->_next;
|
||||||
}
|
|
||||||
|
|
||||||
if (w) {
|
if(w)
|
||||||
|
{
|
||||||
w->receivedFocus();
|
w->receivedFocus();
|
||||||
_focusedWidget = w;
|
_focusedWidget = w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::close() {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::close()
|
||||||
|
{
|
||||||
_visible = false;
|
_visible = false;
|
||||||
g_gui.closeTopDialog();
|
g_gui.closeTopDialog();
|
||||||
|
|
||||||
|
@ -78,22 +93,29 @@ void Dialog::close() {
|
||||||
_mouseWidget->handleMouseLeft(0);
|
_mouseWidget->handleMouseLeft(0);
|
||||||
_mouseWidget = 0;
|
_mouseWidget = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseFocus();
|
releaseFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::releaseFocus() {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if (_focusedWidget) {
|
void Dialog::releaseFocus()
|
||||||
|
{
|
||||||
|
if(_focusedWidget)
|
||||||
|
{
|
||||||
_focusedWidget->lostFocus();
|
_focusedWidget->lostFocus();
|
||||||
_focusedWidget = 0;
|
_focusedWidget = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::draw() {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::draw()
|
||||||
|
{
|
||||||
g_gui._needRedraw = true;
|
g_gui._needRedraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::drawDialog() {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::drawDialog()
|
||||||
|
{
|
||||||
if(!isVisible())
|
if(!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -102,7 +124,8 @@ void Dialog::drawDialog() {
|
||||||
|
|
||||||
// Draw all children
|
// Draw all children
|
||||||
Widget* w = _firstWidget;
|
Widget* w = _firstWidget;
|
||||||
while (w) {
|
while(w)
|
||||||
|
{
|
||||||
w->draw();
|
w->draw();
|
||||||
w = w->_next;
|
w = w->_next;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +134,9 @@ void Dialog::drawDialog() {
|
||||||
g_gui.addDirtyRect(_x, _y, _w, _h);
|
g_gui.addDirtyRect(_x, _y, _w, _h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::handleMouseDown(int x, int y, int button, int clickCount)
|
||||||
|
{
|
||||||
Widget* w;
|
Widget* w;
|
||||||
w = findWidget(x, y);
|
w = findWidget(x, y);
|
||||||
|
|
||||||
|
@ -122,7 +147,8 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||||
// However, right now we "abuse" the focus also for the click&drag
|
// However, right now we "abuse" the focus also for the click&drag
|
||||||
// behaviour of buttons. This should probably be changed by adding
|
// behaviour of buttons. This should probably be changed by adding
|
||||||
// a nother field, e.g. _clickedWidget or _dragWidget.
|
// a nother field, e.g. _clickedWidget or _dragWidget.
|
||||||
if (w && w != _focusedWidget) {
|
if(w && w != _focusedWidget)
|
||||||
|
{
|
||||||
// The focus will change. Tell the old focused widget (if any)
|
// The focus will change. Tell the old focused widget (if any)
|
||||||
// that it lost the focus.
|
// that it lost the focus.
|
||||||
releaseFocus();
|
releaseFocus();
|
||||||
|
@ -138,26 +164,29 @@ void Dialog::handleMouseDown(int x, int y, int button, int clickCount) {
|
||||||
_focusedWidget->handleMouseDown(x - (_focusedWidget->getAbsX() - _x), y - (_focusedWidget->getAbsY() - _y), button, clickCount);
|
_focusedWidget->handleMouseDown(x - (_focusedWidget->getAbsX() - _x), y - (_focusedWidget->getAbsY() - _y), button, clickCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::handleMouseUp(int x, int y, int button, int clickCount) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::handleMouseUp(int x, int y, int button, int clickCount)
|
||||||
|
{
|
||||||
Widget* w;
|
Widget* w;
|
||||||
|
|
||||||
if (_focusedWidget) {
|
if(_focusedWidget)
|
||||||
|
{
|
||||||
w = _focusedWidget;
|
w = _focusedWidget;
|
||||||
|
|
||||||
// Lose focus on mouseup unless the widget requested to retain the focus
|
// Lose focus on mouseup unless the widget requested to retain the focus
|
||||||
if (! (_focusedWidget->getFlags() & WIDGET_RETAIN_FOCUS )) {
|
if(! (_focusedWidget->getFlags() & WIDGET_RETAIN_FOCUS ))
|
||||||
releaseFocus();
|
releaseFocus();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
} else {
|
|
||||||
w = findWidget(x, y);
|
w = findWidget(x, y);
|
||||||
}
|
|
||||||
|
|
||||||
if(w)
|
if(w)
|
||||||
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
|
w->handleMouseUp(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button, clickCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::handleMouseWheel(int x, int y, int direction) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::handleMouseWheel(int x, int y, int direction)
|
||||||
|
{
|
||||||
Widget* w;
|
Widget* w;
|
||||||
|
|
||||||
// This may look a bit backwards, but I think it makes more sense for
|
// This may look a bit backwards, but I think it makes more sense for
|
||||||
|
@ -171,18 +200,22 @@ void Dialog::handleMouseWheel(int x, int y, int direction) {
|
||||||
w->handleMouseWheel(x, y, direction);
|
w->handleMouseWheel(x, y, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if (_focusedWidget) {
|
void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers)
|
||||||
|
{
|
||||||
|
if(_focusedWidget)
|
||||||
if (_focusedWidget->handleKeyDown(ascii, keycode, modifiers))
|
if (_focusedWidget->handleKeyDown(ascii, keycode, modifiers))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Hotkey handling
|
// Hotkey handling
|
||||||
if (ascii != 0) {
|
if(ascii != 0)
|
||||||
|
{
|
||||||
Widget* w = _firstWidget;
|
Widget* w = _firstWidget;
|
||||||
ascii = toupper(ascii);
|
ascii = toupper(ascii);
|
||||||
while (w) {
|
while(w)
|
||||||
if (w->_type == kButtonWidget && ascii == toupper(((ButtonWidget *)w)->_hotkey)) {
|
{
|
||||||
|
if(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.
|
||||||
w->handleMouseDown(0, 0, 1, 1);
|
w->handleMouseDown(0, 0, 1, 1);
|
||||||
|
@ -202,16 +235,21 @@ void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
||||||
// TODO: tab/shift-tab should focus the next/previous focusable widget
|
// TODO: tab/shift-tab should focus the next/previous focusable widget
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::handleKeyUp(uint16 ascii, int keycode, int modifiers)
|
||||||
|
{
|
||||||
// Focused widget receives keyup events
|
// Focused widget receives keyup events
|
||||||
if(_focusedWidget)
|
if(_focusedWidget)
|
||||||
_focusedWidget->handleKeyUp(ascii, keycode, modifiers);
|
_focusedWidget->handleKeyUp(ascii, keycode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::handleMouseMoved(int x, int y, int button) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::handleMouseMoved(int x, int y, int button)
|
||||||
|
{
|
||||||
Widget* w;
|
Widget* w;
|
||||||
|
|
||||||
if (_focusedWidget) {
|
if(_focusedWidget)
|
||||||
|
{
|
||||||
w = _focusedWidget;
|
w = _focusedWidget;
|
||||||
int wx = w->getAbsX() - _x;
|
int wx = w->getAbsX() - _x;
|
||||||
int wy = w->getAbsY() - _y;
|
int wy = w->getAbsY() - _y;
|
||||||
|
@ -219,10 +257,13 @@ void Dialog::handleMouseMoved(int x, int y, int button) {
|
||||||
// We still send mouseEntered/Left messages to the focused item
|
// We still send mouseEntered/Left messages to the focused item
|
||||||
// (but to no other items).
|
// (but to no other items).
|
||||||
bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h);
|
bool mouseInFocusedWidget = (x >= wx && x < wx + w->_w && y >= wy && y < wy + w->_h);
|
||||||
if (mouseInFocusedWidget && _mouseWidget != w) {
|
if(mouseInFocusedWidget && _mouseWidget != w)
|
||||||
|
{
|
||||||
_mouseWidget = w;
|
_mouseWidget = w;
|
||||||
w->handleMouseEntered(button);
|
w->handleMouseEntered(button);
|
||||||
} else if (!mouseInFocusedWidget && _mouseWidget == w) {
|
}
|
||||||
|
else if (!mouseInFocusedWidget && _mouseWidget == w)
|
||||||
|
{
|
||||||
_mouseWidget = 0;
|
_mouseWidget = 0;
|
||||||
w->handleMouseLeft(button);
|
w->handleMouseLeft(button);
|
||||||
}
|
}
|
||||||
|
@ -232,30 +273,35 @@ void Dialog::handleMouseMoved(int x, int y, int button) {
|
||||||
|
|
||||||
w = findWidget(x, y);
|
w = findWidget(x, y);
|
||||||
|
|
||||||
if (_mouseWidget != w) {
|
if(_mouseWidget != w)
|
||||||
|
{
|
||||||
if(_mouseWidget)
|
if(_mouseWidget)
|
||||||
_mouseWidget->handleMouseLeft(button);
|
_mouseWidget->handleMouseLeft(button);
|
||||||
if(w)
|
if(w)
|
||||||
w->handleMouseEntered(button);
|
w->handleMouseEntered(button);
|
||||||
|
|
||||||
_mouseWidget = w;
|
_mouseWidget = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!w || !(w->getFlags() & WIDGET_TRACK_MOUSE)) {
|
if(!w || !(w->getFlags() & WIDGET_TRACK_MOUSE))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
|
w->handleMouseMoved(x - (w->getAbsX() - _x), y - (w->getAbsY() - _y), button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::handleTickle() {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Dialog::handleTickle()
|
||||||
|
{
|
||||||
// Focused widget receives tickle notifications
|
// Focused widget receives tickle notifications
|
||||||
if (_focusedWidget && _focusedWidget->getFlags() & WIDGET_WANT_TICKLE) {
|
if(_focusedWidget && _focusedWidget->getFlags() & WIDGET_WANT_TICKLE)
|
||||||
_focusedWidget->handleTickle();
|
_focusedWidget->handleTickle();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
switch (cmd) {
|
void Dialog::handleCommand(CommandSender* sender, uint32 cmd, uint32 data)
|
||||||
|
{
|
||||||
|
switch(cmd)
|
||||||
|
{
|
||||||
case kCloseCmd:
|
case kCloseCmd:
|
||||||
close();
|
close();
|
||||||
break;
|
break;
|
||||||
|
@ -266,12 +312,15 @@ void Dialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||||
* Determine the widget at location (x,y) if any. Assumes the coordinates are
|
* Determine the widget at location (x,y) if any. Assumes the coordinates are
|
||||||
* in the local coordinate system, i.e. relative to the top left of the dialog.
|
* in the local coordinate system, i.e. relative to the top left of the dialog.
|
||||||
*/
|
*/
|
||||||
Widget *Dialog::findWidget(int x, int y) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
Widget* Dialog::findWidget(int x, int y)
|
||||||
|
{
|
||||||
return Widget::findWidgetInChain(_firstWidget, x, y);
|
return Widget::findWidgetInChain(_firstWidget, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget *Dialog::addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
ButtonWidget* Dialog::addButton(int x, int y, const string &label,
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace GUI
|
|
||||||
|
|
|
@ -13,32 +13,34 @@
|
||||||
// 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.1 2005-02-27 23:41:19 stephena Exp $
|
// $Id: Dialog.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef DIALOG_HXX
|
#ifndef DIALOG_HXX
|
||||||
#define DIALOG_HXX
|
#define DIALOG_HXX
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "Command.hxx"
|
||||||
|
#include "Widget.hxx"
|
||||||
|
#include "GuiObject.hxx"
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
|
||||||
#include "common/str.h"
|
|
||||||
|
|
||||||
#include "gui/object.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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.1 2005-02-27 23:41:19 stephena Exp $
|
@version $Id: Dialog.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Dialog
|
class Dialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Dialog(uInt16 x, uInt16 y, uInt16 w, uInt16 h)
|
Dialog(uInt16 x, uInt16 y, uInt16 w, uInt16 h);
|
||||||
: GuiObject(x, y, w, h),
|
|
||||||
_mouseWidget(0), _focusedWidget(0), _visible(false) {
|
|
||||||
}
|
|
||||||
virtual ~Dialog();
|
virtual ~Dialog();
|
||||||
|
|
||||||
virtual int runModal();
|
virtual int runModal();
|
||||||
|
@ -47,31 +49,31 @@ class Dialog
|
||||||
|
|
||||||
void releaseFocus();
|
void releaseFocus();
|
||||||
|
|
||||||
|
virtual void drawDialog();
|
||||||
|
|
||||||
|
virtual void handleKeyDown(SDLKey key, SDLMod mod);
|
||||||
|
virtual void handleKeyUp(SDLKey key, SDLMod mod);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void open();
|
virtual void open();
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
virtual void drawDialog();
|
|
||||||
|
|
||||||
virtual void handleTickle(); // Called periodically (in every guiloop() )
|
virtual void handleTickle(); // Called periodically (in every guiloop() )
|
||||||
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
virtual void handleMouseDown(int x, int y, int button, int clickCount);
|
||||||
virtual void handleMouseUp(int x, int y, int button, int clickCount);
|
virtual void handleMouseUp(int x, int y, int button, int clickCount);
|
||||||
virtual void handleMouseWheel(int x, int y, int direction);
|
virtual void handleMouseWheel(int x, int y, int direction);
|
||||||
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
|
|
||||||
virtual void handleKeyUp(uint16 ascii, int keycode, int modifiers);
|
|
||||||
virtual void handleMouseMoved(int x, int y, int button);
|
virtual void handleMouseMoved(int x, int y, int button);
|
||||||
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data);
|
||||||
virtual void handleScreenChanged() {}
|
virtual void handleScreenChanged() {}
|
||||||
|
|
||||||
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
|
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any
|
||||||
|
|
||||||
ButtonWidget *addButton(int x, int y, const Common::String &label, uint32 cmd, char hotkey);
|
ButtonWidget* addButton(int x, int y, const string& label, uInt32 cmd, char hotkey);
|
||||||
|
|
||||||
void setResult(int result) { _result = result; }
|
void setResult(int result) { _result = result; }
|
||||||
int getResult() const { return _result; }
|
int getResult() const { return _result; }
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Widget* _mouseWidget;
|
Widget* _mouseWidget;
|
||||||
Widget* _focusedWidget;
|
Widget* _focusedWidget;
|
||||||
|
@ -79,9 +81,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _result;
|
int _result;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace GUI
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
// 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.1 2005-02-27 23:41:19 stephena Exp $
|
// $Id: GuiObject.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef GUI_OBJECT_HXX
|
#ifndef GUI_OBJECT_HXX
|
||||||
|
@ -21,20 +24,26 @@
|
||||||
|
|
||||||
class Widget;
|
class Widget;
|
||||||
|
|
||||||
|
#include "Command.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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.1 2005-02-27 23:41:19 stephena Exp $
|
@version $Id: GuiObject.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class GuiObject
|
class GuiObject : public CommandReceiver
|
||||||
{
|
{
|
||||||
//friend class Widget;
|
friend class Widget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GuiObject(int x, int y, int w, int h) : _x(x), _y(y), _w(w), _h(h), _firstWidget(0) { }
|
GuiObject(int x, int y, int w, int h)
|
||||||
|
: _x(x),
|
||||||
|
_y(y),
|
||||||
|
_w(w),
|
||||||
|
_h(h),
|
||||||
|
_firstWidget(0) { }
|
||||||
|
|
||||||
virtual Int16 getAbsX() const { return _x; }
|
virtual Int16 getAbsX() const { return _x; }
|
||||||
virtual Int16 getAbsY() const { return _y; }
|
virtual Int16 getAbsY() const { return _y; }
|
||||||
|
@ -44,7 +53,6 @@ class GuiObject
|
||||||
virtual uInt16 getHeight() const { return _h; }
|
virtual uInt16 getHeight() const { return _h; }
|
||||||
|
|
||||||
virtual bool isVisible() const = 0;
|
virtual bool isVisible() const = 0;
|
||||||
|
|
||||||
virtual void draw() = 0;
|
virtual void draw() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -13,35 +13,88 @@
|
||||||
// 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.cxx,v 1.1 2005-02-27 23:41:19 stephena Exp $
|
// $Id: Menu.cxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "OSystem.hxx"
|
||||||
|
#include "Dialog.hxx"
|
||||||
|
#include "OptionsDialog.hxx"
|
||||||
|
#include "Stack.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
#include "Menu.hxx"
|
#include "Menu.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Menu::Menu()
|
Menu::Menu(OSystem* osystem)
|
||||||
|
: myOSystem(osystem),
|
||||||
|
myOptionsDialog(NULL)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
cerr << "Menu::Menu()\n";
|
cerr << "Menu::Menu()\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
myOSystem->attach(this);
|
||||||
|
|
||||||
|
// Create a stack to hold the various dialog boxes
|
||||||
|
|
||||||
|
// Create the top-level menu
|
||||||
|
myOptionsDialog = new OptionsDialog(myOSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Menu::~Menu()
|
Menu::~Menu()
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
cerr << "Menu::~Menu()\n";
|
cerr << "Menu::~Menu()\n";
|
||||||
}
|
#endif
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
delete myOptionsDialog;
|
||||||
void Menu::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
|
||||||
{
|
|
||||||
cerr << "Menu::handleKeyEvent()\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Menu::draw()
|
void Menu::draw()
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
cerr << "Menu::draw()\n";
|
cerr << "Menu::draw()\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Draw all the dialogs on the stack
|
||||||
|
for(Int32 i = 0; i < myDialogStack.size(); i++)
|
||||||
|
myDialogStack[i]->drawDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Menu::addDialog(Dialog* d)
|
||||||
|
{
|
||||||
|
myDialogStack.push(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Menu::removeDialog()
|
||||||
|
{
|
||||||
|
if(!myDialogStack.empty())
|
||||||
|
myDialogStack.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Menu::reset()
|
||||||
|
{
|
||||||
|
// Pop all items from the stack, and then add the base menu
|
||||||
|
for(Int32 i = 0; i < myDialogStack.size(); i++)
|
||||||
|
myDialogStack.pop();
|
||||||
|
|
||||||
|
myDialogStack.push(myOptionsDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void Menu::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
||||||
|
{
|
||||||
|
// Send the event to the dialog box on the top of the stack
|
||||||
|
Dialog* activeDialog = myDialogStack.top();
|
||||||
|
|
||||||
|
if(state == 1)
|
||||||
|
activeDialog->handleKeyDown(key, mod);
|
||||||
|
else
|
||||||
|
activeDialog->handleKeyUp(key, mod);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,21 @@
|
||||||
// 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.1 2005-02-27 23:41:19 stephena Exp $
|
// $Id: Menu.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef MENU_HXX
|
#ifndef MENU_HXX
|
||||||
#define MENU_HXX
|
#define MENU_HXX
|
||||||
|
|
||||||
|
class Dialog;
|
||||||
|
class OSystem;
|
||||||
|
class OptionsDialog;
|
||||||
|
|
||||||
|
#include "Stack.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
typedef FixedStack<Dialog *> DialogStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The base class for all menus in Stella.
|
The base class for all menus in Stella.
|
||||||
|
|
||||||
|
@ -28,7 +35,7 @@
|
||||||
a stack, and handles their events.
|
a stack, and handles their events.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: Menu.hxx,v 1.1 2005-02-27 23:41:19 stephena Exp $
|
@version $Id: Menu.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Menu
|
class Menu
|
||||||
{
|
{
|
||||||
|
@ -36,7 +43,7 @@ class Menu
|
||||||
/**
|
/**
|
||||||
Create a new menu stack
|
Create a new menu stack
|
||||||
*/
|
*/
|
||||||
Menu();
|
Menu(OSystem* osystem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destructor
|
Destructor
|
||||||
|
@ -60,8 +67,25 @@ class Menu
|
||||||
*/
|
*/
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
private:
|
/**
|
||||||
|
Add a dialog box to the stack
|
||||||
|
*/
|
||||||
|
void addDialog(Dialog* d);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Remove the topmost dialog box from the stack
|
||||||
|
*/
|
||||||
|
void removeDialog();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reset dialog stack to the main configuration menu
|
||||||
|
*/
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
private:
|
||||||
|
OSystem* myOSystem;
|
||||||
|
OptionsDialog* myOptionsDialog;
|
||||||
|
DialogStack myDialogStack;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,638 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// SSSS tt lll lll
|
||||||
|
// SS SS tt ll ll
|
||||||
|
// SS tttttt eeee ll ll aaaa
|
||||||
|
// SSSS tt ee ee ll ll aa
|
||||||
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
|
// SS SS tt ee ll ll aa aa
|
||||||
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
|
//
|
||||||
|
// Copyright (c) 1995-2005 by Bradford W. Mott
|
||||||
|
//
|
||||||
|
// 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.1 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
|
#include "gui/chooser.h"
|
||||||
|
#include "gui/newgui.h"
|
||||||
|
#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;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using GUI::CommandSender;
|
||||||
|
using GUI::StaticTextWidget;
|
||||||
|
using GUI::kButtonWidth;
|
||||||
|
using GUI::kCloseCmd;
|
||||||
|
using GUI::kTextAlignCenter;
|
||||||
|
using GUI::kTextAlignLeft;
|
||||||
|
using GUI::WIDGET_ENABLED;
|
||||||
|
|
||||||
|
typedef GUI::OptionsDialog GUI_OptionsDialog;
|
||||||
|
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 {
|
||||||
|
kSaveCmd = 'SAVE',
|
||||||
|
kLoadCmd = 'LOAD',
|
||||||
|
kPlayCmd = 'PLAY',
|
||||||
|
kOptionsCmd = 'OPTN',
|
||||||
|
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 {
|
||||||
|
kRowHeight = 18,
|
||||||
|
kBigButtonWidth = 90,
|
||||||
|
kMainMenuWidth = (kBigButtonWidth + 2 * 8),
|
||||||
|
kMainMenuHeight = 7 * kRowHeight + 3 * 5 + 7 + 5
|
||||||
|
};
|
||||||
|
|
||||||
|
#define addBigButton(label, cmd, hotkey) \
|
||||||
|
new GUI::ButtonWidget(this, x, y, kBigButtonWidth, 16, label, cmd, hotkey); y += kRowHeight
|
||||||
|
|
||||||
|
MainMenuDialog::MainMenuDialog(ScummEngine *scumm)
|
||||||
|
: ScummDialog(scumm, (320 - kMainMenuWidth) / 2, (200 - kMainMenuHeight)/2, kMainMenuWidth, kMainMenuHeight) {
|
||||||
|
int y = 7;
|
||||||
|
|
||||||
|
const int x = (_w - kBigButtonWidth) / 2;
|
||||||
|
addBigButton("Resume", kPlayCmd, 'P');
|
||||||
|
y += 5;
|
||||||
|
|
||||||
|
addBigButton("Load", kLoadCmd, 'L');
|
||||||
|
addBigButton("Save", kSaveCmd, 'S');
|
||||||
|
y += 5;
|
||||||
|
|
||||||
|
addBigButton("Options", kOptionsCmd, 'O');
|
||||||
|
#ifndef DISABLE_HELP
|
||||||
|
addBigButton("Help", kHelpCmd, 'H');
|
||||||
|
#endif
|
||||||
|
addBigButton("About", kAboutCmd, 'A');
|
||||||
|
y += 5;
|
||||||
|
|
||||||
|
addBigButton("Quit", kQuitCmd, 'Q');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create the sub dialog(s)
|
||||||
|
//
|
||||||
|
_aboutDialog = new GUI::AboutDialog();
|
||||||
|
#ifndef DISABLE_HELP
|
||||||
|
_helpDialog = new HelpDialog(scumm);
|
||||||
|
#endif
|
||||||
|
_saveDialog = new SaveLoadChooser("Save game:", "Save", true);
|
||||||
|
_loadDialog = new SaveLoadChooser("Load game:", "Load", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
MainMenuDialog::~MainMenuDialog() {
|
||||||
|
delete _aboutDialog;
|
||||||
|
#ifndef DISABLE_HELP
|
||||||
|
delete _helpDialog;
|
||||||
|
#endif
|
||||||
|
delete _saveDialog;
|
||||||
|
delete _loadDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||||
|
switch (cmd) {
|
||||||
|
case kSaveCmd:
|
||||||
|
save();
|
||||||
|
break;
|
||||||
|
case kLoadCmd:
|
||||||
|
load();
|
||||||
|
break;
|
||||||
|
case kPlayCmd:
|
||||||
|
close();
|
||||||
|
break;
|
||||||
|
case kOptionsCmd:
|
||||||
|
_vm->optionsDialog();
|
||||||
|
break;
|
||||||
|
case kAboutCmd:
|
||||||
|
_aboutDialog->runModal();
|
||||||
|
break;
|
||||||
|
#ifndef DISABLE_HELP
|
||||||
|
case kHelpCmd:
|
||||||
|
_helpDialog->runModal();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case kQuitCmd:
|
||||||
|
_vm->_quit = true;
|
||||||
|
close();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ScummDialog::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
|
|
@ -0,0 +1,54 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// SSSS tt lll lll
|
||||||
|
// SS SS tt ll ll
|
||||||
|
// SS tttttt eeee ll ll aaaa
|
||||||
|
// SSSS tt ee ee ll ll aa
|
||||||
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
|
// SS SS tt ee ll ll aa aa
|
||||||
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
|
//
|
||||||
|
// Copyright (c) 1995-2005 by Bradford W. Mott
|
||||||
|
//
|
||||||
|
// See the file "license" for information on usage and redistribution of
|
||||||
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
//
|
||||||
|
// $Id: OptionsDialog.hxx,v 1.1 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#ifndef OPTIONS_DIALOG_HXX
|
||||||
|
#define OPTIONS_DIALOG_HXX
|
||||||
|
|
||||||
|
class CommandSender;
|
||||||
|
class Dialog;
|
||||||
|
class VideoDialog;
|
||||||
|
class AudioDialog;
|
||||||
|
class EventMappingDialog;
|
||||||
|
class MiscDialog;
|
||||||
|
class GameInfoDialog;
|
||||||
|
class HelpDialog;
|
||||||
|
|
||||||
|
#include "OSystem.hxx"
|
||||||
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
class OptionsDialog : public Dialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OptionsDialog(OSystem* osystem);
|
||||||
|
~OptionsDialog();
|
||||||
|
|
||||||
|
virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
VideoDialog* myVideoDialog;
|
||||||
|
AudioDialog* myAudioDialog;
|
||||||
|
EventMappingDialog* myEventMappingDialog;
|
||||||
|
MiscDialog* myMiscDialog;
|
||||||
|
GameInfoDialog* myGameInfoDialog;
|
||||||
|
HelpDialog* myHelpDialog;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,70 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// SSSS tt lll lll
|
||||||
|
// SS SS tt ll ll
|
||||||
|
// SS tttttt eeee ll ll aaaa
|
||||||
|
// SSSS tt ee ee ll ll aa
|
||||||
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
|
// SS SS tt ee ll ll aa aa
|
||||||
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
|
//
|
||||||
|
// Copyright (c) 1995-2005 by Bradford W. Mott
|
||||||
|
//
|
||||||
|
// See the file "license" for information on usage and redistribution of
|
||||||
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
//
|
||||||
|
// $Id: Stack.hxx,v 1.1 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#ifndef STACK_HXX
|
||||||
|
#define STACK_HXX
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extremly simple fixed size stack class.
|
||||||
|
*/
|
||||||
|
template <class T, int MAX_SIZE = 10>
|
||||||
|
class FixedStack
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FixedStack<T, MAX_SIZE>() : _size(0) {}
|
||||||
|
|
||||||
|
bool empty() const { return _size <= 0; }
|
||||||
|
void clear() { _size = 0; }
|
||||||
|
void push(const T& x)
|
||||||
|
{
|
||||||
|
assert(_size < MAX_SIZE);
|
||||||
|
_stack[_size++] = x;
|
||||||
|
}
|
||||||
|
T top() const
|
||||||
|
{
|
||||||
|
if(_size > 0)
|
||||||
|
return _stack[_size - 1];
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
T pop()
|
||||||
|
{
|
||||||
|
T tmp;
|
||||||
|
assert(_size > 0);
|
||||||
|
tmp = _stack[_size - 1];
|
||||||
|
_stack[--_size] = 0;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
int size() const { return _size; }
|
||||||
|
T operator [](int i)
|
||||||
|
{
|
||||||
|
assert(0 <= i && i < MAX_SIZE);
|
||||||
|
return _stack[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
T _stack[MAX_SIZE];
|
||||||
|
int _size;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -13,7 +13,10 @@
|
||||||
// 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.1 2005-02-27 23:41:19 stephena Exp $
|
// $Id: Widget.cxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "Dialog.hxx"
|
#include "Dialog.hxx"
|
||||||
|
@ -24,8 +27,12 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Widget::Widget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h)
|
Widget::Widget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h)
|
||||||
: GuiObject(x, y, w, h), _type(0), _boss(boss),
|
: GuiObject(x, y, w, h),
|
||||||
_id(0), _flags(0), _hasFocus(false)
|
_type(0),
|
||||||
|
_boss(boss),
|
||||||
|
_id(0),
|
||||||
|
_flags(0),
|
||||||
|
_hasFocus(false)
|
||||||
{
|
{
|
||||||
// Insert into the widget list of the boss
|
// Insert into the widget list of the boss
|
||||||
_next = _boss->_firstWidget;
|
_next = _boss->_firstWidget;
|
||||||
|
@ -41,7 +48,7 @@ Widget::~Widget()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Widget::draw()
|
void Widget::draw()
|
||||||
{
|
{
|
||||||
NewGui *gui = &g_gui;
|
FrameBuffer* fb = _boss->instance().frameBuffer();
|
||||||
|
|
||||||
if(!isVisible() || !_boss->isVisible())
|
if(!isVisible() || !_boss->isVisible())
|
||||||
return;
|
return;
|
||||||
|
@ -88,69 +95,88 @@ void Widget::draw()
|
||||||
|
|
||||||
// Draw all children
|
// Draw all children
|
||||||
Widget* w = _firstWidget;
|
Widget* w = _firstWidget;
|
||||||
while (w) {
|
while(w)
|
||||||
|
{
|
||||||
w->draw();
|
w->draw();
|
||||||
w = w->_next;
|
w = w->_next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget *Widget::findWidgetInChain(Widget *w, int x, int y) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
while (w) {
|
Widget* Widget::findWidgetInChain(Widget *w, int x, int y)
|
||||||
|
{
|
||||||
|
while(w)
|
||||||
|
{
|
||||||
// Stop as soon as we find a widget that contains the point (x,y)
|
// Stop as soon as we find a widget that contains the point (x,y)
|
||||||
if(x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->_h)
|
if(x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->_h)
|
||||||
break;
|
break;
|
||||||
w = w->_next;
|
w = w->_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(w)
|
if(w)
|
||||||
w = w->findWidget(x - w->_x, y - w->_y);
|
w = w->findWidget(x - w->_x, y - w->_y);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h,
|
||||||
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int 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;
|
||||||
setLabel(text);
|
setLabel(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticTextWidget::setValue(int value) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void StaticTextWidget::setValue(int value)
|
||||||
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
sprintf(buf, "%d", value);
|
sprintf(buf, "%d", value);
|
||||||
_label = buf;
|
_label = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticTextWidget::drawWidget(bool hilite) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void StaticTextWidget::drawWidget(bool hilite)
|
||||||
|
{
|
||||||
NewGui *gui = &g_gui;
|
NewGui *gui = &g_gui;
|
||||||
gui->drawString(_label, _x, _y, _w, isEnabled() ? gui->_textcolor : gui->_color, _align);
|
gui->drawString(_label, _x, _y, _w,
|
||||||
|
isEnabled() ? gui->_textcolor : gui->_color, _align);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h,
|
||||||
ButtonWidget::ButtonWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
|
const string& label, uint32 cmd, uint8 hotkey)
|
||||||
: StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter), CommandSender(boss),
|
: StaticTextWidget(boss, x, y, w, h, label, kTextAlignCenter),
|
||||||
_cmd(cmd), _hotkey(hotkey) {
|
CommandSender(boss),
|
||||||
|
_cmd(cmd),
|
||||||
|
_hotkey(hotkey)
|
||||||
|
{
|
||||||
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
|
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
|
||||||
_type = kButtonWidget;
|
_type = kButtonWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void ButtonWidget::handleMouseUp(int x, int y, int button, int 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget::drawWidget(bool hilite) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void ButtonWidget::drawWidget(bool hilite)
|
||||||
|
{
|
||||||
NewGui *gui = &g_gui;
|
NewGui *gui = &g_gui;
|
||||||
gui->drawString(_label, _x, _y + (_h - kLineHeight)/2 + 1, _w,
|
gui->drawString(_label, _x, _y + (_h - kLineHeight)/2 + 1, _w,
|
||||||
!isEnabled() ? gui->_color :
|
!isEnabled() ? gui->_color :
|
||||||
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
|
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
/* 8x8 checkbox bitmap */
|
/* 8x8 checkbox bitmap */
|
||||||
static uint32 checked_img[8] = {
|
static uint32 checked_img[8] =
|
||||||
|
{
|
||||||
0x00000000,
|
0x00000000,
|
||||||
0x01000010,
|
0x01000010,
|
||||||
0x00100100,
|
0x00100100,
|
||||||
|
@ -161,20 +187,28 @@ static uint32 checked_img[8] = {
|
||||||
0x00000000,
|
0x00000000,
|
||||||
};
|
};
|
||||||
|
|
||||||
CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint32 cmd, uint8 hotkey)
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _state(false) {
|
CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h,
|
||||||
|
const string& label, uint32 cmd, uint8 hotkey)
|
||||||
|
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
|
||||||
|
_state(false)
|
||||||
|
{
|
||||||
_flags = WIDGET_ENABLED;
|
_flags = WIDGET_ENABLED;
|
||||||
_type = kCheckboxWidget;
|
_type = kCheckboxWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) {
|
void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
||||||
|
{
|
||||||
|
if(isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h)
|
||||||
toggleState();
|
toggleState();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CheckboxWidget::setState(bool state) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if (_state != state) {
|
void CheckboxWidget::setState(bool state)
|
||||||
|
{
|
||||||
|
if(_state != state)
|
||||||
|
{
|
||||||
_state = state;
|
_state = state;
|
||||||
_flags ^= WIDGET_INV_BORDER;
|
_flags ^= WIDGET_INV_BORDER;
|
||||||
draw();
|
draw();
|
||||||
|
@ -182,7 +216,9 @@ void CheckboxWidget::setState(bool state) {
|
||||||
sendCommand(_cmd, _state);
|
sendCommand(_cmd, _state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckboxWidget::drawWidget(bool hilite) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void CheckboxWidget::drawWidget(bool hilite)
|
||||||
|
{
|
||||||
NewGui *gui = &g_gui;
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
// Draw the box
|
// Draw the box
|
||||||
|
@ -190,35 +226,47 @@ void CheckboxWidget::drawWidget(bool hilite) {
|
||||||
|
|
||||||
// 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, isEnabled() ? gui->_textcolor : gui->_color);
|
gui->drawBitmap(checked_img, _x + 3, _y + 3,
|
||||||
|
isEnabled() ? gui->_textcolor : gui->_color);
|
||||||
else
|
else
|
||||||
gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor);
|
gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor);
|
||||||
|
|
||||||
// Finally draw the label
|
// Finally draw the label
|
||||||
gui->drawString(_label, _x + 20, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color);
|
gui->drawString(_label, _x + 20, _y + 3, _w,
|
||||||
|
isEnabled() ? gui->_textcolor : gui->_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h,
|
||||||
SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, const String &label, uint labelWidth, uint32 cmd, uint8 hotkey)
|
const string& label, uint labelWidth, uint32 cmd, uint8 hotkey)
|
||||||
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
|
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey),
|
||||||
_value(0), _oldValue(0),_valueMin(0), _valueMax(100), _isDragging(false),
|
_value(0),
|
||||||
_labelWidth(labelWidth) {
|
_oldValue(0),
|
||||||
|
_valueMin(0),
|
||||||
|
_valueMax(100),
|
||||||
|
_isDragging(false),
|
||||||
|
_labelWidth(labelWidth)
|
||||||
|
{
|
||||||
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
|
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG;
|
||||||
_type = kSliderWidget;
|
_type = kSliderWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::handleMouseMoved(int x, int y, int button) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void SliderWidget::handleMouseMoved(int x, int y, int 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);
|
int newValue = posToValue(x - _labelWidth);
|
||||||
|
|
||||||
if(newValue < _valueMin)
|
if(newValue < _valueMin)
|
||||||
newValue = _valueMin;
|
newValue = _valueMin;
|
||||||
else if (newValue > _valueMax)
|
else if (newValue > _valueMax)
|
||||||
newValue = _valueMax;
|
newValue = _valueMax;
|
||||||
|
|
||||||
if (newValue != _value) {
|
if(newValue != _value)
|
||||||
|
{
|
||||||
_value = newValue;
|
_value = newValue;
|
||||||
draw();
|
draw();
|
||||||
sendCommand(_cmd, _value); // FIXME - hack to allow for "live update" in sound dialog
|
sendCommand(_cmd, _value); // FIXME - hack to allow for "live update" in sound dialog
|
||||||
|
@ -226,26 +274,34 @@ void SliderWidget::handleMouseMoved(int x, int y, int button) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if (isEnabled()) {
|
void SliderWidget::handleMouseDown(int x, int y, int button, int clickCount)
|
||||||
|
{
|
||||||
|
if(isEnabled())
|
||||||
|
{
|
||||||
_isDragging = true;
|
_isDragging = true;
|
||||||
handleMouseMoved(x, y, button);
|
handleMouseMoved(x, y, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if (isEnabled() && _isDragging) {
|
void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount)
|
||||||
|
{
|
||||||
|
if(isEnabled() && _isDragging)
|
||||||
sendCommand(_cmd, _value);
|
sendCommand(_cmd, _value);
|
||||||
}
|
|
||||||
_isDragging = false;
|
_isDragging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::drawWidget(bool hilite) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void SliderWidget::drawWidget(bool hilite)
|
||||||
|
{
|
||||||
NewGui *gui = &g_gui;
|
NewGui *gui = &g_gui;
|
||||||
|
|
||||||
// Draw the label, if any
|
// Draw the label, if any
|
||||||
if(_labelWidth > 0)
|
if(_labelWidth > 0)
|
||||||
gui->drawString(_label, _x, _y + 2, _labelWidth, isEnabled() ? gui->_textcolor : gui->_color, kTextAlignRight);
|
gui->drawString(_label, _x, _y + 2, _labelWidth,
|
||||||
|
isEnabled() ? gui->_textcolor : gui->_color, kTextAlignRight);
|
||||||
|
|
||||||
// Draw the box
|
// Draw the box
|
||||||
gui->box(_x + _labelWidth, _y, _w - _labelWidth, _h, gui->_color, gui->_shadowcolor);
|
gui->box(_x + _labelWidth, _y, _w - _labelWidth, _h, gui->_color, gui->_shadowcolor);
|
||||||
|
@ -256,12 +312,14 @@ void SliderWidget::drawWidget(bool hilite) {
|
||||||
hilite ? gui->_textcolorhi : gui->_textcolor);
|
hilite ? gui->_textcolorhi : gui->_textcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SliderWidget::valueToPos(int value) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
int SliderWidget::valueToPos(int value)
|
||||||
|
{
|
||||||
return ((_w - _labelWidth - 4) * (value - _valueMin) / (_valueMax - _valueMin));
|
return ((_w - _labelWidth - 4) * (value - _valueMin) / (_valueMax - _valueMin));
|
||||||
}
|
}
|
||||||
|
|
||||||
int SliderWidget::posToValue(int pos) {
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
int SliderWidget::posToValue(int pos)
|
||||||
|
{
|
||||||
return (pos) * (_valueMax - _valueMin) / (_w - _labelWidth - 4) + _valueMin;
|
return (pos) * (_valueMax - _valueMin) / (_w - _labelWidth - 4) + _valueMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace GUI
|
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
// 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.1 2005-02-27 23:41:19 stephena Exp $
|
// $Id: Widget.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
|
//
|
||||||
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef WIDGET_HXX
|
#ifndef WIDGET_HXX
|
||||||
|
@ -24,12 +27,23 @@ class Dialog;
|
||||||
#include "GuiObject.hxx"
|
#include "GuiObject.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
WIDGET_ENABLED = 1 << 0,
|
||||||
|
WIDGET_INVISIBLE = 1 << 1,
|
||||||
|
WIDGET_HILITED = 1 << 2,
|
||||||
|
WIDGET_BORDER = 1 << 3,
|
||||||
|
WIDGET_INV_BORDER = 1 << 4,
|
||||||
|
WIDGET_CLEARBG = 1 << 5,
|
||||||
|
WIDGET_WANT_TICKLE = 1 << 7,
|
||||||
|
WIDGET_TRACK_MOUSE = 1 << 8,
|
||||||
|
WIDGET_RETAIN_FOCUS = 1 << 9
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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.1 2005-02-27 23:41:19 stephena Exp $
|
@version $Id: Widget.hxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Widget : public GuiObject
|
class Widget : public GuiObject
|
||||||
{
|
{
|
||||||
|
@ -48,8 +62,8 @@ class Widget : public GuiObject
|
||||||
virtual void handleMouseLeft(uInt32 button) {}
|
virtual void handleMouseLeft(uInt32 button) {}
|
||||||
virtual void handleMouseMoved(uInt32 x, uInt32 y, uInt32 button) {}
|
virtual void handleMouseMoved(uInt32 x, uInt32 y, uInt32 button) {}
|
||||||
virtual void handleMouseWheel(uInt32 x, uInt32 y, uInt32 direction) {}
|
virtual void handleMouseWheel(uInt32 x, uInt32 y, uInt32 direction) {}
|
||||||
//FIXME virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers) { return false; } // Return true if the event was handled
|
virtual bool handleKeyDown(uInt16 ascii, int keycode, int modifiers) { return false; }
|
||||||
//FIXME virtual bool handleKeyUp(uint16 ascii, int keycode, int modifiers) { return false; } // Return true if the event was handled
|
virtual bool handleKeyUp(uInt16 ascii, int keycode, int modifiers) { return false; }
|
||||||
virtual void handleTickle() {}
|
virtual void handleTickle() {}
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
|
@ -76,7 +90,7 @@ class Widget : public GuiObject
|
||||||
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, uInt32 cmd, uInt32 data)
|
||||||
{ assert(_boss); _boss->handleCommand(sender, cmd, data); }
|
{ assert(_boss); _boss->handleCommand(sender, cmd, data); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -97,21 +111,16 @@ class StaticTextWidget : public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StaticTextWidget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h,
|
StaticTextWidget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h,
|
||||||
const String &text, TextAlignment align);
|
const string& text);
|
||||||
void setValue(uInt32 value);
|
void setValue(uInt32 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; }
|
||||||
void setAlign(TextAlignment align) { _align = align; }
|
|
||||||
TextAlignment getAlign() const { return _align; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void drawWidget(bool hilite);
|
void drawWidget(bool hilite);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// typedef Graphics::TextAlignment TextAlignment;
|
|
||||||
|
|
||||||
string _label;
|
string _label;
|
||||||
// TextAlignment _align;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,8 +131,8 @@ class ButtonWidget : public StaticTextWidget
|
||||||
ButtonWidget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h,
|
ButtonWidget(GuiObject* boss, uInt32 x, uInt32 y, uInt32 w, uInt32 h,
|
||||||
const string& label, uInt32 cmd = 0, uInt8 hotkey = 0);
|
const string& label, uInt32 cmd = 0, uInt8 hotkey = 0);
|
||||||
|
|
||||||
void setCmd(uint32 cmd) { _cmd = cmd; }
|
void setCmd(uInt32 cmd) { _cmd = cmd; }
|
||||||
uint32 getCmd() const { return _cmd; }
|
uInt32 getCmd() const { return _cmd; }
|
||||||
|
|
||||||
void handleMouseUp(uInt32 x, uInt32 y, uInt32 button, uInt32 clickCount);
|
void handleMouseUp(uInt32 x, uInt32 y, uInt32 button, uInt32 clickCount);
|
||||||
void handleMouseEntered(uInt32 button) { setFlags(WIDGET_HILITED); draw(); }
|
void handleMouseEntered(uInt32 button) { setFlags(WIDGET_HILITED); draw(); }
|
||||||
|
|
Loading…
Reference in New Issue