mirror of
https://github.com/fadden/ciderpress.git
synced 2024-12-22 05:29:43 +00:00
d8223dbcfd
This moves method comments from the .cpp file to the .h file, where users of the methods can find them. This also makes it possible for the IDE to show the comments when you mouse-hover over the method name, though Visual Studio is a bit weak in this regard. Also, added "override" keywords on overridden methods. Reasonably current versions of popular compilers seem to support this. Also, don't have the return type on a separate line in the .cpp file. The motivation for the practice -- quickly finding a method definition with "^name" -- is less useful in C++ than C, and modern IDEs provide more convenient ways to do the same thing. Also, do some more conversion from unsigned types to uintXX_t. This commit is primarily for the "app" directory.
167 lines
4.8 KiB
C++
167 lines
4.8 KiB
C++
/*
|
|
* CiderPress
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
* See the file LICENSE for distribution terms.
|
|
*/
|
|
#include "stdafx.h"
|
|
#include "ChooseDirDialog.h"
|
|
#include "NewFolderDialog.h"
|
|
#include "DiskFSTree.h"
|
|
#include "HelpTopics.h"
|
|
|
|
BEGIN_MESSAGE_MAP(ChooseDirDialog, CDialog)
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_CHOOSEDIR_TREE, OnSelChanged)
|
|
ON_BN_CLICKED(IDC_CHOOSEDIR_EXPAND_TREE, OnExpandTree)
|
|
ON_BN_CLICKED(IDC_CHOOSEDIR_NEW_FOLDER, OnNewFolder)
|
|
ON_WM_HELPINFO()
|
|
//ON_COMMAND(ID_HELP, OnIDHelp)
|
|
ON_BN_CLICKED(IDHELP, OnHelp)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
BOOL ChooseDirDialog::OnInitDialog(void)
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
/* set up the "new folder" button */
|
|
fNewFolderButton.ReplaceDlgCtrl(this, IDC_CHOOSEDIR_NEW_FOLDER);
|
|
fNewFolderButton.SetBitmapID(IDB_NEW_FOLDER);
|
|
|
|
/* replace the tree control with a ShellTree */
|
|
if (fShellTree.ReplaceDlgCtrl(this, IDC_CHOOSEDIR_TREE) != TRUE) {
|
|
LOGI("WARNING: ShellTree replacement failed");
|
|
ASSERT(false);
|
|
}
|
|
|
|
//enable images
|
|
fShellTree.EnableImages();
|
|
//populate for the with Shell Folders for the first time
|
|
fShellTree.PopulateTree(/*CSIDL_DRIVES*/);
|
|
|
|
if (fPathName.IsEmpty()) {
|
|
// start somewhere reasonable
|
|
fShellTree.ExpandMyComputer();
|
|
} else {
|
|
CString msg("");
|
|
fShellTree.TunnelTree(fPathName, &msg);
|
|
if (!msg.IsEmpty()) {
|
|
/* failed */
|
|
LOGI("TunnelTree failed on '%ls' (%ls), using MyComputer instead",
|
|
(LPCWSTR) fPathName, (LPCWSTR) msg);
|
|
fShellTree.ExpandMyComputer();
|
|
}
|
|
}
|
|
|
|
fShellTree.SetFocus();
|
|
return FALSE; // leave focus on shell tree
|
|
}
|
|
|
|
BOOL ChooseDirDialog::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if (pMsg->message == WM_KEYDOWN &&
|
|
pMsg->wParam == VK_RETURN)
|
|
{
|
|
//LOGI("RETURN!");
|
|
if (GetFocus() == GetDlgItem(IDC_CHOOSEDIR_PATHEDIT)) {
|
|
OnExpandTree();
|
|
return TRUE;
|
|
}
|
|
}
|
|
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
BOOL ChooseDirDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
|
|
{
|
|
DWORD context = lpHelpInfo->iCtrlId;
|
|
WinHelp(context, HELP_CONTEXTPOPUP);
|
|
return TRUE; // indicate success??
|
|
}
|
|
|
|
void ChooseDirDialog::OnHelp(void)
|
|
{
|
|
WinHelp(HELP_TOPIC_CHOOSE_FOLDER, HELP_CONTEXT);
|
|
}
|
|
|
|
void ChooseDirDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
|
|
{
|
|
CString path;
|
|
CWnd* pWnd = GetDlgItem(IDC_CHOOSEDIR_PATH);
|
|
ASSERT(pWnd != NULL);
|
|
|
|
if (fShellTree.GetFolderPath(&path))
|
|
fPathName = path;
|
|
else
|
|
fPathName = L"";
|
|
pWnd->SetWindowText(fPathName);
|
|
|
|
// disable the "Select" button when there's no path ready
|
|
pWnd = GetDlgItem(IDOK);
|
|
ASSERT(pWnd != NULL);
|
|
pWnd->EnableWindow(!fPathName.IsEmpty());
|
|
|
|
// It's confusing to have two different paths showing, so wipe out the
|
|
// free entry field when the selection changes.
|
|
pWnd = GetDlgItem(IDC_CHOOSEDIR_PATHEDIT);
|
|
pWnd->SetWindowText(L"");
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
void ChooseDirDialog::OnExpandTree(void)
|
|
{
|
|
CWnd* pWnd;
|
|
CString str;
|
|
CString msg;
|
|
|
|
pWnd = GetDlgItem(IDC_CHOOSEDIR_PATHEDIT);
|
|
ASSERT(pWnd != NULL);
|
|
pWnd->GetWindowText(str);
|
|
|
|
if (!str.IsEmpty()) {
|
|
fShellTree.TunnelTree(str, &msg);
|
|
if (!msg.IsEmpty()) {
|
|
CString failed;
|
|
failed.LoadString(IDS_FAILED);
|
|
MessageBox(msg, failed, MB_OK | MB_ICONERROR);
|
|
}
|
|
}
|
|
}
|
|
|
|
void ChooseDirDialog::OnNewFolder(void)
|
|
{
|
|
if (fPathName.IsEmpty()) {
|
|
MessageBox(L"You can't create a folder in this part of the tree.",
|
|
L"Bad Location", MB_OK | MB_ICONERROR);
|
|
return;
|
|
}
|
|
|
|
NewFolderDialog newFolderDlg;
|
|
|
|
newFolderDlg.fCurrentFolder = fPathName;
|
|
if (newFolderDlg.DoModal() == IDOK) {
|
|
if (newFolderDlg.GetFolderCreated()) {
|
|
/*
|
|
* They created a new folder. We want to add it to the tree
|
|
* and then select it. This is not too hard because we know
|
|
* that the folder was created under the currently-selected
|
|
* tree node.
|
|
*/
|
|
if (fShellTree.AddFolderAtSelection(newFolderDlg.fNewFolder)) {
|
|
CString msg;
|
|
LOGI("Success, tunneling to '%ls'",
|
|
(LPCWSTR) newFolderDlg.fNewFullPath);
|
|
fShellTree.TunnelTree(newFolderDlg.fNewFullPath, &msg);
|
|
if (!msg.IsEmpty()) {
|
|
LOGI("TunnelTree failed: %ls", (LPCWSTR) msg);
|
|
}
|
|
} else {
|
|
LOGI("AddFolderAtSelection FAILED");
|
|
ASSERT(false);
|
|
}
|
|
} else {
|
|
LOGI("NewFolderDialog returned IDOK but no create");
|
|
}
|
|
}
|
|
}
|