]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_radbx.cpp
Added wxRichTextTableBlock class to help with table UI operations
[wxWidgets.git] / src / xrc / xh_radbx.cpp
CommitLineData
78d14f80 1/////////////////////////////////////////////////////////////////////////////
88a7a4e1 2// Name: src/xrc/xh_radbx.cpp
b5d6954b 3// Purpose: XRC resource for wxRadioBox
78d14f80
VS
4// Author: Bob Mitchell
5// Created: 2000/03/21
78d14f80
VS
6// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
f80ea77b 9
78d14f80
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
621be1ec 17#if wxUSE_XRC && wxUSE_RADIOBOX
a1e4ec87 18
78d14f80 19#include "wx/xrc/xh_radbx.h"
88a7a4e1
WS
20
21#ifndef WX_PRECOMP
22 #include "wx/intl.h"
cc11cc69 23 #include "wx/radiobox.h"
88a7a4e1
WS
24#endif
25
df27f1dc
VZ
26#include "wx/xml/xml.h"
27
854e189f
VS
28IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
29
f80ea77b
WS
30wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
31: wxXmlResourceHandler(), m_insideBox(false)
78d14f80 32{
544fee32
VS
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);
78d14f80
VS
37 AddWindowStyles();
38}
39
40wxObject *wxRadioBoxXmlHandler::DoCreateResource()
f80ea77b 41{
d64ad2c7 42 if ( m_class == wxT("wxRadioBox"))
78d14f80
VS
43 {
44 // find the selection
45 long selection = GetLong( wxT("selection"), -1 );
46
47 // need to build the list of strings from children
f80ea77b 48 m_insideBox = true;
78d14f80 49 CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
d64ad2c7 50
544fee32 51 XRC_MAKE_INSTANCE(control, wxRadioBox)
f2588180
VS
52
53 control->Create(m_parentAsWindow,
54 GetID(),
55 GetText(wxT("label")),
56 GetPosition(), GetSize(),
8758875e 57 m_labels,
f2588180
VS
58 GetLong(wxT("dimension"), 1),
59 GetStyle(),
60 wxDefaultValidator,
61 GetName());
78d14f80 62
544fee32
VS
63 if (selection != -1)
64 control->SetSelection(selection);
78d14f80
VS
65
66 SetupWindow(control);
67
8758875e 68 const unsigned count = m_labels.size();
d64ad2c7
VZ
69 for( unsigned i = 0; i < count; i++ )
70 {
dc26eeb3 71#if wxUSE_TOOLTIPS
8758875e
VZ
72 if ( !m_tooltips[i].empty() )
73 control->SetItemToolTip(i, m_tooltips[i]);
7577ac4b 74#endif // wxUSE_TOOLTIPS
dc26eeb3 75#if wxUSE_HELP
8758875e
VZ
76 if ( m_helptextSpecified[i] )
77 control->SetItemHelpText(i, m_helptexts[i]);
dc26eeb3 78#endif // wxUSE_HELP
8758875e
VZ
79
80 if ( !m_isShown[i] )
81 control->Show(i, false);
82 if ( !m_isEnabled[i] )
83 control->Enable(i, false);
dc26eeb3 84 }
d64ad2c7 85
dc26eeb3 86
8758875e
VZ
87 // forget information about the items of this radiobox, we should start
88 // afresh for the next one
89 m_labels.clear();
78d14f80 90
8758875e
VZ
91#if wxUSE_TOOLTIPS
92 m_tooltips.clear();
93#endif // wxUSE_TOOLTIPS
94
95#if wxUSE_HELP
96 m_helptexts.clear();
97 m_helptextSpecified.clear();
98#endif // wxUSE_HELP
99
100 m_isShown.clear();
101 m_isEnabled.clear();
dc26eeb3 102
78d14f80
VS
103 return control;
104 }
d64ad2c7 105 else // inside the radiobox element
78d14f80 106 {
8758875e
VZ
107 // we handle handle <item>Label</item> constructs here, and the item
108 // tag can have tooltip, helptext, enabled and hidden attributes
78d14f80 109
8758875e 110 wxString label = GetNodeContent(m_node);
dc26eeb3 111
d64ad2c7 112 wxString tooltip;
288b6107 113 m_node->GetAttribute(wxT("tooltip"), &tooltip);
d64ad2c7 114
dc26eeb3 115 wxString helptext;
288b6107 116 bool hasHelptext = m_node->GetAttribute(wxT("helptext"), &helptext);
dc26eeb3 117
74c107ba 118 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
d64ad2c7 119 {
8758875e 120 label = wxGetTranslation(label, m_resource->GetDomain());
d64ad2c7 121 if ( !tooltip.empty() )
d4a724d4 122 tooltip = wxGetTranslation(tooltip, m_resource->GetDomain());
dc26eeb3 123 if ( hasHelptext )
d4a724d4 124 helptext = wxGetTranslation(helptext, m_resource->GetDomain());
d64ad2c7
VZ
125 }
126
8758875e
VZ
127 m_labels.push_back(label);
128#if wxUSE_TOOLTIPS
129 m_tooltips.push_back(tooltip);
130#endif // wxUSE_TOOLTIPS
131#if wxUSE_HELP
132 m_helptexts.push_back(helptext);
133 m_helptextSpecified.push_back(hasHelptext);
134#endif // wxUSE_HELP
135 m_isEnabled.push_back(GetBoolAttr("enabled", 1));
136 m_isShown.push_back(!GetBoolAttr("hidden", 0));
78d14f80
VS
137
138 return NULL;
139 }
140
141}
142
78d14f80
VS
143bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node)
144{
145 return (IsOfClass(node, wxT("wxRadioBox")) ||
544fee32 146 (m_insideBox && node->GetName() == wxT("item")));
78d14f80
VS
147}
148
a1e4ec87 149#endif // wxUSE_XRC && wxUSE_RADIOBOX