1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of html classes
7 // Created: 25-nov-1998
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/html/htmlwin.h>
20 #include <wx/fs_zip.h>
21 #include <wx/fs_inet.h>
22 #include <wx/wfstream.h>
26 //---------------------------------------------------------------------------
29 %include my_typemaps.i
42 //---------------------------------------------------------------------------
55 wxID_HTML_SEARCHBUTTON
58 class wxHtmlHelpController : public wxEvtHandler {
60 wxHtmlHelpController();
61 ~wxHtmlHelpController();
70 void SetTitleFormat(const wxString& format) {m_TitleFormat = format;}
71 // Sets format of title of the frame. Must contain exactly one "%s"
72 // (for title of displayed HTML page)
74 void SetTempDir(const wxString& path);
75 // Sets directory where temporary files are stored.
76 // These temp files are index & contents file in binary (much faster to read)
77 // form. These files are NOT deleted on program's exit.
79 bool AddBook(const wxString& book, bool show_wait_msg = FALSE);
80 // Adds new book. 'book' is location of .htb file (stands for "html book").
81 // See documentation for details on its format.
83 // If show_wait_msg == true then message window with "loading book..." is displayed
85 void Display(const wxString& x);
86 // Displays page x. If not found it will offect the user a choice of searching
88 // Looking for the page runs in these steps:
89 // 1. try to locate file named x (if x is for example "doc/howto.htm")
90 // 2. try to open starting page of book x
91 // 3. try to find x in contents (if x is for example "How To ...")
92 // 4. try to find x in index (if x is for example "How To ...")
93 // 5. offer searching and if the user agree, run KeywordSearch
94 %name(DisplayID) void Display(const int id);
95 // Alternative version that works with numeric ID.
96 // (uses extension to MS format, <param name="ID" value=id>, see docs)
98 void DisplayContents();
99 // Displays help window and focuses contents.
102 // Displays help window and focuses index.
104 bool KeywordSearch(const wxString& keyword);
105 // Searches for keyword. Returns TRUE and display page if found, return
107 // Syntax of keyword is Altavista-like:
108 // * words are separated by spaces
109 // (but "\"hello world\"" is only one world "hello world")
110 // * word may be pretended by + or -
111 // (+ : page must contain the word ; - : page can't contain the word)
112 // * if there is no + or - before the word, + is default
114 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
115 // Assigns config object to the controller. This config is then
116 // used in subsequent calls to Read/WriteCustomization of both help
117 // controller and it's wxHtmlWindow
119 void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
120 // saves custom settings into cfg config. it will use the path 'path'
121 // if given, otherwise it will save info into currently selected path.
122 // saved values : things set by SetFonts, SetBorders.
123 void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
127 class wxHtmlHelpSystem : public wxHtmlHelpController {
129 wxHtmlHelpSystem() {};
130 ~wxHtmlHelpSystem() {};
132 bool AddBookParam(const wxString& title, const wxString& contfile,
133 const wxString& indexfile=wxEmptyString, const wxString& deftopic=wxEmptyString,
134 const wxString& path=wxEmptyString, bool show_wait_msg=FALSE);
135 // Alternative to AddBook(wxString& hhpfile)
136 wxToolBar* CreateToolBar(wxFrame* frame);
137 // creates a dockable toolbar for the frame, containing hide/show, back and forward buttons
138 wxTreeCtrl* CreateContentsTree(wxWindow* parent);
139 // creates a treecontrol with imagelist for books, folders etc and id wxID_HTML_TREECTRL
140 wxListBox* CreateIndexList(wxWindow* parent);
141 // creates a listbox with the right id
142 virtual void CreateHelpWindow();
143 // Slightly different version than in wxHtmlHelpController; uses helpers above
144 // Do nothing if the window already exists
145 void SetControls(wxFrame* frame, wxHtmlWindow* htmlwin,
146 wxTreeCtrl* contents=NULL, wxListBox* index=NULL,
147 wxListBox* searchlist=NULL);
148 // alternative for CreateHelpWindow(), sets frame, htmlwindow, contents tree, index
149 // listbox and searchlist listbox. If null, their functionality won't be used
151 // Some extra accessor functions
152 wxFrame* GetFrame() { return m_Frame; }
153 wxHtmlWindow* GetHtmlWindow() { return m_HtmlWin; }
154 wxTreeCtrl* GetContentsTree() { return m_ContentsBox; }
155 wxListBox* GetIndexList() { return m_IndexBox; }
156 wxListBox* GetSearchList() { return m_SearchList; }
157 wxImageList* GetContentsImageList() { return m_ContentsImageList; }
158 // public interface for wxHtmlHelpControllers handlers, so wxPython can call them
159 void OnToolbar(wxCommandEvent& event);
160 void OnContentsSel(wxTreeEvent& event) {wxHtmlHelpController::OnContentsSel(event);}
161 void OnIndexSel(wxCommandEvent& event) {wxHtmlHelpController::OnIndexSel(event);}
162 void OnSearchSel(wxCommandEvent& event) {wxHtmlHelpController::OnSearchSel(event);}
163 void OnSearch(wxCommandEvent& event) {wxHtmlHelpController::OnSearch(event);}
164 void OnCloseWindow(wxCloseEvent& event);
166 // some more protected functions that should be accessible from wxPython
168 void CreateContents() { if (!m_IndexBox) return; wxHtmlHelpController::CreateContents(); }
169 // Adds items to m_Contents tree control
170 void CreateIndex() { if (! m_ContentsBox) return; wxHtmlHelpController::CreateIndex(); }
171 // Adds items to m_IndexList
174 // just for fun, an Altavista-like search engine (the gems that Vaclav has hidden in wxHtml...)
175 // but not for wxMSW because it's not DLL exported
177 #ifdef THIS_IS_NOT_DEFINED_OKAY
181 wxSearchEngine() : wxObject() {m_Keyword = NULL;}
182 ~wxSearchEngine() {if (m_Keyword) free(m_Keyword);}
184 void LookFor(const wxString& keyword);
185 // Sets the keyword we will be searching for
187 bool Scan(wxInputStream *stream);
188 // Scans the stream for the keyword.
189 // Returns TRUE if the stream contains keyword, fALSE otherwise
191 bool ScanFile(const wxString& filename) {
192 if (filename.IsEmpty())
194 wxFileInputStream istr(filename);
195 return self->Scan(&istr);
201 //---------------------------------------------------------------------------