]>
git.saurik.com Git - wxWidgets.git/blob - 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 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_RADIOBOX
20 #include "wx/xrc/xh_radbx.h"
21 #include "wx/radiobox.h"
24 IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler
, wxXmlResourceHandler
)
26 wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
27 : wxXmlResourceHandler(), m_insideBox(false)
29 XRC_ADD_STYLE(wxRA_SPECIFY_COLS
);
30 XRC_ADD_STYLE(wxRA_HORIZONTAL
);
31 XRC_ADD_STYLE(wxRA_SPECIFY_ROWS
);
32 XRC_ADD_STYLE(wxRA_VERTICAL
);
36 wxObject
*wxRadioBoxXmlHandler::DoCreateResource()
38 if( m_class
== wxT("wxRadioBox"))
41 long selection
= GetLong( wxT("selection"), -1 );
43 // need to build the list of strings from children
45 CreateChildrenPrivately( NULL
, GetParamNode(wxT("content")));
46 wxString
*strings
= (wxString
*) NULL
;
47 if( strList
.GetCount() > 0 )
49 strings
= new wxString
[strList
.GetCount()];
50 int count
= strList
.GetCount();
51 for( int i
= 0; i
< count
; i
++ )
52 strings
[i
]=strList
[i
];
55 XRC_MAKE_INSTANCE(control
, wxRadioBox
)
57 control
->Create(m_parentAsWindow
,
59 GetText(wxT("label")),
60 GetPosition(), GetSize(),
63 GetLong(wxT("dimension"), 1),
69 control
->SetSelection(selection
);
75 strList
.Clear(); // dump the strings
82 // handle <item selected="boolean">Label</item>
85 wxString str
= GetNodeContent(m_node
);
86 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
87 str
= wxGetTranslation(str
);
95 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
97 return (IsOfClass(node
, wxT("wxRadioBox")) ||
98 (m_insideBox
&& node
->GetName() == wxT("item")));
101 #endif // wxUSE_XRC && wxUSE_RADIOBOX