]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xml/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/xml/xh_choic.h"
23 #include "wx/choice.h"
25 wxChoiceXmlHandler::wxChoiceXmlHandler()
26 : wxXmlResourceHandler() , m_InsideBox(FALSE
)
32 wxObject
*wxChoiceXmlHandler::DoCreateResource()
34 if( m_Node
->GetName() == _T("choice"))
37 long selection
= GetLong( _T("selection"), -1 );
39 // need to build the list of strings from children
41 CreateChildren( NULL
, TRUE
/* only this handler */,
42 GetParamNode(_T("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
];
53 wxChoice
*control
= new wxChoice(m_ParentAsWindow
,
55 GetPosition(), GetSize(),
64 control
->SetSelection( selection
);
70 strList
.Clear(); // dump the strings
77 // handle <item>Label</item>
80 strList
.Add( GetNodeContent(m_Node
) );
89 bool wxChoiceXmlHandler::CanHandle(wxXmlNode
*node
)
91 return( node
->GetName() == _T("choice") ||
93 node
->GetName() == _T("item" ))