]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xml/xh_choic.cpp
ea39ffb94b65b230b17866d75199e42005b134a2
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
)
31 wxObject
*wxChoiceXmlHandler::DoCreateResource()
33 if( m_Node
->GetName() == _T("choice"))
36 long selection
= GetLong( _T("selection"), -1 );
38 // need to build the list of strings from children
40 CreateChildren( NULL
, TRUE
/* only this handler */);
41 wxString
*strings
= (wxString
*) NULL
;
42 if( strList
.GetCount() > 0 )
44 strings
= new wxString
[strList
.GetCount()];
45 int count
= strList
.GetCount();
46 for( int i
= 0; i
< count
; i
++ )
47 strings
[i
]=strList
[i
];
51 wxChoice
*control
= new wxChoice(m_ParentAsWindow
,
53 GetPosition(), GetSize(),
62 control
->SetSelection( selection
);
68 strList
.Clear(); // dump the strings
75 // handle <item>Label</item>
78 strList
.Add( GetNodeContent(m_Node
) );
87 bool wxChoiceXmlHandler::CanHandle(wxXmlNode
*node
)
89 return( node
->GetName() == _T("choice") ||
91 node
->GetName() == _T("item" ))