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