]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_html.cpp
wxMSW: return correct value from wxMessageDialog::GetReturnCode().
[wxWidgets.git] / src / xrc / xh_html.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_html.cpp
3 // Purpose: XRC resource for wxHtmlWindow
4 // Author: Bob Mitchell
5 // Created: 2000/03/21
6 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #if wxUSE_XRC && wxUSE_HTML
18
19 #include "wx/xrc/xh_html.h"
20
21 #include "wx/html/htmlwin.h"
22 #include "wx/filesys.h"
23
24 IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler)
25
26 wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
27 : wxXmlResourceHandler()
28 {
29 XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER);
30 XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO);
31 XRC_ADD_STYLE(wxHW_NO_SELECTION);
32 AddWindowStyles();
33 }
34
35 wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
36 {
37 XRC_MAKE_INSTANCE(control, wxHtmlWindow)
38
39 control->Create(m_parentAsWindow,
40 GetID(),
41 GetPosition(), GetSize(),
42 GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO),
43 GetName());
44
45 if (HasParam(wxT("borders")))
46 {
47 control->SetBorders(GetDimension(wxT("borders")));
48 }
49
50 if (HasParam(wxT("url")))
51 {
52 wxString url = GetParamValue(wxT("url"));
53 wxFileSystem& fsys = GetCurFileSystem();
54
55 wxFSFile *f = fsys.OpenFile(url);
56 if (f)
57 {
58 control->LoadPage(f->GetLocation());
59 delete f;
60 }
61 else
62 control->LoadPage(url);
63 }
64
65 else if (HasParam(wxT("htmlcode")))
66 {
67 control->SetPage(GetText(wxT("htmlcode")));
68 }
69
70 SetupWindow(control);
71
72 return control;
73 }
74
75 bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
76 {
77 return IsOfClass(node, wxT("wxHtmlWindow"));
78 }
79
80 #endif // wxUSE_XRC && wxUSE_HTML