m_SearchButton = NULL;
m_SearchText = NULL;
m_SearchChoice = NULL;
+ m_IndexCountInfo = NULL;
m_Splitter = NULL;
m_NavigPan = NULL;
m_HtmlWin = NULL;
m_Bookmarks = NULL;
+ m_SearchCaseSensitive = NULL;
+ m_SearchWholeWords = NULL;
+
m_Config = NULL;
m_ConfigRoot = wxEmptyString;
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();
}
// contents tree panel?
if (style & wxHF_CONTENTS) {
- m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL,
- wxDefaultPosition, wxDefaultSize,
- wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
- m_ContentsBox -> SetImageList(m_ContentsImageList);
- m_NavigPan -> AddPage(m_ContentsBox, _("Contents"));
+ wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE);
+
+ if (style & wxHF_BOOKMARKS) {
+ wxLayoutConstraints *b1 = new wxLayoutConstraints;
+ wxBitmapButton *bmpbt = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxDefaultPosition, wxSize(20,20));
+
+ b1 -> top.SameAs (dummy, wxTop, 10);
+ b1 -> right.SameAs (dummy, wxRight, 10);
+ b1 -> height.AsIs();
+ b1 -> width.AsIs();
+ bmpbt -> SetConstraints(b1);
+
+ wxLayoutConstraints *b2 = new wxLayoutConstraints;
+ wxBitmapButton *bmpbt2 = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxDefaultPosition, wxSize(20,20));
+
+ b2 -> top.SameAs (dummy, wxTop, 10);
+ b2 -> right.LeftOf (bmpbt, 2);
+ b2 -> height.AsIs();
+ b2 -> width.AsIs();
+ bmpbt2 -> SetConstraints(b2);
+
+#if wxUSE_TOOLTIPS
+ bmpbt -> SetToolTip(_("Remove current page from bookmarks"));
+ bmpbt2 -> SetToolTip(_("Add current page to bookmarks"));
+#endif //wxUSE_TOOLTIPS
+
+ wxLayoutConstraints *b3 = new wxLayoutConstraints;
+ m_Bookmarks = new wxComboBox(dummy, wxID_HTML_BOOKMARKSLIST, wxEmptyString,
+ wxDefaultPosition, wxDefaultSize, 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);
+
+ b3 -> centreY.SameAs (bmpbt2, wxCentreY);
+ b3 -> left.SameAs (dummy, wxLeft, 10);
+ b3 -> right.LeftOf (bmpbt2, 5);
+ b3 -> height.AsIs();
+ m_Bookmarks -> SetConstraints(b3);
+
+
+ wxLayoutConstraints *b4 = new wxLayoutConstraints;
+ m_ContentsBox = new wxTreeCtrl(dummy, wxID_HTML_TREECTRL,
+ wxDefaultPosition, wxDefaultSize,
+ wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
+ m_ContentsBox -> SetImageList(m_ContentsImageList);
+
+ b4 -> top.Below (m_Bookmarks, 10);
+ b4 -> left.SameAs (dummy, wxLeft, 0);
+ b4 -> right.SameAs (dummy, wxRight, 0);
+ b4 -> bottom.SameAs (dummy, wxBottom, 0);
+ m_ContentsBox -> SetConstraints(b4);
+
+ dummy -> SetAutoLayout(TRUE);
+ dummy -> Layout();
+
+ m_NavigPan -> AddPage(dummy, _("Contents"));
+ }
+
+ else
+ {
+ m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL,
+ wxDefaultPosition, wxDefaultSize,
+ wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
+ m_ContentsBox -> SetImageList(m_ContentsImageList);
+ m_NavigPan -> AddPage(m_ContentsBox, _("Contents"));
+ }
+
m_ContentsPage = notebook_page++;
}
b2 -> height.AsIs();
m_IndexButton -> SetConstraints(b2);
+ wxLayoutConstraints *b5 = new wxLayoutConstraints;
+ m_IndexCountInfo = new wxStaticText(dummy, wxID_HTML_COUNTINFO, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
+
+ b5 -> top.Below (m_IndexButton, 5);
+ b5 -> right.SameAs (dummy, wxRight, 10);
+ b5 -> left.SameAs (dummy, wxLeft, 10);
+ b5 -> height.AsIs();
+ m_IndexCountInfo -> SetConstraints(b5);
+
wxLayoutConstraints *b3 = new wxLayoutConstraints;
m_IndexList = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_ALWAYS_SB);
- b3 -> top.Below (m_IndexButton, 10);
+ b3 -> top.Below (m_IndexCountInfo, 5);
b3 -> left.SameAs (dummy, wxLeft, 0);
b3 -> right.SameAs (dummy, wxRight, 0);
b3 -> bottom.SameAs (dummy, wxBottom, 0);
#if wxUSE_TOOLTIPS
m_IndexButtonAll -> SetToolTip(_("Show all items in index"));
- m_IndexButton -> SetToolTip(_("Display all index items that contain given substring. Note that this is case sensitive, so 'window' and 'Window' is something else!"));
+ m_IndexButton -> SetToolTip(_("Display all index items that contain given substring. Search is case insensitive."));
#endif //wxUSE_TOOLTIPS
dummy -> SetAutoLayout(TRUE);
b1 -> height.AsIs();
m_SearchText -> SetConstraints(b1);
+ wxLayoutConstraints *b4 = new wxLayoutConstraints;
+ m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, wxDefaultPosition,
+ wxDefaultSize);
+ b4 -> top.Below (m_SearchText, 10);
+ b4 -> left.SameAs (dummy, wxLeft, 10);
+ b4 -> right.SameAs (dummy, wxRight, 10);
+ b4 -> height.AsIs();
+ m_SearchChoice -> SetConstraints(b4);
+
+ wxLayoutConstraints *b5 = new wxLayoutConstraints;
+ m_SearchCaseSensitive = new wxCheckBox(dummy, -1, _("Case sensitive"));
+ b5 -> top.Below (m_SearchChoice, 10);
+ b5 -> left.SameAs (dummy, wxLeft, 10);
+ b5 -> width.AsIs();
+ b5 -> height.AsIs ();
+ m_SearchCaseSensitive -> SetConstraints(b5);
+
+ wxLayoutConstraints *b6 = new wxLayoutConstraints;
+ m_SearchWholeWords = new wxCheckBox(dummy, -1, _("Whole words only"));
+ b6 -> top.Below (m_SearchCaseSensitive, 0);
+ b6 -> left.SameAs (dummy, wxLeft, 10);
+ b6 -> width.AsIs();
+ b6 -> height.AsIs ();
+ m_SearchWholeWords -> SetConstraints(b6);
+
wxLayoutConstraints *b2 = new wxLayoutConstraints;
m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search"));
#if wxUSE_TOOLTIPS
m_SearchButton -> SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above"));
#endif //wxUSE_TOOLTIPS
- b2 -> top.Below (m_SearchText, 10);
- b2 -> left.SameAs (dummy, wxLeft, 10);
+ b2 -> top.Below (m_SearchWholeWords, 0);
+ b2 -> right.SameAs (dummy, wxRight, 10);
b2 -> width.AsIs();
b2 -> height.AsIs();
m_SearchButton -> SetConstraints(b2);
- wxLayoutConstraints *b4 = new wxLayoutConstraints;
- m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, wxDefaultPosition,
- wxDefaultSize);
- b4 -> top.Below (m_SearchText, 10);
- b4 -> left.SameAs (m_SearchButton, wxRight, 10);
- b4 -> right.SameAs (dummy, wxRight, 10);
- b4 -> height.AsIs();
- m_SearchChoice -> SetConstraints(b4);
-
wxLayoutConstraints *b3 = new wxLayoutConstraints;
m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_ALWAYS_SB);
b3 -> top.Below (m_SearchButton, 10);
}
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();
+
+ 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))
return FALSE;
- int foundcnt = 0;
+ int foundcnt = 0, curi;
wxString foundstr;
wxString book = wxEmptyString;
if (m_SearchChoice->GetSelection() != 0)
book = m_SearchChoice->GetStringSelection();
- wxHtmlSearchStatus status(m_Data, keyword, book);
+ wxHtmlSearchStatus status(m_Data, keyword,
+ m_SearchCaseSensitive -> GetValue(), m_SearchWholeWords -> GetValue(),
+ book);
wxProgressDialog progress(_("Searching..."), _("No matching page found yet"),
status.GetMaxIndex(), this,
- wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
+ wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE | wxGA_SMOOTH);
while (status.IsActive()) {
- if (progress.Update(status.GetCurIndex()) == FALSE)
+ curi = status.GetCurIndex();
+ 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();
+ wxString cnttext;
+ if (cnt > INDEX_IS_SMALL) cnttext.Printf(_("%i of %i"), 0, cnt);
+ else cnttext.Printf(_("%i of %i"), cnt, cnt);
+ 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()
return ;
m_SearchList -> Clear();
m_SearchChoice -> Clear();
- m_SearchChoice -> Append(_("all books"));
+ m_SearchChoice -> Append(_("Search in all books"));
const wxHtmlBookRecArray& bookrec = m_Data->GetBookRecArray();
int i, cnt = bookrec.GetCount();
for (i = 0; i < cnt; i++)
}
-void wxHtmlHelpFrame::RefreshLists(bool show_progress)
+void wxHtmlHelpFrame::RefreshLists()
{
- CreateContents(show_progress);
- CreateIndex(show_progress);
+ CreateContents();
+ CreateIndex();
CreateSearch();
}
if (path != wxEmptyString) {
oldpath = cfg -> GetPath();
- cfg -> SetPath(path);
+ cfg -> SetPath(_T("/") + path);
}
m_Cfg.navig_on = cfg -> Read("hcNavigPanel", m_Cfg.navig_on) != 0;
m_BookmarksPages.Clear();
if (m_Bookmarks) {
m_Bookmarks -> Clear();
- m_Bookmarks -> Append(_("<bookmarks>"));
+ m_Bookmarks -> Append(_("(bookmarks)"));
}
for (i = 0; i < cnt; i++) {
- val.Printf("hcBookmark_%i", i);
+ val.Printf(wxT("hcBookmark_%i"), i);
s = cfg -> Read(val);
m_BookmarksNames.Add(s);
if (m_Bookmarks) m_Bookmarks -> Append(s);
- val.Printf("hcBookmark_%i_url", i);
+ val.Printf(wxT("hcBookmark_%i_url"), i);
s = cfg -> Read(val);
m_BookmarksPages.Add(s);
}
}
if (m_HtmlWin)
- m_HtmlWin->ReadCustomization(cfg, path);
+ m_HtmlWin->ReadCustomization(cfg);
if (path != wxEmptyString)
cfg -> SetPath(oldpath);
if (path != wxEmptyString) {
oldpath = cfg -> GetPath();
- cfg -> SetPath(path);
+ cfg -> SetPath(_T("/") + path);
}
cfg -> Write("hcNavigPanel", m_Cfg.navig_on);
cfg -> Write("hcBookmarksCnt", (long)cnt);
for (i = 0; i < cnt; i++) {
- val.Printf("hcBookmark_%i", i);
+ val.Printf(wxT("hcBookmark_%i"), i);
cfg -> Write(val, m_BookmarksNames[i]);
- val.Printf("hcBookmark_%i_url", i);
+ val.Printf(wxT("hcBookmark_%i_url"), i);
cfg -> Write(val, m_BookmarksPages[i]);
}
}
if (m_HtmlWin)
- m_HtmlWin->WriteCustomization(cfg, path);
+ m_HtmlWin->WriteCustomization(cfg);
if (path != wxEmptyString)
cfg -> SetPath(oldpath);
void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event)
{
wxString sr = m_IndexText -> GetLineText(0);
+ sr.MakeLower();
if (sr == wxEmptyString)
OnIndexAll(event);
else {
wxBusyCursor bcur;
const wxChar *cstr = sr.c_str();
+ wxChar mybuff[512], *ptr;
bool first = TRUE;
m_IndexList->Clear();
int cnt = m_Data->GetIndexCnt();
wxHtmlContentsItem* index = m_Data->GetIndex();
+ int displ = 0;
for (int i = 0; i < cnt; i++)
- if (wxStrstr(index[i].m_Name, cstr) != NULL) {
+ {
+ wxStrncpy(mybuff, index[i].m_Name, 512);
+ mybuff[511] = 0;
+ for (ptr = mybuff; *ptr != 0; ptr++)
+ if (*ptr >= 'A' && *ptr <= 'Z') *ptr -= 'A' - 'a';
+ if (wxStrstr(mybuff, cstr) != NULL) {
m_IndexList -> Append(index[i].m_Name, (char*)(index + i));
+ displ++;
if (first) {
m_HtmlWin -> LoadPage(index[i].m_Book -> GetBasePath() + index[i].m_Page);
first = FALSE;
}
}
+ }
+
+ wxString cnttext;
+ cnttext.Printf(_("%i of %i"), displ, cnt);
+ m_IndexCountInfo -> SetLabel(cnttext);
m_IndexText -> SetSelection(0, sr.Length());
m_IndexText -> SetFocus();
first = FALSE;
}
}
+
+ wxString cnttext;
+ cnttext.Printf(_("%i of %i"), cnt, cnt);
+ m_IndexCountInfo -> SetLabel(cnttext);
}
{
wxString sr = m_Bookmarks -> GetStringSelection();
- if (sr != wxEmptyString && sr != _("<bookmarks>"))
+ if (sr != wxEmptyString && sr != _("(bookmarks)"))
m_HtmlWin -> LoadPage(m_BookmarksPages[m_BookmarksNames.Index(sr)]);
}
}
BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame)
- EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_BOOKMARKSREMOVE, wxHtmlHelpFrame::OnToolbar)
+ EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_OPTIONS, wxHtmlHelpFrame::OnToolbar)
+ EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE, wxHtmlHelpFrame::OnToolbar)
+ EVT_BUTTON(wxID_HTML_BOOKMARKSADD, wxHtmlHelpFrame::OnToolbar)
EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpFrame::OnContentsSel)
EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpFrame::OnIndexSel)
EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpFrame::OnSearchSel)