ciderpress/app/ExtractOptionsDialog.cpp

172 lines
6.1 KiB
C++
Raw Normal View History

2007-03-27 17:47:10 +00:00
/*
* CiderPress
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
#include "stdafx.h"
#include "ExtractOptionsDialog.h"
#include "ChooseDirDialog.h"
BEGIN_MESSAGE_MAP(ExtractOptionsDialog, CDialog)
ON_BN_CLICKED(IDC_EXT_CHOOSE_FOLDER, OnChooseFolder)
ON_BN_CLICKED(IDC_EXT_CONVEOLNONE, OnChangeTextConv)
ON_BN_CLICKED(IDC_EXT_CONVEOLTYPE, OnChangeTextConv)
ON_BN_CLICKED(IDC_EXT_CONVEOLTEXT, OnChangeTextConv)
ON_BN_CLICKED(IDC_EXT_CONVEOLALL, OnChangeTextConv)
ON_BN_CLICKED(IDC_EXT_CONFIG_PRESERVE, OnConfigPreserve)
ON_BN_CLICKED(IDC_EXT_CONFIG_CONVERT, OnConfigConvert)
ON_WM_HELPINFO()
ON_COMMAND(IDHELP, OnHelp)
2007-03-27 17:47:10 +00:00
END_MESSAGE_MAP()
/*
* Set up the dialog that lets the user choose file extraction options.
*
* All we really need to do is update the string that indicates how many
* files have been selected.
*/
BOOL ExtractOptionsDialog::OnInitDialog(void)
2007-03-27 17:47:10 +00:00
{
CString countFmt;
CString selStr;
CWnd* pWnd;
/* grab the radio button with the selection count */
pWnd = GetDlgItem(IDC_EXT_SELECTED);
2014-11-18 05:13:13 +00:00
ASSERT(pWnd != NULL);
/* set the count string using a string table entry */
if (fSelectedCount == 1) {
CheckedLoadString(&countFmt, IDS_EXT_SELECTED_COUNT);
pWnd->SetWindowText(countFmt);
} else {
CheckedLoadString(&countFmt, IDS_EXT_SELECTED_COUNTS_FMT);
selStr.Format((LPCWSTR) countFmt, fSelectedCount);
pWnd->SetWindowText(selStr);
// disable "extract selection" when nothing is selected
if (fSelectedCount == 0)
pWnd->EnableWindow(FALSE);
}
/* if "no convert" is selected, disable high ASCII button */
if (fConvEOL == kConvEOLNone) {
pWnd = GetDlgItem(IDC_EXT_CONVHIGHASCII);
pWnd->EnableWindow(false);
}
/* replace the existing button with one of our bitmap buttons */
fChooseFolderButton.ReplaceDlgCtrl(this, IDC_EXT_CHOOSE_FOLDER);
fChooseFolderButton.SetBitmapID(IDB_CHOOSE_FOLDER);
return CDialog::OnInitDialog();
//return TRUE; // let Windows set the focus
2007-03-27 17:47:10 +00:00
}
void ExtractOptionsDialog::DoDataExchange(CDataExchange* pDX)
2007-03-27 17:47:10 +00:00
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EXT_PATH, fExtractPath);
2007-03-27 17:47:10 +00:00
DDX_Radio(pDX, IDC_EXT_SELECTED, fFilesToExtract);
2007-03-27 17:47:10 +00:00
DDX_Check(pDX, IDC_EXT_DATAFORK, fIncludeDataForks);
DDX_Check(pDX, IDC_EXT_RSRCFORK, fIncludeRsrcForks);
DDX_Check(pDX, IDC_EXT_DISKIMAGE, fIncludeDiskImages);
2007-03-27 17:47:10 +00:00
DDX_Check(pDX, IDC_EXT_REFORMAT, fEnableReformat);
DDX_Check(pDX, IDC_EXT_DISK_2MG, fDiskTo2MG);
2007-03-27 17:47:10 +00:00
DDX_Check(pDX, IDC_EXT_ADD_PRESERVE, fAddTypePreservation);
DDX_Check(pDX, IDC_EXT_ADD_EXTEN, fAddExtension);
DDX_Check(pDX, IDC_EXT_STRIP_FOLDER, fStripFolderNames);
2007-03-27 17:47:10 +00:00
DDX_Radio(pDX, IDC_EXT_CONVEOLNONE, fConvEOL);
DDX_Check(pDX, IDC_EXT_CONVHIGHASCII, fConvHighASCII);
2007-03-27 17:47:10 +00:00
DDX_Check(pDX, IDC_EXT_OVERWRITE_EXIST, fOverwriteExisting);
if (pDX->m_bSaveAndValidate) {
if (!fIncludeDataForks && !fIncludeRsrcForks && !fIncludeDiskImages) {
2014-12-17 23:45:28 +00:00
ShowFailureMsg(this, IDS_NO_FORKS_SPECIFIED, IDS_MB_APP_NAME);
pDX->Fail();
return;
}
}
2007-03-27 17:47:10 +00:00
}
void ExtractOptionsDialog::OnConfigPreserve(void)
2007-03-27 17:47:10 +00:00
{
// IDC_EXT_PATH, IDC_EXT_SELECTED
SetDlgButtonCheck(this, IDC_EXT_DATAFORK, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_RSRCFORK, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_DISKIMAGE, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_REFORMAT, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_DISK_2MG, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_ADD_PRESERVE, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_ADD_EXTEN, BST_UNCHECKED);
//SetDlgButtonCheck(this, IDC_EXT_STRIP_FOLDER, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVEOLNONE, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVEOLTYPE, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVEOLTEXT, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVEOLALL, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVHIGHASCII, BST_UNCHECKED);
//SetDlgButtonCheck(this, IDC_EXT_OVERWRITE_EXIST, BST_CHECKED);
OnChangeTextConv();
2007-03-27 17:47:10 +00:00
}
void ExtractOptionsDialog::OnConfigConvert(void)
2007-03-27 17:47:10 +00:00
{
// IDC_EXT_PATH, IDC_EXT_SELECTED
SetDlgButtonCheck(this, IDC_EXT_DATAFORK, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_RSRCFORK, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_DISKIMAGE, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_REFORMAT, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_DISK_2MG, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_ADD_PRESERVE, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_ADD_EXTEN, BST_CHECKED);
//SetDlgButtonCheck(this, IDC_EXT_STRIP_FOLDER, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVEOLNONE, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVEOLTYPE, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVEOLTEXT, BST_CHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVEOLALL, BST_UNCHECKED);
SetDlgButtonCheck(this, IDC_EXT_CONVHIGHASCII, BST_CHECKED);
//SetDlgButtonCheck(this, IDC_EXT_OVERWRITE_EXIST, BST_CHECKED);
OnChangeTextConv();
2007-03-27 17:47:10 +00:00
}
void ExtractOptionsDialog::OnChangeTextConv(void)
2007-03-27 17:47:10 +00:00
{
CButton* pButton = (CButton*) GetDlgItem(IDC_EXT_CONVEOLNONE);
2014-11-18 05:13:13 +00:00
ASSERT(pButton != NULL);
bool convDisabled = (pButton->GetCheck() == BST_CHECKED);
2007-03-27 17:47:10 +00:00
CWnd* pWnd = GetDlgItem(IDC_EXT_CONVHIGHASCII);
2014-11-18 05:13:13 +00:00
ASSERT(pWnd != NULL);
pWnd->EnableWindow(!convDisabled);
2007-03-27 17:47:10 +00:00
}
void ExtractOptionsDialog::OnChooseFolder(void)
2007-03-27 17:47:10 +00:00
{
ChooseDirDialog chooseDir(this);
CWnd* pEditWnd;
CString editPath;
/* get the currently-showing text from the edit field */
pEditWnd = GetDlgItem(IDC_EXT_PATH);
2014-11-18 05:13:13 +00:00
ASSERT(pEditWnd != NULL);
pEditWnd->GetWindowText(editPath);
chooseDir.SetPathName(editPath);
if (chooseDir.DoModal() == IDOK) {
Large set of changes to restore CiderPress build. CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
const WCHAR* ccp = chooseDir.GetPathName();
LOGI("New extract path chosen = '%ls'", ccp);
pEditWnd->SetWindowText(ccp);
}
2007-03-27 17:47:10 +00:00
}