]> Shamusworld >> Repos - apple2/commitdiff
diskwindow is *almost* usable!
authorShamus Hammons <jlhamm@acm.org>
Tue, 3 Feb 2009 05:30:08 +0000 (05:30 +0000)
committerShamus Hammons <jlhamm@acm.org>
Tue, 3 Feb 2009 05:30:08 +0000 (05:30 +0000)
src/floppy.cpp
src/floppy.h
src/gui/text.cpp
src/gui/text.h
src/gui/window.cpp
src/gui/window.h

index dc558cf7959d3471ebd4a3ba57a5c967ebae1b1f..56ea4147333a8aab7ff607bc1f62b96617067766 100755 (executable)
@@ -146,6 +146,8 @@ bool FloppyDrive::SaveImage(uint8 driveNum/*= 0*/)
        fwrite(disk[driveNum], 1, diskSize[driveNum], fp);
        fclose(fp);
 
+       WriteLog("FLOPPY: Successfully wrote image file '%s'...\n", imageName[driveNum]);
+
        return true;
 }
 
@@ -499,6 +501,31 @@ const char * FloppyDrive::GetImageName(uint8 driveNum/*= 0*/)
        return nameBuf;
 }
 
+void FloppyDrive::EjectImage(uint8 driveNum/*= 0*/)
+{
+       // Probably want to save a dirty image... ;-)
+       SaveImage(driveNum);
+
+       WriteLog("FLOPPY: Ejected image file '%s' from drive %u...\n", imageName[driveNum], driveNum);
+
+       if (disk[driveNum])
+               delete[] disk[driveNum];
+
+       disk[driveNum] = NULL;
+       diskSize[driveNum] = 0;
+       diskType[driveNum] = DT_UNKNOWN;
+       imageDirty[driveNum] = false;
+       imageName[driveNum][0] = 0;                     // Zero out filenames
+       memset(nybblizedImage[driveNum], 0xFF, 232960); // Doesn't matter if 00s or FFs...
+
+}
+
+bool FloppyDrive::DriveIsEmpty(uint8 driveNum/*= 0*/)
+{
+       // This is kinda gay, but it works
+       return (imageName[driveNum][0] == 0 ? true : false);
+}
+
 
 // Memory mapped I/O functions
 
index 29043439b5b1ac826c0a998dc75beb012a31d78c..7fe310f2a4951bc5d01f34990d8a37907bb8c701 100755 (executable)
@@ -28,6 +28,8 @@ class FloppyDrive
                void CreateBlankImage(uint8 driveNum = 0);
                void SwapImages(void);
                const char * GetImageName(uint8 driveNum = 0);
+               void EjectImage(uint8 driveNum = 0);
+               bool DriveIsEmpty(uint8 driveNum = 0);
 
                // I/O functions ($C0Ex accesses)
 
index cd65a6ac60b0a8751329509caef282d07e231872..d14903523d238f59e33e0db29686bfb09825d002 100644 (file)
@@ -29,3 +29,8 @@ void Text::Draw(void)
                DrawStringOpaque(screen, r.x, r.y, fgColor, bgColor, "%s", text.c_str());
        }
 }
+
+void Text::SetText(std::string s)
+{
+       text = s;
+}
index 696fd4666f064919136983699076bd3d0256bfc7..df3614b2d14e423050bd503dfa77c92d3a45e5db 100644 (file)
@@ -20,6 +20,7 @@ class Text: public Element
                virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) {}
                virtual void Draw(void);
                virtual void Notify(Element *) {}
+               void SetText(std::string s);
 
        protected:
 //             uint32 fgColor, bgColor;
index 9298cf97bc90d6be27d5e311ebdba384ba009ad0..28c0212a4b6466ab350993823f3523ccafb4b8c8 100755 (executable)
@@ -52,7 +52,7 @@ Window::Window(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*
        cbDown(SDL_CreateRGBSurfaceFrom(&closeBoxDown[4], cbWidth, cbHeight, 32, cbWidth * 4,
                MASK_R, MASK_G, MASK_B, MASK_A)),
        cbHover(SDL_CreateRGBSurfaceFrom(&closeBoxHover[4], cbWidth, cbHeight, 32, cbWidth * 4,
-               MASK_R, MASK_G, MASK_B, MASK_A))
+               MASK_R, MASK_G, MASK_B, MASK_A)), drawBackground(true)
 {
 //Could probably move this into the initializer list as well...
 //     closeButton = new Button(w - (cbWidth + 1), 1, cbUp, cbHover, cbDown, this);
@@ -130,9 +130,14 @@ void Window::Draw(void)
        for(uint32 i=0; i<list.size(); i++)
                list[i]->Draw();
 #else
-       // These are *always* top level and parentless, so no need to traverse up through
-       // the parent chain...
-       SDL_FillRect(screen, &extents, bgColor);
+       if (drawBackground)
+       {
+               // These are *always* top level and parentless, so no need to traverse up through
+               // the parent chain...
+               SDL_FillRect(screen, &extents, bgColor);
+       }
+       else
+               RestoreScreenFromBackstore();
 
        // Handle the items this window contains...
        for(uint32 i=0; i<list.size(); i++)
@@ -171,3 +176,8 @@ void Window::AddCloseButton(void)
                list.push_back(closeButton);
        }
 }
+
+void Window::SetBackgroundDraw(bool state)
+{
+       drawBackground = state;
+}
index 24b478b9ac7a53a9308fc9d028514bc8951fd717..fc3128204e1d0b736dcbd3ae6fc82578066a69db 100755 (executable)
@@ -25,6 +25,7 @@ class Window: public Element
                virtual void Notify(Element *);
                void AddElement(Element * e);
                void AddCloseButton(void);
+               void SetBackgroundDraw(bool);
 
        protected:
                void (* handler)(Element *);
@@ -34,6 +35,7 @@ class Window: public Element
        private:
                uint16 cbWidth, cbHeight;
                SDL_Surface * cbUp, * cbDown, * cbHover;
+               bool drawBackground;
 };
 
 #endif // __WINDOW_H__