more wxHtmlHelpFrame fixes (didn't store customization correctly, still needs some fixing, will do asap)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4279 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -61,7 +61,7 @@ enum
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
long x, y, w, h;
|
int x, y, w, h;
|
||||||
long sashpos;
|
long sashpos;
|
||||||
bool navig_on;
|
bool navig_on;
|
||||||
}
|
}
|
||||||
|
@@ -350,7 +350,7 @@ bool wxHtmlHelpData::AddBookParam(const wxString& title, const wxString& contfil
|
|||||||
if (! path.IsEmpty())
|
if (! path.IsEmpty())
|
||||||
fsys.ChangePathTo(path, TRUE);
|
fsys.ChangePathTo(path, TRUE);
|
||||||
|
|
||||||
bookr = new wxHtmlBookRecord(path + '/', title, deftopic);
|
bookr = new wxHtmlBookRecord(fsys.GetPath(), title, deftopic);
|
||||||
|
|
||||||
if (m_ContentsCnt % wxHTML_REALLOC_STEP == 0)
|
if (m_ContentsCnt % wxHTML_REALLOC_STEP == 0)
|
||||||
m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem));
|
m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem));
|
||||||
@@ -367,12 +367,12 @@ bool wxHtmlHelpData::AddBookParam(const wxString& title, const wxString& contfil
|
|||||||
|
|
||||||
// Try to find cached binary versions:
|
// Try to find cached binary versions:
|
||||||
safetitle = SafeFileName(title);
|
safetitle = SafeFileName(title);
|
||||||
fi = fsys.OpenFile(safetitle + ".cached");
|
fi = fsys.OpenFile(safetitle + wxT(".cached"));
|
||||||
if (fi == NULL) fi = fsys.OpenFile(m_TempPath + safetitle + ".cached");
|
if (fi == NULL) fi = fsys.OpenFile(m_TempPath + safetitle + wxT(".cached"));
|
||||||
if ((fi == NULL) || (m_TempPath == wxEmptyString)) {
|
if ((fi == NULL) || (m_TempPath == wxEmptyString)) {
|
||||||
LoadMSProject(bookr, fsys, indexfile, contfile);
|
LoadMSProject(bookr, fsys, indexfile, contfile);
|
||||||
if (m_TempPath != wxEmptyString) {
|
if (m_TempPath != wxEmptyString) {
|
||||||
wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath + safetitle + ".cached");
|
wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath + safetitle + wxT(".cached"));
|
||||||
SaveCachedBook(bookr, outs);
|
SaveCachedBook(bookr, outs);
|
||||||
delete outs;
|
delete outs;
|
||||||
}
|
}
|
||||||
@@ -394,49 +394,71 @@ bool wxHtmlHelpData::AddBookParam(const wxString& title, const wxString& contfil
|
|||||||
|
|
||||||
bool wxHtmlHelpData::AddBook(const wxString& book)
|
bool wxHtmlHelpData::AddBook(const wxString& book)
|
||||||
{
|
{
|
||||||
wxFSFile *fi;
|
if (book.Right(4).Lower() == wxT(".zip") ||
|
||||||
wxFileSystem fsys;
|
book.Right(4).Lower() == wxT(".htb") /*html book*/)
|
||||||
wxInputStream *s;
|
|
||||||
wxString bookFull;
|
|
||||||
|
|
||||||
int sz;
|
{
|
||||||
char *buff, *lineptr;
|
wxFileSystem fsys;
|
||||||
char linebuf[300];
|
wxString s;
|
||||||
|
bool rt = FALSE;
|
||||||
|
|
||||||
wxString title = _("noname"),
|
s = fsys.FindFirst(book + wxT("#zip:") + wxT("*.hhp"), wxFILE);
|
||||||
safetitle,
|
while (!s.IsEmpty())
|
||||||
start = wxEmptyString,
|
{
|
||||||
contents = wxEmptyString, index = wxEmptyString;
|
if (AddBook(s)) rt = TRUE;
|
||||||
|
s = fsys.FindNext();
|
||||||
|
}
|
||||||
|
|
||||||
if (wxIsAbsolutePath(book)) bookFull = book;
|
return rt;
|
||||||
else bookFull = wxGetCwd() + "/" + book;
|
}
|
||||||
|
|
||||||
fi = fsys.OpenFile(bookFull);
|
|
||||||
if (fi == NULL) return FALSE;
|
|
||||||
fsys.ChangePathTo(bookFull);
|
|
||||||
s = fi -> GetStream();
|
|
||||||
sz = s -> GetSize();
|
|
||||||
buff = new char[sz + 1];
|
|
||||||
buff[sz] = 0;
|
|
||||||
s -> Read(buff, sz);
|
|
||||||
lineptr = buff;
|
|
||||||
delete fi;
|
|
||||||
|
|
||||||
do {
|
else
|
||||||
lineptr = ReadLine(lineptr, linebuf);
|
{
|
||||||
|
wxFSFile *fi;
|
||||||
|
wxFileSystem fsys;
|
||||||
|
wxInputStream *s;
|
||||||
|
wxString bookFull;
|
||||||
|
|
||||||
if (strstr(linebuf, "Title=") == linebuf)
|
int sz;
|
||||||
title = linebuf + strlen("Title=");
|
char *buff, *lineptr;
|
||||||
if (strstr(linebuf, "Default topic=") == linebuf)
|
char linebuf[300];
|
||||||
start = linebuf + strlen("Default topic=");
|
|
||||||
if (strstr(linebuf, "Index file=") == linebuf)
|
|
||||||
index = linebuf + strlen("Index file=");
|
|
||||||
if (strstr(linebuf, "Contents file=") == linebuf)
|
|
||||||
contents = linebuf + strlen("Contents file=");
|
|
||||||
} while (lineptr != NULL);
|
|
||||||
delete[] buff;
|
|
||||||
|
|
||||||
return AddBookParam(title, contents, index, start, fsys.GetPath());
|
wxString title = _("noname"),
|
||||||
|
safetitle,
|
||||||
|
start = wxEmptyString,
|
||||||
|
contents = wxEmptyString, index = wxEmptyString;
|
||||||
|
|
||||||
|
if (wxIsAbsolutePath(book)) bookFull = book;
|
||||||
|
else bookFull = wxGetCwd() + "/" + book;
|
||||||
|
|
||||||
|
fi = fsys.OpenFile(bookFull);
|
||||||
|
if (fi == NULL) return FALSE;
|
||||||
|
fsys.ChangePathTo(bookFull);
|
||||||
|
s = fi -> GetStream();
|
||||||
|
sz = s -> GetSize();
|
||||||
|
buff = new char[sz + 1];
|
||||||
|
buff[sz] = 0;
|
||||||
|
s -> Read(buff, sz);
|
||||||
|
lineptr = buff;
|
||||||
|
delete fi;
|
||||||
|
|
||||||
|
do {
|
||||||
|
lineptr = ReadLine(lineptr, linebuf);
|
||||||
|
|
||||||
|
if (strstr(linebuf, "Title=") == linebuf)
|
||||||
|
title = linebuf + strlen("Title=");
|
||||||
|
if (strstr(linebuf, "Default topic=") == linebuf)
|
||||||
|
start = linebuf + strlen("Default topic=");
|
||||||
|
if (strstr(linebuf, "Index file=") == linebuf)
|
||||||
|
index = linebuf + strlen("Index file=");
|
||||||
|
if (strstr(linebuf, "Contents file=") == linebuf)
|
||||||
|
contents = linebuf + strlen("Contents file=");
|
||||||
|
} while (lineptr != NULL);
|
||||||
|
delete[] buff;
|
||||||
|
|
||||||
|
return AddBookParam(title, contents, index, start, fsys.GetPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxHtmlHelpData::FindPageByName(const wxString& x)
|
wxString wxHtmlHelpData::FindPageByName(const wxString& x)
|
||||||
|
@@ -96,7 +96,7 @@ void wxHtmlHelpFrame::Init(wxHtmlHelpData* data)
|
|||||||
m_DataCreated = TRUE;
|
m_DataCreated = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ContentsImageList = new wxImageList(12, 12);
|
m_ContentsImageList = new wxImageList(16, 16);
|
||||||
m_ContentsImageList -> Add(wxICON(book));
|
m_ContentsImageList -> Add(wxICON(book));
|
||||||
m_ContentsImageList -> Add(wxICON(folder));
|
m_ContentsImageList -> Add(wxICON(folder));
|
||||||
m_ContentsImageList -> Add(wxICON(page));
|
m_ContentsImageList -> Add(wxICON(page));
|
||||||
@@ -137,7 +137,7 @@ bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, const wxString& ti
|
|||||||
if (m_Config)
|
if (m_Config)
|
||||||
ReadCustomization(m_Config, m_ConfigRoot);
|
ReadCustomization(m_Config, m_ConfigRoot);
|
||||||
|
|
||||||
wxFrame::Create(parent, id, "", wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h));
|
wxFrame::Create(parent, id, _("Help"), wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h));
|
||||||
|
|
||||||
int notebook_page = 0;
|
int notebook_page = 0;
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, const wxString& ti
|
|||||||
toolBarBitmaps[2] = new wxBitmap("forward");
|
toolBarBitmaps[2] = new wxBitmap("forward");
|
||||||
int width = 24;
|
int width = 24;
|
||||||
#else
|
#else
|
||||||
toolBarBitmaps[0] = new wxBitmap(panel_xpm);
|
toolBarBitmaps[0] = new wxBitmap(panel_xpm);
|
||||||
toolBarBitmaps[1] = new wxBitmap(back_xpm);
|
toolBarBitmaps[1] = new wxBitmap(back_xpm);
|
||||||
toolBarBitmaps[2] = new wxBitmap(forward_xpm);
|
toolBarBitmaps[2] = new wxBitmap(forward_xpm);
|
||||||
int width = 16;
|
int width = 16;
|
||||||
@@ -279,6 +279,10 @@ toolBarBitmaps[0] = new wxBitmap(panel_xpm);
|
|||||||
m_Splitter -> SetMinimumPaneSize(20);
|
m_Splitter -> SetMinimumPaneSize(20);
|
||||||
if (m_Cfg.navig_on)
|
if (m_Cfg.navig_on)
|
||||||
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
else {
|
||||||
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
m_Splitter -> Unsplit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_HtmlWin -> Show(TRUE);
|
m_HtmlWin -> Show(TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -574,10 +578,12 @@ void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
|
|||||||
if (m_Splitter -> IsSplit()) {
|
if (m_Splitter -> IsSplit()) {
|
||||||
m_Cfg.sashpos = m_Splitter -> GetSashPosition();
|
m_Cfg.sashpos = m_Splitter -> GetSashPosition();
|
||||||
m_Splitter -> Unsplit(m_NavigPan);
|
m_Splitter -> Unsplit(m_NavigPan);
|
||||||
|
m_Cfg.navig_on = FALSE;
|
||||||
} else {
|
} else {
|
||||||
m_NavigPan -> Show(TRUE);
|
m_NavigPan -> Show(TRUE);
|
||||||
m_HtmlWin -> Show(TRUE);
|
m_HtmlWin -> Show(TRUE);
|
||||||
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
m_Cfg.navig_on = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -618,8 +624,13 @@ void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt)
|
void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt)
|
||||||
{
|
{
|
||||||
|
GetSize(&m_Cfg.w, &m_Cfg.h);
|
||||||
|
GetPosition(&m_Cfg.x, &m_Cfg.y);
|
||||||
|
if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter -> GetSashPosition();
|
||||||
|
|
||||||
if (m_Config)
|
if (m_Config)
|
||||||
WriteCustomization(m_Config, m_ConfigRoot);
|
WriteCustomization(m_Config, m_ConfigRoot);
|
||||||
|
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user