]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: xh_radbx.cpp | |
3 | // Purpose: XRC 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/xrc/xh_radbx.h" | |
23 | #include "wx/radiobox.h" | |
24 | #include "wx/intl.h" | |
25 | ||
26 | #if wxUSE_RADIOBOX | |
27 | ||
28 | wxRadioBoxXmlHandler::wxRadioBoxXmlHandler() | |
29 | : wxXmlResourceHandler(), m_insideBox(FALSE) | |
30 | { | |
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); | |
35 | AddWindowStyles(); | |
36 | } | |
37 | ||
38 | wxObject *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 | ||
57 | XRC_MAKE_INSTANCE(control, wxRadioBox) | |
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()); | |
69 | ||
70 | if (selection != -1) | |
71 | control->SetSelection(selection); | |
72 | ||
73 | SetupWindow(control); | |
74 | ||
75 | if (strings != NULL) | |
76 | delete[] strings; | |
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 | |
87 | strList.Add(wxGetTranslation(GetNodeContent(m_node))); | |
88 | ||
89 | return NULL; | |
90 | } | |
91 | ||
92 | } | |
93 | ||
94 | bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node) | |
95 | { | |
96 | return (IsOfClass(node, wxT("wxRadioBox")) || | |
97 | (m_insideBox && node->GetName() == wxT("item"))); | |
98 | } | |
99 | ||
100 | #endif |