]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_radbx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_radbx.cpp
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"
26 #include "wx/radiobox.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler
, wxXmlResourceHandler
)
30 wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
31 : wxXmlResourceHandler(), m_insideBox(false)
33 XRC_ADD_STYLE(wxRA_SPECIFY_COLS
);
34 XRC_ADD_STYLE(wxRA_HORIZONTAL
);
35 XRC_ADD_STYLE(wxRA_SPECIFY_ROWS
);
36 XRC_ADD_STYLE(wxRA_VERTICAL
);
40 wxObject
*wxRadioBoxXmlHandler::DoCreateResource()
42 if ( m_class
== wxT("wxRadioBox"))
45 long selection
= GetLong( wxT("selection"), -1 );
47 // need to build the list of strings from children
49 CreateChildrenPrivately( NULL
, GetParamNode(wxT("content")));
52 if ( !labels
.empty() )
54 strings
= new wxString
[labels
.size()];
55 const unsigned count
= labels
.size();
56 for( unsigned i
= 0; i
< count
; i
++ )
57 strings
[i
] = labels
[i
];
64 XRC_MAKE_INSTANCE(control
, wxRadioBox
)
66 control
->Create(m_parentAsWindow
,
68 GetText(wxT("label")),
69 GetPosition(), GetSize(),
72 GetLong(wxT("dimension"), 1),
80 control
->SetSelection(selection
);
84 const unsigned count
= labels
.size();
85 for( unsigned i
= 0; i
< count
; i
++ )
87 if ( !tooltips
[i
].empty() )
88 control
->SetItemToolTip(i
, tooltips
[i
]);
91 labels
.clear(); // dump the strings
92 tooltips
.clear(); // dump the tooltips
96 else // inside the radiobox element
98 // we handle <item tooltip="...">Label</item> constructs here
100 wxString str
= GetNodeContent(m_node
);
102 m_node
->GetPropVal(wxT("tooltip"), &tooltip
);
104 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
106 str
= wxGetTranslation(str
);
107 if ( !tooltip
.empty() )
108 tooltip
= wxGetTranslation(tooltip
);
111 labels
.push_back(str
);
112 tooltips
.push_back(tooltip
);
119 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
121 return (IsOfClass(node
, wxT("wxRadioBox")) ||
122 (m_insideBox
&& node
->GetName() == wxT("item")));
125 #endif // wxUSE_XRC && wxUSE_RADIOBOX