From a13cd9b31dc59b36305ad04243db760e98053fd5 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Mon, 2 Feb 2009 15:25:25 +0000 Subject: [PATCH] More GUI refinements, added "text" control --- Makefile | 1 + src/apple2.cpp | 3 ++- src/apple2.h | 2 ++ src/floppy.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/floppy.h | 2 ++ src/gui/gui.cpp | 13 +++++++++++++ src/gui/text.cpp | 28 ++++++++++++++++++++++++++++ src/gui/text.h | 29 +++++++++++++++++++++++++++++ 8 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 src/gui/text.cpp create mode 100644 src/gui/text.h diff --git a/Makefile b/Makefile index 311d13e..c0697cb 100755 --- a/Makefile +++ b/Makefile @@ -78,6 +78,7 @@ OBJS = \ obj/gui.o \ obj/guimisc.o \ obj/menu.o \ + obj/text.o \ obj/textedit.o \ obj/window.o \ \ diff --git a/src/apple2.cpp b/src/apple2.cpp index 34e7f80..fa7323a 100755 --- a/src/apple2.cpp +++ b/src/apple2.cpp @@ -62,13 +62,14 @@ uint8 ram[0x10000], rom[0x10000]; // RAM & ROM spaces uint8 diskRom[0x100]; // Disk ROM space V65C02REGS mainCPU; uint8 appleType = APPLE_TYPE_II; +FloppyDrive floppyDrive; // Local variables static uint8 lastKeyPressed = 0; static bool keyDown = false; -static FloppyDrive floppyDrive; +//static FloppyDrive floppyDrive; enum { LC_BANK_1, LC_BANK_2 }; diff --git a/src/apple2.h b/src/apple2.h index cff8eed..65fae5c 100755 --- a/src/apple2.h +++ b/src/apple2.h @@ -3,6 +3,7 @@ // #include "types.h" +#include "floppy.h" enum { APPLE_TYPE_II, APPLE_TYPE_IIE, APPLE_TYPE_IIC }; @@ -10,3 +11,4 @@ enum { APPLE_TYPE_II, APPLE_TYPE_IIE, APPLE_TYPE_IIC }; extern uint8 ram[0x10000], rom[0x10000]; // RAM & ROM pointers extern uint8 appleType; +extern FloppyDrive floppyDrive; diff --git a/src/floppy.cpp b/src/floppy.cpp index 942ffd9..dc558cf 100755 --- a/src/floppy.cpp +++ b/src/floppy.cpp @@ -37,6 +37,7 @@ uint8 FloppyDrive::doSector[16] = { 0x0, 0x7, 0xE, 0x6, 0xD, 0x5, 0xC, 0x4, 0xB, 0x3, 0xA, 0x2, 0x9, 0x1, 0x8, 0xF }; uint8 FloppyDrive::poSector[16] = { 0x0, 0x8, 0x1, 0x9, 0x2, 0xA, 0x3, 0xB, 0x4, 0xC, 0x5, 0xD, 0x6, 0xE, 0x7, 0xF }; +char FloppyDrive::nameBuf[MAX_PATH]; // FloppyDrive class implementation... @@ -462,6 +463,43 @@ void FloppyDrive::DenybblizeImage(uint8 driveNum) } } +const char * FloppyDrive::GetImageName(uint8 driveNum/*= 0*/) +{ + // Set up a zero-length string for return value + nameBuf[0] = 0; + + if (driveNum > 1) + { + WriteLog("FLOPPY: Attempted to get image name for drive #%u!\n", driveNum); + return nameBuf; + } + + // Now we attempt to strip out extraneous paths/extensions to get just the filename + const char * startOfFile = strrchr(imageName[driveNum], '/'); + const char * startOfExt = strrchr(imageName[driveNum], '.'); + + // If there isn't a path, assume we're starting at the beginning + if (startOfFile == NULL) + startOfFile = &imageName[driveNum][0]; + else + startOfFile++; + + // If there isn't an extension, assume it's at the terminating NULL + if (startOfExt == NULL) + startOfExt = &imageName[driveNum][0] + strlen(imageName[driveNum]); + + // Now copy the filename (may copy nothing!) + int j = 0; + + for(const char * i=startOfFile; i 0) +// DrawString(screenBuffer, extents.x + offsetX, extents.y + offsetY, false, "%s", text.c_str()); + DrawStringOpaque(screen, extents.x, extents.y, fgColor, bgColor, "%s", text.c_str()); +} diff --git a/src/gui/text.h b/src/gui/text.h new file mode 100644 index 0000000..696fd46 --- /dev/null +++ b/src/gui/text.h @@ -0,0 +1,29 @@ +// +// Static text class +// +// by James L. Hammons +// + +#ifndef __TEXT_H__ +#define __TEXT_H__ + +#include +#include "element.h" + +class Text: public Element +{ + public: + Text(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0, Element * parent = NULL); + Text(uint32 x, uint32 y, std::string s, uint32 fg = 0xFF8484FF, uint32 bg = 0xFF84FF4D, Element * parent = NULL); + virtual void HandleKey(SDLKey key) {} + virtual void HandleMouseMove(uint32 x, uint32 y) {} + virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) {} + virtual void Draw(void); + virtual void Notify(Element *) {} + + protected: +// uint32 fgColor, bgColor; + std::string text; +}; + +#endif // __TEXT_H__ -- 2.37.2