ciderpress/app/ViewFilesDialog.h

251 lines
7.5 KiB
C
Raw Normal View History

2007-03-27 17:47:10 +00:00
/*
* CiderPress
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Class for the "view files" dialog box.
*/
Large set of changes to restore CiderPress build. CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
#ifndef APP_VIEWFILESDIALOG_H
#define APP_VIEWFILESDIALOG_H
2007-03-27 17:47:10 +00:00
#include "GenericArchive.h"
#include "resource.h"
class MainWindow;
/*
* Implementation of the "view files" dialog box.
*
* The default window size is actually defined over in Preferences.cpp.
* The window size is a "sticky" pref (i.e. not stored in registry).
*/
class ViewFilesDialog : public CDialog {
public:
ViewFilesDialog(CWnd* pParentWnd = NULL) :
CDialog(IDD_FILE_VIEWER, pParentWnd)
{
2014-11-18 05:13:13 +00:00
//fpMainWindow = NULL;
fpSelSet = NULL;
fpHolder = NULL;
fpOutput = NULL;
fTypeFace = "";
fPointSize = 0;
fNoWrapText = false;
fBusy = false;
2014-11-18 05:13:13 +00:00
fpRichEditOle = NULL;
fFirstResize = false;
2014-11-18 05:13:13 +00:00
fpFindDialog = NULL;
fFindDown = false;
fFindMatchCase = false;
fFindMatchWholeWord = false;
}
virtual ~ViewFilesDialog(void) {
delete fpHolder;
delete fpOutput;
// Windows will handle destruction of fpFindDialog (child window)
}
void SetSelectionSet(SelectionSet* pSelSet) { fpSelSet = pSelSet; }
CString GetTextTypeFace(void) const { return fTypeFace; }
Large set of changes to restore CiderPress build. CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
void SetTextTypeFace(const WCHAR* name) { fTypeFace = name; }
int GetTextPointSize(void) const { return fPointSize; }
void SetTextPointSize(int size) { fPointSize = size; }
//bool GetNoWrapText(void) const { return fNoWrapText; }
void SetNoWrapText(bool val) { fNoWrapText = val; }
2007-03-27 17:47:10 +00:00
protected:
/*
* Window creation. Stuff the desired text into the RichEdit box.
*/
virtual BOOL OnInitDialog(void) override;
/*
* Override OnOK/OnCancel so we don't bail out while we're in the middle of
* loading something. It would actually be kind of nice to be able to do
* so, so someday we should make the "cancel" button work, or perhaps allow
* prev/next to skip over the thing being loaded. "TO DO"
*/
virtual void OnOK(void) override;
virtual void OnCancel(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* Window creation stuff. Set the icon and the "gripper".
*/
afx_msg int OnCreate(LPCREATESTRUCT lpcs);
/*
* Window is going away. Save the current size.
*/
afx_msg void OnDestroy(void);
/*
* When the window resizes, we have to tell the edit box to expand, and
* rearrange the controls inside it.
*/
afx_msg void OnSize(UINT nType, int cx, int cy);
/*
* Restrict the minimum window size to something reasonable.
*/
afx_msg void OnGetMinMaxInfo(MINMAXINFO* pMMI);
afx_msg void OnFviewNext(void);
afx_msg void OnFviewPrev(void);
afx_msg void OnFviewFont(void);
afx_msg void OnFviewPrint(void);
afx_msg void OnFviewFind(void);
afx_msg void OnFviewData(void);
afx_msg void OnFviewRsrc(void);
afx_msg void OnFviewCmmt(void);
afx_msg void OnFviewFmtBest(void);
afx_msg void OnFviewFmtHex(void);
afx_msg void OnFviewFmtRaw(void);
afx_msg void OnFormatSelChange(void);
afx_msg void OnHelp(void) {
MyApp::HandleHelp(this, HELP_TOPIC_FILE_VIEWER);
}
//afx_msg void OnFviewWrap(void);
afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
2007-03-27 17:47:10 +00:00
private:
/*
* Adjust the positions and sizes of the controls.
*
* This relies on MinMaxInfo to guarantee that nothing falls off an edge.
*/
void ShiftControls(int deltaX, int deltaY);
//void MoveControl(int id, int deltaX, int deltaY);
//void StretchControl(int id, int deltaX, int deltaY);
void NewFontSelected(bool resetBold);
/*
* Display a buffer of text in the RichEdit control.
*
* The RichEdit dialog will hold its own copy of the data, so "pHolder" can
* be safely destroyed after this returns.
*
* "fileName" is for display only.
*/
Large set of changes to restore CiderPress build. CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
void DisplayText(const WCHAR* fileName);
/*
* Set up the fpHolder. Does not reformat the data, just loads the source
* material and runs the applicability tests.
*
* Returns 0 on success, -1 on failure.
*/
int ReformatPrep(GenericEntry* pEntry);
/*
* Reformat a file.
*
* Returns 0 if the file was reformatted, -1 if not
*/
int Reformat(const GenericEntry* pEntry,
ReformatHolder::ReformatPart part, ReformatHolder::ReformatID id);
/*
* Configure the radio buttons that determine which part to view, enabling
* only those that make sense.
*
* Try to keep the previously-set button set.
*
* If "pEntry" is NULL, all buttons are disabled (useful for first-time
* initialization).
*/
void ConfigurePartButtons(const GenericEntry* pEntry);
/*
* Figure out which part of the file is selected (data/rsrc/comment).
*
* If no part is selected, throws up its hands and returns kPartData.
*/
ReformatHolder::ReformatPart GetSelectedPart(void);
void ForkSelectCommon(ReformatHolder::ReformatPart part);
/*
* Set up the entries in the drop box based on the "applicable" array in
* fpHolder. The set of values is different for each part of the file.
*
* Returns the default reformatter ID. This is always entry #0.
*/
ReformatHolder::ReformatID ConfigureFormatSel(
ReformatHolder::ReformatPart part);
/*
* Return the combo box index for the entry whose "data" field matches "val".
*
* Returns -1 if the entry couldn't be found.
*/
int FindByVal(CComboBox* pCombo, DWORD val);
/*
* Enable or disable all of the format selection buttons.
*/
void EnableFormatSelection(BOOL enable);
/*
* Find the next ocurrence of the specified string.
*/
Large set of changes to restore CiderPress build. CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
void FindNext(const WCHAR* str, bool down, bool matchCase,
bool wholeWord);
// pointer to main window, so we can ask for text to view
//MainWindow* fpMainWindow;
// stuff to display
SelectionSet* fpSelSet;
// edit control
CRichEditCtrl fEditCtrl;
// currently loaded file
ReformatHolder* fpHolder;
// most recent conversion
ReformatOutput* fpOutput;
// current title of window
CString fTitle;
// used to display a "gripper" in the bottom right of the dialog
CGripper fGripper;
// last size of the window, so we can shift things around
CRect fLastWinSize;
// font characteristics
CString fTypeFace; // name of font
int fPointSize; // size, in points
// do we want to scroll or wrap?
bool fNoWrapText;
// the message pump in the progress updater can cause NufxLib reentrancy
// (alternate solution: disable the window while we load stuff)
bool fBusy;
// this is *really* annoying
bool fFirstResize;
// used for stuffing images in; points at something inside RichEdit ctrl
IRichEditOle* fpRichEditOle;
CFindReplaceDialog* fpFindDialog;
CString fFindLastStr;
bool fFindDown;
bool fFindMatchCase;
bool fFindMatchWholeWord;
DECLARE_MESSAGE_MAP()
2007-03-27 17:47:10 +00:00
};
Large set of changes to restore CiderPress build. CiderPress and MDC now compile, and execute far enough to open their respective "about" boxes, but I doubt they'll do much more than that. * Switch from MBCS to UNICODE APIs Microsoft switched to UTF-16 (by way of UCS-2) a long time ago, and the support for MBCS seems to be getting phased out. So it's time to switch to wide strings. This is a bit awkward for CiderPress because it works with disk and file archives with 8-bit filenames, and I want NufxLib and DiskImgLib to continue to work on Linux (which has largely taken the UTF-8 approach to Unicode). The libraries will continue to work with 8-bit filenames, with CiderPress/MDC doing the conversion at the appropriate point. There were a couple of places where strings from a structure handed back by one of the libraries were used directly in the UI, or vice-versa, which is a problem because we have nowhere to store the result of the conversion. These currently have fixed place-holder "xyzzy" strings. All UI strings are now wide. Various format strings now use "%ls" and "%hs" to explicitly specify wide and narrow. This doesn't play well with gcc, so only the Windows-specific parts use those. * Various updates to vcxproj files The project-file conversion had some cruft that is now largely gone. The build now has a common output directory for the EXEs and libraries, avoiding the old post-build copy steps. * Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots The old "prebuilts" directory is now gone. The libraries are now built as part of building the apps. I added a minimal set of files for zlib, and a full set for nufxlib. The Linux-specific nufxlib goodies are included for the benefit of the Linux utilities, which are currently broken (don't build). * Replace symbols used for include guards Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
#endif /*APP_VIEWFILESDIALOG_H*/