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>
19 #include <wx/html/helpctrl.h>
21 #include <wx/fs_zip.h>
22 #include <wx/fs_inet.h>
23 #include <wx/wfstream.h>
26 //---------------------------------------------------------------------------
29 %include my_typemaps.i
43 //---------------------------------------------------------------------------
56 wxID_HTML_SEARCHBUTTON,
57 wxID_HTML_SEARCHCHOICE,
62 //---------------------------------------------------------------------------
64 class wxHtmlHelpFrameCfg
75 //---------------------------------------------------------------------------
77 class wxHtmlBookRecord {
79 wxHtmlBookRecord(const wxString& basepath, const wxString& title,
80 const wxString& start);
84 wxString GetBasePath();
86 void SetContentsRange(int start, int end);
87 int GetContentsStart();
91 //---------------------------------------------------------------------------
99 wxHtmlBookRecord *m_Book;
100 } wxHtmlContentsItem;
102 //---------------------------------------------------------------------------
104 class wxHtmlSearchStatus
107 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
108 // const wxString& book = wxEmptyString);
113 const wxString& GetName();
114 wxHtmlContentsItem* GetContentsItem();
117 //---------------------------------------------------------------------------
119 class wxHtmlHelpData {
124 void SetTempDir(const wxString& path);
125 bool AddBook(const wxString& book);
126 bool AddBookParam(const wxString& title, const wxString& contfile,
127 const wxString& indexfile=wxEmptyString,
128 const wxString& deftopic=wxEmptyString,
129 const wxString& path=wxEmptyString);
131 wxString FindPageByName(const wxString& page);
132 wxString FindPageById(int id);
134 // **** this one needs fixed...
135 const wxHtmlBookRecArray& GetBookRecArray();
137 wxHtmlContentsItem* GetContents();
138 int GetContentsCnt();
139 wxHtmlContentsItem* GetIndex();
143 //---------------------------------------------------------------------------
145 class wxHtmlHelpFrame : public wxFrame {
147 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
148 const wxString& title = wxEmptyString,
149 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
151 wxHtmlHelpData* GetData();
152 void SetTitleFormat(const wxString& format);
153 void Display(const wxString& x);
154 %name(DisplayID) void Display(int id);
155 void DisplayContents();
157 bool KeywordSearch(const wxString& keyword);
158 void RefreshLists(int show_progress = FALSE);
159 void CreateContents(int show_progress = FALSE);
160 void CreateIndex(int show_progress = FALSE);
162 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
163 void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
164 void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
168 //---------------------------------------------------------------------------
170 class wxHtmlHelpController : public wxEvtHandler {
172 wxHtmlHelpController();
173 ~wxHtmlHelpController();
175 void SetTitleFormat(const wxString& format);
176 void SetTempDir(const wxString& path);
177 bool AddBook(const wxString& book, int show_wait_msg = FALSE);
178 void Display(const wxString& x);
179 %name(DisplayID) void Display(int id);
180 void DisplayContents();
182 bool KeywordSearch(const wxString& keyword);
183 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
184 void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
185 void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
186 wxHtmlHelpFrame* GetFrame();
187 void CreateHelpWindow(int show_progress = FALSE);
190 //---------------------------------------------------------------------------
206 #ifdef DO_WE_NEED_TO_KEEP_THIS
207 class wxHtmlHelpSystem : public wxHtmlHelpController {
209 wxHtmlHelpSystem() {};
210 ~wxHtmlHelpSystem() {};
212 bool AddBookParam(const wxString& title, const wxString& contfile,
213 const wxString& indexfile=wxEmptyString, const wxString& deftopic=wxEmptyString,
214 const wxString& path=wxEmptyString, bool show_wait_msg=FALSE);
215 // Alternative to AddBook(wxString& hhpfile)
216 wxToolBar* CreateToolBar(wxFrame* frame);
217 // creates a dockable toolbar for the frame, containing hide/show, back and forward buttons
218 wxTreeCtrl* CreateContentsTree(wxWindow* parent);
219 // creates a treecontrol with imagelist for books, folders etc and id wxID_HTML_TREECTRL
220 wxListBox* CreateIndexList(wxWindow* parent);
221 // creates a listbox with the right id
222 virtual void CreateHelpWindow();
223 // Slightly different version than in wxHtmlHelpController; uses helpers above
224 // Do nothing if the window already exists
225 void SetControls(wxFrame* frame, wxHtmlWindow* htmlwin,
226 wxTreeCtrl* contents=NULL, wxListBox* index=NULL,
227 wxListBox* searchlist=NULL);
228 // alternative for CreateHelpWindow(), sets frame, htmlwindow, contents tree, index
229 // listbox and searchlist listbox. If null, their functionality won't be used
231 // Some extra accessor functions
232 wxFrame* GetFrame() { return m_Frame; }
233 wxHtmlWindow* GetHtmlWindow() { return m_HtmlWin; }
234 wxTreeCtrl* GetContentsTree() { return m_ContentsBox; }
235 wxListBox* GetIndexList() { return m_IndexBox; }
236 wxListBox* GetSearchList() { return m_SearchList; }
237 wxImageList* GetContentsImageList() { return m_ContentsImageList; }
238 // public interface for wxHtmlHelpControllers handlers, so wxPython can call them
239 void OnToolbar(wxCommandEvent& event);
240 void OnContentsSel(wxTreeEvent& event) {wxHtmlHelpController::OnContentsSel(event);}
241 void OnIndexSel(wxCommandEvent& event) {wxHtmlHelpController::OnIndexSel(event);}
242 void OnSearchSel(wxCommandEvent& event) {wxHtmlHelpController::OnSearchSel(event);}
243 void OnSearch(wxCommandEvent& event) {wxHtmlHelpController::OnSearch(event);}
244 void OnCloseWindow(wxCloseEvent& event);
246 // some more protected functions that should be accessible from wxPython
248 void CreateContents() { if (!m_IndexBox) return; wxHtmlHelpController::CreateContents(); }
249 // Adds items to m_Contents tree control
250 void CreateIndex() { if (! m_ContentsBox) return; wxHtmlHelpController::CreateIndex(); }
251 // Adds items to m_IndexList
254 // just for fun, an Altavista-like search engine (the gems that Vaclav has hidden in wxHtml...)
255 // but not for wxMSW because it's not DLL exported
257 #ifdef THIS_IS_NOT_DEFINED_OKAY
261 wxSearchEngine() : wxObject() {m_Keyword = NULL;}
262 ~wxSearchEngine() {if (m_Keyword) free(m_Keyword);}
264 void LookFor(const wxString& keyword);
265 // Sets the keyword we will be searching for
267 bool Scan(wxInputStream *stream);
268 // Scans the stream for the keyword.
269 // Returns TRUE if the stream contains keyword, fALSE otherwise
271 bool ScanFile(const wxString& filename) {
272 if (filename.IsEmpty())
274 wxFileInputStream istr(filename);
275 return self->Scan(&istr);
281 //---------------------------------------------------------------------------