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