]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/xrc/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 | // For compilers that support precompilation, includes "wx.h". | |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
18 | #if wxUSE_XRC && wxUSE_HTML | |
19 | ||
20 | #include "wx/xrc/xh_html.h" | |
21 | ||
22 | #include "wx/html/htmlwin.h" | |
23 | #include "wx/filesys.h" | |
24 | ||
25 | IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowXmlHandler, wxXmlResourceHandler) | |
26 | ||
27 | wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler() | |
28 | : wxXmlResourceHandler() | |
29 | { | |
30 | XRC_ADD_STYLE(wxHW_SCROLLBAR_NEVER); | |
31 | XRC_ADD_STYLE(wxHW_SCROLLBAR_AUTO); | |
32 | XRC_ADD_STYLE(wxHW_NO_SELECTION); | |
33 | AddWindowStyles(); | |
34 | } | |
35 | ||
36 | wxObject *wxHtmlWindowXmlHandler::DoCreateResource() | |
37 | { | |
38 | XRC_MAKE_INSTANCE(control, wxHtmlWindow) | |
39 | ||
40 | control->Create(m_parentAsWindow, | |
41 | GetID(), | |
42 | GetPosition(), GetSize(), | |
43 | GetStyle(wxT("style"), wxHW_SCROLLBAR_AUTO), | |
44 | GetName()); | |
45 | ||
46 | if (HasParam(wxT("borders"))) | |
47 | { | |
48 | control->SetBorders(GetDimension(wxT("borders"))); | |
49 | } | |
50 | ||
51 | if (HasParam(wxT("url"))) | |
52 | { | |
53 | wxString url = GetParamValue(wxT("url")); | |
54 | wxFileSystem& fsys = GetCurFileSystem(); | |
55 | ||
56 | wxFSFile *f = fsys.OpenFile(url); | |
57 | if (f) | |
58 | { | |
59 | control->LoadPage(f->GetLocation()); | |
60 | delete f; | |
61 | } | |
62 | else | |
63 | control->LoadPage(url); | |
64 | } | |
65 | ||
66 | else if (HasParam(wxT("htmlcode"))) | |
67 | { | |
68 | control->SetPage(GetText(wxT("htmlcode"))); | |
69 | } | |
70 | ||
71 | SetupWindow(control); | |
72 | ||
73 | return control; | |
74 | } | |
75 | ||
76 | bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node) | |
77 | { | |
78 | return IsOfClass(node, wxT("wxHtmlWindow")); | |
79 | } | |
80 | ||
81 | #endif // wxUSE_XRC && wxUSE_HTML |