]> Shamusworld >> Repos - apple2/blobdiff - src/gui/diskwindow.cpp
Added floppy #2 saving, statistics to makefile.
[apple2] / src / gui / diskwindow.cpp
index 5029372a91705edb49562f12a4dea96fb51a6e78..1e91a6fe5f6af0455ec53bf06d27909532ac73dd 100644 (file)
@@ -2,9 +2,9 @@
 // DISKWINDOW.CPP
 //
 // Graphical User Interface disk window class
-// by James L. Hammons
+// by James Hammons
 //
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
 //
 // WHO  WHEN        WHAT
 // ---  ----------  ------------------------------------------------------------
@@ -48,7 +48,7 @@ IDEA: Make a recently used file list when ejecting a disk, either here or in
 // NOTE: FG/BG colors are hard-wired
 //
 
-DiskWindow::DiskWindow(FloppyDrive * fdp, uint32 x/*= 0*/, uint32 y/*= 0*/): Window(x, y, 200, 140, NULL), floppyDrive(fdp)
+DiskWindow::DiskWindow(FloppyDrive * fdp, uint32_t x/*= 0*/, uint32_t y/*= 0*/): Window(x, y, 200, 140, NULL), floppyDrive(fdp)
 {
 //Could probably move this into the initializer list as well...
 //     closeButton = new Button(w - (cbWidth + 1), 1, cbUp, cbHover, cbDown, this);
@@ -75,12 +75,23 @@ DiskWindow::DiskWindow(FloppyDrive * fdp, uint32 x/*= 0*/, uint32 y/*= 0*/): Win
 
        newDisk1 = new Button(4, 132, "NewDisk1", this);
        newDisk2 = new Button(4, 152, "NewDisk2", this);
-       swap = new Button(4, 176, "Swap Disks", this);
+       writeProtect1 = new Button(4, 176, "WriteProt1", this);
+       writeProtect2 = new Button(4, 196, "WriteProt2", this);
+       swap = new Button(4, 220, "Swap Disks", this);
+
+       writeProtect1->SetText((floppyDrive->DiskIsWriteProtected(0) ? "no write" : "write"));
+       writeProtect2->SetText((floppyDrive->DiskIsWriteProtected(1) ? "no write" : "write"));
 
        AddElement(newDisk1);
        AddElement(newDisk2);
+       AddElement(writeProtect1);
+       AddElement(writeProtect2);
        AddElement(swap);
 
+       // In spite of this, it's still blanking out the background...
+       // Actually, come to think of it, it's got a stale backbuffer when
+       // the GUI comes in again... !!! FIX !!!
+#warning !!! FIX !!!
        SetBackgroundDraw(false);
 //     CreateBackstore();
        Draw(); // Can we do this in the constructor??? Mebbe.
@@ -93,7 +104,7 @@ printf("Inside ~DiskWindow()...\n");
 #endif
 }
 
-void DiskWindow::HandleKey(SDLKey key)
+void DiskWindow::HandleKey(SDL_Scancode key)
 {
        Window::HandleKey(key);
 #if 0
@@ -105,34 +116,34 @@ void DiskWindow::HandleKey(SDLKey key)
        }
 
        // Handle the items this window contains...
-       for(uint32 i=0; i<list.size(); i++)
+       for(uint32_t i=0; i<list.size(); i++)
                list[i]->HandleKey(key);
 #endif
 }
 
-void DiskWindow::HandleMouseMove(uint32 x, uint32 y)
+void DiskWindow::HandleMouseMove(uint32_t x, uint32_t y)
 {
        Window::HandleMouseMove(x, y);
 #if 0
        // Handle the items this window contains...
-       for(uint32 i=0; i<list.size(); i++)
+       for(uint32_t i=0; i<list.size(); i++)
                // Make coords relative to upper right corner of this window...
                list[i]->HandleMouseMove(x - extents.x, y - extents.y);
 #endif
 }
 
-void DiskWindow::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
+void DiskWindow::HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown)
 {
        Window::HandleMouseButton(x, y, mouseDown);
 #if 0
 #if 1
        // Handle the items this window contains...
-       for(uint32 i=0; i<list.size(); i++)
+       for(uint32_t i=0; i<list.size(); i++)
                // Make coords relative to upper right corner of this window...
                list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
 #else //? This works in draggablewindow2...
        // Handle the items this window contains...
-       for(uint32 i=0; i<list.size(); i++)
+       for(uint32_t i=0; i<list.size(); i++)
        {
                // Make coords relative to upper right corner of this window...
                list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
@@ -153,7 +164,7 @@ void DiskWindow::Draw(void)
        SDL_FillRect(screen, &extents, bgColor);
 
        // Handle the items this window contains...
-       for(uint32 i=0; i<list.size(); i++)
+       for(uint32_t i=0; i<list.size(); i++)
                list[i]->Draw();
 
        needToRefreshScreen = true;
@@ -206,6 +217,17 @@ void DiskWindow::Notify(Element * e)
                {
                        // Put up a warning and give user a chance to exit this potentially
                        // disastrous action
+// Now, how to do this? Notify() isn't asynchronous...
+// And until we return from here, there is no GUI main loop to show any dialogs!
+/*
+what you could do is like this way:
+
+-- have a callback function for after the intermediate window gets dismissed
+-- have a separate GUI thread
+-- have a 2nd GUI object and run that loop to completion
+
+
+*/
                }
 
                floppyDrive->SaveImage(0);
@@ -234,6 +256,25 @@ void DiskWindow::Notify(Element * e)
                name2->SetText(floppyDrive->GetImageName(1));
                Draw();
        }
+       else if (e == writeProtect1)
+       {
+               floppyDrive->SetWriteProtect((floppyDrive->DiskIsWriteProtected(0) ? false : true), 0);
+//                     floppyDrive->SetWriteProtect(false, 0);
+//             else
+//                     floppyDrive->SetWriteProtect(true, 0);
+
+               // Housekeeping
+               writeProtect1->SetText((floppyDrive->DiskIsWriteProtected(0) ? "no write" : "write"));
+               Draw();
+       }
+       else if (e == writeProtect2)
+       {
+               floppyDrive->SetWriteProtect((floppyDrive->DiskIsWriteProtected(1) ? false : true), 1);
+
+               // Housekeeping
+               writeProtect2->SetText((floppyDrive->DiskIsWriteProtected(1) ? "no write" : "write"));
+               Draw();
+       }
        else if (e == swap)
        {
                floppyDrive->SwapImages();