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