added wxHtmlHelpController and -System wrappers. See README for some remarks
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3544 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -9,3 +9,12 @@ html
|
|||||||
There's also a python tag handler, see htmlwidget.py for
|
There's also a python tag handler, see htmlwidget.py for
|
||||||
a demonstration.
|
a demonstration.
|
||||||
|
|
||||||
|
Aug. 31 1999
|
||||||
|
Added wxHtmlHelpController and wxHtmlHelpSystem wrappers
|
||||||
|
wxHtmlHelpSystem is a subclass of the controller, and is still very
|
||||||
|
rough around the edges. The idea is that it gives the python
|
||||||
|
programmer more freedom in the look'n'feel of the html help window.
|
||||||
|
Will be opening up negotiations on the wxwin list to see if
|
||||||
|
the wxHtmlController code can be reorganised in a base and GUI
|
||||||
|
part.
|
||||||
|
|
||||||
|
@@ -3,4 +3,6 @@
|
|||||||
MODULE = 'htmlc'
|
MODULE = 'htmlc'
|
||||||
SWIGFILES = ['html.i', ]
|
SWIGFILES = ['html.i', ]
|
||||||
PYFILES = ['htmlhelper.py']
|
PYFILES = ['htmlhelper.py']
|
||||||
|
SOURCES = ['helpsys.cpp']
|
||||||
|
# include path for htmlhelp's xpm bitmaps
|
||||||
|
OTHERCFLAGS = "-I%s/src/html" % (WXDIR,)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -111,6 +111,148 @@ class wxHtmlWindow(wxHtmlWindowPtr):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class wxHtmlHelpControllerPtr(wxEvtHandlerPtr):
|
||||||
|
IMG_Book = htmlc.wxHtmlHelpController_IMG_Book
|
||||||
|
IMG_Folder = htmlc.wxHtmlHelpController_IMG_Folder
|
||||||
|
IMG_Page = htmlc.wxHtmlHelpController_IMG_Page
|
||||||
|
def __init__(self,this):
|
||||||
|
self.this = this
|
||||||
|
self.thisown = 0
|
||||||
|
def __del__(self,htmlc=htmlc):
|
||||||
|
if self.thisown == 1 :
|
||||||
|
htmlc.delete_wxHtmlHelpController(self)
|
||||||
|
def SetTitleFormat(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_SetTitleFormat,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def SetTempDir(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_SetTempDir,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def AddBook(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_AddBook,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def Display(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_Display,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def DisplayID(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_DisplayID,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def DisplayContents(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_DisplayContents,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def DisplayIndex(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_DisplayIndex,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def KeywordSearch(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_KeywordSearch,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def UseConfig(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_UseConfig,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def ReadCustomization(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_ReadCustomization,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def WriteCustomization(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpController_WriteCustomization,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def __repr__(self):
|
||||||
|
return "<C wxHtmlHelpController instance at %s>" % (self.this,)
|
||||||
|
class wxHtmlHelpController(wxHtmlHelpControllerPtr):
|
||||||
|
def __init__(self,*_args,**_kwargs):
|
||||||
|
self.this = apply(htmlc.new_wxHtmlHelpController,_args,_kwargs)
|
||||||
|
self.thisown = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class wxHtmlHelpSystemPtr(wxHtmlHelpControllerPtr):
|
||||||
|
def __init__(self,this):
|
||||||
|
self.this = this
|
||||||
|
self.thisown = 0
|
||||||
|
def __del__(self,htmlc=htmlc):
|
||||||
|
if self.thisown == 1 :
|
||||||
|
htmlc.delete_wxHtmlHelpSystem(self)
|
||||||
|
def AddBookParam(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_AddBookParam,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def CreateToolBar(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_CreateToolBar,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxToolBarPtr(val)
|
||||||
|
return val
|
||||||
|
def CreateContentsTree(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_CreateContentsTree,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxTreeCtrlPtr(val)
|
||||||
|
return val
|
||||||
|
def CreateIndexList(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_CreateIndexList,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxListBoxPtr(val)
|
||||||
|
return val
|
||||||
|
def CreateHelpWindow(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_CreateHelpWindow,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def SetControls(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_SetControls,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def GetFrame(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_GetFrame,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxFramePtr(val)
|
||||||
|
return val
|
||||||
|
def GetHtmlWindow(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_GetHtmlWindow,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxHtmlWindowPtr(val)
|
||||||
|
return val
|
||||||
|
def GetContentsTree(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_GetContentsTree,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxTreeCtrlPtr(val)
|
||||||
|
return val
|
||||||
|
def GetIndexList(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_GetIndexList,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxListBoxPtr(val)
|
||||||
|
return val
|
||||||
|
def GetSearchList(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_GetSearchList,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxListBoxPtr(val)
|
||||||
|
return val
|
||||||
|
def GetContentsImageList(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_GetContentsImageList,(self,) + _args, _kwargs)
|
||||||
|
if val: val = wxImageListPtr(val)
|
||||||
|
return val
|
||||||
|
def OnToolbar(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_OnToolbar,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def OnContentsSel(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_OnContentsSel,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def OnIndexSel(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_OnIndexSel,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def OnSearchSel(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_OnSearchSel,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def OnSearch(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_OnSearch,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def OnCloseWindow(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_OnCloseWindow,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def RefreshLists(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_RefreshLists,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def CreateContents(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_CreateContents,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def CreateIndex(self, *_args, **_kwargs):
|
||||||
|
val = apply(htmlc.wxHtmlHelpSystem_CreateIndex,(self,) + _args, _kwargs)
|
||||||
|
return val
|
||||||
|
def __repr__(self):
|
||||||
|
return "<C wxHtmlHelpSystem instance at %s>" % (self.this,)
|
||||||
|
class wxHtmlHelpSystem(wxHtmlHelpSystemPtr):
|
||||||
|
def __init__(self,*_args,**_kwargs):
|
||||||
|
self.this = apply(htmlc.new_wxHtmlHelpSystem,_args,_kwargs)
|
||||||
|
self.thisown = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-------------- FUNCTION WRAPPERS ------------------
|
#-------------- FUNCTION WRAPPERS ------------------
|
||||||
@@ -119,3 +261,14 @@ class wxHtmlWindow(wxHtmlWindowPtr):
|
|||||||
|
|
||||||
#-------------- VARIABLE WRAPPERS ------------------
|
#-------------- VARIABLE WRAPPERS ------------------
|
||||||
|
|
||||||
|
wxID_HTML_PANEL = htmlc.wxID_HTML_PANEL
|
||||||
|
wxID_HTML_BACK = htmlc.wxID_HTML_BACK
|
||||||
|
wxID_HTML_FORWARD = htmlc.wxID_HTML_FORWARD
|
||||||
|
wxID_HTML_TREECTRL = htmlc.wxID_HTML_TREECTRL
|
||||||
|
wxID_HTML_INDEXPAGE = htmlc.wxID_HTML_INDEXPAGE
|
||||||
|
wxID_HTML_INDEXLIST = htmlc.wxID_HTML_INDEXLIST
|
||||||
|
wxID_HTML_NOTEBOOK = htmlc.wxID_HTML_NOTEBOOK
|
||||||
|
wxID_HTML_SEARCHPAGE = htmlc.wxID_HTML_SEARCHPAGE
|
||||||
|
wxID_HTML_SEARCHTEXT = htmlc.wxID_HTML_SEARCHTEXT
|
||||||
|
wxID_HTML_SEARCHLIST = htmlc.wxID_HTML_SEARCHLIST
|
||||||
|
wxID_HTML_SEARCHBUTTON = htmlc.wxID_HTML_SEARCHBUTTON
|
||||||
|
322
utils/wxPython/modules/html/helpsys.cpp
Normal file
322
utils/wxPython/modules/html/helpsys.cpp
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
/* htmlsys.h : wxHtmlHelpSystem is an extension of the wxHtmlHelpController.
|
||||||
|
* mainly does two things:
|
||||||
|
* - extend the interface somewhat so the programmer can dictate most of the
|
||||||
|
* look and feel of the htmlhelp frame.
|
||||||
|
* - make some protected functions public (adding _ to the function name) so
|
||||||
|
* that SWIG can wrap them.
|
||||||
|
*
|
||||||
|
* Harm van der Heijden 32aug1999
|
||||||
|
*/
|
||||||
|
#include "helpsys.h"
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#include <wx/wfstream.h>
|
||||||
|
#include <wx/busyinfo.h>
|
||||||
|
|
||||||
|
// Bitmaps:
|
||||||
|
#ifndef __WXMSW__
|
||||||
|
#include "bitmaps/panel.xpm"
|
||||||
|
#include "bitmaps/back.xpm"
|
||||||
|
#include "bitmaps/forward.xpm"
|
||||||
|
#include "bitmaps/book.xpm"
|
||||||
|
#include "bitmaps/folder.xpm"
|
||||||
|
#include "bitmaps/page.xpm"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpSystem, wxHtmlHelpController)
|
||||||
|
|
||||||
|
// The two static funtions below are also defined in htmlhelp.cpp
|
||||||
|
// maybe they should be protected class functions.
|
||||||
|
static wxString SafeFileName(const wxString& s)
|
||||||
|
{
|
||||||
|
wxString res = s;
|
||||||
|
res.Replace(":", "_", TRUE);
|
||||||
|
res.Replace(" ", "_", TRUE);
|
||||||
|
res.Replace("/", "_", TRUE);
|
||||||
|
res.Replace("\\", "_", TRUE);
|
||||||
|
res.Replace("#", "_", TRUE);
|
||||||
|
res.Replace(".", "_", TRUE);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int IndexCompareFunc(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return strcmp(((HtmlContentsItem*)a) -> m_Name, ((HtmlContentsItem*)b) -> m_Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxHtmlHelpSystem::AddBookParam(const wxString& title, const wxString& contfile,
|
||||||
|
const wxString& indexfile, const wxString& deftopic,
|
||||||
|
const wxString& path, bool show_wait_msg)
|
||||||
|
{
|
||||||
|
wxFileSystem fsys;
|
||||||
|
wxFSFile *fi;
|
||||||
|
HtmlBookRecord *bookr;
|
||||||
|
wxString safetitle;
|
||||||
|
|
||||||
|
if (! path.IsEmpty())
|
||||||
|
// workaround for bug in ChangePathTo(name, TRUE)
|
||||||
|
fsys.ChangePathTo(path+"/gaga");
|
||||||
|
|
||||||
|
bookr = new HtmlBookRecord(path+'/', title, deftopic);
|
||||||
|
|
||||||
|
if (m_ContentsCnt % HTML_REALLOC_STEP == 0)
|
||||||
|
m_Contents = (HtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + HTML_REALLOC_STEP) * sizeof(HtmlContentsItem));
|
||||||
|
m_Contents[m_ContentsCnt].m_Level = 0;
|
||||||
|
m_Contents[m_ContentsCnt].m_ID = 0;
|
||||||
|
m_Contents[m_ContentsCnt].m_Page = new char[deftopic.Length() + 1];
|
||||||
|
strcpy(m_Contents[m_ContentsCnt].m_Page, deftopic.c_str());
|
||||||
|
m_Contents[m_ContentsCnt].m_Name = new char [title.Length() + 1];
|
||||||
|
strcpy(m_Contents[m_ContentsCnt].m_Name, title.c_str());
|
||||||
|
m_Contents[m_ContentsCnt].m_Book = bookr;
|
||||||
|
m_ContentsCnt++;
|
||||||
|
|
||||||
|
// Try to find cached binary versions:
|
||||||
|
safetitle = SafeFileName(title);
|
||||||
|
fi = fsys.OpenFile(safetitle + ".cached");
|
||||||
|
if (fi == NULL) fi = fsys.OpenFile(m_TempPath + safetitle + ".cached");
|
||||||
|
if ((fi == NULL) || (m_TempPath == wxEmptyString)) {
|
||||||
|
LoadMSProject(bookr, fsys, indexfile, contfile, show_wait_msg);
|
||||||
|
if (m_TempPath != wxEmptyString) {
|
||||||
|
wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath + safetitle + ".cached");
|
||||||
|
SaveCachedBook(bookr, outs);
|
||||||
|
delete outs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LoadCachedBook(bookr, fi -> GetStream());
|
||||||
|
delete fi;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_BookRecords.Add(bookr);
|
||||||
|
if (m_IndexCnt > 0)
|
||||||
|
qsort(m_Index, m_IndexCnt, sizeof(HtmlContentsItem), IndexCompareFunc);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxToolBar* wxHtmlHelpSystem::CreateToolBar(wxFrame* frame)
|
||||||
|
{
|
||||||
|
wxToolBar *toolBar;
|
||||||
|
toolBar = frame -> CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE);
|
||||||
|
toolBar -> SetMargins(2, 2);
|
||||||
|
wxBitmap* toolBarBitmaps[3];
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
toolBarBitmaps[0] = new wxBitmap("panel");
|
||||||
|
toolBarBitmaps[1] = new wxBitmap("back");
|
||||||
|
toolBarBitmaps[2] = new wxBitmap("forward");
|
||||||
|
int width = 24;
|
||||||
|
#else
|
||||||
|
toolBarBitmaps[0] = new wxBitmap(panel_xpm);
|
||||||
|
toolBarBitmaps[1] = new wxBitmap(back_xpm);
|
||||||
|
toolBarBitmaps[2] = new wxBitmap(forward_xpm);
|
||||||
|
int width = 16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int currentX = 5;
|
||||||
|
|
||||||
|
toolBar -> AddTool(wxID_HTML_PANEL, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Show/hide navigation panel"));
|
||||||
|
currentX += width + 5;
|
||||||
|
toolBar -> AddSeparator();
|
||||||
|
toolBar -> AddTool(wxID_HTML_BACK, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Go back to the previous HTML page"));
|
||||||
|
currentX += width + 5;
|
||||||
|
toolBar -> AddTool(wxID_HTML_FORWARD, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Go forward to the next HTML page"));
|
||||||
|
currentX += width + 5;
|
||||||
|
|
||||||
|
toolBar -> Realize();
|
||||||
|
|
||||||
|
// Can delete the bitmaps since they're reference counted
|
||||||
|
for (int i = 0; i < 3; i++) delete toolBarBitmaps[i];
|
||||||
|
return toolBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTreeCtrl* wxHtmlHelpSystem::CreateContentsTree(wxWindow* parent)
|
||||||
|
{
|
||||||
|
wxTreeCtrl* tree;
|
||||||
|
tree = new wxTreeCtrl(parent, wxID_HTML_TREECTRL, wxDefaultPosition,
|
||||||
|
wxDefaultSize, wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
|
||||||
|
tree -> SetImageList(m_ContentsImageList);
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxListBox* wxHtmlHelpSystem::CreateIndexList(wxWindow* parent)
|
||||||
|
{
|
||||||
|
return new wxListBox(parent, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxHtmlHelpSystem::SetControls(wxFrame* frame, wxHtmlWindow* htmlwin,
|
||||||
|
wxTreeCtrl* contents, wxListBox* index,
|
||||||
|
wxListBox* searchlist)
|
||||||
|
{
|
||||||
|
m_Frame = frame;
|
||||||
|
m_HtmlWin = htmlwin;
|
||||||
|
m_ContentsBox = contents;
|
||||||
|
m_IndexBox = index;
|
||||||
|
m_SearchList = searchlist;
|
||||||
|
m_SearchText = NULL; // provide your own input box
|
||||||
|
/* if you're setting your own controls, you and your event handlers are
|
||||||
|
* responsible for any splitter and notebook adjustments, not the
|
||||||
|
* htmlhelp framework */
|
||||||
|
m_Splitter = NULL;
|
||||||
|
m_NavigPan = NULL;
|
||||||
|
RefreshLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxHtmlHelpSystem::CreateHelpWindow()
|
||||||
|
{
|
||||||
|
wxBusyCursor cur;
|
||||||
|
wxString oldpath;
|
||||||
|
wxStatusBar *sbar;
|
||||||
|
|
||||||
|
if (m_Frame) {
|
||||||
|
m_Frame -> Raise();
|
||||||
|
m_Frame -> Show(TRUE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if wxUSE_BUSYINFO
|
||||||
|
wxBusyInfo busyinfo(_("Preparing help window..."));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (m_Config) ReadCustomization(m_Config, m_ConfigRoot);
|
||||||
|
|
||||||
|
m_Frame = new wxFrame(NULL, -1, "", wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h));
|
||||||
|
m_Frame -> PushEventHandler(this);
|
||||||
|
sbar = m_Frame -> CreateStatusBar();
|
||||||
|
|
||||||
|
CreateToolBar(m_Frame);
|
||||||
|
|
||||||
|
{
|
||||||
|
m_Splitter = new wxSplitterWindow(m_Frame);
|
||||||
|
|
||||||
|
m_HtmlWin = new wxHtmlWindow(m_Splitter);
|
||||||
|
m_HtmlWin -> SetRelatedFrame(m_Frame, m_TitleFormat);
|
||||||
|
m_HtmlWin -> SetRelatedStatusBar(0);
|
||||||
|
if (m_Config) m_HtmlWin -> ReadCustomization(m_Config, m_ConfigRoot);
|
||||||
|
|
||||||
|
m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
|
||||||
|
if (m_ContentsCnt) {
|
||||||
|
m_ContentsBox = CreateContentsTree(m_NavigPan);
|
||||||
|
m_NavigPan -> AddPage(m_ContentsBox, _("Contents"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_IndexCnt) {
|
||||||
|
wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE);
|
||||||
|
wxLayoutConstraints *b1 = new wxLayoutConstraints;
|
||||||
|
b1 -> top.SameAs (dummy, wxTop, 0);
|
||||||
|
b1 -> left.SameAs (dummy, wxLeft, 0);
|
||||||
|
b1 -> width.PercentOf (dummy, wxWidth, 100);
|
||||||
|
b1 -> bottom.SameAs (dummy, wxBottom, 0);
|
||||||
|
m_IndexBox = CreateIndexList(dummy);
|
||||||
|
m_IndexBox -> SetConstraints(b1);
|
||||||
|
|
||||||
|
dummy -> SetAutoLayout(TRUE);
|
||||||
|
m_NavigPan -> AddPage(dummy, _("Index"));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE);
|
||||||
|
|
||||||
|
wxLayoutConstraints *b1 = new wxLayoutConstraints;
|
||||||
|
m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT);
|
||||||
|
b1 -> top.SameAs (dummy, wxTop, 0);
|
||||||
|
b1 -> left.SameAs (dummy, wxLeft, 0);
|
||||||
|
b1 -> right.SameAs (dummy, wxRight, 0);
|
||||||
|
b1 -> height.AsIs();
|
||||||
|
m_SearchText -> SetConstraints(b1);
|
||||||
|
|
||||||
|
wxLayoutConstraints *b2 = new wxLayoutConstraints;
|
||||||
|
m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search!"));
|
||||||
|
b2 -> top.Below (m_SearchText, 10);
|
||||||
|
b2 -> right.SameAs (dummy, wxRight, 10);
|
||||||
|
b2 -> width.AsIs();
|
||||||
|
b2 -> height.AsIs();
|
||||||
|
m_SearchButton -> SetConstraints(b2);
|
||||||
|
|
||||||
|
wxLayoutConstraints *b3 = new wxLayoutConstraints;
|
||||||
|
m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
b3 -> top.Below (m_SearchButton, 10);
|
||||||
|
b3 -> left.SameAs (dummy, wxLeft, 0);
|
||||||
|
b3 -> right.SameAs (dummy, wxRight, 0);
|
||||||
|
b3 -> bottom.SameAs (dummy, wxBottom, 0);
|
||||||
|
m_SearchList -> SetConstraints(b3);
|
||||||
|
|
||||||
|
dummy -> SetAutoLayout(TRUE);
|
||||||
|
dummy -> Layout();
|
||||||
|
m_NavigPan -> AddPage(dummy, _("Search"));
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshLists();
|
||||||
|
m_NavigPan -> Show(TRUE);
|
||||||
|
m_HtmlWin -> Show(TRUE);
|
||||||
|
m_Splitter -> SetMinimumPaneSize(20);
|
||||||
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
if (!m_Cfg.navig_on) m_Splitter -> Unsplit(m_NavigPan);
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Frame -> Show(TRUE);
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxHtmlHelpSystem::RefreshLists()
|
||||||
|
{
|
||||||
|
if (m_Frame) {
|
||||||
|
CreateContents();
|
||||||
|
CreateIndex();
|
||||||
|
if (m_SearchList)
|
||||||
|
m_SearchList -> Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxHtmlHelpSystem::OnToolbar(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
switch (event.GetId()) {
|
||||||
|
case wxID_HTML_BACK :
|
||||||
|
if (m_HtmlWin) m_HtmlWin -> HistoryBack();
|
||||||
|
break;
|
||||||
|
case wxID_HTML_FORWARD :
|
||||||
|
if (m_HtmlWin) m_HtmlWin -> HistoryForward();
|
||||||
|
break;
|
||||||
|
case wxID_HTML_PANEL :
|
||||||
|
if (! (m_Splitter && m_NavigPan))
|
||||||
|
return;
|
||||||
|
if (m_Splitter -> IsSplit()) {
|
||||||
|
m_Cfg.sashpos = m_Splitter -> GetSashPosition();
|
||||||
|
m_Splitter -> Unsplit(m_NavigPan);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_NavigPan -> Show(TRUE);
|
||||||
|
m_HtmlWin -> Show(TRUE);
|
||||||
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxHtmlHelpSystem::OnCloseWindow(wxCloseEvent& event)
|
||||||
|
{
|
||||||
|
int a, b;
|
||||||
|
|
||||||
|
if (m_Splitter && m_NavigPan) {
|
||||||
|
m_Cfg.navig_on = m_Splitter -> IsSplit();
|
||||||
|
if (m_Cfg.navig_on)
|
||||||
|
m_Cfg.sashpos = m_Splitter -> GetSashPosition();
|
||||||
|
m_Frame -> GetPosition(&a, &b);
|
||||||
|
m_Cfg.x = a, m_Cfg.y = b;
|
||||||
|
m_Frame -> GetSize(&a, &b);
|
||||||
|
m_Cfg.w = a, m_Cfg.h = b;
|
||||||
|
}
|
||||||
|
if (m_Config) {
|
||||||
|
WriteCustomization(m_Config, m_ConfigRoot);
|
||||||
|
m_HtmlWin -> WriteCustomization(m_Config, m_ConfigRoot);
|
||||||
|
}
|
||||||
|
m_Frame = NULL;
|
||||||
|
|
||||||
|
//event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxHtmlHelpSystem, wxHtmlHelpController)
|
||||||
|
EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_FORWARD, wxHtmlHelpSystem::OnToolbar)
|
||||||
|
EVT_CLOSE(wxHtmlHelpSystem::OnCloseWindow)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
75
utils/wxPython/modules/html/helpsys.h
Normal file
75
utils/wxPython/modules/html/helpsys.h
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/* htmlsys.h : wxHtmlHelpSystem is an extension of the wxHtmlHelpController.
|
||||||
|
* mainly does two things:
|
||||||
|
* - extend the interface somewhat so the programmer can dictate most of the
|
||||||
|
* look and feel of the htmlhelp frame.
|
||||||
|
* - make some protected functions public (adding _ to the function name) so
|
||||||
|
* that SWIG can wrap them.
|
||||||
|
*
|
||||||
|
* Harm van der Heijden 32aug1999
|
||||||
|
*/
|
||||||
|
#ifndef __HELPSYS_H__
|
||||||
|
#define __HELPSYS_H__
|
||||||
|
|
||||||
|
#include <wx/defs.h>
|
||||||
|
|
||||||
|
#if ! wxUSE_HTML
|
||||||
|
#error "wxHtml needed"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/toolbar.h>
|
||||||
|
#include "wx/listbox.h"
|
||||||
|
#include <wx/html/htmlhelp.h>
|
||||||
|
|
||||||
|
class wxHtmlHelpSystem : public wxHtmlHelpController
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlHelpSystem)
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlHelpSystem() {};
|
||||||
|
~wxHtmlHelpSystem() {};
|
||||||
|
|
||||||
|
bool AddBookParam(const wxString& title, const wxString& contfile,
|
||||||
|
const wxString& indexfile=wxEmptyString, const wxString& deftopic=wxEmptyString,
|
||||||
|
const wxString& path=wxEmptyString, bool show_wait_msg=FALSE);
|
||||||
|
// Alternative to AddBook(wxString& hhpfile)
|
||||||
|
wxToolBar* CreateToolBar(wxFrame* frame);
|
||||||
|
// creates a dockable toolbar for the frame, containing hide/show, back and forward buttons
|
||||||
|
wxTreeCtrl* CreateContentsTree(wxWindow* parent);
|
||||||
|
// creates a treecontrol with imagelist for books, folders etc and id wxID_HTML_TREECTRL
|
||||||
|
wxListBox* CreateIndexList(wxWindow* parent);
|
||||||
|
// creates a listbox with the right id
|
||||||
|
virtual void CreateHelpWindow();
|
||||||
|
// Slightly different version than in wxHtmlHelpController; uses helpers above
|
||||||
|
// Do nothing if the window already exists
|
||||||
|
void SetControls(wxFrame* frame, wxHtmlWindow* htmlwin,
|
||||||
|
wxTreeCtrl* contents=NULL, wxListBox* index=NULL,
|
||||||
|
wxListBox* searchlist=NULL);
|
||||||
|
// alternative for CreateHelpWindow(), sets frame, htmlwindow, contents tree, index
|
||||||
|
// listbox and searchlist listbox. If null, their functionality won't be used
|
||||||
|
|
||||||
|
// Some extra accessor functions
|
||||||
|
wxFrame* GetFrame() { return m_Frame; }
|
||||||
|
wxHtmlWindow* GetHtmlWindow() { return m_HtmlWin; }
|
||||||
|
wxTreeCtrl* GetContentsTree() { return m_ContentsBox; }
|
||||||
|
wxListBox* GetIndexList() { return m_IndexBox; }
|
||||||
|
wxListBox* GetSearchList() { return m_SearchList; }
|
||||||
|
wxImageList* GetContentsImageList() { return m_ContentsImageList; }
|
||||||
|
// public interface for wxHtmlHelpControllers handlers, so wxPython can call them
|
||||||
|
void OnToolbar(wxCommandEvent& event);
|
||||||
|
void OnContentsSel(wxTreeEvent& event) {wxHtmlHelpController::OnContentsSel(event);}
|
||||||
|
void OnIndexSel(wxCommandEvent& event) {wxHtmlHelpController::OnIndexSel(event);}
|
||||||
|
void OnSearchSel(wxCommandEvent& event) {wxHtmlHelpController::OnSearchSel(event);}
|
||||||
|
void OnSearch(wxCommandEvent& event) {wxHtmlHelpController::OnSearch(event);}
|
||||||
|
void OnCloseWindow(wxCloseEvent& event);
|
||||||
|
|
||||||
|
// some more protected functions that should be accessible from wxPython
|
||||||
|
void RefreshLists();
|
||||||
|
void CreateContents() { if (!m_ContentsBox) return; wxHtmlHelpController::CreateContents(); }
|
||||||
|
// Adds items to m_Contents tree control
|
||||||
|
void CreateIndex() { if (! m_IndexBox) return; wxHtmlHelpController::CreateIndex(); }
|
||||||
|
// Adds items to m_IndexList
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@@ -19,6 +19,8 @@
|
|||||||
#include <wx/image.h>
|
#include <wx/image.h>
|
||||||
#include <wx/fs_zip.h>
|
#include <wx/fs_zip.h>
|
||||||
#include <wx/fs_inet.h>
|
#include <wx/fs_inet.h>
|
||||||
|
#include <wx/wfstream.h>
|
||||||
|
#include "helpsys.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -35,8 +37,8 @@
|
|||||||
//%extern frames.i
|
//%extern frames.i
|
||||||
//%extern misc.i
|
//%extern misc.i
|
||||||
//%extern gdi.i
|
//%extern gdi.i
|
||||||
//%extern controls.i
|
%extern controls.i
|
||||||
|
%extern controls2.i
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
@@ -155,7 +157,7 @@ class HtmlHistoryItem
|
|||||||
class wxHtmlWindow : public wxScrolledWindow
|
class wxHtmlWindow : public wxScrolledWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxHtmlWindow(wxWindow *parent, wxWindowID id = -1,
|
wxHtmlWindow(wxWindow *parent, int id = -1,
|
||||||
const wxPoint& pos = wxPyDefaultPosition,
|
const wxPoint& pos = wxPyDefaultPosition,
|
||||||
const wxSize& size = wxPyDefaultSize,
|
const wxSize& size = wxPyDefaultSize,
|
||||||
int flags=wxHW_SCROLLBAR_AUTO,
|
int flags=wxHW_SCROLLBAR_AUTO,
|
||||||
@@ -234,6 +236,164 @@ class wxHtmlWindow : public wxScrolledWindow
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
wxID_HTML_PANEL,
|
||||||
|
wxID_HTML_BACK,
|
||||||
|
wxID_HTML_FORWARD,
|
||||||
|
wxID_HTML_TREECTRL,
|
||||||
|
wxID_HTML_INDEXPAGE,
|
||||||
|
wxID_HTML_INDEXLIST,
|
||||||
|
wxID_HTML_NOTEBOOK,
|
||||||
|
wxID_HTML_SEARCHPAGE,
|
||||||
|
wxID_HTML_SEARCHTEXT,
|
||||||
|
wxID_HTML_SEARCHLIST,
|
||||||
|
wxID_HTML_SEARCHBUTTON
|
||||||
|
};
|
||||||
|
|
||||||
|
class wxHtmlHelpController : public wxEvtHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxHtmlHelpController();
|
||||||
|
~wxHtmlHelpController();
|
||||||
|
|
||||||
|
// Images:
|
||||||
|
enum {
|
||||||
|
IMG_Book = 0,
|
||||||
|
IMG_Folder,
|
||||||
|
IMG_Page
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetTitleFormat(const wxString& format) {m_TitleFormat = format;}
|
||||||
|
// Sets format of title of the frame. Must contain exactly one "%s"
|
||||||
|
// (for title of displayed HTML page)
|
||||||
|
|
||||||
|
void SetTempDir(const wxString& path);
|
||||||
|
// Sets directory where temporary files are stored.
|
||||||
|
// These temp files are index & contents file in binary (much faster to read)
|
||||||
|
// form. These files are NOT deleted on program's exit.
|
||||||
|
|
||||||
|
bool AddBook(const wxString& book, bool show_wait_msg = FALSE);
|
||||||
|
// Adds new book. 'book' is location of .htb file (stands for "html book").
|
||||||
|
// See documentation for details on its format.
|
||||||
|
// Returns success.
|
||||||
|
// If show_wait_msg == true then message window with "loading book..." is displayed
|
||||||
|
|
||||||
|
void Display(const wxString& x);
|
||||||
|
// Displays page x. If not found it will offect the user a choice of searching
|
||||||
|
// books.
|
||||||
|
// Looking for the page runs in these steps:
|
||||||
|
// 1. try to locate file named x (if x is for example "doc/howto.htm")
|
||||||
|
// 2. try to open starting page of book x
|
||||||
|
// 3. try to find x in contents (if x is for example "How To ...")
|
||||||
|
// 4. try to find x in index (if x is for example "How To ...")
|
||||||
|
// 5. offer searching and if the user agree, run KeywordSearch
|
||||||
|
%name(DisplayID) void Display(const int id);
|
||||||
|
// Alternative version that works with numeric ID.
|
||||||
|
// (uses extension to MS format, <param name="ID" value=id>, see docs)
|
||||||
|
|
||||||
|
void DisplayContents();
|
||||||
|
// Displays help window and focuses contents.
|
||||||
|
|
||||||
|
void DisplayIndex();
|
||||||
|
// Displays help window and focuses index.
|
||||||
|
|
||||||
|
bool KeywordSearch(const wxString& keyword);
|
||||||
|
// Searches for keyword. Returns TRUE and display page if found, return
|
||||||
|
// FALSE otherwise
|
||||||
|
// Syntax of keyword is Altavista-like:
|
||||||
|
// * words are separated by spaces
|
||||||
|
// (but "\"hello world\"" is only one world "hello world")
|
||||||
|
// * word may be pretended by + or -
|
||||||
|
// (+ : page must contain the word ; - : page can't contain the word)
|
||||||
|
// * if there is no + or - before the word, + is default
|
||||||
|
|
||||||
|
void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
|
||||||
|
// Assigns config object to the controller. This config is then
|
||||||
|
// used in subsequent calls to Read/WriteCustomization of both help
|
||||||
|
// controller and it's wxHtmlWindow
|
||||||
|
|
||||||
|
void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||||
|
// saves custom settings into cfg config. it will use the path 'path'
|
||||||
|
// if given, otherwise it will save info into currently selected path.
|
||||||
|
// saved values : things set by SetFonts, SetBorders.
|
||||||
|
void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||||
|
// ...
|
||||||
|
};
|
||||||
|
|
||||||
|
class wxHtmlHelpSystem : public wxHtmlHelpController
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxHtmlHelpSystem() {};
|
||||||
|
~wxHtmlHelpSystem() {};
|
||||||
|
|
||||||
|
bool AddBookParam(const wxString& title, const wxString& contfile,
|
||||||
|
const wxString& indexfile=wxEmptyString, const wxString& deftopic=wxEmptyString,
|
||||||
|
const wxString& path=wxEmptyString, bool show_wait_msg=FALSE);
|
||||||
|
// Alternative to AddBook(wxString& hhpfile)
|
||||||
|
wxToolBar* CreateToolBar(wxFrame* frame);
|
||||||
|
// creates a dockable toolbar for the frame, containing hide/show, back and forward buttons
|
||||||
|
wxTreeCtrl* CreateContentsTree(wxWindow* parent);
|
||||||
|
// creates a treecontrol with imagelist for books, folders etc and id wxID_HTML_TREECTRL
|
||||||
|
wxListBox* CreateIndexList(wxWindow* parent);
|
||||||
|
// creates a listbox with the right id
|
||||||
|
virtual void CreateHelpWindow();
|
||||||
|
// Slightly different version than in wxHtmlHelpController; uses helpers above
|
||||||
|
// Do nothing if the window already exists
|
||||||
|
void SetControls(wxFrame* frame, wxHtmlWindow* htmlwin,
|
||||||
|
wxTreeCtrl* contents=NULL, wxListBox* index=NULL,
|
||||||
|
wxListBox* searchlist=NULL);
|
||||||
|
// alternative for CreateHelpWindow(), sets frame, htmlwindow, contents tree, index
|
||||||
|
// listbox and searchlist listbox. If null, their functionality won't be used
|
||||||
|
|
||||||
|
// Some extra accessor functions
|
||||||
|
wxFrame* GetFrame() { return m_Frame; }
|
||||||
|
wxHtmlWindow* GetHtmlWindow() { return m_HtmlWin; }
|
||||||
|
wxTreeCtrl* GetContentsTree() { return m_ContentsBox; }
|
||||||
|
wxListBox* GetIndexList() { return m_IndexBox; }
|
||||||
|
wxListBox* GetSearchList() { return m_SearchList; }
|
||||||
|
wxImageList* GetContentsImageList() { return m_ContentsImageList; }
|
||||||
|
// public interface for wxHtmlHelpControllers handlers, so wxPython can call them
|
||||||
|
void OnToolbar(wxCommandEvent& event);
|
||||||
|
void OnContentsSel(wxTreeEvent& event) {wxHtmlHelpController::OnContentsSel(event);}
|
||||||
|
void OnIndexSel(wxCommandEvent& event) {wxHtmlHelpController::OnIndexSel(event);}
|
||||||
|
void OnSearchSel(wxCommandEvent& event) {wxHtmlHelpController::OnSearchSel(event);}
|
||||||
|
void OnSearch(wxCommandEvent& event) {wxHtmlHelpController::OnSearch(event);}
|
||||||
|
void OnCloseWindow(wxCloseEvent& event);
|
||||||
|
|
||||||
|
// some more protected functions that should be accessible from wxPython
|
||||||
|
void RefreshLists();
|
||||||
|
void CreateContents() { if (!m_IndexBox) return; wxHtmlHelpController::CreateContents(); }
|
||||||
|
// Adds items to m_Contents tree control
|
||||||
|
void CreateIndex() { if (! m_ContentsBox) return; wxHtmlHelpController::CreateIndex(); }
|
||||||
|
// Adds items to m_IndexList
|
||||||
|
};
|
||||||
|
|
||||||
|
// just for fun, an Altavista-like search engine (the gems that Vaclav has hidden in wxHtml...)
|
||||||
|
// but not for wxMSW because it's not DLL exported
|
||||||
|
//#ifndef __WXMSW__
|
||||||
|
#ifdef THIS_IS_NOT_DEFINED_OKAY
|
||||||
|
class wxSearchEngine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxSearchEngine() : wxObject() {m_Keyword = NULL;}
|
||||||
|
~wxSearchEngine() {if (m_Keyword) free(m_Keyword);}
|
||||||
|
|
||||||
|
void LookFor(const wxString& keyword);
|
||||||
|
// Sets the keyword we will be searching for
|
||||||
|
|
||||||
|
bool Scan(wxInputStream *stream);
|
||||||
|
// Scans the stream for the keyword.
|
||||||
|
// Returns TRUE if the stream contains keyword, fALSE otherwise
|
||||||
|
%addmethods {
|
||||||
|
bool ScanFile(const wxString& filename) {
|
||||||
|
if (filename.IsEmpty())
|
||||||
|
return false;
|
||||||
|
wxFileInputStream istr(filename);
|
||||||
|
return self->Scan(&istr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
73
utils/wxPython/modules/html/test/helpsys.py
Normal file
73
utils/wxPython/modules/html/test/helpsys.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
from wxPython.wx import *
|
||||||
|
from wxPython.html import *
|
||||||
|
import sys,os
|
||||||
|
|
||||||
|
if not os.environ.has_key('WXWIN'):
|
||||||
|
print "Can't find html samples. Set WXWIN environment variable."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
help = wxHtmlHelpSystem()
|
||||||
|
# Create the book in a different way, supply title, contents file, index, default topic and basedir
|
||||||
|
help.AddBookParam('Sample help docs', 'contents.hhc', '', 'main.htm',
|
||||||
|
os.environ['WXWIN'] + "/samples/html/help/helpfiles")
|
||||||
|
|
||||||
|
class HelpFrame(wxFrame):
|
||||||
|
def __init__(self):
|
||||||
|
wxFrame.__init__(self, NULL, -1, "", wxDefaultPosition, wxSize(500,500))
|
||||||
|
bar = self.CreateStatusBar(2)
|
||||||
|
bar.SetStatusWidths([400,100])
|
||||||
|
help.CreateToolBar(self)
|
||||||
|
self.text = wxTextCtrl(bar, 1001, "Hello world", wxPoint(400,0), wxSize(80,30))
|
||||||
|
button = wxButton(bar, 1002, "Go", wxPoint(480,0), wxSize(20,30))
|
||||||
|
|
||||||
|
html = wxHtmlWindow(self,-1)
|
||||||
|
html.SetRelatedFrame(self, "%s")
|
||||||
|
html.SetRelatedStatusBar(0)
|
||||||
|
|
||||||
|
self.searchframe = wxMiniFrame(self, -1, "Search result", wxDefaultPosition, wxSize(300,400))
|
||||||
|
self.searchbox = wxListBox(self.searchframe, wxID_HTML_SEARCHLIST)
|
||||||
|
|
||||||
|
self.mframe = wxMiniFrame(self, -1, "Contents", wxDefaultPosition, wxSize(300,500))
|
||||||
|
tree = help.CreateContentsTree(self.mframe)
|
||||||
|
help.SetControls(self, html, tree, NULL, self.searchbox)
|
||||||
|
EVT_TREE_SEL_CHANGED(self, wxID_HTML_TREECTRL, help.OnContentsSel)
|
||||||
|
EVT_LISTBOX(self, wxID_HTML_SEARCHLIST, help.OnSearchSel)
|
||||||
|
EVT_TOOL(self, wxID_HTML_PANEL, self.ToggleContents)
|
||||||
|
EVT_TOOL(self, wxID_HTML_BACK, help.OnToolbar)
|
||||||
|
EVT_TOOL(self, wxID_HTML_FORWARD, help.OnToolbar)
|
||||||
|
EVT_TEXT_ENTER(self, 1001, self.OnTextSearch)
|
||||||
|
EVT_BUTTON(self, 1002, self.OnTextSearch)
|
||||||
|
EVT_CLOSE(self.mframe, self.OnCloseContents)
|
||||||
|
EVT_CLOSE(self.searchframe, self.OnCloseSearch)
|
||||||
|
self.mframe.Show(TRUE)
|
||||||
|
print help.GetSearchList()
|
||||||
|
|
||||||
|
def ToggleContents(self, event):
|
||||||
|
self.mframe.Show(not self.mframe.IsShown())
|
||||||
|
|
||||||
|
def OnCloseContents(self, event):
|
||||||
|
if event.CanVeto():
|
||||||
|
self.mframe.Show(FALSE)
|
||||||
|
else:
|
||||||
|
self.mframe.Destroy()
|
||||||
|
|
||||||
|
def OnCloseSearch(self, event):
|
||||||
|
if event.CanVeto():
|
||||||
|
self.searchframe.Show(FALSE)
|
||||||
|
else:
|
||||||
|
self.searchframe.Destroy()
|
||||||
|
|
||||||
|
def OnTextSearch(self, event):
|
||||||
|
self.searchbox.Clear()
|
||||||
|
self.searchframe.Show(TRUE)
|
||||||
|
print "searching for %s" % (self.text.GetValue(),)
|
||||||
|
help.KeywordSearch(self.text.GetValue())
|
||||||
|
|
||||||
|
class MyApp(wxApp):
|
||||||
|
def OnInit(self):
|
||||||
|
frame = HelpFrame()
|
||||||
|
frame.Show(TRUE)
|
||||||
|
return TRUE
|
||||||
|
|
||||||
|
theApp = MyApp(0)
|
||||||
|
theApp.MainLoop()
|
19
utils/wxPython/modules/html/test/htmlhelp.py
Normal file
19
utils/wxPython/modules/html/test/htmlhelp.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from wxPython.wx import *
|
||||||
|
from wxPython.html import *
|
||||||
|
import os,sys
|
||||||
|
|
||||||
|
if not os.environ.has_key('WXWIN'):
|
||||||
|
print "Can't find html samples. Set WXWIN environment variable."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Minimal htmlhelpcontroller sample. Everything is done by the framework
|
||||||
|
help = wxHtmlHelpController() # Not created in OnInit, otherwise it's deleted before we see it.
|
||||||
|
help.AddBook(os.environ['WXWIN'] + "/samples/html/help/helpfiles/testing.hhp")
|
||||||
|
|
||||||
|
class MyApp(wxApp):
|
||||||
|
def OnInit(self):
|
||||||
|
help.DisplayContents()
|
||||||
|
return TRUE
|
||||||
|
|
||||||
|
theApp = MyApp(0)
|
||||||
|
theApp.MainLoop()
|
Reference in New Issue
Block a user