]> git.saurik.com Git - wxWidgets.git/blame - src/html/helpdlg.cpp
Include wx/stream.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / html / helpdlg.cpp
CommitLineData
3755cfa6 1/////////////////////////////////////////////////////////////////////////////
8e3f3880 2// Name: src/html/helpdlg.cpp
3755cfa6
JS
3// Purpose: wxHtmlHelpDialog
4// Notes: Based on htmlhelp.cpp, implementing a monolithic
5// HTML Help controller class, by Vaclav Slavik
6// Author: Harm van der Heijden, Vaclav Slavik and Julian Smart
7// RCS-ID: $Id$
8// Copyright: (c) Harm van der Heijden, Vaclav Slavik and Julian Smart
9// Licence: wxWidgets licence
10/////////////////////////////////////////////////////////////////////////////
11
3755cfa6
JS
12// For compilers that support precompilation, includes "wx.h"
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
8e3f3880 16 #pragma hdrstop
3755cfa6
JS
17#endif
18
19#if wxUSE_WXHTML_HELP
20
21#ifndef WXPRECOMP
8e3f3880 22 #include "wx/object.h"
3755cfa6
JS
23 #include "wx/intl.h"
24 #include "wx/log.h"
25
3755cfa6
JS
26 #include "wx/sizer.h"
27
28 #include "wx/bmpbuttn.h"
29 #include "wx/statbox.h"
30 #include "wx/radiobox.h"
31#endif // WXPRECOMP
32
33#ifdef __WXMAC__
34 #include "wx/menu.h"
35 #include "wx/msgdlg.h"
36#endif
37
38#include "wx/html/htmlwin.h"
39#include "wx/html/helpdlg.h"
40#include "wx/html/helpctrl.h"
41#include "wx/artprov.h"
42
43IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpDialog, wxDialog)
44
45BEGIN_EVENT_TABLE(wxHtmlHelpDialog, wxDialog)
46 EVT_CLOSE(wxHtmlHelpDialog::OnCloseWindow)
47END_EVENT_TABLE()
48
49wxHtmlHelpDialog::wxHtmlHelpDialog(wxWindow* parent, wxWindowID id, const wxString& title,
50 int style, wxHtmlHelpData* data)
51{
52 Init(data);
53 Create(parent, id, title, style);
54}
55
56void wxHtmlHelpDialog::Init(wxHtmlHelpData* data)
57{
58 // Simply pass the pointer on to the help window
59 m_Data = data;
60 m_HtmlHelpWin = NULL;
61 m_helpController = NULL;
62}
63
64// Create: builds the GUI components.
65bool wxHtmlHelpDialog::Create(wxWindow* parent, wxWindowID id,
66 const wxString& WXUNUSED(title), int style)
67{
68 m_HtmlHelpWin = new wxHtmlHelpWindow(m_Data);
69
8e3f3880 70 wxDialog::Create(parent, id, _("Help"),
3755cfa6 71 wxPoint(m_HtmlHelpWin->GetCfgData().x, m_HtmlHelpWin->GetCfgData().y),
8e3f3880 72 wxSize(m_HtmlHelpWin->GetCfgData().w, m_HtmlHelpWin->GetCfgData().h),
3755cfa6 73 wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, wxT("wxHtmlHelp"));
8e3f3880 74 m_HtmlHelpWin->Create(this, wxID_ANY, wxDefaultPosition, GetClientSize(),
3755cfa6
JS
75 wxTAB_TRAVERSAL|wxNO_BORDER, style);
76
77 GetPosition(& (m_HtmlHelpWin->GetCfgData().x), & (m_HtmlHelpWin->GetCfgData()).y);
78
79 SetIcon(wxArtProvider::GetIcon(wxART_HELP, wxART_HELP_BROWSER));
80
81 wxWindow* item1 = this;
82 wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
83 item1->SetSizer(item2);
84 item1->SetAutoLayout(true);
85
86 wxWindow* item3 = m_HtmlHelpWin;
87 item2->Add(item3, 1, wxGROW|wxALL, 5);
88
89 wxBoxSizer* item4 = new wxBoxSizer(wxHORIZONTAL);
90 item2->Add(item4, 0, wxGROW, 5);
91
92 item4->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
93
94 wxButton* item6 = new wxButton(item1, wxID_OK, _("&Close"), wxDefaultPosition, wxDefaultSize, 0);
95 item4->Add(item6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10);
96#ifdef __WXMAC__
97 // Add some space for the resize handle
98 item4->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 0);
99#endif
8e3f3880 100
3755cfa6
JS
101 Layout();
102 Centre();
103
104 return true;
105}
106
107wxHtmlHelpDialog::~wxHtmlHelpDialog()
108{
109}
110
111void wxHtmlHelpDialog::SetTitleFormat(const wxString& format)
112{
113 m_TitleFormat = format;
114}
115
116void wxHtmlHelpDialog::OnCloseWindow(wxCloseEvent& evt)
117{
118 if (!IsIconized())
119 {
120 GetSize(& (m_HtmlHelpWin->GetCfgData().w), &(m_HtmlHelpWin->GetCfgData().h));
121 GetPosition(& (m_HtmlHelpWin->GetCfgData().x), & (m_HtmlHelpWin->GetCfgData().y));
122 }
123
124 if (m_HtmlHelpWin->GetSplitterWindow() && m_HtmlHelpWin->GetCfgData().navig_on)
125 m_HtmlHelpWin->GetCfgData().sashpos = m_HtmlHelpWin->GetSplitterWindow()->GetSashPosition();
126
127 if (m_helpController)
128 {
129 m_helpController->OnCloseFrame(evt);
130 }
131
132 evt.Skip();
133}
134
135#endif // wxUSE_WXHTML_HELP