]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_choic.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC resource for wxChoice
4 // Author: Bob Mitchell
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xh_choic.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/xrc/xh_choic.h"
23 #include "wx/choice.h"
26 wxChoiceXmlHandler::wxChoiceXmlHandler()
27 : wxXmlResourceHandler() , m_insideBox(FALSE
)
29 XRC_ADD_STYLE(wxCB_SORT
);
33 wxObject
*wxChoiceXmlHandler::DoCreateResource()
35 if( m_class
== wxT("wxChoice"))
38 long selection
= GetLong(wxT("selection"), -1);
40 // need to build the list of strings from children
42 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
43 wxString
*strings
= (wxString
*) NULL
;
44 if (strList
.GetCount() > 0)
46 strings
= new wxString
[strList
.GetCount()];
47 int count
= strList
.GetCount();
48 for (int i
= 0; i
< count
; i
++)
49 strings
[i
]=strList
[i
];
52 XRC_MAKE_INSTANCE(control
, wxChoice
)
54 control
->Create(m_parentAsWindow
,
56 GetPosition(), GetSize(),
64 control
->SetSelection(selection
);
70 strList
.Clear(); // dump the strings
77 // handle <item>Label</item>
80 strList
.Add(wxGetTranslation(GetNodeContent(m_node
)));
86 bool wxChoiceXmlHandler::CanHandle(wxXmlNode
*node
)
88 return (IsOfClass(node
, wxT("wxChoice")) ||
89 (m_insideBox
&& node
->GetName() == wxT("item")));