]>
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
6 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_XRC && wxUSE_RADIOBOX
19 #include "wx/xrc/xh_radbx.h"
23 #include "wx/radiobox.h"
26 #include "wx/xml/xml.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")));
51 XRC_MAKE_INSTANCE(control
, wxRadioBox
)
53 control
->Create(m_parentAsWindow
,
55 GetText(wxT("label")),
56 GetPosition(), GetSize(),
58 GetLong(wxT("dimension"), 1),
64 control
->SetSelection(selection
);
68 const unsigned count
= m_labels
.size();
69 for( unsigned i
= 0; i
< count
; i
++ )
72 if ( !m_tooltips
[i
].empty() )
73 control
->SetItemToolTip(i
, m_tooltips
[i
]);
74 #endif // wxUSE_TOOLTIPS
76 if ( m_helptextSpecified
[i
] )
77 control
->SetItemHelpText(i
, m_helptexts
[i
]);
81 control
->Show(i
, false);
82 if ( !m_isEnabled
[i
] )
83 control
->Enable(i
, false);
87 // forget information about the items of this radiobox, we should start
88 // afresh for the next one
93 #endif // wxUSE_TOOLTIPS
97 m_helptextSpecified
.clear();
105 else // inside the radiobox element
107 // we handle handle <item>Label</item> constructs here, and the item
108 // tag can have tooltip, helptext, enabled and hidden attributes
110 wxString label
= GetNodeContent(m_node
);
113 m_node
->GetAttribute(wxT("tooltip"), &tooltip
);
116 bool hasHelptext
= m_node
->GetAttribute(wxT("helptext"), &helptext
);
118 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
120 label
= wxGetTranslation(label
, m_resource
->GetDomain());
121 if ( !tooltip
.empty() )
122 tooltip
= wxGetTranslation(tooltip
, m_resource
->GetDomain());
124 helptext
= wxGetTranslation(helptext
, m_resource
->GetDomain());
127 m_labels
.push_back(label
);
129 m_tooltips
.push_back(tooltip
);
130 #endif // wxUSE_TOOLTIPS
132 m_helptexts
.push_back(helptext
);
133 m_helptextSpecified
.push_back(hasHelptext
);
135 m_isEnabled
.push_back(GetBoolAttr("enabled", 1));
136 m_isShown
.push_back(!GetBoolAttr("hidden", 0));
143 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
145 return (IsOfClass(node
, wxT("wxRadioBox")) ||
146 (m_insideBox
&& node
->GetName() == wxT("item")));
149 #endif // wxUSE_XRC && wxUSE_RADIOBOX