1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_simplehtmllbox.cpp
3 // Purpose: XML resource handler for wxSimpleHtmlListBox
4 // Author: Francesco Montorsi
6 // Copyright: (c) 2006 Francesco Montorsi
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_XRC && wxUSE_HTML
19 #include "wx/xrc/xh_htmllbox.h"
21 #include "wx/htmllbox.h"
22 #include "wx/filesys.h"
24 #include "wx/xml/xml.h"
26 IMPLEMENT_DYNAMIC_CLASS(wxSimpleHtmlListBoxXmlHandler
, wxXmlResourceHandler
)
28 wxSimpleHtmlListBoxXmlHandler::wxSimpleHtmlListBoxXmlHandler()
29 : wxXmlResourceHandler(), m_insideBox(false)
31 XRC_ADD_STYLE(wxHLB_DEFAULT_STYLE
);
32 XRC_ADD_STYLE(wxHLB_MULTIPLE
);
36 wxObject
*wxSimpleHtmlListBoxXmlHandler::DoCreateResource()
38 if ( m_class
== wxT("wxSimpleHtmlListBox"))
41 long selection
= GetLong(wxT("selection"), -1);
43 // need to build the list of strings from children
45 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
48 XRC_MAKE_INSTANCE(control
, wxSimpleHtmlListBox
)
50 control
->Create(m_parentAsWindow
,
52 GetPosition(), GetSize(),
54 GetStyle(wxT("style"), wxHLB_DEFAULT_STYLE
),
59 control
->SetSelection(selection
);
62 strList
.Clear(); // dump the strings
69 // handle <item>Label</item>
72 wxString str
= GetNodeContent(m_node
);
73 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
74 str
= wxGetTranslation(str
, m_resource
->GetDomain());
81 bool wxSimpleHtmlListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
83 return (IsOfClass(node
, wxT("wxSimpleHtmlListBox")) ||
84 (m_insideBox
&& node
->GetName() == wxT("item")));
87 #endif // wxUSE_XRC && wxUSE_HTML