mirror of
https://github.com/fadden/ciderpress.git
synced 2024-12-21 14:30:02 +00:00
More source code shuffling
Moved comments and return types, switched to uint types, added "override" keyword.
This commit is contained in:
parent
aa3145856c
commit
c78017b1d2
@ -445,7 +445,7 @@ void ContentList::OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult)
|
|||||||
{
|
{
|
||||||
CString modDate;
|
CString modDate;
|
||||||
FormatDate(pEntry->GetModWhen(), &modDate);
|
FormatDate(pEntry->GetModWhen(), &modDate);
|
||||||
::lstrcpy(plvdi->item.pszText, (LPCTSTR) modDate);
|
::lstrcpy(plvdi->item.pszText, (LPCWSTR) modDate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4: // format
|
case 4: // format
|
||||||
|
@ -43,7 +43,7 @@ BOOL ExtractOptionsDialog::OnInitDialog(void)
|
|||||||
pWnd->SetWindowText(countFmt);
|
pWnd->SetWindowText(countFmt);
|
||||||
} else {
|
} else {
|
||||||
countFmt.LoadString(IDS_EXT_SELECTED_COUNTS_FMT);
|
countFmt.LoadString(IDS_EXT_SELECTED_COUNTS_FMT);
|
||||||
selStr.Format((LPCTSTR) countFmt, fSelectedCount);
|
selStr.Format((LPCWSTR) countFmt, fSelectedCount);
|
||||||
pWnd->SetWindowText(selStr);
|
pWnd->SetWindowText(selStr);
|
||||||
|
|
||||||
if (fSelectedCount == 0)
|
if (fSelectedCount == 0)
|
||||||
|
@ -241,7 +241,7 @@ void MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
|
|||||||
iconStr.Format(L"%ls,%d", exeName, iconIdx);
|
iconStr.Format(L"%ls,%d", exeName, iconIdx);
|
||||||
|
|
||||||
if (RegSetValueEx(hIconKey, L"", 0, REG_SZ,
|
if (RegSetValueEx(hIconKey, L"", 0, REG_SZ,
|
||||||
(const BYTE*)(LPCTSTR) iconStr,
|
(const BYTE*)(LPCWSTR) iconStr,
|
||||||
wcslen(iconStr) * sizeof(WCHAR)) == ERROR_SUCCESS)
|
wcslen(iconStr) * sizeof(WCHAR)) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
LOGI(" Set icon for '%ls' to '%ls'", appID,
|
LOGI(" Set icon for '%ls' to '%ls'", appID,
|
||||||
|
@ -149,7 +149,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
int OwnExtension(const WCHAR* ext, const WCHAR* appID) const;
|
int OwnExtension(const WCHAR* ext, const WCHAR* appID) const;
|
||||||
|
|
||||||
DWORD RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const;
|
DWORD RegDeleteKeyNT(HKEY hStartKey, LPCWSTR pKeyName) const;
|
||||||
|
|
||||||
/* key validation */
|
/* key validation */
|
||||||
//static uint16_t CalcCRC16(uint16_t seed,
|
//static uint16_t CalcCRC16(uint16_t seed,
|
||||||
|
@ -31,7 +31,7 @@ BOOL UseSelectionDialog::OnInitDialog(void)
|
|||||||
pWnd->SetWindowText(str);
|
pWnd->SetWindowText(str);
|
||||||
} else {
|
} else {
|
||||||
str.LoadString(fSelCountsID);
|
str.LoadString(fSelCountsID);
|
||||||
selStr.Format((LPCTSTR) str, fSelectedCount);
|
selStr.Format((LPCWSTR) str, fSelectedCount);
|
||||||
pWnd->SetWindowText(selStr);
|
pWnd->SetWindowText(selStr);
|
||||||
|
|
||||||
if (fSelectedCount == 0)
|
if (fSelectedCount == 0)
|
||||||
|
@ -49,7 +49,7 @@ BOOL AboutDlg::OnInitDialog()
|
|||||||
pWnd->GetWindowText(fmt);
|
pWnd->GetWindowText(fmt);
|
||||||
newText.Format(fmt, kAppMajorVersion, kAppMinorVersion, kAppBugVersion);
|
newText.Format(fmt, kAppMajorVersion, kAppMinorVersion, kAppBugVersion);
|
||||||
pWnd->SetWindowText(newText);
|
pWnd->SetWindowText(newText);
|
||||||
LOGI("STR is '%ls'", (LPCWSTR) newText);
|
LOGD("STR is '%ls'", (LPCWSTR) newText);
|
||||||
|
|
||||||
return TRUE; // return TRUE unless you set the focus to a control
|
return TRUE; // return TRUE unless you set the focus to a control
|
||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
|
@ -10,14 +10,7 @@
|
|||||||
#include "ChooseFilesDlg.h"
|
#include "ChooseFilesDlg.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
void ChooseFilesDlg::ShiftControls(int deltaX, int deltaY)
|
||||||
* Override base class version so we can move our stuff around.
|
|
||||||
*
|
|
||||||
* It's important that the base class be called last, because it calls
|
|
||||||
* Invalidate to redraw the dialog.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ChooseFilesDlg::ShiftControls(int deltaX, int deltaY)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* These only need to be here so that the initial move puts them
|
* These only need to be here so that the initial move puts them
|
||||||
|
@ -24,14 +24,13 @@ public:
|
|||||||
virtual ~ChooseFilesDlg(void) {}
|
virtual ~ChooseFilesDlg(void) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//virtual bool MyDataExchange(bool saveAndValidate);
|
/*
|
||||||
virtual void ShiftControls(int deltaX, int deltaY);
|
* Override base class version so we can move our stuff around.
|
||||||
//virtual UINT MyOnCommand(WPARAM wParam, LPARAM lParam);
|
*
|
||||||
|
* It's important that the base class be called last, because it calls
|
||||||
//void OnIDHelp(void);
|
* Invalidate to redraw the dialog.
|
||||||
|
*/
|
||||||
//int GetButtonCheck(int id);
|
virtual void ShiftControls(int deltaX, int deltaY) override;
|
||||||
//void SetButtonCheck(int id, int checkVal);
|
|
||||||
|
|
||||||
//DECLARE_MESSAGE_MAP()
|
//DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
150
mdc/Main.cpp
150
mdc/Main.cpp
@ -27,10 +27,6 @@ BEGIN_MESSAGE_MAP(MainWindow, CFrameWnd)
|
|||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MainWindow constructor. Creates the main window and sets
|
|
||||||
* its properties.
|
|
||||||
*/
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
{
|
{
|
||||||
static const WCHAR* kAppName = L"MDC";
|
static const WCHAR* kAppName = L"MDC";
|
||||||
@ -61,11 +57,6 @@ MainWindow::MainWindow()
|
|||||||
fCancelFlag = false;
|
fCancelFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* MainWindow destructor. Close the archive if one is open, but don't try
|
|
||||||
* to shut down any controls in child windows. By this point, Windows has
|
|
||||||
* already snuffed them.
|
|
||||||
*/
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
// int cc;
|
// int cc;
|
||||||
@ -75,21 +66,15 @@ MainWindow::~MainWindow()
|
|||||||
DiskImgLib::Global::AppCleanup();
|
DiskImgLib::Global::AppCleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MainWindow::OnFileExit(void)
|
||||||
* Handle Exit item by sending a close request.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MainWindow::OnFileExit(void)
|
|
||||||
{
|
{
|
||||||
|
// Handle Exit item by sending a close request.
|
||||||
SendMessage(WM_CLOSE, 0, 0);
|
SendMessage(WM_CLOSE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MainWindow::OnHelpWebSite(void)
|
||||||
* Go to the faddenSoft web site.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MainWindow::OnHelpWebSite(void)
|
|
||||||
{
|
{
|
||||||
|
// Go to the faddenSoft web site.
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = (int) ::ShellExecute(m_hWnd, L"open", kWebSiteURL, NULL, NULL,
|
err = (int) ::ShellExecute(m_hWnd, L"open", kWebSiteURL, NULL, NULL,
|
||||||
@ -101,11 +86,7 @@ MainWindow::OnHelpWebSite(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MainWindow::OnHelpAbout(void)
|
||||||
* Pop up the About box.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MainWindow::OnHelpAbout(void)
|
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -116,11 +97,7 @@ MainWindow::OnHelpAbout(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
void MainWindow::OnFileScan(void)
|
||||||
* Handle "scan" item.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MainWindow::OnFileScan(void)
|
|
||||||
{
|
{
|
||||||
if (0) {
|
if (0) {
|
||||||
CString msg;
|
CString msg;
|
||||||
@ -131,19 +108,7 @@ MainWindow::OnFileScan(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
BOOL MainWindow::PeekAndPump(void)
|
||||||
* Allow events to flow through the message queue whenever the
|
|
||||||
* progress meter gets updated. This will allow us to redraw with
|
|
||||||
* reasonable frequency.
|
|
||||||
*
|
|
||||||
* Calling this can result in other code being called, such as Windows
|
|
||||||
* message handlers, which can lead to reentrancy problems. Make sure
|
|
||||||
* you're adequately semaphored before calling here.
|
|
||||||
*
|
|
||||||
* Returns TRUE if all is well, FALSE if we're trying to quit.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
MainWindow::PeekAndPump(void)
|
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
@ -167,9 +132,6 @@ MainWindow::PeekAndPump(void)
|
|||||||
* ==========================================================================
|
* ==========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Handle a debug message from the DiskImg library.
|
|
||||||
*/
|
|
||||||
/*static*/ void
|
/*static*/ void
|
||||||
MainWindow::DebugMsgHandler(const char* file, int line, const char* msg)
|
MainWindow::DebugMsgHandler(const char* file, int line, const char* msg)
|
||||||
{
|
{
|
||||||
@ -179,11 +141,9 @@ MainWindow::DebugMsgHandler(const char* file, int line, const char* msg)
|
|||||||
LOG_BASE(DebugLog::LOG_INFO, file, line, "<diskimg> %hs", msg);
|
LOG_BASE(DebugLog::LOG_INFO, file, line, "<diskimg> %hs", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Handle a global error message from the NufxLib library.
|
/*static*/ NuResult MainWindow::NufxErrorMsgHandler(NuArchive* /*pArchive*/,
|
||||||
*/
|
void* vErrorMessage)
|
||||||
/*static*/ NuResult
|
|
||||||
MainWindow::NufxErrorMsgHandler(NuArchive* /*pArchive*/, void* vErrorMessage)
|
|
||||||
{
|
{
|
||||||
const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage;
|
const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage;
|
||||||
|
|
||||||
@ -201,11 +161,7 @@ typedef struct ScanOpts {
|
|||||||
ProgressDlg* pProgress;
|
ProgressDlg* pProgress;
|
||||||
} ScanOpts;
|
} ScanOpts;
|
||||||
|
|
||||||
/*
|
void MainWindow::ScanFiles(void)
|
||||||
* Scan a set of files.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MainWindow::ScanFiles(void)
|
|
||||||
{
|
{
|
||||||
ChooseFilesDlg chooseFiles;
|
ChooseFilesDlg chooseFiles;
|
||||||
ScanOpts scanOpts;
|
ScanOpts scanOpts;
|
||||||
@ -361,13 +317,7 @@ typedef struct Win32dirent {
|
|||||||
|
|
||||||
static const WCHAR kWildMatchAll[] = L"*.*";
|
static const WCHAR kWildMatchAll[] = L"*.*";
|
||||||
|
|
||||||
/*
|
Win32dirent* MainWindow::OpenDir(const WCHAR* name)
|
||||||
* Prepare a directory for reading.
|
|
||||||
*
|
|
||||||
* Allocates a Win32dirent struct that must be freed by the caller.
|
|
||||||
*/
|
|
||||||
Win32dirent*
|
|
||||||
MainWindow::OpenDir(const WCHAR* name)
|
|
||||||
{
|
{
|
||||||
Win32dirent* dir = NULL;
|
Win32dirent* dir = NULL;
|
||||||
WCHAR* tmpStr = NULL;
|
WCHAR* tmpStr = NULL;
|
||||||
@ -411,13 +361,7 @@ failed:
|
|||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
Win32dirent* MainWindow::ReadDir(Win32dirent* dir)
|
||||||
* Get an entry from an open directory.
|
|
||||||
*
|
|
||||||
* Returns a NULL pointer after the last entry has been read.
|
|
||||||
*/
|
|
||||||
Win32dirent*
|
|
||||||
MainWindow::ReadDir(Win32dirent* dir)
|
|
||||||
{
|
{
|
||||||
if (dir->d_first)
|
if (dir->d_first)
|
||||||
dir->d_first = 0;
|
dir->d_first = 0;
|
||||||
@ -433,11 +377,7 @@ MainWindow::ReadDir(Win32dirent* dir)
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MainWindow::CloseDir(Win32dirent* dir)
|
||||||
* Close a directory.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MainWindow::CloseDir(Win32dirent* dir)
|
|
||||||
{
|
{
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return;
|
return;
|
||||||
@ -446,14 +386,7 @@ MainWindow::CloseDir(Win32dirent* dir)
|
|||||||
free(dir);
|
free(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MainWindow::Process(const WCHAR* pathname, ScanOpts* pScanOpts,
|
||||||
* Process a file or directory. These are expected to be names of files in
|
|
||||||
* the current directory.
|
|
||||||
*
|
|
||||||
* Returns 0 on success, nonzero on error with a message in "*pErrMsg".
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MainWindow::Process(const WCHAR* pathname, ScanOpts* pScanOpts,
|
|
||||||
CString* pErrMsg)
|
CString* pErrMsg)
|
||||||
{
|
{
|
||||||
bool exists, isDir, isReadable;
|
bool exists, isDir, isReadable;
|
||||||
@ -498,13 +431,7 @@ bail:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MainWindow::ProcessDirectory(const WCHAR* dirName, ScanOpts* pScanOpts,
|
||||||
* Win32 recursive directory descent. Scan the contents of a directory.
|
|
||||||
* If a subdirectory is found, follow it; otherwise, call Win32AddFile to
|
|
||||||
* add the file.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MainWindow::ProcessDirectory(const WCHAR* dirName, ScanOpts* pScanOpts,
|
|
||||||
CString* pErrMsg)
|
CString* pErrMsg)
|
||||||
{
|
{
|
||||||
Win32dirent* dirp = NULL;
|
Win32dirent* dirp = NULL;
|
||||||
@ -560,14 +487,7 @@ bail:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MainWindow::ScanDiskImage(const WCHAR* pathName, ScanOpts* pScanOpts)
|
||||||
/*
|
|
||||||
* Open a disk image and dump the contents.
|
|
||||||
*
|
|
||||||
* Returns 0 on success, nonzero on failure.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MainWindow::ScanDiskImage(const WCHAR* pathName, ScanOpts* pScanOpts)
|
|
||||||
{
|
{
|
||||||
ASSERT(pathName != NULL);
|
ASSERT(pathName != NULL);
|
||||||
ASSERT(pScanOpts != NULL);
|
ASSERT(pScanOpts != NULL);
|
||||||
@ -677,11 +597,7 @@ bail:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MainWindow::AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind,
|
||||||
* Analyze a file's characteristics.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MainWindow::AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind,
|
|
||||||
LONGLONG* pTotalLen, LONGLONG* pTotalCompLen)
|
LONGLONG* pTotalLen, LONGLONG* pTotalCompLen)
|
||||||
{
|
{
|
||||||
if (pFile->IsVolumeDirectory()) {
|
if (pFile->IsVolumeDirectory()) {
|
||||||
@ -710,14 +626,7 @@ MainWindow::AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
bool MainWindow::IsRecordReadOnly(int access)
|
||||||
* Determine whether the access bits on the record make it a read-only
|
|
||||||
* file or not.
|
|
||||||
*
|
|
||||||
* Uses a simplified view of the access flags.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
MainWindow::IsRecordReadOnly(int access)
|
|
||||||
{
|
{
|
||||||
if (access == 0x21L || access == 0x01L)
|
if (access == 0x21L || access == 0x01L)
|
||||||
return true;
|
return true;
|
||||||
@ -761,13 +670,7 @@ static const char gFileTypeNames[256][4] = {
|
|||||||
"$F8", "OS ", "INT", "IVR", "BAS", "VAR", "REL", "SYS"
|
"$F8", "OS ", "INT", "IVR", "BAS", "VAR", "REL", "SYS"
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*static*/ const char* MainWindow::GetFileTypeString(unsigned long fileType)
|
||||||
* Return a pointer to the three-letter representation of the file type name.
|
|
||||||
*
|
|
||||||
* Note to self: code down below tests first char for '?'.
|
|
||||||
*/
|
|
||||||
/*static*/ const char*
|
|
||||||
MainWindow::GetFileTypeString(unsigned long fileType)
|
|
||||||
{
|
{
|
||||||
if (fileType < NELEM(gFileTypeNames))
|
if (fileType < NELEM(gFileTypeNames))
|
||||||
return gFileTypeNames[fileType];
|
return gFileTypeNames[fileType];
|
||||||
@ -778,9 +681,10 @@ MainWindow::GetFileTypeString(unsigned long fileType)
|
|||||||
/*
|
/*
|
||||||
* Sanitize a string. The Mac likes to stick control characters into
|
* Sanitize a string. The Mac likes to stick control characters into
|
||||||
* things, e.g. ^C and ^M, and uses high ASCII for special characters.
|
* things, e.g. ^C and ^M, and uses high ASCII for special characters.
|
||||||
|
*
|
||||||
|
* TODO: use Mac Roman unicode translation instead
|
||||||
*/
|
*/
|
||||||
static void
|
static void MacSanitize(char* str)
|
||||||
MacSanitize(char* str)
|
|
||||||
{
|
{
|
||||||
while (*str != '\0') {
|
while (*str != '\0') {
|
||||||
*str = DiskImg::MacToASCII(*str);
|
*str = DiskImg::MacToASCII(*str);
|
||||||
@ -788,13 +692,7 @@ MacSanitize(char* str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MainWindow::LoadDiskFSContents(DiskFS* pDiskFS, const char* volName,
|
||||||
* Load the contents of a DiskFS.
|
|
||||||
*
|
|
||||||
* Recursively handle sub-volumes.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MainWindow::LoadDiskFSContents(DiskFS* pDiskFS, const char* volName,
|
|
||||||
ScanOpts* pScanOpts)
|
ScanOpts* pScanOpts)
|
||||||
{
|
{
|
||||||
static const char* kBlankFileName = "<blank filename>";
|
static const char* kBlankFileName = "<blank filename>";
|
||||||
|
89
mdc/Main.h
89
mdc/Main.h
@ -31,7 +31,17 @@ typedef enum RecordKind {
|
|||||||
*/
|
*/
|
||||||
class MainWindow : public CFrameWnd {
|
class MainWindow : public CFrameWnd {
|
||||||
public:
|
public:
|
||||||
|
/*
|
||||||
|
* MainWindow constructor. Creates the main window and sets
|
||||||
|
* its properties.
|
||||||
|
*/
|
||||||
MainWindow(void);
|
MainWindow(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MainWindow destructor. Close the archive if one is open, but don't try
|
||||||
|
* to shut down any controls in child windows. By this point, Windows has
|
||||||
|
* already snuffed them.
|
||||||
|
*/
|
||||||
~MainWindow(void);
|
~MainWindow(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -40,29 +50,104 @@ private:
|
|||||||
afx_msg void OnHelpWebSite(void);
|
afx_msg void OnHelpWebSite(void);
|
||||||
afx_msg void OnHelpAbout(void);
|
afx_msg void OnHelpAbout(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allow events to flow through the message queue whenever the
|
||||||
|
* progress meter gets updated. This will allow us to redraw with
|
||||||
|
* reasonable frequency.
|
||||||
|
*
|
||||||
|
* Calling this can result in other code being called, such as Windows
|
||||||
|
* message handlers, which can lead to reentrancy problems. Make sure
|
||||||
|
* you're adequately semaphored before calling here.
|
||||||
|
*
|
||||||
|
* Returns TRUE if all is well, FALSE if we're trying to quit.
|
||||||
|
*/
|
||||||
BOOL PeekAndPump(void);
|
BOOL PeekAndPump(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle a debug message from the DiskImg library.
|
||||||
|
*/
|
||||||
static void DebugMsgHandler(const char* file, int line,
|
static void DebugMsgHandler(const char* file, int line,
|
||||||
const char* msg);
|
const char* msg);
|
||||||
static NuResult NufxErrorMsgHandler(NuArchive* /*pArchive*/,
|
static NuResult NufxErrorMsgHandler(NuArchive* /*pArchive*/,
|
||||||
void* vErrorMessage);
|
void* vErrorMessage);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scan a set of files.
|
||||||
|
*/
|
||||||
void ScanFiles(void);
|
void ScanFiles(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prepare a directory for reading.
|
||||||
|
*
|
||||||
|
* Allocates a Win32dirent struct that must be freed by the caller.
|
||||||
|
*/
|
||||||
Win32dirent* OpenDir(const WCHAR* name);
|
Win32dirent* OpenDir(const WCHAR* name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get an entry from an open directory.
|
||||||
|
*
|
||||||
|
* Returns a NULL pointer after the last entry has been read.
|
||||||
|
*/
|
||||||
Win32dirent* ReadDir(Win32dirent* dir);
|
Win32dirent* ReadDir(Win32dirent* dir);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close a directory.
|
||||||
|
*/
|
||||||
void CloseDir(Win32dirent* dir);
|
void CloseDir(Win32dirent* dir);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Process a file or directory. These are expected to be names of files in
|
||||||
|
* the current directory.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, nonzero on error with a message in "*pErrMsg".
|
||||||
|
*/
|
||||||
int Process(const WCHAR* pathname, ScanOpts* pScanOpts,
|
int Process(const WCHAR* pathname, ScanOpts* pScanOpts,
|
||||||
CString* pErrMsg);
|
CString* pErrMsg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Win32 recursive directory descent. Scan the contents of a directory.
|
||||||
|
* If a subdirectory is found, follow it; otherwise, call Win32AddFile to
|
||||||
|
* add the file.
|
||||||
|
*/
|
||||||
int ProcessDirectory(const WCHAR* dirName, ScanOpts* pScanOpts,
|
int ProcessDirectory(const WCHAR* dirName, ScanOpts* pScanOpts,
|
||||||
CString* pErrMsg);
|
CString* pErrMsg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open a disk image and dump the contents.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, nonzero on failure.
|
||||||
|
*/
|
||||||
int ScanDiskImage(const WCHAR* pathName, ScanOpts* pScanOpts);
|
int ScanDiskImage(const WCHAR* pathName, ScanOpts* pScanOpts);
|
||||||
int LoadDiskFSContents(DiskFS* pDiskFS, const char* volName,
|
|
||||||
ScanOpts* pScanOpts);
|
/*
|
||||||
|
* Analyze a file's characteristics.
|
||||||
|
*/
|
||||||
void AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind,
|
void AnalyzeFile(const A2File* pFile, RecordKind* pRecordKind,
|
||||||
LONGLONG* pTotalLen, LONGLONG* pTotalCompLen);
|
LONGLONG* pTotalLen, LONGLONG* pTotalCompLen);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine whether the access bits on the record make it a read-only
|
||||||
|
* file or not.
|
||||||
|
*
|
||||||
|
* Uses a simplified view of the access flags.
|
||||||
|
*/
|
||||||
bool IsRecordReadOnly(int access);
|
bool IsRecordReadOnly(int access);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return a pointer to the three-letter representation of the file type name.
|
||||||
|
*
|
||||||
|
* Note to self: code down below tests first char for '?'.
|
||||||
|
*/
|
||||||
static const char* GetFileTypeString(unsigned long fileType);
|
static const char* GetFileTypeString(unsigned long fileType);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the contents of a DiskFS.
|
||||||
|
*
|
||||||
|
* Recursively handle sub-volumes.
|
||||||
|
*/
|
||||||
|
int LoadDiskFSContents(DiskFS* pDiskFS, const char* volName,
|
||||||
|
ScanOpts* pScanOpts);
|
||||||
|
|
||||||
bool fCancelFlag;
|
bool fCancelFlag;
|
||||||
//int fTitleAnimation;
|
//int fTitleAnimation;
|
||||||
|
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatAWGS_WP::Examine(ReformatHolder* pHolder)
|
||||||
ReformatAWGS_WP::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -27,8 +26,7 @@ ReformatAWGS_WP::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert AWGS into formatted text.
|
* Convert AWGS into formatted text.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatAWGS_WP::Process(const ReformatHolder* pHolder,
|
||||||
ReformatAWGS_WP::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -148,8 +146,7 @@ ReformatAWGS_WP::Process(const ReformatHolder* pHolder,
|
|||||||
/*
|
/*
|
||||||
* Read one of the chunks of the file.
|
* Read one of the chunks of the file.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatAWGS_WP::ReadChunk(const uint8_t** pSrcBuf, long* pSrcLen,
|
||||||
ReformatAWGS_WP::ReadChunk(const uint8_t** pSrcBuf, long* pSrcLen,
|
|
||||||
Chunk* pChunk)
|
Chunk* pChunk)
|
||||||
{
|
{
|
||||||
/* starts with the saveArray count */
|
/* starts with the saveArray count */
|
||||||
@ -205,8 +202,7 @@ ReformatAWGS_WP::ReadChunk(const uint8_t** pSrcBuf, long* pSrcLen,
|
|||||||
/*
|
/*
|
||||||
* Output a single chunk. We do this by walking down the saveArray.
|
* Output a single chunk. We do this by walking down the saveArray.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatAWGS_WP::PrintChunk(const Chunk* pChunk)
|
||||||
ReformatAWGS_WP::PrintChunk(const Chunk* pChunk)
|
|
||||||
{
|
{
|
||||||
const int kDefaultStatusBits = kAWGSJustifyLeft | kAWGSSingleSpace;
|
const int kDefaultStatusBits = kAWGSJustifyLeft | kAWGSSingleSpace;
|
||||||
SaveArrayEntry sae;
|
SaveArrayEntry sae;
|
||||||
@ -291,8 +287,7 @@ ReformatAWGS_WP::PrintChunk(const Chunk* pChunk)
|
|||||||
* skip through them earlier. We don't really need to worry about running
|
* skip through them earlier. We don't really need to worry about running
|
||||||
* off the end due to a bad file.
|
* off the end due to a bad file.
|
||||||
*/
|
*/
|
||||||
const uint8_t*
|
const uint8_t* ReformatAWGS_WP::FindTextBlock(const Chunk* pChunk, int blockNum)
|
||||||
ReformatAWGS_WP::FindTextBlock(const Chunk* pChunk, int blockNum)
|
|
||||||
{
|
{
|
||||||
const uint8_t* blockPtr = pChunk->textBlocks;
|
const uint8_t* blockPtr = pChunk->textBlocks;
|
||||||
uint32_t blockSize;
|
uint32_t blockSize;
|
||||||
@ -313,8 +308,7 @@ ReformatAWGS_WP::FindTextBlock(const Chunk* pChunk, int blockNum)
|
|||||||
*
|
*
|
||||||
* Returns the #of bytes consumed.
|
* Returns the #of bytes consumed.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatAWGS_WP::PrintParagraph(const uint8_t* ptr, long maxLen)
|
||||||
ReformatAWGS_WP::PrintParagraph(const uint8_t* ptr, long maxLen)
|
|
||||||
{
|
{
|
||||||
const uint8_t* startPtr = ptr;
|
const uint8_t* startPtr = ptr;
|
||||||
uint16_t firstFont;
|
uint16_t firstFont;
|
||||||
@ -407,8 +401,7 @@ ReformatAWGS_WP::PrintParagraph(const uint8_t* ptr, long maxLen)
|
|||||||
/*
|
/*
|
||||||
* Run through the SaveArray and find the highest-numbered ruler index.
|
* Run through the SaveArray and find the highest-numbered ruler index.
|
||||||
*/
|
*/
|
||||||
uint16_t
|
uint16_t ReformatAWGS_WP::GetNumRulers(const uint8_t* pSaveArray,
|
||||||
ReformatAWGS_WP::GetNumRulers(const uint8_t* pSaveArray,
|
|
||||||
uint16_t saveArrayCount)
|
uint16_t saveArrayCount)
|
||||||
{
|
{
|
||||||
SaveArrayEntry sa;
|
SaveArrayEntry sa;
|
||||||
@ -438,8 +431,7 @@ ReformatAWGS_WP::GetNumRulers(const uint8_t* pSaveArray,
|
|||||||
*
|
*
|
||||||
* These are stored linearly, so we just need to look at the last entry.
|
* These are stored linearly, so we just need to look at the last entry.
|
||||||
*/
|
*/
|
||||||
uint16_t
|
uint16_t ReformatAWGS_WP::GetNumTextBlocks(const uint8_t* pSaveArray,
|
||||||
ReformatAWGS_WP::GetNumTextBlocks(const uint8_t* pSaveArray,
|
|
||||||
uint16_t saveArrayCount)
|
uint16_t saveArrayCount)
|
||||||
{
|
{
|
||||||
SaveArrayEntry sa;
|
SaveArrayEntry sa;
|
||||||
@ -480,8 +472,7 @@ ReformatAWGS_WP::GetNumTextBlocks(const uint8_t* pSaveArray,
|
|||||||
/*
|
/*
|
||||||
* Unpack a SaveArray entry.
|
* Unpack a SaveArray entry.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatAWGS_WP::UnpackSaveArrayEntry(const uint8_t* pSaveArray,
|
||||||
ReformatAWGS_WP::UnpackSaveArrayEntry(const uint8_t* pSaveArray,
|
|
||||||
SaveArrayEntry* pSAE)
|
SaveArrayEntry* pSAE)
|
||||||
{
|
{
|
||||||
pSAE->textBlock = Get16LE(pSaveArray + 0);
|
pSAE->textBlock = Get16LE(pSaveArray + 0);
|
||||||
@ -501,8 +492,7 @@ ReformatAWGS_WP::UnpackSaveArrayEntry(const uint8_t* pSaveArray,
|
|||||||
*
|
*
|
||||||
* Returns "true" on success, "false" on failure.
|
* Returns "true" on success, "false" on failure.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatAWGS_WP::SkipTextBlocks(const uint8_t** pSrcBuf,
|
||||||
ReformatAWGS_WP::SkipTextBlocks(const uint8_t** pSrcBuf,
|
|
||||||
long* pSrcLen, int textBlockCount)
|
long* pSrcLen, int textBlockCount)
|
||||||
{
|
{
|
||||||
uint32_t blockSize;
|
uint32_t blockSize;
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatAWGS_WP(void) {}
|
ReformatAWGS_WP(void) {}
|
||||||
virtual ~ReformatAWGS_WP(void) {}
|
virtual ~ReformatAWGS_WP(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
|
@ -29,8 +29,7 @@
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatAWP::Examine(ReformatHolder* pHolder)
|
||||||
ReformatAWP::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -44,8 +43,7 @@ ReformatAWP::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Reformat an AppleWorks WP document.
|
* Reformat an AppleWorks WP document.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatAWP::Process(const ReformatHolder* pHolder,
|
||||||
ReformatAWP::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -157,8 +155,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Initialize the DocState structure.
|
* Initialize the DocState structure.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatAWP::InitDocState(void)
|
||||||
ReformatAWP::InitDocState(void)
|
|
||||||
{
|
{
|
||||||
memset(&fDocState, 0, sizeof(fDocState));
|
memset(&fDocState, 0, sizeof(fDocState));
|
||||||
fDocState.line = 1;
|
fDocState.line = 1;
|
||||||
@ -167,8 +164,7 @@ ReformatAWP::InitDocState(void)
|
|||||||
/*
|
/*
|
||||||
* Process a line record.
|
* Process a line record.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatAWP::ProcessLineRecord(uint8_t lineRecData, uint8_t lineRecCode,
|
||||||
ReformatAWP::ProcessLineRecord(uint8_t lineRecData, uint8_t lineRecCode,
|
|
||||||
const uint8_t** pSrcPtr, long* pLength)
|
const uint8_t** pSrcPtr, long* pLength)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -304,8 +300,7 @@ ReformatAWP::ProcessLineRecord(uint8_t lineRecData, uint8_t lineRecCode,
|
|||||||
*
|
*
|
||||||
* "lineRecData" has the number of bytes of input that we have yet to read.
|
* "lineRecData" has the number of bytes of input that we have yet to read.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatAWP::HandleTextRecord(uint8_t lineRecData,
|
||||||
ReformatAWP::HandleTextRecord(uint8_t lineRecData,
|
|
||||||
const uint8_t** pSrcPtr, long* pLength)
|
const uint8_t** pSrcPtr, long* pLength)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -473,8 +468,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatADB::Examine(ReformatHolder* pHolder)
|
||||||
ReformatADB::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -488,8 +482,7 @@ ReformatADB::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Reformat an AppleWorks DB document.
|
* Reformat an AppleWorks DB document.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatADB::Process(const ReformatHolder* pHolder,
|
||||||
ReformatADB::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -731,8 +724,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatASP::Examine(ReformatHolder* pHolder)
|
||||||
ReformatASP::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -746,8 +738,7 @@ ReformatASP::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Reformat an AppleWorks SS document.
|
* Reformat an AppleWorks SS document.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatASP::Process(const ReformatHolder* pHolder,
|
||||||
ReformatASP::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -842,8 +833,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Process one row of spreadsheet data.
|
* Process one row of spreadsheet data.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatASP::ProcessRow(int rowNum, const uint8_t** pSrcPtr, long* pLength)
|
||||||
ReformatASP::ProcessRow(int rowNum, const uint8_t** pSrcPtr, long* pLength)
|
|
||||||
{
|
{
|
||||||
uint8_t ctrl;
|
uint8_t ctrl;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
@ -898,8 +888,7 @@ ReformatASP::ProcessRow(int rowNum, const uint8_t** pSrcPtr, long* pLength)
|
|||||||
/*
|
/*
|
||||||
* Process the contents of a single cell.
|
* Process the contents of a single cell.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatASP::ProcessCell(const uint8_t* srcPtr, long cellLength)
|
||||||
ReformatASP::ProcessCell(const uint8_t* srcPtr, long cellLength)
|
|
||||||
{
|
{
|
||||||
uint8_t flag1, flag2;
|
uint8_t flag1, flag2;
|
||||||
double dval;
|
double dval;
|
||||||
@ -969,8 +958,7 @@ ReformatASP::ProcessCell(const uint8_t* srcPtr, long cellLength)
|
|||||||
* Print the AppleWorks SS token pointed to by srcPtr. Some tokens require
|
* Print the AppleWorks SS token pointed to by srcPtr. Some tokens require
|
||||||
* several bytes to express.
|
* several bytes to express.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatASP::PrintToken(const uint8_t** pSrcPtr, long* pLength)
|
||||||
ReformatASP::PrintToken(const uint8_t** pSrcPtr, long* pLength)
|
|
||||||
{
|
{
|
||||||
/* string constants; note these must NOT contain '"' chars */
|
/* string constants; note these must NOT contain '"' chars */
|
||||||
const int kTokenStart = 0xc0;
|
const int kTokenStart = 0xc0;
|
||||||
@ -1048,8 +1036,7 @@ ReformatASP::PrintToken(const uint8_t** pSrcPtr, long* pLength)
|
|||||||
* Format the current column number into something like 'A' or 'BA'. This
|
* Format the current column number into something like 'A' or 'BA'. This
|
||||||
* stores the value in fPrintColBuf and returns a pointer to it.
|
* stores the value in fPrintColBuf and returns a pointer to it.
|
||||||
*/
|
*/
|
||||||
const char*
|
const char* ReformatASP::PrintCol(int col)
|
||||||
ReformatASP::PrintCol(int col)
|
|
||||||
{
|
{
|
||||||
if (col < 0 || col >= 702) {
|
if (col < 0 || col >= 702) {
|
||||||
LOGI(" ASP can't PrintCol(%d)", col);
|
LOGI(" ASP can't PrintCol(%d)", col);
|
||||||
@ -1100,8 +1087,7 @@ ReformatASP::PrintCol(int col)
|
|||||||
* 3F847AE147AE147A
|
* 3F847AE147AE147A
|
||||||
* -----
|
* -----
|
||||||
*/
|
*/
|
||||||
double
|
double ReformatASP::ConvertSANEDouble(const uint8_t* srcPtr)
|
||||||
ReformatASP::ConvertSANEDouble(const uint8_t* srcPtr)
|
|
||||||
{
|
{
|
||||||
double newVal;
|
double newVal;
|
||||||
uint8_t* dptr;
|
uint8_t* dptr;
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatAWP(void) { fShowEmbeds = true; }
|
ReformatAWP(void) { fShowEmbeds = true; }
|
||||||
virtual ~ReformatAWP(void) {}
|
virtual ~ReformatAWP(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -156,10 +156,10 @@ public:
|
|||||||
ReformatADB(void) {}
|
ReformatADB(void) {}
|
||||||
virtual ~ReformatADB(void) {}
|
virtual ~ReformatADB(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
@ -179,10 +179,10 @@ public:
|
|||||||
ReformatASP(void) { fCurrentRow = fCurrentCol = 1; }
|
ReformatASP(void) { fCurrentRow = fCurrentCol = 1; }
|
||||||
virtual ~ReformatASP(void) {}
|
virtual ~ReformatASP(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
|
105
reformat/Asm.cpp
105
reformat/Asm.cpp
@ -45,8 +45,7 @@
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatSCAssem::Examine(ReformatHolder* pHolder)
|
||||||
ReformatSCAssem::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
if (pHolder->GetFileType() == kTypeINT && pHolder->GetAuxType() == 0) {
|
if (pHolder->GetFileType() == kTypeINT && pHolder->GetAuxType() == 0) {
|
||||||
if (ReformatSCAssem::IsSCAssem(pHolder)) {
|
if (ReformatSCAssem::IsSCAssem(pHolder)) {
|
||||||
@ -76,8 +75,7 @@ ReformatSCAssem::Examine(ReformatHolder* pHolder)
|
|||||||
* for marking the end of a line, and have different sets of valid chars. We
|
* for marking the end of a line, and have different sets of valid chars. We
|
||||||
* don't need to fully validate the file, just test the first line.
|
* don't need to fully validate the file, just test the first line.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool ReformatSCAssem::IsSCAssem(const ReformatHolder* pHolder)
|
||||||
ReformatSCAssem::IsSCAssem(const ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
||||||
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
||||||
@ -103,8 +101,7 @@ ReformatSCAssem::IsSCAssem(const ReformatHolder* pHolder)
|
|||||||
* Reformat an S-C Assembler listing into text. I don't know exactly what the
|
* Reformat an S-C Assembler listing into text. I don't know exactly what the
|
||||||
* original listings looked like, so I'm just doing what A2FID.C does.
|
* original listings looked like, so I'm just doing what A2FID.C does.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatSCAssem::Process(const ReformatHolder* pHolder,
|
||||||
ReformatSCAssem::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -222,8 +219,7 @@ done:
|
|||||||
* since the text file contents will match. However, it's probably useful
|
* since the text file contents will match. However, it's probably useful
|
||||||
* to support DOS ED/ASM sources with this.
|
* to support DOS ED/ASM sources with this.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatMerlin::Examine(ReformatHolder* pHolder)
|
||||||
ReformatMerlin::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
if (pHolder->GetFileType() == kTypeTXT) {
|
if (pHolder->GetFileType() == kTypeTXT) {
|
||||||
bool isAsm = ReformatMerlin::IsMerlin(pHolder);
|
bool isAsm = ReformatMerlin::IsMerlin(pHolder);
|
||||||
@ -271,8 +267,7 @@ ReformatMerlin::Examine(ReformatHolder* pHolder)
|
|||||||
*
|
*
|
||||||
* This will also return "true" for DOS ED/ASM files.
|
* This will also return "true" for DOS ED/ASM files.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool ReformatMerlin::IsMerlin(const ReformatHolder* pHolder)
|
||||||
ReformatMerlin::IsMerlin(const ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
||||||
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
||||||
@ -329,8 +324,7 @@ ReformatMerlin::IsMerlin(const ReformatHolder* pHolder)
|
|||||||
* has been "washed" through a converter or if this is actually a DOS ED/ASM
|
* has been "washed" through a converter or if this is actually a DOS ED/ASM
|
||||||
* file, tracking quotes is almost always beneficial.
|
* file, tracking quotes is almost always beneficial.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatMerlin::Process(const ReformatHolder* pHolder,
|
||||||
ReformatMerlin::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -430,8 +424,7 @@ ReformatMerlin::Process(const ReformatHolder* pHolder,
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA2::Examine(ReformatHolder* pHolder)
|
||||||
ReformatLISA2::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
if (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS &&
|
if (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS &&
|
||||||
pHolder->GetFileType() == kTypeDOS_B)
|
pHolder->GetFileType() == kTypeDOS_B)
|
||||||
@ -458,8 +451,7 @@ ReformatLISA2::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Quick sanity check on the file contents.
|
* Quick sanity check on the file contents.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatLISA2::IsLISA(const ReformatHolder* pHolder)
|
||||||
ReformatLISA2::IsLISA(const ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
||||||
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
||||||
@ -518,8 +510,7 @@ static const char gOpcodes[] =
|
|||||||
/*
|
/*
|
||||||
* Parse a file.
|
* Parse a file.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatLISA2::Process(const ReformatHolder* pHolder,
|
||||||
ReformatLISA2::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -579,8 +570,7 @@ bail:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ReformatLISA2::ProcessLine(const uint8_t* buf)
|
||||||
ReformatLISA2::ProcessLine(const uint8_t* buf)
|
|
||||||
{
|
{
|
||||||
int len = *buf;
|
int len = *buf;
|
||||||
uint8_t uch;
|
uint8_t uch;
|
||||||
@ -663,7 +653,7 @@ ReformatLISA2::ProcessLine(const uint8_t* buf)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* ===========================================================================
|
* ===========================================================================
|
||||||
* LISA Assembler - v4 and v5
|
* LISA Assembler - v3
|
||||||
* ===========================================================================
|
* ===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -747,8 +737,7 @@ static const char gMnemonics3[256*3 +1] =
|
|||||||
/*
|
/*
|
||||||
* Determine whether this is one of our files.
|
* Determine whether this is one of our files.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA3::Examine(ReformatHolder* pHolder)
|
||||||
ReformatLISA3::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Note we cannot false-positive on an INT file on a DOS disk, because
|
* Note we cannot false-positive on an INT file on a DOS disk, because
|
||||||
@ -780,8 +769,7 @@ ReformatLISA3::Examine(ReformatHolder* pHolder)
|
|||||||
* Decide if this is one of ours or perhaps an Integer BASIC or S-C
|
* Decide if this is one of ours or perhaps an Integer BASIC or S-C
|
||||||
* assembler source.
|
* assembler source.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool ReformatLISA3::IsLISA(const ReformatHolder* pHolder)
|
||||||
ReformatLISA3::IsLISA(const ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
bool dosStructure = (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS);
|
bool dosStructure = (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS);
|
||||||
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
||||||
@ -817,8 +805,7 @@ ReformatLISA3::IsLISA(const ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Parse a file.
|
* Parse a file.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatLISA3::Process(const ReformatHolder* pHolder,
|
||||||
ReformatLISA3::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -966,8 +953,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* BIGONE
|
* BIGONE
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA3::ProcessLine(const uint8_t* codePtr, int len)
|
||||||
ReformatLISA3::ProcessLine(const uint8_t* codePtr, int len)
|
|
||||||
{
|
{
|
||||||
uint8_t mnemonic = 0;
|
uint8_t mnemonic = 0;
|
||||||
|
|
||||||
@ -1054,8 +1040,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* CNVOPRND
|
* CNVOPRND
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA3::ConvertOperand(uint8_t mnemonic,
|
||||||
ReformatLISA3::ConvertOperand(uint8_t mnemonic,
|
|
||||||
const uint8_t** pCodePtr, int* pLen)
|
const uint8_t** pCodePtr, int* pLen)
|
||||||
{
|
{
|
||||||
static const char kOPRTRST1[] = "+-*/&|^=<>%<><";
|
static const char kOPRTRST1[] = "+-*/&|^=<>%<><";
|
||||||
@ -1163,8 +1148,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Output a single byte as a binary string.
|
* Output a single byte as a binary string.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA3::PrintBin(uint8_t val)
|
||||||
ReformatLISA3::PrintBin(uint8_t val)
|
|
||||||
{
|
{
|
||||||
char buf[9];
|
char buf[9];
|
||||||
buf[8] = '\0';
|
buf[8] = '\0';
|
||||||
@ -1177,9 +1161,8 @@ ReformatLISA3::PrintBin(uint8_t val)
|
|||||||
/*
|
/*
|
||||||
* OUTNUM
|
* OUTNUM
|
||||||
*/
|
*/
|
||||||
ReformatLISA3::OperandResult
|
ReformatLISA3::OperandResult ReformatLISA3::PrintNum(int adrsMode, uint8_t val,
|
||||||
ReformatLISA3::PrintNum(int adrsMode, uint8_t val,
|
const uint8_t** pCodePtr, int* pLen)
|
||||||
const uint8_t** pCodePtr, int* pLen)
|
|
||||||
{
|
{
|
||||||
const uint8_t* codePtr = *pCodePtr;
|
const uint8_t* codePtr = *pCodePtr;
|
||||||
int len = *pLen;
|
int len = *pLen;
|
||||||
@ -1315,8 +1298,7 @@ bail:
|
|||||||
* Print symbol table entry. Each entry is an 8-byte label packed into
|
* Print symbol table entry. Each entry is an 8-byte label packed into
|
||||||
* 6 bytes.
|
* 6 bytes.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA3::PrintSymEntry(int ent)
|
||||||
ReformatLISA3::PrintSymEntry(int ent)
|
|
||||||
{
|
{
|
||||||
if (ent < 0 || ent >= fSymCount) {
|
if (ent < 0 || ent >= fSymCount) {
|
||||||
Output("!BAD SYM!");
|
Output("!BAD SYM!");
|
||||||
@ -1349,8 +1331,7 @@ ReformatLISA3::PrintSymEntry(int ent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ReformatLISA3::PrintMnemonic(uint8_t val)
|
||||||
ReformatLISA3::PrintMnemonic(uint8_t val)
|
|
||||||
{
|
{
|
||||||
const char* ptr = &gMnemonics3[val * 3];
|
const char* ptr = &gMnemonics3[val * 3];
|
||||||
Output(ptr[0]);
|
Output(ptr[0]);
|
||||||
@ -1363,8 +1344,7 @@ ReformatLISA3::PrintMnemonic(uint8_t val)
|
|||||||
*
|
*
|
||||||
* Prints the comment. Finishes off the operand if necessary.
|
* Prints the comment. Finishes off the operand if necessary.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA3::PrintComment(int adrsMode, const uint8_t* codePtr, int len)
|
||||||
ReformatLISA3::PrintComment(int adrsMode, const uint8_t* codePtr, int len)
|
|
||||||
{
|
{
|
||||||
assert(len >= 0);
|
assert(len >= 0);
|
||||||
|
|
||||||
@ -1411,8 +1391,7 @@ ReformatLISA3::PrintComment(int adrsMode, const uint8_t* codePtr, int len)
|
|||||||
/*
|
/*
|
||||||
* Determine whether this is one of our files.
|
* Determine whether this is one of our files.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA4::Examine(ReformatHolder* pHolder)
|
||||||
ReformatLISA4::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Note we cannot false-positive on an INT file on a DOS disk, because
|
* Note we cannot false-positive on an INT file on a DOS disk, because
|
||||||
@ -1444,8 +1423,7 @@ ReformatLISA4::Examine(ReformatHolder* pHolder)
|
|||||||
* Decide if this is one of ours or perhaps an Integer BASIC or S-C
|
* Decide if this is one of ours or perhaps an Integer BASIC or S-C
|
||||||
* assembler source.
|
* assembler source.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool ReformatLISA4::IsLISA(const ReformatHolder* pHolder)
|
||||||
ReformatLISA4::IsLISA(const ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
bool dosStructure = (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS);
|
bool dosStructure = (pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatDOS);
|
||||||
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
const uint8_t* srcPtr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
||||||
@ -1558,8 +1536,7 @@ static const char* gMnemonics4[] = {
|
|||||||
/*
|
/*
|
||||||
* Parse a file.
|
* Parse a file.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatLISA4::Process(const ReformatHolder* pHolder,
|
||||||
ReformatLISA4::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -1585,9 +1562,9 @@ ReformatLISA4::Process(const ReformatHolder* pHolder,
|
|||||||
fComTab = srcPtr[0x08];
|
fComTab = srcPtr[0x08];
|
||||||
fCpuType = srcPtr[0x09];
|
fCpuType = srcPtr[0x09];
|
||||||
|
|
||||||
LOGI(" LISA4 version = 0x%04x symEnd=%d symCount=%d",
|
LOGD(" LISA4 version = 0x%04x symEnd=%d symCount=%d",
|
||||||
version, symEnd, fSymCount);
|
version, symEnd, fSymCount);
|
||||||
LOGI(" LISA4 opTab=%d adTab=%d comTab=%d cpuType=%d",
|
LOGD(" LISA4 opTab=%d adTab=%d comTab=%d cpuType=%d",
|
||||||
fOpTab, fAdTab, fComTab, fCpuType);
|
fOpTab, fAdTab, fComTab, fCpuType);
|
||||||
|
|
||||||
if (symEnd > srcLen) {
|
if (symEnd > srcLen) {
|
||||||
@ -1731,8 +1708,7 @@ bail:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ReformatLISA4::ProcessLine(const uint8_t* codePtr, int len)
|
||||||
ReformatLISA4::ProcessLine(const uint8_t* codePtr, int len)
|
|
||||||
{
|
{
|
||||||
uint8_t mnemonic = 0;
|
uint8_t mnemonic = 0;
|
||||||
|
|
||||||
@ -1835,8 +1811,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* ConvtOperand
|
* ConvtOperand
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA4::ConvertOperand(uint8_t mnemonic,
|
||||||
ReformatLISA4::ConvertOperand(uint8_t mnemonic,
|
|
||||||
const uint8_t** pCodePtr, int* pLen)
|
const uint8_t** pCodePtr, int* pLen)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -2095,8 +2070,7 @@ not_operator:
|
|||||||
/*
|
/*
|
||||||
* CnvrtDec - convert to decimal output.
|
* CnvrtDec - convert to decimal output.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA4::PrintDec(int count, const uint8_t** pCodePtr,
|
||||||
ReformatLISA4::PrintDec(int count, const uint8_t** pCodePtr,
|
|
||||||
int* pLen)
|
int* pLen)
|
||||||
{
|
{
|
||||||
const uint8_t* codePtr = *pCodePtr;
|
const uint8_t* codePtr = *pCodePtr;
|
||||||
@ -2118,8 +2092,7 @@ ReformatLISA4::PrintDec(int count, const uint8_t** pCodePtr,
|
|||||||
/*
|
/*
|
||||||
* CnvrtHex - convert to hex output.
|
* CnvrtHex - convert to hex output.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA4::PrintHex(int count, const uint8_t** pCodePtr,
|
||||||
ReformatLISA4::PrintHex(int count, const uint8_t** pCodePtr,
|
|
||||||
int* pLen)
|
int* pLen)
|
||||||
{
|
{
|
||||||
const uint8_t* codePtr = *pCodePtr;
|
const uint8_t* codePtr = *pCodePtr;
|
||||||
@ -2142,8 +2115,7 @@ ReformatLISA4::PrintHex(int count, const uint8_t** pCodePtr,
|
|||||||
/*
|
/*
|
||||||
* CnvrtBin - convert to binary output.
|
* CnvrtBin - convert to binary output.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA4::PrintBin(int count, const uint8_t** pCodePtr,
|
||||||
ReformatLISA4::PrintBin(int count, const uint8_t** pCodePtr,
|
|
||||||
int* pLen)
|
int* pLen)
|
||||||
{
|
{
|
||||||
const uint8_t* codePtr = *pCodePtr;
|
const uint8_t* codePtr = *pCodePtr;
|
||||||
@ -2171,9 +2143,8 @@ ReformatLISA4::PrintBin(int count, const uint8_t** pCodePtr,
|
|||||||
/*
|
/*
|
||||||
* OUTNUM
|
* OUTNUM
|
||||||
*/
|
*/
|
||||||
ReformatLISA4::OperandResult
|
ReformatLISA4::OperandResult ReformatLISA4::PrintNum(uint8_t opr,
|
||||||
ReformatLISA4::PrintNum(uint8_t opr, const uint8_t** pCodePtr,
|
const uint8_t** pCodePtr, int* pLen)
|
||||||
int* pLen)
|
|
||||||
{
|
{
|
||||||
OperandResult result = kResultUnknown;
|
OperandResult result = kResultUnknown;
|
||||||
const uint8_t* codePtr = *pCodePtr;
|
const uint8_t* codePtr = *pCodePtr;
|
||||||
@ -2295,9 +2266,8 @@ ReformatLISA4::PrintNum(uint8_t opr, const uint8_t** pCodePtr,
|
|||||||
/*
|
/*
|
||||||
* OutOprComp
|
* OutOprComp
|
||||||
*/
|
*/
|
||||||
ReformatLISA4::OperandResult
|
ReformatLISA4::OperandResult ReformatLISA4::PrintComplexOperand(uint8_t opr,
|
||||||
ReformatLISA4::PrintComplexOperand(uint8_t opr,
|
const uint8_t** pCodePtr, int* pLen)
|
||||||
const uint8_t** pCodePtr, int* pLen)
|
|
||||||
{
|
{
|
||||||
if (opr != kBign_tkn)
|
if (opr != kBign_tkn)
|
||||||
return PrintNum(opr, pCodePtr, pLen);
|
return PrintNum(opr, pCodePtr, pLen);
|
||||||
@ -2360,8 +2330,7 @@ const uint8_t** pCodePtr, int* pLen)
|
|||||||
/*
|
/*
|
||||||
* Print symbol table entry.
|
* Print symbol table entry.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatLISA4::PrintSymEntry(int ent)
|
||||||
ReformatLISA4::PrintSymEntry(int ent)
|
|
||||||
{
|
{
|
||||||
if (ent < 0 || ent >= fSymCount) {
|
if (ent < 0 || ent >= fSymCount) {
|
||||||
Output("!BAD SYM!");
|
Output("!BAD SYM!");
|
||||||
|
@ -71,10 +71,10 @@ public:
|
|||||||
ReformatSCAssem(void) {}
|
ReformatSCAssem(void) {}
|
||||||
virtual ~ReformatSCAssem(void) {}
|
virtual ~ReformatSCAssem(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
/* this gets called by Integer BASIC converter */
|
/* this gets called by Integer BASIC converter */
|
||||||
static bool IsSCAssem(const ReformatHolder* pHolder);
|
static bool IsSCAssem(const ReformatHolder* pHolder);
|
||||||
@ -89,10 +89,10 @@ public:
|
|||||||
ReformatMerlin(void) {}
|
ReformatMerlin(void) {}
|
||||||
virtual ~ReformatMerlin(void) {}
|
virtual ~ReformatMerlin(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool IsMerlin(const ReformatHolder* pHolder);
|
static bool IsMerlin(const ReformatHolder* pHolder);
|
||||||
@ -107,10 +107,10 @@ public:
|
|||||||
ReformatLISA2(void) {}
|
ReformatLISA2(void) {}
|
||||||
virtual ~ReformatLISA2(void) {}
|
virtual ~ReformatLISA2(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool IsLISA(const ReformatHolder* pHolder);
|
bool IsLISA(const ReformatHolder* pHolder);
|
||||||
@ -132,10 +132,10 @@ public:
|
|||||||
ReformatLISA3(void) : fSymTab(NULL) {}
|
ReformatLISA3(void) : fSymTab(NULL) {}
|
||||||
virtual ~ReformatLISA3(void) {}
|
virtual ~ReformatLISA3(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
static bool IsLISA(const ReformatHolder* pHolder);
|
static bool IsLISA(const ReformatHolder* pHolder);
|
||||||
|
|
||||||
@ -200,10 +200,10 @@ public:
|
|||||||
ReformatLISA4(void) : fSymTab(NULL) {}
|
ReformatLISA4(void) : fSymTab(NULL) {}
|
||||||
virtual ~ReformatLISA4(void) { delete[] fSymTab; }
|
virtual ~ReformatLISA4(void) { delete[] fSymTab; }
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
static bool IsLISA(const ReformatHolder* pHolder);
|
static bool IsLISA(const ReformatHolder* pHolder);
|
||||||
|
|
||||||
|
@ -44,8 +44,7 @@ const ReformatText::TextColor kColonColor = ReformatText::kColorRed;
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatApplesoft::Examine(ReformatHolder* pHolder)
|
||||||
ReformatApplesoft::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -101,8 +100,7 @@ static const char gApplesoftTokens[128 * ReformatApplesoft::kTokenLen] = {
|
|||||||
* Reformat an Applesoft BASIC program into a text format that mimics the
|
* Reformat an Applesoft BASIC program into a text format that mimics the
|
||||||
* output of the "LIST" command (with POKE 33,73 to suppress CRs).
|
* output of the "LIST" command (with POKE 33,73 to suppress CRs).
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatApplesoft::Process(const ReformatHolder* pHolder,
|
||||||
ReformatApplesoft::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -306,8 +304,7 @@ static const char* const gIntegerTokens[128] = {
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatInteger::Examine(ReformatHolder* pHolder)
|
||||||
ReformatInteger::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies apply = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies apply = ReformatHolder::kApplicNot;
|
||||||
if (pHolder->GetFileType() == kTypeINT) {
|
if (pHolder->GetFileType() == kTypeINT) {
|
||||||
@ -346,8 +343,7 @@ ReformatInteger::Examine(ReformatHolder* pHolder)
|
|||||||
* Reformat an Integer BASIC program into a text format that mimics the
|
* Reformat an Integer BASIC program into a text format that mimics the
|
||||||
* output of the "LIST" command.
|
* output of the "LIST" command.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatInteger::Process(const ReformatHolder* pHolder,
|
||||||
ReformatInteger::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -550,8 +546,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatBusiness::Examine(ReformatHolder* pHolder)
|
||||||
ReformatBusiness::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -574,7 +569,7 @@ ReformatBusiness::Examine(ReformatHolder* pHolder)
|
|||||||
* show up as error messages. The goal here is to produce values that are
|
* show up as error messages. The goal here is to produce values that are
|
||||||
* human-readable and/or EXECable, so no attempt has been made to display
|
* human-readable and/or EXECable, so no attempt has been made to display
|
||||||
* the error values.
|
* the error values.
|
||||||
* TODO: replace this with something accurate -- looks like copy & paste leftover
|
* TODO: verify this comment -- looks like copy & paste from BAS token table
|
||||||
*/
|
*/
|
||||||
static const char gBusinessTokens[128*10] = {
|
static const char gBusinessTokens[128*10] = {
|
||||||
/* 0x80 */ "END\0 FOR\0 NEXT\0 INPUT\0 OUTPUT\0 DIM\0 READ\0 WRITE\0 "
|
/* 0x80 */ "END\0 FOR\0 NEXT\0 INPUT\0 OUTPUT\0 DIM\0 READ\0 WRITE\0 "
|
||||||
@ -618,8 +613,7 @@ static const char gExtendedBusinessTokens[128*10] = {
|
|||||||
* Reformat an Apple /// Business BASIC program into a text format that
|
* Reformat an Apple /// Business BASIC program into a text format that
|
||||||
* mimics the output of the "LIST" command.
|
* mimics the output of the "LIST" command.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatBusiness::Process(const ReformatHolder* pHolder,
|
||||||
ReformatBusiness::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatApplesoft(void) {}
|
ReformatApplesoft(void) {}
|
||||||
virtual ~ReformatApplesoft(void) {}
|
virtual ~ReformatApplesoft(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
/* share our token list with others */
|
/* share our token list with others */
|
||||||
// TODO: this is a hack; find a better way to do this
|
// TODO: this is a hack; find a better way to do this
|
||||||
@ -38,10 +38,10 @@ public:
|
|||||||
ReformatInteger(void) {}
|
ReformatInteger(void) {}
|
||||||
virtual ~ReformatInteger(void) {}
|
virtual ~ReformatInteger(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -52,10 +52,10 @@ public:
|
|||||||
ReformatBusiness(void) {}
|
ReformatBusiness(void) {}
|
||||||
virtual ~ReformatBusiness(void) {}
|
virtual ~ReformatBusiness(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*REFORMAT_BASIC_H*/
|
#endif /*REFORMAT_BASIC_H*/
|
||||||
|
@ -58,8 +58,7 @@ static const char gIsBinary[256] = {
|
|||||||
* End-of-file is at the first Ctrl-Z, but we can't stop there because it
|
* End-of-file is at the first Ctrl-Z, but we can't stop there because it
|
||||||
* could be a binary file with a leading Ctrl-Z (e.g. PNG).
|
* could be a binary file with a leading Ctrl-Z (e.g. PNG).
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatCPMText::Examine(ReformatHolder* pHolder)
|
||||||
ReformatCPMText::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
||||||
@ -118,8 +117,7 @@ done:
|
|||||||
* Generally speaking, CP/M text files should already be in CRLF format, so
|
* Generally speaking, CP/M text files should already be in CRLF format, so
|
||||||
* this will go quickly.
|
* this will go quickly.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatCPMText::Process(const ReformatHolder* pHolder,
|
||||||
ReformatCPMText::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatCPMText(void) {}
|
ReformatCPMText(void) {}
|
||||||
virtual ~ReformatCPMText(void) {}
|
virtual ~ReformatCPMText(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*REFORMAT_CPMFILES_H*/
|
#endif /*REFORMAT_CPMFILES_H*/
|
||||||
|
@ -16,8 +16,7 @@ using namespace DiskImgLib;
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDirectory::Examine(ReformatHolder* pHolder)
|
||||||
ReformatDirectory::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -33,8 +32,7 @@ ReformatDirectory::Examine(ReformatHolder* pHolder)
|
|||||||
* Convert a ProDOS directory into a format resembling BASIC.System's
|
* Convert a ProDOS directory into a format resembling BASIC.System's
|
||||||
* 80-column "catalog" command.
|
* 80-column "catalog" command.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDirectory::Process(const ReformatHolder* pHolder,
|
||||||
ReformatDirectory::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -70,8 +68,7 @@ ReformatDirectory::Process(const ReformatHolder* pHolder,
|
|||||||
* The "showDeleted" flag determines whether we show active entries or
|
* The "showDeleted" flag determines whether we show active entries or
|
||||||
* deleted entries.
|
* deleted entries.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDirectory::PrintDirEntries(const uint8_t* srcBuf,
|
||||||
ReformatDirectory::PrintDirEntries(const uint8_t* srcBuf,
|
|
||||||
long srcLen, bool showDeleted)
|
long srcLen, bool showDeleted)
|
||||||
{
|
{
|
||||||
const int kEntriesPerBlock = 0x0d; // expected value for entries per blk
|
const int kEntriesPerBlock = 0x0d; // expected value for entries per blk
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatDirectory(void) {}
|
ReformatDirectory(void) {}
|
||||||
virtual ~ReformatDirectory(void) {}
|
virtual ~ReformatDirectory(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PrintDirEntries(const uint8_t* srcBuf,
|
void PrintDirEntries(const uint8_t* srcBuf,
|
||||||
|
@ -42,8 +42,7 @@
|
|||||||
* Width is always > 0. This guarantees that we don't loop forever even if
|
* Width is always > 0. This guarantees that we don't loop forever even if
|
||||||
* we hit stuff we don't recognize.
|
* we hit stuff we don't recognize.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDisasm65xxx::GetOpWidth(OpCode opCode, AddrMode addrMode, CPU cpu,
|
||||||
ReformatDisasm65xxx::GetOpWidth(OpCode opCode, AddrMode addrMode, CPU cpu,
|
|
||||||
bool emul, bool shortM, bool shortX)
|
bool emul, bool shortM, bool shortX)
|
||||||
{
|
{
|
||||||
int width = 0;
|
int width = 0;
|
||||||
@ -148,8 +147,7 @@ ReformatDisasm65xxx::GetOpWidth(OpCode opCode, AddrMode addrMode, CPU cpu,
|
|||||||
*
|
*
|
||||||
* The caller is expected to check to see if we're in bank 0.
|
* The caller is expected to check to see if we're in bank 0.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatDisasm65xxx::IsP8Call(const uint8_t* srcBuf, long srcLen)
|
||||||
ReformatDisasm65xxx::IsP8Call(const uint8_t* srcBuf, long srcLen)
|
|
||||||
{
|
{
|
||||||
if (srcLen >= 6 &&
|
if (srcLen >= 6 &&
|
||||||
srcBuf[0] == 0x20 && srcBuf[1] == 0x00 && srcBuf[2] == 0xbf)
|
srcBuf[0] == 0x20 && srcBuf[1] == 0x00 && srcBuf[2] == 0xbf)
|
||||||
@ -162,8 +160,7 @@ ReformatDisasm65xxx::IsP8Call(const uint8_t* srcBuf, long srcLen)
|
|||||||
/*
|
/*
|
||||||
* Returns "true" if it looks like we're pointing at a IIgs toolbox call.
|
* Returns "true" if it looks like we're pointing at a IIgs toolbox call.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatDisasm65xxx::IsToolboxCall(const uint8_t* srcBuf, long srcLen,
|
||||||
ReformatDisasm65xxx::IsToolboxCall(const uint8_t* srcBuf, long srcLen,
|
|
||||||
long backState)
|
long backState)
|
||||||
{
|
{
|
||||||
if (srcLen >= 4 && backState >= 3 &&
|
if (srcLen >= 4 && backState >= 3 &&
|
||||||
@ -178,8 +175,7 @@ ReformatDisasm65xxx::IsToolboxCall(const uint8_t* srcBuf, long srcLen,
|
|||||||
/*
|
/*
|
||||||
* Returns "true" if it looks like we're pointing at an inline GS/OS call.
|
* Returns "true" if it looks like we're pointing at an inline GS/OS call.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatDisasm65xxx::IsInlineGSOS(const uint8_t* srcBuf, long srcLen)
|
||||||
ReformatDisasm65xxx::IsInlineGSOS(const uint8_t* srcBuf, long srcLen)
|
|
||||||
{
|
{
|
||||||
if (srcLen >= 10 &&
|
if (srcLen >= 10 &&
|
||||||
srcBuf[0] == 0x22 && srcBuf[1] == 0xa8 && srcBuf[2] == 0x00 &&
|
srcBuf[0] == 0x22 && srcBuf[1] == 0xa8 && srcBuf[2] == 0x00 &&
|
||||||
@ -193,8 +189,7 @@ ReformatDisasm65xxx::IsInlineGSOS(const uint8_t* srcBuf, long srcLen)
|
|||||||
/*
|
/*
|
||||||
* Returns "true" if it looks like we're pointing at a stack GS/OS call.
|
* Returns "true" if it looks like we're pointing at a stack GS/OS call.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatDisasm65xxx::IsStackGSOS(const uint8_t* srcBuf, long srcLen,
|
||||||
ReformatDisasm65xxx::IsStackGSOS(const uint8_t* srcBuf, long srcLen,
|
|
||||||
long backState)
|
long backState)
|
||||||
{
|
{
|
||||||
if (srcLen >= 4 && backState >= 3 &&
|
if (srcLen >= 4 && backState >= 3 &&
|
||||||
@ -213,8 +208,7 @@ ReformatDisasm65xxx::IsStackGSOS(const uint8_t* srcBuf, long srcLen,
|
|||||||
*
|
*
|
||||||
* Returns the number of bytes consumed.
|
* Returns the number of bytes consumed.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDisasm65xxx::OutputMonitor8(const uint8_t* srcBuf, long srcLen,
|
||||||
ReformatDisasm65xxx::OutputMonitor8(const uint8_t* srcBuf, long srcLen,
|
|
||||||
long backState, uint16_t addr)
|
long backState, uint16_t addr)
|
||||||
{
|
{
|
||||||
const CPU kCPU = kCPU65C02; // 6502 or 65C02
|
const CPU kCPU = kCPU65C02; // 6502 or 65C02
|
||||||
@ -265,10 +259,8 @@ ReformatDisasm65xxx::OutputMonitor8(const uint8_t* srcBuf, long srcLen,
|
|||||||
/*
|
/*
|
||||||
* Output one line of 8-bit monitor stuff.
|
* Output one line of 8-bit monitor stuff.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDisasm65xxx::PrintMonitor8Line(OpCode opCode, AddrMode addrMode,
|
||||||
ReformatDisasm65xxx::PrintMonitor8Line(OpCode opCode, AddrMode addrMode,
|
uint16_t addr, const uint8_t* srcBuf, long srcLen, const char* comment)
|
||||||
uint16_t addr, const uint8_t* srcBuf, long srcLen,
|
|
||||||
const char* comment)
|
|
||||||
{
|
{
|
||||||
char lineBuf[64]; // actual length is about 30 -- does not hold comment
|
char lineBuf[64]; // actual length is about 30 -- does not hold comment
|
||||||
char* cp;
|
char* cp;
|
||||||
@ -393,15 +385,13 @@ ReformatDisasm65xxx::PrintMonitor8Line(OpCode opCode, AddrMode addrMode,
|
|||||||
RTFNewPara();
|
RTFNewPara();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output one or more lines of text similar to what the monitor would output
|
* Output one or more lines of text similar to what the monitor would output
|
||||||
* on an 8-bit Apple II.
|
* on an 8-bit Apple II.
|
||||||
*
|
*
|
||||||
* Returns the number of bytes consumed.
|
* Returns the number of bytes consumed.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDisasm65xxx::OutputMonitor16(const uint8_t* srcBuf, long srcLen,
|
||||||
ReformatDisasm65xxx::OutputMonitor16(const uint8_t* srcBuf, long srcLen,
|
|
||||||
long backState, uint32_t addr, bool shortRegs)
|
long backState, uint32_t addr, bool shortRegs)
|
||||||
{
|
{
|
||||||
const CPU kCPU = kCPU65816;
|
const CPU kCPU = kCPU65816;
|
||||||
@ -472,10 +462,8 @@ ReformatDisasm65xxx::OutputMonitor16(const uint8_t* srcBuf, long srcLen,
|
|||||||
/*
|
/*
|
||||||
* Output one line of 16-bit monitor stuff.
|
* Output one line of 16-bit monitor stuff.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode,
|
||||||
ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode,
|
uint32_t addr, const uint8_t* srcBuf, long srcLen, const char* comment)
|
||||||
uint32_t addr, const uint8_t* srcBuf, long srcLen,
|
|
||||||
const char* comment)
|
|
||||||
{
|
{
|
||||||
char lineBuf[64]; // actual length is about 30 -- does not hold comment
|
char lineBuf[64]; // actual length is about 30 -- does not hold comment
|
||||||
char* cp;
|
char* cp;
|
||||||
@ -671,8 +659,7 @@ ReformatDisasm65xxx::PrintMonitor16Line(OpCode opCode, AddrMode addrMode,
|
|||||||
* file is code or, say, a hi-res graphic. We use "maybe" level to put
|
* file is code or, say, a hi-res graphic. We use "maybe" level to put
|
||||||
* disassembly below other formats.
|
* disassembly below other formats.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDisasm8::Examine(ReformatHolder* pHolder)
|
||||||
ReformatDisasm8::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
int fileType = pHolder->GetFileType();
|
int fileType = pHolder->GetFileType();
|
||||||
@ -703,8 +690,7 @@ ReformatDisasm8::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Create a monitor listing or disassembly of a file.
|
* Create a monitor listing or disassembly of a file.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDisasm8::Process(const ReformatHolder* pHolder,
|
||||||
ReformatDisasm8::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -757,8 +743,7 @@ ReformatDisasm8::Process(const ReformatHolder* pHolder,
|
|||||||
* want to keep 16-bit disassembly available but prioritized below "raw" for
|
* want to keep 16-bit disassembly available but prioritized below "raw" for
|
||||||
* BIN files.
|
* BIN files.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDisasm16::Examine(ReformatHolder* pHolder)
|
||||||
ReformatDisasm16::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -812,8 +797,7 @@ ReformatDisasm16::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Disassemble or show monitor listing for 16-bit code.
|
* Disassemble or show monitor listing for 16-bit code.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDisasm16::Process(const ReformatHolder* pHolder,
|
||||||
ReformatDisasm16::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -861,8 +845,7 @@ ReformatDisasm16::Process(const ReformatHolder* pHolder,
|
|||||||
/*
|
/*
|
||||||
* Output one section of a file.
|
* Output one section of a file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDisasm16::OutputSection(const uint8_t* srcBuf, long srcLen,
|
||||||
ReformatDisasm16::OutputSection(const uint8_t* srcBuf, long srcLen,
|
|
||||||
uint32_t addr, bool shortRegs)
|
uint32_t addr, bool shortRegs)
|
||||||
{
|
{
|
||||||
long backState = 0;
|
long backState = 0;
|
||||||
@ -882,8 +865,7 @@ ReformatDisasm16::OutputSection(const uint8_t* srcBuf, long srcLen,
|
|||||||
/*
|
/*
|
||||||
* Break an OMF file into sections, and output each individually.
|
* Break an OMF file into sections, and output each individually.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatDisasm16::OutputOMF(const uint8_t* srcBuf, long srcLen,
|
||||||
ReformatDisasm16::OutputOMF(const uint8_t* srcBuf, long srcLen,
|
|
||||||
long fileType, bool shortRegs)
|
long fileType, bool shortRegs)
|
||||||
{
|
{
|
||||||
const uint8_t* origBuf = srcBuf;
|
const uint8_t* origBuf = srcBuf;
|
||||||
@ -948,8 +930,7 @@ ReformatDisasm16::OutputOMF(const uint8_t* srcBuf, long srcLen,
|
|||||||
/*
|
/*
|
||||||
* Print the interesting bits of the header.
|
* Print the interesting bits of the header.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDisasm16::PrintHeader(const OMFSegmentHeader* pSegHdr,
|
||||||
ReformatDisasm16::PrintHeader(const OMFSegmentHeader* pSegHdr,
|
|
||||||
int segmentNumber, bool longFmt)
|
int segmentNumber, bool longFmt)
|
||||||
{
|
{
|
||||||
//pSegHdr->Dump();
|
//pSegHdr->Dump();
|
||||||
@ -1004,8 +985,7 @@ ReformatDisasm16::PrintHeader(const OMFSegmentHeader* pSegHdr,
|
|||||||
/*
|
/*
|
||||||
* Print the contents of the segment.
|
* Print the contents of the segment.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr,
|
||||||
ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr,
|
|
||||||
const uint8_t* srcBuf, long srcLen, bool shortRegs)
|
const uint8_t* srcBuf, long srcLen, bool shortRegs)
|
||||||
{
|
{
|
||||||
uint32_t subLen;
|
uint32_t subLen;
|
||||||
@ -1065,9 +1045,7 @@ ReformatDisasm16::PrintSegment(const OMFSegmentHeader* pSegHdr,
|
|||||||
*
|
*
|
||||||
* Returns "true" on success, "false" on failure.
|
* Returns "true" on success, "false" on failure.
|
||||||
*/
|
*/
|
||||||
bool
|
bool OMFSegmentHeader::Unpack(const uint8_t* srcBuf, long srcLen, int fileType)
|
||||||
OMFSegmentHeader::Unpack(const uint8_t* srcBuf, long srcLen,
|
|
||||||
int fileType)
|
|
||||||
{
|
{
|
||||||
if (srcLen < kHdrMinSize) {
|
if (srcLen < kHdrMinSize) {
|
||||||
LOGI("OMF: Too short to be segment (%ld)", srcLen);
|
LOGI("OMF: Too short to be segment (%ld)", srcLen);
|
||||||
@ -1238,8 +1216,7 @@ OMFSegmentHeader::Unpack(const uint8_t* srcBuf, long srcLen,
|
|||||||
/*
|
/*
|
||||||
* Pry the segment type out of the "type" or "kind" field.
|
* Pry the segment type out of the "type" or "kind" field.
|
||||||
*/
|
*/
|
||||||
OMFSegmentHeader::SegmentType
|
OMFSegmentHeader::SegmentType OMFSegmentHeader::GetSegmentType(void) const
|
||||||
OMFSegmentHeader::GetSegmentType(void) const
|
|
||||||
{
|
{
|
||||||
assert(fReady);
|
assert(fReady);
|
||||||
|
|
||||||
@ -1252,8 +1229,7 @@ OMFSegmentHeader::GetSegmentType(void) const
|
|||||||
/*
|
/*
|
||||||
* Return the value of one of the segment header flags.
|
* Return the value of one of the segment header flags.
|
||||||
*/
|
*/
|
||||||
bool
|
bool OMFSegmentHeader::GetSegmentFlag(SegmentFlag flag) const
|
||||||
OMFSegmentHeader::GetSegmentFlag(SegmentFlag flag) const
|
|
||||||
{
|
{
|
||||||
if (fVersion < 2) {
|
if (fVersion < 2) {
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
@ -1291,12 +1267,10 @@ OMFSegmentHeader::GetSegmentFlag(SegmentFlag flag) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dump the contents of the segment header struct.
|
* Dump the contents of the segment header struct.
|
||||||
*/
|
*/
|
||||||
void
|
void OMFSegmentHeader::Dump(void) const
|
||||||
OMFSegmentHeader::Dump(void) const
|
|
||||||
{
|
{
|
||||||
LOGI("OMF segment header:");
|
LOGI("OMF segment header:");
|
||||||
LOGI(" segNum=%d loadName='%hs' segName='%hs'",
|
LOGI(" segNum=%d loadName='%hs' segName='%hs'",
|
||||||
|
@ -202,10 +202,10 @@ public:
|
|||||||
ReformatDisasm8(void) {}
|
ReformatDisasm8(void) {}
|
||||||
virtual ~ReformatDisasm8(void) {}
|
virtual ~ReformatDisasm8(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -434,10 +434,10 @@ public:
|
|||||||
ReformatDisasm16(void) {}
|
ReformatDisasm16(void) {}
|
||||||
virtual ~ReformatDisasm16(void) {}
|
virtual ~ReformatDisasm16(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OutputSection(const uint8_t* srcBuf, long srcLen,
|
void OutputSection(const uint8_t* srcBuf, long srcLen,
|
||||||
|
@ -598,8 +598,7 @@ const int kOpXCE_Implied = OPMODE(kOpXCE, kAddrImplied); // 0
|
|||||||
*
|
*
|
||||||
* Returns "true" on success, "false" on failure.
|
* Returns "true" on success, "false" on failure.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatDisasm65xxx::ValidateOpMap(void)
|
||||||
ReformatDisasm65xxx::ValidateOpMap(void)
|
|
||||||
{
|
{
|
||||||
if (NELEM(kOpMap) != 256) {
|
if (NELEM(kOpMap) != 256) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
@ -754,8 +753,7 @@ ReformatDisasm65xxx::ValidateOpMap(void)
|
|||||||
*
|
*
|
||||||
* Returns "true" on success, "false" on failure.
|
* Returns "true" on success, "false" on failure.
|
||||||
*/
|
*/
|
||||||
bool
|
bool ReformatDisasm65xxx::ValidateOpCodeDetails(void)
|
||||||
ReformatDisasm65xxx::ValidateOpCodeDetails(void)
|
|
||||||
{
|
{
|
||||||
if (NELEM(kOpCodeDetails) != kOpCodeMAX) {
|
if (NELEM(kOpCodeDetails) != kOpCodeMAX) {
|
||||||
LOGI("Found %d entries in details, max=%d",
|
LOGI("Found %d entries in details, max=%d",
|
||||||
|
@ -26,8 +26,7 @@
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDHR::Examine(ReformatHolder* pHolder)
|
||||||
ReformatDHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
long fileLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
||||||
@ -86,8 +85,7 @@ ReformatDHR::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert a Double-Hi-Res image to a bitmap.
|
* Convert a Double-Hi-Res image to a bitmap.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDHR::Process(const ReformatHolder* pHolder,
|
||||||
ReformatDHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -139,8 +137,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Initialize the 4-bit-window color lookup table.
|
* Initialize the 4-bit-window color lookup table.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDHR::InitColorLookup(void)
|
||||||
ReformatDHR::InitColorLookup(void)
|
|
||||||
{
|
{
|
||||||
for (int ii = 0; ii < 4; ii++) {
|
for (int ii = 0; ii < 4; ii++) {
|
||||||
for (int jj = 0; jj < kNumDHRColors; jj++) {
|
for (int jj = 0; jj < kNumDHRColors; jj++) {
|
||||||
@ -161,8 +158,7 @@ ReformatDHR::InitColorLookup(void)
|
|||||||
/*
|
/*
|
||||||
* Convert a buffer of double-hires data to a 16-color DIB.
|
* Convert a buffer of double-hires data to a 16-color DIB.
|
||||||
*/
|
*/
|
||||||
MyDIBitmap*
|
MyDIBitmap* ReformatDHR::DHRScreenToBitmap(const uint8_t* buf)
|
||||||
ReformatDHR::DHRScreenToBitmap(const uint8_t* buf)
|
|
||||||
{
|
{
|
||||||
MyDIBitmap* pDib = new MyDIBitmap;
|
MyDIBitmap* pDib = new MyDIBitmap;
|
||||||
uint8_t* outBuf;
|
uint8_t* outBuf;
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatDHR(void) {}
|
ReformatDHR(void) {}
|
||||||
virtual ~ReformatDHR(void) {}
|
virtual ~ReformatDHR(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kPixelsPerLine = 560,
|
kPixelsPerLine = 560,
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDG256SHR::Examine(ReformatHolder* pHolder)
|
||||||
ReformatDG256SHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -36,8 +35,7 @@ ReformatDG256SHR::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert a 256-color DreamGrafix Super Hi-Res Image.
|
* Convert a 256-color DreamGrafix Super Hi-Res Image.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDG256SHR::Process(const ReformatHolder* pHolder,
|
||||||
ReformatDG256SHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -66,8 +64,7 @@ ReformatDG256SHR::Process(const ReformatHolder* pHolder,
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatDG3200SHR::Examine(ReformatHolder* pHolder)
|
||||||
ReformatDG3200SHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -81,8 +78,7 @@ ReformatDG3200SHR::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert a 3200-color DreamGrafix Super Hi-Res Image.
|
* Convert a 3200-color DreamGrafix Super Hi-Res Image.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatDG3200SHR::Process(const ReformatHolder* pHolder,
|
||||||
ReformatDG3200SHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -102,8 +98,6 @@ ReformatDG3200SHR::Process(const ReformatHolder* pHolder,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ==========================================================================
|
* ==========================================================================
|
||||||
* ReformatDreamGrafix
|
* ReformatDreamGrafix
|
||||||
@ -114,8 +108,7 @@ ReformatDG3200SHR::Process(const ReformatHolder* pHolder,
|
|||||||
* Examine a DreamGrafix file. This figures out if its any of the
|
* Examine a DreamGrafix file. This figures out if its any of the
|
||||||
* DreamGrafix formats, i.e. 256-color, 3200-color, packed, or unpacked.
|
* DreamGrafix formats, i.e. 256-color, 3200-color, packed, or unpacked.
|
||||||
*/
|
*/
|
||||||
bool
|
bool DreamGrafix::ScanDreamGrafix(ReformatHolder* pHolder)
|
||||||
DreamGrafix::ScanDreamGrafix(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
long auxType = pHolder->GetAuxType();
|
long auxType = pHolder->GetAuxType();
|
||||||
@ -163,8 +156,7 @@ DreamGrafix::ScanDreamGrafix(ReformatHolder* pHolder)
|
|||||||
* Returns true on success, false if the uncompress step failed to produce
|
* Returns true on success, false if the uncompress step failed to produce
|
||||||
* exactly 32768+32*200 bytes.
|
* exactly 32768+32*200 bytes.
|
||||||
*/
|
*/
|
||||||
bool
|
bool DreamGrafix::UnpackDG(const uint8_t* srcBuf, long srcLen,
|
||||||
DreamGrafix::UnpackDG(const uint8_t* srcBuf, long srcLen,
|
|
||||||
ReformatSHR::SHRScreen* pScreen, uint8_t* extColorTable)
|
ReformatSHR::SHRScreen* pScreen, uint8_t* extColorTable)
|
||||||
{
|
{
|
||||||
int expectedLen;
|
int expectedLen;
|
||||||
@ -195,7 +187,7 @@ ReformatSHR::SHRScreen* pScreen, uint8_t* extColorTable)
|
|||||||
|
|
||||||
actual = UnpackLZW(srcBuf, srcLen, tmpBuf, expectedLen);
|
actual = UnpackLZW(srcBuf, srcLen, tmpBuf, expectedLen);
|
||||||
if (actual != expectedLen && actual != (expectedLen-512)) {
|
if (actual != expectedLen && actual != (expectedLen-512)) {
|
||||||
LOGI("UnpackLZW expected %d, got %d", expectedLen, actual);
|
LOGW("UnpackLZW expected %d, got %d", expectedLen, actual);
|
||||||
delete[] tmpBuf;
|
delete[] tmpBuf;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -266,8 +258,7 @@ static const unsigned int bitMasks[] = {
|
|||||||
bitOffset += nBitMod1; \
|
bitOffset += nBitMod1; \
|
||||||
};
|
};
|
||||||
|
|
||||||
/*static*/ int
|
/*static*/ int DreamGrafix::UnpackLZW(const uint8_t* srcBuf, long srcLen,
|
||||||
DreamGrafix::UnpackLZW(const uint8_t* srcBuf, long srcLen,
|
|
||||||
uint8_t* dstBuf, long dstLen)
|
uint8_t* dstBuf, long dstLen)
|
||||||
{
|
{
|
||||||
uint16_t finChar, oldCode, inCode, freeCode, maxCode, k;
|
uint16_t finChar, oldCode, inCode, freeCode, maxCode, k;
|
||||||
|
@ -174,8 +174,7 @@ The Apple values seem to be good.
|
|||||||
* $4001 is a compressed DHR image. In practice, nobody uses these, so
|
* $4001 is a compressed DHR image. In practice, nobody uses these, so
|
||||||
* any FOT file with a correct-looking length is treated as hi-res.
|
* any FOT file with a correct-looking length is treated as hi-res.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatHiRes::Examine(ReformatHolder* pHolder)
|
||||||
ReformatHiRes::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
long fileLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
||||||
@ -222,8 +221,7 @@ ReformatHiRes::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert a Hi-Res image to a bitmap.
|
* Convert a Hi-Res image to a bitmap.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatHiRes::Process(const ReformatHolder* pHolder,
|
||||||
ReformatHiRes::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -259,8 +257,7 @@ bail:
|
|||||||
*
|
*
|
||||||
* Table must be able to hold kNumLines values.
|
* Table must be able to hold kNumLines values.
|
||||||
*/
|
*/
|
||||||
/*static*/ void
|
/*static*/ void ReformatHiRes::InitLineOffset(int* pOffsetBuf)
|
||||||
ReformatHiRes::InitLineOffset(int* pOffsetBuf)
|
|
||||||
{
|
{
|
||||||
long offset;
|
long offset;
|
||||||
int line;
|
int line;
|
||||||
@ -275,12 +272,10 @@ ReformatHiRes::InitLineOffset(int* pOffsetBuf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a buffer of hires data to a 16-color DIB.
|
* Convert a buffer of hires data to a 16-color DIB.
|
||||||
*/
|
*/
|
||||||
MyDIBitmap*
|
MyDIBitmap* ReformatHiRes::HiResScreenToBitmap(const uint8_t* buf)
|
||||||
ReformatHiRes::HiResScreenToBitmap(const uint8_t* buf)
|
|
||||||
{
|
{
|
||||||
MyDIBitmap* pDib = new MyDIBitmap;
|
MyDIBitmap* pDib = new MyDIBitmap;
|
||||||
uint8_t* outBuf;
|
uint8_t* outBuf;
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatHiRes(void) { fBlackWhite = false; }
|
ReformatHiRes(void) { fBlackWhite = false; }
|
||||||
virtual ~ReformatHiRes(void) {}
|
virtual ~ReformatHiRes(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kPixelsPerLine = 280,
|
kPixelsPerLine = 280,
|
||||||
|
@ -39,8 +39,7 @@
|
|||||||
* If the file ends in ".mac", we accept it if it has a MacBinary header or
|
* If the file ends in ".mac", we accept it if it has a MacBinary header or
|
||||||
* if it begins with 00000002 and exceeds the minimum size required.
|
* if it begins with 00000002 and exceeds the minimum size required.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatMacPaint::Examine(ReformatHolder* pHolder)
|
||||||
ReformatMacPaint::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
||||||
@ -78,8 +77,7 @@ done:
|
|||||||
/*
|
/*
|
||||||
* Convert the image to a monochrome bitmap.
|
* Convert the image to a monochrome bitmap.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatMacPaint::Process(const ReformatHolder* pHolder,
|
||||||
ReformatMacPaint::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -110,8 +108,7 @@ bail:
|
|||||||
* 576 pixels per line == 72 bytes per line, which is a multiple of 4 bytes
|
* 576 pixels per line == 72 bytes per line, which is a multiple of 4 bytes
|
||||||
* (required for windows BMP).
|
* (required for windows BMP).
|
||||||
*/
|
*/
|
||||||
MyDIBitmap*
|
MyDIBitmap* ReformatMacPaint::ConvertMacPaint(const uint8_t* srcBuf, long length)
|
||||||
ReformatMacPaint::ConvertMacPaint(const uint8_t* srcBuf, long length)
|
|
||||||
{
|
{
|
||||||
MyDIBitmap* pDib = NULL;
|
MyDIBitmap* pDib = NULL;
|
||||||
uint8_t* outBuf;
|
uint8_t* outBuf;
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatMacPaint(void) {}
|
ReformatMacPaint(void) {}
|
||||||
virtual ~ReformatMacPaint(void) {}
|
virtual ~ReformatMacPaint(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MyDIBitmap* ConvertMacPaint(const uint8_t* srcBuf, long length);
|
MyDIBitmap* ConvertMacPaint(const uint8_t* srcBuf, long length);
|
||||||
|
@ -50,8 +50,7 @@
|
|||||||
/*
|
/*
|
||||||
* Load the NiftyList data file.
|
* Load the NiftyList data file.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool NiftyList::AppInit(const WCHAR* fileName)
|
||||||
NiftyList::AppInit(const WCHAR* fileName)
|
|
||||||
{
|
{
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
long fileLen;
|
long fileLen;
|
||||||
@ -124,8 +123,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Discard all allocated storage.
|
* Discard all allocated storage.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool NiftyList::AppCleanup(void)
|
||||||
NiftyList::AppCleanup(void)
|
|
||||||
{
|
{
|
||||||
delete[] fP8MLI.pEntries;
|
delete[] fP8MLI.pEntries;
|
||||||
delete[] fGSOS.pEntries;
|
delete[] fGSOS.pEntries;
|
||||||
@ -148,9 +146,8 @@ NiftyList::AppCleanup(void)
|
|||||||
* Leaves "*ppData" pointing at the start of the next section. "*pRemLen"
|
* Leaves "*ppData" pointing at the start of the next section. "*pRemLen"
|
||||||
* is updated appropriately.
|
* is updated appropriately.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool NiftyList::ReadSection(char** ppData, long* pRemLen,
|
||||||
NiftyList::ReadSection(char** ppData, long* pRemLen, DataSet* pSet,
|
DataSet* pSet, LoadMode mode)
|
||||||
LoadMode mode)
|
|
||||||
{
|
{
|
||||||
assert(ppData != NULL);
|
assert(ppData != NULL);
|
||||||
assert(pRemLen != NULL);
|
assert(pRemLen != NULL);
|
||||||
@ -265,8 +262,7 @@ NiftyList::ReadSection(char** ppData, long* pRemLen, DataSet* pSet,
|
|||||||
* Returns 0 if there's no data, which can only happen if "remLen" is zero
|
* Returns 0 if there's no data, which can only happen if "remLen" is zero
|
||||||
* (i.e. we hit EOF).
|
* (i.e. we hit EOF).
|
||||||
*/
|
*/
|
||||||
/*static*/ int
|
/*static*/ int NiftyList::ScanLine(const char* pData, long remLen)
|
||||||
NiftyList::ScanLine(const char* pData, long remLen)
|
|
||||||
{
|
{
|
||||||
bool atEOL = false;
|
bool atEOL = false;
|
||||||
int lineLen = 0;
|
int lineLen = 0;
|
||||||
@ -286,8 +282,7 @@ NiftyList::ScanLine(const char* pData, long remLen)
|
|||||||
/*
|
/*
|
||||||
* qsort() sort function.
|
* qsort() sort function.
|
||||||
*/
|
*/
|
||||||
/*static*/ int
|
/*static*/ int NiftyList::SortNameValue(const void* v1, const void* v2)
|
||||||
NiftyList::SortNameValue(const void* v1, const void* v2)
|
|
||||||
{
|
{
|
||||||
const NameValue* pnv1 = (const NameValue*) v1;
|
const NameValue* pnv1 = (const NameValue*) v1;
|
||||||
const NameValue* pnv2 = (const NameValue*) v2;
|
const NameValue* pnv2 = (const NameValue*) v2;
|
||||||
@ -305,8 +300,7 @@ NiftyList::SortNameValue(const void* v1, const void* v2)
|
|||||||
/*
|
/*
|
||||||
* Hex digit converter.
|
* Hex digit converter.
|
||||||
*/
|
*/
|
||||||
static inline int
|
static inline int HexValue(char ch)
|
||||||
HexValue(char ch)
|
|
||||||
{
|
{
|
||||||
if (ch >= '0' && ch <= '9')
|
if (ch >= '0' && ch <= '9')
|
||||||
return ch - '0';
|
return ch - '0';
|
||||||
@ -321,8 +315,7 @@ HexValue(char ch)
|
|||||||
/*
|
/*
|
||||||
* Convert a 4-char hexadecimal value to an unsigned 16-bit value.
|
* Convert a 4-char hexadecimal value to an unsigned 16-bit value.
|
||||||
*/
|
*/
|
||||||
/*static*/ uint16_t
|
/*static*/ uint16_t NiftyList::ConvHexFour(const char* data)
|
||||||
NiftyList::ConvHexFour(const char* data)
|
|
||||||
{
|
{
|
||||||
return HexValue(data[0]) << 12 |
|
return HexValue(data[0]) << 12 |
|
||||||
HexValue(data[1]) << 8 |
|
HexValue(data[1]) << 8 |
|
||||||
@ -333,8 +326,7 @@ NiftyList::ConvHexFour(const char* data)
|
|||||||
/*
|
/*
|
||||||
* Dump the contents of a section.
|
* Dump the contents of a section.
|
||||||
*/
|
*/
|
||||||
/*static*/ void
|
/*static*/ void NiftyList::DumpSection(const DataSet& dataSet)
|
||||||
NiftyList::DumpSection(const DataSet& dataSet)
|
|
||||||
{
|
{
|
||||||
long ent;
|
long ent;
|
||||||
|
|
||||||
@ -346,15 +338,13 @@ NiftyList::DumpSection(const DataSet& dataSet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look up a value in the specified table. Returns the name, or NULL if
|
* Look up a value in the specified table. Returns the name, or NULL if
|
||||||
* not found.
|
* not found.
|
||||||
*
|
*
|
||||||
* This uses a binary search, so the entries must be in sorted order.
|
* This uses a binary search, so the entries must be in sorted order.
|
||||||
*/
|
*/
|
||||||
/*static*/ const char*
|
/*static*/ const char* NiftyList::Lookup(const DataSet& dataSet, uint16_t key)
|
||||||
NiftyList::Lookup(const DataSet& dataSet, uint16_t key)
|
|
||||||
{
|
{
|
||||||
if (!fDataReady) {
|
if (!fDataReady) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
* See the file LICENSE for distribution terms.
|
* See the file LICENSE for distribution terms.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Process UCSD Pascal text and code files.
|
* Process UCSD Pascal text and code files. Files with this format, but
|
||||||
|
* usually containing 6502 assembly rather than p-code, can appear on
|
||||||
|
* Apple /// SOS disks.
|
||||||
*/
|
*/
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
#include "PascalFiles.h"
|
#include "PascalFiles.h"
|
||||||
@ -18,8 +20,7 @@
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatPascalCode::Examine(ReformatHolder* pHolder)
|
||||||
ReformatPascalCode::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -40,8 +41,7 @@ ReformatPascalCode::Examine(ReformatHolder* pHolder)
|
|||||||
* Rather than dump the header and follow it with bits and pieces, we gather
|
* Rather than dump the header and follow it with bits and pieces, we gather
|
||||||
* up all the header data and present it with the contents of the block.
|
* up all the header data and present it with the contents of the block.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatPascalCode::Process(const ReformatHolder* pHolder,
|
||||||
ReformatPascalCode::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -141,8 +141,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Print information about and the contents of one segment.
|
* Print information about and the contents of one segment.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatPascalCode::PrintSegment(PCDSegment* pSegment, int segNum,
|
||||||
ReformatPascalCode::PrintSegment(PCDSegment* pSegment, int segNum,
|
|
||||||
const uint8_t* srcBuf, long srcLen)
|
const uint8_t* srcBuf, long srcLen)
|
||||||
{
|
{
|
||||||
const char* segKindStr;
|
const char* segKindStr;
|
||||||
@ -210,8 +209,7 @@ ReformatPascalCode::PrintSegment(PCDSegment* pSegment, int segNum,
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatPascalText::Examine(ReformatHolder* pHolder)
|
||||||
ReformatPascalText::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -231,8 +229,7 @@ ReformatPascalText::Examine(ReformatHolder* pHolder)
|
|||||||
* that the next value is 32+indent. Lines end with a CR. If the next line
|
* that the next value is 32+indent. Lines end with a CR. If the next line
|
||||||
* won't fit in the block, the remainder of the block is filled with zeroes.
|
* won't fit in the block, the remainder of the block is filled with zeroes.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatPascalText::Process(const ReformatHolder* pHolder,
|
||||||
ReformatPascalText::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -277,8 +274,7 @@ bail:
|
|||||||
* I'm not sure if the format mandates full 1024-byte blocks -- it
|
* I'm not sure if the format mandates full 1024-byte blocks -- it
|
||||||
* appears to -- but I'm not going to assume it.
|
* appears to -- but I'm not going to assume it.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatPascalText::ProcessBlock(const uint8_t* srcBuf, long length)
|
||||||
ReformatPascalText::ProcessBlock(const uint8_t* srcBuf, long length)
|
|
||||||
{
|
{
|
||||||
ASSERT(srcBuf != NULL);
|
ASSERT(srcBuf != NULL);
|
||||||
ASSERT(length > 0 && length <= kPTXBlockSize);
|
ASSERT(length > 0 && length <= kPTXBlockSize);
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatPascalCode(void) {}
|
ReformatPascalCode(void) {}
|
||||||
virtual ~ReformatPascalCode(void) {}
|
virtual ~ReformatPascalCode(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// VC++6.0 demands this be public, probably because it's used to
|
// VC++6.0 demands this be public, probably because it's used to
|
||||||
@ -84,10 +84,10 @@ public:
|
|||||||
ReformatPascalText(void) {}
|
ReformatPascalText(void) {}
|
||||||
virtual ~ReformatPascalText(void) {}
|
virtual ~ReformatPascalText(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatPrintShop::Examine(ReformatHolder* pHolder)
|
||||||
ReformatPrintShop::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -58,8 +57,7 @@ ReformatPrintShop::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert Print Shop clip art into a DIB.
|
* Convert Print Shop clip art into a DIB.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatPrintShop::Process(const ReformatHolder* pHolder,
|
||||||
ReformatPrintShop::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -94,8 +92,7 @@ ReformatPrintShop::Process(const ReformatHolder* pHolder,
|
|||||||
* The file is a linear 1-bit 88x52 image, with four extra bytes of data
|
* The file is a linear 1-bit 88x52 image, with four extra bytes of data
|
||||||
* at the end.
|
* at the end.
|
||||||
*/
|
*/
|
||||||
MyDIBitmap*
|
MyDIBitmap* ReformatPrintShop::ConvertBW(const uint8_t* srcBuf)
|
||||||
ReformatPrintShop::ConvertBW(const uint8_t* srcBuf)
|
|
||||||
{
|
{
|
||||||
MyDIBitmap* pDib = new MyDIBitmap;
|
MyDIBitmap* pDib = new MyDIBitmap;
|
||||||
uint8_t* outBuf;
|
uint8_t* outBuf;
|
||||||
@ -145,8 +142,7 @@ bail:
|
|||||||
* is actually 100% blue and "magenta" is 100% red. The values in the color
|
* is actually 100% blue and "magenta" is 100% red. The values in the color
|
||||||
* table below come from a screen capture of KEGS.
|
* table below come from a screen capture of KEGS.
|
||||||
*/
|
*/
|
||||||
MyDIBitmap*
|
MyDIBitmap* ReformatPrintShop::ConvertColor(const uint8_t* srcBuf)
|
||||||
ReformatPrintShop::ConvertColor(const uint8_t* srcBuf)
|
|
||||||
{
|
{
|
||||||
MyDIBitmap* pDib = new MyDIBitmap;
|
MyDIBitmap* pDib = new MyDIBitmap;
|
||||||
uint8_t* outBuf;
|
uint8_t* outBuf;
|
||||||
|
@ -20,10 +20,10 @@ public:
|
|||||||
ReformatPrintShop(void) {}
|
ReformatPrintShop(void) {}
|
||||||
virtual ~ReformatPrintShop(void) {}
|
virtual ~ReformatPrintShop(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum { kWidth=88, kHeight=52 };
|
enum { kWidth=88, kHeight=52 };
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
/*
|
/*
|
||||||
* Create an instance of the class identified by "id".
|
* Create an instance of the class identified by "id".
|
||||||
*/
|
*/
|
||||||
/*static*/ Reformat*
|
/*static*/ Reformat* ReformatHolder::GetReformatInstance(ReformatID id)
|
||||||
ReformatHolder::GetReformatInstance(ReformatID id)
|
|
||||||
{
|
{
|
||||||
Reformat* pReformat = NULL;
|
Reformat* pReformat = NULL;
|
||||||
|
|
||||||
@ -102,8 +101,7 @@ ReformatHolder::GetReformatInstance(ReformatID id)
|
|||||||
* Would have been nice to embed these in the individual classes, but that's
|
* Would have been nice to embed these in the individual classes, but that's
|
||||||
* harder to maintain.
|
* harder to maintain.
|
||||||
*/
|
*/
|
||||||
/*static*/ const WCHAR*
|
/*static*/ const WCHAR* ReformatHolder::GetReformatName(ReformatID id)
|
||||||
ReformatHolder::GetReformatName(ReformatID id)
|
|
||||||
{
|
{
|
||||||
const WCHAR* descr = NULL;
|
const WCHAR* descr = NULL;
|
||||||
|
|
||||||
@ -266,13 +264,11 @@ ReformatHolder::GetReformatName(ReformatID id)
|
|||||||
return descr;
|
return descr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the file attributes. These are used by TestApplicability tests to
|
* Set the file attributes. These are used by TestApplicability tests to
|
||||||
* decide what it is we're looking at.
|
* decide what it is we're looking at.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatHolder::SetSourceAttributes(long fileType, long auxType,
|
||||||
ReformatHolder::SetSourceAttributes(long fileType, long auxType,
|
|
||||||
SourceFormat sourceFormat, const char* nameExt)
|
SourceFormat sourceFormat, const char* nameExt)
|
||||||
{
|
{
|
||||||
fFileType = fileType;
|
fFileType = fileType;
|
||||||
@ -300,8 +296,7 @@ ReformatHolder::SetSourceAttributes(long fileType, long auxType,
|
|||||||
* Before calling here, the file data and file attributes (e.g. file type)
|
* Before calling here, the file data and file attributes (e.g. file type)
|
||||||
* should be stored in "ReformatHolder".
|
* should be stored in "ReformatHolder".
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatHolder::TestApplicability(void)
|
||||||
ReformatHolder::TestApplicability(void)
|
|
||||||
{
|
{
|
||||||
Reformat* pReformat;
|
Reformat* pReformat;
|
||||||
int i;
|
int i;
|
||||||
@ -344,8 +339,8 @@ ReformatHolder::TestApplicability(void)
|
|||||||
/*
|
/*
|
||||||
* Return the appropriate applicability level.
|
* Return the appropriate applicability level.
|
||||||
*/
|
*/
|
||||||
ReformatHolder::ReformatApplies
|
ReformatHolder::ReformatApplies ReformatHolder::GetApplic(ReformatPart part,
|
||||||
ReformatHolder::GetApplic(ReformatPart part, ReformatID id) const
|
ReformatID id) const
|
||||||
{
|
{
|
||||||
if (id < kReformatUnknown || id >= kReformatMAX) {
|
if (id < kReformatUnknown || id >= kReformatMAX) {
|
||||||
assert(false);
|
assert(false);
|
||||||
@ -362,8 +357,7 @@ ReformatHolder::GetApplic(ReformatPart part, ReformatID id) const
|
|||||||
/*
|
/*
|
||||||
* Set the appropriate applicability level.
|
* Set the appropriate applicability level.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatHolder::SetApplic(ReformatID id, ReformatApplies applyData,
|
||||||
ReformatHolder::SetApplic(ReformatID id, ReformatApplies applyData,
|
|
||||||
ReformatApplies applyRsrc, ReformatApplies applyCmmt)
|
ReformatApplies applyRsrc, ReformatApplies applyCmmt)
|
||||||
{
|
{
|
||||||
if (id <= kReformatUnknown || id >= kReformatMAX) {
|
if (id <= kReformatUnknown || id >= kReformatMAX) {
|
||||||
@ -385,8 +379,7 @@ ReformatHolder::SetApplic(ReformatID id, ReformatApplies applyData,
|
|||||||
* a BASIC program or choosing a double-hi-res algorithm. The preference
|
* a BASIC program or choosing a double-hi-res algorithm. The preference
|
||||||
* indicates the default choice, but does not exclude others.
|
* indicates the default choice, but does not exclude others.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatHolder::SetApplicPreferred(ReformatID id, ReformatPart part)
|
||||||
ReformatHolder::SetApplicPreferred(ReformatID id, ReformatPart part)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < kPartMAX; i++) {
|
for (int i = 0; i < kPartMAX; i++) {
|
||||||
if (i == kPartUnknown)
|
if (i == kPartUnknown)
|
||||||
@ -403,13 +396,11 @@ ReformatHolder::SetApplicPreferred(ReformatID id, ReformatPart part)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns <0, 0, or >0 depending on whether app1 is worse, equal to,
|
* Returns <0, 0, or >0 depending on whether app1 is worse, equal to,
|
||||||
* or better than app2.
|
* or better than app2.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatHolder::CompareApplies(ReformatApplies app1, ReformatApplies app2)
|
||||||
ReformatHolder::CompareApplies(ReformatApplies app1, ReformatApplies app2)
|
|
||||||
{
|
{
|
||||||
if ((app1 & kApplicPrefMask) < (app2 & kApplicPrefMask))
|
if ((app1 & kApplicPrefMask) < (app2 & kApplicPrefMask))
|
||||||
return -1;
|
return -1;
|
||||||
@ -421,8 +412,7 @@ ReformatHolder::CompareApplies(ReformatApplies app1, ReformatApplies app2)
|
|||||||
/*
|
/*
|
||||||
* Find the best reformatter for the specified part of the loaded file.
|
* Find the best reformatter for the specified part of the loaded file.
|
||||||
*/
|
*/
|
||||||
ReformatHolder::ReformatID
|
ReformatHolder::ReformatID ReformatHolder::FindBest(ReformatPart part)
|
||||||
ReformatHolder::FindBest(ReformatPart part)
|
|
||||||
{
|
{
|
||||||
ReformatID bestID = kReformatUnknown;
|
ReformatID bestID = kReformatUnknown;
|
||||||
ReformatApplies bestApply = kApplicNot;
|
ReformatApplies bestApply = kApplicNot;
|
||||||
@ -446,7 +436,7 @@ ReformatHolder::FindBest(ReformatPart part)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bestID == kReformatUnknown || bestApply == kApplicNot) {
|
if (bestID == kReformatUnknown || bestApply == kApplicNot) {
|
||||||
LOGI("Did you forget to call TestApplicability?");
|
LOGW("Did you forget to call TestApplicability?");
|
||||||
assert(false);
|
assert(false);
|
||||||
return kReformatRaw;
|
return kReformatRaw;
|
||||||
}
|
}
|
||||||
@ -459,8 +449,7 @@ ReformatHolder::FindBest(ReformatPart part)
|
|||||||
/*
|
/*
|
||||||
* Apply the requested formatter to the specified part.
|
* Apply the requested formatter to the specified part.
|
||||||
*/
|
*/
|
||||||
ReformatOutput*
|
ReformatOutput* ReformatHolder::Apply(ReformatPart part, ReformatID id)
|
||||||
ReformatHolder::Apply(ReformatPart part, ReformatID id)
|
|
||||||
{
|
{
|
||||||
ReformatOutput* pOutput;
|
ReformatOutput* pOutput;
|
||||||
Reformat* pReformat;
|
Reformat* pReformat;
|
||||||
@ -469,7 +458,7 @@ ReformatHolder::Apply(ReformatPart part, ReformatID id)
|
|||||||
if (id <= kReformatUnknown || id >= kReformatMAX ||
|
if (id <= kReformatUnknown || id >= kReformatMAX ||
|
||||||
part <= kPartUnknown || part >= kPartMAX)
|
part <= kPartUnknown || part >= kPartMAX)
|
||||||
{
|
{
|
||||||
LOGI("Invalid reformat request (part=%d id=%d)", part, id);
|
LOGW("Invalid reformat request (part=%d id=%d)", part, id);
|
||||||
assert(false);
|
assert(false);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -524,12 +513,10 @@ ReformatHolder::Apply(ReformatPart part, ReformatID id)
|
|||||||
return pOutput;
|
return pOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the appropriate input buffer.
|
* Get the appropriate input buffer.
|
||||||
*/
|
*/
|
||||||
const uint8_t*
|
const uint8_t* ReformatHolder::GetSourceBuf(ReformatPart part) const
|
||||||
ReformatHolder::GetSourceBuf(ReformatPart part) const
|
|
||||||
{
|
{
|
||||||
if (part <= kPartUnknown || part >= kPartMAX) {
|
if (part <= kPartUnknown || part >= kPartMAX) {
|
||||||
assert(false);
|
assert(false);
|
||||||
@ -542,8 +529,7 @@ ReformatHolder::GetSourceBuf(ReformatPart part) const
|
|||||||
/*
|
/*
|
||||||
* Get the length of the appropriate input buffer.
|
* Get the length of the appropriate input buffer.
|
||||||
*/
|
*/
|
||||||
long
|
long ReformatHolder::GetSourceLen(ReformatPart part) const
|
||||||
ReformatHolder::GetSourceLen(ReformatPart part) const
|
|
||||||
{
|
{
|
||||||
if (part <= kPartUnknown || part >= kPartMAX) {
|
if (part <= kPartUnknown || part >= kPartMAX) {
|
||||||
assert(false);
|
assert(false);
|
||||||
@ -562,9 +548,7 @@ ReformatHolder::GetSourceLen(ReformatPart part) const
|
|||||||
* The ReformatHolder "owns" the buffer afterward, so the caller should
|
* The ReformatHolder "owns" the buffer afterward, so the caller should
|
||||||
* discard its pointer.
|
* discard its pointer.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatHolder::SetSourceBuf(ReformatPart part, uint8_t* buf, long len)
|
||||||
ReformatHolder::SetSourceBuf(ReformatPart part, uint8_t* buf,
|
|
||||||
long len)
|
|
||||||
{
|
{
|
||||||
if (part <= kPartUnknown || part >= kPartMAX) {
|
if (part <= kPartUnknown || part >= kPartMAX) {
|
||||||
assert(false);
|
assert(false);
|
||||||
@ -577,13 +561,11 @@ ReformatHolder::SetSourceBuf(ReformatPart part, uint8_t* buf,
|
|||||||
fSourceLen[part] = len;
|
fSourceLen[part] = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Specify an error message to return instead of reformatted text for a
|
* Specify an error message to return instead of reformatted text for a
|
||||||
* given part.
|
* given part.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatHolder::SetErrorMsg(ReformatPart part, const char* msg)
|
||||||
ReformatHolder::SetErrorMsg(ReformatPart part, const char* msg)
|
|
||||||
{
|
{
|
||||||
assert(msg != NULL && *msg != '\0');
|
assert(msg != NULL && *msg != '\0');
|
||||||
assert(part > kPartUnknown && part < kPartMAX);
|
assert(part > kPartUnknown && part < kPartMAX);
|
||||||
@ -593,8 +575,7 @@ ReformatHolder::SetErrorMsg(ReformatPart part, const char* msg)
|
|||||||
LOGI("+++ set error message for part %d to '%hs'", part, msg);
|
LOGI("+++ set error message for part %d to '%hs'", part, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ReformatHolder::SetErrorMsg(ReformatPart part, const CString& str)
|
||||||
ReformatHolder::SetErrorMsg(ReformatPart part, const CString& str)
|
|
||||||
{
|
{
|
||||||
CStringA stra(str);
|
CStringA stra(str);
|
||||||
SetErrorMsg(part, (LPCSTR) stra);
|
SetErrorMsg(part, (LPCSTR) stra);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define REFORMAT_REFORMAT_H
|
#define REFORMAT_REFORMAT_H
|
||||||
|
|
||||||
#include "../util/UtilLib.h"
|
#include "../util/UtilLib.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
class Reformat;
|
class Reformat;
|
||||||
class ReformatOutput;
|
class ReformatOutput;
|
||||||
|
@ -166,8 +166,7 @@ const int kUnk = 0x3f; // for unmappable chars, use '?'
|
|||||||
* if we want to have a reversible transformation someday, it'll make our
|
* if we want to have a reversible transformation someday, it'll make our
|
||||||
* lives easier then.
|
* lives easier then.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::CheckGSCharConv(void)
|
||||||
ReformatText::CheckGSCharConv(void)
|
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
bool test[256];
|
bool test[256];
|
||||||
@ -185,14 +184,12 @@ ReformatText::CheckGSCharConv(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the output format and buffer.
|
* Set the output format and buffer.
|
||||||
*
|
*
|
||||||
* Clears our work buffer pointer so we don't free it.
|
* Clears our work buffer pointer so we don't free it.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::SetResultBuffer(ReformatOutput* pOutput, bool multiFont)
|
||||||
ReformatText::SetResultBuffer(ReformatOutput* pOutput, bool multiFont)
|
|
||||||
{
|
{
|
||||||
char* buf;
|
char* buf;
|
||||||
long len;
|
long len;
|
||||||
@ -225,7 +222,6 @@ ReformatText::SetResultBuffer(ReformatOutput* pOutput, bool multiFont)
|
|||||||
pOutput->SetMultipleFontsFlag(true);
|
pOutput->SetMultipleFontsFlag(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output the RTF header.
|
* Output the RTF header.
|
||||||
*
|
*
|
||||||
@ -235,8 +231,7 @@ ReformatText::SetResultBuffer(ReformatOutput* pOutput, bool multiFont)
|
|||||||
*
|
*
|
||||||
* The default font is Courier New (\f0) at 10 points (\fs20).
|
* The default font is Courier New (\f0) at 10 points (\fs20).
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFBegin(int flags)
|
||||||
ReformatText::RTFBegin(int flags)
|
|
||||||
{
|
{
|
||||||
// static const char* rtfHdr =
|
// static const char* rtfHdr =
|
||||||
//"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0 Courier New;}}\r\n"
|
//"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0 Courier New;}}\r\n"
|
||||||
@ -274,15 +269,16 @@ ReformatText::RTFBegin(int flags)
|
|||||||
/*
|
/*
|
||||||
* Output the RTF footer.
|
* Output the RTF footer.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFEnd(void)
|
||||||
ReformatText::RTFEnd(void) { if (fUseRTF) BufPrintf("}\r\n%c", '\0'); }
|
{
|
||||||
|
if (fUseRTF) BufPrintf("}\r\n%c", '\0');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output RTF paragraph definition marker. Do this every time we change some
|
* Output RTF paragraph definition marker. Do this every time we change some
|
||||||
* aspect of paragraph formatting, such as margins or justification.
|
* aspect of paragraph formatting, such as margins or justification.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFSetPara(void)
|
||||||
ReformatText::RTFSetPara(void)
|
|
||||||
{
|
{
|
||||||
if (!fUseRTF)
|
if (!fUseRTF)
|
||||||
return;
|
return;
|
||||||
@ -320,8 +316,7 @@ ReformatText::RTFSetPara(void)
|
|||||||
* If you're producing RTF output, this is the right way to output an
|
* If you're producing RTF output, this is the right way to output an
|
||||||
* end-of-line character.
|
* end-of-line character.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFNewPara(void)
|
||||||
ReformatText::RTFNewPara(void)
|
|
||||||
{
|
{
|
||||||
if (fUseRTF)
|
if (fUseRTF)
|
||||||
BufPrintf("\\par\r\n");
|
BufPrintf("\\par\r\n");
|
||||||
@ -335,8 +330,7 @@ ReformatText::RTFNewPara(void)
|
|||||||
* so it won't appear in CiderPress or WordPad, but it will come out in
|
* so it won't appear in CiderPress or WordPad, but it will come out in
|
||||||
* Microsoft Word if you extract to a file.
|
* Microsoft Word if you extract to a file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFPageBreak(void)
|
||||||
ReformatText::RTFPageBreak(void)
|
|
||||||
{
|
{
|
||||||
if (fUseRTF)
|
if (fUseRTF)
|
||||||
BufPrintf("\\page ");
|
BufPrintf("\\page ");
|
||||||
@ -345,8 +339,7 @@ ReformatText::RTFPageBreak(void)
|
|||||||
/*
|
/*
|
||||||
* RTF tab character.
|
* RTF tab character.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFTab(void)
|
||||||
ReformatText::RTFTab(void)
|
|
||||||
{
|
{
|
||||||
if (fUseRTF)
|
if (fUseRTF)
|
||||||
BufPrintf("\\tab ");
|
BufPrintf("\\tab ");
|
||||||
@ -355,8 +348,7 @@ ReformatText::RTFTab(void)
|
|||||||
/*
|
/*
|
||||||
* Minor formatting.
|
* Minor formatting.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFBoldOn(void)
|
||||||
ReformatText::RTFBoldOn(void)
|
|
||||||
{
|
{
|
||||||
if (fBoldEnabled)
|
if (fBoldEnabled)
|
||||||
return;
|
return;
|
||||||
@ -365,8 +357,8 @@ ReformatText::RTFBoldOn(void)
|
|||||||
fBoldEnabled = true;
|
fBoldEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFBoldOff(void)
|
void ReformatText::RTFBoldOff(void)
|
||||||
{
|
{
|
||||||
if (!fBoldEnabled)
|
if (!fBoldEnabled)
|
||||||
return;
|
return;
|
||||||
@ -375,8 +367,8 @@ ReformatText::RTFBoldOff(void)
|
|||||||
fBoldEnabled = false;
|
fBoldEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFItalicOn(void)
|
void ReformatText::RTFItalicOn(void)
|
||||||
{
|
{
|
||||||
if (fItalicEnabled)
|
if (fItalicEnabled)
|
||||||
return;
|
return;
|
||||||
@ -385,8 +377,8 @@ ReformatText::RTFItalicOn(void)
|
|||||||
fItalicEnabled = true;
|
fItalicEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFItalicOff(void)
|
void ReformatText::RTFItalicOff(void)
|
||||||
{
|
{
|
||||||
if (!fItalicEnabled)
|
if (!fItalicEnabled)
|
||||||
return;
|
return;
|
||||||
@ -395,8 +387,8 @@ ReformatText::RTFItalicOff(void)
|
|||||||
fItalicEnabled = false;
|
fItalicEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFUnderlineOn(void)
|
void ReformatText::RTFUnderlineOn(void)
|
||||||
{
|
{
|
||||||
if (fUnderlineEnabled)
|
if (fUnderlineEnabled)
|
||||||
return;
|
return;
|
||||||
@ -405,8 +397,8 @@ ReformatText::RTFUnderlineOn(void)
|
|||||||
fUnderlineEnabled = true;
|
fUnderlineEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFUnderlineOff(void)
|
void ReformatText::RTFUnderlineOff(void)
|
||||||
{
|
{
|
||||||
if (!fUnderlineEnabled)
|
if (!fUnderlineEnabled)
|
||||||
return;
|
return;
|
||||||
@ -415,8 +407,8 @@ ReformatText::RTFUnderlineOff(void)
|
|||||||
fUnderlineEnabled = false;
|
fUnderlineEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFSubscriptOn(void)
|
void ReformatText::RTFSubscriptOn(void)
|
||||||
{
|
{
|
||||||
if (fSubscriptEnabled)
|
if (fSubscriptEnabled)
|
||||||
return;
|
return;
|
||||||
@ -425,8 +417,8 @@ ReformatText::RTFSubscriptOn(void)
|
|||||||
fSubscriptEnabled = true;
|
fSubscriptEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFSubscriptOff(void)
|
void ReformatText::RTFSubscriptOff(void)
|
||||||
{
|
{
|
||||||
if (!fSubscriptEnabled)
|
if (!fSubscriptEnabled)
|
||||||
return;
|
return;
|
||||||
@ -435,8 +427,8 @@ ReformatText::RTFSubscriptOff(void)
|
|||||||
fSubscriptEnabled = false;
|
fSubscriptEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFSuperscriptOn(void)
|
void ReformatText::RTFSuperscriptOn(void)
|
||||||
{
|
{
|
||||||
if (fSuperscriptEnabled)
|
if (fSuperscriptEnabled)
|
||||||
return;
|
return;
|
||||||
@ -445,8 +437,8 @@ ReformatText::RTFSuperscriptOn(void)
|
|||||||
fSuperscriptEnabled = true;
|
fSuperscriptEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFSuperscriptOff(void)
|
void ReformatText::RTFSuperscriptOff(void)
|
||||||
{
|
{
|
||||||
if (!fSuperscriptEnabled)
|
if (!fSuperscriptEnabled)
|
||||||
return;
|
return;
|
||||||
@ -455,8 +447,8 @@ ReformatText::RTFSuperscriptOff(void)
|
|||||||
fSuperscriptEnabled = false;
|
fSuperscriptEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFSetColor(TextColor color)
|
void ReformatText::RTFSetColor(TextColor color)
|
||||||
{
|
{
|
||||||
if (color == fTextColor)
|
if (color == fTextColor)
|
||||||
return;
|
return;
|
||||||
@ -469,32 +461,31 @@ ReformatText::RTFSetColor(TextColor color)
|
|||||||
/*
|
/*
|
||||||
* Change paragraph formatting.
|
* Change paragraph formatting.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFParaLeft(void)
|
||||||
ReformatText::RTFParaLeft(void)
|
|
||||||
{
|
{
|
||||||
if (fJustified != kJustifyLeft) {
|
if (fJustified != kJustifyLeft) {
|
||||||
fJustified = kJustifyLeft;
|
fJustified = kJustifyLeft;
|
||||||
RTFSetPara();
|
RTFSetPara();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFParaRight(void)
|
void ReformatText::RTFParaRight(void)
|
||||||
{
|
{
|
||||||
if (fJustified != kJustifyRight) {
|
if (fJustified != kJustifyRight) {
|
||||||
fJustified = kJustifyRight;
|
fJustified = kJustifyRight;
|
||||||
RTFSetPara();
|
RTFSetPara();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFParaCenter(void)
|
void ReformatText::RTFParaCenter(void)
|
||||||
{
|
{
|
||||||
if (fJustified != kJustifyCenter) {
|
if (fJustified != kJustifyCenter) {
|
||||||
fJustified = kJustifyCenter;
|
fJustified = kJustifyCenter;
|
||||||
RTFSetPara();
|
RTFSetPara();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFParaJustify(void)
|
void ReformatText::RTFParaJustify(void)
|
||||||
{
|
{
|
||||||
if (fJustified != kJustifyFull) {
|
if (fJustified != kJustifyFull) {
|
||||||
fJustified = kJustifyFull;
|
fJustified = kJustifyFull;
|
||||||
@ -505,27 +496,24 @@ ReformatText::RTFParaJustify(void)
|
|||||||
/*
|
/*
|
||||||
* Page margins, in 1/10th inches.
|
* Page margins, in 1/10th inches.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFLeftMargin(int margin)
|
||||||
ReformatText::RTFLeftMargin(int margin)
|
|
||||||
{
|
{
|
||||||
//LOGI("+++ Left margin now %d", margin);
|
//LOGI("+++ Left margin now %d", margin);
|
||||||
fLeftMargin = margin;
|
fLeftMargin = margin;
|
||||||
RTFSetPara();
|
RTFSetPara();
|
||||||
}
|
}
|
||||||
void
|
|
||||||
ReformatText::RTFRightMargin(int margin)
|
void ReformatText::RTFRightMargin(int margin)
|
||||||
{
|
{
|
||||||
//LOGI("+++ Right margin now %d", margin);
|
//LOGI("+++ Right margin now %d", margin);
|
||||||
fRightMargin = margin;
|
fRightMargin = margin;
|
||||||
RTFSetPara();
|
RTFSetPara();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Switch to a different font size.
|
* Switch to a different font size.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFSetFontSize(int points)
|
||||||
ReformatText::RTFSetFontSize(int points)
|
|
||||||
{
|
{
|
||||||
if (fUseRTF && fPointSize != points)
|
if (fUseRTF && fPointSize != points)
|
||||||
BufPrintf("\\fs%d ", points * 2);
|
BufPrintf("\\fs%d ", points * 2);
|
||||||
@ -534,8 +522,7 @@ ReformatText::RTFSetFontSize(int points)
|
|||||||
/*
|
/*
|
||||||
* Switch to a different font.
|
* Switch to a different font.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFSetFont(RTFFont font)
|
||||||
ReformatText::RTFSetFont(RTFFont font)
|
|
||||||
{
|
{
|
||||||
if (fUseRTF)
|
if (fUseRTF)
|
||||||
BufPrintf("\\f%d ", font);
|
BufPrintf("\\f%d ", font);
|
||||||
@ -544,8 +531,7 @@ ReformatText::RTFSetFont(RTFFont font)
|
|||||||
/*
|
/*
|
||||||
* Set the font by specifying a IIgs QuickDraw II font family number.
|
* Set the font by specifying a IIgs QuickDraw II font family number.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFSetGSFont(uint16_t family)
|
||||||
ReformatText::RTFSetGSFont(uint16_t family)
|
|
||||||
{
|
{
|
||||||
float newMult;
|
float newMult;
|
||||||
|
|
||||||
@ -629,8 +615,7 @@ ReformatText::RTFSetGSFont(uint16_t family)
|
|||||||
* BUG: we should track the state of the "underline" mode, and turn it
|
* BUG: we should track the state of the "underline" mode, and turn it
|
||||||
* on and off based on the font size (8-point fonts aren't underlined).
|
* on and off based on the font size (8-point fonts aren't underlined).
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFSetGSFontSize(int points)
|
||||||
ReformatText::RTFSetGSFontSize(int points)
|
|
||||||
{
|
{
|
||||||
RTFSetFontSize((int) roundf(points * fGSFontSizeMult));
|
RTFSetFontSize((int) roundf(points * fGSFontSizeMult));
|
||||||
|
|
||||||
@ -650,8 +635,7 @@ ReformatText::RTFSetGSFontSize(int points)
|
|||||||
* bold as they do in plain. This doesn't hold true for Windows
|
* bold as they do in plain. This doesn't hold true for Windows
|
||||||
* fonts, so we're going to look different in some circumstances.
|
* fonts, so we're going to look different in some circumstances.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::RTFSetGSFontStyle(uint8_t qdStyle)
|
||||||
ReformatText::RTFSetGSFontStyle(uint8_t qdStyle)
|
|
||||||
{
|
{
|
||||||
if (!fUseRTF)
|
if (!fUseRTF)
|
||||||
return;
|
return;
|
||||||
@ -701,8 +685,7 @@ ReformatText::RTFProportionalOff(void) {
|
|||||||
* If "stripHiBits" is set, the high bit of each character is cleared before
|
* If "stripHiBits" is set, the high bit of each character is cleared before
|
||||||
* the value is considered.
|
* the value is considered.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
|
||||||
ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
|
|
||||||
bool stripHiBits)
|
bool stripHiBits)
|
||||||
{
|
{
|
||||||
/* Compatibility - assume we're not stripping nulls */
|
/* Compatibility - assume we're not stripping nulls */
|
||||||
@ -715,11 +698,10 @@ ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
|
|||||||
*
|
*
|
||||||
* If "stripHiBits" is set, the high bit of each character is cleared before
|
* If "stripHiBits" is set, the high bit of each character is cleared before
|
||||||
* the value is considered.
|
* the value is considered.
|
||||||
*
|
*2
|
||||||
* If "stripNulls" is true, no null values will make it through.
|
* If "stripNulls" is true, no null values will make it through.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
|
||||||
ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
|
|
||||||
bool stripHiBits, bool stripNulls)
|
bool stripHiBits, bool stripNulls)
|
||||||
{
|
{
|
||||||
uint8_t ch;
|
uint8_t ch;
|
||||||
@ -760,8 +742,7 @@ ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,
|
|||||||
/*
|
/*
|
||||||
* Write a hex dump into the buffer.
|
* Write a hex dump into the buffer.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatText::BufHexDump(const uint8_t* srcBuf, long srcLen)
|
||||||
ReformatText::BufHexDump(const uint8_t* srcBuf, long srcLen)
|
|
||||||
{
|
{
|
||||||
const uint8_t* origSrcBuf = srcBuf;
|
const uint8_t* origSrcBuf = srcBuf;
|
||||||
char chBuf[17];
|
char chBuf[17];
|
||||||
@ -863,8 +844,7 @@ ReformatText::BufHexDump(const uint8_t* srcBuf, long srcLen)
|
|||||||
* Initialize the Apple II color palette, used for Hi-Res and DHR
|
* Initialize the Apple II color palette, used for Hi-Res and DHR
|
||||||
* conversions. Could also be used for lo-res mode.
|
* conversions. Could also be used for lo-res mode.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatGraphics::InitPalette(void)
|
||||||
ReformatGraphics::InitPalette(void)
|
|
||||||
{
|
{
|
||||||
ASSERT(kPaletteSize == 16);
|
ASSERT(kPaletteSize == 16);
|
||||||
|
|
||||||
@ -894,8 +874,7 @@ ReformatGraphics::InitPalette(void)
|
|||||||
/*
|
/*
|
||||||
* Stuff out DIB into the output fields, and set the appropriate flags.
|
* Stuff out DIB into the output fields, and set the appropriate flags.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib)
|
||||||
ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib)
|
|
||||||
{
|
{
|
||||||
ASSERT(pOutput != NULL);
|
ASSERT(pOutput != NULL);
|
||||||
ASSERT(pDib != NULL);
|
ASSERT(pDib != NULL);
|
||||||
@ -903,7 +882,6 @@ ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib)
|
|||||||
pOutput->SetDIB(pDib);
|
pOutput->SetDIB(pDib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unpack the Apple PackBytes format.
|
* Unpack the Apple PackBytes format.
|
||||||
*
|
*
|
||||||
@ -922,8 +900,7 @@ ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib)
|
|||||||
*
|
*
|
||||||
* Returns 0 on success, nonzero if the buffer is overfilled or underfilled.
|
* Returns 0 on success, nonzero if the buffer is overfilled or underfilled.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src,
|
||||||
ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src,
|
|
||||||
long dstRem, long srcLen)
|
long dstRem, long srcLen)
|
||||||
{
|
{
|
||||||
while (srcLen > 0) {
|
while (srcLen > 0) {
|
||||||
@ -1028,7 +1005,6 @@ ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unpack Macintosh PackBits format. See Technical Note TN1023.
|
* Unpack Macintosh PackBits format. See Technical Note TN1023.
|
||||||
*
|
*
|
||||||
@ -1047,8 +1023,7 @@ ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src,
|
|||||||
*
|
*
|
||||||
* We have to watch for underruns on the input and overruns on the output.
|
* We have to watch for underruns on the input and overruns on the output.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatGraphics::UnPackBits(const uint8_t** pSrcBuf, long* pSrcLen,
|
||||||
ReformatGraphics::UnPackBits(const uint8_t** pSrcBuf, long* pSrcLen,
|
|
||||||
uint8_t** pOutPtr, long dstLen, uint8_t xorVal)
|
uint8_t** pOutPtr, long dstLen, uint8_t xorVal)
|
||||||
{
|
{
|
||||||
const uint8_t* srcBuf = *pSrcBuf;
|
const uint8_t* srcBuf = *pSrcBuf;
|
||||||
|
@ -55,8 +55,7 @@ static const char* kRsrcC000[0x04] = {
|
|||||||
/*
|
/*
|
||||||
* We handle all files, but only the resource fork.
|
* We handle all files, but only the resource fork.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatResourceFork::Examine(ReformatHolder* pHolder)
|
||||||
ReformatResourceFork::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
pHolder->SetApplic(ReformatHolder::kReformatResourceFork,
|
pHolder->SetApplic(ReformatHolder::kReformatResourceFork,
|
||||||
ReformatHolder::kApplicNot,
|
ReformatHolder::kApplicNot,
|
||||||
@ -66,8 +65,7 @@ ReformatResourceFork::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Split a resource fork into its individual resources, and display them.
|
* Split a resource fork into its individual resources, and display them.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatResourceFork::Process(const ReformatHolder* pHolder,
|
||||||
ReformatResourceFork::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -166,9 +164,8 @@ done:
|
|||||||
/*
|
/*
|
||||||
* Extract and verify the header of a resource fork.
|
* Extract and verify the header of a resource fork.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool ReformatResourceFork::ReadHeader(const uint8_t* srcBuf,
|
||||||
ReformatResourceFork::ReadHeader(const uint8_t* srcBuf, long srcLen,
|
long srcLen, long* pFileVersion, long* pFileToMap, long* pFileMapSize,
|
||||||
long* pFileVersion, long* pFileToMap, long* pFileMapSize,
|
|
||||||
bool* pLittleEndian)
|
bool* pLittleEndian)
|
||||||
{
|
{
|
||||||
if (srcLen < 128) {
|
if (srcLen < 128) {
|
||||||
@ -197,15 +194,13 @@ ReformatResourceFork::ReadHeader(const uint8_t* srcBuf, long srcLen,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For use by other reformatters: find a specific resource.
|
* For use by other reformatters: find a specific resource.
|
||||||
*
|
*
|
||||||
* Returns "true" on success, "false" on failure.
|
* Returns "true" on success, "false" on failure.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool ReformatResourceFork::GetResource(const uint8_t* srcBuf,
|
||||||
ReformatResourceFork::GetResource(const uint8_t* srcBuf, long srcLen,
|
long srcLen, uint16_t resourceType, uint32_t resourceID,
|
||||||
uint16_t resourceType, uint32_t resourceID,
|
|
||||||
const uint8_t** pResource, long* pResourceLen)
|
const uint8_t** pResource, long* pResourceLen)
|
||||||
{
|
{
|
||||||
/* read the file header */
|
/* read the file header */
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatResourceFork(void) {}
|
ReformatResourceFork(void) {}
|
||||||
virtual ~ReformatResourceFork(void) {}
|
virtual ~ReformatResourceFork(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
static bool GetResource(const uint8_t* srcBuf, long srcLen,
|
static bool GetResource(const uint8_t* srcBuf, long srcLen,
|
||||||
uint16_t resourceType, uint32_t resourceID,
|
uint16_t resourceType, uint32_t resourceID,
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
/*
|
/*
|
||||||
* Indicate that we handle all parts of all files.
|
* Indicate that we handle all parts of all files.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatRaw::Examine(ReformatHolder* pHolder)
|
||||||
ReformatRaw::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
pHolder->SetApplic(ReformatHolder::kReformatRaw,
|
pHolder->SetApplic(ReformatHolder::kReformatRaw,
|
||||||
ReformatHolder::kApplicAlways,
|
ReformatHolder::kApplicAlways,
|
||||||
@ -37,20 +36,17 @@ ReformatRaw::Examine(ReformatHolder* pHolder)
|
|||||||
* This should inspire whoever is calling us to present the data without
|
* This should inspire whoever is calling us to present the data without
|
||||||
* reformatting it first.
|
* reformatting it first.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatRaw::Process(const ReformatHolder* pHolder,
|
||||||
ReformatRaw::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Indicate that we handle all parts of all files.
|
* Indicate that we handle all parts of all files.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatHexDump::Examine(ReformatHolder* pHolder)
|
||||||
ReformatHexDump::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
pHolder->SetApplic(ReformatHolder::kReformatHexDump,
|
pHolder->SetApplic(ReformatHolder::kReformatHexDump,
|
||||||
ReformatHolder::kApplicAlways,
|
ReformatHolder::kApplicAlways,
|
||||||
@ -60,8 +56,7 @@ ReformatHexDump::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert a file to a hex dump.
|
* Convert a file to a hex dump.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatHexDump::Process(const ReformatHolder* pHolder,
|
||||||
ReformatHexDump::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -91,12 +86,10 @@ ReformatHexDump::Process(const ReformatHolder* pHolder,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Indicate that we handle all parts of all files.
|
* Indicate that we handle all parts of all files.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatEOL_HA::Examine(ReformatHolder* pHolder)
|
||||||
ReformatEOL_HA::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
pHolder->SetApplic(ReformatHolder::kReformatTextEOL_HA,
|
pHolder->SetApplic(ReformatHolder::kReformatTextEOL_HA,
|
||||||
ReformatHolder::kApplicAlways,
|
ReformatHolder::kApplicAlways,
|
||||||
@ -109,8 +102,7 @@ ReformatEOL_HA::Examine(ReformatHolder* pHolder)
|
|||||||
*
|
*
|
||||||
* Sadly, this most likely requires expanding the original.
|
* Sadly, this most likely requires expanding the original.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatEOL_HA::Process(const ReformatHolder* pHolder,
|
||||||
ReformatEOL_HA::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
ReformatEOL_HA(void) {}
|
ReformatEOL_HA(void) {}
|
||||||
virtual ~ReformatEOL_HA(void) {}
|
virtual ~ReformatEOL_HA(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -33,10 +33,10 @@ public:
|
|||||||
ReformatRaw(void) {}
|
ReformatRaw(void) {}
|
||||||
virtual ~ReformatRaw(void) {}
|
virtual ~ReformatRaw(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -47,10 +47,10 @@ public:
|
|||||||
ReformatHexDump(void) {}
|
ReformatHexDump(void) {}
|
||||||
virtual ~ReformatHexDump(void) {}
|
virtual ~ReformatHexDump(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*REFORMAT_SIMPLE_H*/
|
#endif /*REFORMAT_SIMPLE_H*/
|
||||||
|
@ -46,16 +46,14 @@
|
|||||||
*
|
*
|
||||||
* This is a reasonably generic routine shared by SHR functions.
|
* This is a reasonably generic routine shared by SHR functions.
|
||||||
*/
|
*/
|
||||||
MyDIBitmap*
|
MyDIBitmap* ReformatSHR::SHRScreenToBitmap8(const SHRScreen* pScreen)
|
||||||
ReformatSHR::SHRScreenToBitmap8(const SHRScreen* pScreen)
|
|
||||||
{
|
{
|
||||||
return SHRDataToBitmap8(pScreen->pixels, pScreen->scb,
|
return SHRDataToBitmap8(pScreen->pixels, pScreen->scb,
|
||||||
pScreen->colorTable, kPixelBytesPerLine, kNumLines,
|
pScreen->colorTable, kPixelBytesPerLine, kNumLines,
|
||||||
kOutputWidth, kOutputHeight);
|
kOutputWidth, kOutputHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
MyDIBitmap*
|
MyDIBitmap* ReformatSHR::SHRDataToBitmap8(const uint8_t* pPixels,
|
||||||
ReformatSHR::SHRDataToBitmap8(const uint8_t* pPixels,
|
|
||||||
const uint8_t* pSCB, const uint8_t* pColorTable,
|
const uint8_t* pSCB, const uint8_t* pColorTable,
|
||||||
int pixelBytesPerLine, int numScanLines,
|
int pixelBytesPerLine, int numScanLines,
|
||||||
int outputWidth, int outputHeight)
|
int outputWidth, int outputHeight)
|
||||||
@ -223,8 +221,7 @@ bail:
|
|||||||
* Occasionally somebody slaps the wrong aux type on, so if we're in
|
* Occasionally somebody slaps the wrong aux type on, so if we're in
|
||||||
* "relaxed" mode we accept just about anything that's the right size.
|
* "relaxed" mode we accept just about anything that's the right size.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatUnpackedSHR::Examine(ReformatHolder* pHolder)
|
||||||
ReformatUnpackedSHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -255,8 +252,7 @@ ReformatUnpackedSHR::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert an unpacked Super Hi-Res image.
|
* Convert an unpacked Super Hi-Res image.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatUnpackedSHR::Process(const ReformatHolder* pHolder,
|
||||||
ReformatUnpackedSHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -283,6 +279,7 @@ bail:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ==========================================================================
|
* ==========================================================================
|
||||||
* ReformatAppSHR
|
* ReformatAppSHR
|
||||||
@ -295,8 +292,7 @@ bail:
|
|||||||
* This file type seems exclusive to the IIgs version of "John Elway
|
* This file type seems exclusive to the IIgs version of "John Elway
|
||||||
* Quarterback".
|
* Quarterback".
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatJEQSHR::Examine(ReformatHolder* pHolder)
|
||||||
ReformatJEQSHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -324,8 +320,7 @@ ReformatJEQSHR::Examine(ReformatHolder* pHolder)
|
|||||||
* and only one color table is stored. Total savings of 480 bytes -- less
|
* and only one color table is stored. Total savings of 480 bytes -- less
|
||||||
* than a ProDOS block. Sorta dumb.
|
* than a ProDOS block. Sorta dumb.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatJEQSHR::Process(const ReformatHolder* pHolder,
|
||||||
ReformatJEQSHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -366,8 +361,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatPaintworksSHR::Examine(ReformatHolder* pHolder)
|
||||||
ReformatPaintworksSHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -386,7 +380,6 @@ ReformatPaintworksSHR::Examine(ReformatHolder* pHolder)
|
|||||||
ReformatHolder::kApplicNot, ReformatHolder::kApplicNot);
|
ReformatHolder::kApplicNot, ReformatHolder::kApplicNot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a PaintWorks format Super Hi-Res image.
|
* Convert a PaintWorks format Super Hi-Res image.
|
||||||
*
|
*
|
||||||
@ -405,8 +398,7 @@ ReformatPaintworksSHR::Examine(ReformatHolder* pHolder)
|
|||||||
* Sometimes it runs a few bytes over. If it runs significantly under, it's
|
* Sometimes it runs a few bytes over. If it runs significantly under, it's
|
||||||
* probably a generic packed image (PNT/0001) with the wrong auxtype.
|
* probably a generic packed image (PNT/0001) with the wrong auxtype.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatPaintworksSHR::Process(const ReformatHolder* pHolder,
|
||||||
ReformatPaintworksSHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -493,8 +485,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatPackedSHR::Examine(ReformatHolder* pHolder)
|
||||||
ReformatPackedSHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -516,8 +507,7 @@ ReformatPackedSHR::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert a packed Super Hi-Res image (PNT/$0001).
|
* Convert a packed Super Hi-Res image (PNT/$0001).
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatPackedSHR::Process(const ReformatHolder* pHolder,
|
||||||
ReformatPackedSHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -560,8 +550,7 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatAPFSHR::Examine(ReformatHolder* pHolder)
|
||||||
ReformatAPFSHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -590,8 +579,7 @@ ReformatAPFSHR::Examine(ReformatHolder* pHolder)
|
|||||||
* All we're really interested in is the "MAIN" block, though we need
|
* All we're really interested in is the "MAIN" block, though we need
|
||||||
* to handle MULTIPAL as well for 3200-color images.
|
* to handle MULTIPAL as well for 3200-color images.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatAPFSHR::Process(const ReformatHolder* pHolder,
|
||||||
ReformatAPFSHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -707,8 +695,7 @@ bail:
|
|||||||
* that happens to be 640 pixels wide? Did all //gs applications set this
|
* that happens to be 640 pixels wide? Did all //gs applications set this
|
||||||
* correctly? Can the format be different on every line?
|
* correctly? Can the format be different on every line?
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen)
|
||||||
ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen)
|
|
||||||
{
|
{
|
||||||
const int kColorTableSize = kNumEntriesPerColorTable * kColorTableEntrySize;
|
const int kColorTableSize = kNumEntriesPerColorTable * kColorTableEntrySize;
|
||||||
uint16_t masterMode;
|
uint16_t masterMode;
|
||||||
@ -733,7 +720,7 @@ ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen)
|
|||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGI(" APFSHR masterMode=0x%04x, ppsl=%d, nct=%d",
|
LOGD(" APFSHR masterMode=0x%04x, ppsl=%d, nct=%d",
|
||||||
masterMode, fPixelsPerScanLine, numColorTables);
|
masterMode, fPixelsPerScanLine, numColorTables);
|
||||||
if (numColorTables <= 0 || numColorTables > kNumColorTables) {
|
if (numColorTables <= 0 || numColorTables > kNumColorTables) {
|
||||||
LOGI(" APFSHR unexpected numColorTables %d", numColorTables);
|
LOGI(" APFSHR unexpected numColorTables %d", numColorTables);
|
||||||
@ -773,7 +760,7 @@ ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen)
|
|||||||
{
|
{
|
||||||
/* standard-sized image, use fScreen */
|
/* standard-sized image, use fScreen */
|
||||||
ASSERT(!fNonStandard);
|
ASSERT(!fNonStandard);
|
||||||
LOGI(" Assuming this is a standard, full-width SHR image");
|
LOGD(" Assuming this is a standard, full-width SHR image");
|
||||||
fPixelBytesPerLine = kPixelBytesPerLine; // 160
|
fPixelBytesPerLine = kPixelBytesPerLine; // 160
|
||||||
fPixelStore = fScreen.pixels;
|
fPixelStore = fScreen.pixels;
|
||||||
fSCBStore = fScreen.scb;
|
fSCBStore = fScreen.scb;
|
||||||
@ -820,7 +807,7 @@ ReformatAPFSHR::UnpackMain(const uint8_t* srcPtr, long srcLen)
|
|||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOGI(" APFSHR numScanLines=%d, outputWidth=%d, pixelBytesPerLine=%d",
|
LOGD(" APFSHR numScanLines=%d, outputWidth=%d, pixelBytesPerLine=%d",
|
||||||
fNumScanLines, fOutputWidth, fPixelBytesPerLine);
|
fNumScanLines, fOutputWidth, fPixelBytesPerLine);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -881,8 +868,7 @@ bail:
|
|||||||
* Brooks format by stuffing them into the file the wrong way. We could
|
* Brooks format by stuffing them into the file the wrong way. We could
|
||||||
* fix it here, but we can't reliably detect the files.
|
* fix it here, but we can't reliably detect the files.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatAPFSHR::UnpackMultipal(uint8_t* dstPtr,
|
||||||
ReformatAPFSHR::UnpackMultipal(uint8_t* dstPtr,
|
|
||||||
const uint8_t* srcPtr, long srcLen)
|
const uint8_t* srcPtr, long srcLen)
|
||||||
{
|
{
|
||||||
const int kMultipalSize = kNumLines *
|
const int kMultipalSize = kNumLines *
|
||||||
@ -934,8 +920,7 @@ ReformatAPFSHR::UnpackMultipal(uint8_t* dstPtr,
|
|||||||
* Unpack a "NOTE" chunk. This seems to be a 16-bit count followed by
|
* Unpack a "NOTE" chunk. This seems to be a 16-bit count followed by
|
||||||
* ASCII data.
|
* ASCII data.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatAPFSHR::UnpackNote(const uint8_t* srcPtr, long srcLen)
|
||||||
ReformatAPFSHR::UnpackNote(const uint8_t* srcPtr, long srcLen)
|
|
||||||
{
|
{
|
||||||
int numChars;
|
int numChars;
|
||||||
|
|
||||||
@ -965,8 +950,7 @@ ReformatAPFSHR::UnpackNote(const uint8_t* srcPtr, long srcLen)
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void Reformat3200SHR::Examine(ReformatHolder* pHolder)
|
||||||
Reformat3200SHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -997,8 +981,7 @@ Reformat3200SHR::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert a 3200-color Super Hi-Res Image.
|
* Convert a 3200-color Super Hi-Res Image.
|
||||||
*/
|
*/
|
||||||
int
|
int Reformat3200SHR::Process(const ReformatHolder* pHolder,
|
||||||
Reformat3200SHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -1049,8 +1032,7 @@ bail:
|
|||||||
*
|
*
|
||||||
* This is shared among the 3200-color SHR formats.
|
* This is shared among the 3200-color SHR formats.
|
||||||
*/
|
*/
|
||||||
MyDIBitmap*
|
MyDIBitmap* Reformat3200SHR::SHR3200ToBitmap24(void)
|
||||||
Reformat3200SHR::SHR3200ToBitmap24(void)
|
|
||||||
{
|
{
|
||||||
MyDIBitmap* pDib = new MyDIBitmap;
|
MyDIBitmap* pDib = new MyDIBitmap;
|
||||||
RGBTRIPLE colorLookup[kExtNumColorTables][kNumEntriesPerColorTable];
|
RGBTRIPLE colorLookup[kExtNumColorTables][kNumEntriesPerColorTable];
|
||||||
@ -1139,8 +1121,7 @@ bail:
|
|||||||
* This *might* also be $c0/0004, but there's no file type note
|
* This *might* also be $c0/0004, but there's no file type note
|
||||||
* for that.
|
* for that.
|
||||||
*/
|
*/
|
||||||
void
|
void Reformat3201SHR::Examine(ReformatHolder* pHolder)
|
||||||
Reformat3201SHR::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
long fileType = pHolder->GetFileType();
|
long fileType = pHolder->GetFileType();
|
||||||
@ -1159,12 +1140,10 @@ Reformat3201SHR::Examine(ReformatHolder* pHolder)
|
|||||||
ReformatHolder::kApplicNot, ReformatHolder::kApplicNot);
|
ReformatHolder::kApplicNot, ReformatHolder::kApplicNot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a 3201-format packed 3200-color Super Hi-Res Image.
|
* Convert a 3201-format packed 3200-color Super Hi-Res Image.
|
||||||
*/
|
*/
|
||||||
int
|
int Reformat3201SHR::Process(const ReformatHolder* pHolder,
|
||||||
Reformat3201SHR::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
|
@ -84,10 +84,10 @@ public:
|
|||||||
ReformatUnpackedSHR(void) {}
|
ReformatUnpackedSHR(void) {}
|
||||||
virtual ~ReformatUnpackedSHR(void) {}
|
virtual ~ReformatUnpackedSHR(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SHRScreen fScreen;
|
SHRScreen fScreen;
|
||||||
@ -102,10 +102,10 @@ public:
|
|||||||
ReformatJEQSHR(void) {}
|
ReformatJEQSHR(void) {}
|
||||||
virtual ~ReformatJEQSHR(void) {}
|
virtual ~ReformatJEQSHR(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum { kExpectedLen = 32288 };
|
enum { kExpectedLen = 32288 };
|
||||||
@ -121,10 +121,10 @@ public:
|
|||||||
ReformatPaintworksSHR(void) {}
|
ReformatPaintworksSHR(void) {}
|
||||||
virtual ~ReformatPaintworksSHR(void) {}
|
virtual ~ReformatPaintworksSHR(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum { kMinSize = 223 };
|
enum { kMinSize = 223 };
|
||||||
@ -140,10 +140,10 @@ public:
|
|||||||
ReformatPackedSHR(void) {}
|
ReformatPackedSHR(void) {}
|
||||||
virtual ~ReformatPackedSHR(void) {}
|
virtual ~ReformatPackedSHR(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SHRScreen fScreen;
|
SHRScreen fScreen;
|
||||||
@ -166,10 +166,10 @@ public:
|
|||||||
delete[] fSCBStore;
|
delete[] fSCBStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int UnpackMain(const uint8_t* srcPtr, long srcLen);
|
int UnpackMain(const uint8_t* srcPtr, long srcLen);
|
||||||
@ -206,10 +206,10 @@ public:
|
|||||||
memcpy(fExtColorTable, multiPal, sizeof(fExtColorTable));
|
memcpy(fExtColorTable, multiPal, sizeof(fExtColorTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
MyDIBitmap* SHR3200ToBitmap24(void);
|
MyDIBitmap* SHR3200ToBitmap24(void);
|
||||||
|
|
||||||
@ -234,10 +234,10 @@ public:
|
|||||||
Reformat3201SHR(void) {}
|
Reformat3201SHR(void) {}
|
||||||
virtual ~Reformat3201SHR(void) {}
|
virtual ~Reformat3201SHR(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -279,10 +279,10 @@ public:
|
|||||||
ReformatDG256SHR(void) {}
|
ReformatDG256SHR(void) {}
|
||||||
virtual ~ReformatDG256SHR(void) {}
|
virtual ~ReformatDG256SHR(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DreamGrafix fDG;
|
DreamGrafix fDG;
|
||||||
@ -297,10 +297,10 @@ public:
|
|||||||
ReformatDG3200SHR(void) {}
|
ReformatDG3200SHR(void) {}
|
||||||
virtual ~ReformatDG3200SHR(void) {}
|
virtual ~ReformatDG3200SHR(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DreamGrafix fDG;
|
DreamGrafix fDG;
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
* document. Possibly useful for converting the special characters. We'll
|
* document. Possibly useful for converting the special characters. We'll
|
||||||
* activate it for any GWP file other than the two known types.
|
* activate it for any GWP file other than the two known types.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatGWP::Examine(ReformatHolder* pHolder)
|
||||||
ReformatGWP::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -40,8 +39,7 @@ ReformatGWP::Examine(ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Convert GWP into formatted text.
|
* Convert GWP into formatted text.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatGWP::Process(const ReformatHolder* pHolder,
|
||||||
ReformatGWP::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -89,8 +87,7 @@ ReformatGWP::Process(const ReformatHolder* pHolder,
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatTeach::Examine(ReformatHolder* pHolder)
|
||||||
ReformatTeach::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
ReformatHolder::ReformatApplies applies = ReformatHolder::kApplicNot;
|
||||||
|
|
||||||
@ -106,8 +103,7 @@ ReformatTeach::Examine(ReformatHolder* pHolder)
|
|||||||
*
|
*
|
||||||
* The text is in the data fork and the formatting is in the resource fork.
|
* The text is in the data fork and the formatting is in the resource fork.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatTeach::Process(const ReformatHolder* pHolder,
|
||||||
ReformatTeach::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -238,8 +234,7 @@ ReformatTeach::Process(const ReformatHolder* pHolder,
|
|||||||
/*
|
/*
|
||||||
* Unpack an rStyleBlock resource.
|
* Unpack an rStyleBlock resource.
|
||||||
*/
|
*/
|
||||||
bool
|
bool RStyleBlock::Create(const uint8_t* buf, long len)
|
||||||
RStyleBlock::Create(const uint8_t* buf, long len)
|
|
||||||
{
|
{
|
||||||
uint16_t version;
|
uint16_t version;
|
||||||
uint32_t partLen;
|
uint32_t partLen;
|
||||||
@ -326,14 +321,12 @@ RStyleBlock::Create(const uint8_t* buf, long len)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct a TERuler from a chunk of data.
|
* Construct a TERuler from a chunk of data.
|
||||||
*
|
*
|
||||||
* Returns the #of bytes consumed, or -1 on failure.
|
* Returns the #of bytes consumed, or -1 on failure.
|
||||||
*/
|
*/
|
||||||
int
|
int RStyleBlock::TERuler::Create(const uint8_t* buf, long len)
|
||||||
RStyleBlock::TERuler::Create(const uint8_t* buf, long len)
|
|
||||||
{
|
{
|
||||||
long origLen = len;
|
long origLen = len;
|
||||||
|
|
||||||
@ -395,8 +388,7 @@ RStyleBlock::TERuler::Create(const uint8_t* buf, long len)
|
|||||||
/*
|
/*
|
||||||
* Extract a TEStyle object from the buffer.
|
* Extract a TEStyle object from the buffer.
|
||||||
*/
|
*/
|
||||||
void
|
void RStyleBlock::TEStyle::Create(const uint8_t* buf)
|
||||||
RStyleBlock::TEStyle::Create(const uint8_t* buf)
|
|
||||||
{
|
{
|
||||||
fFontID = Reformat::Get32LE(buf);
|
fFontID = Reformat::Get32LE(buf);
|
||||||
fForeColor = Reformat::Get16LE(buf + 4);
|
fForeColor = Reformat::Get16LE(buf + 4);
|
||||||
@ -410,8 +402,7 @@ RStyleBlock::TEStyle::Create(const uint8_t* buf)
|
|||||||
/*
|
/*
|
||||||
* Extract a StyleItem object from the buffer.
|
* Extract a StyleItem object from the buffer.
|
||||||
*/
|
*/
|
||||||
void
|
void RStyleBlock::StyleItem::Create(const uint8_t* buf)
|
||||||
RStyleBlock::StyleItem::Create(const uint8_t* buf)
|
|
||||||
{
|
{
|
||||||
fLength = Reformat::Get32LE(buf);
|
fLength = Reformat::Get32LE(buf);
|
||||||
fOffset = Reformat::Get32LE(buf + 4);
|
fOffset = Reformat::Get32LE(buf + 4);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define REFORMAT_TEACH_H
|
#define REFORMAT_TEACH_H
|
||||||
|
|
||||||
#include "ReformatBase.h"
|
#include "ReformatBase.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reformat a generic IIgs text file.
|
* Reformat a generic IIgs text file.
|
||||||
@ -19,10 +20,10 @@ public:
|
|||||||
ReformatGWP(void) {}
|
ReformatGWP(void) {}
|
||||||
virtual ~ReformatGWP(void) {}
|
virtual ~ReformatGWP(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -33,10 +34,10 @@ public:
|
|||||||
ReformatTeach(void) {}
|
ReformatTeach(void) {}
|
||||||
virtual ~ReformatTeach(void) {}
|
virtual ~ReformatTeach(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
@ -207,5 +208,4 @@ private:
|
|||||||
StyleItem* fpStyleItems;
|
StyleItem* fpStyleItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /*REFORMAT_TEACH_H*/
|
#endif /*REFORMAT_TEACH_H*/
|
||||||
|
@ -37,8 +37,7 @@
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatMagicWindow::Examine(ReformatHolder* pHolder)
|
||||||
ReformatMagicWindow::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
if (pHolder->GetFileType() == kTypeBIN) {
|
if (pHolder->GetFileType() == kTypeBIN) {
|
||||||
bool isMW = ReformatMagicWindow::IsFormatted(pHolder);
|
bool isMW = ReformatMagicWindow::IsFormatted(pHolder);
|
||||||
@ -79,8 +78,7 @@ ReformatMagicWindow::Examine(ReformatHolder* pHolder)
|
|||||||
* I don't know much about the format, so this is based on the similarities
|
* I don't know much about the format, so this is based on the similarities
|
||||||
* observed between half a dozen documents from different sources.
|
* observed between half a dozen documents from different sources.
|
||||||
*/
|
*/
|
||||||
/*static*/ bool
|
/*static*/ bool ReformatMagicWindow::IsFormatted(const ReformatHolder* pHolder)
|
||||||
ReformatMagicWindow::IsFormatted(const ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
const uint8_t* ptr = pHolder->GetSourceBuf(ReformatHolder::kPartData);
|
||||||
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
|
||||||
@ -145,8 +143,7 @@ ReformatMagicWindow::IsFormatted(const ReformatHolder* pHolder)
|
|||||||
/*
|
/*
|
||||||
* Skip the header and text-convert the rest.
|
* Skip the header and text-convert the rest.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatMagicWindow::Process(const ReformatHolder* pHolder,
|
||||||
ReformatMagicWindow::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
@ -184,10 +181,9 @@ bail:
|
|||||||
/*
|
/*
|
||||||
* Decide whether or not we want to handle this file.
|
* Decide whether or not we want to handle this file.
|
||||||
*/
|
*/
|
||||||
void
|
void ReformatGutenberg::Examine(ReformatHolder* pHolder)
|
||||||
ReformatGutenberg::Examine(ReformatHolder* pHolder)
|
|
||||||
{
|
{
|
||||||
if ((pHolder->GetFileType() == kTypeTXT) &&
|
if ((pHolder->GetFileType() == kTypeTXT) &&
|
||||||
(pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatGutenberg)) {
|
(pHolder->GetSourceFormat() == ReformatHolder::kSourceFormatGutenberg)) {
|
||||||
|
|
||||||
pHolder->SetApplic(ReformatHolder::kReformatGutenberg,
|
pHolder->SetApplic(ReformatHolder::kReformatGutenberg,
|
||||||
@ -196,12 +192,10 @@ ReformatGutenberg::Examine(ReformatHolder* pHolder)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert the text.
|
* Convert the text.
|
||||||
*/
|
*/
|
||||||
int
|
int ReformatGutenberg::Process(const ReformatHolder* pHolder,
|
||||||
ReformatGutenberg::Process(const ReformatHolder* pHolder,
|
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput)
|
ReformatOutput* pOutput)
|
||||||
{
|
{
|
||||||
|
@ -20,10 +20,10 @@ public:
|
|||||||
ReformatMagicWindow(void) {}
|
ReformatMagicWindow(void) {}
|
||||||
virtual ~ReformatMagicWindow(void) {}
|
virtual ~ReformatMagicWindow(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool IsFormatted(const ReformatHolder* pHolder);
|
static bool IsFormatted(const ReformatHolder* pHolder);
|
||||||
@ -39,10 +39,10 @@ public:
|
|||||||
ReformatGutenberg(void) {}
|
ReformatGutenberg(void) {}
|
||||||
virtual ~ReformatGutenberg(void) {}
|
virtual ~ReformatGutenberg(void) {}
|
||||||
|
|
||||||
virtual void Examine(ReformatHolder* pHolder);
|
virtual void Examine(ReformatHolder* pHolder) override;
|
||||||
virtual int Process(const ReformatHolder* pHolder,
|
virtual int Process(const ReformatHolder* pHolder,
|
||||||
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
ReformatHolder::ReformatID id, ReformatHolder::ReformatPart part,
|
||||||
ReformatOutput* pOutput);
|
ReformatOutput* pOutput) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,11 +37,11 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/* override Cancel button to just raise the flag */
|
/* override Cancel button to just raise the flag */
|
||||||
virtual void OnCancel(void) {
|
virtual void OnCancel(void) override {
|
||||||
/* "cancel" button or escape hit */
|
/* "cancel" button or escape hit */
|
||||||
*fpCancelFlag = true;
|
*fpCancelFlag = true;
|
||||||
}
|
}
|
||||||
//void PostNcDestroy(void) { delete this; }
|
//void PostNcDestroy(void) override { delete this; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,4 +135,4 @@ IOleObject *CImageDataObject::GetOleObject(IOleClientSite *pOleClientSite, IStor
|
|||||||
if (sc != S_OK)
|
if (sc != S_OK)
|
||||||
AfxThrowOleException(sc);
|
AfxThrowOleException(sc);
|
||||||
return pOleObject;
|
return pOleObject;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
* OK button clicked. Must override to prevent standard EndDialog
|
* OK button clicked. Must override to prevent standard EndDialog
|
||||||
* behavior.
|
* behavior.
|
||||||
*/
|
*/
|
||||||
virtual void OnOK(void) {
|
virtual void OnOK(void) override {
|
||||||
if (UpdateData() != FALSE) // try the DDX/DDV stuff, if any
|
if (UpdateData() != FALSE) // try the DDX/DDV stuff, if any
|
||||||
DestroyWindow();
|
DestroyWindow();
|
||||||
}
|
}
|
||||||
@ -41,12 +41,12 @@ public:
|
|||||||
* ESC key hit or Cancel button clicked. Must override to prevent
|
* ESC key hit or Cancel button clicked. Must override to prevent
|
||||||
* standard EndDialog behavior.
|
* standard EndDialog behavior.
|
||||||
*/
|
*/
|
||||||
virtual void OnCancel(void) {
|
virtual void OnCancel(void) override {
|
||||||
DestroyWindow();
|
DestroyWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void PostNcDestroy(void) {
|
void PostNcDestroy(void) override {
|
||||||
// this may not arrive immediately
|
// this may not arrive immediately
|
||||||
fOkayToDelete = true;
|
fOkayToDelete = true;
|
||||||
delete this;
|
delete this;
|
||||||
@ -77,7 +77,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* enable the parent window before we're destroyed */
|
/* enable the parent window before we're destroyed */
|
||||||
virtual BOOL DestroyWindow(void) {
|
virtual BOOL DestroyWindow(void) override {
|
||||||
if (fpParentWnd != NULL)
|
if (fpParentWnd != NULL)
|
||||||
fpParentWnd->EnableWindow(TRUE);
|
fpParentWnd->EnableWindow(TRUE);
|
||||||
return ModelessDialog::DestroyWindow();
|
return ModelessDialog::DestroyWindow();
|
||||||
|
@ -15,13 +15,7 @@ BEGIN_MESSAGE_MAP(MyBitmapButton, CButton)
|
|||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
/*
|
BOOL MyBitmapButton::ReplaceDlgCtrl(CDialog* pDialog, int buttonID)
|
||||||
* Replace a button control in a dialog with ourselves.
|
|
||||||
*
|
|
||||||
* Returns TRUE on success, FALSE on failure.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
MyBitmapButton::ReplaceDlgCtrl(CDialog* pDialog, int buttonID)
|
|
||||||
{
|
{
|
||||||
CWnd* pWnd = pDialog->GetDlgItem(buttonID);
|
CWnd* pWnd = pDialog->GetDlgItem(buttonID);
|
||||||
if (pWnd == NULL)
|
if (pWnd == NULL)
|
||||||
@ -50,27 +44,19 @@ MyBitmapButton::ReplaceDlgCtrl(CDialog* pDialog, int buttonID)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
BOOL MyBitmapButton::SetBitmapID(int id)
|
||||||
* Set the bitmap ID, and update the button appropriately.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
MyBitmapButton::SetBitmapID(int id)
|
|
||||||
{
|
{
|
||||||
fBitmapID = id;
|
fBitmapID = id;
|
||||||
UpdateBitmap();
|
UpdateBitmap();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MyBitmapButton::UpdateBitmap(void)
|
||||||
* (Re-)load the bitmap and attach it to the button.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MyBitmapButton::UpdateBitmap(void)
|
|
||||||
{
|
{
|
||||||
HBITMAP hNewBits;
|
HBITMAP hNewBits;
|
||||||
|
|
||||||
if (fBitmapID == -1) {
|
if (fBitmapID == -1) {
|
||||||
LOGI("ERROR: UpdateBitmap called before bitmap set");
|
LOGE("ERROR: UpdateBitmap called before bitmap set");
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -78,7 +64,7 @@ MyBitmapButton::UpdateBitmap(void)
|
|||||||
hNewBits = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
|
hNewBits = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
|
||||||
MAKEINTRESOURCE(fBitmapID), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
|
MAKEINTRESOURCE(fBitmapID), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
|
||||||
if (hNewBits == NULL) {
|
if (hNewBits == NULL) {
|
||||||
LOGI("WARNING: LoadImage failed (bitID=%d)", fBitmapID);
|
LOGW("WARNING: LoadImage failed (bitID=%d)", fBitmapID);
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,11 +75,7 @@ MyBitmapButton::UpdateBitmap(void)
|
|||||||
fhBitmap = hNewBits;
|
fhBitmap = hNewBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MyBitmapButton::OnSysColorChange(void)
|
||||||
* If the system colors have changed, reload the bitmap.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MyBitmapButton::OnSysColorChange(void)
|
|
||||||
{
|
{
|
||||||
LOGD("MyBitmapButton 0x%p tracking color change", this);
|
LOGD("MyBitmapButton 0x%p tracking color change", this);
|
||||||
UpdateBitmap();
|
UpdateBitmap();
|
||||||
|
@ -34,13 +34,29 @@ public:
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual BOOL SetBitmapID(int id);
|
/*
|
||||||
|
* Replace a button control in a dialog with ourselves.
|
||||||
|
*
|
||||||
|
* Returns TRUE on success, FALSE on failure.
|
||||||
|
*/
|
||||||
virtual BOOL ReplaceDlgCtrl(CDialog* pDialog, int buttonID);
|
virtual BOOL ReplaceDlgCtrl(CDialog* pDialog, int buttonID);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the bitmap ID, and update the button appropriately.
|
||||||
|
*/
|
||||||
|
virtual BOOL SetBitmapID(int id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void UpdateBitmap(void);
|
/*
|
||||||
|
* If the system colors have changed, reload the bitmap.
|
||||||
|
*/
|
||||||
afx_msg void OnSysColorChange(void);
|
afx_msg void OnSysColorChange(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (Re-)load the bitmap and attach it to the button.
|
||||||
|
*/
|
||||||
|
virtual void UpdateBitmap(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HBITMAP fhBitmap;
|
HBITMAP fhBitmap;
|
||||||
int fBitmapID;
|
int fBitmapID;
|
||||||
|
@ -30,9 +30,6 @@
|
|||||||
//using namespace libfadden;
|
//using namespace libfadden;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Destroy allocated memory and delete the DIB object.
|
|
||||||
*/
|
|
||||||
MyDIBitmap::~MyDIBitmap(void)
|
MyDIBitmap::~MyDIBitmap(void)
|
||||||
{
|
{
|
||||||
if (mhBitmap != NULL)
|
if (mhBitmap != NULL)
|
||||||
@ -43,18 +40,12 @@ MyDIBitmap::~MyDIBitmap(void)
|
|||||||
/* fpPixels point to system-allocated memory inside fhBitmap */
|
/* fpPixels point to system-allocated memory inside fhBitmap */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void* MyDIBitmap::Create(int width, int height, int bitsPerPixel, int colorsUsed,
|
||||||
* Create a blank DIB with the requested dimensions.
|
|
||||||
*
|
|
||||||
* We probably don't need to allocate DIB storage here. We can do most
|
|
||||||
* operations ourselves, in local memory, and only convert when needed.
|
|
||||||
*
|
|
||||||
* Returns a pointer to the pixel storage on success, or NULL on failure.
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
MyDIBitmap::Create(int width, int height, int bitsPerPixel, int colorsUsed,
|
|
||||||
bool dibSection /*=false*/)
|
bool dibSection /*=false*/)
|
||||||
{
|
{
|
||||||
|
// We probably don't need to allocate DIB storage here. We can do most
|
||||||
|
// operations ourselves, in local memory, and only convert when needed.
|
||||||
|
|
||||||
if (mhBitmap != NULL || mpPixels != NULL || mpFileBuffer != NULL) {
|
if (mhBitmap != NULL || mpPixels != NULL || mpFileBuffer != NULL) {
|
||||||
LOGI(" DIB GLITCH: already created");
|
LOGI(" DIB GLITCH: already created");
|
||||||
assert(false);
|
assert(false);
|
||||||
@ -146,11 +137,7 @@ MyDIBitmap::Create(int width, int height, int bitsPerPixel, int colorsUsed,
|
|||||||
return mpPixels;
|
return mpPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MyDIBitmap::CreateFromFile(const WCHAR* fileName)
|
||||||
* Open the file and call the FILE* version.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::CreateFromFile(const WCHAR* fileName)
|
|
||||||
{
|
{
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
int err;
|
int err;
|
||||||
@ -173,11 +160,7 @@ MyDIBitmap::CreateFromFile(const WCHAR* fileName)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MyDIBitmap::CreateFromFile(FILE* fp, long len)
|
||||||
* Create a DIB by reading a BMP or TGA file into memory.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::CreateFromFile(FILE* fp, long len)
|
|
||||||
{
|
{
|
||||||
void* buf = NULL;
|
void* buf = NULL;
|
||||||
int err = -1;
|
int err = -1;
|
||||||
@ -198,14 +181,7 @@ bail:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MyDIBitmap::CreateFromBuffer(void* buf, long len, bool doDelete)
|
||||||
* Create object from a copy of the file in memory.
|
|
||||||
*
|
|
||||||
* We want to hang on to the data buffer, but if we don't own it then we
|
|
||||||
* have to make a copy.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::CreateFromBuffer(void* buf, long len, bool doDelete)
|
|
||||||
{
|
{
|
||||||
assert(len > 0);
|
assert(len > 0);
|
||||||
|
|
||||||
@ -221,18 +197,7 @@ MyDIBitmap::CreateFromBuffer(void* buf, long len, bool doDelete)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MyDIBitmap::CreateFromNewBuffer(void* vbuf, long len)
|
||||||
* Create object from a buffer of new[]-created memory that we own.
|
|
||||||
*
|
|
||||||
* The memory will be discarded if this function fails.
|
|
||||||
*
|
|
||||||
* We don't want to create a DIB section if the eventual user of this data
|
|
||||||
* doesn't need it (e.g. it's just getting converted into a 3D texture
|
|
||||||
* without using any GDI calls), so we just leave the pixels in the file
|
|
||||||
* buffer for now.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::CreateFromNewBuffer(void* vbuf, long len)
|
|
||||||
{
|
{
|
||||||
BITMAPFILEHEADER* pHeader = (BITMAPFILEHEADER*) vbuf;
|
BITMAPFILEHEADER* pHeader = (BITMAPFILEHEADER*) vbuf;
|
||||||
unsigned char* buf = (unsigned char*) vbuf;
|
unsigned char* buf = (unsigned char*) vbuf;
|
||||||
@ -256,13 +221,7 @@ MyDIBitmap::CreateFromNewBuffer(void* vbuf, long len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MyDIBitmap::ImportBMP(void* vbuf, long len)
|
||||||
* Set up internal structures for the BMP file.
|
|
||||||
*
|
|
||||||
* On error, "vbuf" is discarded.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::ImportBMP(void* vbuf, long len)
|
|
||||||
{
|
{
|
||||||
BITMAPFILEHEADER* pHeader = (BITMAPFILEHEADER*) vbuf;
|
BITMAPFILEHEADER* pHeader = (BITMAPFILEHEADER*) vbuf;
|
||||||
BITMAPINFO* pInfo;
|
BITMAPINFO* pInfo;
|
||||||
@ -328,18 +287,7 @@ bail:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MyDIBitmap::ImportTGA(void* vbuf, long len)
|
||||||
* Set up internal structures for the TGA file.
|
|
||||||
*
|
|
||||||
* We handle 16-, 24-, and 32-bit .TGA files only. They happen to use the
|
|
||||||
* same byte layout as BMP files, so we do very little work here. If we
|
|
||||||
* tried to write the raw data to a BMP file we could end up in trouble,
|
|
||||||
* because we don't force the "pitch must be multiple of 4 bytes" rule.
|
|
||||||
*
|
|
||||||
* On error, "vbuf" is discarded.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::ImportTGA(void* vbuf, long len)
|
|
||||||
{
|
{
|
||||||
TargaHeader targaHdr;
|
TargaHeader targaHdr;
|
||||||
unsigned char* hdr = (unsigned char*) vbuf;
|
unsigned char* hdr = (unsigned char*) vbuf;
|
||||||
@ -422,15 +370,7 @@ MyDIBitmap::ImportTGA(void* vbuf, long len)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MyDIBitmap::ConvertBufToDIBSection(void)
|
||||||
/*
|
|
||||||
* If the bitmap wasn't initially created as a DIB section, transform it now
|
|
||||||
* so the application can use it in GDI calls.
|
|
||||||
*
|
|
||||||
* Returns 0 on success, -1 on error.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::ConvertBufToDIBSection(void)
|
|
||||||
{
|
{
|
||||||
void* oldPixels = mpPixels;
|
void* oldPixels = mpPixels;
|
||||||
|
|
||||||
@ -478,13 +418,7 @@ MyDIBitmap::ConvertBufToDIBSection(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void* MyDIBitmap::CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc)
|
||||||
* Create the object from a resource embedded in the application.
|
|
||||||
*
|
|
||||||
* Use MAKEINTRESOURCE to load a resource by ordinal.
|
|
||||||
*/
|
|
||||||
void*
|
|
||||||
MyDIBitmap::CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc)
|
|
||||||
{
|
{
|
||||||
mhBitmap = (HBITMAP) ::LoadImage(hInstance, rsrc, IMAGE_BITMAP, 0, 0,
|
mhBitmap = (HBITMAP) ::LoadImage(hInstance, rsrc, IMAGE_BITMAP, 0, 0,
|
||||||
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION);
|
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION);
|
||||||
@ -539,7 +473,7 @@ MyDIBitmap::CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc)
|
|||||||
DWORD err = ::GetLastError();
|
DWORD err = ::GetLastError();
|
||||||
CString buf;
|
CString buf;
|
||||||
GetWin32ErrorString(err, &buf);
|
GetWin32ErrorString(err, &buf);
|
||||||
LOGI(" DIB GetDIBColorTable failed (err=0x%x '%ls')",
|
LOGW(" DIB GetDIBColorTable failed (err=0x%x '%ls')",
|
||||||
err, (LPCWSTR) buf);
|
err, (LPCWSTR) buf);
|
||||||
}
|
}
|
||||||
SelectObject(memDC, oldBits);
|
SelectObject(memDC, oldBits);
|
||||||
@ -587,12 +521,7 @@ bail:
|
|||||||
memcpy( m_pResourceBuffer, pvRes, dwSize );
|
memcpy( m_pResourceBuffer, pvRes, dwSize );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void MyDIBitmap::ClearPixels(void)
|
||||||
/*
|
|
||||||
* Zero out a bitmap's pixels. Does not touch the color table.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MyDIBitmap::ClearPixels(void)
|
|
||||||
{
|
{
|
||||||
assert(mpPixels != NULL);
|
assert(mpPixels != NULL);
|
||||||
|
|
||||||
@ -600,12 +529,7 @@ MyDIBitmap::ClearPixels(void)
|
|||||||
memset(mpPixels, 0, mPitchBytes * mHeight);
|
memset(mpPixels, 0, mPitchBytes * mHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyDIBitmap::SetColorTable(const RGBQUAD* pColorTable)
|
||||||
/*
|
|
||||||
* Set the values in the color table.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MyDIBitmap::SetColorTable(const RGBQUAD* pColorTable)
|
|
||||||
{
|
{
|
||||||
assert(pColorTable != NULL);
|
assert(pColorTable != NULL);
|
||||||
|
|
||||||
@ -627,14 +551,7 @@ MyDIBitmap::SetColorTable(const RGBQUAD* pColorTable)
|
|||||||
mColorTableInitialized = true;
|
mColorTableInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MyDIBitmap::GetTransparentColor(RGBQUAD* pColor) const
|
||||||
/*
|
|
||||||
* Retrieve the transparency color key, if any.
|
|
||||||
*
|
|
||||||
* Returns "false" if no color key has been set.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
MyDIBitmap::GetTransparentColor(RGBQUAD* pColor) const
|
|
||||||
{
|
{
|
||||||
if (mAlphaType != kAlphaTransparency)
|
if (mAlphaType != kAlphaTransparency)
|
||||||
return false;
|
return false;
|
||||||
@ -642,11 +559,7 @@ MyDIBitmap::GetTransparentColor(RGBQUAD* pColor) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MyDIBitmap::SetTransparentColor(const RGBQUAD* pColor)
|
||||||
* Set the transparent color. Changes the alpha mode to kAlphaTransparency.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MyDIBitmap::SetTransparentColor(const RGBQUAD* pColor)
|
|
||||||
{
|
{
|
||||||
if (mAlphaType == kAlphaFull) {
|
if (mAlphaType == kAlphaFull) {
|
||||||
LOGI(" NOTE: switching from full alpha to transparent-color alpha");
|
LOGI(" NOTE: switching from full alpha to transparent-color alpha");
|
||||||
@ -656,15 +569,7 @@ MyDIBitmap::SetTransparentColor(const RGBQUAD* pColor)
|
|||||||
mAlphaType = kAlphaTransparency;
|
mAlphaType = kAlphaTransparency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MyDIBitmap::LookupColor(const RGBQUAD* pRgbQuad)
|
||||||
/*
|
|
||||||
* Look up an RGB color in an indexed color table.
|
|
||||||
*
|
|
||||||
* Returns the index of the color, or -1 if not found (-2 on error, e.g. this
|
|
||||||
* isn't an indexed-color bitmap or the color table hasn't been created).
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::LookupColor(const RGBQUAD* pRgbQuad)
|
|
||||||
{
|
{
|
||||||
if (mBpp > 8) {
|
if (mBpp > 8) {
|
||||||
LOGI(" DIB LookupColor on %d-bit image", mBpp);
|
LOGI(" DIB LookupColor on %d-bit image", mBpp);
|
||||||
@ -688,14 +593,12 @@ MyDIBitmap::LookupColor(const RGBQUAD* pRgbQuad)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the RGB value of a single pixel in a bitmap.
|
* Return the RGB value of a single pixel in a bitmap.
|
||||||
*
|
*
|
||||||
* "rgbReserved" is always set to zero.
|
* "rgbReserved" is always set to zero.
|
||||||
*/
|
*/
|
||||||
void
|
void MyDIBitmap::GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const
|
||||||
MyDIBitmap::GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const
|
|
||||||
{
|
{
|
||||||
GetPixelRGBA(x, y, pRgbQuad);
|
GetPixelRGBA(x, y, pRgbQuad);
|
||||||
pRgbQuad->rgbReserved = 0;
|
pRgbQuad->rgbReserved = 0;
|
||||||
@ -706,8 +609,7 @@ MyDIBitmap::GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const
|
|||||||
*
|
*
|
||||||
* This sets rgbReserved appropriately for the current alpha mode.
|
* This sets rgbReserved appropriately for the current alpha mode.
|
||||||
*/
|
*/
|
||||||
void
|
void MyDIBitmap::GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const
|
||||||
MyDIBitmap::GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const
|
|
||||||
{
|
{
|
||||||
assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight);
|
assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight);
|
||||||
y = mHeight - y -1; // upside-down
|
y = mHeight - y -1; // upside-down
|
||||||
@ -799,8 +701,7 @@ MyDIBitmap::GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const
|
|||||||
*
|
*
|
||||||
* The "rgbReserved" channel is forced to zero.
|
* The "rgbReserved" channel is forced to zero.
|
||||||
*/
|
*/
|
||||||
void
|
void MyDIBitmap::SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad)
|
||||||
MyDIBitmap::SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad)
|
|
||||||
{
|
{
|
||||||
if (pRgbQuad->rgbReserved == 0) {
|
if (pRgbQuad->rgbReserved == 0) {
|
||||||
SetPixelRGBA(x, y, pRgbQuad);
|
SetPixelRGBA(x, y, pRgbQuad);
|
||||||
@ -816,8 +717,7 @@ MyDIBitmap::SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad)
|
|||||||
*
|
*
|
||||||
* For index-color bitmaps, this requires a (slow) table lookup.
|
* For index-color bitmaps, this requires a (slow) table lookup.
|
||||||
*/
|
*/
|
||||||
void
|
void MyDIBitmap::SetPixelRGBA(int x, int y, const RGBQUAD* pRgbQuad)
|
||||||
MyDIBitmap::SetPixelRGBA(int x, int y, const RGBQUAD* pRgbQuad)
|
|
||||||
{
|
{
|
||||||
assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight);
|
assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight);
|
||||||
y = mHeight - y -1; // upside-down
|
y = mHeight - y -1; // upside-down
|
||||||
@ -854,8 +754,7 @@ MyDIBitmap::SetPixelRGBA(int x, int y, const RGBQUAD* pRgbQuad)
|
|||||||
*
|
*
|
||||||
* Only works on indexed-color formats (8bpp or less).
|
* Only works on indexed-color formats (8bpp or less).
|
||||||
*/
|
*/
|
||||||
void
|
void MyDIBitmap::GetPixelIndex(int x, int y, int* pIdx) const
|
||||||
MyDIBitmap::GetPixelIndex(int x, int y, int* pIdx) const
|
|
||||||
{
|
{
|
||||||
assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight);
|
assert(x >= 0 && x < mWidth && y >= 0 && y < mHeight);
|
||||||
y = mHeight - y -1; // upside-down
|
y = mHeight - y -1; // upside-down
|
||||||
@ -881,8 +780,7 @@ MyDIBitmap::GetPixelIndex(int x, int y, int* pIdx) const
|
|||||||
/*
|
/*
|
||||||
* Set the index value of a pixel in an indexed-color bitmap (8bpp or less).
|
* Set the index value of a pixel in an indexed-color bitmap (8bpp or less).
|
||||||
*/
|
*/
|
||||||
void
|
void MyDIBitmap::SetPixelIndex(int x, int y, int idx)
|
||||||
MyDIBitmap::SetPixelIndex(int x, int y, int idx)
|
|
||||||
{
|
{
|
||||||
if (x < 0 || x >= mWidth || y < 0 || y >= mHeight) {
|
if (x < 0 || x >= mWidth || y < 0 || y >= mHeight) {
|
||||||
LOGI("BAD x=%d y=%d idx=%d", x, y, idx);
|
LOGI("BAD x=%d y=%d idx=%d", x, y, idx);
|
||||||
@ -911,38 +809,29 @@ MyDIBitmap::SetPixelIndex(int x, int y, int idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ bool MyDIBitmap::Blit(MyDIBitmap* pDstBits, const RECT* pDstRect,
|
||||||
/*
|
|
||||||
* Blit a block of pixels from one bitmap to another.
|
|
||||||
*
|
|
||||||
* The bitmaps must share a common format, and the rectangles must be the
|
|
||||||
* same size. We could implement color conversion and resizing here, but
|
|
||||||
* for now let's not.
|
|
||||||
*/
|
|
||||||
/*static*/ bool
|
|
||||||
MyDIBitmap::Blit(MyDIBitmap* pDstBits, const RECT* pDstRect,
|
|
||||||
const MyDIBitmap* pSrcBits, const RECT* pSrcRect)
|
const MyDIBitmap* pSrcBits, const RECT* pSrcRect)
|
||||||
{
|
{
|
||||||
if (pDstRect->right - pDstRect->left !=
|
if (pDstRect->right - pDstRect->left !=
|
||||||
pSrcRect->right - pSrcRect->left)
|
pSrcRect->right - pSrcRect->left)
|
||||||
{
|
{
|
||||||
LOGI("DIB blit: widths differ");
|
LOGW("DIB blit: widths differ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pDstRect->bottom - pDstRect->top !=
|
if (pDstRect->bottom - pDstRect->top !=
|
||||||
pSrcRect->bottom - pSrcRect->top)
|
pSrcRect->bottom - pSrcRect->top)
|
||||||
{
|
{
|
||||||
LOGI("DIB blit: heights differ");
|
LOGW("DIB blit: heights differ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pSrcBits->mBpp != pDstBits->mBpp) {
|
if (pSrcBits->mBpp != pDstBits->mBpp) {
|
||||||
LOGI("DIB blit: different formats");
|
LOGW("DIB blit: different formats");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pDstRect->right <= pDstRect->left ||
|
if (pDstRect->right <= pDstRect->left ||
|
||||||
pDstRect->bottom <= pDstRect->top)
|
pDstRect->bottom <= pDstRect->top)
|
||||||
{
|
{
|
||||||
LOGI("DIB blit: poorly formed rect");
|
LOGW("DIB blit: poorly formed rect");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,18 +877,7 @@ MyDIBitmap::Blit(MyDIBitmap* pDstBits, const RECT* pDstRect,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HBITMAP MyDIBitmap::ConvertToDDB(HDC dc) const
|
||||||
/*
|
|
||||||
* Create a DDB from the current bitmap in the specified DC, and return its
|
|
||||||
* handle. The returned handle must eventually be disposed with DeleteObject.
|
|
||||||
*
|
|
||||||
* Since we're just supplying pointers to various pieces of data, there's no
|
|
||||||
* need for us to have a DIB section.
|
|
||||||
*
|
|
||||||
* Returns NULL on failure.
|
|
||||||
*/
|
|
||||||
HBITMAP
|
|
||||||
MyDIBitmap::ConvertToDDB(HDC dc) const
|
|
||||||
{
|
{
|
||||||
HBITMAP hBitmap = NULL;
|
HBITMAP hBitmap = NULL;
|
||||||
|
|
||||||
@ -1079,13 +957,7 @@ MyDIBitmap::ConvertToDDB(HDC dc) const
|
|||||||
return hBitmap;
|
return hBitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MyDIBitmap::WriteToFile(const WCHAR* fileName) const
|
||||||
/*
|
|
||||||
* Write the bitmap to the named file. Opens the file and calls the FILE*
|
|
||||||
* function.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::WriteToFile(const WCHAR* fileName) const
|
|
||||||
{
|
{
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
int err;
|
int err;
|
||||||
@ -1104,15 +976,7 @@ MyDIBitmap::WriteToFile(const WCHAR* fileName) const
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int MyDIBitmap::WriteToFile(FILE* fp) const
|
||||||
* Write the bitmap to a file.
|
|
||||||
*
|
|
||||||
* Pass in an open, seeked file pointer (make sure to use "wb" mode).
|
|
||||||
*
|
|
||||||
* Returns 0 on success, or nonzero (errno) on failure.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
MyDIBitmap::WriteToFile(FILE* fp) const
|
|
||||||
{
|
{
|
||||||
BITMAPFILEHEADER fileHeader;
|
BITMAPFILEHEADER fileHeader;
|
||||||
long pixelBufSize;
|
long pixelBufSize;
|
||||||
|
@ -58,33 +58,84 @@ public:
|
|||||||
{
|
{
|
||||||
memset(&mBitmapInfoHdr, 0, sizeof(mBitmapInfoHdr));
|
memset(&mBitmapInfoHdr, 0, sizeof(mBitmapInfoHdr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroys allocated memory and delete the DIB object.
|
||||||
|
*/
|
||||||
virtual ~MyDIBitmap(void);
|
virtual ~MyDIBitmap(void);
|
||||||
|
|
||||||
// create an empty bitmap with the specified characteristics; returns a
|
/*
|
||||||
// pointer to the pixel storage
|
* Creates a blank DIB with the requested dimensions.
|
||||||
|
*
|
||||||
|
* Returns a pointer to the pixel storage on success, or NULL on failure.
|
||||||
|
*/
|
||||||
void* Create(int width, int height, int bitsPerPixel, int colorsUsed,
|
void* Create(int width, int height, int bitsPerPixel, int colorsUsed,
|
||||||
bool dibSection = false);
|
bool dibSection = false);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the values in the color table.
|
||||||
|
*/
|
||||||
void SetColorTable(const RGBQUAD* pColorTable);
|
void SetColorTable(const RGBQUAD* pColorTable);
|
||||||
|
|
||||||
const RGBQUAD* GetColorTable(void) const { return mpColorTable; }
|
const RGBQUAD* GetColorTable(void) const { return mpColorTable; }
|
||||||
|
|
||||||
// zero out the pixels
|
/*
|
||||||
|
* Zero out a bitmap's pixels. Does not touch the color table.
|
||||||
|
*/
|
||||||
void ClearPixels(void);
|
void ClearPixels(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a DDB from the current bitmap in the specified DC, and return its
|
||||||
|
* handle. The returned handle must eventually be disposed with DeleteObject.
|
||||||
|
*
|
||||||
|
* Since we're just supplying pointers to various pieces of data, there's no
|
||||||
|
* need for us to have a DIB section.
|
||||||
|
*
|
||||||
|
* Returns NULL on failure.
|
||||||
|
*/
|
||||||
HBITMAP ConvertToDDB(HDC dc) const;
|
HBITMAP ConvertToDDB(HDC dc) const;
|
||||||
|
|
||||||
// create a DIB from a file on disk
|
/*
|
||||||
|
* Opens the file and call the FILE* version.
|
||||||
|
*/
|
||||||
int CreateFromFile(const WCHAR* fileName);
|
int CreateFromFile(const WCHAR* fileName);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a DIB by reading a BMP or TGA file into memory.
|
||||||
|
*/
|
||||||
int CreateFromFile(FILE* fp, long len);
|
int CreateFromFile(FILE* fp, long len);
|
||||||
// create from memory buffer; set "doDelete" if object should own mem
|
|
||||||
// (if "doDelete" is set, memory will be deleted if function fails)
|
/*
|
||||||
// contents of buffer will be analyzed to determine file type
|
* Creates object from a copy of the file in memory. Set "doDelete" to
|
||||||
|
* transfer ownership of object.
|
||||||
|
*
|
||||||
|
* We want to hang on to the data buffer, but if we don't own it then we
|
||||||
|
* have to make a copy.
|
||||||
|
*
|
||||||
|
* If "doDelete" is set, memory will be deleted if function fails.
|
||||||
|
*/
|
||||||
int CreateFromBuffer(void* buffer, long len, bool doDelete);
|
int CreateFromBuffer(void* buffer, long len, bool doDelete);
|
||||||
|
|
||||||
// create a DIB from an embedded resource
|
/*
|
||||||
|
* Creates the object from a resource embedded in the application.
|
||||||
|
*
|
||||||
|
* Use MAKEINTRESOURCE to load a resource by ordinal.
|
||||||
|
*/
|
||||||
void* CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc);
|
void* CreateFromResource(HINSTANCE hInstance, const WCHAR* rsrc);
|
||||||
|
|
||||||
// write bitmap to file (for FILE*, make sure it's open in "wb" mode)
|
/*
|
||||||
|
* Write the bitmap to the named file. Opens the file and calls the FILE*
|
||||||
|
* function.
|
||||||
|
*/
|
||||||
int WriteToFile(const WCHAR* fileName) const;
|
int WriteToFile(const WCHAR* fileName) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Write the bitmap to a file.
|
||||||
|
*
|
||||||
|
* Pass in an open, seeked file pointer (make sure to use "wb" mode).
|
||||||
|
*
|
||||||
|
* Returns 0 on success, or nonzero (errno) on failure.
|
||||||
|
*/
|
||||||
int WriteToFile(FILE* fp) const;
|
int WriteToFile(FILE* fp) const;
|
||||||
|
|
||||||
// simple getters
|
// simple getters
|
||||||
@ -95,16 +146,30 @@ public:
|
|||||||
|
|
||||||
// retrieve current alpha mode
|
// retrieve current alpha mode
|
||||||
AlphaType GetAlphaType(void) const { return mAlphaType; }
|
AlphaType GetAlphaType(void) const { return mAlphaType; }
|
||||||
// get transparent color; returns "false" if none has been set
|
|
||||||
|
/*
|
||||||
|
* Retrieve the transparency color key, if any.
|
||||||
|
*
|
||||||
|
* Returns "false" if no color key has been set.
|
||||||
|
*/
|
||||||
bool GetTransparentColor(RGBQUAD* pColor) const;
|
bool GetTransparentColor(RGBQUAD* pColor) const;
|
||||||
// set transparent color and change alpha to kAlphaTransparency
|
|
||||||
|
/*
|
||||||
|
* Set the transparent color. Changes the alpha mode to kAlphaTransparency.
|
||||||
|
*/
|
||||||
void SetTransparentColor(const RGBQUAD* pColor);
|
void SetTransparentColor(const RGBQUAD* pColor);
|
||||||
|
|
||||||
// return the index of the specified color (-1 if not found, -2 on err)
|
/*
|
||||||
|
* Look up an RGB color in an indexed color table.
|
||||||
|
*
|
||||||
|
* Returns the index of the color, or -1 if not found (-2 on error, e.g. this
|
||||||
|
* isn't an indexed-color bitmap or the color table hasn't been created).
|
||||||
|
*/
|
||||||
int LookupColor(const RGBQUAD* pRgbQuad);
|
int LookupColor(const RGBQUAD* pRgbQuad);
|
||||||
|
|
||||||
// set/get individual pixel values; the "RGB" functions always set
|
// set/get individual pixel values; the "RGB" functions always set
|
||||||
// alpha to zero, while "RGBA" follow the current alpha mode
|
// alpha to zero, while "RGBA" follow the current alpha mode
|
||||||
|
|
||||||
void FASTCALL GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const;
|
void FASTCALL GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const;
|
||||||
void FASTCALL SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad);
|
void FASTCALL SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad);
|
||||||
void FASTCALL GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const;
|
void FASTCALL GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const;
|
||||||
@ -125,7 +190,13 @@ public:
|
|||||||
|
|
||||||
int GetPitch(void) const { return mPitchBytes; }
|
int GetPitch(void) const { return mPitchBytes; }
|
||||||
|
|
||||||
// Blit pixels from one bitmap to another.
|
/*
|
||||||
|
* Blit a block of pixels from one bitmap to another.
|
||||||
|
*
|
||||||
|
* The bitmaps must share a common format, and the rectangles must be the
|
||||||
|
* same size. We could implement color conversion and resizing here, but
|
||||||
|
* for now let's not.
|
||||||
|
*/
|
||||||
static bool Blit(MyDIBitmap* pDstBits, const RECT* pDstRect,
|
static bool Blit(MyDIBitmap* pDstBits, const RECT* pDstRect,
|
||||||
const MyDIBitmap* pSrcBits, const RECT* pSrcRect);
|
const MyDIBitmap* pSrcBits, const RECT* pSrcRect);
|
||||||
|
|
||||||
@ -152,9 +223,43 @@ private:
|
|||||||
kTargaUnmappedRGB = 2, // for imageType field
|
kTargaUnmappedRGB = 2, // for imageType field
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up internal structures for the BMP file.
|
||||||
|
*
|
||||||
|
* On error, "vbuf" is discarded.
|
||||||
|
*/
|
||||||
int ImportBMP(void* vbuf, long len);
|
int ImportBMP(void* vbuf, long len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up internal structures for the TGA file.
|
||||||
|
*
|
||||||
|
* We handle 16-, 24-, and 32-bit .TGA files only. They happen to use the
|
||||||
|
* same byte layout as BMP files, so we do very little work here. If we
|
||||||
|
* tried to write the raw data to a BMP file we could end up in trouble,
|
||||||
|
* because we don't force the "pitch must be multiple of 4 bytes" rule.
|
||||||
|
*
|
||||||
|
* On error, "vbuf" is discarded.
|
||||||
|
*/
|
||||||
int ImportTGA(void* vbuf, long len);
|
int ImportTGA(void* vbuf, long len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the bitmap wasn't initially created as a DIB section, transform it now
|
||||||
|
* so the application can use it in GDI calls.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, -1 on error.
|
||||||
|
*/
|
||||||
int ConvertBufToDIBSection(void);
|
int ConvertBufToDIBSection(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create object from a buffer of new[]-created memory that we own.
|
||||||
|
*
|
||||||
|
* The memory will be discarded if this function fails.
|
||||||
|
*
|
||||||
|
* We don't want to create a DIB section if the eventual user of this data
|
||||||
|
* doesn't need it (e.g. it's just getting converted into a 3D texture
|
||||||
|
* without using any GDI calls), so we just leave the pixels in the file
|
||||||
|
* buffer for now.
|
||||||
|
*/
|
||||||
int CreateFromNewBuffer(void* vbuf, long len);
|
int CreateFromNewBuffer(void* vbuf, long len);
|
||||||
|
|
||||||
BITMAPINFOHEADER mBitmapInfoHdr;
|
BITMAPINFOHEADER mBitmapInfoHdr;
|
||||||
|
@ -18,8 +18,7 @@
|
|||||||
*
|
*
|
||||||
* Returns TRUE on success, FALSE on failure.
|
* Returns TRUE on success, FALSE on failure.
|
||||||
*/
|
*/
|
||||||
BOOL
|
BOOL MyEdit::ReplaceDlgCtrl(CDialog* pDialog, int editID)
|
||||||
MyEdit::ReplaceDlgCtrl(CDialog* pDialog, int editID)
|
|
||||||
{
|
{
|
||||||
CWnd* pWnd = pDialog->GetDlgItem(editID);
|
CWnd* pWnd = pDialog->GetDlgItem(editID);
|
||||||
if (pWnd == NULL)
|
if (pWnd == NULL)
|
||||||
@ -34,20 +33,17 @@ MyEdit::ReplaceDlgCtrl(CDialog* pDialog, int editID)
|
|||||||
/*
|
/*
|
||||||
* Set the properties that make us special.
|
* Set the properties that make us special.
|
||||||
*/
|
*/
|
||||||
void
|
void MyEdit::SetProperties(int props)
|
||||||
MyEdit::SetProperties(int props)
|
|
||||||
{
|
{
|
||||||
fCapsOnly = (props & kCapsOnly) != 0;
|
fCapsOnly = (props & kCapsOnly) != 0;
|
||||||
fHexOnly = (props & kHexOnly) != 0;
|
fHexOnly = (props & kHexOnly) != 0;
|
||||||
fNoWhiteSpace = (props & kNoWhiteSpace) != 0;
|
fNoWhiteSpace = (props & kNoWhiteSpace) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Special keypress handling.
|
* Special keypress handling.
|
||||||
*/
|
*/
|
||||||
BOOL
|
BOOL MyEdit::PreTranslateMessage(MSG* pMsg)
|
||||||
MyEdit::PreTranslateMessage(MSG* pMsg)
|
|
||||||
{
|
{
|
||||||
if (pMsg->message == WM_CHAR) {
|
if (pMsg->message == WM_CHAR) {
|
||||||
if (fCapsOnly)
|
if (fCapsOnly)
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
virtual BOOL ReplaceDlgCtrl(CDialog* pDialog, int editID);
|
virtual BOOL ReplaceDlgCtrl(CDialog* pDialog, int editID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
virtual BOOL PreTranslateMessage(MSG* pMsg) override;
|
||||||
|
|
||||||
bool fCapsOnly;
|
bool fCapsOnly;
|
||||||
bool fHexOnly;
|
bool fHexOnly;
|
||||||
|
@ -37,13 +37,7 @@ void MySpinCtrl::PreSubclassWindow()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
bool MySpinCtrl::ConvLong(const WCHAR* str, long* pVal) const
|
||||||
* Convert a decimal or hex string to a long.
|
|
||||||
*
|
|
||||||
* Returns "true" on success, "false" on error.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
MySpinCtrl::ConvLong(const WCHAR* str, long* pVal) const
|
|
||||||
{
|
{
|
||||||
WCHAR* endp;
|
WCHAR* endp;
|
||||||
|
|
||||||
@ -57,8 +51,7 @@ MySpinCtrl::ConvLong(const WCHAR* str, long* pVal) const
|
|||||||
/*
|
/*
|
||||||
* Handle UDN_DELTAPOS notification.
|
* Handle UDN_DELTAPOS notification.
|
||||||
*/
|
*/
|
||||||
void
|
void MySpinCtrl::OnDeltaPos(NMHDR* pNMHDR, LRESULT* pResult)
|
||||||
MySpinCtrl::OnDeltaPos(NMHDR* pNMHDR, LRESULT* pResult)
|
|
||||||
{
|
{
|
||||||
_ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked");
|
_ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked");
|
||||||
// _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked");
|
// _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked");
|
||||||
@ -101,8 +94,7 @@ bail:
|
|||||||
*
|
*
|
||||||
* Returns the previous position.
|
* Returns the previous position.
|
||||||
*/
|
*/
|
||||||
int
|
int MySpinCtrl::SetPos(int nPos)
|
||||||
MySpinCtrl::SetPos(int nPos)
|
|
||||||
{
|
{
|
||||||
_ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked");
|
_ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked");
|
||||||
// _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked");
|
// _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked");
|
||||||
@ -129,8 +121,7 @@ MySpinCtrl::SetPos(int nPos)
|
|||||||
*
|
*
|
||||||
* Returns -1 on error. Yes, that's bogus, but it's good enough for now.
|
* Returns -1 on error. Yes, that's bogus, but it's good enough for now.
|
||||||
*/
|
*/
|
||||||
int
|
int MySpinCtrl::GetPos() const
|
||||||
MySpinCtrl::GetPos() const
|
|
||||||
{
|
{
|
||||||
_ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked");
|
_ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked");
|
||||||
// _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked");
|
// _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked");
|
||||||
@ -158,8 +149,7 @@ MySpinCtrl::GetPos() const
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD
|
DWORD MySpinCtrl::GetRange(void) const
|
||||||
MySpinCtrl::GetRange(void) const
|
|
||||||
{
|
{
|
||||||
_ASSERTE(! "Do NOT use this method!");
|
_ASSERTE(! "Do NOT use this method!");
|
||||||
return 0;
|
return 0;
|
||||||
@ -168,8 +158,7 @@ MySpinCtrl::GetRange(void) const
|
|||||||
/*
|
/*
|
||||||
* Get 32-bit ranges.
|
* Get 32-bit ranges.
|
||||||
*/
|
*/
|
||||||
void
|
void MySpinCtrl::GetRange32(int& lower, int& upper) const
|
||||||
MySpinCtrl::GetRange32(int& lower, int& upper) const
|
|
||||||
{
|
{
|
||||||
lower = fLow;
|
lower = fLow;
|
||||||
upper = fHigh;
|
upper = fHigh;
|
||||||
@ -179,8 +168,7 @@ MySpinCtrl::GetRange32(int& lower, int& upper) const
|
|||||||
/*
|
/*
|
||||||
* Set 32-bit ranges.
|
* Set 32-bit ranges.
|
||||||
*/
|
*/
|
||||||
void
|
void MySpinCtrl::SetRange32(int nLo, int nHi)
|
||||||
MySpinCtrl::SetRange32(int nLo, int nHi)
|
|
||||||
{
|
{
|
||||||
_ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked");
|
_ASSERTE(! (UDS_SETBUDDYINT & GetStyle()) && "'Auto Buddy Int' style *MUST* be unchecked");
|
||||||
// _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked");
|
// _ASSERTE( (UDS_AUTOBUDDY & GetStyle()) && "'Auto Buddy' style *MUST* be checked");
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
MySpinCtrl(void) : fLow(0), fHigh(100) {}
|
MySpinCtrl(void) : fLow(0), fHigh(100) {}
|
||||||
virtual ~MySpinCtrl(void) {}
|
virtual ~MySpinCtrl(void) {}
|
||||||
|
|
||||||
// override original methods (AFXCMN.H)
|
// replacements for superclass methods (AFXCMN.H)
|
||||||
int SetPos(int nPos);
|
int SetPos(int nPos);
|
||||||
int GetPos() const;
|
int GetPos() const;
|
||||||
void SetRange(int nLower, int nUpper) { SetRange32(nLower, nUpper); }
|
void SetRange(int nLower, int nUpper) { SetRange32(nLower, nUpper); }
|
||||||
@ -42,6 +42,11 @@ protected:
|
|||||||
private:
|
private:
|
||||||
int fLow, fHigh;
|
int fLow, fHigh;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a decimal or hex string to a long.
|
||||||
|
*
|
||||||
|
* Returns "true" on success, "false" on error.
|
||||||
|
*/
|
||||||
bool ConvLong(const WCHAR* str, long* pVal) const;
|
bool ConvLong(const WCHAR* str, long* pVal) const;
|
||||||
|
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
|
@ -38,15 +38,7 @@
|
|||||||
|
|
||||||
#define kFilenameExtDelim '.' /* separates extension from filename */
|
#define kFilenameExtDelim '.' /* separates extension from filename */
|
||||||
|
|
||||||
/*
|
const WCHAR* PathName::FilenameOnly(const WCHAR* pathname, WCHAR fssep)
|
||||||
* Find the filename component of a local pathname. Uses the fssep passed
|
|
||||||
* in. If the fssep is '\0' (as is the case for DOS 3.3), then the entire
|
|
||||||
* pathname is returned.
|
|
||||||
*
|
|
||||||
* Always returns a pointer to a string; never returns NULL.
|
|
||||||
*/
|
|
||||||
const WCHAR*
|
|
||||||
PathName::FilenameOnly(const WCHAR* pathname, WCHAR fssep)
|
|
||||||
{
|
{
|
||||||
const WCHAR* retstr;
|
const WCHAR* retstr;
|
||||||
const WCHAR* pSlash;
|
const WCHAR* pSlash;
|
||||||
@ -99,19 +91,7 @@ bail:
|
|||||||
return retstr;
|
return retstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
const WCHAR* PathName::FindExtension(const WCHAR* pathname, WCHAR fssep)
|
||||||
* Return the filename extension found in a full pathname.
|
|
||||||
*
|
|
||||||
* An extension is the stuff following the last '.' in the filename. If
|
|
||||||
* there is nothing following the last '.', then there is no extension.
|
|
||||||
*
|
|
||||||
* Returns a pointer to the '.' preceding the extension, or NULL if no
|
|
||||||
* extension was found.
|
|
||||||
*
|
|
||||||
* We guarantee that there is at least one character after the '.'.
|
|
||||||
*/
|
|
||||||
const WCHAR*
|
|
||||||
PathName::FindExtension(const WCHAR* pathname, WCHAR fssep)
|
|
||||||
{
|
{
|
||||||
const WCHAR* pFilename;
|
const WCHAR* pFilename;
|
||||||
const WCHAR* pExt;
|
const WCHAR* pExt;
|
||||||
@ -131,13 +111,7 @@ PathName::FindExtension(const WCHAR* pathname, WCHAR fssep)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CString PathName::GetFileName(void)
|
||||||
|
|
||||||
/*
|
|
||||||
* Get just the file name.
|
|
||||||
*/
|
|
||||||
CString
|
|
||||||
PathName::GetFileName(void)
|
|
||||||
{
|
{
|
||||||
CString str;
|
CString str;
|
||||||
|
|
||||||
@ -157,22 +131,14 @@ PathName::GetFileName(void)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
CString PathName::GetDriveOnly(void)
|
||||||
* Get just the drive name.
|
|
||||||
*/
|
|
||||||
CString
|
|
||||||
PathName::GetDriveOnly(void)
|
|
||||||
{
|
{
|
||||||
SplitIFN();
|
SplitIFN();
|
||||||
|
|
||||||
return fDrive;
|
return fDrive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
CString PathName::GetDriveAndPath(void)
|
||||||
* Get directory names, prefixed with the drive.
|
|
||||||
*/
|
|
||||||
CString
|
|
||||||
PathName::GetDriveAndPath(void)
|
|
||||||
{
|
{
|
||||||
CString str;
|
CString str;
|
||||||
|
|
||||||
@ -183,22 +149,14 @@ PathName::GetDriveAndPath(void)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
CString PathName::GetPathOnly(void)
|
||||||
* Get just the directory names.
|
|
||||||
*/
|
|
||||||
CString
|
|
||||||
PathName::GetPathOnly(void)
|
|
||||||
{
|
{
|
||||||
SplitIFN();
|
SplitIFN();
|
||||||
|
|
||||||
return fDir;
|
return fDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
CString PathName::GetExtension(void)
|
||||||
* Get just the extension.
|
|
||||||
*/
|
|
||||||
CString
|
|
||||||
PathName::GetExtension(void)
|
|
||||||
{
|
{
|
||||||
SplitIFN();
|
SplitIFN();
|
||||||
|
|
||||||
@ -216,13 +174,7 @@ PathName::GetExtension(void)
|
|||||||
return fExt;
|
return fExt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int PathName::SFNToLFN(void)
|
||||||
* Expand the short file name of an existing file into its long form.
|
|
||||||
*
|
|
||||||
* Returns 0 on success, -1 on failure.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PathName::SFNToLFN(void)
|
|
||||||
{
|
{
|
||||||
WCHAR buf[MAX_PATH];
|
WCHAR buf[MAX_PATH];
|
||||||
WIN32_FIND_DATA findFileData;
|
WIN32_FIND_DATA findFileData;
|
||||||
@ -310,11 +262,7 @@ PathName::SFNToLFN(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
CString PathName::GetDescription()
|
||||||
* Return the description of the file type.
|
|
||||||
*/
|
|
||||||
CString
|
|
||||||
PathName::GetDescription()
|
|
||||||
{
|
{
|
||||||
CString szTypeName;
|
CString szTypeName;
|
||||||
SHFILEINFO sfi = { 0 };
|
SHFILEINFO sfi = { 0 };
|
||||||
@ -326,21 +274,14 @@ PathName::GetDescription()
|
|||||||
return szTypeName;
|
return szTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
bool PathName::Exists(void)
|
||||||
* Check to see if the file exists.
|
|
||||||
*
|
|
||||||
* If we use something simple like access(), we will catch all files including
|
|
||||||
* the ones in Network Neighborhood. Using the FindFirstFile stuff avoids
|
|
||||||
* the problem, but raises the difficulty of being unable to find simple
|
|
||||||
* things like "D:\".
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
PathName::Exists(void)
|
|
||||||
{
|
{
|
||||||
// if (strncmp(fPathName, "\\\\", 2) == 0) {
|
/*
|
||||||
// LOGI("Refusing to check for network path '%ls'", fPathName);
|
* If we use something simple like access(), we will catch all files including
|
||||||
// return false;
|
* the ones in Network Neighborhood. Using the FindFirstFile stuff avoids
|
||||||
// }
|
* the problem, but raises the difficulty of being unable to find simple
|
||||||
|
* things like "D:\".
|
||||||
|
*/
|
||||||
|
|
||||||
return (::_waccess(fPathName, 0) != -1);
|
return (::_waccess(fPathName, 0) != -1);
|
||||||
|
|
||||||
@ -409,11 +350,7 @@ with
|
|||||||
----------------------
|
----------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
int PathName::Mkdir(const WCHAR* dir)
|
||||||
* Invoke the system-dependent directory creation function.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PathName::Mkdir(const WCHAR* dir)
|
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
@ -425,16 +362,7 @@ PathName::Mkdir(const WCHAR* dir)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int PathName::GetFileInfo(const WCHAR* pathname, struct _stat* psb,
|
||||||
* Determine if a file exists, and if so whether or not it's a directory.
|
|
||||||
*
|
|
||||||
* Set fields you're not interested in to NULL.
|
|
||||||
*
|
|
||||||
* On success, returns 0 and fields are set appropriately. On failure,
|
|
||||||
* returns nonzero and result values are undefined.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PathName::GetFileInfo(const WCHAR* pathname, struct _stat* psb,
|
|
||||||
time_t* pModWhen, bool* pExists, bool* pIsReadable, bool* pIsDirectory)
|
time_t* pModWhen, bool* pExists, bool* pIsReadable, bool* pIsDirectory)
|
||||||
{
|
{
|
||||||
struct _stat sbuf;
|
struct _stat sbuf;
|
||||||
@ -494,21 +422,13 @@ PathName::GetFileInfo(const WCHAR* pathname, struct _stat* psb,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int PathName::CheckFileStatus(struct _stat* psb, bool* pExists, bool* pIsReadable,
|
||||||
* Check the status of a file.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PathName::CheckFileStatus(struct _stat* psb, bool* pExists, bool* pIsReadable,
|
|
||||||
bool* pIsDir)
|
bool* pIsDir)
|
||||||
{
|
{
|
||||||
return GetFileInfo(fPathName, psb, NULL, pExists, pIsReadable, pIsDir);
|
return GetFileInfo(fPathName, psb, NULL, pExists, pIsReadable, pIsDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
time_t PathName::GetModWhen(void)
|
||||||
* Get the modification date of a file.
|
|
||||||
*/
|
|
||||||
time_t
|
|
||||||
PathName::GetModWhen(void)
|
|
||||||
{
|
{
|
||||||
time_t when;
|
time_t when;
|
||||||
|
|
||||||
@ -518,11 +438,7 @@ PathName::GetModWhen(void)
|
|||||||
return when;
|
return when;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int PathName::SetModWhen(time_t when)
|
||||||
* Set the modification date on a file.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PathName::SetModWhen(time_t when)
|
|
||||||
{
|
{
|
||||||
struct _utimbuf utbuf;
|
struct _utimbuf utbuf;
|
||||||
|
|
||||||
@ -539,16 +455,7 @@ PathName::SetModWhen(time_t when)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int PathName::CreateSubdirIFN(const WCHAR* pathStart, const WCHAR* pathEnd,
|
||||||
* Create a single subdirectory if it doesn't exist. If the next-highest
|
|
||||||
* subdirectory level doesn't exist either, cut down the pathname and
|
|
||||||
* recurse.
|
|
||||||
*
|
|
||||||
* "pathEnd" points at the last valid character. The length of the valid
|
|
||||||
* path component is therefore (pathEnd-pathStart+1).
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PathName::CreateSubdirIFN(const WCHAR* pathStart, const WCHAR* pathEnd,
|
|
||||||
WCHAR fssep)
|
WCHAR fssep)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -597,17 +504,7 @@ bail:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int PathName::CreatePathIFN(void)
|
||||||
* Create subdirectories, if needed. The paths leading up to the filename
|
|
||||||
* in "pathname" will be created.
|
|
||||||
*
|
|
||||||
* If "pathname" is just a filename, or the set of directories matches
|
|
||||||
* the last directory we created, we don't do anything.
|
|
||||||
*
|
|
||||||
* Returns 0 on success, or a Windows error code on failure.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PathName::CreatePathIFN(void)
|
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
CString pathName(fPathName);
|
CString pathName(fPathName);
|
||||||
|
@ -72,12 +72,13 @@ public:
|
|||||||
CString GetDriveAndPath(void);
|
CString GetDriveAndPath(void);
|
||||||
CString GetPathOnly(void);
|
CString GetPathOnly(void);
|
||||||
|
|
||||||
// try to normalize a short name into a long name
|
/*
|
||||||
|
* Expand the short file name of an existing file into its long form.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, -1 on failure.
|
||||||
|
*/
|
||||||
int SFNToLFN(void);
|
int SFNToLFN(void);
|
||||||
|
|
||||||
/*
|
|
||||||
* File manipulations.
|
|
||||||
*/
|
|
||||||
// returns the description of the file type (as seen in explorer)
|
// returns the description of the file type (as seen in explorer)
|
||||||
CString GetDescription(void);
|
CString GetDescription(void);
|
||||||
|
|
||||||
@ -93,12 +94,38 @@ public:
|
|||||||
// set the modification date
|
// set the modification date
|
||||||
int SetModWhen(time_t when);
|
int SetModWhen(time_t when);
|
||||||
|
|
||||||
// create the path, if necessary
|
/*
|
||||||
|
* Create subdirectories, if needed. The paths leading up to the filename
|
||||||
|
* in "pathname" will be created.
|
||||||
|
*
|
||||||
|
* If "pathname" is just a filename, or the set of directories matches
|
||||||
|
* the last directory we created, we don't do anything.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, or a Windows error code on failure.
|
||||||
|
*/
|
||||||
int CreatePathIFN(void);
|
int CreatePathIFN(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the filename extension found in a full pathname.
|
||||||
|
*
|
||||||
|
* An extension is the stuff following the last '.' in the filename. If
|
||||||
|
* there is nothing following the last '.', then there is no extension.
|
||||||
|
*
|
||||||
|
* Returns a pointer to the '.' preceding the extension, or NULL if no
|
||||||
|
* extension was found.
|
||||||
|
*
|
||||||
|
* We guarantee that there is at least one character after the '.'.
|
||||||
|
*/
|
||||||
static const WCHAR* FindExtension(const WCHAR* pathname, WCHAR fssep);
|
static const WCHAR* FindExtension(const WCHAR* pathname, WCHAR fssep);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find the filename component of a local pathname. Uses the fssep passed
|
||||||
|
* in. If the fssep is '\0' (as is the case for DOS 3.3), then the entire
|
||||||
|
* pathname is returned.
|
||||||
|
*
|
||||||
|
* Always returns a pointer to a string; never returns NULL.
|
||||||
|
*/
|
||||||
static const WCHAR* FilenameOnly(const WCHAR* pathname, WCHAR fssep);
|
static const WCHAR* FilenameOnly(const WCHAR* pathname, WCHAR fssep);
|
||||||
//int SFNToLFN(const char* sfn, CString* pLfn);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SplitIFN(void) {
|
void SplitIFN(void) {
|
||||||
@ -107,9 +134,31 @@ private:
|
|||||||
fSplit = true;
|
fSplit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Invoke the system-dependent directory creation function.
|
||||||
|
*/
|
||||||
int Mkdir(const WCHAR* dir);
|
int Mkdir(const WCHAR* dir);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine if a file exists, and if so whether or not it's a directory.
|
||||||
|
*
|
||||||
|
* Set fields you're not interested in to NULL.
|
||||||
|
*
|
||||||
|
* On success, returns 0 and fields are set appropriately. On failure,
|
||||||
|
* returns nonzero and result values are undefined.
|
||||||
|
*/
|
||||||
int GetFileInfo(const WCHAR* pathname, struct _stat* psb, time_t* pModWhen,
|
int GetFileInfo(const WCHAR* pathname, struct _stat* psb, time_t* pModWhen,
|
||||||
bool* pExists, bool* pIsReadable, bool* pIsDirectory);
|
bool* pExists, bool* pIsReadable, bool* pIsDirectory);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a single subdirectory if it doesn't exist. If the next-highest
|
||||||
|
* subdirectory level doesn't exist either, cut down the pathname and
|
||||||
|
* recurse.
|
||||||
|
*
|
||||||
|
* "pathEnd" points at the last valid character. The length of the valid
|
||||||
|
* path component is therefore (pathEnd-pathStart+1).
|
||||||
|
*/
|
||||||
int CreateSubdirIFN(const WCHAR* pathStart, const WCHAR* pathEnd,
|
int CreateSubdirIFN(const WCHAR* pathStart, const WCHAR* pathEnd,
|
||||||
WCHAR fssep);
|
WCHAR fssep);
|
||||||
|
|
||||||
|
@ -15,13 +15,7 @@
|
|||||||
* ==========================================================================
|
* ==========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
LPITEMIDLIST Pidl::Next(LPCITEMIDLIST pidl)
|
||||||
* Return the next item in the PIDL.
|
|
||||||
*
|
|
||||||
* "pidl->mkid.cb" will be zero at the end of the list.
|
|
||||||
*/
|
|
||||||
LPITEMIDLIST
|
|
||||||
Pidl::Next(LPCITEMIDLIST pidl)
|
|
||||||
{
|
{
|
||||||
LPSTR lpMem = (LPSTR)pidl;
|
LPSTR lpMem = (LPSTR)pidl;
|
||||||
|
|
||||||
@ -30,11 +24,7 @@ Pidl::Next(LPCITEMIDLIST pidl)
|
|||||||
return (LPITEMIDLIST)lpMem;
|
return (LPITEMIDLIST)lpMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
UINT Pidl::GetSize(LPCITEMIDLIST pidl)
|
||||||
* Compute the size in bytes of a PIDL.
|
|
||||||
*/
|
|
||||||
UINT
|
|
||||||
Pidl::GetSize(LPCITEMIDLIST pidl)
|
|
||||||
{
|
{
|
||||||
UINT cbTotal = 0;
|
UINT cbTotal = 0;
|
||||||
|
|
||||||
@ -49,11 +39,7 @@ Pidl::GetSize(LPCITEMIDLIST pidl)
|
|||||||
return cbTotal;
|
return cbTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
LPITEMIDLIST Pidl::CreatePidl(UINT cbSize)
|
||||||
* Allocate a PIDL of the specified size.
|
|
||||||
*/
|
|
||||||
LPITEMIDLIST
|
|
||||||
Pidl::CreatePidl(UINT cbSize)
|
|
||||||
{
|
{
|
||||||
LPMALLOC lpMalloc;
|
LPMALLOC lpMalloc;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@ -74,13 +60,7 @@ Pidl::CreatePidl(UINT cbSize)
|
|||||||
return pidl;
|
return pidl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
LPITEMIDLIST Pidl::ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
|
||||||
* Concatenates two PIDLs. The PIDL returned is newly-allocated storage.
|
|
||||||
*
|
|
||||||
* "pidl1" may be NULL.
|
|
||||||
*/
|
|
||||||
LPITEMIDLIST
|
|
||||||
Pidl::ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
|
|
||||||
{
|
{
|
||||||
LPITEMIDLIST pidlNew;
|
LPITEMIDLIST pidlNew;
|
||||||
UINT cb1;
|
UINT cb1;
|
||||||
@ -102,13 +82,7 @@ Pidl::ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
|
|||||||
return pidlNew;
|
return pidlNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
LPITEMIDLIST Pidl::CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi)
|
||||||
* Make a copy of a PIDL.
|
|
||||||
*
|
|
||||||
* The PIDL returned is newly-allocated storage.
|
|
||||||
*/
|
|
||||||
LPITEMIDLIST
|
|
||||||
Pidl::CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi)
|
|
||||||
{
|
{
|
||||||
LPITEMIDLIST lpiTemp;
|
LPITEMIDLIST lpiTemp;
|
||||||
|
|
||||||
@ -119,16 +93,7 @@ Pidl::CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi)
|
|||||||
return lpiTemp;
|
return lpiTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
BOOL Pidl::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags,
|
||||||
* Get the display name of a file in a ShellFolder.
|
|
||||||
*
|
|
||||||
* "lpsf" is the ShellFolder that contains the file, "lpi" is the PIDL for
|
|
||||||
* the file, "dwFlags" is passed to GetDisplayNameOf and affects which
|
|
||||||
* name is returned, and "lpFriendlyName" is a buffer of at least MAX_PATH
|
|
||||||
* bytes.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
Pidl::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags,
|
|
||||||
CString* pFriendlyName)
|
CString* pFriendlyName)
|
||||||
{
|
{
|
||||||
BOOL bSuccess=TRUE;
|
BOOL bSuccess=TRUE;
|
||||||
@ -176,20 +141,7 @@ Pidl::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags,
|
|||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LPITEMIDLIST Pidl::GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi)
|
||||||
|
|
||||||
/*
|
|
||||||
* Get a fully qualified PIDL for a ShellFolder.
|
|
||||||
*
|
|
||||||
* This is a rather roundabout way of doing things (converting to a full
|
|
||||||
* display name and then converting that to a PIDL). However, there doesn't
|
|
||||||
* seem to be a way to just ask a ShellFolder for its fully qualified PIDL.
|
|
||||||
* TODO: see if there's a better way now.
|
|
||||||
*
|
|
||||||
* Pass in the parent ShellFolder and the item's partial PIDL.
|
|
||||||
*/
|
|
||||||
LPITEMIDLIST
|
|
||||||
Pidl::GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi)
|
|
||||||
{
|
{
|
||||||
//char szBuff[MAX_PATH];
|
//char szBuff[MAX_PATH];
|
||||||
//OLECHAR szOleChar[MAX_PATH];
|
//OLECHAR szOleChar[MAX_PATH];
|
||||||
@ -223,13 +175,7 @@ Pidl::GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi)
|
|||||||
return lpifq;
|
return lpifq;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
BOOL Pidl::GetPath(LPCITEMIDLIST pidl, CString* pPath)
|
||||||
* Convert a PIDL to a filesystem path.
|
|
||||||
*
|
|
||||||
* Returns TRUE on success, FALSE on failure.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
Pidl::GetPath(LPCITEMIDLIST pidl, CString* pPath)
|
|
||||||
{
|
{
|
||||||
BOOL result;
|
BOOL result;
|
||||||
WCHAR buf[MAX_PATH];
|
WCHAR buf[MAX_PATH];
|
||||||
@ -336,14 +282,7 @@ Pidl::DoTheMenuThing(HWND hwnd, LPSHELLFOLDER lpsfParent,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
int Pidl::GetItemIcon(LPITEMIDLIST lpi, UINT uFlags)
|
||||||
* Get the index for an icon for a ShellFolder object.
|
|
||||||
*
|
|
||||||
* "lpi" is the fully-qualified PIDL for the object in question. "uFlags"
|
|
||||||
* specifies which of the object's icons to retrieve.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
Pidl::GetItemIcon(LPITEMIDLIST lpi, UINT uFlags)
|
|
||||||
{
|
{
|
||||||
SHFILEINFO sfi = { 0 };
|
SHFILEINFO sfi = { 0 };
|
||||||
|
|
||||||
|
61
util/Pidl.h
61
util/Pidl.h
@ -15,20 +15,73 @@
|
|||||||
*/
|
*/
|
||||||
class Pidl {
|
class Pidl {
|
||||||
public:
|
public:
|
||||||
// Functions that deal with PIDLs
|
/*
|
||||||
|
* Concatenates two PIDLs. The PIDL returned is newly-allocated storage.
|
||||||
|
*
|
||||||
|
* "pidl1" may be NULL.
|
||||||
|
*/
|
||||||
static LPITEMIDLIST ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
|
static LPITEMIDLIST ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a fully qualified PIDL for a ShellFolder.
|
||||||
|
*
|
||||||
|
* This is a rather roundabout way of doing things (converting to a full
|
||||||
|
* display name and then converting that to a PIDL). However, there doesn't
|
||||||
|
* seem to be a way to just ask a ShellFolder for its fully qualified PIDL.
|
||||||
|
* TODO: see if there's a better way now.
|
||||||
|
*
|
||||||
|
* Pass in the parent ShellFolder and the item's partial PIDL.
|
||||||
|
*/
|
||||||
static LPITEMIDLIST GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi);
|
static LPITEMIDLIST GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a copy of a PIDL.
|
||||||
|
*
|
||||||
|
* The PIDL returned is newly-allocated storage.
|
||||||
|
*/
|
||||||
static LPITEMIDLIST CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi);
|
static LPITEMIDLIST CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the display name of a file in a ShellFolder.
|
||||||
|
*
|
||||||
|
* "lpsf" is the ShellFolder that contains the file, "lpi" is the PIDL for
|
||||||
|
* the file, "dwFlags" is passed to GetDisplayNameOf and affects which
|
||||||
|
* name is returned, and "lpFriendlyName" is a buffer of at least MAX_PATH
|
||||||
|
* bytes.
|
||||||
|
*/
|
||||||
static BOOL GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags,
|
static BOOL GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags,
|
||||||
CString* pFriendlyName);
|
CString* pFriendlyName);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate a PIDL of the specified size.
|
||||||
|
*/
|
||||||
static LPITEMIDLIST CreatePidl(UINT cbSize);
|
static LPITEMIDLIST CreatePidl(UINT cbSize);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compute the size in bytes of a PIDL.
|
||||||
|
*/
|
||||||
static UINT GetSize(LPCITEMIDLIST pidl);
|
static UINT GetSize(LPCITEMIDLIST pidl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the next item in the PIDL.
|
||||||
|
*
|
||||||
|
* "pidl->mkid.cb" will be zero at the end of the list.
|
||||||
|
*/
|
||||||
static LPITEMIDLIST Next(LPCITEMIDLIST pidl);
|
static LPITEMIDLIST Next(LPCITEMIDLIST pidl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a PIDL to a filesystem path.
|
||||||
|
*
|
||||||
|
* Returns TRUE on success, FALSE on failure.
|
||||||
|
*/
|
||||||
static BOOL GetPath(LPCITEMIDLIST pidl, CString* pPath);
|
static BOOL GetPath(LPCITEMIDLIST pidl, CString* pPath);
|
||||||
|
|
||||||
// Utility Functions
|
/*
|
||||||
//static BOOL DoTheMenuThing(HWND hwnd, LPSHELLFOLDER lpsfParent,
|
* Get the index for an icon for a ShellFolder object.
|
||||||
// LPITEMIDLIST lpi, LPPOINT lppt);
|
*
|
||||||
|
* "lpi" is the fully-qualified PIDL for the object in question. "uFlags"
|
||||||
|
* specifies which of the object's icons to retrieve.
|
||||||
|
*/
|
||||||
static int GetItemIcon(LPITEMIDLIST lpi, UINT uFlags);
|
static int GetItemIcon(LPITEMIDLIST lpi, UINT uFlags);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,9 +69,8 @@
|
|||||||
* Return zero to enable standard processing, nonzero to claim ownership of
|
* Return zero to enable standard processing, nonzero to claim ownership of
|
||||||
* the message.
|
* the message.
|
||||||
*/
|
*/
|
||||||
/*static*/ UINT CALLBACK
|
/*static*/ UINT CALLBACK SelectFilesDialog::OFNHookProc(HWND hDlg, UINT uiMsg,
|
||||||
SelectFilesDialog::OFNHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam,
|
WPARAM wParam, LPARAM lParam)
|
||||||
LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
OPENFILENAME* pOfn;
|
OPENFILENAME* pOfn;
|
||||||
SelectFilesDialog* pSFD = NULL;
|
SelectFilesDialog* pSFD = NULL;
|
||||||
@ -117,8 +116,7 @@ SelectFilesDialog::OFNHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam,
|
|||||||
* You can indicate displeasure with the CDN_* messages by using SetWindowLong
|
* You can indicate displeasure with the CDN_* messages by using SetWindowLong
|
||||||
* to alter the DWL_MSGRESULT value.
|
* to alter the DWL_MSGRESULT value.
|
||||||
*/
|
*/
|
||||||
UINT
|
UINT SelectFilesDialog::HandleNotify(HWND hDlg, LPOFNOTIFY pofn)
|
||||||
SelectFilesDialog::HandleNotify(HWND hDlg, LPOFNOTIFY pofn)
|
|
||||||
{
|
{
|
||||||
// int count;
|
// int count;
|
||||||
|
|
||||||
@ -173,8 +171,7 @@ SelectFilesDialog::HandleNotify(HWND hDlg, LPOFNOTIFY pofn)
|
|||||||
/*
|
/*
|
||||||
* Handle WM_COMMAND messages.
|
* Handle WM_COMMAND messages.
|
||||||
*/
|
*/
|
||||||
UINT
|
UINT SelectFilesDialog::HandleCommand(HWND hDlg, WPARAM wParam, LPARAM lParam)
|
||||||
SelectFilesDialog::HandleCommand(HWND hDlg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
LOGI(" HandleCommand wParam=%d lParam=0x%08lx", wParam, lParam);
|
LOGI(" HandleCommand wParam=%d lParam=0x%08lx", wParam, lParam);
|
||||||
|
|
||||||
@ -192,8 +189,7 @@ SelectFilesDialog::HandleCommand(HWND hDlg, WPARAM wParam, LPARAM lParam)
|
|||||||
/*
|
/*
|
||||||
* Handle WM_SIZE.
|
* Handle WM_SIZE.
|
||||||
*/
|
*/
|
||||||
UINT
|
UINT SelectFilesDialog::HandleSize(HWND hDlg, UINT nType, int cx, int cy)
|
||||||
SelectFilesDialog::HandleSize(HWND hDlg, UINT nType, int cx, int cy)
|
|
||||||
{
|
{
|
||||||
//LOGI("Dialog: old size %d,%d (ready=%d)",
|
//LOGI("Dialog: old size %d,%d (ready=%d)",
|
||||||
// fLastWinSize.Width(), fLastWinSize.Height(), fReady);
|
// fLastWinSize.Width(), fLastWinSize.Height(), fReady);
|
||||||
@ -219,8 +215,7 @@ SelectFilesDialog::HandleSize(HWND hDlg, UINT nType, int cx, int cy)
|
|||||||
* User hit F1 or applied the '?' button to something. Our heritage is
|
* User hit F1 or applied the '?' button to something. Our heritage is
|
||||||
* dubious, so use global functions to access the help file.
|
* dubious, so use global functions to access the help file.
|
||||||
*/
|
*/
|
||||||
UINT
|
UINT SelectFilesDialog::HandleHelp(HWND hDlg, LPHELPINFO lpHelpInfo)
|
||||||
SelectFilesDialog::HandleHelp(HWND hDlg, LPHELPINFO lpHelpInfo)
|
|
||||||
{
|
{
|
||||||
CWnd* pWndMain = ::AfxGetMainWnd();
|
CWnd* pWndMain = ::AfxGetMainWnd();
|
||||||
CWinApp* pAppMain = ::AfxGetApp();
|
CWinApp* pAppMain = ::AfxGetApp();
|
||||||
@ -243,8 +238,7 @@ SelectFilesDialog::HandleHelp(HWND hDlg, LPHELPINFO lpHelpInfo)
|
|||||||
* We need to shift everything up by the difference between the IDOK button
|
* We need to shift everything up by the difference between the IDOK button
|
||||||
* and our "accept" button.
|
* and our "accept" button.
|
||||||
*/
|
*/
|
||||||
void
|
void SelectFilesDialog::MyOnInitDone(void)
|
||||||
SelectFilesDialog::MyOnInitDone(void)
|
|
||||||
{
|
{
|
||||||
LOGI("OnInitDone!");
|
LOGI("OnInitDone!");
|
||||||
CWnd* pParent = GetParent();
|
CWnd* pParent = GetParent();
|
||||||
@ -293,8 +287,7 @@ SelectFilesDialog::MyOnInitDone(void)
|
|||||||
* because the CFileDialog is also moving the controls, though it doesn't
|
* because the CFileDialog is also moving the controls, though it doesn't
|
||||||
* move them in quite the way we want.
|
* move them in quite the way we want.
|
||||||
*/
|
*/
|
||||||
void
|
void SelectFilesDialog::ShiftControls(int deltaX, int deltaY)
|
||||||
SelectFilesDialog::ShiftControls(int deltaX, int deltaY)
|
|
||||||
{
|
{
|
||||||
if (deltaX == 0 && deltaY == 0) {
|
if (deltaX == 0 && deltaY == 0) {
|
||||||
LOGI("SFD OnSize: no meaningful change");
|
LOGI("SFD OnSize: no meaningful change");
|
||||||
@ -316,8 +309,7 @@ SelectFilesDialog::ShiftControls(int deltaX, int deltaY)
|
|||||||
*
|
*
|
||||||
* Returns "NULL" if it can't find it.
|
* Returns "NULL" if it can't find it.
|
||||||
*/
|
*/
|
||||||
CWnd*
|
CWnd* SelectFilesDialog::GetListCtrl(void)
|
||||||
SelectFilesDialog::GetListCtrl(void)
|
|
||||||
{
|
{
|
||||||
CWnd* pItem;
|
CWnd* pItem;
|
||||||
CWnd* pList;
|
CWnd* pList;
|
||||||
@ -338,8 +330,7 @@ SelectFilesDialog::GetListCtrl(void)
|
|||||||
/*
|
/*
|
||||||
* When the selection changes, update our dialog.
|
* When the selection changes, update our dialog.
|
||||||
*/
|
*/
|
||||||
void
|
void SelectFilesDialog::MyOnFileNameChange(void)
|
||||||
SelectFilesDialog::MyOnFileNameChange(void)
|
|
||||||
{
|
{
|
||||||
//LOGI("OnFileNameChange");
|
//LOGI("OnFileNameChange");
|
||||||
|
|
||||||
@ -364,8 +355,7 @@ SelectFilesDialog::MyOnFileNameChange(void)
|
|||||||
/*
|
/*
|
||||||
* The user hit the "Accept" button. Package up the file selection.
|
* The user hit the "Accept" button. Package up the file selection.
|
||||||
*/
|
*/
|
||||||
void
|
void SelectFilesDialog::MyOnAccept(void)
|
||||||
SelectFilesDialog::MyOnAccept(void)
|
|
||||||
{
|
{
|
||||||
//LOGI("OnAccept!");
|
//LOGI("OnAccept!");
|
||||||
PrepEndDialog();
|
PrepEndDialog();
|
||||||
@ -378,8 +368,7 @@ SelectFilesDialog::MyOnAccept(void)
|
|||||||
* Returns "true" if all went well, "false" if it failed (e.g. because the
|
* Returns "true" if all went well, "false" if it failed (e.g. because the
|
||||||
* user hasn't selected any files).
|
* user hasn't selected any files).
|
||||||
*/
|
*/
|
||||||
bool
|
bool SelectFilesDialog::PrepEndDialog(void)
|
||||||
SelectFilesDialog::PrepEndDialog(void)
|
|
||||||
{
|
{
|
||||||
CListCtrl* pList;
|
CListCtrl* pList;
|
||||||
int nextSpot = 0;
|
int nextSpot = 0;
|
||||||
@ -569,8 +558,7 @@ SelectFilesDialog::PrepEndDialog(void)
|
|||||||
/*
|
/*
|
||||||
* User hit our cancel button.
|
* User hit our cancel button.
|
||||||
*/
|
*/
|
||||||
void
|
void SelectFilesDialog::MyOnCancel(void)
|
||||||
SelectFilesDialog::MyOnCancel(void)
|
|
||||||
{
|
{
|
||||||
fExitStatus = IDCANCEL;
|
fExitStatus = IDCANCEL;
|
||||||
CDialog* pDialog = (CDialog*) GetParent();
|
CDialog* pDialog = (CDialog*) GetParent();
|
||||||
@ -580,8 +568,7 @@ SelectFilesDialog::MyOnCancel(void)
|
|||||||
/*
|
/*
|
||||||
* Clear the filename field.
|
* Clear the filename field.
|
||||||
*/
|
*/
|
||||||
void
|
void SelectFilesDialog::ClearFileName(void)
|
||||||
SelectFilesDialog::ClearFileName(void)
|
|
||||||
{
|
{
|
||||||
CWnd* pWnd = GetParent()->GetDlgItem(edt1);
|
CWnd* pWnd = GetParent()->GetDlgItem(edt1);
|
||||||
if (pWnd != NULL)
|
if (pWnd != NULL)
|
||||||
|
@ -25,14 +25,7 @@ BEGIN_MESSAGE_MAP(ShellTree, CTreeCtrl)
|
|||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
/*
|
BOOL ShellTree::ReplaceDlgCtrl(CDialog* pDialog, int treeID)
|
||||||
* Replace a CTreeCtrl in a dialog box with us. All of the styles are
|
|
||||||
* copied from the original dialog window.
|
|
||||||
*
|
|
||||||
* Returns TRUE on success, FALSE on failure.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
ShellTree::ReplaceDlgCtrl(CDialog* pDialog, int treeID)
|
|
||||||
{
|
{
|
||||||
CWnd* pWnd = pDialog->GetDlgItem(treeID);
|
CWnd* pWnd = pDialog->GetDlgItem(treeID);
|
||||||
if (pWnd == NULL)
|
if (pWnd == NULL)
|
||||||
@ -55,13 +48,7 @@ ShellTree::ReplaceDlgCtrl(CDialog* pDialog, int treeID)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
BOOL ShellTree::PopulateTree(int nFolder)
|
||||||
* Populate the tree, starting from "nFolder".
|
|
||||||
*
|
|
||||||
* Returns TRUE on success, FALSE on failure.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
ShellTree::PopulateTree(int nFolder)
|
|
||||||
{
|
{
|
||||||
LPSHELLFOLDER lpsf = NULL, lpsf2 = NULL;
|
LPSHELLFOLDER lpsf = NULL, lpsf2 = NULL;
|
||||||
LPITEMIDLIST lpi = NULL;
|
LPITEMIDLIST lpi = NULL;
|
||||||
@ -121,11 +108,7 @@ bail:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ShellTree::ExpandMyComputer(void)
|
||||||
* Open up and select My Computer.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ShellTree::ExpandMyComputer(void)
|
|
||||||
{
|
{
|
||||||
HTREEITEM hItem;
|
HTREEITEM hItem;
|
||||||
hItem = FindMyComputer();
|
hItem = FindMyComputer();
|
||||||
@ -135,17 +118,7 @@ ShellTree::ExpandMyComputer(void)
|
|||||||
Select(hItem, TVGN_CARET);
|
Select(hItem, TVGN_CARET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShellTree::FillTreeView(LPSHELLFOLDER lpsf, LPITEMIDLIST lpifq,
|
||||||
/*
|
|
||||||
* Fills a branch of the TreeView control. Given the shell folder (both as
|
|
||||||
* a shell folder and the fully-qualified item ID list to it) and the parent
|
|
||||||
* item in the tree (TVI_ROOT to start off), add all the kids to the tree.
|
|
||||||
*
|
|
||||||
* Does not try to add the current entry, as a result of which we don't
|
|
||||||
* have a root "Desktop" node that everything is a child of. This is okay.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ShellTree::FillTreeView(LPSHELLFOLDER lpsf, LPITEMIDLIST lpifq,
|
|
||||||
HTREEITEM hParent)
|
HTREEITEM hParent)
|
||||||
{
|
{
|
||||||
CWaitCursor wait;
|
CWaitCursor wait;
|
||||||
@ -323,13 +296,7 @@ Done:
|
|||||||
//LOGI("FillTreeView DONE");
|
//LOGI("FillTreeView DONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
BOOL ShellTree::AddNode(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, LPITEMIDLIST lpifq,
|
||||||
* Add a node to the tree.
|
|
||||||
*
|
|
||||||
* Returns TRUE on success, FALSE on failure.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
ShellTree::AddNode(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, LPITEMIDLIST lpifq,
|
|
||||||
unsigned long ulAttrs, HTREEITEM hParent, HTREEITEM* phPrev)
|
unsigned long ulAttrs, HTREEITEM hParent, HTREEITEM* phPrev)
|
||||||
{
|
{
|
||||||
TVITEM tvi;
|
TVITEM tvi;
|
||||||
@ -411,14 +378,7 @@ bail:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ShellTree::GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTV_ITEM lptvitem)
|
||||||
* Set the TreeView normal and selected icons for the specified entry.
|
|
||||||
*
|
|
||||||
* "lpifq" is the fully-qualified PIDL, LPTV_ITEM is an item in the tree.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ShellTree::GetNormalAndSelectedIcons(LPITEMIDLIST lpifq,
|
|
||||||
LPTV_ITEM lptvitem)
|
|
||||||
{
|
{
|
||||||
//Note that we don't check the return value here because if GetIcon()
|
//Note that we don't check the return value here because if GetIcon()
|
||||||
//fails, then we're in big trouble...
|
//fails, then we're in big trouble...
|
||||||
@ -435,13 +395,8 @@ ShellTree::GetNormalAndSelectedIcons(LPITEMIDLIST lpifq,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ int CALLBACK ShellTree::TreeViewCompareProc(LPARAM lparam1,
|
||||||
|
LPARAM lparam2, LPARAM)
|
||||||
/*
|
|
||||||
* Sort function callback for TreeView SortChildrenCB.
|
|
||||||
*/
|
|
||||||
int CALLBACK
|
|
||||||
ShellTree::TreeViewCompareProc(LPARAM lparam1, LPARAM lparam2, LPARAM)
|
|
||||||
{
|
{
|
||||||
TVItemData* lptvid1 = (TVItemData*)lparam1;
|
TVItemData* lptvid1 = (TVItemData*)lparam1;
|
||||||
TVItemData* lptvid2 = (TVItemData*)lparam2;
|
TVItemData* lptvid2 = (TVItemData*)lparam2;
|
||||||
@ -473,16 +428,7 @@ ShellTree::TreeViewCompareProc(LPARAM lparam1, LPARAM lparam2, LPARAM)
|
|||||||
return (short) HRESULT_CODE(hr);
|
return (short) HRESULT_CODE(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL ShellTree::AddFolderAtSelection(const CString& name)
|
||||||
/*
|
|
||||||
* Add a new folder to the tree at the currently-selected node. This may
|
|
||||||
* not actually add a folder if the new folder is at a point in the tree
|
|
||||||
* below where we have already expanded.
|
|
||||||
*
|
|
||||||
* Returns TRUE on success, or FALSE on failure.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
ShellTree::AddFolderAtSelection(const CString& name)
|
|
||||||
{
|
{
|
||||||
LPSHELLFOLDER lpsf = NULL;
|
LPSHELLFOLDER lpsf = NULL;
|
||||||
LPITEMIDLIST lpi = NULL;
|
LPITEMIDLIST lpi = NULL;
|
||||||
@ -607,12 +553,6 @@ bail:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Respond to TVN_ITEMEXPANDING message.
|
|
||||||
*
|
|
||||||
* If the subtree hasn't been expanded yet, dig in.
|
|
||||||
*/
|
|
||||||
void ShellTree::OnFolderExpanding(NMHDR* pNMHDR, LRESULT* pResult)
|
void ShellTree::OnFolderExpanding(NMHDR* pNMHDR, LRESULT* pResult)
|
||||||
{
|
{
|
||||||
TVItemData* lptvid; //Long pointer to TreeView item data
|
TVItemData* lptvid; //Long pointer to TreeView item data
|
||||||
@ -691,24 +631,14 @@ void ShellTree::GetContextMenu(NMHDR*, LRESULT* pResult)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
BOOL ShellTree::OnSelectionChange(NMHDR* pnmh, LRESULT* pResult)
|
||||||
* Respond to TVN_SELCHANGED notification.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
ShellTree::OnSelectionChange(NMHDR* pnmh, LRESULT* pResult)
|
|
||||||
{
|
{
|
||||||
fFolderPathValid = OnFolderSelected(pnmh, pResult, fFolderPath);
|
fFolderPathValid = OnFolderSelected(pnmh, pResult, fFolderPath);
|
||||||
*pResult = 0;
|
*pResult = 0;
|
||||||
return FALSE; // allow window parent to handle notification
|
return FALSE; // allow window parent to handle notification
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
BOOL ShellTree::OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult,
|
||||||
* This does the bulk of the work when the selection changes.
|
|
||||||
*
|
|
||||||
* The filesystem path (if any) to the object is placed in "szFolderPath".
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
ShellTree::OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult,
|
|
||||||
CString &szFolderPath)
|
CString &szFolderPath)
|
||||||
{
|
{
|
||||||
TVItemData* lptvid;
|
TVItemData* lptvid;
|
||||||
@ -780,11 +710,7 @@ ShellTree::OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult,
|
|||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ShellTree::OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult)
|
||||||
* Handle TVN_DELETEITEM notification by cleaning up our stuff.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ShellTree::OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult)
|
|
||||||
{
|
{
|
||||||
TVItemData* lptvid=NULL;
|
TVItemData* lptvid=NULL;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@ -809,14 +735,7 @@ ShellTree::OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult)
|
|||||||
*pResult = 0;
|
*pResult = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ShellTree::EnableImages()
|
||||||
* Gets a handle to the system image list (by just grabbing whatever is
|
|
||||||
* in place for C:\) and makes it available to the tree control.
|
|
||||||
*
|
|
||||||
* The image list should NOT be deleted.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ShellTree::EnableImages()
|
|
||||||
{
|
{
|
||||||
// Get the handle to the system image list, for our icons
|
// Get the handle to the system image list, for our icons
|
||||||
HIMAGELIST hImageList;
|
HIMAGELIST hImageList;
|
||||||
@ -832,18 +751,6 @@ ShellTree::EnableImages()
|
|||||||
(LPARAM)hImageList);
|
(LPARAM)hImageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: GetSelectedFolderPath(CString &szFolderPath)
|
|
||||||
*
|
|
||||||
* PURPOSE: Retrieves the path of the currently selected string.
|
|
||||||
* Pass a CString object that will hold the folder path.
|
|
||||||
* If the path is not in the filesystem(eg MyComputer)
|
|
||||||
* or none is selected it returns false.
|
|
||||||
*
|
|
||||||
* MESSAGEMAP: NONE
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
BOOL ShellTree::GetSelectedFolderPath(CString &szFolderPath)
|
BOOL ShellTree::GetSelectedFolderPath(CString &szFolderPath)
|
||||||
{
|
{
|
||||||
TVItemData* lptvid; //Long pointer to TreeView item data
|
TVItemData* lptvid; //Long pointer to TreeView item data
|
||||||
@ -887,16 +794,6 @@ BOOL ShellTree::GetSelectedFolderPath(CString &szFolderPath)
|
|||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: GetParentShellFolder(HTREEITEM folderNode)
|
|
||||||
*
|
|
||||||
* PURPOSE: Retrieves the pointer to the ISHELLFOLDER interface
|
|
||||||
* of the tree node passed as the paramter.
|
|
||||||
*
|
|
||||||
* MESSAGEMAP: NONE
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
LPSHELLFOLDER ShellTree::GetParentShellFolder(HTREEITEM folderNode)
|
LPSHELLFOLDER ShellTree::GetParentShellFolder(HTREEITEM folderNode)
|
||||||
{
|
{
|
||||||
TVItemData* lptvid; //Long pointer to TreeView item data
|
TVItemData* lptvid; //Long pointer to TreeView item data
|
||||||
@ -908,17 +805,6 @@ LPSHELLFOLDER ShellTree::GetParentShellFolder(HTREEITEM folderNode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: GetRelativeIDLIST(HTREEITEM folderNode)
|
|
||||||
*
|
|
||||||
* PURPOSE: Retrieves the Pointer to an ITEMIDLIST structure that
|
|
||||||
* identifies the subfolder relative to its parent folder.
|
|
||||||
* see GetParentShellFolder();
|
|
||||||
*
|
|
||||||
* MESSAGEMAP: NONE
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
LPITEMIDLIST ShellTree::GetRelativeIDLIST(HTREEITEM folderNode)
|
LPITEMIDLIST ShellTree::GetRelativeIDLIST(HTREEITEM folderNode)
|
||||||
{
|
{
|
||||||
TVItemData* lptvid; //Long pointer to TreeView item data
|
TVItemData* lptvid; //Long pointer to TreeView item data
|
||||||
@ -930,17 +816,6 @@ LPITEMIDLIST ShellTree::GetRelativeIDLIST(HTREEITEM folderNode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* FUNCTION: GetFullyQualifiedIDLIST(HTREEITEM folderNode)
|
|
||||||
*
|
|
||||||
* PURPOSE: Retrieves the Pointer to an ITEMIDLIST
|
|
||||||
* structure that identifies the subfolder relative to the
|
|
||||||
* desktop. This is a fully qualified Item Identifier
|
|
||||||
*
|
|
||||||
* MESSAGEMAP: NONE
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
LPITEMIDLIST ShellTree::GetFullyQualifiedID(HTREEITEM folderNode)
|
LPITEMIDLIST ShellTree::GetFullyQualifiedID(HTREEITEM folderNode)
|
||||||
{
|
{
|
||||||
TVItemData* lptvid; //Long pointer to TreeView item data
|
TVItemData* lptvid; //Long pointer to TreeView item data
|
||||||
@ -952,26 +827,18 @@ LPITEMIDLIST ShellTree::GetFullyQualifiedID(HTREEITEM folderNode)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShellTree::TunnelTree(CString path, CString* pResultStr)
|
||||||
/*
|
|
||||||
* Tunnel into the tree, finding the node that corresponds to the
|
|
||||||
* requested pathname.
|
|
||||||
*
|
|
||||||
* Sets "resultMsg" to a non-empty string on error.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ShellTree::TunnelTree(CString path, CString* pResultStr)
|
|
||||||
{
|
{
|
||||||
const WCHAR* str = path;
|
const WCHAR* str = path;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (str[0] == '\\' && str[1] == '\\') {
|
if (str[0] == '\\' && str[1] == '\\') {
|
||||||
*pResultStr = "Can't expand network locations directly.";
|
*pResultStr = L"Can't expand network locations directly.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
len = path.GetLength();
|
len = path.GetLength();
|
||||||
if (len < 1) {
|
if (len < 1) {
|
||||||
*pResultStr = "You must enter a folder name.";
|
*pResultStr = L"You must enter a folder name.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,24 +890,21 @@ ShellTree::TunnelTree(CString path, CString* pResultStr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
HTREEITEM ShellTree::FindMyComputer(void)
|
||||||
* Find the tree entry that corresponds to "My Computer".
|
|
||||||
*
|
|
||||||
* This is hampered somewhat by the absence of a way to compare two
|
|
||||||
* shell folders for equality. The PIDL compare function is meant for
|
|
||||||
* sorting only (at least as far as it has been documented), and the My
|
|
||||||
* Computer "folder" has no path to examine.
|
|
||||||
*
|
|
||||||
* It helps greatly to assume that My Computer is right under Desktop.
|
|
||||||
* If it moved, or if we started the tree somewhere other than right at
|
|
||||||
* the desktop, we'd have to recursively search the tree.
|
|
||||||
*
|
|
||||||
* Returns a handle to the tree item, or NULL if My Computer wasn't found
|
|
||||||
* or didn't have any children.
|
|
||||||
*/
|
|
||||||
HTREEITEM
|
|
||||||
ShellTree::FindMyComputer(void)
|
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Find the tree entry that corresponds to "My Computer".
|
||||||
|
*
|
||||||
|
* This is hampered somewhat by the absence of a way to compare two
|
||||||
|
* shell folders for equality. The PIDL compare function is meant for
|
||||||
|
* sorting only (at least as far as it has been documented), and the My
|
||||||
|
* Computer "folder" has no path to examine.
|
||||||
|
*
|
||||||
|
* It helps greatly to assume that My Computer is right under Desktop.
|
||||||
|
* If it moved, or if we started the tree somewhere other than right at
|
||||||
|
* the desktop, we'd have to recursively search the tree.
|
||||||
|
*/
|
||||||
|
|
||||||
LPSHELLFOLDER desktop = NULL;
|
LPSHELLFOLDER desktop = NULL;
|
||||||
LPITEMIDLIST myComputerPidl = NULL;
|
LPITEMIDLIST myComputerPidl = NULL;
|
||||||
LPMALLOC lpMalloc = NULL;
|
LPMALLOC lpMalloc = NULL;
|
||||||
@ -1088,15 +952,7 @@ bail:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
HTREEITEM ShellTree::FindDrive(HTREEITEM myComputer, const CString& drive)
|
||||||
* Given a pointer to the My Computer node in the tree, find the node
|
|
||||||
* corresponding to the requested drive (which should be of the form
|
|
||||||
* "C:").
|
|
||||||
*
|
|
||||||
* Returns a pointer to the drive's node on success, or NULL on failure.
|
|
||||||
*/
|
|
||||||
HTREEITEM
|
|
||||||
ShellTree::FindDrive(HTREEITEM myComputer, const CString& drive)
|
|
||||||
{
|
{
|
||||||
CString udrive;
|
CString udrive;
|
||||||
|
|
||||||
@ -1135,17 +991,9 @@ ShellTree::FindDrive(HTREEITEM myComputer, const CString& drive)
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
HTREEITEM ShellTree::SearchTree(HTREEITEM treeNode, const CString& path)
|
||||||
* Given a path, search a subtree following the components.
|
|
||||||
*
|
|
||||||
* Pass in the tree's root (it's children will be searched for a
|
|
||||||
* match with the first path component) and the path to look for
|
|
||||||
* (which must start and end with '\\').
|
|
||||||
*/
|
|
||||||
HTREEITEM
|
|
||||||
ShellTree::SearchTree(HTREEITEM treeNode, const CString& path)
|
|
||||||
{
|
{
|
||||||
LOGI("SearchTree node=0x%p path='%ls'", treeNode, (LPCWSTR) path);
|
LOGD("SearchTree node=0x%p path='%ls'", treeNode, (LPCWSTR) path);
|
||||||
|
|
||||||
HTREEITEM node;
|
HTREEITEM node;
|
||||||
CString mangle(path);
|
CString mangle(path);
|
||||||
|
139
util/ShellTree.h
139
util/ShellTree.h
@ -28,17 +28,80 @@ public:
|
|||||||
Detach(); // we don't own the window handle
|
Detach(); // we don't own the window handle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Replace a CTreeCtrl in a dialog box with us. All of the styles are
|
||||||
|
* copied from the original dialog window.
|
||||||
|
*
|
||||||
|
* Returns TRUE on success, FALSE on failure.
|
||||||
|
*/
|
||||||
BOOL ReplaceDlgCtrl(CDialog* pDialog, int treeID);
|
BOOL ReplaceDlgCtrl(CDialog* pDialog, int treeID);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Populate the tree, starting from "nFolder".
|
||||||
|
*
|
||||||
|
* Returns TRUE on success, FALSE on failure.
|
||||||
|
*/
|
||||||
BOOL PopulateTree(int nFolder = CSIDL_DESKTOP);
|
BOOL PopulateTree(int nFolder = CSIDL_DESKTOP);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open up and select My Computer.
|
||||||
|
*/
|
||||||
void ExpandMyComputer(void);
|
void ExpandMyComputer(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a new folder to the tree at the currently-selected node. This may
|
||||||
|
* not actually add a folder if the new folder is at a point in the tree
|
||||||
|
* below where we have already expanded.
|
||||||
|
*
|
||||||
|
* Returns TRUE on success, or FALSE on failure.
|
||||||
|
*/
|
||||||
BOOL AddFolderAtSelection(const CString& name);
|
BOOL AddFolderAtSelection(const CString& name);
|
||||||
|
|
||||||
void GetContextMenu(NMHDR* pNMHDR, LRESULT* pResult);
|
void GetContextMenu(NMHDR* pNMHDR, LRESULT* pResult);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets a handle to the system image list (by just grabbing whatever is
|
||||||
|
* in place for C:\) and makes it available to the tree control.
|
||||||
|
*
|
||||||
|
* The image list should NOT be deleted.
|
||||||
|
*/
|
||||||
void EnableImages();
|
void EnableImages();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves the path of the currently selected string.
|
||||||
|
* Pass a CString object that will hold the folder path.
|
||||||
|
* If the path is not in the filesystem(eg MyComputer)
|
||||||
|
* or none is selected it returns false.
|
||||||
|
*/
|
||||||
BOOL GetSelectedFolderPath(CString &szFolderPath);
|
BOOL GetSelectedFolderPath(CString &szFolderPath);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves the pointer to the ISHELLFOLDER interface
|
||||||
|
* of the tree node passed as the parameter.
|
||||||
|
*/
|
||||||
|
LPSHELLFOLDER GetParentShellFolder(HTREEITEM folderNode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves the Pointer to an ITEMIDLIST structure that
|
||||||
|
* identifies the subfolder relative to its parent folder.
|
||||||
|
* see GetParentShellFolder();
|
||||||
|
*/
|
||||||
|
LPITEMIDLIST GetRelativeIDLIST(HTREEITEM folderNode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves the Pointer to an ITEMIDLIST
|
||||||
|
* structure that identifies the subfolder relative to the
|
||||||
|
* desktop. This is a fully qualified Item Identifier
|
||||||
|
*/
|
||||||
|
LPITEMIDLIST GetFullyQualifiedID(HTREEITEM folderNode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tunnel into the tree, finding the node that corresponds to the
|
||||||
|
* requested pathname.
|
||||||
|
*
|
||||||
|
* Sets "resultMsg" to a non-empty string on error.
|
||||||
|
*/
|
||||||
void TunnelTree(CString path, CString* pResultStr);
|
void TunnelTree(CString path, CString* pResultStr);
|
||||||
LPSHELLFOLDER GetParentShellFolder(HTREEITEM folderNode);
|
|
||||||
LPITEMIDLIST GetRelativeIDLIST(HTREEITEM folderNode);
|
|
||||||
LPITEMIDLIST GetFullyQualifiedID(HTREEITEM folderNode);
|
|
||||||
|
|
||||||
// Get the most-recently-set folder path. This will be updated on
|
// Get the most-recently-set folder path. This will be updated on
|
||||||
// every TVN_SELCHANGED, so add an ON_NOTIFY handler to the parent.
|
// every TVN_SELCHANGED, so add an ON_NOTIFY handler to the parent.
|
||||||
@ -48,19 +111,85 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/*
|
||||||
|
* Respond to TVN_ITEMEXPANDING message.
|
||||||
|
*
|
||||||
|
* If the subtree hasn't been expanded yet, dig in.
|
||||||
|
*/
|
||||||
void OnFolderExpanding(NMHDR* pNMHDR, LRESULT* pResult);
|
void OnFolderExpanding(NMHDR* pNMHDR, LRESULT* pResult);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle TVN_DELETEITEM notification by cleaning up our stuff.
|
||||||
|
*/
|
||||||
void OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult);
|
void OnDeleteShellItem(NMHDR* pNMHDR, LRESULT* pResult);
|
||||||
BOOL OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult,
|
|
||||||
CString& szFolderPath);
|
/*
|
||||||
|
* Respond to TVN_SELCHANGED notification.
|
||||||
|
*/
|
||||||
BOOL OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult);
|
BOOL OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This does the bulk of the work when the selection changes.
|
||||||
|
*
|
||||||
|
* The filesystem path (if any) to the object is placed in "szFolderPath".
|
||||||
|
*/
|
||||||
|
BOOL OnFolderSelected(NMHDR* pNMHDR, LRESULT* pResult,
|
||||||
|
CString& szFolderPath);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fills a branch of the TreeView control. Given the shell folder (both as
|
||||||
|
* a shell folder and the fully-qualified item ID list to it) and the parent
|
||||||
|
* item in the tree (TVI_ROOT to start off), add all the kids to the tree.
|
||||||
|
*
|
||||||
|
* Does not try to add the current entry, as a result of which we don't
|
||||||
|
* have a root "Desktop" node that everything is a child of. This is okay.
|
||||||
|
*/
|
||||||
void FillTreeView(LPSHELLFOLDER lpsf,LPITEMIDLIST lpifq, HTREEITEM hParent);
|
void FillTreeView(LPSHELLFOLDER lpsf,LPITEMIDLIST lpifq, HTREEITEM hParent);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a node to the tree.
|
||||||
|
*
|
||||||
|
* Returns TRUE on success, FALSE on failure.
|
||||||
|
*/
|
||||||
BOOL AddNode(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, LPITEMIDLIST lpifq,
|
BOOL AddNode(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, LPITEMIDLIST lpifq,
|
||||||
unsigned long ulAttrs, HTREEITEM hParent, HTREEITEM* phPrev);
|
unsigned long ulAttrs, HTREEITEM hParent, HTREEITEM* phPrev);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sort function callback for TreeView SortChildrenCB.
|
||||||
|
*/
|
||||||
static int CALLBACK TreeViewCompareProc(LPARAM, LPARAM, LPARAM);
|
static int CALLBACK TreeViewCompareProc(LPARAM, LPARAM, LPARAM);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the TreeView normal and selected icons for the specified entry.
|
||||||
|
*
|
||||||
|
* "lpifq" is the fully-qualified PIDL, LPTV_ITEM is an item in the tree.
|
||||||
|
*/
|
||||||
void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTV_ITEM lptvitem);
|
void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTV_ITEM lptvitem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find the tree entry that corresponds to "My Computer".
|
||||||
|
*
|
||||||
|
* Returns a handle to the tree item, or NULL if My Computer wasn't found
|
||||||
|
* or didn't have any children.
|
||||||
|
*/
|
||||||
HTREEITEM FindMyComputer(void);
|
HTREEITEM FindMyComputer(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Given a pointer to the My Computer node in the tree, find the node
|
||||||
|
* corresponding to the requested drive (which should be of the form
|
||||||
|
* "C:").
|
||||||
|
*
|
||||||
|
* Returns a pointer to the drive's node on success, or NULL on failure.
|
||||||
|
*/
|
||||||
HTREEITEM FindDrive(HTREEITEM myComputer, const CString& drive);
|
HTREEITEM FindDrive(HTREEITEM myComputer, const CString& drive);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Given a path, search a subtree following the components.
|
||||||
|
*
|
||||||
|
* Pass in the tree's root (it's children will be searched for a
|
||||||
|
* match with the first path component) and the path to look for
|
||||||
|
* (which must start and end with '\\').
|
||||||
|
*/
|
||||||
HTREEITEM SearchTree(HTREEITEM treeNode, const CString& path);
|
HTREEITEM SearchTree(HTREEITEM treeNode, const CString& path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -21,13 +21,12 @@
|
|||||||
* The constant is expected to match 4-character values read from a binary
|
* The constant is expected to match 4-character values read from a binary
|
||||||
* file, so the value is endian-dependent.
|
* file, so the value is endian-dependent.
|
||||||
*/
|
*/
|
||||||
static inline unsigned long
|
static inline uint32_t MakeFourCC(uint8_t c0, uint8_t c1, uint8_t c2,
|
||||||
MakeFourCC(unsigned char c0, unsigned char c1, unsigned char c2,
|
uint8_t c3)
|
||||||
unsigned char c3)
|
|
||||||
{
|
{
|
||||||
/* little-endian */
|
/* little-endian */
|
||||||
return ((unsigned long)c0) | ((unsigned long)c1 << 8) |
|
return ((uint32_t)c0) | ((uint32_t)c1 << 8) |
|
||||||
((unsigned long)c2 << 16) | ((unsigned long)c3 << 24);
|
((uint32_t)c2 << 16) | ((uint32_t)c3 << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -35,8 +34,7 @@ MakeFourCC(unsigned char c0, unsigned char c1, unsigned char c2,
|
|||||||
*
|
*
|
||||||
* Returns 0 on success.
|
* Returns 0 on success.
|
||||||
*/
|
*/
|
||||||
int
|
int SoundFile::Create(const WCHAR* fileName, CString* pErrMsg)
|
||||||
SoundFile::Create(const WCHAR* fileName, CString* pErrMsg)
|
|
||||||
{
|
{
|
||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
long fileLen;
|
long fileLen;
|
||||||
@ -61,19 +59,18 @@ SoundFile::Create(const WCHAR* fileName, CString* pErrMsg)
|
|||||||
*
|
*
|
||||||
* Returns 0 on success.
|
* Returns 0 on success.
|
||||||
*/
|
*/
|
||||||
int
|
int SoundFile::Create(FILE* fp, long len, bool doClose, CString* pErrMsg)
|
||||||
SoundFile::Create(FILE* fp, long len, bool doClose, CString* pErrMsg)
|
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
unsigned long riff;
|
uint32_t riff;
|
||||||
unsigned long fileLen;
|
uint32_t fileLen;
|
||||||
unsigned long wav;
|
uint32_t wav;
|
||||||
} fileHeader;
|
} fileHeader;
|
||||||
unsigned long chunkLen;
|
uint32_t chunkLen;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (mFP != NULL) {
|
if (mFP != NULL) {
|
||||||
LOGI("SoundFile object already created");
|
LOGW("SoundFile object already created");
|
||||||
assert(false);
|
assert(false);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -99,7 +96,7 @@ SoundFile::Create(FILE* fp, long len, bool doClose, CString* pErrMsg)
|
|||||||
}
|
}
|
||||||
if (fileHeader.riff != MakeFourCC('R','I','F','F') ||
|
if (fileHeader.riff != MakeFourCC('R','I','F','F') ||
|
||||||
fileHeader.wav != MakeFourCC('W','A','V','E') ||
|
fileHeader.wav != MakeFourCC('W','A','V','E') ||
|
||||||
fileHeader.fileLen > (unsigned long) len)
|
fileHeader.fileLen > (uint32_t) len)
|
||||||
{
|
{
|
||||||
*pErrMsg = L"File is not a WAV file";
|
*pErrMsg = L"File is not a WAV file";
|
||||||
LOGI("Not a valid WAV header (0x%08lx %d 0x%08lx)",
|
LOGI("Not a valid WAV header (0x%08lx %d 0x%08lx)",
|
||||||
@ -154,10 +151,10 @@ SoundFile::Create(FILE* fp, long len, bool doClose, CString* pErrMsg)
|
|||||||
mSampleStart = ftell(mFP);
|
mSampleStart = ftell(mFP);
|
||||||
mSampleLen = chunkLen;
|
mSampleLen = chunkLen;
|
||||||
|
|
||||||
LOGI("WAV: chan=%d samples/sec=%d avgBPS=%d block=%d",
|
LOGD("WAV: chan=%d samples/sec=%d avgBPS=%d block=%d",
|
||||||
mFormat.nChannels, mFormat.nSamplesPerSec, mFormat.nAvgBytesPerSec,
|
mFormat.nChannels, mFormat.nSamplesPerSec, mFormat.nAvgBytesPerSec,
|
||||||
mFormat.nBlockAlign);
|
mFormat.nBlockAlign);
|
||||||
LOGI(" bits/sample=%d [start=%d len=%d]", mFormat.wBitsPerSample,
|
LOGD(" bits/sample=%d [start=%d len=%d]", mFormat.wBitsPerSample,
|
||||||
mSampleStart, mSampleLen);
|
mSampleStart, mSampleLen);
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
@ -168,12 +165,11 @@ bail:
|
|||||||
* Skip forward until we find the named chunk. The file should be
|
* Skip forward until we find the named chunk. The file should be
|
||||||
* positioned immediately before the first chunk.
|
* positioned immediately before the first chunk.
|
||||||
*/
|
*/
|
||||||
int
|
int SoundFile::SkipToHeader(uint32_t hdrID, uint32_t* pChunkLen)
|
||||||
SoundFile::SkipToHeader(unsigned long hdrID, unsigned long* pChunkLen)
|
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
unsigned long fourcc;
|
uint32_t fourcc;
|
||||||
unsigned long chunkLen;
|
uint32_t chunkLen;
|
||||||
} chunkHeader;
|
} chunkHeader;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
@ -205,10 +201,9 @@ SoundFile::SkipToHeader(unsigned long hdrID, unsigned long* pChunkLen)
|
|||||||
/*
|
/*
|
||||||
* Read a block of data from the specified offset.
|
* Read a block of data from the specified offset.
|
||||||
*/
|
*/
|
||||||
int
|
int SoundFile::ReadData(void* buf, long sampleOffset, long len) const
|
||||||
SoundFile::ReadData(void* buf, long sampleOffset, long len) const
|
|
||||||
{
|
{
|
||||||
if ((unsigned long)(sampleOffset+len) > mSampleLen) {
|
if ((uint32_t)(sampleOffset+len) > mSampleLen) {
|
||||||
LOGI("ERROR: invalid read request (%d bytes, %d into %d)",
|
LOGI("ERROR: invalid read request (%d bytes, %d into %d)",
|
||||||
len, sampleOffset, mSampleLen);
|
len, sampleOffset, mSampleLen);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Class providing read-only access to uncompressed sound samples and
|
* Class providing read-only access to uncompressed sound samples and
|
||||||
* associated meta-data. The sound is assumed to fit in main memory.
|
* associated meta-data. The sound file is assumed to fit in main memory.
|
||||||
*
|
*
|
||||||
* Because game sound effects are generally loaded into "secondary sound
|
* Because game sound effects are generally loaded into "secondary sound
|
||||||
* buffers" allocated by DirectX, this class doesn't load the sound data
|
* buffers" allocated by DirectX, this class doesn't load the sound data
|
||||||
@ -56,7 +56,7 @@ public:
|
|||||||
int SeekAbs(long offset) { return fseek(mFP, offset, SEEK_SET); }
|
int SeekAbs(long offset) { return fseek(mFP, offset, SEEK_SET); }
|
||||||
|
|
||||||
long GetDataOffset(void) const { return mSampleStart; }
|
long GetDataOffset(void) const { return mSampleStart; }
|
||||||
unsigned long GetDataLen(void) const { return mSampleLen; }
|
uint32_t GetDataLen(void) const { return mSampleLen; }
|
||||||
const WAVEFORMATEX* GetWaveFormat(void) { return &mFormat; }
|
const WAVEFORMATEX* GetWaveFormat(void) { return &mFormat; }
|
||||||
|
|
||||||
/* returns the #of bytes per sample (all channels) */
|
/* returns the #of bytes per sample (all channels) */
|
||||||
@ -66,7 +66,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int SkipToHeader(unsigned long hdrID, unsigned long* pChunkLen);
|
int SkipToHeader(uint32_t hdrID, uint32_t* pChunkLen);
|
||||||
|
|
||||||
enum { kWAVMinSize = 40 };
|
enum { kWAVMinSize = 40 };
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ private:
|
|||||||
|
|
||||||
long mFileStart; // so we can rewind the sound file
|
long mFileStart; // so we can rewind the sound file
|
||||||
long mSampleStart; // offset in mem or file to sound samples
|
long mSampleStart; // offset in mem or file to sound samples
|
||||||
unsigned long mSampleLen; // length in bytes of audio sample section
|
uint32_t mSampleLen; // length in bytes of audio sample section
|
||||||
|
|
||||||
WAVEFORMATEX mFormat; // WAV parameters (from mmsystem.h/mmreg.h)
|
WAVEFORMATEX mFormat; // WAV parameters (from mmsystem.h/mmreg.h)
|
||||||
};
|
};
|
||||||
|
221
util/Util.cpp
221
util/Util.cpp
@ -25,8 +25,7 @@ BEGIN_MESSAGE_MAP(CGripper, CScrollBar)
|
|||||||
ON_WM_NCHITTEST()
|
ON_WM_NCHITTEST()
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
LRESULT
|
LRESULT CGripper::OnNcHitTest(CPoint point)
|
||||||
CGripper::OnNcHitTest(CPoint point)
|
|
||||||
{
|
{
|
||||||
UINT ht = CScrollBar::OnNcHitTest(point);
|
UINT ht = CScrollBar::OnNcHitTest(point);
|
||||||
if (ht == HTCLIENT) {
|
if (ht == HTCLIENT) {
|
||||||
@ -50,8 +49,8 @@ CGripper::OnNcHitTest(CPoint point)
|
|||||||
*
|
*
|
||||||
* Returns 0 on success, nonzero on error.
|
* Returns 0 on success, nonzero on error.
|
||||||
*/
|
*/
|
||||||
DWORD
|
DWORD RichEditXfer::EditStreamCallback(DWORD dwCookie, LPBYTE pbBuff,
|
||||||
RichEditXfer::EditStreamCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG* pcb)
|
LONG cb, LONG* pcb)
|
||||||
{
|
{
|
||||||
RichEditXfer* pThis = (RichEditXfer*) dwCookie;
|
RichEditXfer* pThis = (RichEditXfer*) dwCookie;
|
||||||
|
|
||||||
@ -87,11 +86,7 @@ bail:
|
|||||||
* ===========================================================================
|
* ===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
int ExpandBuffer::CreateWorkBuf(void)
|
||||||
* Allocate the initial buffer.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
ExpandBuffer::CreateWorkBuf(void)
|
|
||||||
{
|
{
|
||||||
if (fWorkBuf != NULL) {
|
if (fWorkBuf != NULL) {
|
||||||
ASSERT(fWorkMax > 0);
|
ASSERT(fWorkMax > 0);
|
||||||
@ -110,36 +105,24 @@ ExpandBuffer::CreateWorkBuf(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ExpandBuffer::SeizeBuffer(char** ppBuf, long* pLen)
|
||||||
* Let the caller seize control of our buffer. We throw away our pointer to
|
|
||||||
* the buffer so we don't free it.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ExpandBuffer::SeizeBuffer(char** ppBuf, long* pLen)
|
|
||||||
{
|
{
|
||||||
*ppBuf = fWorkBuf;
|
*ppBuf = fWorkBuf;
|
||||||
*pLen = fWorkCount;
|
*pLen = fWorkCount;
|
||||||
|
|
||||||
fWorkBuf = NULL;
|
fWorkBuf = NULL; // discard pointer so we don't free it
|
||||||
fWorkCount = 0;
|
fWorkCount = 0;
|
||||||
fWorkMax = 0;
|
fWorkMax = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int ExpandBuffer::GrowWorkBuf(void)
|
||||||
* Grow the buffer to the next incremental size. We keep doubling it until
|
|
||||||
* we reach out maximum rate of expansion.
|
|
||||||
*
|
|
||||||
* Returns 0 on success, -1 on failure.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
ExpandBuffer::GrowWorkBuf(void)
|
|
||||||
{
|
{
|
||||||
int newIncr = fWorkMax;
|
int newIncr = fWorkMax;
|
||||||
if (newIncr > kWorkBufMaxIncrement)
|
if (newIncr > kWorkBufMaxIncrement)
|
||||||
newIncr = kWorkBufMaxIncrement;
|
newIncr = kWorkBufMaxIncrement;
|
||||||
|
|
||||||
//LOGI("Extending buffer by %d (count=%d, max=%d)",
|
LOGV("Extending buffer by %d (count=%d, max=%d)",
|
||||||
// newIncr, fWorkCount, fWorkMax);
|
newIncr, fWorkCount, fWorkMax);
|
||||||
|
|
||||||
fWorkMax += newIncr;
|
fWorkMax += newIncr;
|
||||||
|
|
||||||
@ -148,7 +131,7 @@ ExpandBuffer::GrowWorkBuf(void)
|
|||||||
|
|
||||||
char* newBuf = new char[fWorkMax];
|
char* newBuf = new char[fWorkMax];
|
||||||
if (newBuf == NULL) {
|
if (newBuf == NULL) {
|
||||||
LOGI("ALLOC FAILURE (%ld)", fWorkMax);
|
LOGE("ALLOC FAILURE (%ld)", fWorkMax);
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
fWorkMax -= newIncr; // put it back so we don't overrun
|
fWorkMax -= newIncr; // put it back so we don't overrun
|
||||||
return -1;
|
return -1;
|
||||||
@ -161,11 +144,7 @@ ExpandBuffer::GrowWorkBuf(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ExpandBuffer::Write(const unsigned char* buf, long len)
|
||||||
* Write binary data to the buffer.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ExpandBuffer::Write(const unsigned char* buf, long len)
|
|
||||||
{
|
{
|
||||||
if (fWorkBuf == NULL)
|
if (fWorkBuf == NULL)
|
||||||
CreateWorkBuf();
|
CreateWorkBuf();
|
||||||
@ -178,20 +157,12 @@ ExpandBuffer::Write(const unsigned char* buf, long len)
|
|||||||
fWorkCount += len;
|
fWorkCount += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ExpandBuffer::Putc(char ch)
|
||||||
* Write one character into the buffer.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ExpandBuffer::Putc(char ch)
|
|
||||||
{
|
{
|
||||||
Write((const unsigned char*) &ch, 1);
|
Write((const unsigned char*) &ch, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ExpandBuffer::Printf(_Printf_format_string_ const char* format, ...)
|
||||||
* Print a formatted string into the buffer.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ExpandBuffer::Printf(const char* format, ...)
|
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@ -232,11 +203,7 @@ ExpandBuffer::Printf(const char* format, ...)
|
|||||||
* ===========================================================================
|
* ===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
void EnableControl(CDialog* pDlg, int id, bool enable)
|
||||||
* Enable or disable a control.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
EnableControl(CDialog* pDlg, int id, bool enable)
|
|
||||||
{
|
{
|
||||||
CWnd* pWnd = pDlg->GetDlgItem(id);
|
CWnd* pWnd = pDlg->GetDlgItem(id);
|
||||||
if (pWnd == NULL) {
|
if (pWnd == NULL) {
|
||||||
@ -247,12 +214,7 @@ EnableControl(CDialog* pDlg, int id, bool enable)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw)
|
||||||
* Move a control so it maintains its same position relative to the bottom
|
|
||||||
* and right edges.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw)
|
|
||||||
{
|
{
|
||||||
CWnd* pWnd;
|
CWnd* pWnd;
|
||||||
CRect rect;
|
CRect rect;
|
||||||
@ -271,11 +233,7 @@ MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw)
|
|||||||
pWnd->MoveWindow(&rect, redraw);
|
pWnd->MoveWindow(&rect, redraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw)
|
||||||
* Make a control larger by the same delta as the parent window.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw)
|
|
||||||
{
|
{
|
||||||
CWnd* pWnd;
|
CWnd* pWnd;
|
||||||
CRect rect;
|
CRect rect;
|
||||||
@ -292,9 +250,6 @@ StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw)
|
|||||||
pWnd->MoveWindow(&rect, redraw);
|
pWnd->MoveWindow(&rect, redraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Stretch and move a control.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY,
|
MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY,
|
||||||
int stretchX, int stretchY, bool redraw)
|
int stretchX, int stretchY, bool redraw)
|
||||||
@ -303,12 +258,7 @@ MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY,
|
|||||||
StretchControl(pDlg, id, stretchX, stretchY, redraw);
|
StretchControl(pDlg, id, stretchX, stretchY, redraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
HDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
||||||
* Move a control so it maintains its same position relative to the bottom
|
|
||||||
* and right edges.
|
|
||||||
*/
|
|
||||||
HDWP
|
|
||||||
MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
|
||||||
bool redraw)
|
bool redraw)
|
||||||
{
|
{
|
||||||
CWnd* pWnd;
|
CWnd* pWnd;
|
||||||
@ -331,11 +281,7 @@ MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
|||||||
return hdwp;
|
return hdwp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
HDWP StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
||||||
* Make a control larger by the same delta as the parent window.
|
|
||||||
*/
|
|
||||||
HDWP
|
|
||||||
StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
|
||||||
bool redraw)
|
bool redraw)
|
||||||
{
|
{
|
||||||
CWnd* pWnd;
|
CWnd* pWnd;
|
||||||
@ -356,11 +302,7 @@ StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
|||||||
return hdwp;
|
return hdwp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
HDWP MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY,
|
||||||
* Stretch and move a control.
|
|
||||||
*/
|
|
||||||
HDWP
|
|
||||||
MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY,
|
|
||||||
int stretchX, int stretchY, bool redraw)
|
int stretchX, int stretchY, bool redraw)
|
||||||
{
|
{
|
||||||
CWnd* pWnd;
|
CWnd* pWnd;
|
||||||
@ -385,11 +327,7 @@ MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY,
|
|||||||
return hdwp;
|
return hdwp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int GetDlgButtonCheck(CWnd* pWnd, int id)
|
||||||
* Get/set the check state of a button in a dialog.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
GetDlgButtonCheck(CWnd* pWnd, int id)
|
|
||||||
{
|
{
|
||||||
CButton* pButton;
|
CButton* pButton;
|
||||||
pButton = (CButton*) pWnd->GetDlgItem(id);
|
pButton = (CButton*) pWnd->GetDlgItem(id);
|
||||||
@ -398,8 +336,8 @@ GetDlgButtonCheck(CWnd* pWnd, int id)
|
|||||||
return -1;
|
return -1;
|
||||||
return pButton->GetCheck();
|
return pButton->GetCheck();
|
||||||
}
|
}
|
||||||
void
|
|
||||||
SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal)
|
void SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal)
|
||||||
{
|
{
|
||||||
CButton* pButton;
|
CButton* pButton;
|
||||||
pButton = (CButton*) pWnd->GetDlgItem(id);
|
pButton = (CButton*) pWnd->GetDlgItem(id);
|
||||||
@ -409,12 +347,7 @@ SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal)
|
|||||||
pButton->SetCheck(checkVal);
|
pButton->SetCheck(checkVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace,
|
||||||
/*
|
|
||||||
* Create a font, using defaults for most things.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace,
|
|
||||||
int pointSize)
|
int pointSize)
|
||||||
{
|
{
|
||||||
CClientDC dc(pWnd);
|
CClientDC dc(pWnd);
|
||||||
@ -426,11 +359,7 @@ CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace,
|
|||||||
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, typeFace);
|
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, typeFace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void GetWin32ErrorString(DWORD err, CString* pStr)
|
||||||
* Get a Win32 error string for an error code returned by GetLastError.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
GetWin32ErrorString(DWORD err, CString* pStr)
|
|
||||||
{
|
{
|
||||||
DWORD count;
|
DWORD count;
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
@ -457,11 +386,7 @@ GetWin32ErrorString(DWORD err, CString* pStr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID)
|
||||||
* Post a failure message.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID)
|
|
||||||
{
|
{
|
||||||
CString failed;
|
CString failed;
|
||||||
|
|
||||||
@ -469,22 +394,13 @@ ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID)
|
|||||||
pWnd->MessageBox(msg, failed, MB_OK | MB_ICONERROR);
|
pWnd->MessageBox(msg, failed, MB_OK | MB_ICONERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
BOOL ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo)
|
||||||
* Show context help, based on the control ID.
|
|
||||||
*/
|
|
||||||
BOOL
|
|
||||||
ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo)
|
|
||||||
{
|
{
|
||||||
pWnd->WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
|
pWnd->WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
bool IsWin9x(void)
|
||||||
* Returns "true" if we're running on Win9x (Win95, Win98, WinME), "false"
|
|
||||||
* if not (could be WinNT/2K/XP or even Win31 with Win32s).
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
IsWin9x(void)
|
|
||||||
{
|
{
|
||||||
OSVERSIONINFO osvers;
|
OSVERSIONINFO osvers;
|
||||||
BOOL result;
|
BOOL result;
|
||||||
@ -506,13 +422,7 @@ IsWin9x(void)
|
|||||||
* ===========================================================================
|
* ===========================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
int GetPascalString(const uint8_t* buf, long maxLen, CString* pStr)
|
||||||
* Pull a pascal string out of a buffer and stuff it into "*pStr".
|
|
||||||
*
|
|
||||||
* Returns the length of the string found, or -1 on error.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
GetPascalString(const uint8_t* buf, long maxLen, CString* pStr)
|
|
||||||
{
|
{
|
||||||
int len = *buf++;
|
int len = *buf++;
|
||||||
int retLen = len;
|
int retLen = len;
|
||||||
@ -537,11 +447,7 @@ GetPascalString(const uint8_t* buf, long maxLen, CString* pStr)
|
|||||||
return retLen;
|
return retLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void LogHexDump(const void* vbuf, long len)
|
||||||
* Dump a block of stuff to the log file.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
LogHexDump(const void* vbuf, long len)
|
|
||||||
{
|
{
|
||||||
const unsigned char* buf = (const unsigned char*) vbuf;
|
const unsigned char* buf = (const unsigned char*) vbuf;
|
||||||
char outBuf[10 + 16*3 +1 +8]; // addr: 00 11 22 ... + 8 bytes slop
|
char outBuf[10 + 16*3 +1 +8]; // addr: 00 11 22 ... + 8 bytes slop
|
||||||
@ -586,11 +492,7 @@ LogHexDump(const void* vbuf, long len)
|
|||||||
LOGI(" %hs", outBuf);
|
LOGI(" %hs", outBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int ComputePercent(LONGLONG part, LONGLONG full)
|
||||||
* Compute a percentage.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
ComputePercent(LONGLONG part, LONGLONG full)
|
|
||||||
{
|
{
|
||||||
LONGLONG perc;
|
LONGLONG perc;
|
||||||
|
|
||||||
@ -609,14 +511,7 @@ ComputePercent(LONGLONG part, LONGLONG full)
|
|||||||
return (int) perc;
|
return (int) perc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void FormatDate(time_t when, CString* pStr)
|
||||||
* Format a time_t into a string.
|
|
||||||
*
|
|
||||||
* (Should take format as an argument, so we can use global format set by
|
|
||||||
* user preferences.)
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
FormatDate(time_t when, CString* pStr)
|
|
||||||
{
|
{
|
||||||
if (when == kDateNone) {
|
if (when == kDateNone) {
|
||||||
*pStr = L"[No Date]";
|
*pStr = L"[No Date]";
|
||||||
@ -628,15 +523,7 @@ FormatDate(time_t when, CString* pStr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
const WCHAR* Stristr(const WCHAR* string1, const WCHAR* string2)
|
||||||
* Case-insensitive version of strstr(), pulled from the MSDN stuff that
|
|
||||||
* comes with VC++6.0.
|
|
||||||
*
|
|
||||||
* The isalpha() stuff is an optimization, so they can skip the tolower()
|
|
||||||
* in the outer loop comparison.
|
|
||||||
*/
|
|
||||||
const WCHAR*
|
|
||||||
Stristr(const WCHAR* string1, const WCHAR* string2)
|
|
||||||
{
|
{
|
||||||
WCHAR *cp1 = (WCHAR*)string1, *cp2, *cp1a;
|
WCHAR *cp1 = (WCHAR*)string1, *cp2, *cp1a;
|
||||||
WCHAR first; // get the first char in string to find
|
WCHAR first; // get the first char in string to find
|
||||||
@ -679,20 +566,7 @@ Stristr(const WCHAR* string1, const WCHAR* string2)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc)
|
||||||
/*
|
|
||||||
* Break a string down into its component parts.
|
|
||||||
*
|
|
||||||
* "mangle" will be mangled (various bits stomped by '\0'), "argv" will
|
|
||||||
* receive pointers to the strings, and "*pArgc" will hold the number of
|
|
||||||
* arguments in the vector. The initial value of "*pArgc" should hold the
|
|
||||||
* maximum "argv" capacity (including program name in argv[0]).
|
|
||||||
*
|
|
||||||
* The argv pointers will point into "mangle"; no new storage will be
|
|
||||||
* allocated.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc)
|
|
||||||
{
|
{
|
||||||
bool inWhiteSpace = true;
|
bool inWhiteSpace = true;
|
||||||
bool inQuote = false;
|
bool inQuote = false;
|
||||||
@ -737,13 +611,11 @@ VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc)
|
|||||||
*pArgc = idx;
|
*pArgc = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a sub-string to lower case according to rules for English book
|
* Convert a sub-string to lower case according to rules for English book
|
||||||
* titles. Assumes the initial string is in all caps.
|
* titles. Assumes the initial string is in all caps.
|
||||||
*/
|
*/
|
||||||
static void
|
static void DowncaseSubstring(CString* pStr, int startPos, int endPos,
|
||||||
DowncaseSubstring(CString* pStr, int startPos, int endPos,
|
|
||||||
bool prevWasSpace)
|
bool prevWasSpace)
|
||||||
{
|
{
|
||||||
static const WCHAR* shortWords[] = {
|
static const WCHAR* shortWords[] = {
|
||||||
@ -806,13 +678,7 @@ DowncaseSubstring(CString* pStr, int startPos, int endPos,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void InjectLowercase(CString* pStr)
|
||||||
* Convert parts of the filename to lower case.
|
|
||||||
*
|
|
||||||
* If the name already has lowercase characters, do nothing.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
InjectLowercase(CString* pStr)
|
|
||||||
{
|
{
|
||||||
int len = pStr->GetLength();
|
int len = pStr->GetLength();
|
||||||
static const WCHAR* kGapChars = L" .:&-+/\\()<>@*";
|
static const WCHAR* kGapChars = L" .:&-+/\\()<>@*";
|
||||||
@ -865,13 +731,7 @@ InjectLowercase(CString* pStr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MatchSemicolonList(const CString set, const CString match)
|
||||||
/*
|
|
||||||
* Test to see if a sub-string matches a value in a set of strings. The set
|
|
||||||
* comes from a semicolon-delimited string.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
MatchSemicolonList(const CString set, const CString match)
|
|
||||||
{
|
{
|
||||||
const WCHAR* cp;
|
const WCHAR* cp;
|
||||||
CString mangle(set);
|
CString mangle(set);
|
||||||
@ -899,14 +759,7 @@ MatchSemicolonList(const CString set, const CString match)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* StrcpyNew(const char* str)
|
||||||
/*
|
|
||||||
* Like strcpy(), but allocate with new[] instead.
|
|
||||||
*
|
|
||||||
* If "str" is NULL, or "new" fails, this returns NULL.
|
|
||||||
*/
|
|
||||||
char*
|
|
||||||
StrcpyNew(const char* str)
|
|
||||||
{
|
{
|
||||||
char* newStr;
|
char* newStr;
|
||||||
|
|
||||||
|
184
util/Util.h
184
util/Util.h
@ -9,6 +9,8 @@
|
|||||||
#ifndef UTIL_UTIL_H
|
#ifndef UTIL_UTIL_H
|
||||||
#define UTIL_UTIL_H
|
#define UTIL_UTIL_H
|
||||||
|
|
||||||
|
#include <sal.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gripper for a resizable window.
|
* Gripper for a resizable window.
|
||||||
*/
|
*/
|
||||||
@ -53,6 +55,10 @@ public:
|
|||||||
delete[] fWorkBuf;
|
delete[] fWorkBuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate the initial buffer.
|
||||||
|
*/
|
||||||
virtual int CreateWorkBuf(void);
|
virtual int CreateWorkBuf(void);
|
||||||
|
|
||||||
void Reset(void) {
|
void Reset(void) {
|
||||||
@ -62,7 +68,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy printf-formatted output into the output buffer.
|
// Copy printf-formatted output into the output buffer.
|
||||||
void Printf(const char* format, ...);
|
void Printf(_Printf_format_string_ const char* format, ...);
|
||||||
|
|
||||||
// Write binary data to the buffer.
|
// Write binary data to the buffer.
|
||||||
void Write(const unsigned char* buf, long len);
|
void Write(const unsigned char* buf, long len);
|
||||||
@ -75,6 +81,12 @@ public:
|
|||||||
virtual void SeizeBuffer(char** ppBuf, long* pLen);
|
virtual void SeizeBuffer(char** ppBuf, long* pLen);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/*
|
||||||
|
* Grow the buffer to the next incremental size. We keep doubling it until
|
||||||
|
* we reach out maximum rate of expansion.
|
||||||
|
*
|
||||||
|
* Returns 0 on success, -1 on failure.
|
||||||
|
*/
|
||||||
virtual int GrowWorkBuf(void);
|
virtual int GrowWorkBuf(void);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -89,41 +101,165 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Windows helpers.
|
* ====================================
|
||||||
|
* Windows helpers
|
||||||
|
* ====================================
|
||||||
*/
|
*/
|
||||||
void EnableControl(CDialog* pDlg, int id, bool enable=true);
|
|
||||||
void MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY,
|
|
||||||
bool redraw = true);
|
|
||||||
void StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY,
|
|
||||||
bool redraw = true);
|
|
||||||
void MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY,
|
|
||||||
int stretchX, int stretchY, bool redraw = true);
|
|
||||||
HDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
|
||||||
bool redraw = true);
|
|
||||||
HDWP StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
|
||||||
bool redraw = true);
|
|
||||||
HDWP MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY,
|
|
||||||
int stretchX, int stretchY, bool redraw = true);
|
|
||||||
int GetDlgButtonCheck(CWnd* pWnd, int id);
|
|
||||||
void SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal);
|
|
||||||
void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace,
|
|
||||||
int pointSize);
|
|
||||||
void GetWin32ErrorString(DWORD err, CString* pStr);
|
|
||||||
void ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID);
|
|
||||||
BOOL ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo);
|
|
||||||
bool IsWin9x(void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Miscellaneous functions.
|
* Enable or disable a control.
|
||||||
|
*/
|
||||||
|
void EnableControl(CDialog* pDlg, int id, bool enable=true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Move a control so it maintains its same position relative to the bottom
|
||||||
|
* and right edges.
|
||||||
|
*/
|
||||||
|
void MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY,
|
||||||
|
bool redraw = true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a control larger by the same delta as the parent window.
|
||||||
|
*/
|
||||||
|
void StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY,
|
||||||
|
bool redraw = true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stretch and move a control.
|
||||||
|
*/
|
||||||
|
void MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY,
|
||||||
|
int stretchX, int stretchY, bool redraw = true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Move a control so it maintains its same position relative to the bottom
|
||||||
|
* and right edges.
|
||||||
|
*/
|
||||||
|
HDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
||||||
|
bool redraw = true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make a control larger by the same delta as the parent window.
|
||||||
|
*/
|
||||||
|
HDWP StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
||||||
|
bool redraw = true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stretch and move a control.
|
||||||
|
*/
|
||||||
|
HDWP MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY,
|
||||||
|
int stretchX, int stretchY, bool redraw = true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the check state of a button in a dialog.
|
||||||
|
*/
|
||||||
|
int GetDlgButtonCheck(CWnd* pWnd, int id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the check state of a button in a dialog.
|
||||||
|
*/
|
||||||
|
void SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a font, using defaults for most things.
|
||||||
|
*/
|
||||||
|
void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace,
|
||||||
|
int pointSize);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a Win32 error string for an error code returned by GetLastError.
|
||||||
|
*/
|
||||||
|
void GetWin32ErrorString(DWORD err, CString* pStr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Post a failure message in a message box.
|
||||||
|
*/
|
||||||
|
void ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Show context help, based on the control ID.
|
||||||
|
*/
|
||||||
|
BOOL ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns "true" if we're running on Win9x (Win95, Win98, WinME), "false"
|
||||||
|
* if not (could be WinNT/2K/XP or even Win31 with Win32s).
|
||||||
|
*/
|
||||||
|
bool IsWin9x(void);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ====================================
|
||||||
|
* Miscellaneous functions
|
||||||
|
* ====================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pull a pascal string out of a buffer and stuff it into "*pStr".
|
||||||
|
*
|
||||||
|
* Returns the length of the string found, or -1 on error.
|
||||||
*/
|
*/
|
||||||
int GetPascalString(const uint8_t* buf, long maxLen, CString* pStr);
|
int GetPascalString(const uint8_t* buf, long maxLen, CString* pStr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Dump a block of stuff to the log file.
|
||||||
|
*/
|
||||||
void LogHexDump(const void* buf, long len);
|
void LogHexDump(const void* buf, long len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compute a percentage.
|
||||||
|
*/
|
||||||
int ComputePercent(LONGLONG part, LONGLONG full);
|
int ComputePercent(LONGLONG part, LONGLONG full);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format a time_t into a string.
|
||||||
|
*
|
||||||
|
* (Should take format as an argument, so we can use global format set by
|
||||||
|
* user preferences.)
|
||||||
|
*/
|
||||||
void FormatDate(time_t when, CString* pStr);
|
void FormatDate(time_t when, CString* pStr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Case-insensitive version of strstr(), pulled from the MSDN stuff that
|
||||||
|
* comes with VC++6.0.
|
||||||
|
*
|
||||||
|
* The isalpha() stuff is an optimization, so they can skip the tolower()
|
||||||
|
* in the outer loop comparison.
|
||||||
|
*/
|
||||||
const WCHAR* Stristr(const WCHAR* string1, const WCHAR* string2);
|
const WCHAR* Stristr(const WCHAR* string1, const WCHAR* string2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Break a string down into its component parts.
|
||||||
|
*
|
||||||
|
* "mangle" will be mangled (various bits stomped by '\0'), "argv" will
|
||||||
|
* receive pointers to the strings, and "*pArgc" will hold the number of
|
||||||
|
* arguments in the vector. The initial value of "*pArgc" should hold the
|
||||||
|
* maximum "argv" capacity (including program name in argv[0]).
|
||||||
|
*
|
||||||
|
* The argv pointers will point into "mangle"; no new storage will be
|
||||||
|
* allocated.
|
||||||
|
*/
|
||||||
void VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc);
|
void VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert parts of the filename to lower case.
|
||||||
|
*
|
||||||
|
* If the name already has lowercase characters, do nothing.
|
||||||
|
*/
|
||||||
void InjectLowercase(CString* pStr);
|
void InjectLowercase(CString* pStr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test to see if a sub-string matches a value in a set of strings. The set
|
||||||
|
* comes from a semicolon-delimited string.
|
||||||
|
*/
|
||||||
bool MatchSemicolonList(const CString set, const CString match);
|
bool MatchSemicolonList(const CString set, const CString match);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Like strcpy(), but allocate with new[] instead.
|
||||||
|
*
|
||||||
|
* If "str" is NULL, or "new" fails, this returns NULL.
|
||||||
|
*
|
||||||
|
* TODO: this should be "StrdupNew()".
|
||||||
|
*/
|
||||||
char* StrcpyNew(const char* str);
|
char* StrcpyNew(const char* str);
|
||||||
|
|
||||||
/* time_t values for bad dates */
|
/* time_t values for bad dates */
|
||||||
|
Loading…
Reference in New Issue
Block a user