]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/helpdata.h
Added missing costructor
[wxWidgets.git] / include / wx / html / helpdata.h
CommitLineData
8ec2b484
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: helpdata.h
3// Purpose: wxHtmlHelpData
f42b1601 4// Notes: Based on htmlhelp.cpp, implementing a monolithic
8ec2b484
HH
5// HTML Help controller class, by Vaclav Slavik
6// Author: Harm van der Heijden and Vaclav Slavik
69941f05 7// RCS-ID: $Id$
8ec2b484
HH
8// Copyright: (c) Harm van der Heijden and Vaclav Slavik
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_HELPDATA_H_
13#define _WX_HELPDATA_H_
14
15#ifdef __GNUG__
69941f05 16#pragma interface
8ec2b484
HH
17#endif
18
19#include "wx/defs.h"
20
21#if wxUSE_HTML
22
23#include "wx/object.h"
24#include "wx/string.h"
25#include "wx/filesys.h"
26#include "wx/dynarray.h"
27
28//--------------------------------------------------------------------------------
29// helper classes & structs
30//--------------------------------------------------------------------------------
31
32class WXDLLEXPORT wxHtmlBookRecord : public wxObject
33{
34public:
f42b1601 35 wxHtmlBookRecord(const wxString& basepath, const wxString& title,
8ec2b484
HH
36 const wxString& start) {
37 m_BasePath = basepath; m_Title = title; m_Start = start;
38 // for debugging, give the contents index obvious default values
39 contents_start = contents_end = -1;
40 }
41 wxString GetTitle() const {return m_Title;}
42 wxString GetStart() const {return m_Start;}
43 wxString GetBasePath() const {return m_BasePath;}
44 /* SetContentsRange: store in the bookrecord where in the index/contents lists the
45 * book's records are stored. This to facilitate searching in a specific book.
46 * This code will have to be revised when loading/removing books becomes dynamic.
f42b1601 47 * (as opposed to appending only)
8ec2b484
HH
48 * Note that storing index range is pointless, because the index is alphab. sorted. */
49 void SetContentsRange(int start, int end) { contents_start = start; contents_end = end; }
f42b1601
RD
50 int GetContentsStart() const { return contents_start; }
51 int GetContentsEnd() const { return contents_end; }
8ec2b484
HH
52protected:
53 wxString m_BasePath;
54 wxString m_Title;
55 wxString m_Start;
56 int contents_start;
57 int contents_end;
58};
59
60
61#undef WXDLLEXPORTLOCAL
62#define WXDLLEXPORTLOCAL WXDLLEXPORT
63 // ?? Don't know why - but Allen Van Sickel reported it to fix problems with DLL
64WX_DECLARE_OBJARRAY(wxHtmlBookRecord, wxHtmlBookRecArray);
65
66#undef WXDLLEXPORTLOCAL
67#define WXDLLEXPORTLOCAL
68
69
70typedef struct
71{
72 short int m_Level;
73 int m_ID;
74 char* m_Name;
75 char* m_Page;
76 wxHtmlBookRecord *m_Book;
77} wxHtmlContentsItem;
78
79//------------------------------------------------------------------------------
80// wxSearchEngine
81// This class takes input streams and scans them for occurence
82// of keyword(s)
83//------------------------------------------------------------------------------
f42b1601 84class WXDLLEXPORT wxSearchEngine : public wxObject
8ec2b484
HH
85{
86private:
87 char *m_Keyword;
88
89public:
90 wxSearchEngine() : wxObject() {m_Keyword = NULL;}
91 ~wxSearchEngine() {if (m_Keyword) free(m_Keyword);}
f42b1601 92
8ec2b484
HH
93 virtual void LookFor(const wxString& keyword);
94 // Sets the keyword we will be searching for
95
96 virtual bool Scan(wxInputStream *stream);
97 // Scans the stream for the keyword.
98 // Returns TRUE if the stream contains keyword, fALSE otherwise
99};
100
101class wxHtmlHelpData;
102
103// State information of a search action. I'd have prefered to make this a nested
104// class inside wxHtmlHelpData, but that's against coding standards :-(
f42b1601 105// Never construct this class yourself, obtain a copy from
8ec2b484
HH
106// wxHtmlHelpData::PrepareKeywordSearch(const wxString& key)
107class WXDLLEXPORT wxHtmlSearchStatus
108{
109public:
110 // constructor; supply wxHtmlHelpData ptr, the keyword and (optionally) the
111 // title of the book to search. By default, all books are searched.
112 wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
113 const wxString& book = wxEmptyString);
114 bool Search(); // do the next iteration
115 bool IsActive() { return m_Active; }
116 int GetCurIndex() { return m_CurIndex; }
117 int GetMaxIndex() { return m_MaxIndex; }
118 const wxString& GetName() { return m_Name; }
119 wxHtmlContentsItem* GetContentsItem() { return m_ContentsItem; }
120private:
121 wxHtmlHelpData* m_Data;
122 wxSearchEngine m_Engine;
123 wxString m_Keyword, m_Name, m_LastPage;
f42b1601 124 wxHtmlContentsItem* m_ContentsItem;
8ec2b484
HH
125 bool m_Active; // search is not finished
126 int m_CurIndex; // where we are now
f42b1601 127 int m_MaxIndex; // number of files we search
8ec2b484
HH
128 // For progress bar: 100*curindex/maxindex = % complete
129};
130
131class WXDLLEXPORT wxHtmlHelpData : public wxObject
132{
133 DECLARE_DYNAMIC_CLASS(wxHtmlHelpData)
134
135 friend class wxHtmlSearchStatus;
136
137public:
138 wxHtmlHelpData();
139 ~wxHtmlHelpData();
f42b1601 140
8ec2b484
HH
141 void SetTempDir(const wxString& path);
142 // Sets directory where temporary files are stored.
143 // These temp files are index & contents file in binary (much faster to read)
144 // form. These files are NOT deleted on program's exit.
f42b1601 145
8ec2b484
HH
146 bool AddBook(const wxString& book);
147 // Adds new book. 'book' is location of .htb file (stands for "html book").
148 // See documentation for details on its format.
149 // Returns success.
f42b1601
RD
150 bool AddBookParam(const wxString& title, const wxString& contfile,
151 const wxString& indexfile=wxEmptyString,
152 const wxString& deftopic=wxEmptyString,
8ec2b484 153 const wxString& path=wxEmptyString);
f42b1601 154
8ec2b484
HH
155 // Some accessing stuff
156 wxString FindPageByName(const wxString& page);
157 // returns URL of page on basis of (file)name
158 wxString FindPageById(int id);
159 // returns URL of page on basis of MS id
160
161 const wxHtmlBookRecArray& GetBookRecArray() { return m_BookRecords; }
162 wxHtmlContentsItem* GetContents() { return m_Contents; }
163 int GetContentsCnt() { return m_ContentsCnt; }
164 wxHtmlContentsItem* GetIndex() { return m_Index; }
165 int GetIndexCnt() { return m_IndexCnt; }
f42b1601 166
8ec2b484
HH
167protected:
168 wxString m_TempPath;
f42b1601 169
8ec2b484
HH
170 wxHtmlBookRecArray m_BookRecords;
171 // each book has one record in this array
172 wxHtmlContentsItem* m_Contents;
173 int m_ContentsCnt;
174 // list of all available books and pages.
175 wxHtmlContentsItem* m_Index;
176 int m_IndexCnt;
177 // list of index items
f42b1601 178
8ec2b484 179protected:
f42b1601 180 bool LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys,
8ec2b484
HH
181 const wxString& indexfile, const wxString& contentsfile);
182 // Imports .hhp files (MS HTML Help Workshop)
183 bool LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f);
184 // Reads binary book
185 bool SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f);
186 // Writes binary book
187};
188
189#endif
190
191#endif