]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xrc/xh_radbx.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC resource for wxRadioBox
4 // Author: Bob Mitchell
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xh_radbx.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/xrc/xh_radbx.h"
23 #include "wx/radiobox.h"
28 wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
29 : wxXmlResourceHandler(), m_insideBox(FALSE
)
31 XRC_ADD_STYLE(wxRA_SPECIFY_COLS
);
32 XRC_ADD_STYLE(wxRA_HORIZONTAL
);
33 XRC_ADD_STYLE(wxRA_SPECIFY_ROWS
);
34 XRC_ADD_STYLE(wxRA_VERTICAL
);
38 wxObject
*wxRadioBoxXmlHandler::DoCreateResource()
40 if( m_class
== wxT("wxRadioBox"))
43 long selection
= GetLong( wxT("selection"), -1 );
45 // need to build the list of strings from children
47 CreateChildrenPrivately( NULL
, GetParamNode(wxT("content")));
48 wxString
*strings
= (wxString
*) NULL
;
49 if( strList
.GetCount() > 0 )
51 strings
= new wxString
[strList
.GetCount()];
52 int count
= strList
.GetCount();
53 for( int i
= 0; i
< count
; i
++ )
54 strings
[i
]=strList
[i
];
57 XRC_MAKE_INSTANCE(control
, wxRadioBox
)
59 control
->Create(m_parentAsWindow
,
61 GetText(wxT("label")),
62 GetPosition(), GetSize(),
65 GetLong(wxT("dimension"), 1),
71 control
->SetSelection(selection
);
77 strList
.Clear(); // dump the strings
84 // handle <item selected="boolean">Label</item>
87 wxString str
= GetNodeContent(m_node
);
88 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
89 str
= wxGetTranslation(str
);
97 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
99 return (IsOfClass(node
, wxT("wxRadioBox")) ||
100 (m_insideBox
&& node
->GetName() == wxT("item")));