]>
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 | ///////////////////////////////////////////////////////////////////////////// | |
f80ea77b | 10 | |
78d14f80 VS |
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 | ||
621be1ec | 22 | #if wxUSE_XRC && wxUSE_HTML |
78d14f80 | 23 | |
a1e4ec87 | 24 | #include "wx/xrc/xh_html.h" |
78d14f80 VS |
25 | |
26 | #include "wx/html/htmlwin.h" | |
135ace6d | 27 | #include "wx/filesys.h" |
78d14f80 | 28 | |
854e189f | 29 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler) |
78d14f80 | 30 | |
f80ea77b WS |
31 | wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() |
32 | : wxXmlResourceHandler() | |
78d14f80 | 33 | { |
544fee32 VS |
34 | XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER); |
35 | XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO); | |
161a87e6 | 36 | XRC_ADD_STYLE(wxHW_NO_SELECTION); |
78d14f80 VS |
37 | AddWindowStyles(); |
38 | } | |
39 | ||
40 | wxObject *wxHtmlWindowXmlHandler::DoCreateResource() | |
f2588180 | 41 | { |
544fee32 | 42 | XRC_MAKE_INSTANCE(control, wxHtmlWindow) |
f2588180 VS |
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"))) | |
78d14f80 | 51 | { |
f2588180 | 52 | control->SetBorders(GetDimension(wxT("borders"))); |
78d14f80 VS |
53 | } |
54 | ||
544fee32 | 55 | if (HasParam(wxT("url"))) |
78d14f80 | 56 | { |
f2588180 | 57 | wxString url = GetParamValue(wxT("url")); |
135ace6d | 58 | wxFileSystem& fsys = GetCurFileSystem(); |
f80ea77b | 59 | |
135ace6d VS |
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); | |
78d14f80 | 68 | } |
f80ea77b | 69 | |
f2588180 | 70 | else if (HasParam(wxT("htmlcode"))) |
78d14f80 | 71 | { |
f2588180 | 72 | control->SetPage(GetText(wxT("htmlcode"))); |
78d14f80 VS |
73 | } |
74 | ||
75 | SetupWindow(control); | |
f80ea77b | 76 | |
78d14f80 VS |
77 | return control; |
78 | } | |
79 | ||
78d14f80 VS |
80 | bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node) |
81 | { | |
82 | return IsOfClass(node, wxT("wxHtmlWindow")); | |
83 | } | |
84 | ||
621be1ec | 85 | #endif // wxUSE_XRC && wxUSE_HTML |