]>
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
);
85 const unsigned count
= labels
.size();
86 for( unsigned i
= 0; i
< count
; i
++ )
88 if ( !tooltips
[i
].empty() )
89 control
->SetItemToolTip(i
, tooltips
[i
]);
91 #endif // wxUSE_TOOLTIPS
93 labels
.clear(); // dump the strings
94 tooltips
.clear(); // dump the tooltips
98 else // inside the radiobox element
100 // we handle <item tooltip="...">Label</item> constructs here
102 wxString str
= GetNodeContent(m_node
);
104 m_node
->GetPropVal(wxT("tooltip"), &tooltip
);
106 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
108 str
= wxGetTranslation(str
);
109 if ( !tooltip
.empty() )
110 tooltip
= wxGetTranslation(tooltip
);
113 labels
.push_back(str
);
114 tooltips
.push_back(tooltip
);
121 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
123 return (IsOfClass(node
, wxT("wxRadioBox")) ||
124 (m_insideBox
&& node
->GetName() == wxT("item")));
127 #endif // wxUSE_XRC && wxUSE_RADIOBOX