1
/////////////////////////////////////////////////////////////////////////////
3
// Purpose: XRC resource for wxListBox
4
// Author: Bob Mitchell & Vaclav Slavik
6
// RCS-ID: $Id: xh_listb.cpp,v 1.12 2005/01/07 21:33:13 VS Exp $
7
// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8
// Licence: wxWindows licence
9
/////////////////////////////////////////////////////////////////////////////
11
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
12
#pragma implementation "xh_listb.h"
15
// For compilers that support precompilation, includes "wx.h".
16
#include "wx/wxprec.h"
24
#include "wx/xrc/xh_listb.h"
25
#include "wx/listbox.h"
28
IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler, wxXmlResourceHandler)
30
wxListBoxXmlHandler::wxListBoxXmlHandler()
31
: wxXmlResourceHandler() , m_insideBox(false)
33
XRC_ADD_STYLE(wxLB_SINGLE);
34
XRC_ADD_STYLE(wxLB_MULTIPLE);
35
XRC_ADD_STYLE(wxLB_EXTENDED);
36
XRC_ADD_STYLE(wxLB_HSCROLL);
37
XRC_ADD_STYLE(wxLB_ALWAYS_SB);
38
XRC_ADD_STYLE(wxLB_NEEDED_SB);
39
XRC_ADD_STYLE(wxLB_SORT);
43
wxObject *wxListBoxXmlHandler::DoCreateResource()
45
if( m_class == wxT("wxListBox"))
48
long selection = GetLong(wxT("selection"), -1);
50
// need to build the list of strings from children
52
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
53
wxString *strings = (wxString *) NULL;
54
if (strList.GetCount() > 0)
56
strings = new wxString[strList.GetCount()];
57
int count = strList.GetCount();
58
for (int i = 0; i < count; i++)
59
strings[i]=strList[i];
62
XRC_MAKE_INSTANCE(control, wxListBox)
64
control->Create(m_parentAsWindow,
66
GetPosition(), GetSize(),
74
control->SetSelection(selection);
80
strList.Clear(); // dump the strings
87
// handle <item>Label</item>
90
wxString str = GetNodeContent(m_node);
91
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
92
str = wxGetTranslation(str);
99
bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node)
101
return (IsOfClass(node, wxT("wxListBox")) ||
102
(m_insideBox && node->GetName() == wxT("item")));