added font encoding support
[wxWidgets.git] / utils / wxPython / modules / html / htmlhelp.i
CommitLineData
0f66a9f3
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: htmlhelp.i
3// Purpose: SWIG definitions of html classes
4//
5// Author: Robin Dunn
6//
7// Created: 25-nov-1998
8// RCS-ID: $Id$
9// Copyright: (c) 1998 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13
14%module htmlhelp
15
16%{
17#include "helpers.h"
18#include <wx/html/htmlwin.h>
2f90df85 19#include <wx/html/helpctrl.h>
0f66a9f3
RD
20#include <wx/image.h>
21#include <wx/fs_zip.h>
22#include <wx/fs_inet.h>
23#include <wx/wfstream.h>
0f66a9f3
RD
24%}
25
26//---------------------------------------------------------------------------
27
28%include typemaps.i
29%include my_typemaps.i
30
31%extern wx.i
32%extern windows.i
2f90df85 33%extern frames.i
0f66a9f3
RD
34%extern _defs.i
35%extern events.i
36%extern controls.i
37%extern controls2.i
38
39%extern utils.i
40
41%extern html.i
42
43//---------------------------------------------------------------------------
44
45enum {
46 wxID_HTML_PANEL,
47 wxID_HTML_BACK,
48 wxID_HTML_FORWARD,
49 wxID_HTML_TREECTRL,
50 wxID_HTML_INDEXPAGE,
51 wxID_HTML_INDEXLIST,
52 wxID_HTML_NOTEBOOK,
53 wxID_HTML_SEARCHPAGE,
54 wxID_HTML_SEARCHTEXT,
55 wxID_HTML_SEARCHLIST,
56 wxID_HTML_SEARCHBUTTON
57};
58
2f90df85
RD
59//---------------------------------------------------------------------------
60
61class wxHtmlHelpFrameCfg
62{
0f66a9f3 63public:
2f90df85
RD
64 wxHtmlHelpFrameCfg();
65
66 long x, y, w, h;
67 long sashpos;
68 bool navig_on;
69 int style;
70 wxString titleformat;
71};
72
73
74//---------------------------------------------------------------------------
75
76class wxHtmlBookRecord {
77public:
78 wxHtmlBookRecord(const wxString& basepath, const wxString& title,
79 const wxString& start);
80
81 wxString GetTitle();
82 wxString GetStart();
83 wxString GetBasePath();
84
85 void SetContentsRange(int start, int end);
86 int GetContentsStart();
87 int GetContentsEnd();
88};
89
90//---------------------------------------------------------------------------
91
92typedef struct
93{
94 short int m_Level;
95 int m_ID;
96 char* m_Name;
97 char* m_Page;
98 wxHtmlBookRecord *m_Book;
99} wxHtmlContentsItem;
100
101//---------------------------------------------------------------------------
102
103class wxHtmlSearchStatus
104{
105public:
106 //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
107 // const wxString& book = wxEmptyString);
108 bool Search();
109 bool IsActive();
110 int GetCurIndex();
111 int GetMaxIndex();
112 const wxString& GetName();
113 wxHtmlContentsItem* GetContentsItem();
114};
0f66a9f3 115
2f90df85 116//---------------------------------------------------------------------------
0f66a9f3 117
2f90df85
RD
118class wxHtmlHelpData {
119public:
120 wxHtmlHelpData();
121 ~wxHtmlHelpData();
0f66a9f3
RD
122
123 void SetTempDir(const wxString& path);
2f90df85
RD
124 bool AddBook(const wxString& book);
125 bool AddBookParam(const wxString& title, const wxString& contfile,
126 const wxString& indexfile=wxEmptyString,
127 const wxString& deftopic=wxEmptyString,
128 const wxString& path=wxEmptyString);
0f66a9f3 129
2f90df85
RD
130 wxString FindPageByName(const wxString& page);
131 wxString FindPageById(int id);
0f66a9f3 132
2f90df85
RD
133 // **** this one needs fixed...
134 const wxHtmlBookRecArray& GetBookRecArray();
0f66a9f3 135
2f90df85
RD
136 wxHtmlContentsItem* GetContents();
137 int GetContentsCnt();
138 wxHtmlContentsItem* GetIndex();
139 int GetIndexCnt();
140};
0f66a9f3 141
2f90df85 142//---------------------------------------------------------------------------
0f66a9f3 143
2f90df85
RD
144class wxHtmlHelpFrame : public wxFrame {
145public:
146 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
147 const wxString& title = wxEmptyString,
148 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
0f66a9f3 149
2f90df85
RD
150 wxHtmlHelpData* GetData();
151 void SetTitleFormat(const wxString& format);
152 void Display(const wxString& x);
153 %name(DisplayID) void Display(int id);
154 void DisplayContents();
155 void DisplayIndex();
156 bool KeywordSearch(const wxString& keyword);
157 void RefreshLists(int show_progress = FALSE);
158 void CreateContents(int show_progress = FALSE);
159 void CreateIndex(int show_progress = FALSE);
160 void CreateSearch();
0f66a9f3 161 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
2f90df85
RD
162 void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
163 void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
164};
0f66a9f3 165
2f90df85
RD
166
167//---------------------------------------------------------------------------
168
169class wxHtmlHelpController : public wxEvtHandler {
170public:
171 wxHtmlHelpController();
172 ~wxHtmlHelpController();
173
174 void SetTitleFormat(const wxString& format);
175 void SetTempDir(const wxString& path);
176 bool AddBook(const wxString& book, int show_wait_msg = FALSE);
177 void Display(const wxString& x);
178 %name(DisplayID) void Display(int id);
179 void DisplayContents();
180 void DisplayIndex();
181 bool KeywordSearch(const wxString& keyword);
182 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
0f66a9f3 183 void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
0f66a9f3 184 void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
2f90df85
RD
185 wxHtmlHelpFrame* GetFrame();
186 void CreateHelpWindow(int show_progress = FALSE);
0f66a9f3
RD
187};
188
2f90df85
RD
189//---------------------------------------------------------------------------
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205#ifdef DO_WE_NEED_TO_KEEP_THIS
0f66a9f3
RD
206class wxHtmlHelpSystem : public wxHtmlHelpController {
207public:
208 wxHtmlHelpSystem() {};
209 ~wxHtmlHelpSystem() {};
210
211 bool AddBookParam(const wxString& title, const wxString& contfile,
212 const wxString& indexfile=wxEmptyString, const wxString& deftopic=wxEmptyString,
213 const wxString& path=wxEmptyString, bool show_wait_msg=FALSE);
214 // Alternative to AddBook(wxString& hhpfile)
215 wxToolBar* CreateToolBar(wxFrame* frame);
216 // creates a dockable toolbar for the frame, containing hide/show, back and forward buttons
217 wxTreeCtrl* CreateContentsTree(wxWindow* parent);
218 // creates a treecontrol with imagelist for books, folders etc and id wxID_HTML_TREECTRL
219 wxListBox* CreateIndexList(wxWindow* parent);
220 // creates a listbox with the right id
221 virtual void CreateHelpWindow();
222 // Slightly different version than in wxHtmlHelpController; uses helpers above
223 // Do nothing if the window already exists
224 void SetControls(wxFrame* frame, wxHtmlWindow* htmlwin,
225 wxTreeCtrl* contents=NULL, wxListBox* index=NULL,
226 wxListBox* searchlist=NULL);
227 // alternative for CreateHelpWindow(), sets frame, htmlwindow, contents tree, index
228 // listbox and searchlist listbox. If null, their functionality won't be used
229
230 // Some extra accessor functions
231 wxFrame* GetFrame() { return m_Frame; }
232 wxHtmlWindow* GetHtmlWindow() { return m_HtmlWin; }
233 wxTreeCtrl* GetContentsTree() { return m_ContentsBox; }
234 wxListBox* GetIndexList() { return m_IndexBox; }
235 wxListBox* GetSearchList() { return m_SearchList; }
236 wxImageList* GetContentsImageList() { return m_ContentsImageList; }
237 // public interface for wxHtmlHelpControllers handlers, so wxPython can call them
238 void OnToolbar(wxCommandEvent& event);
239 void OnContentsSel(wxTreeEvent& event) {wxHtmlHelpController::OnContentsSel(event);}
240 void OnIndexSel(wxCommandEvent& event) {wxHtmlHelpController::OnIndexSel(event);}
241 void OnSearchSel(wxCommandEvent& event) {wxHtmlHelpController::OnSearchSel(event);}
242 void OnSearch(wxCommandEvent& event) {wxHtmlHelpController::OnSearch(event);}
243 void OnCloseWindow(wxCloseEvent& event);
244
245 // some more protected functions that should be accessible from wxPython
246 void RefreshLists();
247 void CreateContents() { if (!m_IndexBox) return; wxHtmlHelpController::CreateContents(); }
248 // Adds items to m_Contents tree control
249 void CreateIndex() { if (! m_ContentsBox) return; wxHtmlHelpController::CreateIndex(); }
250 // Adds items to m_IndexList
251};
252
253// just for fun, an Altavista-like search engine (the gems that Vaclav has hidden in wxHtml...)
254// but not for wxMSW because it's not DLL exported
255//#ifndef __WXMSW__
256#ifdef THIS_IS_NOT_DEFINED_OKAY
257class wxSearchEngine
258{
259 public:
260 wxSearchEngine() : wxObject() {m_Keyword = NULL;}
261 ~wxSearchEngine() {if (m_Keyword) free(m_Keyword);}
262
263 void LookFor(const wxString& keyword);
264 // Sets the keyword we will be searching for
265
266 bool Scan(wxInputStream *stream);
267 // Scans the stream for the keyword.
268 // Returns TRUE if the stream contains keyword, fALSE otherwise
269 %addmethods {
270 bool ScanFile(const wxString& filename) {
271 if (filename.IsEmpty())
272 return false;
273 wxFileInputStream istr(filename);
274 return self->Scan(&istr);
275 }
276 }
277};
278#endif
2f90df85 279#endif
0f66a9f3 280//---------------------------------------------------------------------------