]>
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")));
51 if ( !labels
.empty() )
53 strings
= new wxString
[labels
.size()];
54 const unsigned count
= labels
.size();
55 for( unsigned i
= 0; i
< count
; i
++ )
56 strings
[i
] = labels
[i
];
63 XRC_MAKE_INSTANCE(control
, wxRadioBox
)
65 control
->Create(m_parentAsWindow
,
67 GetText(wxT("label")),
68 GetPosition(), GetSize(),
71 GetLong(wxT("dimension"), 1),
79 control
->SetSelection(selection
);
83 const unsigned count
= labels
.size();
84 for( unsigned i
= 0; i
< count
; i
++ )
87 if ( !tooltips
[i
].empty() )
88 control
->SetItemToolTip(i
, tooltips
[i
]);
89 #endif // wxUSE_TOOLTIPS
91 if ( helptextSpecified
[i
] )
92 control
->SetItemHelpText(i
, helptexts
[i
]);
96 labels
.clear(); // dump the strings
98 tooltips
.clear(); // dump the tooltips
100 helptexts
.clear(); // dump the helptexts
101 helptextSpecified
.clear();
105 else // inside the radiobox element
107 // we handle handle <item tooltip="..." helptext="...">Label</item> constructs here
109 wxString str
= GetNodeContent(m_node
);
112 m_node
->GetPropVal(wxT("tooltip"), &tooltip
);
115 bool hasHelptext
= m_node
->GetPropVal(wxT("helptext"), &helptext
);
117 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
119 str
= wxGetTranslation(str
, m_resource
->GetDomain());
120 if ( !tooltip
.empty() )
121 tooltip
= wxGetTranslation(tooltip
, m_resource
->GetDomain());
123 helptext
= wxGetTranslation(helptext
, m_resource
->GetDomain());
126 labels
.push_back(str
);
127 tooltips
.push_back(tooltip
);
128 helptexts
.push_back(helptext
);
129 helptextSpecified
.push_back(hasHelptext
);
136 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
138 return (IsOfClass(node
, wxT("wxRadioBox")) ||
139 (m_insideBox
&& node
->GetName() == wxT("item")));
142 #endif // wxUSE_XRC && wxUSE_RADIOBOX