#ifndef WCRYPTOTE_H
#define WCRYPTOTE_H
#include <wx/wx.h>
#include <wx/filename.h>
#include <wx/hyperlink.h>
#include <wx/wfstream.h>
#include <wx/aui/aui.h>
#include <wx/wxhtml.h>
#include "enctain.h"
enum {
myID_FIRST = wxID_HIGHEST + 1,
myID_AUINOTEBOOK,
myID_TIMER_IDLECHECK,
myID_MENU_CONTAINER_SHOWLIST,
myID_MENU_CONTAINER_PASSLIST,
myID_MENU_SUBFILE_NEW,
myID_MENU_SUBFILE_OPEN,
myID_MENU_SUBFILE_IMPORT,
myID_MENU_SUBFILE_EXPORT,
myID_MENU_SUBFILE_PROPERTIES,
myID_MENU_SUBFILE_RENAME,
myID_MENU_SUBFILE_CLOSE,
myID_MENU_SUBFILE_DELETE,
myID_MENU_EDIT_QUICKFIND,
myID_MENU_EDIT_GOTO,
myID_MENU_EDIT_SELECTLINE,
myID_MENU_EDIT_INSERT_PASSWORD,
myID_MENU_EDIT_INSERT_PASSWORD_DIALOG,
myID_TOOL_EDIT_INSERT_PASSWORD,
myID_MENU_EDIT_INSERT_DATETIME,
myID_TOOL_EDIT_INSERT_DATETIME,
myID_MENU_EDIT_INSERT_DATETIME_YYYYMMDD_HHMMSS,
myID_MENU_EDIT_INSERT_DATETIME_YYYYMMDD,
myID_MENU_EDIT_INSERT_DATETIME_HHMMSS,
myID_MENU_EDIT_INSERT_DATETIME_LOCALE,
myID_MENU_EDIT_INSERT_DATETIME_LOCALE_DATE,
myID_MENU_EDIT_INSERT_DATETIME_LOCALE_TIME,
myID_MENU_EDIT_INSERT_DATETIME_RFC822,
myID_MENU_VIEW_LINEWRAP,
myID_MENU_VIEW_LINENUMBER,
myID_MENU_VIEW_WHITESPACE,
myID_MENU_VIEW_ENDOFLINE,
myID_MENU_VIEW_INDENTGUIDE,
myID_MENU_VIEW_LONGLINEGUIDE,
myID_MENU_VIEW_ZOOM,
myID_MENU_VIEW_ZOOM_INCREASE,
myID_MENU_VIEW_ZOOM_DECREASE,
myID_MENU_VIEW_ZOOM_RESET,
myID_MENU_VIEW_BIGICONS,
myID_MENU_VIEW_LIST,
myID_MENU_VIEW_REPORT,
myID_MENU_HELP_BROWSER,
myID_MENU_HELP_WEBUPDATECHECK,
myID_ACCEL_ESCAPE,
myID_QUICKFIND_TEXT,
myID_QUICKFIND_CLOSE,
myID_QUICKFIND_NEXT,
myID_QUICKFIND_PREV,
myID_QUICKGOTO_TEXT,
myID_QUICKGOTO_GO,
myID_QUICKGOTO_CLOSE,
myID_FILETYPE_BINARY,
myID_FILETYPE_TEXT,
myID_FILETYPE_IMAGE,
myID_FILETYPE_BINARY_LARGE,
myID_FILETYPE_TEXT_LARGE,
myID_FILETYPE_IMAGE_LARGE,
myID_IMAGE_USERKEYSLOT,
myID_IMAGE_USERKEYSLOT_ACTIVE,
myID_MENU_EDIT_INSERT_PASSWORD_FIRST = wxID_HIGHEST + 1000,
myID_MENU_SHOW_COLUMN0 = wxID_HIGHEST + 2000,
};
class WCryptoTE : public wxFrame
{
public:
WCryptoTE(wxWindow* parent, class MyLocale* locale);
~WCryptoTE();
static const wxChar* EnctainErrorString(Enctain::error_type e);
static wxString EnctainExceptionString(Enctain::Exception& e);
void UpdateStatusBar(const wxString& str);
void HidePane(wxWindow* child);
bool IsModified();
void UpdateModified();
void SetModified();
class WNotePage* FindSubFilePage(unsigned int sfid);
void OpenSubFile(unsigned int sfid);
void UpdateSubFileCaption(int sfid);
void UpdateSubFileModified(WNotePage* page, bool modified);
void ImportSubFiles(const wxArrayString& filelist, const std::string& filetype, bool openpage);
void ExportSubFile(unsigned int sfid, wxOutputStream& os);
void DeleteSubFile(unsigned int sfid, bool resetfilelist);
void UpdateTitle();
wxString GetSavedFilename();
void ShowFilelistPane(bool on);
void HideQuickBars();
void ContainerNew();
bool ContainerOpen(const wxString& filename, const wxString& defpass=wxEmptyString);
bool ContainerSaveAs(const wxString& filename);
void SaveOpenSubFilelist();
void RestoreOpenSubFilelist();
void WebUpdateCheck();
int prefs_bitmaptheme;
bool prefs_makebackups;
int prefs_backupnum;
bool prefs_autoclose;
int prefs_autoclosetime;
bool prefs_autocloseexit;
bool prefs_sharelock;
bool prefs_webupdatecheck;
time_t prefs_webupdatecheck_time;
wxString prefs_webupdatecheck_version;
void LoadPreferences();
bool copt_restoreview;
void OnClose(wxCloseEvent& event);
bool AllowCloseModified();
void OnMenuContainerOpen(wxCommandEvent& event);
void OnMenuContainerSave(wxCommandEvent& event);
void OnMenuContainerSaveAs(wxCommandEvent& event);
void OnMenuContainerRevert(wxCommandEvent& event);
void OnMenuContainerClose(wxCommandEvent& event);
bool UserContainerOpen();
bool UserContainerSave();
bool UserContainerSaveAs();
void OnMenuContainerShowList(wxCommandEvent& event);
void OnMenuContainerProperties(wxCommandEvent& event);
void OnMenuContainerPasswordList(wxCommandEvent& event);
void OnMenuContainerPreferences(wxCommandEvent& event);
void OnMenuContainerQuit(wxCommandEvent& event);
void OnMenuSubFileNew(wxCommandEvent& event);
void OnMenuSubFileImport(wxCommandEvent& event);
void OnMenuSubFileExport(wxCommandEvent& event);
void OnMenuSubFileProperties(wxCommandEvent& event);
void OnMenuSubFileClose(wxCommandEvent& event);
void OnMenuEditGeneric(wxCommandEvent& event);
void OnMenuEditQuickFind(wxCommandEvent& event);
void OnMenuEditGoto(wxCommandEvent& event);
void OnMenuEditFind(wxCommandEvent& event);
void OnMenuEditFindReplace(wxCommandEvent& event);
void OnMenuEditInsertPassword(wxCommandEvent& event);
void OnToolEditInsertPassword(wxCommandEvent& event);
void OnMenuEditInsertPasswordPreset(wxCommandEvent& event);
void OnMenuEditInsertDateTime(wxCommandEvent& event);
void OnToolEditInsertDateTime(wxCommandEvent& event);
void OnMenuViewLineWrap(wxCommandEvent& event);
void OnMenuViewLineNumber(wxCommandEvent& event);
void OnMenuViewWhitespace(wxCommandEvent& event);
void OnMenuViewEndOfLine(wxCommandEvent& event);
void OnMenuViewIndentGuide(wxCommandEvent& event);
void OnMenuViewLonglineGuide(wxCommandEvent& event);
void OnMenuViewZoomIncrease(wxCommandEvent& event);
void OnMenuViewZoomDecrease(wxCommandEvent& event);
void OnMenuViewZoomReset(wxCommandEvent& event);
void OnMenuHelpBrowser(wxCommandEvent& event);
void OnMenuHelpWebUpdateCheck(wxCommandEvent& event);
void OnMenuHelpAbout(wxCommandEvent& event);
void OnAccelEscape(wxCommandEvent& event);
void OnAuiManagerPaneClose(wxAuiManagerEvent& event);
void OnNotebookPageChanged(wxAuiNotebookEvent& event);
void OnNotebookPageClose(wxAuiNotebookEvent& event);
void OnNotebookPageRightDown(wxAuiNotebookEvent& event);
void UpdateNotebookPageChanged(int pageid, WNotePage* page);
void OnTextQuickFind(wxCommandEvent& event);
void OnButtonQuickFindNext(wxCommandEvent& event);
void OnButtonQuickFindPrev(wxCommandEvent& event);
void OnButtonQuickFindClose(wxCommandEvent& event);
void OnButtonGotoGo(wxCommandEvent& event);
void OnButtonGotoClose(wxCommandEvent& event);
protected:
class MyLocale* m_locale;
public:
class wxMenuBar* menubar_plain;
class wxMenuBar* menubar_textpage;
class wxMenuBar* menubar_binarypage;
class wxMenuBar* menubar_active;
class wxToolBar* toolbar;
class WStatusBar* statusbar;
wxMenuBar* CreateMenuBar(const wxClassInfo* page);
void CreateToolBar();
void UpdateMenuInsertPassword();
protected:
wxAuiManager auimgr;
public:
wxAuiNotebook* auinotebook;
Enctain::Container container;
wxFileName container_filename;
wxFile* container_filehandle;
bool main_modified;
public:
class WNotePage* cpage;
int cpageid;
class WQuickFindBar* quickfindbar;
bool quickfindbar_visible;
class WQuickGotoBar* quickgotobar;
bool quickgotobar_visible;
class WFindReplace* findreplacedlg;
class WFileList* filelistpane;
class WPassGen* wpassgen;
bool webupdatecheck_running;
wxHtmlHelpController* m_htmlhelp;
wxHtmlHelpController* GetHtmlHelpController();
public:
long lastuserevent;
wxTimer idlechecktimer;
wxString idletimestatusbar;
void OnIdleTimerCheck(wxTimerEvent& event);
void ResetIdleTimer();
private:
DECLARE_EVENT_TABLE()
};
class WStatusBar : public wxStatusBar, public Enctain::ProgressIndicator
{
public:
WStatusBar(wxWindow *parent);
void OnSize(wxSizeEvent& event);
void SetModified(bool on);
wxWindow *parent;
wxStaticBitmap* lockbitmap;
wxWindow* panelProgress;
wxBoxSizer* sizerProgress;
wxStaticText* labelProgress;
wxGauge* gaugeProgress;
virtual void ProgressStart(const char* text, Enctain::progress_indicator_type pitype,
size_t value, size_t limit);
virtual void ProgressUpdate(size_t value);
virtual void ProgressStop();
private:
DECLARE_EVENT_TABLE()
};
class WAbout : public wxDialog
{
public:
WAbout(wxWindow* parent, int id=wxID_ANY, const wxString& title=wxEmptyString, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE);
private:
void set_properties();
void do_layout();
protected:
wxStaticBitmap* bitmapIcon;
wxStaticBitmap* bitmapWeb;
wxHyperlinkCtrl* hyperlink1;
wxStaticText* labelBuildTime;
wxButton* buttonOK;
};
class WWebUpdateCheck : public wxDialog
{
public:
WWebUpdateCheck(wxWindow* parent, const wxString& newversion, const wxString& changes, int id=wxID_ANY, const wxString& title=wxEmptyString, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE);
private:
void set_properties();
void do_layout();
protected:
wxStaticText* labelNewVersion;
wxHyperlinkCtrl* hyperlink1;
wxTextCtrl* textctrlChanges;
wxButton* buttonOK;
wxButton* buttonDisable;
wxButton* buttonClose;
virtual void OnButtonDisableWebUpdateCheck(wxCommandEvent &event);
protected:
DECLARE_EVENT_TABLE()
};
class WNotePage : public wxPanel
{
protected:
WNotePage(class WCryptoTE* _wmain);
class WCryptoTE* wmain;
void UpdateStatusBar(const wxString& str);
void SetModified(bool modified);
public:
int subfileid;
bool page_modified;
public:
virtual wxString GetCaption() = 0;
virtual void PageFocused() = 0;
virtual void PageBlurred() = 0;
virtual void PageSaveData() = 0;
virtual void PageClosed() = 0;
virtual size_t ImportFile(wxFile& file) = 0;
virtual void ExportBuffer(wxOutputStream& outstream) = 0;
virtual void StopQuickFind() = 0;
virtual bool DoQuickGoto(const wxString& gototext) = 0;
DECLARE_ABSTRACT_CLASS(WNotePage);
};
struct DataInputStream : public Enctain::DataInput
{
wxInputStream& is;
DataInputStream(wxInputStream& s)
: is(s)
{
}
virtual unsigned int Input(void* data, size_t maxlen)
{
return is.Read(data, maxlen).LastRead();
}
};
class DataOutputStream : public Enctain::DataOutput
{
public:
class wxOutputStream& outstream;
DataOutputStream(wxOutputStream& os)
: outstream(os)
{
}
virtual bool Output(const void* data, size_t datalen)
{
return outstream.Write(data, datalen).IsOk();
}
};
#endif