From 6cffb30330c8e47e99423658b607215ad2bf270f Mon Sep 17 00:00:00 2001 From: Andrea Date: Sun, 10 Jan 2021 16:33:06 +0000 Subject: [PATCH] FrameBase: some changes to ease implementations (PR #910) . simplify the interface FrameBase to make it easier to implement it for different cases (remove HDC and make parameters more explicit) . remove functions which are only called on a Win32Frame (in which case a cast is guaranteed to succeed) . otherwise there is the risk that every FrameBase implementation wants to add its own variants. . FrameBase::FrameRefreshStatus() simplify implementation: pass all flags explicitly --- source/Configuration/PageConfig.cpp | 25 +- source/Configuration/PageDisk.cpp | 4 +- source/Configuration/PropertySheetHelper.cpp | 1 - source/Debugger/Debug.cpp | 24 +- source/Debugger/Debugger_Display.cpp | 7 +- source/Disk.cpp | 28 +- source/FrameBase.h | 10 +- source/Harddisk.cpp | 8 +- source/Keyboard.cpp | 6 +- source/Pravets.cpp | 2 +- source/Utilities.cpp | 4 +- source/Windows/AppleWin.cpp | 4 +- source/Windows/Win32Frame.cpp | 21 ++ source/Windows/Win32Frame.h | 75 ++++- source/Windows/WinFrame.cpp | 301 +++++++++---------- source/Windows/WinFrame.h | 11 - 16 files changed, 292 insertions(+), 239 deletions(-) diff --git a/source/Configuration/PageConfig.cpp b/source/Configuration/PageConfig.cpp index b5026ab6..1b24a08b 100644 --- a/source/Configuration/PageConfig.cpp +++ b/source/Configuration/PageConfig.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "PropertySheet.h" #include "../Windows/AppleWin.h" -#include "../Windows/WinFrame.h" +#include "../Windows/Win32Frame.h" #include "../Registry.h" #include "../SerialComms.h" #include "../resource/resource.h" @@ -115,7 +115,7 @@ INT_PTR CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPA break; case IDC_MONOCOLOR: - GetFrame().ChooseMonochromeColor(); + Win32Frame::GetWin32Frame().ChooseMonochromeColor(); break; case IDC_CHECK_CONFIRM_REBOOT: @@ -201,7 +201,8 @@ INT_PTR CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPA m_PropertySheetHelper.FillComboBox(hWnd,IDC_VIDEOTYPE, GetVideo().GetVideoChoices(), GetVideo().GetVideoType()); CheckDlgButton(hWnd, IDC_CHECK_HALF_SCAN_LINES, GetVideo().IsVideoStyle(VS_HALF_SCANLINES) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_CHECK_FS_SHOW_SUBUNIT_STATUS, GetFullScreenShowSubunitStatus() ? BST_CHECKED : BST_UNCHECKED); + Win32Frame& win32Frame = Win32Frame::GetWin32Frame(); + CheckDlgButton(hWnd, IDC_CHECK_FS_SHOW_SUBUNIT_STATUS, win32Frame.GetFullScreenShowSubunitStatus() ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_CHECK_VERTICAL_BLEND, GetVideo().IsVideoStyle(VS_COLOR_VERTICAL_BLEND) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hWnd, IDC_CHECK_VERTICAL_BLEND), (GetVideo().GetVideoType() == VT_COLOR_IDEALIZED) ? TRUE : FALSE); @@ -271,6 +272,7 @@ INT_PTR CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPA void CPageConfig::DlgOK(HWND hWnd) { bool bVideoReinit = false; + Win32Frame& win32Frame = Win32Frame::GetWin32Frame(); const VideoType_e newVideoType = (VideoType_e) SendDlgItemMessage(hWnd, IDC_VIDEOTYPE, CB_GETCURSEL, 0, 0); if (GetVideo().GetVideoType() != newVideoType) @@ -312,34 +314,35 @@ void CPageConfig::DlgOK(HWND hWnd) { GetVideo().Config_Save_Video(); - GetFrame().FrameRefreshStatus(DRAW_TITLE, false); + win32Frame.FrameRefreshStatus(DRAW_TITLE); GetVideo().VideoReinitialize(); if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) { - GetFrame().VideoRedrawScreen(); + win32Frame.VideoRedrawScreen(); } } // const bool bNewFSSubunitStatus = IsDlgButtonChecked(hWnd, IDC_CHECK_FS_SHOW_SUBUNIT_STATUS) ? true : false; - if (GetFullScreenShowSubunitStatus() != bNewFSSubunitStatus) + + if (win32Frame.GetFullScreenShowSubunitStatus() != bNewFSSubunitStatus) { REGSAVE(TEXT(REGVALUE_FS_SHOW_SUBUNIT_STATUS), bNewFSSubunitStatus ? 1 : 0); - GetFrame().SetFullScreenShowSubunitStatus(bNewFSSubunitStatus); + win32Frame.SetFullScreenShowSubunitStatus(bNewFSSubunitStatus); - if (IsFullScreen()) - GetFrame().FrameRefreshStatus(DRAW_BACKGROUND | DRAW_LEDS | DRAW_DISK_STATUS); + if (win32Frame.IsFullScreen()) + win32Frame.FrameRefreshStatus(DRAW_BACKGROUND | DRAW_LEDS | DRAW_DISK_STATUS); } // const BOOL bNewConfirmReboot = IsDlgButtonChecked(hWnd, IDC_CHECK_CONFIRM_REBOOT) ? 1 : 0; - if (GetFrame().g_bConfirmReboot != bNewConfirmReboot) + if (win32Frame.g_bConfirmReboot != bNewConfirmReboot) { REGSAVE(TEXT(REGVALUE_CONFIRM_REBOOT), bNewConfirmReboot); - GetFrame().g_bConfirmReboot = bNewConfirmReboot; + win32Frame.g_bConfirmReboot = bNewConfirmReboot; } // diff --git a/source/Configuration/PageDisk.cpp b/source/Configuration/PageDisk.cpp index 92cbda58..0720f54c 100644 --- a/source/Configuration/PageDisk.cpp +++ b/source/Configuration/PageDisk.cpp @@ -91,14 +91,14 @@ INT_PTR CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARA if (HIWORD(wparam) == CBN_SELCHANGE) { HandleFloppyDriveCombo(hWnd, DRIVE_1, LOWORD(wparam)); - GetFrame().FrameRefreshStatus(DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); } break; case IDC_COMBO_DISK2: if (HIWORD(wparam) == CBN_SELCHANGE) { HandleFloppyDriveCombo(hWnd, DRIVE_2, LOWORD(wparam)); - GetFrame().FrameRefreshStatus(DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); } break; case IDC_COMBO_HDD1: diff --git a/source/Configuration/PropertySheetHelper.cpp b/source/Configuration/PropertySheetHelper.cpp index f164b2d6..e80c2b2a 100644 --- a/source/Configuration/PropertySheetHelper.cpp +++ b/source/Configuration/PropertySheetHelper.cpp @@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../Windows/AppleWin.h" // g_nAppMode, g_uScrollLockToggle, sg_PropertySheet #include "../CardManager.h" #include "../Disk.h" -#include "../Windows/WinFrame.h" #include "../Log.h" #include "../Registry.h" #include "../SaveState.h" diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index b9159a2e..744278c5 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../Memory.h" #include "../NTSC.h" #include "../SoundCore.h" // SoundCore_SetFade() +#include "../Windows/Win32Frame.h" #include "../Windows/WinFrame.h" // #define DEBUG_COMMAND_HELP 1 @@ -752,7 +753,7 @@ Update_t CmdBenchmarkStop (int nArgs) g_bBenchmarking = false; DebugEnd(); - GetFrame().FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE | DRAW_DISK_STATUS); GetFrame().VideoRedrawScreen(); DWORD currtime = GetTickCount(); while ((extbench = GetTickCount()) != currtime) @@ -1962,7 +1963,7 @@ static Update_t CmdGo (int nArgs, const bool bFullSpeed) g_bGoCmd_ReinitFlag = true; g_nAppMode = MODE_STEPPING; - GetFrame().FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE | DRAW_DISK_STATUS); SoundCore_SetFade(FADE_IN); @@ -2031,7 +2032,7 @@ Update_t CmdTrace (int nArgs) g_nDebugStepStart = regs.pc; g_nDebugStepUntil = -1; g_nAppMode = MODE_STEPPING; - GetFrame().FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE | DRAW_DISK_STATUS); DebugContinueStepping(true); return UPDATE_ALL; // TODO: Verify // 0 @@ -2091,7 +2092,7 @@ Update_t CmdTraceLine (int nArgs) g_nDebugStepUntil = -1; g_nAppMode = MODE_STEPPING; - GetFrame().FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE | DRAW_DISK_STATUS); DebugContinueStepping(true); return UPDATE_ALL; // TODO: Verify // 0 @@ -3771,7 +3772,7 @@ Update_t CmdDisk ( int nArgs) return HelpLastCommand(); diskCard.EjectDisk( iDrive ); - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); } else if (iParam == PARAM_DISK_PROTECT) @@ -3785,7 +3786,7 @@ Update_t CmdDisk ( int nArgs) bProtect = g_aArgs[ 3 ].nValue ? true : false; diskCard.SetProtect( iDrive, bProtect ); - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); } else { @@ -3796,7 +3797,7 @@ Update_t CmdDisk ( int nArgs) // DISK # "Diskname" diskCard.InsertDisk( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE ); - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); } return UPDATE_CONSOLE_DISPLAY; @@ -8547,7 +8548,7 @@ void DebugBegin () GetDebuggerMemDC(); g_nAppMode = MODE_DEBUG; - GetFrame().FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE | DRAW_DISK_STATUS); if (GetMainCpu() == CPU_6502) { @@ -8734,7 +8735,7 @@ void DebugContinueStepping(const bool bCallerWillUpdateDisplay/*=false*/) SoundCore_SetFade(FADE_OUT); // NB. Call when MODE_STEPPING (not MODE_DEBUG) - see function g_nAppMode = MODE_DEBUG; - GetFrame().FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE | DRAW_DISK_STATUS); // BUG: PageUp, Trace - doesn't center cursor g_nDisasmCurAddress = regs.pc; @@ -9662,9 +9663,10 @@ void DebuggerMouseClick( int x, int y ) int nFontHeight = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nLineHeight * GetViewportScale(); // do picking + Win32Frame& win32Frame = Win32Frame::GetWin32Frame(); - const int nOffsetX = IsFullScreen() ? GetFullScreenOffsetX() : Get3DBorderWidth(); - const int nOffsetY = IsFullScreen() ? GetFullScreenOffsetY() : Get3DBorderHeight(); + const int nOffsetX = win32Frame.IsFullScreen() ? win32Frame.GetFullScreenOffsetX() : win32Frame.Get3DBorderWidth(); + const int nOffsetY = win32Frame.IsFullScreen() ? win32Frame.GetFullScreenOffsetY() : win32Frame.Get3DBorderHeight(); const int nOffsetInScreenX = x - nOffsetX; const int nOffsetInScreenY = y - nOffsetY; diff --git a/source/Debugger/Debugger_Display.cpp b/source/Debugger/Debugger_Display.cpp index 915ba308..25915f99 100644 --- a/source/Debugger/Debugger_Display.cpp +++ b/source/Debugger/Debugger_Display.cpp @@ -36,6 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../Interface.h" #include "../CPU.h" #include "../Windows/WinFrame.h" +#include "../Windows/Win32Frame.h" #include "../LanguageCard.h" #include "../Memory.h" #include "../Mockingboard.h" @@ -671,8 +672,10 @@ void StretchBltMemToFrameDC(void) int nViewportCX, nViewportCY; GetViewportCXCY(nViewportCX, nViewportCY); - int xdest = IsFullScreen() ? GetFullScreenOffsetX() : 0; - int ydest = IsFullScreen() ? GetFullScreenOffsetY() : 0; + Win32Frame& win32Frame = Win32Frame::GetWin32Frame(); + + int xdest = win32Frame.IsFullScreen() ? win32Frame.GetFullScreenOffsetX() : 0; + int ydest = win32Frame.IsFullScreen() ? win32Frame.GetFullScreenOffsetY() : 0; int wdest = nViewportCX; int hdest = nViewportCY; diff --git a/source/Disk.cpp b/source/Disk.cpp index ee9a7e89..a0128c00 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -218,7 +218,7 @@ void Disk2InterfaceCard::CheckSpinning(const bool stateChanged, const ULONG uExe m_floppyDrive[m_currDrive].m_spinning = SPINNING_CYCLES; if (modeChanged) - GetFrame().FrameDrawDiskLEDS( (HDC)0 ); + GetFrame().FrameDrawDiskLEDS(); if (modeChanged) { @@ -510,7 +510,7 @@ void __stdcall Disk2InterfaceCard::ControlStepper(WORD, WORD address, BYTE, BYTE pDrive->m_phasePrecise = newPhasePrecise; pFloppy->m_trackimagedata = false; m_formatTrack.DriveNotWritingTrack(); - GetFrame().FrameDrawDiskStatus((HDC)0); // Show track status (GH#201) + GetFrame().FrameDrawDiskStatus(); // Show track status (GH#201) } #if LOG_DISK_PHASES @@ -682,7 +682,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname)) { EjectDisk(!drive); - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); } } @@ -1032,7 +1032,7 @@ void __stdcall Disk2InterfaceCard::ReadWrite(WORD pc, WORD addr, BYTE bWrite, BY // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!! if ((pFloppy->m_byte & 0xFF) == 0) - GetFrame().FrameDrawDiskStatus( (HDC)0 ); + GetFrame().FrameDrawDiskStatus(); } //=========================================================================== @@ -1183,7 +1183,7 @@ void __stdcall Disk2InterfaceCard::DataLatchReadWriteWOZ(WORD pc, WORD addr, BYT // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!! if ((floppy.m_byte & 0xFF) == 0) - GetFrame().FrameDrawDiskStatus((HDC)0); + GetFrame().FrameDrawDiskStatus(); } void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemainder) @@ -1542,11 +1542,11 @@ void Disk2InterfaceCard::Reset(const bool bIsPowerCycle) m_floppyDrive[DRIVE_2].m_spinning = 0; m_floppyDrive[DRIVE_2].m_writelight = 0; - GetFrame().FrameRefreshStatus(DRAW_LEDS, false); + GetFrame().FrameRefreshStatus(DRAW_LEDS); } InitFirmware(GetCxRomPeripheral()); - GetFrame().FrameRefreshStatus(DRAW_TITLE, false); + GetFrame().FrameRefreshStatus(DRAW_TITLE); } void Disk2InterfaceCard::ResetSwitches(void) @@ -1684,7 +1684,7 @@ void __stdcall Disk2InterfaceCard::SetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uE m_floppyDrive[m_currDrive].m_writelight = WRITELIGHT_CYCLES; if (modechange) - GetFrame().FrameDrawDiskLEDS( (HDC)0 ); + GetFrame().FrameDrawDiskLEDS(); } //=========================================================================== @@ -1700,8 +1700,8 @@ void Disk2InterfaceCard::UpdateDriveState(DWORD cycles) { if (!(pDrive->m_spinning -= MIN(pDrive->m_spinning, cycles))) { - GetFrame().FrameDrawDiskLEDS( (HDC)0 ); - GetFrame().FrameDrawDiskStatus( (HDC)0 ); + GetFrame().FrameDrawDiskLEDS(); + GetFrame().FrameDrawDiskStatus(); } } @@ -1713,8 +1713,8 @@ void Disk2InterfaceCard::UpdateDriveState(DWORD cycles) { if (!(pDrive->m_writelight -= MIN(pDrive->m_writelight, cycles))) { - GetFrame().FrameDrawDiskLEDS( (HDC)0 ); - GetFrame().FrameDrawDiskStatus( (HDC)0 ); + GetFrame().FrameDrawDiskLEDS(); + GetFrame().FrameDrawDiskStatus(); } } } @@ -1770,7 +1770,7 @@ bool Disk2InterfaceCard::DriveSwap(void) SaveLastDiskImage(DRIVE_1); SaveLastDiskImage(DRIVE_2); - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES, false); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); return true; } @@ -2261,7 +2261,7 @@ bool Disk2InterfaceCard::LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT LoadSnapshotDriveUnit(yamlLoadHelper, DRIVE_1, version); LoadSnapshotDriveUnit(yamlLoadHelper, DRIVE_2, version); - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); return true; } diff --git a/source/FrameBase.h b/source/FrameBase.h index 315999e4..6ebbf677 100644 --- a/source/FrameBase.h +++ b/source/FrameBase.h @@ -18,9 +18,10 @@ public: virtual void Initialize(void) = 0; virtual void Destroy(void) = 0; - virtual void FrameDrawDiskLEDS(HDC hdc) = 0; - virtual void FrameDrawDiskStatus(HDC hdc) = 0; - virtual void FrameRefreshStatus(int, bool bUpdateDiskStatus = true) = 0; + virtual void FrameDrawDiskLEDS() = 0; + virtual void FrameDrawDiskStatus() = 0; + + virtual void FrameRefreshStatus(int drawflags) = 0; virtual void FrameUpdateApple2Type() = 0; virtual void FrameSetCursorPosByMousePos() = 0; @@ -32,9 +33,6 @@ public: virtual void SetLoadedSaveStateFlag(const bool bFlag) = 0; virtual void VideoPresentScreen(void) = 0; - virtual void ChooseMonochromeColor(void) = 0; - virtual void Benchmark(void) = 0; - virtual void DisplayLogo(void) = 0; void VideoRefreshScreen(uint32_t uRedrawWholeScreenVideoMode, bool bRedrawWholeScreen); void VideoRedrawScreen(void); diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 6911fb61..ccbcb965 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -417,7 +417,7 @@ BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename) if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname)) { HD_Unplug(!iDrive); - GetFrame().FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); } } @@ -711,7 +711,7 @@ static BYTE __stdcall HD_IO_EMUL(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG if( pHDD->hd_status_prev != pHDD->hd_status_next ) // Update LEDs if state changes { pHDD->hd_status_prev = pHDD->hd_status_next; - GetFrame().FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); } #endif @@ -740,7 +740,7 @@ bool HD_ImageSwap(void) HD_SaveLastDiskImage(HARDDISK_1); HD_SaveLastDiskImage(HARDDISK_2); - GetFrame().FrameRefreshStatus(DRAW_LEDS, false); + GetFrame().FrameRefreshStatus(DRAW_LEDS); return true; } @@ -900,7 +900,7 @@ bool HD_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version, co HD_SetEnabled(true); - GetFrame().FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); return true; } diff --git a/source/Keyboard.cpp b/source/Keyboard.cpp index 6d43aa8a..169d7b0c 100644 --- a/source/Keyboard.cpp +++ b/source/Keyboard.cpp @@ -301,7 +301,7 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII) if (g_Apple2Type == A2TYPE_TK30002E) { g_bTK3KModeKey = (GetKeyState(VK_SCROLL) & 1) ? true : false; // Sync with the Scroll Lock status - GetFrame().FrameRefreshStatus(DRAW_LEDS); // TODO: Implement |Mode| LED in the UI; make it appear only when in TK3000 mode + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); // TODO: Implement |Mode| LED in the UI; make it appear only when in TK3000 mode GetFrame().VideoRedrawScreen(); // TODO: Still need to implement page mode switching and 'whatnot' } return; @@ -537,7 +537,7 @@ void KeybToggleCapsLock () if (!IS_APPLE2) { g_bCapsLock = (GetKeyState(VK_CAPITAL) & 1); - GetFrame().FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); } } @@ -546,7 +546,7 @@ void KeybToggleP8ACapsLock () { _ASSERT(g_Apple2Type == A2TYPE_PRAVETS8A); P8CAPS_ON = !P8CAPS_ON; - GetFrame().FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); // g_bP8CapsLock= g_bP8CapsLock?false:true; //The same as the upper, but slower } diff --git a/source/Pravets.cpp b/source/Pravets.cpp index fce3e449..03f0c249 100644 --- a/source/Pravets.cpp +++ b/source/Pravets.cpp @@ -44,6 +44,6 @@ void PravetsReset(void) { P8CAPS_ON = false; TapeWrite(0, 0, 0, 0 ,0); - GetFrame().FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); } } diff --git a/source/Utilities.cpp b/source/Utilities.cpp index 7bc3f1fa..b4860d2d 100644 --- a/source/Utilities.cpp +++ b/source/Utilities.cpp @@ -402,7 +402,7 @@ void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], boo { bRes = DoDiskInsert(slot, DRIVE_1, szImageName_drive[DRIVE_1]); LogFileOutput("Init: S%d, DoDiskInsert(D1), res=%d\n", slot, bRes); - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); // floppy activity LEDs and floppy buttons + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); // floppy activity LEDs and floppy buttons bBoot = true; } @@ -442,7 +442,7 @@ void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot) { bRes = DoHardDiskInsert(HARDDISK_1, szImageName_harddisk[HARDDISK_1]); LogFileOutput("Init: DoHardDiskInsert(HDD1), res=%d\n", bRes); - GetFrame().FrameRefreshStatus(DRAW_LEDS); // harddisk activity LED + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); // harddisk activity LED bBoot = true; } diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index f20a6d6e..d23fe8b2 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -768,7 +768,7 @@ static void OneTimeInitialization(HINSTANCE passinstance) LogFileOutput("Init: RegisterExtensions()\n"); } - FrameRegisterClass(); + Win32Frame::GetWin32Frame().FrameRegisterClass(); LogFileOutput("Init: FrameRegisterClass()\n"); } @@ -843,7 +843,7 @@ static void RepeatInitialization(void) LogFileOutput("Main: VideoInitialize()\n"); LogFileOutput("Main: FrameCreateWindow() - pre\n"); - FrameCreateWindow(); // GetFrame().g_hFrameWindow is now valid + Win32Frame::GetWin32Frame().FrameCreateWindow(); // GetFrame().g_hFrameWindow is now valid LogFileOutput("Main: FrameCreateWindow() - post\n"); // Init palette color diff --git a/source/Windows/Win32Frame.cpp b/source/Windows/Win32Frame.cpp index bb7a8893..b0ea09fe 100644 --- a/source/Windows/Win32Frame.cpp +++ b/source/Windows/Win32Frame.cpp @@ -22,6 +22,20 @@ Win32Frame::Win32Frame() g_hLogoBitmap = (HBITMAP)0; g_hDeviceBitmap = (HBITMAP)0; g_hDeviceDC = (HDC)0; + g_bAltEnter_ToggleFullScreen = false; + g_bIsFullScreen = false; + g_bShowingCursor = true; + g_bLastCursorInAppleViewport = false; + g_uCount100msec = 0; + g_TimerIDEvent_100msec = 0; + g_bUsingCursor = FALSE; + g_bAppActive = false; + g_bFrameActive = false; + g_windowMinimized = false; + g_bFullScreen_ShowSubunitStatus = true; + g_win_fullscreen_scale = 1; + g_win_fullscreen_offsetx = 0; + g_win_fullscreen_offsety = 0; } void Win32Frame::videoCreateDIBSection(Video & video) @@ -499,3 +513,10 @@ void Win32Frame::DDUninit(void) } #undef SAFE_RELEASE + +Win32Frame& Win32Frame::GetWin32Frame() +{ + FrameBase& frameBase = GetFrame(); + Win32Frame& win32Frame = dynamic_cast(frameBase); + return win32Frame; +} diff --git a/source/Windows/Win32Frame.h b/source/Windows/Win32Frame.h index e095474b..08a401fd 100644 --- a/source/Windows/Win32Frame.h +++ b/source/Windows/Win32Frame.h @@ -4,14 +4,23 @@ class Video; +#if 0 // enable non-integral full-screen scaling +#define FULLSCREEN_SCALE_TYPE float +#else +#define FULLSCREEN_SCALE_TYPE int +#endif + class Win32Frame : public FrameBase { public: Win32Frame(); - virtual void FrameDrawDiskLEDS(HDC hdc); - virtual void FrameDrawDiskStatus(HDC hdc); - virtual void FrameRefreshStatus(int, bool bUpdateDiskStatus = true); + static Win32Frame& GetWin32Frame(); + + virtual void FrameDrawDiskLEDS(); + virtual void FrameDrawDiskStatus(); + + virtual void FrameRefreshStatus(int drawflags); virtual void FrameUpdateApple2Type(); virtual void FrameSetCursorPosByMousePos(); @@ -25,21 +34,73 @@ public: virtual void Initialize(void); virtual void Destroy(void); virtual void VideoPresentScreen(void); - virtual void ChooseMonochromeColor(void); - virtual void Benchmark(void); - virtual void DisplayLogo(void); + + bool GetFullScreenShowSubunitStatus(void); + int GetFullScreenOffsetX(void); + int GetFullScreenOffsetY(void); + bool IsFullScreen(void); + void FrameRegisterClass(); + void FrameCreateWindow(void); + void ChooseMonochromeColor(void); + UINT Get3DBorderWidth(void); + UINT Get3DBorderHeight(void); + LRESULT WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam); + private: + static BOOL CALLBACK DDEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext); + void videoCreateDIBSection(Video& video); void VideoDrawLogoBitmap(HDC hDstDC, int xoff, int yoff, int srcw, int srch, int scale); - static BOOL CALLBACK DDEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext); bool DDInit(void); void DDUninit(void); + void Benchmark(void); + void DisplayLogo(void); + void FrameDrawDiskLEDS(HDC hdc); // overloaded Win32 only, call via GetWin32Frame() + void FrameDrawDiskStatus(HDC hdc); // overloaded Win32 only, call via GetWin32Frame() + void EraseButton(int number); + void DrawButton(HDC passdc, int number); + void DrawCrosshairs(int x, int y); + void DrawFrameWindow(bool bPaintingWindow = false); + void DrawStatusArea(HDC passdc, int drawflags); + void ProcessButtonClick(int button, bool bFromButtonUI = false); + bool ConfirmReboot(bool bFromButtonUI); + void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive); + void RelayEvent(UINT message, WPARAM wparam, LPARAM lparam); + void SetFullScreenMode(); + void SetNormalMode(); + void SetUsingCursor(BOOL bNewValue); + void SetupTooltipControls(void); + void FrameResizeWindow(int nNewScale); + void RevealCursor(); + void ScreenWindowResize(const bool bCtrlKey); + void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int x=0, int y=0); + void DrawCrosshairsMouse(); + void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeavingAppleScreen); + void CreateGdiObjects(void); + void FrameShowCursor(BOOL bShow); + void FullScreenRevealCursor(void); + + bool g_bAltEnter_ToggleFullScreen; // Default for ALT+ENTER is to toggle between windowed and full-screen modes + bool g_bIsFullScreen; + bool g_bShowingCursor; + bool g_bLastCursorInAppleViewport; + UINT_PTR g_TimerIDEvent_100msec; + UINT g_uCount100msec; COLORREF customcolors[256]; // MONOCHROME is last custom color HBITMAP g_hLogoBitmap; HBITMAP g_hDeviceBitmap; HDC g_hDeviceDC; LPBITMAPINFO g_pFramebufferinfo; + BOOL g_bUsingCursor; // TRUE = AppleWin is using (hiding) the mouse-cursor && restricting cursor to window - see SetUsingCursor() + bool g_bAppActive; + bool g_bFrameActive; + bool g_windowMinimized; + std::string driveTooltip; + bool g_bFullScreen_ShowSubunitStatus; + FULLSCREEN_SCALE_TYPE g_win_fullscreen_scale; + int g_win_fullscreen_offsetx; + int g_win_fullscreen_offsety; static const UINT MAX_DRAW_DEVICES = 10; char* draw_devices[MAX_DRAW_DEVICES]; diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index bb613f55..be5c9ad9 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -105,7 +105,6 @@ static DWORD g_aDiskFullScreenColorsLED[ NUM_DISK_STATUS ] = static HBITMAP buttonbitmap[BUTTONS]; -static bool g_bAppActive = false; static HBRUSH btnfacebrush = (HBRUSH)0; static HPEN btnfacepen = (HPEN)0; static HPEN btnhighlightpen = (HPEN)0; @@ -118,62 +117,22 @@ static int buttony = BUTTONY; static HDC g_hFrameDC = (HDC)0; static RECT framerect = {0,0,0,0}; -static bool g_bIsFullScreen = false; - static BOOL helpquit = 0; static HFONT smallfont = (HFONT)0; static HWND tooltipwindow = (HWND)0; -static BOOL g_bUsingCursor = FALSE; // TRUE = AppleWin is using (hiding) the mouse-cursor && restricting cursor to window - see SetUsingCursor() static int viewportx = VIEWPORTX; // Default to Normal (non-FullScreen) mode static int viewporty = VIEWPORTY; // Default to Normal (non-FullScreen) mode -static UINT_PTR g_TimerIDEvent_100msec = 0; -static UINT g_uCount100msec = 0; - -static bool g_bShowingCursor = true; -static bool g_bLastCursorInAppleViewport = false; - -static void DrawStatusArea (HDC passdc, int drawflags); -static void ProcessButtonClick (int button, bool bFromButtonUI=false); -void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive); -void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam); -void SetFullScreenMode (); -void SetNormalMode (); -static void SetUsingCursor(BOOL); static bool FileExists(std::string strFilename); bool g_bScrollLock_FullSpeed = false; -static bool g_bFullScreen32Bit = true; - -#if 0 // enable non-integral full-screen scaling -#define FULLSCREEN_SCALE_TYPE float -#else -#define FULLSCREEN_SCALE_TYPE int -#endif static RECT g_main_window_saved_rect; static int g_main_window_saved_style; static int g_main_window_saved_exstyle; -static FULLSCREEN_SCALE_TYPE g_win_fullscreen_scale = 1; -static int g_win_fullscreen_offsetx = 0; -static int g_win_fullscreen_offsety = 0; - -static bool g_bFrameActive = false; -static bool g_windowMinimized = false; - -static std::string driveTooltip; - -// __ Prototypes __________________________________________________________________________________ -void DrawCrosshairs (int x, int y); -void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int x=0, int y=0); -static void ScreenWindowResize(const bool bCtrlKey); -void FrameResizeWindow(int nNewScale); - // ========================================================================== -static bool g_bAltEnter_ToggleFullScreen = true; // Default for ALT+ENTER is to toggle between windowed and full-screen modes - void Win32Frame::SetAltEnterToggleFullScreen(bool mode) { g_bAltEnter_ToggleFullScreen = mode; @@ -191,19 +150,19 @@ void Win32Frame::SetAltEnterToggleFullScreen(bool mode) // - Optional: Draw status area to frame DC // -UINT Get3DBorderWidth(void) +UINT Win32Frame::Get3DBorderWidth(void) { return IsFullScreen() ? 0 : VIEWPORTX; } -UINT Get3DBorderHeight(void) +UINT Win32Frame::Get3DBorderHeight(void) { return IsFullScreen() ? 0 : VIEWPORTY; } //=========================================================================== -static void FrameShowCursor(BOOL bShow) +void Win32Frame::FrameShowCursor(BOOL bShow) { int nCount; @@ -231,7 +190,7 @@ static void FrameShowCursor(BOOL bShow) // . Ctrl-Left mouse button // . PAUSE pressed (when MODE_RUNNING) // . AppleWin's main window is activated/deactivated -static void RevealCursor() +void Win32Frame::RevealCursor() { CMouseInterface* pMouseCard = GetCardMgr().GetMouseCard(); @@ -255,7 +214,7 @@ static void RevealCursor() // . WM_MOUSEMOVE event // . Switch from full-screen to normal (windowed) mode // . AppleWin's main window is activated/deactivated -static void FullScreenRevealCursor(void) +void Win32Frame::FullScreenRevealCursor(void) { if (!g_bIsFullScreen) return; @@ -272,13 +231,13 @@ static void FullScreenRevealCursor(void) //=========================================================================== -#define LOADBUTTONBITMAP(bitmapname) LoadImage(GetFrame().g_hInstance,bitmapname, \ +#define LOADBUTTONBITMAP(bitmapname) LoadImage(g_hInstance,bitmapname, \ IMAGE_BITMAP,0,0, \ LR_CREATEDIBSECTION | \ LR_LOADMAP3DCOLORS | \ LR_LOADTRANSPARENT); -static void CreateGdiObjects(void) +void Win32Frame::CreateGdiObjects(void) { memset(buttonbitmap, 0, BUTTONS*sizeof(HBITMAP)); @@ -397,9 +356,9 @@ static void DrawBitmapRect (HDC dc, int x, int y, LPRECT rect, HBITMAP bitmap) { } //=========================================================================== -static void DrawButton (HDC passdc, int number) { +void Win32Frame::DrawButton (HDC passdc, int number) { FrameReleaseDC(); - HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow)); + HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); int x = buttonx; int y = buttony+number*BUTTONCY; if (number == buttondown) { @@ -436,17 +395,17 @@ static void DrawButton (HDC passdc, int number) { NULL); } if (!passdc) - ReleaseDC(GetFrame().g_hFrameWindow,dc); + ReleaseDC(g_hFrameWindow,dc); } //=========================================================================== // NB. x=y=0 means erase only -static void DrawCrosshairs (int x, int y) { +void Win32Frame::DrawCrosshairs (int x, int y) { static int lastx = 0; static int lasty = 0; FrameReleaseDC(); - HDC dc = GetDC(GetFrame().g_hFrameWindow); + HDC dc = GetDC(g_hFrameWindow); #define LINE(x1,y1,x2,y2) MoveToEx(dc,x1,y1,NULL); LineTo(dc,x2,y2); // ERASE THE OLD CROSSHAIRS @@ -531,18 +490,17 @@ static void DrawCrosshairs (int x, int y) { #undef LINE lastx = x; lasty = y; - ReleaseDC(GetFrame().g_hFrameWindow,dc); + ReleaseDC(g_hFrameWindow,dc); } //=========================================================================== -static void DrawFrameWindow (bool bPaintingWindow = false); -static void DrawFrameWindow (bool bPaintingWindow/*=false*/) +void Win32Frame::DrawFrameWindow (bool bPaintingWindow/*=false*/) { FrameReleaseDC(); PAINTSTRUCT ps; HDC dc = bPaintingWindow - ? BeginPaint(GetFrame().g_hFrameWindow,&ps) - : GetDC(GetFrame().g_hFrameWindow); + ? BeginPaint(g_hFrameWindow,&ps) + : GetDC(g_hFrameWindow); if (!g_bIsFullScreen) { @@ -584,28 +542,27 @@ static void DrawFrameWindow (bool bPaintingWindow/*=false*/) // DRAW THE CONTENTS OF THE EMULATED SCREEN if (g_nAppMode == MODE_LOGO) - GetFrame().DisplayLogo(); + DisplayLogo(); else if (g_nAppMode == MODE_DEBUG) DebugDisplay(); else - GetFrame().VideoRedrawScreen(); + VideoRedrawScreen(); if (bPaintingWindow) - EndPaint(GetFrame().g_hFrameWindow,&ps); + EndPaint(g_hFrameWindow,&ps); else - ReleaseDC(GetFrame().g_hFrameWindow,dc); + ReleaseDC(g_hFrameWindow,dc); } //=========================================================================== -static bool g_bFullScreen_ShowSubunitStatus = true; -bool IsFullScreen(void) +bool Win32Frame::IsFullScreen(void) { return g_bIsFullScreen; } -bool GetFullScreenShowSubunitStatus(void) +bool Win32Frame::GetFullScreenShowSubunitStatus(void) { return g_bFullScreen_ShowSubunitStatus; } @@ -615,6 +572,11 @@ void Win32Frame::SetFullScreenShowSubunitStatus(bool bShow) g_bFullScreen_ShowSubunitStatus = bShow; } +void Win32Frame::FrameDrawDiskLEDS() +{ + FrameDrawDiskLEDS((HDC)0); +} + //=========================================================================== void Win32Frame::FrameDrawDiskLEDS( HDC passdc ) { @@ -638,7 +600,7 @@ void Win32Frame::FrameDrawDiskLEDS( HDC passdc ) // Draw Track/Sector FrameReleaseDC(); - HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow)); + HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); int x = buttonx; int y = buttony+BUTTONS*BUTTONCY+1; @@ -667,6 +629,11 @@ void Win32Frame::FrameDrawDiskLEDS( HDC passdc ) } } +void Win32Frame::FrameDrawDiskStatus() +{ + FrameDrawDiskStatus((HDC)0); +} + // Feature Request #201 Show track status // https://github.com/AppleWin/AppleWin/issues/201 //=========================================================================== @@ -762,7 +729,7 @@ void Win32Frame::FrameDrawDiskStatus( HDC passdc ) // Draw Track/Sector FrameReleaseDC(); - HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow)); + HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); int x = buttonx; int y = buttony+BUTTONS*BUTTONCY+4; @@ -823,9 +790,9 @@ void Win32Frame::FrameDrawDiskStatus( HDC passdc ) } //=========================================================================== -static void DrawStatusArea (HDC passdc, int drawflags) +void Win32Frame::DrawStatusArea (HDC passdc, int drawflags) { - if (GetFrame().g_hFrameWindow == NULL) + if (g_hFrameWindow == NULL) { // TC: Fix drawing of drive buttons before frame created: // . Main init loop: LoadConfiguration() called before FrameCreateWindow(), eg: @@ -834,7 +801,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) } FrameReleaseDC(); - HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow)); + HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); int x = buttonx; int y = buttony+BUTTONS*BUTTONCY+1; const bool bCaps = KeybGetCapsStatus(); @@ -859,7 +826,9 @@ static void DrawStatusArea (HDC passdc, int drawflags) SelectObject(dc,smallfont); if (drawflags & DRAW_DISK_STATUS) - GetFrame().FrameDrawDiskStatus( dc ); + { + FrameDrawDiskStatus(dc); + } #if HD_LED SetTextAlign(dc, TA_RIGHT | TA_TOP); @@ -926,10 +895,10 @@ static void DrawStatusArea (HDC passdc, int drawflags) if (drawflags & DRAW_LEDS) { - GetFrame().FrameDrawDiskLEDS( dc ); + FrameDrawDiskLEDS( dc ); if (drawflags & DRAW_DISK_STATUS) - GetFrame().FrameDrawDiskStatus( dc ); + FrameDrawDiskStatus( dc ); if (!IS_APPLE2) { @@ -957,7 +926,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) if (drawflags & DRAW_TITLE) { GetAppleWindowTitle(); // SetWindowText() // WindowTitle - SendMessage(GetFrame().g_hFrameWindow,WM_SETTEXT,0,(LPARAM)g_pAppTitle.c_str()); + SendMessage(g_hFrameWindow,WM_SETTEXT,0,(LPARAM)g_pAppTitle.c_str()); } if (drawflags & DRAW_BUTTON_DRIVES) @@ -968,23 +937,33 @@ static void DrawStatusArea (HDC passdc, int drawflags) } if (!passdc) - ReleaseDC(GetFrame().g_hFrameWindow,dc); + ReleaseDC(g_hFrameWindow,dc); } //=========================================================================== -static void EraseButton (int number) { +void Win32Frame::EraseButton (int number) { RECT rect; rect.left = buttonx; rect.right = rect.left+BUTTONCX; rect.top = buttony+number*BUTTONCY; rect.bottom = rect.top+BUTTONCY; - InvalidateRect(GetFrame().g_hFrameWindow,&rect,1); + InvalidateRect(g_hFrameWindow,&rect,1); } //=========================================================================== -LRESULT CALLBACK FrameWndProc ( +LRESULT CALLBACK FrameWndProc( + HWND window, + UINT message, + WPARAM wparam, + LPARAM lparam) +{ + Win32Frame& win32Frame = Win32Frame::GetWin32Frame(); + return win32Frame.WndProc(window, message, wparam, lparam); +} + +LRESULT Win32Frame::WndProc( HWND window, UINT message, WPARAM wparam, @@ -1039,7 +1018,7 @@ LRESULT CALLBACK FrameWndProc ( } if (g_TimerIDEvent_100msec) { - BOOL bRes = KillTimer(GetFrame().g_hFrameWindow, g_TimerIDEvent_100msec); + BOOL bRes = KillTimer(g_hFrameWindow, g_TimerIDEvent_100msec); LogFileOutput("KillTimer(g_TimerIDEvent_100msec), res=%d\n", bRes ? 1 : 0); g_TimerIDEvent_100msec = 0; } @@ -1063,7 +1042,7 @@ LRESULT CALLBACK FrameWndProc ( CpuDestroy(); MemDestroy(); SpkrDestroy(); - GetFrame().Destroy(); + Destroy(); MB_Destroy(); DeleteGdiObjects(); DIMouse::DirectInputUninit(window); // NB. do before window is destroyed @@ -1073,7 +1052,7 @@ LRESULT CALLBACK FrameWndProc ( case WM_CREATE: LogFileOutput("WM_CREATE\n"); - GetFrame().g_hFrameWindow = window; // NB. g_hFrameWindow by CreateWindow() + g_hFrameWindow = window; // NB. g_hFrameWindow by CreateWindow() CreateGdiObjects(); LogFileOutput("WM_CREATE: CreateGdiObjects()\n"); @@ -1185,12 +1164,12 @@ LRESULT CALLBACK FrameWndProc ( // lparam = modifiers: shift, ctrl, alt, win if (wparam == VK_SNAPSHOT_560) { - GetFrame().Video_TakeScreenShot( Video::SCREENSHOT_560x384 ); + Video_TakeScreenShot( Video::SCREENSHOT_560x384 ); } else if (wparam == VK_SNAPSHOT_280) // ( lparam & MOD_SHIFT ) { - GetFrame().Video_TakeScreenShot( Video::SCREENSHOT_280x192 ); + Video_TakeScreenShot( Video::SCREENSHOT_280x192 ); } else if (wparam == VK_SNAPSHOT_TEXT) // ( lparam & MOD_CONTROL ) @@ -1253,13 +1232,13 @@ LRESULT CALLBACK FrameWndProc ( { UINT debugVideoMode; if ( DebugGetVideoMode(&debugVideoMode) ) - GetFrame().VideoRefreshScreen(debugVideoMode, true); + VideoRefreshScreen(debugVideoMode, true); else - GetFrame().VideoPresentScreen(); + VideoPresentScreen(); } else { - GetFrame().VideoPresentScreen(); + VideoPresentScreen(); } } @@ -1321,7 +1300,7 @@ LRESULT CALLBACK FrameWndProc ( } DrawStatusArea((HDC)0,DRAW_TITLE); if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) - GetFrame().VideoRedrawScreen(); + VideoRedrawScreen(); } else if ((wparam == VK_SCROLL) && GetPropertySheet().GetScrollLockToggle()) { @@ -1425,7 +1404,7 @@ LRESULT CALLBACK FrameWndProc ( const int iDrive = wparam - VK_F3; ProcessDiskPopupMenu( window, pt, iDrive ); - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); DrawButton((HDC)0, iButton); } else @@ -1496,7 +1475,7 @@ LRESULT CALLBACK FrameWndProc ( POINT Point; GetCursorPos(&Point); - ScreenToClient(GetFrame().g_hFrameWindow, &Point); + ScreenToClient(g_hFrameWindow, &Point); const int iOutOfBoundsX=0, iOutOfBoundsY=0; UpdateMouseInAppleViewport(iOutOfBoundsX, iOutOfBoundsY, Point.x, Point.y); @@ -1733,7 +1712,7 @@ LRESULT CALLBACK FrameWndProc ( ProcessDiskPopupMenu( window, pt, iDrive ); } - GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); DrawButton((HDC)0, iButton); } } @@ -1808,7 +1787,7 @@ LRESULT CALLBACK FrameWndProc ( DrawStatusArea((HDC)0,DRAW_TITLE); HCURSOR oldcursor = SetCursor(LoadCursor(0,IDC_WAIT)); g_nAppMode = MODE_BENCHMARK; - GetFrame().Benchmark(); + Win32Frame::GetWin32Frame().Benchmark(); g_nAppMode = MODE_LOGO; ResetMachineState(); SetCursor(oldcursor); @@ -1902,7 +1881,7 @@ LRESULT CALLBACK FrameWndProc ( //=========================================================================== // Process: VK_F6 -static void ScreenWindowResize(const bool bCtrlKey) +void Win32Frame::ScreenWindowResize(const bool bCtrlKey) { static int nOldViewportScale = kDEFAULT_VIEWPORT_SCALE; @@ -1924,12 +1903,12 @@ static void ScreenWindowResize(const bool bCtrlKey) } } -static bool ConfirmReboot(bool bFromButtonUI) +bool Win32Frame::ConfirmReboot(bool bFromButtonUI) { - if (!bFromButtonUI || !GetFrame().g_bConfirmReboot) + if (!bFromButtonUI || !g_bConfirmReboot) return true; - int res = MessageBox(GetFrame().g_hFrameWindow, + int res = MessageBox(g_hFrameWindow, "Are you sure you want to reboot?\n" "(All data will be lost!)\n" "\n" @@ -1943,7 +1922,7 @@ static bool ConfirmReboot(bool bFromButtonUI) return res == IDYES; } -static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) +void Win32Frame::ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) { SoundCore_SetFade(FADE_OUT); bool bAllowFadeIn = true; @@ -1967,7 +1946,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) DeleteFile(filename_with_zone_identifier.c_str()); } - HtmlHelp(GetFrame().g_hFrameWindow,filename.c_str(),HH_DISPLAY_TOC,0); + HtmlHelp(g_hFrameWindow,filename.c_str(),HH_DISPLAY_TOC,0); helpquit = 1; } break; @@ -2004,7 +1983,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) } DrawStatusArea((HDC)0,DRAW_TITLE); - GetFrame().VideoRedrawScreen(); + VideoRedrawScreen(); break; case BTN_DRIVE1: @@ -2074,7 +2053,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/menus/usingmenus.asp // http://www.codeproject.com/menu/MenusForBeginners.asp?df=100&forumid=67645&exp=0&select=903061 -void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) +void Win32Frame::ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) { if (GetCardMgr().QuerySlot(SLOT6) != CT_Disk2) return; @@ -2101,7 +2080,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) // Load the menu template containing the shortcut menu from the // application's resources. - HMENU hmenu = LoadMenu(GetFrame().g_hInstance, MAKEINTRESOURCE(IDR_MENU_DISK_POPUP)); // menu template + HMENU hmenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU_DISK_POPUP)); // menu template if (hmenu == NULL) return; @@ -2161,7 +2140,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) //if(!filename1.compare("\"\"") == false) //Do not use this, for some reason it does not work!!! if(!filename1.compare(sFileNameEmpty) ) { - int MB_Result = MessageBox(GetFrame().g_hFrameWindow, "No disk image loaded. Do you want to run CiderPress anyway?" ,"No disk image.", MB_ICONINFORMATION|MB_YESNO); + int MB_Result = MessageBox(g_hFrameWindow, "No disk image loaded. Do you want to run CiderPress anyway?" ,"No disk image.", MB_ICONINFORMATION|MB_YESNO); if (MB_Result == IDYES) { if (FileExists (PathToCiderPress )) @@ -2170,7 +2149,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) } else { - MessageBox(GetFrame().g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); + MessageBox(g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); } } } @@ -2182,7 +2161,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) } else { - MessageBox(GetFrame().g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); + MessageBox(g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); } } } @@ -2194,11 +2173,11 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) //=========================================================================== -void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { +void Win32Frame::RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { if (g_bIsFullScreen) return; MSG msg; - msg.hwnd = GetFrame().g_hFrameWindow; + msg.hwnd = g_hFrameWindow; msg.message = message; msg.wParam = wparam; msg.lParam = lparam; @@ -2208,17 +2187,17 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { //=========================================================================== -int GetFullScreenOffsetX(void) +int Win32Frame::GetFullScreenOffsetX(void) { return g_win_fullscreen_offsetx; } -int GetFullScreenOffsetY(void) +int Win32Frame::GetFullScreenOffsetY(void) { return g_win_fullscreen_offsety; } -void SetFullScreenMode () +void Win32Frame::SetFullScreenMode () { #ifdef NO_DIRECT_X @@ -2232,14 +2211,14 @@ void SetFullScreenMode () buttonover = -1; - g_main_window_saved_style = GetWindowLong(GetFrame().g_hFrameWindow, GWL_STYLE); - g_main_window_saved_exstyle = GetWindowLong(GetFrame().g_hFrameWindow, GWL_EXSTYLE); - GetWindowRect(GetFrame().g_hFrameWindow, &g_main_window_saved_rect); - SetWindowLong(GetFrame().g_hFrameWindow, GWL_STYLE , g_main_window_saved_style & ~(WS_CAPTION | WS_THICKFRAME)); - SetWindowLong(GetFrame().g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); + g_main_window_saved_style = GetWindowLong(g_hFrameWindow, GWL_STYLE); + g_main_window_saved_exstyle = GetWindowLong(g_hFrameWindow, GWL_EXSTYLE); + GetWindowRect(g_hFrameWindow, &g_main_window_saved_rect); + SetWindowLong(g_hFrameWindow, GWL_STYLE , g_main_window_saved_style & ~(WS_CAPTION | WS_THICKFRAME)); + SetWindowLong(g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); monitor_info.cbSize = sizeof(monitor_info); - GetMonitorInfo(MonitorFromWindow(GetFrame().g_hFrameWindow, MONITOR_DEFAULTTONEAREST), &monitor_info); + GetMonitorInfo(MonitorFromWindow(g_hFrameWindow, MONITOR_DEFAULTTONEAREST), &monitor_info); left = monitor_info.rcMonitor.left; top = monitor_info.rcMonitor.top; @@ -2253,23 +2232,23 @@ void SetFullScreenMode () g_win_fullscreen_scale = (scalex <= scaley) ? scalex : scaley; g_win_fullscreen_offsetx = ((int)width - (int)(g_win_fullscreen_scale * GetVideo().GetFrameBufferBorderlessWidth())) / 2; g_win_fullscreen_offsety = ((int)height - (int)(g_win_fullscreen_scale * GetVideo().GetFrameBufferBorderlessHeight())) / 2; - SetWindowPos(GetFrame().g_hFrameWindow, NULL, left, top, (int)width, (int)height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); + SetWindowPos(g_hFrameWindow, NULL, left, top, (int)width, (int)height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); g_bIsFullScreen = true; - GetFrame().SetViewportScale(g_win_fullscreen_scale, true); + SetViewportScale(g_win_fullscreen_scale, true); buttonx = GetFullScreenOffsetX() + g_nViewportCX + VIEWPORTX*2; buttony = GetFullScreenOffsetY(); viewportx = VIEWPORTX; // TC-TODO: Should be zero too? (Since there's no 3D border in full-screen) viewporty = 0; // GH#464 - InvalidateRect(GetFrame().g_hFrameWindow,NULL,1); + InvalidateRect(g_hFrameWindow,NULL,1); #endif // NO_DIRECT_X } //=========================================================================== -void SetNormalMode () +void Win32Frame::SetNormalMode () { FullScreenRevealCursor(); // Do before clearing g_bIsFullScreen flag @@ -2282,9 +2261,9 @@ void SetNormalMode () g_win_fullscreen_offsetx = 0; g_win_fullscreen_offsety = 0; g_win_fullscreen_scale = 1; - SetWindowLong(GetFrame().g_hFrameWindow, GWL_STYLE, g_main_window_saved_style); - SetWindowLong(GetFrame().g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle); - SetWindowPos(GetFrame().g_hFrameWindow, NULL, + SetWindowLong(g_hFrameWindow, GWL_STYLE, g_main_window_saved_style); + SetWindowLong(g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle); + SetWindowPos(g_hFrameWindow, NULL, g_main_window_saved_rect.left, g_main_window_saved_rect.top, g_main_window_saved_rect.right - g_main_window_saved_rect.left, @@ -2294,7 +2273,7 @@ void SetNormalMode () } //=========================================================================== -static void SetUsingCursor (BOOL bNewValue) +void Win32Frame::SetUsingCursor (BOOL bNewValue) { if (bNewValue == g_bUsingCursor) return; @@ -2306,18 +2285,18 @@ static void SetUsingCursor (BOOL bNewValue) // Set TRUE when: // . Using mouse for joystick emulation // . Using mousecard and mouse is restricted to window - SetCapture(GetFrame().g_hFrameWindow); + SetCapture(g_hFrameWindow); RECT rect = { viewportx+2, // left viewporty+2, // top viewportx+g_nViewportCX-1, // right viewporty+g_nViewportCY-1}; // bottom - ClientToScreen(GetFrame().g_hFrameWindow,(LPPOINT)&rect.left); - ClientToScreen(GetFrame().g_hFrameWindow,(LPPOINT)&rect.right); + ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.left); + ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.right); ClipCursor(&rect); FrameShowCursor(FALSE); POINT pt; GetCursorPos(&pt); - ScreenToClient(GetFrame().g_hFrameWindow,&pt); + ScreenToClient(g_hFrameWindow,&pt); DrawCrosshairs(pt.x,pt.y); } else @@ -2346,13 +2325,13 @@ int Win32Frame::SetViewportScale(int nNewScale, bool bForce /*=false*/) return nNewScale; } -static void SetupTooltipControls(void) +void Win32Frame::SetupTooltipControls(void) { TOOLINFO toolinfo; toolinfo.cbSize = sizeof(toolinfo); toolinfo.uFlags = TTF_CENTERTIP; - toolinfo.hwnd = GetFrame().g_hFrameWindow; - toolinfo.hinst = GetFrame().g_hInstance; + toolinfo.hwnd = g_hFrameWindow; + toolinfo.hinst = g_hInstance; toolinfo.lpszText = LPSTR_TEXTCALLBACK; toolinfo.rect.left = BUTTONX; toolinfo.rect.right = toolinfo.rect.left+BUTTONCX+1; @@ -2397,14 +2376,14 @@ static void GetWidthHeight(int& nWidth, int& nHeight) #endif } -static void FrameResizeWindow(int nNewScale) +void Win32Frame::FrameResizeWindow(int nNewScale) { int nOldWidth, nOldHeight; GetWidthHeight(nOldWidth, nOldHeight); - nNewScale = GetFrame().SetViewportScale(nNewScale); + nNewScale = SetViewportScale(nNewScale); - GetWindowRect(GetFrame().g_hFrameWindow, &framerect); + GetWindowRect(g_hFrameWindow, &framerect); int nXPos = framerect.left; int nYPos = framerect.top; @@ -2419,20 +2398,20 @@ static void FrameResizeWindow(int nNewScale) irect.left = irect.top = 0; irect.right = nOldWidth; irect.bottom = nOldHeight; - InvalidateRect(GetFrame().g_hFrameWindow, &irect, TRUE); + InvalidateRect(g_hFrameWindow, &irect, TRUE); } // Resize the window int nNewWidth, nNewHeight; GetWidthHeight(nNewWidth, nNewHeight); - MoveWindow(GetFrame().g_hFrameWindow, nXPos, nYPos, nNewWidth, nNewHeight, TRUE); - UpdateWindow(GetFrame().g_hFrameWindow); + MoveWindow(g_hFrameWindow, nXPos, nYPos, nNewWidth, nNewHeight, TRUE); + UpdateWindow(g_hFrameWindow); // Remove the tooltips for the old window size TOOLINFO toolinfo = {0}; toolinfo.cbSize = sizeof(toolinfo); - toolinfo.hwnd = GetFrame().g_hFrameWindow; + toolinfo.hwnd = g_hFrameWindow; toolinfo.uId = 0; SendMessage(tooltipwindow, TTM_DELTOOL, 0, (LPARAM)&toolinfo); toolinfo.uId = 1; @@ -2448,7 +2427,7 @@ static void FrameResizeWindow(int nNewScale) //=========================================================================== -void FrameCreateWindow(void) +void Win32Frame::FrameCreateWindow(void) { int nWidth, nHeight; @@ -2474,7 +2453,7 @@ void FrameCreateWindow(void) if (g_nViewportScale == 2 && (nWidth > GetSystemMetrics(SM_CXSCREEN) || nHeight > GetSystemMetrics(SM_CYSCREEN))) { g_nMaxViewportScale = 1; - GetFrame().SetViewportScale(1); + SetViewportScale(1); GetWidthHeight(nWidth, nHeight); } @@ -2485,11 +2464,11 @@ void FrameCreateWindow(void) if (RegLoadValue(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_WINDOW_X_POS), 1, (DWORD*)&nXPos)) { - if ((nXPos > nXScreen) && !GetFrame().g_bMultiMon) + if ((nXPos > nXScreen) && !g_bMultiMon) nXPos = -1; // Not fully visible, so default to centre position } - if ((nXPos == -1) && !GetFrame().g_bMultiMon) + if ((nXPos == -1) && !g_bMultiMon) nXPos = nXScreen / 2; } @@ -2500,11 +2479,11 @@ void FrameCreateWindow(void) if (RegLoadValue(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_WINDOW_Y_POS), 1, (DWORD*)&nYPos)) { - if ((nYPos > nYScreen) && !GetFrame().g_bMultiMon) + if ((nYPos > nYScreen) && !g_bMultiMon) nYPos = -1; // Not fully visible, so default to centre position } - if ((nYPos == -1) && !GetFrame().g_bMultiMon) + if ((nYPos == -1) && !g_bMultiMon) nYPos = nYScreen / 2; } @@ -2516,7 +2495,7 @@ void FrameCreateWindow(void) GetAppleWindowTitle(); // NB. g_hFrameWindow also set by WM_CREATE - NB. CreateWindow() must synchronously send WM_CREATE - GetFrame().g_hFrameWindow = CreateWindow( + g_hFrameWindow = CreateWindow( TEXT("APPLE2FRAME"), g_pAppTitle.c_str(), WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | @@ -2524,20 +2503,20 @@ void FrameCreateWindow(void) nXPos, nYPos, nWidth, nHeight, HWND_DESKTOP, (HMENU)0, - GetFrame().g_hInstance, NULL ); + g_hInstance, NULL ); InitCommonControls(); tooltipwindow = CreateWindow( TOOLTIPS_CLASS,NULL,TTS_ALWAYSTIP, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, - GetFrame().g_hFrameWindow, + g_hFrameWindow, (HMENU)0, - GetFrame().g_hInstance,NULL ); + g_hInstance,NULL ); SetupTooltipControls(); _ASSERT(g_TimerIDEvent_100msec == 0); - g_TimerIDEvent_100msec = SetTimer(GetFrame().g_hFrameWindow, IDEVENT_TIMER_100MSEC, 100, NULL); + g_TimerIDEvent_100msec = SetTimer(g_hFrameWindow, IDEVENT_TIMER_100MSEC, 100, NULL); LogFileOutput("FrameCreateWindow: SetTimer(), id=0x%08X\n", g_TimerIDEvent_100msec); } @@ -2560,28 +2539,26 @@ void FrameReleaseDC () { } //=========================================================================== -void Win32Frame::FrameRefreshStatus (int drawflags, bool bUpdateDiskStatus) { - // NB. 99% of the time we draw the disk status. On DiskDriveSwap() we don't. - drawflags |= bUpdateDiskStatus ? DRAW_DISK_STATUS : 0; +void Win32Frame::FrameRefreshStatus (int drawflags) { DrawStatusArea((HDC)0,drawflags); } //=========================================================================== -void FrameRegisterClass () { +void Win32Frame::FrameRegisterClass () { WNDCLASSEX wndclass; memset(&wndclass, 0, sizeof(WNDCLASSEX)); wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.style = CS_OWNDC | CS_BYTEALIGNCLIENT; wndclass.lpfnWndProc = FrameWndProc; - wndclass.hInstance = GetFrame().g_hInstance; - wndclass.hIcon = LoadIcon(GetFrame().g_hInstance,TEXT("APPLEWIN_ICON")); + wndclass.hInstance = g_hInstance; + wndclass.hIcon = LoadIcon(g_hInstance,TEXT("APPLEWIN_ICON")); wndclass.hCursor = LoadCursor(0,IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); #if ENABLE_MENU wndclass.lpszMenuName = (LPCSTR)IDR_MENU1; #endif wndclass.lpszClassName = TEXT("APPLE2FRAME"); - wndclass.hIconSm = (HICON)LoadImage(GetFrame().g_hInstance,TEXT("APPLEWIN_ICON"), + wndclass.hIconSm = (HICON)LoadImage(g_hInstance,TEXT("APPLEWIN_ICON"), IMAGE_ICON,16,16,LR_DEFAULTCOLOR); RegisterClassEx(&wndclass); } @@ -2606,7 +2583,7 @@ void Win32Frame::FrameSetCursorPosByMousePos() if (!GetCardMgr().IsMouseCardInstalled()) return; - if (!GetFrame().g_hFrameWindow || g_bShowingCursor) + if (!g_hFrameWindow || g_bShowingCursor) return; int iX, iMinX, iMaxX; @@ -2620,7 +2597,7 @@ void Win32Frame::FrameSetCursorPosByMousePos() int iWindowY = (int)(fScaleY * (float)g_nViewportCY); POINT Point = {viewportx+2, viewporty+2}; // top-left - ClientToScreen(GetFrame().g_hFrameWindow, &Point); + ClientToScreen(g_hFrameWindow, &Point); SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY); #if defined(_DEBUG) && 0 // OutputDebugString() when cursor position changes since last time @@ -2639,14 +2616,14 @@ void Win32Frame::FrameSetCursorPosByMousePos() // Called when: // . UpdateMouseInAppleViewport() is called and mouse leaving/entering Apple screen area // . NB. Not called when leaving & mouse clipped to Apple screen area -static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeavingAppleScreen) +void Win32Frame::FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeavingAppleScreen) { _ASSERT(GetCardMgr().IsMouseCardInstalled()); if (!GetCardMgr().IsMouseCardInstalled()) return; // char szDbg[200]; - if (!GetFrame().g_hFrameWindow || (g_bShowingCursor && bLeavingAppleScreen) || (!g_bShowingCursor && !bLeavingAppleScreen)) + if (!g_hFrameWindow || (g_bShowingCursor && bLeavingAppleScreen) || (!g_bShowingCursor && !bLeavingAppleScreen)) return; int iX, iMinX, iMaxX; @@ -2668,7 +2645,7 @@ static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeav int iWindowY = (int)(fScaleY * (float)g_nViewportCY) + dy; POINT Point = {viewportx+2, viewporty+2}; // top-left - ClientToScreen(GetFrame().g_hFrameWindow, &Point); + ClientToScreen(g_hFrameWindow, &Point); SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY); // sprintf(szDbg, "[MOUSE_LEAVING ] x=%d, y=%d (Scale: x,y=%f,%f; iX,iY=%d,%d)\n", iWindowX, iWindowY, fScaleX, fScaleY, iX, iY); OutputDebugString(szDbg); } @@ -2696,7 +2673,7 @@ static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeav } } -static void DrawCrosshairsMouse() +void Win32Frame::DrawCrosshairsMouse() { _ASSERT(GetCardMgr().IsMouseCardInstalled()); if (!GetCardMgr().IsMouseCardInstalled()) @@ -2723,7 +2700,7 @@ static void DrawCrosshairsMouse() //#define _DEBUG_SHOW_CURSOR // NB. Get an ASSERT on LMB (after Ctrl+LMB) #endif -static void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int x, int y) +void Win32Frame::UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int x, int y) { const bool bOutsideAppleViewport = iOutOfBoundsX || iOutOfBoundsY; @@ -2766,7 +2743,7 @@ static void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int } else { - GetFrame().FrameSetCursorPosByMousePos(); // Set cursor to Apple position each time + FrameSetCursorPosByMousePos(); // Set cursor to Apple position each time } DrawCrosshairsMouse(); diff --git a/source/Windows/WinFrame.h b/source/Windows/WinFrame.h index a9b18a41..5499b37b 100644 --- a/source/Windows/WinFrame.h +++ b/source/Windows/WinFrame.h @@ -10,24 +10,13 @@ // Prototypes - void FrameCreateWindow(void); HDC FrameGetDC (); void FrameReleaseDC (); - void FrameRegisterClass (); int GetViewportScale(void); void GetViewportCXCY(int& nViewportCX, int& nViewportCY); - bool IsFullScreen(void); - bool GetFullScreenShowSubunitStatus(void); - LRESULT CALLBACK FrameWndProc ( HWND window, UINT message, WPARAM wparam, LPARAM lparam ); - - int GetFullScreenOffsetX(void); - int GetFullScreenOffsetY(void); - - UINT Get3DBorderWidth(void); - UINT Get3DBorderHeight(void);