]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/xml/xh_radbx.cpp
Add quantize and treebase
[wxWidgets.git] / contrib / src / xml / xh_radbx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xh_radbx.cpp
3 // Purpose: XML resource for wxRadioBox
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/xml/xh_radbx.h"
23 #include "wx/radiobox.h"
24
25 #if wxUSE_RADIOBOX
26
27 wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
28 : wxXmlResourceHandler() , m_InsideBox(FALSE)
29 {
30 ADD_STYLE(wxRA_SPECIFY_COLS);
31 ADD_STYLE(wxRA_HORIZONTAL);
32 ADD_STYLE(wxRA_SPECIFY_ROWS);
33 ADD_STYLE(wxRA_VERTICAL);
34 }
35
36 wxObject *wxRadioBoxXmlHandler::DoCreateResource()
37 {
38 if( m_Node->GetName() == _T("radiobox"))
39 {
40 // find the selection
41 long selection = GetLong( _T("selection"), -1 );
42
43 // need to build the list of strings from children
44 m_InsideBox = TRUE;
45 CreateChildren( NULL, TRUE /* only this handler */, GetParamNode(_T("content")));
46 wxString *strings = (wxString *) NULL;
47 if( strList.GetCount() > 0 )
48 {
49 strings = new wxString[strList.GetCount()];
50 int count = strList.GetCount();
51 for( int i = 0; i < count; i++ )
52 strings[i]=strList[i];
53 }
54
55
56 wxRadioBox *control = new wxRadioBox(m_ParentAsWindow,
57 GetID(),
58 GetText(_T("label")),
59 GetPosition(), GetSize(),
60 strList.GetCount(),
61 strings,
62 GetLong( _T("dimension"), 1 ),
63 GetStyle(),
64 wxDefaultValidator,
65 GetName()
66 );
67
68 if( selection != -1 )
69 control->SetSelection( selection );
70
71 SetupWindow(control);
72
73 if( strings != NULL )
74 delete [] strings;
75 strList.Clear(); // dump the strings
76
77 return control;
78 }
79 else
80 {
81 // on the inside now.
82 // handle <item selected="boolean">Label</item>
83
84 // add to the list
85 strList.Add( GetNodeContent(m_Node) );
86
87 return NULL;
88 }
89
90 }
91
92
93
94 bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node)
95 {
96 return( node->GetName() == _T("radiobox") ||
97 ( m_InsideBox &&
98 node->GetName() == _T("item" ))
99 );
100 }
101
102 #endif