]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_radbx.cpp
edbbbf6a492d4cf39d397bd9ff5e4bb2e1ccb5c6
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
);
84 const unsigned count
= labels
.size();
85 for( unsigned i
= 0; i
< count
; i
++ )
87 if ( !tooltips
[i
].empty() )
88 control
->SetItemToolTip(i
, tooltips
[i
]);
90 #endif // wxUSE_TOOLTIPS
92 labels
.clear(); // dump the strings
93 tooltips
.clear(); // dump the tooltips
97 else // inside the radiobox element
99 // we handle <item tooltip="...">Label</item> constructs here
101 wxString str
= GetNodeContent(m_node
);
103 m_node
->GetPropVal(wxT("tooltip"), &tooltip
);
105 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
107 str
= wxGetTranslation(str
);
108 if ( !tooltip
.empty() )
109 tooltip
= wxGetTranslation(tooltip
);
112 labels
.push_back(str
);
113 tooltips
.push_back(tooltip
);
120 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode
*node
)
122 return (IsOfClass(node
, wxT("wxRadioBox")) ||
123 (m_insideBox
&& node
->GetName() == wxT("item")));
126 #endif // wxUSE_XRC && wxUSE_RADIOBOX