1
/////////////////////////////////////////////////////////////////////////////
3
// Purpose: XRC resource for wxChoice
4
// Author: Bob Mitchell
6
// RCS-ID: $Id: xh_choic.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_choic.h"
15
// For compilers that support precompilation, includes "wx.h".
16
#include "wx/wxprec.h"
24
#include "wx/xrc/xh_choic.h"
25
#include "wx/choice.h"
28
IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler)
30
wxChoiceXmlHandler::wxChoiceXmlHandler()
31
: wxXmlResourceHandler() , m_insideBox(false)
33
XRC_ADD_STYLE(wxCB_SORT);
37
wxObject *wxChoiceXmlHandler::DoCreateResource()
39
if( m_class == wxT("wxChoice"))
42
long selection = GetLong(wxT("selection"), -1);
44
// need to build the list of strings from children
46
CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
47
wxString *strings = (wxString *) NULL;
48
if (strList.GetCount() > 0)
50
strings = new wxString[strList.GetCount()];
51
int count = strList.GetCount();
52
for (int i = 0; i < count; i++)
53
strings[i]=strList[i];
56
XRC_MAKE_INSTANCE(control, wxChoice)
58
control->Create(m_parentAsWindow,
60
GetPosition(), GetSize(),
68
control->SetSelection(selection);
74
strList.Clear(); // dump the strings
81
// handle <item>Label</item>
84
wxString str = GetNodeContent(m_node);
85
if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
86
str = wxGetTranslation(str);
93
bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node)
95
return (IsOfClass(node, wxT("wxChoice")) ||
96
(m_insideBox && node->GetName() == wxT("item")));