]>
git.saurik.com Git - wxWidgets.git/blob - src/html/helpfrm.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlHelpFrame
4 // Notes: Based on htmlhelp.cpp, implementing a monolithic
5 // HTML Help controller class, by Vaclav Slavik
6 // Author: Harm van der Heijden and Vaclav Slavik
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h"
14 #include "wx/wxprec.h"
26 #include "wx/object.h"
29 #include "wx/bmpbuttn.h"
30 #include "wx/statbox.h"
31 #include "wx/radiobox.h"
36 #include "wx/msgdlg.h"
39 #include "wx/html/helpfrm.h"
40 #include "wx/html/helpctrl.h"
41 #include "wx/textctrl.h"
42 #include "wx/notebook.h"
43 #include "wx/imaglist.h"
44 #include "wx/treectrl.h"
45 #include "wx/tokenzr.h"
46 #include "wx/wfstream.h"
47 #include "wx/html/htmlwin.h"
48 #include "wx/busyinfo.h"
49 #include "wx/progdlg.h"
50 #include "wx/toolbar.h"
51 #include "wx/fontenum.h"
52 #include "wx/stream.h"
53 #include "wx/filedlg.h"
54 #include "wx/artprov.h"
55 #include "wx/spinctrl.h"
56 #include "wx/dynarray.h"
57 #include "wx/choicdlg.h"
58 #include "wx/settings.h"
60 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame
, wxFrame
)
62 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
63 EVT_ACTIVATE(wxHtmlHelpFrame::OnActivate
)
64 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)
66 EVT_MENU(wxID_CLOSE
, wxHtmlHelpFrame::OnClose
)
67 EVT_MENU(wxID_ABOUT
, wxHtmlHelpFrame::OnAbout
)
68 EVT_MENU(wxID_HELP_CONTENTS
, wxHtmlHelpFrame::OnAbout
)
72 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
73 int style
, wxHtmlHelpData
* data
)
76 Create(parent
, id
, title
, style
);
79 void wxHtmlHelpFrame::Init(wxHtmlHelpData
* data
)
81 // Simply pass the pointer on to the help window
84 m_helpController
= (wxHtmlHelpController
*) NULL
;
87 // Create: builds the GUI components.
88 bool wxHtmlHelpFrame::Create(wxWindow
* parent
, wxWindowID id
,
89 const wxString
& WXUNUSED(title
), int style
)
91 m_HtmlHelpWin
= new wxHtmlHelpWindow(m_Data
);
93 wxFrame::Create(parent
, id
, _("Help"),
94 wxPoint(m_HtmlHelpWin
->GetCfgData().x
, m_HtmlHelpWin
->GetCfgData().y
),
95 wxSize(m_HtmlHelpWin
->GetCfgData().w
, m_HtmlHelpWin
->GetCfgData().h
),
96 wxDEFAULT_FRAME_STYLE
, wxT("wxHtmlHelp"));
100 m_HtmlHelpWin
->Create(this, -1, wxDefaultPosition
, wxDefaultSize
,
101 wxTAB_TRAVERSAL
|wxNO_BORDER
, style
);
103 GetPosition(& (m_HtmlHelpWin
->GetCfgData().x
), & (m_HtmlHelpWin
->GetCfgData()).y
);
105 SetIcon(wxArtProvider::GetIcon(wxART_HELP
, wxART_HELP_BROWSER
));
107 // On the Mac, each modeless frame must have a menubar.
108 // TODO: add more menu items, and perhaps add a style to show
109 // the menubar: compulsory on the Mac, optional elsewhere.
111 wxMenuBar
* menuBar
= new wxMenuBar
;
113 wxMenu
* fileMenu
= new wxMenu
;
114 fileMenu
->Append(wxID_HTML_OPENFILE
, _("&Open..."));
115 fileMenu
->AppendSeparator();
116 fileMenu
->Append(wxID_CLOSE
, _("&Close"));
118 wxMenu
* helpMenu
= new wxMenu
;
119 helpMenu
->Append(wxID_ABOUT
, _("&About..."));
120 // Ensures we don't get an empty help menu
121 helpMenu
->Append(wxID_HELP_CONTENTS
, _("&About..."));
123 menuBar
->Append(fileMenu
,_("&File"));
124 menuBar
->Append(helpMenu
,_("&Help"));
128 m_HtmlHelpWin
->GetHtmlWindow()->SetRelatedFrame(this, m_TitleFormat
);
130 m_HtmlHelpWin
->GetHtmlWindow()->SetRelatedStatusBar(0);
135 wxHtmlHelpFrame::~wxHtmlHelpFrame()
139 void wxHtmlHelpFrame::SetTitleFormat(const wxString
& format
)
141 if (GetHelpWindow() && GetHelpWindow()->GetHtmlWindow())
142 GetHelpWindow()->GetHtmlWindow()->SetRelatedFrame(this, format
);
143 m_TitleFormat
= format
;
151 void wxHtmlHelpFrame::OnActivate(wxActivateEvent
& event
)
153 // This saves one mouse click when using the
154 // wxHTML for context sensitive help systems
156 // NB: wxActivateEvent is a bit broken in wxGTK
157 // and is sometimes sent when it should not be
158 if (event
.GetActive() && m_HtmlHelpWin
)
159 m_HtmlHelpWin
->GetHtmlWindow()->SetFocus();
165 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
169 GetSize(& (m_HtmlHelpWin
->GetCfgData().w
), &(m_HtmlHelpWin
->GetCfgData().h
));
170 GetPosition(& (m_HtmlHelpWin
->GetCfgData().x
), & (m_HtmlHelpWin
->GetCfgData().y
));
180 if (m_HtmlHelpWin
->GetSplitterWindow() && m_HtmlHelpWin
->GetCfgData().navig_on
)
181 m_HtmlHelpWin
->GetCfgData().sashpos
= m_HtmlHelpWin
->GetSplitterWindow()->GetSashPosition();
183 if (m_helpController
&& m_helpController
->IsKindOf(CLASSINFO(wxHtmlHelpController
)))
185 ((wxHtmlHelpController
*) m_helpController
)->OnCloseFrame(evt
);
191 // Make the help controller's frame 'modal' if
193 void wxHtmlHelpFrame::AddGrabIfNeeded()
195 // So far, wxGTK only
197 bool needGrab
= FALSE
;
199 // Check if there are any modal windows present,
200 // in which case we need to add a grab.
201 for ( wxWindowList::Node
* node
= wxTopLevelWindows
.GetFirst();
203 node
= node
->GetNext() )
205 wxWindow
*win
= node
->GetData();
206 wxDialog
*dialog
= wxDynamicCast(win
, wxDialog
);
208 if (dialog
&& dialog
->IsModal())
218 void wxHtmlHelpFrame::UseConfig(wxConfigBase
*config
, const wxString
& rootPath
)
221 m_HtmlHelpWin
->UseConfig(config
, rootPath
);
225 void wxHtmlHelpFrame::OnClose(wxCommandEvent
& event
)
230 void wxHtmlHelpFrame::OnAbout(wxCommandEvent
& event
)
232 wxMessageBox(wxT("wxWidgets HTML Help Viewer (c) 1998-2006, Vaclav Slavik et al"), wxT("HelpView"),
233 wxICON_INFORMATION
|wxOK
, this);
237 #endif // wxUSE_WXHTML_HELP