]>
Commit | Line | Data |
---|---|---|
78d14f80 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: xh_html.cpp | |
b5d6954b | 3 | // Purpose: XRC resource for wxHtmlWindow |
78d14f80 VS |
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" | |
135ace6d | 27 | #include "wx/filesys.h" |
78d14f80 VS |
28 | |
29 | ||
30 | wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() | |
31 | : wxXmlResourceHandler() | |
32 | { | |
544fee32 VS |
33 | XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER); |
34 | XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO); | |
161a87e6 | 35 | XRC_ADD_STYLE(wxHW_NO_SELECTION); |
78d14f80 VS |
36 | AddWindowStyles(); |
37 | } | |
38 | ||
39 | wxObject *wxHtmlWindowXmlHandler::DoCreateResource() | |
f2588180 | 40 | { |
544fee32 | 41 | XRC_MAKE_INSTANCE(control, wxHtmlWindow) |
f2588180 VS |
42 | |
43 | control->Create(m_parentAsWindow, | |
44 | GetID(), | |
45 | GetPosition(), GetSize(), | |
46 | GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO), | |
47 | GetName()); | |
48 | ||
49 | if (HasParam(wxT("borders"))) | |
78d14f80 | 50 | { |
f2588180 | 51 | control->SetBorders(GetDimension(wxT("borders"))); |
78d14f80 VS |
52 | } |
53 | ||
544fee32 | 54 | if (HasParam(wxT("url"))) |
78d14f80 | 55 | { |
f2588180 | 56 | wxString url = GetParamValue(wxT("url")); |
135ace6d VS |
57 | wxFileSystem& fsys = GetCurFileSystem(); |
58 | ||
59 | wxFSFile *f = fsys.OpenFile(url); | |
60 | if (f) | |
61 | { | |
62 | control->LoadPage(f->GetLocation()); | |
63 | delete f; | |
64 | } | |
65 | else | |
66 | control->LoadPage(url); | |
78d14f80 | 67 | } |
135ace6d | 68 | |
f2588180 | 69 | else if (HasParam(wxT("htmlcode"))) |
78d14f80 | 70 | { |
f2588180 | 71 | control->SetPage(GetText(wxT("htmlcode"))); |
78d14f80 VS |
72 | } |
73 | ||
74 | SetupWindow(control); | |
75 | ||
76 | return control; | |
77 | } | |
78 | ||
78d14f80 VS |
79 | bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node) |
80 | { | |
81 | return IsOfClass(node, wxT("wxHtmlWindow")); | |
82 | } | |
83 | ||
84 | #endif // wxUSE_HTML |