]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_radbx.cpp
made SetDirectory() work, minor code cleanup (much is left to do)
[wxWidgets.git] / src / xrc / xh_radbx.cpp
CommitLineData
78d14f80
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: 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/////////////////////////////////////////////////////////////////////////////
10
11#ifdef __GNUG__
12#pragma implementation "xh_radbx.h"
13#endif
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
22#include "wx/xrc/xh_radbx.h"
23#include "wx/radiobox.h"
02df3799 24#include "wx/intl.h"
78d14f80
VS
25
26#if wxUSE_RADIOBOX
27
28wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
544fee32 29: wxXmlResourceHandler(), m_insideBox(FALSE)
78d14f80 30{
544fee32
VS
31 XRC_ADD_STYLE(wxRA_SPECIFY_COLS);
32 XRC_ADD_STYLE(wxRA_HORIZONTAL);
33 XRC_ADD_STYLE(wxRA_SPECIFY_ROWS);
34 XRC_ADD_STYLE(wxRA_VERTICAL);
78d14f80
VS
35 AddWindowStyles();
36}
37
38wxObject *wxRadioBoxXmlHandler::DoCreateResource()
39{
40 if( m_class == wxT("wxRadioBox"))
41 {
42 // find the selection
43 long selection = GetLong( wxT("selection"), -1 );
44
45 // need to build the list of strings from children
46 m_insideBox = TRUE;
47 CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
48 wxString *strings = (wxString *) NULL;
49 if( strList.GetCount() > 0 )
50 {
51 strings = new wxString[strList.GetCount()];
52 int count = strList.GetCount();
53 for( int i = 0; i < count; i++ )
54 strings[i]=strList[i];
55 }
56
544fee32 57 XRC_MAKE_INSTANCE(control, wxRadioBox)
f2588180
VS
58
59 control->Create(m_parentAsWindow,
60 GetID(),
61 GetText(wxT("label")),
62 GetPosition(), GetSize(),
63 strList.GetCount(),
64 strings,
65 GetLong(wxT("dimension"), 1),
66 GetStyle(),
67 wxDefaultValidator,
68 GetName());
78d14f80 69
544fee32
VS
70 if (selection != -1)
71 control->SetSelection(selection);
78d14f80
VS
72
73 SetupWindow(control);
74
544fee32
VS
75 if (strings != NULL)
76 delete[] strings;
78d14f80
VS
77 strList.Clear(); // dump the strings
78
79 return control;
80 }
81 else
82 {
83 // on the inside now.
84 // handle <item selected="boolean">Label</item>
85
86 // add to the list
74c107ba
VS
87 wxString str = GetNodeContent(m_node);
88 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
89 str = wxGetTranslation(str);
90 strList.Add(str);
78d14f80
VS
91
92 return NULL;
93 }
94
95}
96
78d14f80
VS
97bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node)
98{
99 return (IsOfClass(node, wxT("wxRadioBox")) ||
544fee32 100 (m_insideBox && node->GetName() == wxT("item")));
78d14f80
VS
101}
102
103#endif