Do not reintroduce #pragma interface/implementation for html/helpdlg and mediactrl...
[wxWidgets.git] / src / html / helpdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: helpdlg.cpp
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
12 // For compilers that support precompilation, includes "wx.h"
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #if wxUSE_WXHTML_HELP
20
21 #ifndef WXPRECOMP
22 #include "wx/intl.h"
23 #include "wx/log.h"
24
25 #include "wx/object.h"
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
43 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpDialog, wxDialog)
44
45 BEGIN_EVENT_TABLE(wxHtmlHelpDialog, wxDialog)
46 EVT_CLOSE(wxHtmlHelpDialog::OnCloseWindow)
47 END_EVENT_TABLE()
48
49 wxHtmlHelpDialog::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
56 void 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.
65 bool wxHtmlHelpDialog::Create(wxWindow* parent, wxWindowID id,
66 const wxString& WXUNUSED(title), int style)
67 {
68 m_HtmlHelpWin = new wxHtmlHelpWindow(m_Data);
69
70 wxDialog::Create(parent, id, _("Help"),
71 wxPoint(m_HtmlHelpWin->GetCfgData().x, m_HtmlHelpWin->GetCfgData().y),
72 wxSize(m_HtmlHelpWin->GetCfgData().w, m_HtmlHelpWin->GetCfgData().h),
73 wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, wxT("wxHtmlHelp"));
74 m_HtmlHelpWin->Create(this, -1, wxDefaultPosition, GetClientSize(),
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
100
101 Layout();
102 Centre();
103
104 return true;
105 }
106
107 wxHtmlHelpDialog::~wxHtmlHelpDialog()
108 {
109 }
110
111 void wxHtmlHelpDialog::SetTitleFormat(const wxString& format)
112 {
113 m_TitleFormat = format;
114 }
115
116 void 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
136