SetTitle method (internal use only) changed to virtual OnSetTitle, added GetOpenedPageTitle

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4736 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
1999-11-28 18:24:57 +00:00
parent 31e24645c0
commit d5db80c269
4 changed files with 40 additions and 12 deletions

View File

@@ -69,6 +69,12 @@ See also: \helpref{Cells Overview}{cells},
Returns full location of the opened page. If no page is opened or if the displayed page wasn't Returns full location of the opened page. If no page is opened or if the displayed page wasn't
produced by call to LoadPage, empty string is returned. produced by call to LoadPage, empty string is returned.
\membersection{wxHtmlWindow::GetOpenedPageTitle}\label{wxhtmlwindowgetopenedpagetitle}
\func{wxString}{GetOpenedPageTitle}{\void}
Returns title of the opened page or wxEmptyString if current page does not contain {\tt <TITLE>} tag.
\membersection{wxHtmlWindow::GetRelatedFrame}\label{wxhtmlwindowgetrelatedframe} \membersection{wxHtmlWindow::GetRelatedFrame}\label{wxhtmlwindowgetrelatedframe}
\constfunc{wxFrame*}{GetRelatedFrame}{\void} \constfunc{wxFrame*}{GetRelatedFrame}{\void}
@@ -120,6 +126,14 @@ FALSE if an error occured, TRUE otherwise
Called when user clicks on hypertext link. Default behaviour is to call Called when user clicks on hypertext link. Default behaviour is to call
\helpref{LoadPage}{wxhtmlwindowloadpage} and do nothing else. \helpref{LoadPage}{wxhtmlwindowloadpage} and do nothing else.
\membersection{wxHtmlWindow::OnSetTitle}\label{wxhtmlwindowonsettitle}
\func{virtual void}{OnSetTitle}{\param{const wxString\& }{title}}
Called on parsing {\tt <TITLE>} tag.
\membersection{wxHtmlWindow::ReadCustomization}\label{wxhtmlwindowreadcustomization} \membersection{wxHtmlWindow::ReadCustomization}\label{wxhtmlwindowreadcustomization}
\func{virtual void}{ReadCustomization}{\param{wxConfigBase }{*cfg}, \param{wxString }{path = wxEmptyString}} \func{virtual void}{ReadCustomization}{\param{wxConfigBase }{*cfg}, \param{wxString }{path = wxEmptyString}}
@@ -234,6 +248,7 @@ this sets statusbar slot where messages will be displayed.
\docparam{bar}{statusbar slot number (0..n)} \docparam{bar}{statusbar slot number (0..n)}
\membersection{wxHtmlWindow::WriteCustomization}\label{wxhtmlwindowwritecustomization} \membersection{wxHtmlWindow::WriteCustomization}\label{wxhtmlwindowwritecustomization}
\func{virtual void}{WriteCustomization}{\param{wxConfigBase }{*cfg}, \param{wxString }{path = wxEmptyString}} \func{virtual void}{WriteCustomization}{\param{wxConfigBase }{*cfg}, \param{wxString }{path = wxEmptyString}}

View File

@@ -68,7 +68,7 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
wxHtmlWindow() : wxScrolledWindow() {}; wxHtmlWindow() : wxScrolledWindow() {};
wxHtmlWindow(wxWindow *parent, wxWindowID id = -1, wxHtmlWindow(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxHW_SCROLLBAR_AUTO, long style = wxHW_SCROLLBAR_AUTO,
const wxString& name = "htmlWindow"); const wxString& name = "htmlWindow");
~wxHtmlWindow(); ~wxHtmlWindow();
@@ -92,6 +92,9 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
wxString GetOpenedPage() const {return m_OpenedPage;} wxString GetOpenedPage() const {return m_OpenedPage;}
// Returns full location of opened page // Returns full location of opened page
wxString GetOpenedPageTitle() const {return m_OpenedPageTitle;}
// Returns <TITLE> of opened page or empty string otherwise
void SetRelatedFrame(wxFrame* frame, const wxString& format); void SetRelatedFrame(wxFrame* frame, const wxString& format);
// sets frame in which page title will be displayed. Format is format of // sets frame in which page title will be displayed. Format is format of
// frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
@@ -105,7 +108,7 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
// sets fonts to be used when displaying HTML page. // sets fonts to be used when displaying HTML page.
// *_italic_mode can be either wxSLANT or wxITALIC // *_italic_mode can be either wxSLANT or wxITALIC
void SetTitle(const wxString& title); virtual void OnSetTitle(const wxString& title);
// Sets the title of the window // Sets the title of the window
// (depending on the information passed to SetRelatedFrame() method) // (depending on the information passed to SetRelatedFrame() method)
@@ -176,6 +179,8 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
// contains name of actualy opened page or empty string if no page opened // contains name of actualy opened page or empty string if no page opened
wxString m_OpenedAnchor; wxString m_OpenedAnchor;
// contains name of current anchor within m_OpenedPage // contains name of current anchor within m_OpenedPage
wxString m_OpenedPageTitle;
// contains title of actualy opened page or empty string if no <TITLE> tag
wxFileSystem* m_FS; wxFileSystem* m_FS;
// class for opening files (file system) // class for opening files (file system)

View File

