// 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
// --- ---------- ------------------------------------------------------------
// 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);
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.
#endif
}
-void DiskWindow::HandleKey(SDLKey key)
+void DiskWindow::HandleKey(SDL_Scancode key)
{
Window::HandleKey(key);
#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++)
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);
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;
{
// 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);
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();