]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_choic.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_choic.cpp
3 // Purpose: XRC resource for wxChoice
4 // Author: Bob Mitchell
6 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_XRC && wxUSE_CHOICE
19 #include "wx/xrc/xh_choic.h"
23 #include "wx/choice.h"
26 #include "wx/xml/xml.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")));
48 XRC_MAKE_INSTANCE(control
, wxChoice
)
50 control
->Create(m_parentAsWindow
,
52 GetPosition(), GetSize(),
59 control
->SetSelection(selection
);
63 strList
.Clear(); // dump the strings
70 // handle <item>Label</item>
73 wxString str
= GetNodeContent(m_node
);
74 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
75 str
= wxGetTranslation(str
, m_resource
->GetDomain());
82 bool wxChoiceXmlHandler::CanHandle(wxXmlNode
*node
)
84 return (IsOfClass(node
, wxT("wxChoice")) ||
85 (m_insideBox
&& node
->GetName() == wxT("item")));
88 #endif // wxUSE_XRC && wxUSE_CHOICE