-
Notifications
You must be signed in to change notification settings - Fork 3
/
GVHelpFrame.cpp
101 lines (80 loc) · 2.11 KB
/
GVHelpFrame.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "wx/toolbar.h"
#include "GVHelpFrame.h"
GVHelpFrame::GVHelpFrame (wxWindow * parent)
{
wxXmlResource::Get ()->LoadFrame (this, parent, _T ("helpframe"));
m_toolbar =
(wxToolBar *) wxXmlResource::Get ()->LoadToolBar (this,
_
("helpframe_toolbar"));
this->Show (true);
this->Raise ();
}
bool GVHelpFrame::SetIndex (wxString & page)
{
m_index = page;
wxHtmlWindow *
helpWindow =
XRCCTRL (*this, "helpframe_html", wxHtmlWindow);
helpWindow->SetRelatedFrame (this, _T ("%s"));
if (!helpWindow->LoadPage (page)) {
wxLogMessage (_T ("Unable to load index page"));
}
return true;
}
void
GVHelpFrame::OnClose (wxCloseEvent & evt)
{
this->Show (false);
}
void
GVHelpFrame::OnHome (wxCommandEvent & evt)
{
wxHtmlWindow *helpWindow =
XRCCTRL (*this, "helpframe_html", wxHtmlWindow);
helpWindow->LoadPage (m_index);
}
void
GVHelpFrame::OnForward (wxCommandEvent & evt)
{
wxHtmlWindow *helpWindow =
XRCCTRL (*this, "helpframe_html", wxHtmlWindow);
helpWindow->HistoryForward ();
}
void
GVHelpFrame::OnBack (wxCommandEvent & evt)
{
wxHtmlWindow *helpWindow =
XRCCTRL (*this, "helpframe_html", wxHtmlWindow);
helpWindow->HistoryBack ();
}
/* hellcat0:
* this is a bit of a hack because i didn't want to create a new class and overwrite
* the OnLinkClicked etc.
*/
void
GVHelpFrame::OnPaint (wxPaintEvent & evt)
{
wxPaintDC dc (this);
wxHtmlWindow *helpWindow =
XRCCTRL (*this, "helpframe_html", wxHtmlWindow);
if (helpWindow->HistoryCanBack ()) {
m_toolbar->EnableTool (XRCID ("helpframe_back"), true);
}
else {
m_toolbar->EnableTool (XRCID ("helpframe_back"), false);
}
if (helpWindow->HistoryCanForward ()) {
m_toolbar->EnableTool (XRCID ("helpframe_forward"), true);
}
else {
m_toolbar->EnableTool (XRCID ("helpframe_forward"), false);
}
}
BEGIN_EVENT_TABLE (GVHelpFrame, wxFrame)
EVT_PAINT (GVHelpFrame::OnPaint)
EVT_CLOSE (GVHelpFrame::OnClose)
EVT_TOOL (XRCID ("helpframe_home"), GVHelpFrame::OnHome)
EVT_TOOL (XRCID ("helpframe_forward"), GVHelpFrame::OnForward)
EVT_TOOL (XRCID ("helpframe_back"),
GVHelpFrame::OnBack) END_EVENT_TABLE ()