]>
git.saurik.com Git - wxWidgets.git/blob - src/html/helpfrm.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/helpfrm.cpp
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"
23 #include "wx/object.h"
24 #include "wx/dynarray.h"
28 #include "wx/stream.h"
33 #include "wx/bmpbuttn.h"
34 #include "wx/statbox.h"
35 #include "wx/radiobox.h"
40 #include "wx/msgdlg.h"
43 #include "wx/html/helpfrm.h"
44 #include "wx/html/helpctrl.h"
45 #include "wx/textctrl.h"
46 #include "wx/notebook.h"
47 #include "wx/imaglist.h"
48 #include "wx/treectrl.h"
49 #include "wx/tokenzr.h"
50 #include "wx/wfstream.h"
51 #include "wx/html/htmlwin.h"
52 #include "wx/busyinfo.h"
53 #include "wx/progdlg.h"
54 #include "wx/toolbar.h"
55 #include "wx/fontenum.h"
56 #include "wx/filedlg.h"
57 #include "wx/artprov.h"
58 #include "wx/spinctrl.h"
59 #include "wx/choicdlg.h"
60 #include "wx/settings.h"
62 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame
, wxFrame
)
64 BEGIN_EVENT_TABLE(wxHtmlHelpFrame
, wxFrame
)
65 EVT_ACTIVATE(wxHtmlHelpFrame::OnActivate
)
66 EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow
)
68 EVT_MENU(wxID_CLOSE
, wxHtmlHelpFrame::OnClose
)
69 EVT_MENU(wxID_ABOUT
, wxHtmlHelpFrame::OnAbout
)
70 EVT_MENU(wxID_HELP_CONTENTS
, wxHtmlHelpFrame::OnAbout
)
74 wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
75 int style
, wxHtmlHelpData
* data
)
78 Create(parent
, id
, title
, style
);
81 void wxHtmlHelpFrame::Init(wxHtmlHelpData
* data
)
83 // Simply pass the pointer on to the help window
86 m_helpController
= (wxHtmlHelpController
*) NULL
;
89 // Create: builds the GUI components.
90 bool wxHtmlHelpFrame::Create(wxWindow
* parent
, wxWindowID id
,
91 const wxString
& WXUNUSED(title
), int style
)
93 m_HtmlHelpWin
= new wxHtmlHelpWindow(m_Data
);
95 wxFrame::Create(parent
, id
, _("Help"),
96 wxPoint(m_HtmlHelpWin
->GetCfgData().x
, m_HtmlHelpWin
->GetCfgData().y
),
97 wxSize(m_HtmlHelpWin
->GetCfgData().w
, m_HtmlHelpWin
->GetCfgData().h
),
98 wxDEFAULT_FRAME_STYLE
, wxT("wxHtmlHelp"));
102 m_HtmlHelpWin
->Create(this, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
,
103 wxTAB_TRAVERSAL
|wxNO_BORDER
, style
);
105 GetPosition(& (m_HtmlHelpWin
->GetCfgData().x
), & (m_HtmlHelpWin
->GetCfgData()).y
);
107 SetIcon(wxArtProvider::GetIcon(wxART_HELP
, wxART_HELP_BROWSER
));
109 // On the Mac, each modeless frame must have a menubar.
110 // TODO: add more menu items, and perhaps add a style to show
111 // the menubar: compulsory on the Mac, optional elsewhere.
113 wxMenuBar
* menuBar
= new wxMenuBar
;
115 wxMenu
* fileMenu
= new wxMenu
;
116 fileMenu
->Append(wxID_HTML_OPENFILE
, _("&Open..."));
117 fileMenu
->AppendSeparator();
118 fileMenu
->Append(wxID_CLOSE
, _("&Close"));
120 wxMenu
* helpMenu
= new wxMenu
;
121 helpMenu
->Append(wxID_ABOUT
, _("&About..."));
122 // Ensures we don't get an empty help menu
123 helpMenu
->Append(wxID_HELP_CONTENTS
, _("&About..."));
125 menuBar
->Append(fileMenu
,_("&File"));
126 menuBar
->Append(helpMenu
,_("&Help"));
130 m_HtmlHelpWin
->GetHtmlWindow()->SetRelatedFrame(this, m_TitleFormat
);
132 m_HtmlHelpWin
->GetHtmlWindow()->SetRelatedStatusBar(0);
137 wxHtmlHelpFrame::~wxHtmlHelpFrame()
141 void wxHtmlHelpFrame::SetTitleFormat(const wxString
& format
)
143 if (GetHelpWindow() && GetHelpWindow()->GetHtmlWindow())
144 GetHelpWindow()->GetHtmlWindow()->SetRelatedFrame(this, format
);
145 m_TitleFormat
= format
;
153 void wxHtmlHelpFrame::OnActivate(wxActivateEvent
& event
)
155 // This saves one mouse click when using the
156 // wxHTML for context sensitive help systems
158 // NB: wxActivateEvent is a bit broken in wxGTK
159 // and is sometimes sent when it should not be
160 if (event
.GetActive() && m_HtmlHelpWin
)
161 m_HtmlHelpWin
->GetHtmlWindow()->SetFocus();
167 void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent
& evt
)
171 GetSize(& (m_HtmlHelpWin
->GetCfgData().w
), &(m_HtmlHelpWin
->GetCfgData().h
));
172 GetPosition(& (m_HtmlHelpWin
->GetCfgData().x
), & (m_HtmlHelpWin
->GetCfgData().y
));
182 if (m_HtmlHelpWin
->GetSplitterWindow() && m_HtmlHelpWin
->GetCfgData().navig_on
)
183 m_HtmlHelpWin
->GetCfgData().sashpos
= m_HtmlHelpWin
->GetSplitterWindow()->GetSashPosition();
185 if (m_helpController
&& m_helpController
->IsKindOf(CLASSINFO(wxHtmlHelpController
)))
187 ((wxHtmlHelpController
*) m_helpController
)->OnCloseFrame(evt
);
193 // Make the help controller's frame 'modal' if
195 void wxHtmlHelpFrame::AddGrabIfNeeded()
197 // So far, wxGTK only
199 bool needGrab
= false;
201 // Check if there are any modal windows present,
202 // in which case we need to add a grab.
203 for ( wxWindowList::iterator it
= wxTopLevelWindows
.begin();
204 it
!= wxTopLevelWindows
.end();
208 wxDialog
*dialog
= wxDynamicCast(win
, wxDialog
);
210 if (dialog
&& dialog
->IsModal())
220 void wxHtmlHelpFrame::UseConfig(wxConfigBase
*config
, const wxString
& rootPath
)
223 m_HtmlHelpWin
->UseConfig(config
, rootPath
);
227 void wxHtmlHelpFrame::OnClose(wxCommandEvent
& event
)
232 void wxHtmlHelpFrame::OnAbout(wxCommandEvent
& event
)
234 wxMessageBox(wxT("wxWidgets HTML Help Viewer (c) 1998-2006, Vaclav Slavik et al"), wxT("HelpView"),
235 wxICON_INFORMATION
|wxOK
, this);
239 #endif // wxUSE_WXHTML_HELP