]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/helpwxht.cpp
5e4ad3fa930c213a81643f2406327999a08c72bc
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"
23 # include "wx/setup.h"
24 # include "wx/string.h"
25 # include "wx/utils.h"
28 # include "wx/layout.h"
31 #include "wx/helpbase.h"
32 #include "wx/generic/helpwxht.h"
33 #include "wx/html/htmlwin.h"
43 IMPLEMENT_CLASS(wxHelpControllerHtml
, wxHTMLHelpControllerBase
)
46 This class implements help via an external browser.
47 It requires the name of a directory containing the documentation
48 and a file mapping numerical Section numbers to relative URLS.
51 #define FRAME_WIDTH 400
52 #define FRAME_HEIGHT 400
53 #define LAYOUT_X_MARGIN 2
54 #define LAYOUT_Y_MARGIN 2
57 class wxHelpFrame
: public wxFrame
60 wxHelpFrame(wxWindow
*parent
, int id
, const wxString
&title
,
61 const wxPoint
&pos
, const wxSize
&size
,
62 wxHelpControllerHtml
*controller
);
64 void OnClose(wxCloseEvent
&ev
);
65 bool LoadPage(const wxString
&url
) { return m_htmlwin
->LoadPage(url
); }
67 wxHelpControllerHtml
*m_controller
;
68 wxHtmlWindow
*m_htmlwin
;
72 BEGIN_EVENT_TABLE(wxHelpFrame
, wxFrame
)
73 EVT_CLOSE(wxHelpFrame::OnClose
)
76 wxHelpFrame::wxHelpFrame(wxWindow
*parent
, int id
,
77 const wxString
&title
,
78 const wxPoint
&pos
, const wxSize
&size
,
79 wxHelpControllerHtml
*controller
)
80 : wxFrame(parent
, id
, title
, pos
, size
)
83 m_controller
= controller
;
84 m_htmlwin
= new wxHtmlWindow(this,-1,wxDefaultPosition
,wxSize(FRAME_WIDTH
,
87 wxLayoutConstraints
*c
;
89 c
= new wxLayoutConstraints
;
90 c
->left
.SameAs(this, wxLeft
, 2*LAYOUT_X_MARGIN
);
91 c
->right
.SameAs(this, wxRight
, 2*LAYOUT_X_MARGIN
);
92 c
->top
.SameAs(this, wxTop
, 2*LAYOUT_Y_MARGIN
);
93 c
->bottom
.SameAs(this, wxBottom
, 2*LAYOUT_Y_MARGIN
);
94 m_htmlwin
->SetConstraints(c
);
99 wxHelpFrame::~wxHelpFrame()
104 wxHelpFrame::OnClose(wxCloseEvent
&ev
)
106 wxASSERT(m_controller
);
107 m_controller
->m_Frame
= NULL
;
112 m_controller
->GetFrameParameters(NULL
, NULL
, &newFrame
);
113 m_controller
->SetFrameParameters(GetTitle(), GetSize(),
119 wxHelpControllerHtml::wxHelpControllerHtml(void)
124 SetFrameParameters(_("Help"),
125 wxSize(FRAME_WIDTH
, FRAME_HEIGHT
),
129 wxHelpControllerHtml::~wxHelpControllerHtml(void)
131 if(m_Frame
&& ! m_NewFrameEachTime
)
143 wxHelpControllerHtml::DisplayHelp(wxString
const &relativeURL
)
145 wxBusyCursor b
; // display a busy cursor
148 url
<< m_MapFile
<< SEP
<< relativeURL
;
149 if(! m_Frame
|| m_NewFrameEachTime
)
151 m_Frame
= new wxHelpFrame(NULL
, -1, m_FrameTitle
,
152 m_FramePosition
+wxPoint(m_offset
,m_offset
),
155 if(m_NewFrameEachTime
)
163 return m_Frame
->LoadPage(url
);
168 wxHelpControllerHtml::SetFrameParameters(const wxString
&title
,
173 m_FrameTitle
= title
;
175 m_FramePosition
= pos
;
176 m_NewFrameEachTime
= newFrame
;
180 wxHelpControllerHtml::GetFrameParameters(wxSize
*size
= NULL
,
182 bool *newframe
= NULL
)
184 if(size
) *size
= m_FrameSize
;
185 if(pos
) *pos
= m_FramePosition
;
186 if(newframe
) *newframe
= m_NewFrameEachTime
;