]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/helpfrm.h
Committing in .
[wxWidgets.git] / include / wx / html / helpfrm.h
CommitLineData
8ec2b484
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: helpfrm.h
3// Purpose: wxHtmlHelpFrame
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_HELPFRM_H_
13#define _WX_HELPFRM_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
16a12a3d 23#include "wx/html/helpdata.h"
8ec2b484
HH
24#include "wx/window.h"
25#include "wx/frame.h"
26#include "wx/config.h"
27#include "wx/splitter.h"
28#include "wx/notebook.h"
29#include "wx/listbox.h"
30#include "wx/choice.h"
31#include "wx/html/htmlwin.h"
32
d5bb85a0 33
8ec2b484 34// style flags for the Help Frame
d5bb85a0
VS
35#define wxHF_TOOLBAR 0x0001
36#define wxHF_CONTENTS 0x0002
37#define wxHF_INDEX 0x0004
38#define wxHF_SEARCH 0x0008
39#define wxHF_DEFAULTSTYLE (wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH)
40
8ec2b484
HH
41
42// Command IDs :
d5bb85a0
VS
43enum
44{
8ec2b484
HH
45 wxID_HTML_PANEL = wxID_HIGHEST + 1,
46 wxID_HTML_BACK,
47 wxID_HTML_FORWARD,
48 wxID_HTML_TREECTRL,
49 wxID_HTML_INDEXPAGE,
50 wxID_HTML_INDEXLIST,
51 wxID_HTML_NOTEBOOK,
52 wxID_HTML_SEARCHPAGE,
53 wxID_HTML_SEARCHTEXT,
54 wxID_HTML_SEARCHLIST,
55 wxID_HTML_SEARCHBUTTON,
56 wxID_HTML_SEARCHCHOICE,
57 wxID_HTML_HELPFRAME // the id of wxHtmlHelpController's helpframe
d5bb85a0
VS
58}
59;
8ec2b484 60
d5bb85a0
VS
61
62typedef struct
b31ba288 63{
68364659 64 int x, y, w, h;
d5bb85a0
VS
65 long sashpos;
66 bool navig_on;
67}
68wxHtmlHelpFrameCfg;
69
70
b31ba288 71
8ec2b484
HH
72class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
73{
d5bb85a0
VS
74 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
75
76 public:
77 wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
78 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
79 const wxString& title = wxEmptyString,
80 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
81 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
82 int style = wxHF_DEFAULTSTYLE);
83 ~wxHtmlHelpFrame();
84
85 wxHtmlHelpData* GetData() { return m_Data; }
86
87 void SetTitleFormat(const wxString& format)
88 {
89 if (m_HtmlWin)
90 m_HtmlWin->SetRelatedFrame(this, format);
91 m_TitleFormat = format;
92 }
93 // Sets format of title of the frame. Must contain exactly one "%s"
94 // (for title of displayed HTML page)
95
96 bool Display(const wxString& x);
97 // Displays page x. If not found it will offect the user a choice of
98 // searching books.
99 // Looking for the page runs in these steps:
100 // 1. try to locate file named x (if x is for example "doc/howto.htm")
101 // 2. try to open starting page of book x
102 // 3. try to find x in contents (if x is for example "How To ...")
103 // 4. try to find x in index (if x is for example "How To ...")
104 bool Display(const int id);
105 // Alternative version that works with numeric ID.
106 // (uses extension to MS format, <param name="ID" value=id>, see docs)
107
108 bool DisplayContents();
109 // Displays help window and focuses contents.
110
111 bool DisplayIndex();
112 // Displays help window and focuses index.
113
114 bool KeywordSearch(const wxString& keyword);
115 // Searches for keyword. Returns TRUE and display page if found, return
116 // FALSE otherwise
117 // Syntax of keyword is Altavista-like:
118 // * words are separated by spaces
119 // (but "\"hello world\"" is only one world "hello world")
120 // * word may be pretended by + or -
121 // (+ : page must contain the word ; - : page can't contain the word)
122 // * if there is no + or - before the word, + is default
123 void RefreshLists(bool show_progress = FALSE);
124 // Refreshes Contents and Index tabs
125 void CreateContents(bool show_progress = FALSE);
126 // Adds items to m_Contents tree control
127 void CreateIndex(bool show_progress = FALSE);
128 // Adds items to m_IndexList
129 void CreateSearch();
130 // Add books to search choice panel
131 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
132 {
133 m_Config = config;
134 m_ConfigRoot = rootpath;
135 ReadCustomization(config, rootpath);
136 }
137 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
138 // saves custom settings into cfg config. it will use the path 'path'
139 // if given, otherwise it will save info into currently selected path.
140 // saved values : things set by SetFonts, SetBorders.
141 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
142 // ...
143 void OnToolbar(wxCommandEvent& event);
144 void OnContentsSel(wxTreeEvent& event);
145 void OnIndexSel(wxCommandEvent& event);
146 void OnSearchSel(wxCommandEvent& event);
147 void OnSearch(wxCommandEvent& event);
148 void OnCloseWindow(wxCloseEvent& event);
149
150 // Images:
151 enum {
152 IMG_Book = 0,
153 IMG_Folder,
5c172c17
VS
154 IMG_Page,
155 IMG_RootFolder
d5bb85a0
VS
156 };
157
158 protected:
159 wxHtmlHelpData* m_Data;
160 bool m_DataCreated; // m_Data created by frame, or supplied?
161 wxString m_TitleFormat; // title of the help frame
162 // below are various pointers to GUI components
163 wxHtmlWindow *m_HtmlWin;
164 wxSplitterWindow *m_Splitter;
165 wxNotebook *m_NavigPan;
166 wxTreeCtrl *m_ContentsBox;
167 wxImageList *m_ContentsImageList;
168 wxListBox *m_IndexBox;
169 wxTextCtrl *m_SearchText;
170 wxButton *m_SearchButton;
171 wxListBox *m_SearchList;
172 wxChoice *m_SearchChoice;
173
174 wxHtmlHelpFrameCfg m_Cfg;
175
176 wxConfigBase *m_Config;
177 wxString m_ConfigRoot;
178
179 // pagenumbers of controls in notebook (usually 0,1,2)
180 int m_ContentsPage;
181 int m_IndexPage;
182 int m_SearchPage;
183
184 protected:
185 void Init(wxHtmlHelpData* data = NULL);
186
187 DECLARE_EVENT_TABLE()
8ec2b484
HH
188};
189
190#endif
191
192#endif