]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_htmllbox.cpp
Add virtual ~wxAnyScrollHelperBase() to fix compiler warning.
[wxWidgets.git] / src / xrc / xh_htmllbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_simplehtmllbox.cpp
3 // Purpose: XML resource handler for wxSimpleHtmlListBox
4 // Author: Francesco Montorsi
5 // Created: 2006/10/21
6 // Copyright: (c) 2006 Francesco Montorsi
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #if wxUSE_XRC && wxUSE_HTML
18
19 #include "wx/xrc/xh_htmllbox.h"
20
21 #include "wx/htmllbox.h"
22 #include "wx/filesys.h"
23
24 #include "wx/xml/xml.h"
25
26 IMPLEMENT_DYNAMIC_CLASS(wxSimpleHtmlListBoxXmlHandler, wxXmlResourceHandler)
27
28 wxSimpleHtmlListBoxXmlHandler::wxSimpleHtmlListBoxXmlHandler()
29 : wxXmlResourceHandler(), m_insideBox(false)
30 {
31 XRC_ADD_STYLE(wxHLB_DEFAULT_STYLE);
32 XRC_ADD_STYLE(wxHLB_MULTIPLE);
33 AddWindowStyles();
34 }
35
36 wxObject *wxSimpleHtmlListBoxXmlHandler::DoCreateResource()
37 {
38 if ( m_class == wxT("wxSimpleHtmlListBox"))
39 {
40 // find the selection
41 long selection = GetLong(wxT("selection"), -1);
42
43 // need to build the list of strings from children
44 m_insideBox = true;
45 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
46 m_insideBox = false;
47
48 XRC_MAKE_INSTANCE(control, wxSimpleHtmlListBox)
49
50 control->Create(m_parentAsWindow,
51 GetID(),
52 GetPosition(), GetSize(),
53 strList,
54 GetStyle(wxT("style"), wxHLB_DEFAULT_STYLE),
55 wxDefaultValidator,
56 GetName());
57
58 if (selection != -1)
59 control->SetSelection(selection);
60
61 SetupWindow(control);
62 strList.Clear(); // dump the strings
63
64 return control;
65 }
66 else
67 {
68 // on the inside now.
69 // handle <item>Label</item>
70
71 // add to the list
72 wxString str = GetNodeContent(m_node);
73 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
74 str = wxGetTranslation(str, m_resource->GetDomain());
75 strList.Add(str);
76
77 return NULL;
78 }
79 }
80
81 bool wxSimpleHtmlListBoxXmlHandler::CanHandle(wxXmlNode *node)
82 {
83 return (IsOfClass(node, wxT("wxSimpleHtmlListBox")) ||
84 (m_insideBox && node->GetName() == wxT("item")));
85 }
86
87 #endif // wxUSE_XRC && wxUSE_HTML