]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_html.cpp
Don't create a bitmap with dimensions <= 0...
[wxWidgets.git] / src / xrc / xh_html.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xh_html.cpp
3 // Purpose: XML 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
30 wxHtmlWindowXmlHandler::wxHtmlWindowXmlHandler()
31 : wxXmlResourceHandler()
32 {
33 ADD_STYLE( wxHW_SCROLLBAR_NEVER );
34 ADD_STYLE( wxHW_SCROLLBAR_AUTO );
35 AddWindowStyles();
36 }
37
38 wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
39 {
40 wxHtmlWindow *control = new wxHtmlWindow(m_parentAsWindow,
41 GetID(),
42 GetPosition(), GetSize(),
43 GetStyle( wxT("style" ), wxHW_SCROLLBAR_AUTO),
44 GetName()
45 );
46
47 if( HasParam( wxT("borders") ))
48 {
49 control->SetBorders( GetDimension( wxT("borders" )));
50 }
51
52 if( HasParam( wxT("url") ))
53 {
54 wxString url = GetParamValue(wxT("url" ));
55 wxFileSystem& fsys = GetCurFileSystem();
56
57 wxFSFile *f = fsys.OpenFile(url);
58 if (f)
59 {
60 control->LoadPage(f->GetLocation());
61 delete f;
62 }
63 else
64 control->LoadPage(url);
65 }
66
67 else if( HasParam( wxT("htmlcode") ))
68 {
69 control->SetPage( GetText(wxT("htmlcode")) );
70 }
71
72 SetupWindow(control);
73
74 return control;
75 }
76
77
78
79 bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
80 {
81 return IsOfClass(node, wxT("wxHtmlWindow"));
82 }
83
84 #endif // wxUSE_HTML