]> git.saurik.com Git - wxWidgets.git/blob - src/html/helpdlg.cpp
fix bug VC6 with returning void function
[wxWidgets.git] / src / html / helpdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/html/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 WX_PRECOMP
22 #include "wx/object.h"
23 #include "wx/intl.h"
24 #include "wx/log.h"
25
26 #include "wx/sizer.h"
27
28 #include "wx/bmpbuttn.h"
29 #include "wx/statbox.h"
30 #include "wx/radiobox.h"
31 #include "wx/menu.h"
32 #include "wx/msgdlg.h"
33 #endif // WX_PRECOMP
34
35 #include "wx/html/htmlwin.h"
36 #include "wx/html/helpdlg.h"
37 #include "wx/html/helpctrl.h"
38 #include "wx/artprov.h"
39
40 IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpDialog, wxDialog)
41
42 BEGIN_EVENT_TABLE(wxHtmlHelpDialog, wxDialog)
43 EVT_CLOSE(wxHtmlHelpDialog::OnCloseWindow)
44 END_EVENT_TABLE()
45
46 wxHtmlHelpDialog::wxHtmlHelpDialog(wxWindow* parent, wxWindowID id, const wxString& title,
47 int style, wxHtmlHelpData* data)
48 {
49 Init(data);
50 Create(parent, id, title, style);
51 }
52
53 void wxHtmlHelpDialog::Init(wxHtmlHelpData* data)
54 {
55 // Simply pass the pointer on to the help window
56 m_Data = data;
57 m_HtmlHelpWin = NULL;
58 m_helpController = NULL;
59 }
60
61 // Create: builds the GUI components.
62 bool wxHtmlHelpDialog::Create(wxWindow* parent, wxWindowID id,
63 const wxString& WXUNUSED(title), int style)
64 {
65 m_HtmlHelpWin = new wxHtmlHelpWindow(m_Data);
66
67 wxDialog::Create(parent, id, _("Help"),
68 wxPoint(m_HtmlHelpWin->GetCfgData().x, m_HtmlHelpWin->GetCfgData().y),
69 wxSize(m_HtmlHelpWin->GetCfgData().w, m_HtmlHelpWin->GetCfgData().h),
70 wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, wxT("wxHtmlHelp"));
71 m_HtmlHelpWin->Create(this, wxID_ANY, wxDefaultPosition, GetClientSize(),
72 wxTAB_TRAVERSAL|wxNO_BORDER, style);
73
74 GetPosition(& (m_HtmlHelpWin->GetCfgData().x), & (m_HtmlHelpWin->GetCfgData()).y);
75
76 SetIcon(wxArtProvider::GetIcon(wxART_HELP, wxART_HELP_BROWSER));
77
78 wxWindow* item1 = this;
79 wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
80 item1->SetSizer(item2);
81 item1->SetAutoLayout(true);
82
83 wxWindow* item3 = m_HtmlHelpWin;
84 item2->Add(item3, 1, wxGROW|wxALL, 5);
85
86 wxBoxSizer* item4 = new wxBoxSizer(wxHORIZONTAL);
87 item2->Add(item4, 0, wxGROW, 5);
88
89 item4->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
90
91 wxButton* item6 = new wxButton(item1, wxID_OK, _("Close"), wxDefaultPosition, wxDefaultSize, 0);
92 item4->Add(item6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10);
93 #ifdef __WXMAC__
94 // Add some space for the resize handle
95 item4->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 0);
96 #endif
97
98 Layout();
99 Centre();
100
101 return true;
102 }
103
104 wxHtmlHelpDialog::~wxHtmlHelpDialog()
105 {
106 }
107
108 void wxHtmlHelpDialog::SetTitleFormat(const wxString& format)
109 {
110 m_TitleFormat = format;
111 }
112
113 void wxHtmlHelpDialog::OnCloseWindow(wxCloseEvent& evt)
114 {
115 if (!IsIconized())
116 {
117 GetSize(& (m_HtmlHelpWin->GetCfgData().w), &(m_HtmlHelpWin->GetCfgData().h));
118 GetPosition(& (m_HtmlHelpWin->GetCfgData().x), & (m_HtmlHelpWin->GetCfgData().y));
119 }
120
121 if (m_HtmlHelpWin->GetSplitterWindow() && m_HtmlHelpWin->GetCfgData().navig_on)
122 m_HtmlHelpWin->GetCfgData().sashpos = m_HtmlHelpWin->GetSplitterWindow()->GetSashPosition();
123
124 if (m_helpController)
125 {
126 m_helpController->OnCloseFrame(evt);
127 }
128
129 evt.Skip();
130 }
131
132 #endif // wxUSE_WXHTML_HELP