mirror of
https://github.com/fadden/ciderpress.git
synced 2024-11-26 17:49:21 +00:00
51b5f00f5c
CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
301 lines
9.8 KiB
C++
301 lines
9.8 KiB
C++
/*
|
|
* CiderPress
|
|
* Copyright (C) 2007, 2008 by faddenSoft, LLC. All Rights Reserved.
|
|
* See the file LICENSE for distribution terms.
|
|
*/
|
|
/*
|
|
* Keep track of user preferences.
|
|
*
|
|
* How to add a new preference item:
|
|
* - Add an entry to the PrefNum enum, below.
|
|
* - Add a corresponding entry to Preferences::fPrefMaps, adding a new
|
|
* section to the registry if appropriate.
|
|
* - Add a default value to Preferences::Preferences. If not specified,
|
|
* strings will be nil and numeric values will be zero.
|
|
*/
|
|
#ifndef APP_PREFERENCES_H
|
|
#define APP_PREFERENCES_H
|
|
|
|
#include "MyApp.h"
|
|
|
|
class ContentList;
|
|
|
|
/*
|
|
* Number of visible columns. (We no longer have "invisible" columns, so the
|
|
* name is somewhat misleading.)
|
|
*
|
|
* This is used widely. Update with care.
|
|
*/
|
|
const int kNumVisibleColumns = 9;
|
|
|
|
/*
|
|
* Used to save & restore column layout and sorting preferences for
|
|
* the ContentList class.
|
|
*/
|
|
class ColumnLayout {
|
|
public:
|
|
ColumnLayout(void) {
|
|
for (int i = 0; i < kNumVisibleColumns; i++)
|
|
fColumnWidth[i] = kWidthDefaulted;
|
|
fSortColumn = kNumVisibleColumns; // means "use original order"
|
|
fAscending = true;
|
|
}
|
|
~ColumnLayout(void) {}
|
|
|
|
void LoadFromRegistry(const WCHAR* section);
|
|
void SaveToRegistry(const WCHAR* section);
|
|
|
|
int GetColumnWidth(int col) const {
|
|
ASSERT(col >= 0 && col < kNumVisibleColumns);
|
|
return fColumnWidth[col];
|
|
}
|
|
void SetColumnWidth(int col, int width) {
|
|
ASSERT(col >= 0 && col < kNumVisibleColumns);
|
|
ASSERT(width >= 0 || width == kWidthDefaulted);
|
|
fColumnWidth[col] = width;
|
|
}
|
|
|
|
int GetSortColumn(void) const { return fSortColumn; }
|
|
void SetSortColumn(int col) {
|
|
ASSERT(col >= 0 && col <= kNumVisibleColumns);
|
|
fSortColumn = col;
|
|
}
|
|
bool GetAscending(void) const { return fAscending; }
|
|
void SetAscending(bool val) { fAscending = val; }
|
|
|
|
/* column width value used to flag "defaulted" status */
|
|
enum { kWidthDefaulted = -1 };
|
|
/* minimium width of column 0 (pathname) */
|
|
enum { kMinCol0Width = 50 };
|
|
|
|
private:
|
|
// Create a dummy list control to get default column widths.
|
|
void DetermineDefaultWidths(ContentList* pList);
|
|
|
|
int fColumnWidth[kNumVisibleColumns];
|
|
int fSortColumn;
|
|
bool fAscending;
|
|
};
|
|
|
|
|
|
/*
|
|
* Preferences type enumeration.
|
|
*
|
|
* This is logically part of the Preferences object, but it's annoying to
|
|
* have to specify the scope resolution operator everywhere.
|
|
*/
|
|
typedef enum {
|
|
/**/ kPrefNumUnknown = 0,
|
|
|
|
/* these are saved in the registry */
|
|
|
|
// sticky settings for add file options
|
|
kPrAddIncludeSubFolders, // bool
|
|
kPrAddStripFolderNames, // bool
|
|
kPrAddOverwriteExisting, // bool
|
|
kPrAddTypePreservation, // long
|
|
kPrAddConvEOL, // long
|
|
|
|
// sticky settings for file extraction
|
|
//kPrExtractPath, // string
|
|
kPrExtractConvEOL, // long
|
|
kPrExtractConvHighASCII, // bool
|
|
kPrExtractIncludeData, // bool
|
|
kPrExtractIncludeRsrc, // bool
|
|
kPrExtractIncludeDisk, // bool
|
|
kPrExtractEnableReformat, // bool
|
|
kPrExtractDiskTo2MG, // bool
|
|
kPrExtractAddTypePreservation, // bool
|
|
kPrExtractAddExtension, // bool
|
|
kPrExtractStripFolderNames, // bool
|
|
kPrExtractOverwriteExisting, // bool
|
|
|
|
// // view file options
|
|
// kPrViewIncludeDataForks, // bool
|
|
// kPrViewIncludeRsrcForks, // bool
|
|
// kPrViewIncludeDiskImages, // bool
|
|
// kPrViewIncludeComments, // bool
|
|
|
|
// convert disk image to file archive
|
|
//kPrConvFileConvDOSText, // bool
|
|
//kPrConvFileConvPascalText, // bool
|
|
kPrConvFileEmptyFolders, // bool
|
|
|
|
// folders for CFileDialog initialization
|
|
kPrOpenArchiveFolder, // string
|
|
kPrConvertArchiveFolder, // string
|
|
kPrAddFileFolder, // string
|
|
kPrExtractFileFolder, // string
|
|
|
|
// logical/physical volume prefs
|
|
kPrVolumeFilter, // long
|
|
//kPrVolumeReadOnly, // bool
|
|
|
|
// cassette import/export prefs
|
|
kPrCassetteAlgorithm, // long
|
|
kPrOpenWAVFolder, // string
|
|
|
|
// items from the Preferences propertypages (must be saved/restored)
|
|
kPrMimicShrinkIt, // bool
|
|
kPrBadMacSHK, // bool
|
|
kPrReduceSHKErrorChecks, // bool
|
|
kPrCoerceDOSFilenames, // bool
|
|
kPrSpacesToUnder, // bool
|
|
kPrPasteJunkPaths, // bool
|
|
kPrBeepOnSuccess, // bool
|
|
|
|
kPrQueryImageFormat, // bool
|
|
kPrOpenVolumeRO, // bool
|
|
kPrOpenVolumePhys0, // bool
|
|
kPrProDOSAllowLower, // bool
|
|
kPrProDOSUseSparse, // bool
|
|
|
|
kPrCompressionType, // long
|
|
|
|
kPrMaxViewFileSize, // long
|
|
kPrNoWrapText, // bool
|
|
|
|
kPrHighlightHexDump, // bool
|
|
kPrHighlightBASIC, // bool
|
|
kPrConvHiResBlackWhite, // bool
|
|
kPrConvDHRAlgorithm, // long
|
|
kPrRelaxGfxTypeCheck, // bool
|
|
kPrDisasmOneByteBrkCop, // bool
|
|
//kPrEOLConvRaw, // bool
|
|
kPrConvTextEOL_HA, // bool
|
|
kPrConvPascalText, // bool
|
|
kPrConvPascalCode, // bool
|
|
kPrConvCPMText, // bool
|
|
kPrConvApplesoft, // bool
|
|
kPrConvInteger, // bool
|
|
kPrConvBusiness, // bool
|
|
kPrConvGWP, // bool
|
|
kPrConvText8, // bool
|
|
kPrConvGutenberg, // bool
|
|
kPrConvAWP, // bool
|
|
kPrConvADB, // bool
|
|
kPrConvASP, // bool
|
|
kPrConvSCAssem, // bool
|
|
kPrConvDisasm, // bool
|
|
kPrConvHiRes, // bool
|
|
kPrConvDHR, // bool
|
|
kPrConvSHR, // bool
|
|
kPrConvPrintShop, // bool
|
|
kPrConvMacPaint, // bool
|
|
kPrConvProDOSFolder, // bool
|
|
kPrConvResources, // bool
|
|
|
|
kPrTempPath, // string
|
|
kPrExtViewerExts, // string
|
|
|
|
// open file dialog
|
|
kPrLastOpenFilterIndex, // long
|
|
|
|
/**/ kPrefNumLastRegistry,
|
|
/* these are temporary settings, not saved in the registry */
|
|
|
|
// sticky settings for internal file viewer (ViewFilesDialog)
|
|
kPrViewTextTypeFace, // string
|
|
kPrViewTextPointSize, // long
|
|
kPrFileViewerWidth, // long
|
|
kPrFileViewerHeight, // long
|
|
|
|
// sticky setting for disk image creator
|
|
kPrDiskImageCreateFormat, // long
|
|
|
|
/**/ kPrefNumLastEntry
|
|
} PrefNum;
|
|
|
|
|
|
/*
|
|
* Container for preferences.
|
|
*/
|
|
class Preferences {
|
|
public:
|
|
Preferences(void);
|
|
~Preferences(void) {
|
|
FreeStringValues();
|
|
}
|
|
|
|
// Load/save preferences from/to registry.
|
|
int LoadFromRegistry(void);
|
|
int SaveToRegistry(void);
|
|
|
|
ColumnLayout* GetColumnLayout(void) { return &fColumnLayout; }
|
|
//bool GetShowToolbarText(void) const { return fShowToolbarText; }
|
|
//void SetShowToolbarText(bool val) { fShowToolbarText = val; }
|
|
|
|
bool GetPrefBool(PrefNum num) const;
|
|
void SetPrefBool(PrefNum num, bool val);
|
|
long GetPrefLong(PrefNum num) const;
|
|
void SetPrefLong(PrefNum num, long val);
|
|
const WCHAR* GetPrefString(PrefNum num) const;
|
|
void SetPrefString(PrefNum num, const WCHAR* str);
|
|
|
|
|
|
private:
|
|
void InitTempPath(void);
|
|
void InitFolders(void);
|
|
bool GetMyDocuments(CString* pPath);
|
|
int DefaultCompressionType(void);
|
|
void FreeStringValues(void);
|
|
|
|
/*
|
|
* Internal data structure used to manage preferences.
|
|
*/
|
|
typedef enum { kPTNone, kBool, kLong, kString } PrefType;
|
|
typedef struct PrefMap {
|
|
PrefNum num;
|
|
PrefType type;
|
|
const WCHAR* registrySection;
|
|
const WCHAR* registryKey;
|
|
} PrefMap;
|
|
static const PrefMap fPrefMaps[kPrefNumLastEntry];
|
|
void ScanPrefMaps(void);
|
|
|
|
// this holds the actual values
|
|
void* fValues[kPrefNumLastEntry];
|
|
|
|
// verify that the entry exists and has the expected type
|
|
bool ValidateEntry(PrefNum num, PrefType type) const {
|
|
if (num <= kPrefNumUnknown || num >= kPrefNumLastEntry) {
|
|
ASSERT(false);
|
|
return false;
|
|
}
|
|
if (fPrefMaps[num].type != type) {
|
|
ASSERT(false);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// column widths for ContentList
|
|
ColumnLayout fColumnLayout;
|
|
|
|
/*
|
|
* Registry helpers.
|
|
*/
|
|
UINT GetInt(const WCHAR* section, const WCHAR* key, int dflt) {
|
|
return gMyApp.GetProfileInt(section, key, dflt);
|
|
}
|
|
bool GetBool(const WCHAR* section, const WCHAR* key, bool dflt) {
|
|
return (gMyApp.GetProfileInt(section, key, dflt) != 0);
|
|
}
|
|
CString GetString(const WCHAR* section, const WCHAR* key,
|
|
const WCHAR* dflt)
|
|
{
|
|
return gMyApp.GetProfileString(section, key, dflt);
|
|
}
|
|
BOOL WriteInt(const WCHAR* section, const WCHAR* key, int value) {
|
|
return gMyApp.WriteProfileInt(section, key, value);
|
|
}
|
|
BOOL WriteBool(const WCHAR* section, const WCHAR* key, bool value) {
|
|
return gMyApp.WriteProfileInt(section, key, value);
|
|
}
|
|
BOOL WriteString(const WCHAR* section, const WCHAR* key, const WCHAR* value) {
|
|
return gMyApp.WriteProfileString(section, key, value);
|
|
}
|
|
};
|
|
|
|
#endif /*APP_PREFERENCES_H*/
|