chmframe.h

00001 /*
00002 
00003   Copyright (C) 2003  Razvan Cojocaru <razvanco@gmx.net>
00004  
00005   This program is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009   
00010   This program is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU General Public License for more details.
00014   
00015   You should have received a copy of the GNU General Public License
00016   along with this program; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018   MA 02110-1301, USA.
00019 
00020 */
00021 
00022 
00023 #ifndef __CHMFRAME_H_
00024 #define __CHMFRAME_H_
00025 
00026 #include <wx/wx.h>
00027 #include <wx/html/htmprint.h>
00028 #include <wx/splitter.h>
00029 #include <wx/notebook.h>
00030 #include <wx/treectrl.h>
00031 #include <wx/panel.h>
00032 #include <wx/combobox.h>
00033 #include <wx/font.h>
00034 #include <wx/docview.h>
00035 #include <wx/thread.h>
00036 
00037 
00038 // Forward declarations.
00039 class CHMHtmlWindow;
00040 class CHMSearchPanel;
00041 class CHMIndexPanel;
00042 class wxFileType;
00043 class CHMHtmlNotebook;
00044 
00046 #define CHM_DEFAULT_FONT_SIZE 12
00047 
00049 #define CONTENTS_MARGIN 170
00050 
00051 
00052 #ifdef HAVE_CONFIG_H
00053 #       include <config.h>
00054 #else
00055         // this should never happen
00056 #       define VERSION "unknown"
00057 #endif
00058 
00059 
00061 enum
00062 {
00063         ID_Quit = 1,
00064         ID_About,
00065         ID_Open,
00066         ID_Fonts,
00067         ID_Print,
00068         ID_Home,
00069         ID_Forward,
00070         ID_Back,
00071         ID_Contents,
00072         ID_Bookmarks,
00073         ID_Add,
00074         ID_Remove,
00075         ID_FindInPage,
00076         ID_CopySelection,
00077         ID_Recent,
00078         ID_Notebook,
00079         ID_RegisterExtension,
00080         ID_CloseTab,
00081         ID_NewTab,
00082         ID_TreeCtrl = 1000,
00083 };
00084 
00085 
00096 class CHMFrame : public wxFrame {
00097 public:
00098 
00115         CHMFrame(const wxString& title, const wxString& booksDir,
00116                  const wxPoint& pos, const wxSize& size,
00117                  const wxString& normalFont = wxEmptyString,
00118                  const wxString& fixedFont = wxEmptyString,
00119                  const int fontSize = CHM_DEFAULT_FONT_SIZE,
00120                  const int sashPosition = CONTENTS_MARGIN,
00121                  const wxString& fullAppPath = wxEmptyString);
00122 
00124         ~CHMFrame();
00125 
00131         bool LoadCHM(const wxString& archive);
00132         
00133 
00139         bool LoadContextID( const int contextID );
00140 
00141 
00143         void UpdateCHMInfo();
00144 
00146         void AddHtmlView(const wxString& path, const wxString& link);
00147 
00148 protected:
00150         void OnQuit(wxCommandEvent& event);
00151 
00153         void OnAbout(wxCommandEvent& event);
00154 
00156         void OnOpen(wxCommandEvent& event);
00157 
00159         void OnChangeFonts(wxCommandEvent& event);
00160 
00162         void OnHome(wxCommandEvent& event);
00163 
00165         void OnHistoryForward(wxCommandEvent& event);
00166 
00168         void OnHistoryBack(wxCommandEvent& event);      
00169 
00174         void OnShowContents(wxCommandEvent& event);     
00175 
00177         void OnPrint(wxCommandEvent& event);
00178 
00180         void OnHistFile(wxCommandEvent& event);
00181 
00183         void OnFind(wxCommandEvent& event);
00184 
00186         void OnCopySelection(wxCommandEvent& event);
00187 
00189         void OnAddBookmark(wxCommandEvent& event);
00190 
00191 #if defined(__WXMSW__) || defined(__WXMAC__)
00193         void OnRegisterExtension(wxCommandEvent& event);        
00194 #endif// __WXMSW__
00195 
00197         void OnRemoveBookmark(wxCommandEvent& event);
00198 
00200         void OnBookmarkSel(wxCommandEvent &event);
00201 
00203         void OnSelectionChanged(wxTreeEvent& event);
00204 
00206         void OnCloseWindow(wxCloseEvent& event);
00207 
00209         void OnChar(wxKeyEvent &event);
00210 
00212         void OnCloseTab(wxCommandEvent& event);
00213 
00215         void OnNewTab(wxCommandEvent& event);
00216 private:
00218         wxMenuBar *CreateMenu();
00219 
00221         bool InitToolBar(wxToolBar *toolbar);
00222 
00224         wxPanel* CreateContentsPanel();
00225 
00227         void LoadBookmarks();
00228 
00230         void SaveBookmarks();
00231 
00233         void SaveExitInfo();
00234 
00235 private:
00236         CHMHtmlNotebook * _nbhtml;
00237         wxTreeCtrl* _tcl;
00238         wxSplitterWindow* _sw;
00239         wxMenu* _menuFile;
00240         wxToolBar* _tb;
00241         wxHtmlEasyPrinting* _ep;
00242         wxNotebook* _nb;
00243         wxComboBox* _cb;
00244         CHMSearchPanel* _csp;
00245         CHMIndexPanel* _cip;
00246 
00247         wxString _openPath;
00248         wxArrayString* _normalFonts;
00249         wxArrayString* _fixedFonts;
00250         wxString _normalFont;
00251         wxString _fixedFont;
00252         int _fontSize;
00253         bool _bookmarkSel;
00254         bool _bookmarksDeleted;
00255         int _sashPos;   
00256         wxFont _font;
00257         wxFileHistory _fh;
00258         wxString _fullAppPath;
00259 
00260 private:
00261         DECLARE_EVENT_TABLE()   
00262 };
00263 
00264 
00265 #endif // __CHMFRAME_H_
00266 
00267 
00268 /*
00269   Local Variables:
00270   mode: c++
00271   c-basic-offset: 8
00272   tab-width: 8
00273   c-indent-comments-syntactically-p: t
00274   c-tab-always-indent: t
00275   indent-tabs-mode: t
00276   End:
00277 */
00278 
00279 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8

Generated on Tue Apr 14 19:43:38 2009 for xCHM by  doxygen 1.5.4