2014-08-13 20:30:35 +00:00
|
|
|
/*
|
|
|
|
AppleWin : An Apple //e emulator for Windows
|
|
|
|
|
|
|
|
Copyright (C) 1994-1996, Michael O'Brien
|
|
|
|
Copyright (C) 1999-2001, Oliver Schmidt
|
|
|
|
Copyright (C) 2002-2005, Tom Charlesworth
|
|
|
|
Copyright (C) 2006-2014, Tom Charlesworth, Michael Pohoreski, Nick Westgate
|
|
|
|
|
|
|
|
AppleWin is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
AppleWin is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with AppleWin; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2012-03-27 21:20:36 +00:00
|
|
|
#include "StdAfx.h"
|
2014-08-13 20:30:35 +00:00
|
|
|
|
|
|
|
#include "..\AppleWin.h"
|
|
|
|
#include "..\Frame.h"
|
|
|
|
#include "..\Registry.h"
|
2012-03-27 21:20:36 +00:00
|
|
|
#include "..\resource\resource.h"
|
2014-08-13 20:30:35 +00:00
|
|
|
#include "PageDisk.h"
|
|
|
|
#include "PropertySheetHelper.h"
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
CPageDisk* CPageDisk::ms_this = 0; // reinit'd in ctor
|
|
|
|
|
|
|
|
const TCHAR CPageDisk::m_discchoices[] =
|
|
|
|
TEXT("Authentic Speed\0")
|
|
|
|
TEXT("Enhanced Speed\0");
|
|
|
|
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
BOOL CALLBACK CPageDisk::DlgProc(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
|
|
|
// Switch from static func to our instance
|
2012-05-06 22:14:03 +00:00
|
|
|
return CPageDisk::ms_this->DlgProcInternal(hWnd, message, wparam, lparam);
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
// Property Sheet notifications
|
|
|
|
|
|
|
|
switch (((LPPSHNOTIFY)lparam)->hdr.code)
|
|
|
|
{
|
2012-03-31 21:34:02 +00:00
|
|
|
case PSN_SETACTIVE:
|
|
|
|
// About to become the active page
|
|
|
|
m_PropertySheetHelper.SetLastPage(m_Page);
|
2012-05-06 22:14:03 +00:00
|
|
|
InitOptions(hWnd);
|
2012-03-31 21:34:02 +00:00
|
|
|
break;
|
2012-03-27 21:20:36 +00:00
|
|
|
case PSN_KILLACTIVE:
|
2012-05-06 22:14:03 +00:00
|
|
|
SetWindowLong(hWnd, DWL_MSGRESULT, FALSE); // Changes are valid
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case PSN_APPLY:
|
2012-05-06 22:14:03 +00:00
|
|
|
DlgOK(hWnd);
|
|
|
|
SetWindowLong(hWnd, DWL_MSGRESULT, PSNRET_NOERROR); // Changes are valid
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case PSN_QUERYCANCEL:
|
|
|
|
// Can use this to ask user to confirm cancel
|
|
|
|
break;
|
|
|
|
case PSN_RESET:
|
2012-05-06 22:14:03 +00:00
|
|
|
DlgCANCEL(hWnd);
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wparam))
|
|
|
|
{
|
|
|
|
case IDC_DISK1:
|
|
|
|
DiskSelect(DRIVE_1);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_DISK1, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_1));
|
2012-03-27 21:20:36 +00:00
|
|
|
FrameRefreshStatus(DRAW_BUTTON_DRIVES);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_DISK2:
|
|
|
|
DiskSelect(DRIVE_2);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_DISK2, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_2));
|
2012-03-27 21:20:36 +00:00
|
|
|
FrameRefreshStatus(DRAW_BUTTON_DRIVES);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_HDD1:
|
2012-05-06 22:14:03 +00:00
|
|
|
if(IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE))
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
|
|
|
HD_Select(HARDDISK_1);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_HDD1, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_1));
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_HDD2:
|
2012-05-06 22:14:03 +00:00
|
|
|
if(IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE))
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
|
|
|
HD_Select(HARDDISK_2);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_HDD2, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_2));
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_HDD_ENABLE:
|
2012-05-06 22:14:03 +00:00
|
|
|
EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE));
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_CIDERPRESS_BROWSE:
|
|
|
|
{
|
2014-08-13 20:30:35 +00:00
|
|
|
std::string CiderPressLoc = m_PropertySheetHelper.BrowseToFile(hWnd, TEXT("Select path to CiderPress"), REGVALUE_CIDERPRESSLOC, TEXT("Applications (*.exe)\0*.exe\0") TEXT("All Files\0*.*\0") );
|
2012-05-06 22:14:03 +00:00
|
|
|
RegSaveString(TEXT(REG_CONFIG), REGVALUE_CIDERPRESSLOC, 1, CiderPressLoc.c_str());
|
|
|
|
SendDlgItemMessage(hWnd, IDC_CIDERPRESS_FILENAME, WM_SETTEXT, 0, (LPARAM) CiderPressLoc.c_str());
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
case WM_INITDIALOG:
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
m_PropertySheetHelper.FillComboBox(hWnd,IDC_DISKTYPE,m_discchoices,enhancedisk);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_DISK1, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_1));
|
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_DISK2, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_2));
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_HDD1, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_1));
|
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_HDD2, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_2));
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
TCHAR PathToCiderPress[MAX_PATH] = "";
|
|
|
|
RegLoadString(TEXT("Configuration"), REGVALUE_CIDERPRESSLOC, 1, PathToCiderPress,MAX_PATH);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_CIDERPRESS_FILENAME ,WM_SETTEXT, 0, (LPARAM)PathToCiderPress);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
CheckDlgButton(hWnd, IDC_HDD_ENABLE, HD_CardIsEnabled() ? BST_CHECKED : BST_UNCHECKED);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE));
|
|
|
|
|
|
|
|
InitOptions(hWnd);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
{
|
|
|
|
RECT rect; // client area
|
|
|
|
POINT pt; // location of mouse click
|
|
|
|
|
|
|
|
// Get the bounding rectangle of the client area.
|
2012-05-06 22:14:03 +00:00
|
|
|
GetClientRect(hWnd, (LPRECT) &rect);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
// Get the client coordinates for the mouse click.
|
|
|
|
pt.x = GET_X_LPARAM(lparam);
|
|
|
|
pt.y = GET_Y_LPARAM(lparam);
|
|
|
|
|
|
|
|
// If the mouse click took place inside the client
|
|
|
|
// area, execute the application-defined function
|
|
|
|
// that displays the shortcut menu.
|
|
|
|
if (PtInRect((LPRECT) &rect, pt))
|
|
|
|
{
|
|
|
|
// Load the menu template containing the shortcut menu from the application's resources.
|
|
|
|
HMENU hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU_DISK_CFG_POPUP)); // menu template
|
|
|
|
_ASSERT(hMenu);
|
|
|
|
if (!hMenu)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Get the first shortcut menu in the menu template.
|
|
|
|
// This is the menu that TrackPopupMenu displays.
|
|
|
|
HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); // shortcut menu
|
|
|
|
|
|
|
|
// TrackPopup uses screen coordinates, so convert the coordinates of the mouse click to screen coordinates.
|
2012-05-06 22:14:03 +00:00
|
|
|
ClientToScreen(hWnd, (LPPOINT) &pt);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
if (Disk_IsDriveEmpty(DRIVE_1))
|
|
|
|
EnableMenuItem(hMenu, ID_DISKMENU_EJECT_DISK1, MF_GRAYED);
|
|
|
|
if (Disk_IsDriveEmpty(DRIVE_2))
|
|
|
|
EnableMenuItem(hMenu, ID_DISKMENU_EJECT_DISK2, MF_GRAYED);
|
|
|
|
if (HD_IsDriveUnplugged(HARDDISK_1))
|
|
|
|
EnableMenuItem(hMenu, ID_DISKMENU_UNPLUG_HARDDISK1, MF_GRAYED);
|
|
|
|
if (HD_IsDriveUnplugged(HARDDISK_2))
|
|
|
|
EnableMenuItem(hMenu, ID_DISKMENU_UNPLUG_HARDDISK2, MF_GRAYED);
|
|
|
|
|
|
|
|
// Draw and track the shortcut menu.
|
|
|
|
int iCommand = TrackPopupMenu(
|
|
|
|
hMenuTrackPopup
|
|
|
|
, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD
|
|
|
|
, pt.x, pt.y
|
|
|
|
, 0
|
2012-05-06 22:14:03 +00:00
|
|
|
, hWnd, NULL );
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
if (iCommand)
|
|
|
|
{
|
|
|
|
TCHAR szText[100];
|
|
|
|
bool bMsgBox = true;
|
|
|
|
if (iCommand == ID_DISKMENU_EJECT_DISK1 || iCommand == ID_DISKMENU_EJECT_DISK2)
|
|
|
|
wsprintf(szText, "Do you really want to eject the disk in drive-%c ?", '1'+iCommand-ID_DISKMENU_EJECT_DISK1);
|
|
|
|
else if (iCommand == ID_DISKMENU_UNPLUG_HARDDISK1 || iCommand == ID_DISKMENU_UNPLUG_HARDDISK2)
|
|
|
|
wsprintf(szText, "Do you really want to unplug harddisk-%c ?", '1'+iCommand-ID_DISKMENU_UNPLUG_HARDDISK1);
|
|
|
|
else
|
|
|
|
bMsgBox = false;
|
|
|
|
|
|
|
|
if (bMsgBox)
|
|
|
|
{
|
|
|
|
int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Eject/Unplug Warning"), MB_ICONWARNING | MB_OKCANCEL | MB_SETFOREGROUND);
|
|
|
|
if (nRes == IDNO)
|
|
|
|
iCommand = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (iCommand)
|
|
|
|
{
|
|
|
|
case ID_DISKMENU_EJECT_DISK1:
|
|
|
|
DiskEject(DRIVE_1);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_DISK1, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_1));
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case ID_DISKMENU_EJECT_DISK2:
|
|
|
|
DiskEject(DRIVE_2);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_DISK2, WM_SETTEXT, 0, (LPARAM)DiskGetFullName(DRIVE_2));
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case ID_DISKMENU_UNPLUG_HARDDISK1:
|
|
|
|
HD_Unplug(HARDDISK_1);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_HDD1, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_1));
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
case ID_DISKMENU_UNPLUG_HARDDISK2:
|
|
|
|
HD_Unplug(HARDDISK_2);
|
2012-05-06 22:14:03 +00:00
|
|
|
SendDlgItemMessage(hWnd, IDC_EDIT_HDD2, WM_SETTEXT, 0, (LPARAM)HD_GetFullName(HARDDISK_2));
|
2012-03-27 21:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iCommand != 0)
|
|
|
|
FrameRefreshStatus(DRAW_BUTTON_DRIVES);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
void CPageDisk::DlgOK(HWND hWnd)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
const BOOL bNewEnhanceDisk = (BOOL) SendDlgItemMessage(hWnd, IDC_DISKTYPE,CB_GETCURSEL, 0, 0);
|
|
|
|
if (bNewEnhanceDisk != enhancedisk)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
m_PropertySheetHelper.GetConfigNew().m_bEnhanceDisk = bNewEnhanceDisk;
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
const bool bNewHDDIsEnabled = IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE) ? true : false;
|
|
|
|
if (bNewHDDIsEnabled != HD_CardIsEnabled())
|
|
|
|
{
|
|
|
|
m_PropertySheetHelper.GetConfigNew().m_bEnableHDD = bNewHDDIsEnabled;
|
|
|
|
}
|
2012-03-27 21:20:36 +00:00
|
|
|
|
|
|
|
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_1), 1, HD_GetFullPathName(HARDDISK_1));
|
|
|
|
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_LAST_HARDDISK_2), 1, HD_GetFullPathName(HARDDISK_2));
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
m_PropertySheetHelper.PostMsgAfterClose(hWnd, m_Page);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPageDisk::InitOptions(HWND hWnd)
|
|
|
|
{
|
|
|
|
// Nothing to do:
|
|
|
|
// - no changes made on any other pages affect this page
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
void CPageDisk::EnableHDD(HWND hWnd, BOOL bEnable)
|
2012-03-27 21:20:36 +00:00
|
|
|
{
|
2012-05-06 22:14:03 +00:00
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_HDD1), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_HDD1), bEnable);
|
2012-03-27 21:20:36 +00:00
|
|
|
|
2012-05-06 22:14:03 +00:00
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_HDD2), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_HDD2), bEnable);
|
2012-03-27 21:20:36 +00:00
|
|
|
}
|