]>
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 IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler
, wxXmlResourceHandler
)
29 wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
30 : wxXmlResourceHandler(), m_insideBox(false)
32 XRC_ADD_STYLE(wxRA_SPECIFY_COLS
);
33 XRC_ADD_STYLE(wxRA_HORIZONTAL
);
34 XRC_ADD_STYLE(wxRA_SPECIFY_ROWS
);
35 XRC_ADD_STYLE(wxRA_VERTICAL
);
39 wxObject
*wxRadioBoxXmlHandler::DoCreateResource()
41 if ( m_class
== wxT("wxRadioBox"))
44 long selection
= GetLong( wxT("selection"), -1 );
46 // need to build the list of strings from children
48 CreateChildrenPrivately( NULL
, GetParamNode(wxT("content")));
50 XRC_MAKE_INSTANCE(control
, wxRadioBox
)
52 control
->Create(m_parentAsWindow
,
54 GetText(wxT("label")),
55 GetPosition(), GetSize(),
57 GetLong(wxT("dimension"), 1),
63 control
->SetSelection(selection
);
67 const unsigned count
= m_labels
.size();
68 for( unsigned i
= 0; i
< count
; i
++ )
71 if ( !m_tooltips
[i
].empty() )
72 control
->SetItemToolTip(i
, m_tooltips
[i
]);
73 #endif // wxUSE_TOOLTIPS
75 if ( m_helptextSpecified
[i
] )
76 control
->SetItemHelpText(i
, m_helptexts
[i
]);
80 control
->Show(i
, false);
81 if ( !m_isEnabled
[i
] )
82 control
->Enable(i
, false);
86 // forget information about the items of this radiobox, we should start
87 // afresh for the next one
92 #endif // wxUSE_TOOLTIPS
96 m_helptextSpecified
.clear();
104 else // inside the radiobox element
106 // we handle handle <item>Label</item> constructs here, and the item
107 // tag can have tooltip, helptext, enabled and hidden attributes
109 wxString label
= GetNodeContent(m_node
);
112 m_node
->GetAttribute(wxT("tooltip"), &tooltip
);
115 bool hasHelptext
= m_node
->GetAttribute(wxT("helptext"), &helptext
);
117 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
119 label
= wxGetTranslation(label
, m_resource
->GetDomain());
120 if ( !tooltip
.empty() )
121 tooltip
= wxGetTranslation(tooltip
, m_resource
->GetDomain());
123 helptext
= wxGetTranslation(helptext
, m_resource
->GetDomain());
126 m_labels
.push_back(label
);
128 m_tooltips
.push_back(tooltip
);
129 #endif // wxUSE_TOOLTIPS
131 m_helptexts
.push_back(helptext
);
132 m_helptextSpecified
.push_back(hasHelptext
);
134 m_isEnabled
.push_back(GetBoolAttr("enabled", 1));
135 m_isShown
.push_back(!GetBoolAttr("hidden", 0));
142 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
144 return (IsOfClass(node
, wxT("wxRadioBox")) ||
145 (m_insideBox
&& node
->GetName() == wxT("item")));
148 #endif // wxUSE_XRC && wxUSE_RADIOBOX