]>
Commit | Line | Data |
---|---|---|
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 | ///////////////////////////////////////////////////////////////////////////// | |
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 VS |
20 | #include "wx/xrc/xh_radbx.h" |
21 | #include "wx/radiobox.h" | |
02df3799 | 22 | #include "wx/intl.h" |
78d14f80 | 23 | |
854e189f VS |
24 | IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler) |
25 | ||
f80ea77b WS |
26 | wxRadioBoxXmlHandler::wxRadioBoxXmlHandler() |
27 | : wxXmlResourceHandler(), m_insideBox(false) | |
78d14f80 | 28 | { |
544fee32 VS |
29 | XRC_ADD_STYLE(wxRA_SPECIFY_COLS); |
30 | XRC_ADD_STYLE(wxRA_HORIZONTAL); | |
31 | XRC_ADD_STYLE(wxRA_SPECIFY_ROWS); | |
32 | XRC_ADD_STYLE(wxRA_VERTICAL); | |
78d14f80 VS |
33 | AddWindowStyles(); |
34 | } | |
35 | ||
36 | wxObject *wxRadioBoxXmlHandler::DoCreateResource() | |
f80ea77b | 37 | { |
78d14f80 VS |
38 | if( m_class == wxT("wxRadioBox")) |
39 | { | |
40 | // find the selection | |
41 | long selection = GetLong( wxT("selection"), -1 ); | |
42 | ||
43 | // need to build the list of strings from children | |
f80ea77b | 44 | m_insideBox = true; |
78d14f80 VS |
45 | CreateChildrenPrivately( NULL, GetParamNode(wxT("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 | ||
544fee32 | 55 | XRC_MAKE_INSTANCE(control, wxRadioBox) |
f2588180 VS |
56 | |
57 | control->Create(m_parentAsWindow, | |
58 | GetID(), | |
59 | GetText(wxT("label")), | |
60 | GetPosition(), GetSize(), | |
61 | strList.GetCount(), | |
62 | strings, | |
63 | GetLong(wxT("dimension"), 1), | |
64 | GetStyle(), | |
65 | wxDefaultValidator, | |
66 | GetName()); | |
78d14f80 | 67 | |
544fee32 VS |
68 | if (selection != -1) |
69 | control->SetSelection(selection); | |
78d14f80 VS |
70 | |
71 | SetupWindow(control); | |
72 | ||
544fee32 VS |
73 | if (strings != NULL) |
74 | delete[] strings; | |
f80ea77b | 75 | strList.Clear(); // dump the strings |
78d14f80 VS |
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 | |
74c107ba VS |
85 | wxString str = GetNodeContent(m_node); |
86 | if (m_resource->GetFlags() & wxXRC_USE_LOCALE) | |
87 | str = wxGetTranslation(str); | |
88 | strList.Add(str); | |
78d14f80 VS |
89 | |
90 | return NULL; | |
91 | } | |
92 | ||
93 | } | |
94 | ||
78d14f80 VS |
95 | bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node) |
96 | { | |
97 | return (IsOfClass(node, wxT("wxRadioBox")) || | |
544fee32 | 98 | (m_insideBox && node->GetName() == wxT("item"))); |
78d14f80 VS |
99 | } |
100 | ||
a1e4ec87 | 101 | #endif // wxUSE_XRC && wxUSE_RADIOBOX |