forked from jonmmorgan/wxwebconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxh_webcontrol.cpp
executable file
·62 lines (48 loc) · 1.53 KB
/
xh_webcontrol.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/////////////////////////////////////////////////////////////////////////////
// Name: xh_webcontrol.cpp
// Purpose: XRC resource handler for wxWebControl
// Author: Ben Morgan
// Licence: wxWindows Licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_XRC
#include <wx/wx.h>
#include "xh_webcontrol.h"
#include "webcontrol.h"
// Register with wxWindows' dynamic class subsystem.
IMPLEMENT_DYNAMIC_CLASS(wxWebControlXmlHandler, wxXmlResourceHandler)
// Constructor.
wxWebControlXmlHandler::wxWebControlXmlHandler()
{
AddWindowStyles();
}
// Creates the control and returns a pointer to it.
wxObject *wxWebControlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(control, wxWebControl)
control->Create(m_parentAsWindow, GetID(),
GetPosition(), GetSize());
if (HasParam(wxT("url")))
{
wxString url = GetParamValue(wxT("url"));
control->OpenURI(url);
}
else if (HasParam(wxT("htmlcode")))
{
// Dunno what makes for a good default URI;
// this should do for now though...
control->SetContent(wxT("about:blank"), GetText(wxT("htmlcode")));
}
SetupWindow(control);
return control;
}
// Returns true if we know how to create a control for the given node.
bool wxWebControlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("wxWebControl"));
}
#endif // wxUSE_XRC