]>
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"
24 #include "wx/radiobox.h"
27 #include "wx/xml/xml.h"
29 IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler
, wxXmlResourceHandler
)
31 wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
32 : wxXmlResourceHandler(), m_insideBox(false)
34 XRC_ADD_STYLE(wxRA_SPECIFY_COLS
);
35 XRC_ADD_STYLE(wxRA_HORIZONTAL
);
36 XRC_ADD_STYLE(wxRA_SPECIFY_ROWS
);
37 XRC_ADD_STYLE(wxRA_VERTICAL
);
41 wxObject
*wxRadioBoxXmlHandler::DoCreateResource()
43 if ( m_class
== wxT("wxRadioBox"))
46 long selection
= GetLong( wxT("selection"), -1 );
48 // need to build the list of strings from children
50 CreateChildrenPrivately( NULL
, GetParamNode(wxT("content")));
52 XRC_MAKE_INSTANCE(control
, wxRadioBox
)
54 control
->Create(m_parentAsWindow
,
56 GetText(wxT("label")),
57 GetPosition(), GetSize(),
59 GetLong(wxT("dimension"), 1),
65 control
->SetSelection(selection
);
69 const unsigned count
= m_labels
.size();
70 for( unsigned i
= 0; i
< count
; i
++ )
73 if ( !m_tooltips
[i
].empty() )
74 control
->SetItemToolTip(i
, m_tooltips
[i
]);
75 #endif // wxUSE_TOOLTIPS
77 if ( m_helptextSpecified
[i
] )
78 control
->SetItemHelpText(i
, m_helptexts
[i
]);
82 control
->Show(i
, false);
83 if ( !m_isEnabled
[i
] )
84 control
->Enable(i
, false);
88 // forget information about the items of this radiobox, we should start
89 // afresh for the next one
94 #endif // wxUSE_TOOLTIPS
98 m_helptextSpecified
.clear();
106 else // inside the radiobox element
108 // we handle handle <item>Label</item> constructs here, and the item
109 // tag can have tooltip, helptext, enabled and hidden attributes
111 wxString label
= GetNodeContent(m_node
);
114 m_node
->GetAttribute(wxT("tooltip"), &tooltip
);
117 bool hasHelptext
= m_node
->GetAttribute(wxT("helptext"), &helptext
);
119 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
121 label
= wxGetTranslation(label
, m_resource
->GetDomain());
122 if ( !tooltip
.empty() )
123 tooltip
= wxGetTranslation(tooltip
, m_resource
->GetDomain());
125 helptext
= wxGetTranslation(helptext
, m_resource
->GetDomain());
128 m_labels
.push_back(label
);
130 m_tooltips
.push_back(tooltip
);
131 #endif // wxUSE_TOOLTIPS
133 m_helptexts
.push_back(helptext
);
134 m_helptextSpecified
.push_back(hasHelptext
);
136 m_isEnabled
.push_back(GetBoolAttr("enabled", 1));
137 m_isShown
.push_back(!GetBoolAttr("hidden", 0));
144 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
146 return (IsOfClass(node
, wxT("wxRadioBox")) ||
147 (m_insideBox
&& node
->GetName() == wxT("item")));
150 #endif // wxUSE_XRC && wxUSE_RADIOBOX