@@ -51,7 +51,7 @@ wxHtmlWindow::wxHtmlWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos,
m_RelatedStatusBar = -1; m_RelatedStatusBar = -1;
m_RelatedFrame = NULL; m_RelatedFrame = NULL;
m_TitleFormat = "%s"; m_TitleFormat = "%s";
m_OpenedPage = m_OpenedAnchor = wxEmptyString; m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
m_Cell = NULL; m_Cell = NULL;
m_Parser = new wxHtmlWinParser(this); m_Parser = new wxHtmlWinParser(this);
m_Parser -> SetFS(m_FS); m_Parser -> SetFS(m_FS);
@@ -96,8 +96,11 @@ void wxHtmlWindow::SetRelatedStatusBar(int bar)
void wxHtmlWindow::SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, const int *sizes) void wxHtmlWindow::SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, const int *sizes)
{ {
wxString op = m_OpenedPage;
m_Parser -> SetFonts(normal_face, normal_italic_mode, fixed_face, fixed_italic_mode, sizes); m_Parser -> SetFonts(normal_face, normal_italic_mode, fixed_face, fixed_italic_mode, sizes);
if (!m_OpenedPage.IsEmpty()) LoadPage(m_OpenedPage); SetPage(wxT("")); // fonts changed => contents invalid
if (!op.IsEmpty()) LoadPage(op);
} }
@@ -108,7 +111,7 @@ bool wxHtmlWindow::SetPage(const wxString& source)
dc -> SetMapMode(wxMM_TEXT); dc -> SetMapMode(wxMM_TEXT);
SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF)); SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
m_OpenedPage = m_OpenedAnchor = wxEmptyString; m_OpenedPage = m_OpenedAnchor = m_OpenedPageTitle = wxEmptyString;
m_Parser -> SetDC(dc); m_Parser -> SetDC(dc);
if (m_Cell) { if (m_Cell) {
delete m_Cell; delete m_Cell;
@@ -237,13 +240,14 @@ bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor)
} }
void wxHtmlWindow::SetTitle(const wxString& title) void wxHtmlWindow::OnSetTitle(const wxString& title)
{ {
if (m_RelatedFrame) { if (m_RelatedFrame) {
wxString tit; wxString tit;
tit.Printf(m_TitleFormat, title.c_str()); tit.Printf(m_TitleFormat, title.c_str());
m_RelatedFrame -> SetTitle(tit); m_RelatedFrame -> SetTitle(tit);
} }
m_OpenedPageTitle = title;
} }
@@ -290,6 +294,9 @@ void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path)
{ {
wxString oldpath; wxString oldpath;
wxString tmp; wxString tmp;
int p_fontsizes[7];
wxString p_fff, p_ffn;
int p_imf, p_imn;
if (path != wxEmptyString) { if (path != wxEmptyString) {
oldpath = cfg -> GetPath(); oldpath = cfg -> GetPath();
@@ -297,14 +304,15 @@ void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path)
} }
m_Borders = cfg -> Read("wxHtmlWindow/Borders", m_Borders); m_Borders = cfg -> Read("wxHtmlWindow/Borders", m_Borders);
m_Parser -> m_FontFaceFixed = cfg -> Read("wxHtmlWindow/FontFaceFixed", m_Parser -> m_FontFaceFixed); p_fff = cfg -> Read("wxHtmlWindow/FontFaceFixed", m_Parser -> m_FontFaceFixed);
m_Parser -> m_FontFaceNormal = cfg -> Read("wxHtmlWindow/FontFaceNormal", m_Parser -> m_FontFaceNormal); p_ffn = cfg -> Read("wxHtmlWindow/FontFaceNormal", m_Parser -> m_FontFaceNormal);
m_Parser -> m_ItalicModeFixed = cfg -> Read("wxHtmlWindow/ItalicModeFixed", m_Parser -> m_ItalicModeFixed); p_imf = cfg -> Read("wxHtmlWindow/ItalicModeFixed", m_Parser -> m_ItalicModeFixed);
m_Parser -> m_ItalicModeNormal = cfg -> Read("wxHtmlWindow/ItalicModeNormal", m_Parser -> m_ItalicModeNormal); p_imn = cfg -> Read("wxHtmlWindow/ItalicModeNormal", m_Parser -> m_ItalicModeNormal);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i); tmp.Printf(wxT("wxHtmlWindow/FontsSize%i"), i);
m_Parser -> m_FontsSizes[i] = cfg -> Read(tmp, m_Parser -> m_FontsSizes[i]); p_fontsizes[i] = cfg -> Read(tmp, m_Parser -> m_FontsSizes[i]);
} }
m_Parser -> SetFonts(p_ffn, p_imn, p_fff, p_imf, p_fontsizes);
if (path != wxEmptyString) if (path != wxEmptyString)
cfg -> SetPath(oldpath); cfg -> SetPath(oldpath);

View File

@@ -150,7 +150,7 @@ TAG_HANDLER_BEGIN(TITLE, "TITLE")
wxString *src = m_WParser -> GetSource(); wxString *src = m_WParser -> GetSource();
for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[(unsigned int) i]; for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[(unsigned int) i];
wfr -> SetTitle(title); wfr -> OnSetTitle(title);
} }
} }
return TRUE; return TRUE;