]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/xrc/xh_html.cpp
Further refine of #15226: wxRichTextCtrl: Implement setting properties with undo...
[wxWidgets.git] / src / xrc / xh_html.cpp
... / ...
CommitLineData
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
24IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler)
25
26wxHtmlWindowXmlHandler::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
35wxObject *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
75bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
76{
77 return IsOfClass(node, wxT("wxHtmlWindow"));
78}
79
80#endif // wxUSE_XRC && wxUSE_HTML