]>
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
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_CHOICE
20 #include "wx/xrc/xh_choic.h"
24 #include "wx/choice.h"
27 IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler
, wxXmlResourceHandler
)
29 wxChoiceXmlHandler::wxChoiceXmlHandler()
30 : wxXmlResourceHandler() , m_insideBox(false)
32 XRC_ADD_STYLE(wxCB_SORT
);
36 wxObject
*wxChoiceXmlHandler::DoCreateResource()
38 if( m_class
== wxT("wxChoice"))
41 long selection
= GetLong(wxT("selection"), -1);
43 // need to build the list of strings from children
45 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
47 XRC_MAKE_INSTANCE(control
, wxChoice
)
49 control
->Create(m_parentAsWindow
,
51 GetPosition(), GetSize(),
58 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 wxChoiceXmlHandler::CanHandle(wxXmlNode
*node
)
83 return (IsOfClass(node
, wxT("wxChoice")) ||
84 (m_insideBox
&& node
->GetName() == wxT("item")));
87 #endif // wxUSE_XRC && wxUSE_CHOICE