diff --git a/stella/src/build/makefile b/stella/src/build/makefile index 840ce8f5a..006cf1acc 100644 --- a/stella/src/build/makefile +++ b/stella/src/build/makefile @@ -13,7 +13,7 @@ ## See the file "license" for information on usage and redistribution of ## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## -## $Id: makefile,v 1.70 2005-04-03 19:37:32 stephena Exp $ +## $Id: makefile,v 1.71 2005-04-04 02:19:19 stephena Exp $ ##============================================================================ ##============================================================================ @@ -146,9 +146,9 @@ win32-gl: ############################################################################### M6502_OBJS = D6502.o Device.o M6502.o M6502Low.o M6502Hi.o NullDev.o System.o -GUI_OBJS = StellaFont.o Menu.o Widget.o PopUpWidget.o Dialog.o \ - OptionsDialog.o VideoDialog.o AudioDialog.o \ - GameInfoDialog.o HelpDialog.o +GUI_OBJS = StellaFont.o Menu.o Widget.o PopUpWidget.o ScrollBarWidget.o ListWidget.o \ + Dialog.o OptionsDialog.o VideoDialog.o AudioDialog.o \ + EventMappingDialog.o GameInfoDialog.o HelpDialog.o CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \ CartE0.o CartE7.o CartF4.o CartF4SC.o CartF6.o CartF6SC.o \ @@ -368,6 +368,12 @@ Widget.o: $(GUI)/Widget.cxx $(GUI)/Widget.hxx PopUpWidget.o: $(GUI)/PopUpWidget.cxx $(GUI)/PopUpWidget.hxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/PopUpWidget.cxx +ScrollBarWidget.o: $(GUI)/ScrollBarWidget.cxx $(GUI)/ScrollBarWidget.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/ScrollBarWidget.cxx + +ListWidget.o: $(GUI)/ListWidget.cxx $(GUI)/ListWidget.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/ListWidget.cxx + Dialog.o: $(GUI)/Dialog.cxx $(GUI)/Dialog.hxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Dialog.cxx @@ -380,6 +386,9 @@ VideoDialog.o: $(GUI)/VideoDialog.cxx $(GUI)/VideoDialog.hxx AudioDialog.o: $(GUI)/AudioDialog.cxx $(GUI)/AudioDialog.hxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/AudioDialog.cxx +EventMappingDialog.o: $(GUI)/EventMappingDialog.cxx $(GUI)/EventMappingDialog.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/EventMappingDialog.cxx + GameInfoDialog.o: $(GUI)/GameInfoDialog.cxx $(GUI)/GameInfoDialog.hxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/GameInfoDialog.cxx diff --git a/stella/src/common/FrameBufferGL.cxx b/stella/src/common/FrameBufferGL.cxx index ad2b4a7c2..1229381e7 100644 --- a/stella/src/common/FrameBufferGL.cxx +++ b/stella/src/common/FrameBufferGL.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferGL.cxx,v 1.16 2005-04-03 19:37:32 stephena Exp $ +// $Id: FrameBufferGL.cxx,v 1.17 2005-04-04 02:19:20 stephena Exp $ //============================================================================ #include @@ -384,13 +384,6 @@ void FrameBufferGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, glRecti(x, y, x+w, y+h); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBufferGL::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color) -{ -cerr << "FrameBufferGL::frameRect()\n"; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferGL::drawChar(uInt8 chr, uInt32 xorig, uInt32 yorig, OverlayColor color) diff --git a/stella/src/common/FrameBufferGL.hxx b/stella/src/common/FrameBufferGL.hxx index d37b36747..6cc9e86a5 100644 --- a/stella/src/common/FrameBufferGL.hxx +++ b/stella/src/common/FrameBufferGL.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferGL.hxx,v 1.9 2005-03-28 00:04:53 stephena Exp $ +// $Id: FrameBufferGL.hxx,v 1.10 2005-04-04 02:19:20 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_GL_HXX @@ -33,7 +33,7 @@ class OSystem; This class implements an SDL OpenGL framebuffer. @author Stephen Anthony - @version $Id: FrameBufferGL.hxx,v 1.9 2005-03-28 00:04:53 stephena Exp $ + @version $Id: FrameBufferGL.hxx,v 1.10 2005-04-04 02:19:20 stephena Exp $ */ class FrameBufferGL : public FrameBuffer { @@ -148,18 +148,6 @@ class FrameBufferGL : public FrameBuffer virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color); - /** - This routine is called to draw a framed rectangle. - - @param x The x coordinate - @param y The y coordinate - @param w The width of the area - @param h The height of the area - @param color The color of the surrounding frame - */ - virtual void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color); - /** This routine is called to draw the specified character. diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index 018578feb..985fc60a8 100644 --- a/stella/src/common/FrameBufferSoft.cxx +++ b/stella/src/common/FrameBufferSoft.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferSoft.cxx,v 1.15 2005-03-28 20:36:39 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.16 2005-04-04 02:19:20 stephena Exp $ //============================================================================ #include @@ -385,13 +385,6 @@ void FrameBufferSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, SDL_FillRect(myScreen, &tmp, myGUIPalette[color]); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBufferSoft::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color) -{ - cerr << "FrameBufferSoft::frameRect()\n"; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSoft::drawChar(uInt8 chr, uInt32 xorig, uInt32 yorig, OverlayColor color) diff --git a/stella/src/common/FrameBufferSoft.hxx b/stella/src/common/FrameBufferSoft.hxx index d9562a736..540445aa6 100644 --- a/stella/src/common/FrameBufferSoft.hxx +++ b/stella/src/common/FrameBufferSoft.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferSoft.hxx,v 1.11 2005-03-28 00:04:53 stephena Exp $ +// $Id: FrameBufferSoft.hxx,v 1.12 2005-04-04 02:19:20 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_SOFT_HXX @@ -34,7 +34,7 @@ class RectList; This class implements an SDL software framebuffer. @author Stephen Anthony - @version $Id: FrameBufferSoft.hxx,v 1.11 2005-03-28 00:04:53 stephena Exp $ + @version $Id: FrameBufferSoft.hxx,v 1.12 2005-04-04 02:19:20 stephena Exp $ */ class FrameBufferSoft : public FrameBuffer { @@ -149,18 +149,6 @@ class FrameBufferSoft : public FrameBuffer virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color); - /** - This routine is called to draw a framed rectangle. - - @param x The x coordinate - @param y The y coordinate - @param w The width of the area - @param h The height of the area - @param color The color of the surrounding frame - */ - virtual void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color); - /** This routine is called to draw the specified character. diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index d785c1a27..e54f7f9ac 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.cxx,v 1.40 2005-04-03 19:37:32 stephena Exp $ +// $Id: EventHandler.cxx,v 1.41 2005-04-04 02:19:20 stephena Exp $ //============================================================================ #include @@ -801,3 +801,73 @@ void EventHandler::setPaddleMode(Int8 num) myOSystem->settings().setInt("paddle", myPaddleMode); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ActionList EventHandler::ourActionList[58] = { + { Event::ConsoleSelect, "Select", "" }, + { Event::ConsoleReset, "Reset", "" }, + { Event::ConsoleColor, "Color TV", "" }, + { Event::ConsoleBlackWhite, "Black & White TV", "" }, + { Event::ConsoleLeftDifficultyB, "Left Difficulty B", "" }, + { Event::ConsoleLeftDifficultyA, "Left Difficulty A", "" }, + { Event::ConsoleRightDifficultyB, "Right Difficulty B", "" }, + { Event::ConsoleRightDifficultyA, "Right Difficulty A", "" }, + { Event::SaveState, "Save State", "" }, + { Event::ChangeState, "Change State", "" }, + { Event::LoadState, "Load State", "" }, + { Event::TakeSnapshot, "Snapshot", "" }, + { Event::Pause, "Pause", "" }, + { Event::Quit, "Quit", "" }, + + { Event::JoystickZeroUp, "Left Joystick Up Direction", "" }, + { Event::JoystickZeroDown, "Left Joystick Down Direction", "" }, + { Event::JoystickZeroLeft, "Left Joystick Left Direction", "" }, + { Event::JoystickZeroRight, "Left Joystick Right Direction", "" }, + { Event::JoystickZeroFire, "Left Joystick Fire Button", "" }, + + { Event::JoystickOneUp, "Right Joystick Up Direction", "" }, + { Event::JoystickOneDown, "Right Joystick Down Direction", "" }, + { Event::JoystickOneLeft, "Right Joystick Left Direction", "" }, + { Event::JoystickOneRight, "Right Joystick Right Direction", "" }, + { Event::JoystickOneFire, "Right Joystick Fire Button", "" }, + + { Event::BoosterGripZeroTrigger, "Left Booster-Grip Trigger", "" }, + { Event::BoosterGripZeroBooster, "Left Booster-Grip Booster", "" }, + + { Event::BoosterGripOneTrigger, "Right Booster-Grip Trigger", "" }, + { Event::BoosterGripOneBooster, "Right Booster-Grip Booster", "" }, + + { Event::DrivingZeroCounterClockwise, "Left Driving Controller Left Direction", "" }, + { Event::DrivingZeroClockwise, "Left Driving Controller Right Direction", "" }, + { Event::DrivingZeroFire, "Left Driving Controller Fire Button", "" }, + + { Event::DrivingOneCounterClockwise, "Right Driving Controller Left Direction", "" }, + { Event::DrivingOneClockwise, "Right Driving Controller Right Direction", "" }, + { Event::DrivingOneFire, "Right Driving Controller Fire Button", "" }, + + { Event::KeyboardZero1, "Left GamePad 1", "" }, + { Event::KeyboardZero2, "Left GamePad 2", "" }, + { Event::KeyboardZero3, "Left GamePad 3", "" }, + { Event::KeyboardZero4, "Left GamePad 4", "" }, + { Event::KeyboardZero5, "Left GamePad 5", "" }, + { Event::KeyboardZero6, "Left GamePad 6", "" }, + { Event::KeyboardZero7, "Left GamePad 7", "" }, + { Event::KeyboardZero8, "Left GamePad 8", "" }, + { Event::KeyboardZero9, "Left GamePad 9", "" }, + { Event::KeyboardZeroStar, "Left GamePad *", "" }, + { Event::KeyboardZero0, "Left GamePad 0", "" }, + { Event::KeyboardZeroPound, "Left GamePad #", "" }, + + { Event::KeyboardOne1, "Right GamePad 1", "" }, + { Event::KeyboardOne2, "Right GamePad 2", "" }, + { Event::KeyboardOne3, "Right GamePad 3", "" }, + { Event::KeyboardOne4, "Right GamePad 4", "" }, + { Event::KeyboardOne5, "Right GamePad 5", "" }, + { Event::KeyboardOne6, "Right GamePad 6", "" }, + { Event::KeyboardOne7, "Right GamePad 7", "" }, + { Event::KeyboardOne8, "Right GamePad 8", "" }, + { Event::KeyboardOne9, "Right GamePad 9", "" }, + { Event::KeyboardOneStar, "Right GamePad *", "" }, + { Event::KeyboardOne0, "Right GamePad 0", "" }, + { Event::KeyboardOnePound, "Right GamePad #", "" } +}; diff --git a/stella/src/emucore/EventHandler.hxx b/stella/src/emucore/EventHandler.hxx index 0922ef884..85c437337 100644 --- a/stella/src/emucore/EventHandler.hxx +++ b/stella/src/emucore/EventHandler.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.hxx,v 1.20 2005-04-03 19:37:32 stephena Exp $ +// $Id: EventHandler.hxx,v 1.21 2005-04-04 02:19:21 stephena Exp $ //============================================================================ #ifndef EVENTHANDLER_HXX @@ -37,6 +37,13 @@ enum MouseButton { EVENT_WHEELUP }; +// Structure used for action menu items +struct ActionList { + Event::Type event; + string action; + string keys; +}; + /** This class takes care of event remapping and dispatching for the Stella core, as well as keeping track of the current 'mode'. @@ -50,7 +57,7 @@ enum MouseButton { mapping can take place. @author Stephen Anthony - @version $Id: EventHandler.hxx,v 1.20 2005-04-03 19:37:32 stephena Exp $ + @version $Id: EventHandler.hxx,v 1.21 2005-04-04 02:19:21 stephena Exp $ */ class EventHandler { @@ -111,6 +118,9 @@ class EventHandler */ inline bool doQuit() { return myQuitFlag; } + // Holds static strings for the remap menu + static ActionList ourActionList[58]; + void getKeymapArray(Event::Type** array, uInt32* size); void getJoymapArray(Event::Type** array, uInt32* size); diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 7c38bd2cf..f5aa16b72 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.cxx,v 1.23 2005-03-28 00:04:54 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.24 2005-04-04 02:19:21 stephena Exp $ //============================================================================ #include @@ -520,6 +520,15 @@ void FrameBuffer::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h, vLine(x + w - 2, y + 1, y + h - 1, colorB); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBuffer::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, + OverlayColor color) +{ + hLine(x, y, x + w - 1, color); + hLine(x, y + h - 1, x + w - 1, color); + vLine(x, y, y + h - 1, color); + vLine(x + w - 1, y, y + h - 1, color); +} /* // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -956,93 +965,6 @@ void FrameBuffer::deleteBinding(Event::Type event) loadRemapMenu(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const uInt8 FrameBuffer::ourFontData[2048] = { -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x81,0xa5,0x81,0xbd,0x99,0x81,0x7e,0x7e,0xff,0xdb,0xff,0xc3,0xe7,0xff,0x7e,0x36,0x7f,0x7f,0x7f,0x3e,0x1c,0x08,0x00,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x08,0x00,0x1c,0x3e,0x1c,0x7f,0x7f,0x3e,0x1c,0x3e,0x08,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x3e,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xf0,0xe0,0xf0,0xbe,0x33,0x33,0x33,0x1e,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0xfc,0xcc,0xfc,0x0c,0x0c,0x0e,0x0f,0x07,0xfe,0xc6,0xfe,0xc6,0xc6,0xe6,0x67,0x03,0x99,0x5a,0x3c,0xe7,0xe7,0x3c,0x5a,0x99,0x01,0x07,0x1f,0x7f,0x1f,0x07,0x01,0x00,0x40,0x70,0x7c,0x7f,0x7c,0x70,0x40,0x00,0x18,0x3c,0x7e,0x18,0x18,0x7e,0x3c,0x18,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x00,0xfe,0xdb,0xdb,0xde,0xd8,0xd8,0xd8,0x00,0x7c,0xc6,0x1c,0x36,0x36,0x1c,0x33,0x1e,0x00,0x00,0x00,0x00,0x7e,0x7e,0x7e,0x00,0x18,0x3c,0x7e,0x18,0x7e,0x3c,0x18,0xff,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x18,0x30,0x7f,0x30,0x18,0x00,0x00,0x00,0x0c,0x06,0x7f,0x06,0x0c,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x7f,0x00,0x00,0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0x7e,0x3c,0x18,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x1e,0x1e,0x0c,0x0c,0x00,0x0c,0x00,0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x7f,0x36,0x7f,0x36,0x36,0x00,0x0c,0x3e,0x03,0x1e,0x30,0x1f,0x0c,0x00,0x00,0x63,0x33,0x18,0x0c,0x66,0x63,0x00,0x1c,0x36,0x1c,0x6e,0x3b,0x33,0x6e,0x00,0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x18,0x0c,0x06,0x06,0x06,0x0c,0x18,0x00,0x06,0x0c,0x18,0x18,0x18,0x0c,0x06,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x06,0x00,0x00,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x60,0x30,0x18,0x0c,0x06,0x03,0x01,0x00,0x3e,0x63,0x73,0x7b,0x6f,0x67,0x3e,0x00,0x0c,0x0e,0x0c,0x0c,0x0c,0x0c,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x06,0x33,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x30,0x33,0x1e,0x00,0x38,0x3c,0x36,0x33,0x7f,0x30,0x78,0x00,0x3f,0x03,0x1f,0x30,0x30,0x33,0x1e,0x00,0x1c,0x06,0x03,0x1f,0x33,0x33,0x1e,0x00,0x3f,0x33,0x30,0x18,0x0c,0x0c,0x0c,0x00,0x1e,0x33,0x33,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x33,0x3e,0x30,0x18,0x0e,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x06,0x18,0x0c,0x06,0x03,0x06,0x0c,0x18,0x00,0x00,0x00,0x3f,0x00,0x00,0x3f,0x00,0x00,0x06,0x0c,0x18,0x30,0x18,0x0c,0x06,0x00,0x1e,0x33,0x30,0x18,0x0c,0x00,0x0c,0x00, -0x3e,0x63,0x7b,0x7b,0x7b,0x03,0x1e,0x00,0x0c,0x1e,0x33,0x33,0x3f,0x33,0x33,0x00,0x3f,0x66,0x66,0x3e,0x66,0x66,0x3f,0x00,0x3c,0x66,0x03,0x03,0x03,0x66,0x3c,0x00,0x1f,0x36,0x66,0x66,0x66,0x36,0x1f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x46,0x7f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x06,0x0f,0x00,0x3c,0x66,0x03,0x03,0x73,0x66,0x7c,0x00,0x33,0x33,0x33,0x3f,0x33,0x33,0x33,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x78,0x30,0x30,0x30,0x33,0x33,0x1e,0x00,0x67,0x66,0x36,0x1e,0x36,0x66,0x67,0x00,0x0f,0x06,0x06,0x06,0x46,0x66,0x7f,0x00,0x63,0x77,0x7f,0x7f,0x6b,0x63,0x63,0x00,0x63,0x67,0x6f,0x7b,0x73,0x63,0x63,0x00,0x1c,0x36,0x63,0x63,0x63,0x36,0x1c,0x00,0x3f,0x66,0x66,0x3e,0x06,0x06,0x0f,0x00,0x1e,0x33,0x33,0x33,0x3b,0x1e,0x38,0x00,0x3f,0x66,0x66,0x3e,0x36,0x66,0x67,0x00,0x1e,0x33,0x07,0x0e,0x38,0x33,0x1e,0x00,0x3f,0x2d,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x00,0x33,0x33,0x33,0x33,0x33,0x1e,0x0c,0x00,0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00,0x63,0x63,0x36,0x1c,0x1c,0x36,0x63,0x00,0x33,0x33,0x33,0x1e,0x0c,0x0c,0x1e,0x00,0x7f,0x63,0x31,0x18,0x4c,0x66,0x7f,0x00,0x1e,0x06,0x06,0x06,0x06,0x06,0x1e,0x00,0x03,0x06,0x0c,0x18,0x30,0x60,0x40,0x00,0x1e,0x18,0x18,0x18,0x18,0x18,0x1e,0x00,0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff, -0x0c,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x30,0x3e,0x33,0x6e,0x00,0x07,0x06,0x06,0x3e,0x66,0x66,0x3b,0x00,0x00,0x00,0x1e,0x33,0x03,0x33,0x1e,0x00,0x38,0x30,0x30,0x3e,0x33,0x33,0x6e,0x00,0x00,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x1c,0x36,0x06,0x0f,0x06,0x06,0x0f,0x00,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x1f,0x07,0x06,0x36,0x6e,0x66,0x66,0x67,0x00,0x0c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x30,0x00,0x30,0x30,0x30,0x33,0x33,0x1e,0x07,0x06,0x66,0x36,0x1e,0x36,0x67,0x00,0x0e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x33,0x7f,0x7f,0x6b,0x63,0x00,0x00,0x00,0x1f,0x33,0x33,0x33,0x33,0x00,0x00,0x00,0x1e,0x33,0x33,0x33,0x1e,0x00,0x00,0x00,0x3b,0x66,0x66,0x3e,0x06,0x0f,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x78,0x00,0x00,0x3b,0x6e,0x66,0x06,0x0f,0x00,0x00,0x00,0x3e,0x03,0x1e,0x30,0x1f,0x00,0x08,0x0c,0x3e,0x0c,0x0c,0x2c,0x18,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x6e,0x00,0x00,0x00,0x33,0x33,0x33,0x1e,0x0c,0x00,0x00,0x00,0x63,0x6b,0x7f,0x7f,0x36,0x00,0x00,0x00,0x63,0x36,0x1c,0x36,0x63,0x00,0x00,0x00,0x33,0x33,0x33,0x3e,0x30,0x1f,0x00,0x00,0x3f,0x19,0x0c,0x26,0x3f,0x00,0x38,0x0c,0x0c,0x07,0x0c,0x0c,0x38,0x00,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x07,0x0c,0x0c,0x38,0x0c,0x0c,0x07,0x00,0x6e,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x00, -0x1e,0x33,0x03,0x33,0x1e,0x18,0x30,0x1e,0x00,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x38,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x7e,0xc3,0x3c,0x60,0x7c,0x66,0xfc,0x00,0x33,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x07,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x0c,0x0c,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x00,0x00,0x1e,0x03,0x03,0x1e,0x30,0x1c,0x7e,0xc3,0x3c,0x66,0x7e,0x06,0x3c,0x00,0x33,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x07,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x33,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x3e,0x63,0x1c,0x18,0x18,0x18,0x3c,0x00,0x07,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x63,0x1c,0x36,0x63,0x7f,0x63,0x63,0x00,0x0c,0x0c,0x00,0x1e,0x33,0x3f,0x33,0x00,0x38,0x00,0x3f,0x06,0x1e,0x06,0x3f,0x00,0x00,0x00,0xfe,0x30,0xfe,0x33,0xfe,0x00,0x7c,0x36,0x33,0x7f,0x33,0x33,0x73,0x00,0x1e,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x07,0x00,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x07,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x33,0x00,0x33,0x33,0x3e,0x30,0x1f,0xc3,0x18,0x3c,0x66,0x66,0x3c,0x18,0x00,0x33,0x00,0x33,0x33,0x33,0x33,0x1e,0x00,0x18,0x18,0x7e,0x03,0x03,0x7e,0x18,0x18,0x1c,0x36,0x26,0x0f,0x06,0x67,0x3f,0x00,0x33,0x33,0x1e,0x3f,0x0c,0x3f,0x0c,0x0c,0x1f,0x33,0x33,0x5f,0x63,0xf3,0x63,0xe3,0x70,0xd8,0x18,0x3c,0x18,0x18,0x1b,0x0e, -0x38,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x1c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x38,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x38,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x1f,0x00,0x1f,0x33,0x33,0x33,0x00,0x3f,0x00,0x33,0x37,0x3f,0x3b,0x33,0x00,0x3c,0x36,0x36,0x7c,0x00,0x7e,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x3e,0x00,0x00,0x0c,0x00,0x0c,0x06,0x03,0x33,0x1e,0x00,0x00,0x00,0x00,0x3f,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x30,0x00,0x00,0xc3,0x63,0x33,0x7b,0xcc,0x66,0x33,0xf0,0xc3,0x63,0x33,0xdb,0xec,0xf6,0xf3,0xc0,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0xcc,0x66,0x33,0x66,0xcc,0x00,0x00,0x00,0x33,0x66,0xcc,0x66,0x33,0x00,0x00,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xdb,0xee,0xdb,0x77,0xdb,0xee,0xdb,0x77,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0x6f,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x7f,0x6c,0x6c,0x6c,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x7f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6f,0x60,0x7f,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0x7f,0x00,0x00,0x00,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18, -0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xfc,0x00,0x00,0x00,0x00,0x00,0xfc,0x0c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xef,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xef,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xec,0x6c,0x6c,0x6c,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0xef,0x00,0xef,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xfc,0x00,0x00,0x00,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xfc,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xff,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, -0x00,0x00,0x6e,0x3b,0x13,0x3b,0x6e,0x00,0x00,0x1e,0x33,0x1f,0x33,0x1f,0x03,0x03,0x00,0x3f,0x33,0x03,0x03,0x03,0x03,0x00,0x00,0x7f,0x36,0x36,0x36,0x36,0x36,0x00,0x3f,0x33,0x06,0x0c,0x06,0x33,0x3f,0x00,0x00,0x00,0x7e,0x1b,0x1b,0x1b,0x0e,0x00,0x00,0x66,0x66,0x66,0x66,0x3e,0x06,0x03,0x00,0x6e,0x3b,0x18,0x18,0x18,0x18,0x00,0x3f,0x0c,0x1e,0x33,0x33,0x1e,0x0c,0x3f,0x1c,0x36,0x63,0x7f,0x63,0x36,0x1c,0x00,0x1c,0x36,0x63,0x63,0x36,0x36,0x77,0x00,0x38,0x0c,0x18,0x3e,0x33,0x33,0x1e,0x00,0x00,0x00,0x7e,0xdb,0xdb,0x7e,0x00,0x00,0x60,0x30,0x7e,0xdb,0xdb,0x7e,0x06,0x03,0x1c,0x06,0x03,0x1f,0x03,0x06,0x1c,0x00,0x1e,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,0x3f,0x00,0x3f,0x00,0x3f,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x3f,0x00,0x06,0x0c,0x18,0x0c,0x06,0x00,0x3f,0x00,0x18,0x0c,0x06,0x0c,0x18,0x00,0x3f,0x00,0x70,0xd8,0xd8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1b,0x1b,0x0e,0x0c,0x0c,0x00,0x3f,0x00,0x0c,0x0c,0x00,0x00,0x6e,0x3b,0x00,0x6e,0x3b,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0xf0,0x30,0x30,0x30,0x37,0x36,0x3c,0x38,0x1e,0x36,0x36,0x36,0x36,0x00,0x00,0x00,0x0e,0x18,0x0c,0x06,0x1e,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 -}; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FrameBuffer::MainMenuItem FrameBuffer::ourMainMenu[2] = { - { REMAP_MENU, "Event Remapping" }, - { INFO_MENU, "Game Information" } -}; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FrameBuffer::RemapMenuItem FrameBuffer::ourRemapMenu[57] = { - { Event::ConsoleSelect, "Select", "" }, - { Event::ConsoleReset, "Reset", "" }, - { Event::ConsoleColor, "Color TV", "" }, - { Event::ConsoleBlackWhite, "B/W TV", "" }, - { Event::ConsoleLeftDifficultyB, "Left Diff. B", "" }, - { Event::ConsoleLeftDifficultyA, "Left Diff. A", "" }, - { Event::ConsoleRightDifficultyB, "Right Diff. B", "" }, - { Event::ConsoleRightDifficultyA, "Right Diff. A", "" }, - { Event::SaveState, "Save State", "" }, - { Event::ChangeState, "Change State", "" }, - { Event::LoadState, "Load State", "" }, - { Event::TakeSnapshot, "Snapshot", "" }, - { Event::Pause, "Pause", "" }, -// { Event::Quit, "Quit", "" }, - - { Event::JoystickZeroUp, "Left-Joy Up", "" }, - { Event::JoystickZeroDown, "Left-Joy Down", "" }, - { Event::JoystickZeroLeft, "Left-Joy Left", "" }, - { Event::JoystickZeroRight, "Left-Joy Right", "" }, - { Event::JoystickZeroFire, "Left-Joy Fire", "" }, - - { Event::JoystickOneUp, "Right-Joy Up", "" }, - { Event::JoystickOneDown, "Right-Joy Down", "" }, - { Event::JoystickOneLeft, "Right-Joy Left", "" }, - { Event::JoystickOneRight, "Right-Joy Right", "" }, - { Event::JoystickOneFire, "Right-Joy Fire", "" }, - - { Event::BoosterGripZeroTrigger, "Left-BGrip Trigger", "" }, - { Event::BoosterGripZeroBooster, "Left-BGrip Booster", "" }, - - { Event::BoosterGripOneTrigger, "Right-BGrip Trigger", "" }, - { Event::BoosterGripOneBooster, "Right-BGrip Booster", "" }, - - { Event::DrivingZeroCounterClockwise, "Left-Driving Left", "" }, - { Event::DrivingZeroClockwise, "Left-Driving Right", "" }, - { Event::DrivingZeroFire, "Left-Driving Fire", "" }, - - { Event::DrivingOneCounterClockwise, "Right-Driving Left", "" }, - { Event::DrivingOneClockwise, "Right-Driving Right", "" }, - { Event::DrivingOneFire, "Right-Driving Fire", "" }, - - { Event::KeyboardZero1, "Left-Pad 1", "" }, - { Event::KeyboardZero2, "Left-Pad 2", "" }, - { Event::KeyboardZero3, "Left-Pad 3", "" }, - { Event::KeyboardZero4, "Left-Pad 4", "" }, - { Event::KeyboardZero5, "Left-Pad 5", "" }, - { Event::KeyboardZero6, "Left-Pad 6", "" }, - { Event::KeyboardZero7, "Left-Pad 7", "" }, - { Event::KeyboardZero8, "Left-Pad 8", "" }, - { Event::KeyboardZero9, "Left-Pad 9", "" }, - { Event::KeyboardZeroStar, "Left-Pad *", "" }, - { Event::KeyboardZero0, "Left-Pad 0", "" }, - { Event::KeyboardZeroPound, "Left-Pad #", "" }, - - { Event::KeyboardOne1, "Right-Pad 1", "" }, - { Event::KeyboardOne2, "Right-Pad 2", "" }, - { Event::KeyboardOne3, "Right-Pad 3", "" }, - { Event::KeyboardOne4, "Right-Pad 4", "" }, - { Event::KeyboardOne5, "Right-Pad 5", "" }, - { Event::KeyboardOne6, "Right-Pad 6", "" }, - { Event::KeyboardOne7, "Right-Pad 7", "" }, - { Event::KeyboardOne8, "Right-Pad 8", "" }, - { Event::KeyboardOne9, "Right-Pad 9", "" }, - { Event::KeyboardOneStar, "Right-Pad *", "" }, - { Event::KeyboardOne0, "Right-Pad 0", "" }, - { Event::KeyboardOnePound, "Right-Pad #", "" } -}; */ #if 0 diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index dade04381..a8024f258 100644 --- a/stella/src/emucore/FrameBuffer.hxx +++ b/stella/src/emucore/FrameBuffer.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.hxx,v 1.24 2005-04-03 19:37:32 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.25 2005-04-04 02:19:21 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -41,7 +41,7 @@ class OSystem; All GUI elements (ala ScummVM) are drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.24 2005-04-03 19:37:32 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.25 2005-04-04 02:19:21 stephena Exp $ */ class FrameBuffer { @@ -133,7 +133,7 @@ class FrameBuffer */ void refresh(bool now = false) { -//FIXME cerr << "refresh() " << val++ << endl; +//cerr << "refresh() " << val++ << endl; theRedrawEntireFrameIndicator = true; myMenuRedraws = 2; if(now) drawMediaSource(); @@ -221,6 +221,19 @@ class FrameBuffer void box(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor colorA, OverlayColor colorB); + /** + This routine should be called to draw a framed rectangle. + I'm not exactly sure what it is, so I can't explain it :) + + @param x The x coordinate + @param y The y coordinate + @param w The width of the area + @param h The height of the area + @param color The color of the surrounding frame + */ + void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, + OverlayColor color); + /** Indicate that the specified area should be redrawn. Currently we just redraw the entire screen. @@ -326,18 +339,6 @@ class FrameBuffer virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor color) = 0; - /** - This routine should be called to draw a framed rectangle. - - @param x The x coordinate - @param y The y coordinate - @param w The width of the area - @param h The height of the area - @param color The color of the surrounding frame - */ - virtual void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, - OverlayColor color) = 0; - /** This routine should be called to draw the specified character. @@ -501,14 +502,6 @@ FIXME string action; }; - // Structure used for remap menu items - struct RemapMenuItem - { - Event::Type event; - string action; - string key; - }; - // Table of strings representing the various StellaEvent codes static const char* ourEventName[StellaEvent::LastKCODE]; @@ -546,9 +539,6 @@ FIXME // Holds static strings for the main menu static MainMenuItem ourMainMenu[2]; - // Holds static strings for the remap menu - static RemapMenuItem ourRemapMenu[57]; - // Holds the current key mappings Event::Type* myKeyTable; diff --git a/stella/src/gui/Array.hxx b/stella/src/gui/Array.hxx index 948d4dfc6..84a27a1f4 100644 --- a/stella/src/gui/Array.hxx +++ b/stella/src/gui/Array.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Array.hxx,v 1.1 2005-03-14 04:08:15 stephena Exp $ +// $Id: Array.hxx,v 1.2 2005-04-04 02:19:21 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -125,60 +125,67 @@ class Array void clear() { - if (_data) { - delete [] _data; - _data = 0; - } - _size = 0; - _capacity = 0; - } + if(_data) + { + delete [] _data; + _data = 0; + } + _size = 0; + _capacity = 0; + } - bool isEmpty() const { - return (_size == 0); - } + bool isEmpty() const + { + return (_size == 0); + } + iterator begin() + { + return _data; + } - iterator begin() { - return _data; - } + iterator end() + { + return _data + _size; + } - iterator end() { - return _data + _size; - } + const_iterator begin() const + { + return _data; + } - const_iterator begin() const { - return _data; - } + const_iterator end() const + { + return _data + _size; + } - const_iterator end() const { - return _data + _size; - } + bool contains(const T &key) const + { + for (const_iterator i = begin(); i != end(); ++i) { + if (*i == key) + return true; + } + return false; + } - bool contains(const T &key) const { - for (const_iterator i = begin(); i != end(); ++i) { - if (*i == key) - return true; - } - return false; - } + protected: + void ensureCapacity(int new_len) + { + if (new_len <= _capacity) + return; + T *old_data = _data; + _capacity = new_len + 32; + _data = new T[_capacity]; -protected: - void ensureCapacity(int new_len) { - if (new_len <= _capacity) - return; - - T *old_data = _data; - _capacity = new_len + 32; - _data = new T[_capacity]; - - if (old_data) { - // Copy old data - for (int i = 0; i < _size; i++) - _data[i] = old_data[i]; - delete [] old_data; - } - } + if (old_data) + { + // Copy old data + for (int i = 0; i < _size; i++) + _data[i] = old_data[i]; + delete [] old_data; + } + } }; #endif diff --git a/stella/src/gui/Dialog.cxx b/stella/src/gui/Dialog.cxx index 28745986e..4720ce981 100644 --- a/stella/src/gui/Dialog.cxx +++ b/stella/src/gui/Dialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Dialog.cxx,v 1.8 2005-03-26 04:19:56 stephena Exp $ +// $Id: Dialog.cxx,v 1.9 2005-04-04 02:19:22 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -116,7 +116,6 @@ void Dialog::releaseFocus() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::draw() { - instance()->frameBuffer().refresh(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -137,9 +136,6 @@ void Dialog::drawDialog() w->draw(); w = w->_next; } - - // Flag the draw area as dirty - fb.addDirtyRect(_x, _y, _w, _h); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/EventMappingDialog.cxx b/stella/src/gui/EventMappingDialog.cxx new file mode 100644 index 000000000..be76db599 --- /dev/null +++ b/stella/src/gui/EventMappingDialog.cxx @@ -0,0 +1,113 @@ +//============================================================================ +// +// 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: EventMappingDialog.cxx,v 1.1 2005-04-04 02:19:22 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "OSystem.hxx" +#include "Widget.hxx" +#include "ListWidget.hxx" +#include "Dialog.hxx" +#include "GuiUtils.hxx" +#include "EventHandler.hxx" +#include "EventMappingDialog.hxx" + +#include "bspf.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +EventMappingDialog::EventMappingDialog(OSystem* osystem, uInt16 x, uInt16 y, + uInt16 w, uInt16 h) + : Dialog(osystem, x, y, w, h) +{ + // Add Previous, Next and Close buttons + addButton(10, h - 24, "Defaults", kDefaultsCmd, 0); + addButton(w - (kButtonWidth + 10), h - 24, "OK", kCloseCmd, 0); + + new StaticTextWidget(this, 10, 8, 200, 16, "Select an event to remap:", kTextAlignCenter); + myActionsList = new ListWidget(this, 10, 20, 200, 100); + myActionsList->setNumberingMode(kListNumberingOff); + + string title = "Hello Test!"; + myActionTitle = new StaticTextWidget(this, 10, 125, 200, 16, title, kTextAlignCenter); + myKeyMapping = new StaticTextWidget(this, 10, 130, 200, 16, "", kTextAlignCenter); + + myActionTitle->setFlags(WIDGET_CLEARBG); + myKeyMapping->setFlags(WIDGET_CLEARBG); + + // Add remap and erase buttons + addButton(220, 30, "Map", kMapCmd, 0); + addButton(220, 50, "Erase", kEraseCmd, 0); + + // Get actions names + StringList l; + + for(int i = 0; i < 58; ++i) // FIXME - create a size() method + l.push_back(EventHandler::ourActionList[i].action); + + myActionsList->setList(l); + + myActionSelected = -1; +// CEActions::Instance()->beginMapping(false); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +EventMappingDialog::~EventMappingDialog() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventMappingDialog::handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers) +{ + cerr << "EventMappingDialog::handleKeyDown received: " << ascii << endl; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventMappingDialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data) +{ + switch(cmd) + { + case kListSelectionChangedCmd: + if(myActionsList->getSelected() >= 0) + { +cerr << "Item selected: " << myActionsList->getSelected() << endl; + +/* char selection[100]; + + sprintf(selection, "Associated key : %s", CEDevice::getKeyName(CEActions::Instance()->getMapping((ActionType)(_actionsList->getSelected() + 1))).c_str()); + _keyMapping->setLabel(selection); + _keyMapping->draw(); +*/ + } + break; + + case kMapCmd: +cerr << "Remap item: " << myActionsList->getSelected() << endl; + break; + + case kEraseCmd: +cerr << "Erase item: " << myActionsList->getSelected() << endl; + break; + + case kDefaultsCmd: +cerr << "Set default mapping\n"; + break; + + default: + Dialog::handleCommand(sender, cmd, data); + } +} diff --git a/stella/src/gui/EventMappingDialog.hxx b/stella/src/gui/EventMappingDialog.hxx new file mode 100644 index 000000000..e893acdba --- /dev/null +++ b/stella/src/gui/EventMappingDialog.hxx @@ -0,0 +1,57 @@ +//============================================================================ +// +// 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: EventMappingDialog.hxx,v 1.1 2005-04-04 02:19:22 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef EVENT_MAPPING_DIALOG_HXX +#define EVENT_MAPPING_DIALOG_HXX + +class CommandSender; +class ButtonWidget; +class StaticTextWidget; +class ListWidget; + +#include "OSystem.hxx" +#include "bspf.hxx" + +class EventMappingDialog : public Dialog +{ + public: + EventMappingDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 h); + ~EventMappingDialog(); + + virtual void handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers); + + protected: + ListWidget* myActionsList; + StaticTextWidget* myActionTitle; + StaticTextWidget* myKeyMapping; + Int32 myActionSelected; + + private: + virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data); + + enum { + kMapCmd = 'map ', + kEraseCmd = 'eras' + }; +// void loadConfig() { } +}; + +#endif diff --git a/stella/src/gui/GuiUtils.hxx b/stella/src/gui/GuiUtils.hxx index 89c2d3550..ae3f7ee04 100644 --- a/stella/src/gui/GuiUtils.hxx +++ b/stella/src/gui/GuiUtils.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: GuiUtils.hxx,v 1.5 2005-03-27 03:07:34 stephena Exp $ +// $Id: GuiUtils.hxx,v 1.6 2005-04-04 02:19:22 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -29,10 +29,11 @@ Probably not very neat, but at least it works ... @author Stephen Anthony - @version $Id: GuiUtils.hxx,v 1.5 2005-03-27 03:07:34 stephena Exp $ + @version $Id: GuiUtils.hxx,v 1.6 2005-04-04 02:19:22 stephena Exp $ */ #define kLineHeight 12 +#define kScrollBarWidth 9 // Colors indices to use for the various GUI elements enum OverlayColor { @@ -45,11 +46,12 @@ enum OverlayColor { // The commands generated by various widgets enum { - kOKCmd = 'OK ', - kCloseCmd = 'CLOS', - kNextCmd = 'NEXT', - kPrevCmd = 'PREV', - kDefaultsCmd = 'DEFA', + kOKCmd = 'OK ', + kCloseCmd = 'CLOS', + kNextCmd = 'NEXT', + kPrevCmd = 'PREV', + kDefaultsCmd = 'DEFA', + kSetPositionCmd = 'SETP', kRendererChanged, kAspectRatioChanged, kFrameRateChanged, diff --git a/stella/src/gui/ListWidget.cxx b/stella/src/gui/ListWidget.cxx new file mode 100644 index 000000000..1317577ae --- /dev/null +++ b/stella/src/gui/ListWidget.cxx @@ -0,0 +1,505 @@ +//============================================================================ +// +// 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: ListWidget.cxx,v 1.1 2005-04-04 02:19:22 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "OSystem.hxx" +#include "Widget.hxx" +#include "ScrollBarWidget.hxx" +#include "Dialog.hxx" +#include "FrameBuffer.hxx" +#include "ListWidget.hxx" +#include "bspf.hxx" + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ListWidget::ListWidget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h) + : Widget(boss, x, y, w - kScrollBarWidth, h), + CommandSender(boss) +{ + _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE; + _type = kListWidget; + _numberingMode = kListNumberingOne; + _entriesPerPage = (_h - 2) / kLineHeight; + _currentPos = 0; + _selectedItem = -1; + _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kScrollBarWidth, _h); + _scrollBar->setTarget(this); + _currentKeyDown = 0; + + _caretVisible = false; + _caretTime = 0; + + _quickSelectTime = 0; + + // FIXME: This flag should come from widget definition + _editable = true; + + _editMode = false; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ListWidget::~ListWidget() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::setSelected(Int32 item) +{ + assert(item >= -1 && item < (Int32)_list.size()); + + if(isEnabled() && _selectedItem != item) + { + Int32 oldSelectedItem = _selectedItem; + _selectedItem = item; + + if (_editMode) + { + // undo any changes made + _list[oldSelectedItem] = _backupString; + _editMode = false; + drawCaret(true); + } + + sendCommand(kListSelectionChangedCmd, _selectedItem); + + _currentPos = _selectedItem - _entriesPerPage / 2; + scrollToCurrent(); + draw(); + + _boss->instance()->frameBuffer().refresh(); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::setList(const StringList& list) +{ + if (_editMode && _caretVisible) + drawCaret(true); + + Int32 size = list.size(); + _list = list; + + if (_currentPos >= size) + _currentPos = size - 1; + if (_currentPos < 0) + _currentPos = 0; + _selectedItem = -1; + _editMode = false; + scrollBarRecalc(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::scrollTo(Int32 item) +{ + Int32 size = _list.size(); + if (item >= size) + item = size - 1; + if (item < 0) + item = 0; + + if (_currentPos != item) + { + _currentPos = item; + scrollBarRecalc(); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::scrollBarRecalc() +{ + _scrollBar->_numEntries = _list.size(); + _scrollBar->_entriesPerPage = _entriesPerPage; + _scrollBar->_currentPos = _currentPos; + _scrollBar->recalc(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::handleTickle() +{ +/* + uint32 time = g_system->getMillis(); + if (_editMode && _caretTime < time) { + _caretTime = time + kCaretBlinkTime; + drawCaret(_caretVisible); + } +*/ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCount) +{ + if (isEnabled()) + { + Int32 oldSelectedItem = _selectedItem; + _selectedItem = (y - 1) / kLineHeight + _currentPos; + if (_selectedItem > (Int32)_list.size() - 1) + _selectedItem = -1; + + if (oldSelectedItem != _selectedItem) + { + if (_editMode) + { + // undo any changes made + _list[oldSelectedItem] = _backupString; + _editMode = false; + drawCaret(true); + } + sendCommand(kListSelectionChangedCmd, _selectedItem); + } + draw(); + _boss->instance()->frameBuffer().refresh(); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount) +{ + _scrollBar->handleMouseUp(x, y, button, clickCount); + + // If this was a double click and the mouse is still over the selected item, + // send the double click command + if (clickCount == 2 && (_selectedItem == (y - 1) / kLineHeight + _currentPos)) + sendCommand(kListItemDoubleClickedCmd, _selectedItem); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::handleMouseWheel(Int32 x, Int32 y, Int32 direction) +{ + _scrollBar->handleMouseWheel(x, y, direction); + _boss->instance()->frameBuffer().refresh(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +static int matchingCharsIgnoringCase(const char* x, const char* y, bool& stop) +{ + int match = 0; + while (*x && *y && toupper(*x) == toupper(*y)) + { + ++x; + ++y; + ++match; + } + stop = !*y || (*x && (toupper(*x) >= toupper(*y))); + return match; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool ListWidget::handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers) +{ +cerr << "ListWidget::handleKeyDown()\n"; +return false; // FIXME - do something with this method ... +/* + bool handled = true; + bool dirty = false; + Int32 oldSelectedItem = _selectedItem; + + if (!_editMode && isprint((char)ascii)) + { + // Quick selection mode: Go to first list item starting with this key + // (or a substring accumulated from the last couple key presses). + // Only works in a useful fashion if the list entries are sorted. + // TODO: Maybe this should be off by default, and instead we add a + // method "enableQuickSelect()" or so ? + uInt32 time = g_system->getMillis(); + if (_quickSelectTime < time) + _quickSelectStr = (char)ascii; + else + _quickSelectStr += (char)ascii; + + _quickSelectTime = time + 300; // TODO: Turn this into a proper constant (kQuickSelectDelay ?) + + // FIXME: This is bad slow code (it scans the list linearly each time a + // key is pressed); it could be much faster. Only of importance if we have + // quite big lists to deal with -- so for now we can live with this lazy + // implementation :-) + int newSelectedItem = 0; + int bestMatch = 0; + bool stop; + for (StringList::const_iterator i = _list.begin(); i != _list.end(); ++i) + { + const int match = matchingCharsIgnoringCase(i->c_str(), _quickSelectStr.c_str(), stop); + if (match > bestMatch || stop) + { + _selectedItem = newSelectedItem; + bestMatch = match; + if (stop) + break; + } + newSelectedItem++; + } + + scrollToCurrent(); + } + else if (_editMode) + { + if (_caretVisible) + drawCaret(true); + + switch (keycode) + { + case '\n': // enter/return + case '\r': + // confirm edit and exit editmode + _editMode = false; + dirty = true; + sendCommand(kListItemActivatedCmd, _selectedItem); + break; + case 27: // escape + // abort edit and exit editmode + _editMode = false; + dirty = true; + _list[_selectedItem] = _backupString; + break; + case 8: // backspace + _list[_selectedItem].deleteLastChar(); + dirty = true; + break; + default: + if (isprint((char)ascii)) + { + _list[_selectedItem] += (char)ascii; + dirty = true; + } + else + handled = false; + } + } + else + { + // not editmode + + switch (keycode) { + case '\n': // enter/return + case '\r': + if (_selectedItem >= 0) { + // override continuous enter keydown + if (_editable && (_currentKeyDown != '\n' && _currentKeyDown != '\r')) { + dirty = true; + _editMode = true; + _backupString = _list[_selectedItem]; + } else + sendCommand(kListItemActivatedCmd, _selectedItem); + } + break; + case 256+17: // up arrow + if (_selectedItem > 0) + _selectedItem--; + break; + case 256+18: // down arrow + if (_selectedItem < (int)_list.size() - 1) + _selectedItem++; + break; + case 256+24: // pageup + _selectedItem -= _entriesPerPage - 1; + if (_selectedItem < 0) + _selectedItem = 0; + break; + case 256+25: // pagedown + _selectedItem += _entriesPerPage - 1; + if (_selectedItem >= (int)_list.size() ) + _selectedItem = _list.size() - 1; + break; + case 256+22: // home + _selectedItem = 0; + break; + case 256+23: // end + _selectedItem = _list.size() - 1; + break; + default: + handled = false; + } + + scrollToCurrent(); + } + + if (dirty || _selectedItem != oldSelectedItem) + draw(); + + if (_selectedItem != oldSelectedItem) { + sendCommand(kListSelectionChangedCmd, _selectedItem); + // also draw scrollbar + _scrollBar->draw(); + } + + return handled; +*/ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool ListWidget::handleKeyUp(uInt16 ascii, Int32 keycode, Int32 modifiers) +{ + if (keycode == _currentKeyDown) + _currentKeyDown = 0; + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::lostFocusWidget() +{ + _editMode = false; + drawCaret(true); + draw(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data) +{ + switch (cmd) + { + case kSetPositionCmd: + if (_currentPos != (int)data) + { + _currentPos = data; + draw(); + } + break; + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::drawWidget(bool hilite) +{ + FrameBuffer& fb = _boss->instance()->frameBuffer(); + int i, pos, len = _list.size(); + string buffer; + + // Draw a thin frame around the list. + fb.hLine(_x, _y, _x + _w - 1, kColor); + fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor); + fb.vLine(_x, _y, _y + _h - 1, kColor); + + // Draw the list items + for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) + { + if (_numberingMode == kListNumberingZero || _numberingMode == kListNumberingOne) + { + char temp[10]; + sprintf(temp, "%2d. ", (pos + _numberingMode)); + buffer = temp; + buffer += _list[pos]; + } + else + buffer = _list[pos]; + + if (_selectedItem == pos) + { + if (_hasFocus) + fb.fillRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, kTextColorHi); + else + fb.frameRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, kTextColorHi); + } + fb.font().drawString(buffer, _x + 2, _y + 2 + kLineHeight * i, _w - 4, + (_selectedItem == pos && _hasFocus) ? kBGColor : kTextColor); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Int32 ListWidget::getCaretPos() const +{ + Int32 caretpos = 0; + FrameBuffer& fb = _boss->instance()->frameBuffer(); + + if (_numberingMode == kListNumberingZero || _numberingMode == kListNumberingOne) + { + char temp[10]; + sprintf(temp, "%2d. ", (_selectedItem + _numberingMode)); + caretpos += fb.font().getStringWidth(temp); + } + + caretpos += fb.font().getStringWidth(_list[_selectedItem]); + + return caretpos; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::drawCaret(bool erase) +{ + // Only draw if item is visible + if (_selectedItem < _currentPos || _selectedItem >= _currentPos + _entriesPerPage) + return; + if (!isVisible() || !_boss->isVisible()) + return; + + FrameBuffer& fb = _boss->instance()->frameBuffer(); + + // The item is selected, thus _bgcolor is used to draw the caret and _textcolorhi to erase it + OverlayColor color = erase ? kTextColorHi : kBGColor; + int x = getAbsX() + 3; + int y = getAbsY() + 1; + + y += (_selectedItem - _currentPos) * kLineHeight; + x += getCaretPos(); + + fb.vLine(x, y, y+kLineHeight, color); + + _caretVisible = !erase; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::scrollToCurrent() +{ + // Only do something if the current item is not in our view port + if (_selectedItem < _currentPos) + { + // it's above our view + _currentPos = _selectedItem; + } + else if (_selectedItem >= _currentPos + _entriesPerPage ) + { + // it's below our view + _currentPos = _selectedItem - _entriesPerPage + 1; + } + + if (_currentPos < 0 || _entriesPerPage > (int)_list.size()) + _currentPos = 0; + else if (_currentPos + _entriesPerPage > (int)_list.size()) + _currentPos = _list.size() - _entriesPerPage; + + _scrollBar->_currentPos = _currentPos; + _scrollBar->recalc(); +} + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::startEditMode() +{ +cerr << "ListWidget::startEditMode()\n"; + + if (_editable && !_editMode && _selectedItem >= 0) + { + _editMode = true; + _backupString = _list[_selectedItem]; + draw(); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ListWidget::abortEditMode() +{ +cerr << "ListWidget::abortEditMode()\n"; + + if (_editMode) + { + _editMode = false; + _list[_selectedItem] = _backupString; + drawCaret(true); + draw(); + } +} diff --git a/stella/src/gui/ListWidget.hxx b/stella/src/gui/ListWidget.hxx new file mode 100644 index 000000000..8b8386cd5 --- /dev/null +++ b/stella/src/gui/ListWidget.hxx @@ -0,0 +1,108 @@ +//============================================================================ +// +// 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: ListWidget.hxx,v 1.1 2005-04-04 02:19:22 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef LIST_WIDGET_HXX +#define LIST_WIDGET_HXX + +#include "GuiObject.hxx" +#include "Widget.hxx" +#include "ScrollBarWidget.hxx" +#include "Command.hxx" +#include "StringList.hxx" +#include "bspf.hxx" + +enum NumberingMode { + kListNumberingOff = -1, + kListNumberingZero = 0, + kListNumberingOne = 1 +}; + +// Some special commands +enum { + kListItemDoubleClickedCmd = 'LIdb', // double click on item - 'data' will be item index + kListItemActivatedCmd = 'LIac', // item activated by return/enter - 'data' will be item index + kListSelectionChangedCmd = 'Lsch' // selection changed - 'data' will be item index +}; + + +/* ListWidget */ +class ListWidget : public Widget, public CommandSender +{ + public: + ListWidget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h); + virtual ~ListWidget(); + + void setList(const StringList& list); + const StringList& getList() const { return _list; } + Int32 getSelected() const { return _selectedItem; } + void setSelected(Int32 item); + const string& getSelectedString() const { return _list[_selectedItem]; } + bool isEditable() const { return _editable; } + void setEditable(bool editable) { _editable = editable; } + void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; } + void scrollTo(Int32 item); + + virtual void handleTickle(); + virtual void handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCount); + virtual void handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount); + virtual void handleMouseWheel(Int32 x, Int32 y, Int32 direction); + virtual void handleMouseEntered(Int32 button) { _scrollBar->handleMouseLeft(button); } + virtual void handleMouseLeft(Int32 button) { _scrollBar->handleMouseLeft(button); } + virtual bool handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers); + virtual bool handleKeyUp(uInt16 ascii, Int32 keycode, Int32 modifiers); + virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data); + + virtual bool wantsFocus() { return true; }; + + void scrollBarRecalc(); + + void startEditMode(); + void abortEditMode(); + + protected: + void drawWidget(bool hilite); + + Int32 getCaretPos() const; + void drawCaret(bool erase); + + void lostFocusWidget(); + void scrollToCurrent(); + + protected: + StringList _list; + bool _editable; + bool _editMode; + NumberingMode _numberingMode; + Int32 _currentPos; + Int32 _entriesPerPage; + Int32 _selectedItem; + ScrollBarWidget* _scrollBar; + Int32 _currentKeyDown; + string _backupString; + + bool _caretVisible; + uInt32 _caretTime; + + string _quickSelectStr; + uInt32 _quickSelectTime; +}; + +#endif diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index f91ee7077..9e12c61a8 100644 --- a/stella/src/gui/OptionsDialog.cxx +++ b/stella/src/gui/OptionsDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OptionsDialog.cxx,v 1.8 2005-03-28 00:04:54 stephena Exp $ +// $Id: OptionsDialog.cxx,v 1.9 2005-04-04 02:19:22 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -26,6 +26,7 @@ #include "Control.hxx" #include "VideoDialog.hxx" #include "AudioDialog.hxx" +#include "EventMappingDialog.hxx" #include "GameInfoDialog.hxx" #include "HelpDialog.hxx" #include "OptionsDialog.hxx" @@ -85,10 +86,14 @@ OptionsDialog::OptionsDialog(OSystem* osystem) checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); myAudioDialog = new AudioDialog(myOSystem, x, y, w, h); -/* - myEventMappingDialog = new EventMappingDialog(myOSystem); - myMiscDialog = new MiscDialog(myOSystem); -*/ + w = 280; h = 180; + checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); + myEventMappingDialog = new EventMappingDialog(myOSystem, x, y, w, h); + +// w = 250; h = 150; +// checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); +// myMiscDialog = new MiscDialog(myOSystem, x, y, w, h); + w = 255; h = 150; checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); myGameInfoDialog = new GameInfoDialog(myOSystem, x, y, w, h); @@ -103,7 +108,7 @@ OptionsDialog::~OptionsDialog() { delete myVideoDialog; delete myAudioDialog; -// delete myEventMappingDialog; + delete myEventMappingDialog; // delete myMiscDialog; delete myGameInfoDialog; delete myHelpDialog; @@ -133,8 +138,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data break; case kEMapCmd: -// instance()->menu().addDialog(myEventMappingDialog); -cerr << "push EventMappingDialog to top of stack\n"; + instance()->menu().addDialog(myEventMappingDialog); break; case kMiscCmd: diff --git a/stella/src/gui/PopUpWidget.cxx b/stella/src/gui/PopUpWidget.cxx index bff65307a..24e3d8700 100644 --- a/stella/src/gui/PopUpWidget.cxx +++ b/stella/src/gui/PopUpWidget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: PopUpWidget.cxx,v 1.3 2005-03-26 19:26:47 stephena Exp $ +// $Id: PopUpWidget.cxx,v 1.4 2005-04-04 02:19:22 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -89,8 +89,6 @@ void PopUpDialog::drawDialog() Int32 count = _popUpBoss->_entries.size(); for(Int32 i = 0; i < count; i++) drawMenuEntry(i, i == _selection); - - fb.addDirtyRect(_x, _y, _w, _h); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -186,6 +184,8 @@ void PopUpDialog::setSelection(Int32 item) // Draw new selection if(item >= 0) drawMenuEntry(item, true); + + _popUpBoss->instance()->frameBuffer().refresh(); } } @@ -257,8 +257,6 @@ void PopUpDialog::drawMenuEntry(Int32 entry, bool hilite) } else fb.font().drawString(name, x + 1, y + 2, w - 2, hilite ? kBGColor : kTextColor); - - fb.addDirtyRect(x, y, w, kLineHeight); } // diff --git a/stella/src/gui/ScrollBarWidget.cxx b/stella/src/gui/ScrollBarWidget.cxx new file mode 100644 index 000000000..25ddfc2e5 --- /dev/null +++ b/stella/src/gui/ScrollBarWidget.cxx @@ -0,0 +1,288 @@ +//============================================================================ +// +// 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: ScrollBarWidget.cxx,v 1.1 2005-04-04 02:19:22 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "OSystem.hxx" +#include "Dialog.hxx" +#include "FrameBuffer.hxx" +#include "ScrollBarWidget.hxx" +#include "bspf.hxx" + +/* + * TODO: + * - Auto-repeat: if user clicks & holds on one of the arrows, then after a + * brief delay, it should start to contiously scroll + * - Allow for a horizontal scrollbar, too? + * - If there are less items than fit on one pages, no scrolling can be done + * and we thus should not highlight the arrows/slider. + * - Allow the mouse wheel to scroll more than one line at a time + */ + +#define UP_DOWN_BOX_HEIGHT 10 + +// Up arrow +static uInt32 up_arrow[8] = { + 0x00000000, + 0x00000000, + 0x00001000, + 0x00001000, + 0x00011100, + 0x00011100, + 0x00110110, + 0x00100010, +}; + +// Down arrow +static uInt32 down_arrow[8] = { + 0x00000000, + 0x00000000, + 0x00100010, + 0x00110110, + 0x00011100, + 0x00011100, + 0x00001000, + 0x00001000, +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ScrollBarWidget::ScrollBarWidget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h) + : Widget(boss, x, y, w, h), CommandSender(boss) +{ + _flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE | WIDGET_CLEARBG; + _type = kScrollBarWidget; + + _part = kNoPart; + _sliderHeight = 0; + _sliderPos = 0; + + _draggingPart = kNoPart; + _sliderDeltaMouseDownPos = 0; + + _numEntries = 0; + _entriesPerPage = 0; + _currentPos = 0; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::handleMouseDown(Int32 x, Int32 y, Int32 button, + Int32 clickCount) +{ + Int32 old_pos = _currentPos; + + // Do nothing if there are less items than fit on one page + if(_numEntries <= _entriesPerPage) + return; + + if (y <= UP_DOWN_BOX_HEIGHT) + { + // Up arrow + _currentPos--; + _draggingPart = kUpArrowPart; + } + else if(y >= _h - UP_DOWN_BOX_HEIGHT) + { + // Down arrow + _currentPos++; + _draggingPart = kDownArrowPart; + } + else if(y < _sliderPos) + { + _currentPos -= _entriesPerPage; + } + else if(y >= _sliderPos + _sliderHeight) + { + _currentPos += _entriesPerPage; + } + else + { + _draggingPart = kSliderPart; + _sliderDeltaMouseDownPos = y - _sliderPos; + } + + // Make sure that _currentPos is still inside the bounds + checkBounds(old_pos); + + _boss->instance()->frameBuffer().refresh(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::handleMouseUp(Int32 x, Int32 y, Int32 button, + Int32 clickCount) +{ + _draggingPart = kNoPart; + _boss->instance()->frameBuffer().refresh(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::handleMouseWheel(Int32 x, Int32 y, Int32 direction) +{ + Int32 old_pos = _currentPos; + + if(_numEntries < _entriesPerPage) + return; + + if(direction < 0) + _currentPos--; + else + _currentPos++; + + // Make sure that _currentPos is still inside the bounds + checkBounds(old_pos); + _boss->instance()->frameBuffer().refresh(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::handleMouseMoved(Int32 x, Int32 y, Int32 button) +{ + // Do nothing if there are less items than fit on one page + if(_numEntries <= _entriesPerPage) + return; + + if(_draggingPart == kSliderPart) + { + Int32 old_pos = _currentPos; + _sliderPos = y - _sliderDeltaMouseDownPos; + + if(_sliderPos < UP_DOWN_BOX_HEIGHT) + _sliderPos = UP_DOWN_BOX_HEIGHT; + + if(_sliderPos > _h - UP_DOWN_BOX_HEIGHT - _sliderHeight) + _sliderPos = _h - UP_DOWN_BOX_HEIGHT - _sliderHeight; + + _currentPos = (_sliderPos - UP_DOWN_BOX_HEIGHT) * (_numEntries - _entriesPerPage) / + (_h - 2 * UP_DOWN_BOX_HEIGHT - _sliderHeight); + checkBounds(old_pos); + } + else + { + Int32 old_part = _part; + + if(y <= UP_DOWN_BOX_HEIGHT) // Up arrow + _part = kUpArrowPart; + else if(y >= _h - UP_DOWN_BOX_HEIGHT) // Down arrow + _part = kDownArrowPart; + else if(y < _sliderPos) + _part = kPageUpPart; + else if(y >= _sliderPos + _sliderHeight) + _part = kPageDownPart; + else + _part = kSliderPart; + + if (old_part != _part) + draw(); + } + _boss->instance()->frameBuffer().refresh(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::handleTickle() { +/* + // FIXME/TODO - this code is supposed to allow for "click-repeat" (like key repeat), + // i.e. if you click on one of the arrows and keep clicked, it will scroll + // continuously. However, just like key repeat, this requires two delays: + // First an "initial" delay that has to pass before repeating starts (otherwise + // it is near to impossible to achieve single clicks). Secondly, a repeat delay + // that determines how often per second a click is simulated. + int old_pos = _currentPos; + + if (_draggingPart == kUpArrowPart) + _currentPos--; + else if (_draggingPart == kDownArrowPart) + _currentPos++; + + // Make sure that _currentPos is still inside the bounds + checkBounds(old_pos); +*/ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::checkBounds(Int32 old_pos) +{ + if(_numEntries <= _entriesPerPage || _currentPos < 0) + _currentPos = 0; + else if(_currentPos > _numEntries - _entriesPerPage) + _currentPos = _numEntries - _entriesPerPage; + + if (old_pos != _currentPos) + { + recalc(); + draw(); + sendCommand(kSetPositionCmd, _currentPos); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::recalc() +{ + if(_numEntries > _entriesPerPage) + { + _sliderHeight = (_h - 2 * UP_DOWN_BOX_HEIGHT) * _entriesPerPage / _numEntries; + if(_sliderHeight < UP_DOWN_BOX_HEIGHT) + _sliderHeight = UP_DOWN_BOX_HEIGHT; + + _sliderPos = UP_DOWN_BOX_HEIGHT + (_h - 2 * UP_DOWN_BOX_HEIGHT - _sliderHeight) * + _currentPos / (_numEntries - _entriesPerPage); + if(_sliderPos < 0) + _sliderPos = 0; + } + else + { + _sliderHeight = _h - 2 * UP_DOWN_BOX_HEIGHT; + _sliderPos = UP_DOWN_BOX_HEIGHT; + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ScrollBarWidget::drawWidget(bool hilite) +{ + FrameBuffer& fb = _boss->instance()->frameBuffer(); + int bottomY = _y + _h; + bool isSinglePage = (_numEntries <= _entriesPerPage); + + fb.frameRect(_x, _y, _w, _h, kShadowColor); + + if(_draggingPart != kNoPart) + _part = _draggingPart; + + // Up arrow + fb.frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, kColor); + fb.drawBitmap(up_arrow, _x, _y, + isSinglePage ? kColor : + (hilite && _part == kUpArrowPart) ? kTextColorHi : kTextColor); + + // Down arrow + fb.frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, kColor); + fb.drawBitmap(down_arrow, _x, bottomY - UP_DOWN_BOX_HEIGHT, + isSinglePage ? kColor : + (hilite && _part == kDownArrowPart) ? kTextColorHi : kTextColor); + + // Slider + if(!isSinglePage) + { + fb.fillRect(_x, _y + _sliderPos, _w, _sliderHeight, + (hilite && _part == kSliderPart) ? kTextColorHi : kTextColor); + fb.frameRect(_x, _y + _sliderPos, _w, _sliderHeight, kColor); + int y = _y + _sliderPos + _sliderHeight / 2; + OverlayColor color = (hilite && _part == kSliderPart) ? kColor : kShadowColor; + fb.hLine(_x + 2, y - 2, _x + _w - 3, color); + fb.hLine(_x + 2, y, _x + _w - 3, color); + fb.hLine(_x + 2, y + 2, _x + _w-3, color); + } +} diff --git a/stella/src/gui/ScrollBarWidget.hxx b/stella/src/gui/ScrollBarWidget.hxx new file mode 100644 index 000000000..39982ddd2 --- /dev/null +++ b/stella/src/gui/ScrollBarWidget.hxx @@ -0,0 +1,76 @@ +//============================================================================ +// +// 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: ScrollBarWidget.hxx,v 1.1 2005-04-04 02:19:22 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef SCROLL_BAR_WIDGET_HXX +#define SCROLL_BAR_WIDGET_HXX + +#include "GuiObject.hxx" +#include "Widget.hxx" +#include "Command.hxx" +#include "bspf.hxx" + + +class ScrollBarWidget : public Widget, public CommandSender +{ + protected: + typedef enum { + kNoPart, + kUpArrowPart, + kDownArrowPart, + kSliderPart, + kPageUpPart, + kPageDownPart + } Part; + + public: + ScrollBarWidget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h); + + virtual void handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCount); + virtual void handleMouseUp(Int32 x, Int32 y, Int32 button, Int32 clickCount); + virtual void handleMouseWheel(Int32 x, Int32 y, Int32 direction); + virtual void handleMouseMoved(Int32 x, Int32 y, Int32 button); + virtual void handleMouseEntered(Int32 button) { setFlags(WIDGET_HILITED); } + virtual void handleMouseLeft(Int32 button) { clearFlags(WIDGET_HILITED); _part = kNoPart; draw(); } + virtual void handleTickle(); + + // FIXME - this should be private, but then we also have to add accessors + // for _numEntries, _entriesPerPage and _currentPos. This again leads to the question: + // should these accessors force a redraw? + void recalc(); + + public: + Int32 _numEntries; + Int32 _entriesPerPage; + Int32 _currentPos; + + protected: + void drawWidget(bool hilite); + void checkBounds(int old_pos); + + protected: + Part _part; + Int32 _sliderHeight; + Int32 _sliderPos; + Part _draggingPart; + Int32 _sliderDeltaMouseDownPos; +}; + +#endif diff --git a/stella/src/gui/StringList.hxx b/stella/src/gui/StringList.hxx new file mode 100644 index 000000000..0ec9aa962 --- /dev/null +++ b/stella/src/gui/StringList.hxx @@ -0,0 +1,45 @@ +//============================================================================ +// +// 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: StringList.hxx,v 1.1 2005-04-04 02:19:22 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef STRING_LIST_HXX +#define STRING_LIST_HXX + +#include "Array.hxx" +#include "bspf.hxx" + + +class StringList : public Array +{ + public: + void push_back(const char *str) + { + ensureCapacity(_size + 1); + _data[_size++] = str; + } + + void push_back(const string& str) + { + ensureCapacity(_size + 1); + _data[_size++] = str; + } +}; + +#endif diff --git a/stella/src/gui/Widget.cxx b/stella/src/gui/Widget.cxx index ca626c98b..e067df2ed 100644 --- a/stella/src/gui/Widget.cxx +++ b/stella/src/gui/Widget.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Widget.cxx,v 1.6 2005-03-26 19:26:48 stephena Exp $ +// $Id: Widget.cxx,v 1.7 2005-04-04 02:19:22 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -92,9 +92,6 @@ void Widget::draw() _h += 8; } - // Flag the draw area as dirty - fb.addDirtyRect(_x, _y, _w, _h); - _x = oldX; _y = oldY; @@ -141,6 +138,10 @@ void StaticTextWidget::setValue(Int32 value) char buf[256]; sprintf(buf, "%d", value); _label = buf; + + // Refresh the screen when the text has changed + // FIXME - eventually, this should be a dirty rectangle + _boss->instance()->frameBuffer().refresh(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -220,6 +221,10 @@ void CheckboxWidget::setState(bool state) draw(); } sendCommand(_cmd, _state); + + // Refresh the screen after the checkbox is drawn + // FIXME - eventually, this should be a dirty rectangle + _boss->instance()->frameBuffer().refresh(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -277,6 +282,9 @@ void SliderWidget::handleMouseMoved(Int32 x, Int32 y, Int32 button) draw(); sendCommand(_cmd, _value); } + // Refresh the screen while the slider is being redrawn + // FIXME - eventually, this should be a dirty rectangle + _boss->instance()->frameBuffer().refresh(); } } diff --git a/stella/src/gui/Widget.hxx b/stella/src/gui/Widget.hxx index 43f0599a1..6758a7b4c 100644 --- a/stella/src/gui/Widget.hxx +++ b/stella/src/gui/Widget.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Widget.hxx,v 1.7 2005-03-26 04:19:56 stephena Exp $ +// $Id: Widget.hxx,v 1.8 2005-04-04 02:19:22 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -26,6 +26,7 @@ class Dialog; #include +#include "OSystem.hxx" #include "StellaFont.hxx" #include "FrameBuffer.hxx" #include "GuiObject.hxx" @@ -64,7 +65,7 @@ enum { This is the base class for all widgets. @author Stephen Anthony - @version $Id: Widget.hxx,v 1.7 2005-03-26 04:19:56 stephena Exp $ + @version $Id: Widget.hxx,v 1.8 2005-04-04 02:19:22 stephena Exp $ */ class Widget : public GuiObject { @@ -92,8 +93,12 @@ class Widget : public GuiObject void lostFocus() { _hasFocus = false; lostFocusWidget(); } virtual bool wantsFocus() { return false; }; - void setFlags(Int32 flags) { _flags |= flags; } - void clearFlags(Int32 flags) { _flags &= ~flags; } + void setFlags(Int32 flags) { _flags |= flags; + _boss->instance()->frameBuffer().refresh(); + } + void clearFlags(Int32 flags) { _flags &= ~flags; + _boss->instance()->frameBuffer().refresh(); + } Int32 getFlags() const { return _flags; } void setEnabled(bool e) { if (e) setFlags(WIDGET_ENABLED); else clearFlags(WIDGET_ENABLED); } @@ -135,7 +140,9 @@ class StaticTextWidget : public Widget Int32 x, Int32 y, Int32 w, Int32 h, const string& text, TextAlignment align); void setValue(Int32 value); - void setLabel(const string& label) { _label = label; } + void setLabel(const string& label) { _label = label; + _boss->instance()->frameBuffer().refresh(); + } const string& getLabel() const { return _label; } protected: