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