if (style & wxHF_TOOLBAR) {
wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_DOCKABLE);
toolBar->SetMargins( 2, 2 );
-
- toolBar -> AddTool(wxID_HTML_PANEL, wxBITMAP(wpanel), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
- _("Show/hide navigation panel"));
- toolBar -> AddSeparator();
- toolBar -> AddTool(wxID_HTML_BACK, wxBITMAP(wback), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
- _("Go back to the previous HTML page"));
- toolBar -> AddTool(wxID_HTML_FORWARD, wxBITMAP(wforward), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
- _("Go forward to the next HTML page"));
- toolBar -> AddSeparator();
-
- if (style & wxHF_BOOKMARKS) {
- m_Bookmarks = new wxComboBox(toolBar, wxID_HTML_BOOKMARKSLIST, wxEmptyString,
- wxDefaultPosition, wxSize(300,-1), 0, NULL, wxCB_READONLY | wxCB_SORT);
- m_Bookmarks -> Append(_("<bookmarks>"));
- for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++)
- m_Bookmarks -> Append(m_BookmarksNames[i]);
- m_Bookmarks -> SetSelection(0);
- toolBar -> AddControl(m_Bookmarks);
-#ifdef __WXGTK__
- toolBar -> AddSeparator();
-#endif
- toolBar -> AddTool(wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
- _("Add current page to bookmarks"));
- toolBar -> AddTool(wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
- _("Remove current page from bookmarks"));
- }
-
- toolBar -> AddSeparator();
- toolBar -> AddTool(wxID_HTML_OPTIONS, wxBITMAP(woptions), wxNullBitmap,
- FALSE, -1, -1, (wxObject *) NULL,
- _("Display options dialog"));
-
+ AddToolbarButtons(toolBar, style);
toolBar -> Realize();
}
}
m_HtmlWin -> Show(TRUE);
- //RefreshLists();
+ RefreshLists();
// showtime
if (m_NavigPan && m_Splitter) {
wxHtmlHelpFrame::~wxHtmlHelpFrame()
{
+ PopEventHandler(); // wxhtmlhelpcontroller
delete m_ContentsImageList;
if (m_DataCreated)
delete m_Data;
if (m_FixedFonts) delete m_FixedFonts;
}
+
+void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar *toolBar, int style)
+{
+ toolBar -> AddTool(wxID_HTML_PANEL, wxBITMAP(wpanel), wxNullBitmap,
+ FALSE, -1, -1, (wxObject *) NULL,
+ _("Show/hide navigation panel"));
+ toolBar -> AddSeparator();
+ toolBar -> AddTool(wxID_HTML_BACK, wxBITMAP(wback), wxNullBitmap,
+ FALSE, -1, -1, (wxObject *) NULL,
+ _("Go back to the previous HTML page"));
+ toolBar -> AddTool(wxID_HTML_FORWARD, wxBITMAP(wforward), wxNullBitmap,
+ FALSE, -1, -1, (wxObject *) NULL,
+ _("Go forward to the next HTML page"));
+ toolBar -> AddSeparator();
+
+ if (style & wxHF_BOOKMARKS) {
+ m_Bookmarks = new wxComboBox(toolBar, wxID_HTML_BOOKMARKSLIST, wxEmptyString,
+ wxDefaultPosition, wxSize(300,-1), 0, NULL, wxCB_READONLY | wxCB_SORT);
+ m_Bookmarks -> Append(_("<bookmarks>"));
+ for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++)
+ m_Bookmarks -> Append(m_BookmarksNames[i]);
+ m_Bookmarks -> SetSelection(0);
+ toolBar -> AddControl(m_Bookmarks);
+#ifdef __WXGTK__
+ toolBar -> AddSeparator();
+#endif
+ toolBar -> AddTool(wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxNullBitmap,
+ FALSE, -1, -1, (wxObject *) NULL,
+ _("Add current page to bookmarks"));
+ toolBar -> AddTool(wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxNullBitmap,
+ FALSE, -1, -1, (wxObject *) NULL,
+ _("Remove current page from bookmarks"));
+ }
+
+ toolBar -> AddSeparator();
+ toolBar -> AddTool(wxID_HTML_OPTIONS, wxBITMAP(woptions), wxNullBitmap,
+ FALSE, -1, -1, (wxObject *) NULL,
+ _("Display options dialog"));
+}
+
+
+
bool wxHtmlHelpFrame::Display(const wxString& x)
{
wxString url = m_Data->FindPageByName(x);
return TRUE;
}
+
+
bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword)
{
if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice))
while (status.IsActive()) {
curi = status.GetCurIndex();
- if (curi % 10 == 0 && progress.Update(curi) == FALSE)
+ if (curi % 32 == 0 && progress.Update(curi) == FALSE)
break;
if (status.Search()) {
foundstr.Printf(_("Found %i matches"), ++foundcnt);
progress.Update(status.GetCurIndex(), foundstr);
m_SearchList -> Append(status.GetName(), status.GetContentsItem());
}
- wxYield();
}
m_SearchButton -> Enable(TRUE);
#define MAX_ROOTS 64
-void wxHtmlHelpFrame::CreateContents(bool show_progress)
+void wxHtmlHelpFrame::CreateContents()
{
if (! m_ContentsBox)
return ;
- wxProgressDialog *progress = NULL;
- wxString proginfo;
-
m_ContentsBox->Clear();
int cnt = m_Data->GetContentsCnt();
- int div = (cnt / PROGRESS_STEP) + 1;
int i;
wxHtmlContentsItem *it;
- if (show_progress)
- progress = new wxProgressDialog(_("Building contents tree..."), wxEmptyString,
- cnt, this, wxPD_APP_MODAL | wxPD_CAN_ABORT |
- wxPD_AUTO_HIDE);
-
wxTreeItemId roots[MAX_ROOTS];
bool imaged[MAX_ROOTS];
imaged[0] = TRUE;
for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++) {
- if (show_progress && ((i % div) == 0)) {
- proginfo.Printf(_("Added %d/%d items"), i, cnt);
- if (! progress->Update(i, proginfo))
- break;
- wxYield();
- }
roots[it -> m_Level + 1] = m_ContentsBox -> AppendItem(
roots[it -> m_Level], it -> m_Name, IMG_Page, -1,
new wxHtmlHelpTreeItemData(it));
imaged[it -> m_Level] = TRUE;
}
}
- if (show_progress)
- delete progress;
m_ContentsBox -> Expand(roots[0]);
}
-void wxHtmlHelpFrame::CreateIndex(bool show_progress)
+void wxHtmlHelpFrame::CreateIndex()
{
if (! m_IndexList)
return ;
- wxProgressDialog *progress = NULL;
- wxString proginfo;
-
m_IndexList->Clear();
int cnt = m_Data->GetIndexCnt();
m_IndexCountInfo -> SetLabel(cnttext);
if (cnt > INDEX_IS_SMALL) return;
- int div = (cnt / PROGRESS_STEP) + 1;
-
wxHtmlContentsItem* index = m_Data->GetIndex();
- if (show_progress)
- progress = new wxProgressDialog(_("Building index list..."), wxEmptyString,
- cnt, this, wxPD_APP_MODAL | wxPD_CAN_ABORT |
- wxPD_AUTO_HIDE);
- for (int i = 0; i < cnt; i++) {
- if (show_progress && ((i % div) == 0)) {
- proginfo.Printf(_("Added %d/%d items"), i, cnt);
- if (! progress->Update(i, proginfo))
- break;
- wxYield();
- }
+ for (int i = 0; i < cnt; i++)
m_IndexList -> Append(index[i].m_Name, (char*)(index + i));
- }
-
- if (show_progress)
- delete progress;
}
void wxHtmlHelpFrame::CreateSearch()
}
-void wxHtmlHelpFrame::RefreshLists(bool show_progress)
+void wxHtmlHelpFrame::RefreshLists()
{
- CreateContents(show_progress);
- CreateIndex(show_progress);
+ CreateContents();
+ CreateIndex();
CreateSearch();
}