]>
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 #include "wx/xml/xml.h"
29 IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler
, wxXmlResourceHandler
)
31 wxChoiceXmlHandler::wxChoiceXmlHandler()
32 : wxXmlResourceHandler() , m_insideBox(false)
34 XRC_ADD_STYLE(wxCB_SORT
);
38 wxObject
*wxChoiceXmlHandler::DoCreateResource()
40 if( m_class
== wxT("wxChoice"))
43 long selection
= GetLong(wxT("selection"), -1);
45 // need to build the list of strings from children
47 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
49 XRC_MAKE_INSTANCE(control
, wxChoice
)
51 control
->Create(m_parentAsWindow
,
53 GetPosition(), GetSize(),
60 control
->SetSelection(selection
);
64 strList
.Clear(); // dump the strings
71 // handle <item>Label</item>
74 wxString str
= GetNodeContent(m_node
);
75 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
76 str
= wxGetTranslation(str
, m_resource
->GetDomain());
83 bool wxChoiceXmlHandler::CanHandle(wxXmlNode
*node
)
85 return (IsOfClass(node
, wxT("wxChoice")) ||
86 (m_insideBox
&& node
->GetName() == wxT("item")));
89 #endif // wxUSE_XRC && wxUSE_CHOICE