]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/helpwxht.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: an external help controller for wxWindows
4 // Author: Karsten Ballueder
8 // Copyright: (c) Karsten Ballueder
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 # pragma implementation "helpwxht.h"
16 #include "wx/wxprec.h"
25 # include "wx/string.h"
26 # include "wx/utils.h"
29 # include "wx/layout.h"
32 #include "wx/helpbase.h"
33 #include "wx/generic/helpwxht.h"
34 #include "wx/html/htmlwin.h"
44 IMPLEMENT_CLASS(wxHelpControllerHtml
, wxHTMLHelpControllerBase
)
47 This class implements help via an external browser.
48 It requires the name of a directory containing the documentation
49 and a file mapping numerical Section numbers to relative URLS.
52 #define FRAME_WIDTH 400
53 #define FRAME_HEIGHT 400
54 #define LAYOUT_X_MARGIN 2
55 #define LAYOUT_Y_MARGIN 2
58 class wxHelpFrame
: public wxFrame
61 wxHelpFrame(wxWindow
*parent
, int id
, const wxString
&title
,
62 const wxPoint
&pos
, const wxSize
&size
,
63 wxHelpControllerHtml
*controller
);
65 void OnClose(wxCloseEvent
&ev
);
66 bool LoadPage(const wxString
&url
) { return m_htmlwin
->LoadPage(url
); }
68 wxHelpControllerHtml
*m_controller
;
69 wxHtmlWindow
*m_htmlwin
;
73 BEGIN_EVENT_TABLE(wxHelpFrame
, wxFrame
)
74 EVT_CLOSE(wxHelpFrame::OnClose
)
77 wxHelpFrame::wxHelpFrame(wxWindow
*parent
, int id
,
78 const wxString
&title
,
79 const wxPoint
&pos
, const wxSize
&size
,
80 wxHelpControllerHtml
*controller
)
81 : wxFrame(parent
, id
, title
, pos
, size
)
84 m_controller
= controller
;
85 m_htmlwin
= new wxHtmlWindow(this,-1,wxDefaultPosition
,wxSize(FRAME_WIDTH
,
88 wxLayoutConstraints
*c
;
90 c
= new wxLayoutConstraints
;
91 c
->left
.SameAs(this, wxLeft
, 2*LAYOUT_X_MARGIN
);
92 c
->right
.SameAs(this, wxRight
, 2*LAYOUT_X_MARGIN
);
93 c
->top
.SameAs(this, wxTop
, 2*LAYOUT_Y_MARGIN
);
94 c
->bottom
.SameAs(this, wxBottom
, 2*LAYOUT_Y_MARGIN
);
95 m_htmlwin
->SetConstraints(c
);
100 wxHelpFrame::~wxHelpFrame()
105 wxHelpFrame::OnClose(wxCloseEvent
&ev
)
107 wxASSERT(m_controller
);
108 m_controller
->m_Frame
= NULL
;
113 m_controller
->GetFrameParameters(NULL
, NULL
, &newFrame
);
114 m_controller
->SetFrameParameters(GetTitle(), GetSize(),
120 wxHelpControllerHtml::wxHelpControllerHtml(void)
125 SetFrameParameters(_("Help"),
126 wxSize(FRAME_WIDTH
, FRAME_HEIGHT
),
130 wxHelpControllerHtml::~wxHelpControllerHtml(void)
132 if(m_Frame
&& ! m_NewFrameEachTime
)
144 wxHelpControllerHtml::DisplayHelp(wxString
const &relativeURL
)
146 wxBusyCursor b
; // display a busy cursor
149 url
<< m_MapFile
<< SEP
<< relativeURL
;
150 if(! m_Frame
|| m_NewFrameEachTime
)
152 m_Frame
= new wxHelpFrame(NULL
, -1, m_FrameTitle
,
153 m_FramePosition
+wxPoint(m_offset
,m_offset
),
156 if(m_NewFrameEachTime
)
164 return m_Frame
->LoadPage(url
);
169 wxHelpControllerHtml::SetFrameParameters(const wxString
&title
,
174 m_FrameTitle
= title
;
176 m_FramePosition
= pos
;
177 m_NewFrameEachTime
= newFrame
;
181 wxHelpControllerHtml::GetFrameParameters(wxSize
*size
= NULL
,
183 bool *newframe
= NULL
)
185 if(size
) *size
= m_FrameSize
;
186 if(pos
) *pos
= m_FramePosition
;
187 if(newframe
) *newframe
= m_NewFrameEachTime
;