]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xrc/xh_choic.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XML 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"
25 wxChoiceXmlHandler::wxChoiceXmlHandler()
26 : wxXmlResourceHandler() , m_insideBox(FALSE
)
32 wxObject
*wxChoiceXmlHandler::DoCreateResource()
34 if( m_class
== wxT("wxChoice"))
37 long selection
= GetLong( wxT("selection"), -1 );
39 // need to build the list of strings from children
41 CreateChildrenPrivately( NULL
, GetParamNode(wxT("content")));
42 wxString
*strings
= (wxString
*) NULL
;
43 if( strList
.GetCount() > 0 )
45 strings
= new wxString
[strList
.GetCount()];
46 int count
= strList
.GetCount();
47 for( int i
= 0; i
< count
; i
++ )
48 strings
[i
]=strList
[i
];
52 wxChoice
*control
= new wxChoice(m_parentAsWindow
,
54 GetPosition(), GetSize(),
63 control
->SetSelection( selection
);
69 strList
.Clear(); // dump the strings
76 // handle <item>Label</item>
79 strList
.Add( GetNodeContent(m_node
) );
88 bool wxChoiceXmlHandler::CanHandle(wxXmlNode
*node
)
90 return (IsOfClass(node
, wxT("wxChoice")) ||
91 (m_insideBox
&& node
->GetName() == wxT("item"))