]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_chckl.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC resource for wxCheckList
4 // Author: Bob Mitchell
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
12 #pragma implementation "xh_chckl.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
24 #if wxUSE_CHECKLISTBOX
26 #include "wx/xrc/xh_chckl.h"
27 #include "wx/checklst.h"
31 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler
, wxXmlResourceHandler
)
33 wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
34 : wxXmlResourceHandler(), m_insideBox(false)
37 XRC_ADD_STYLE(wxLB_SINGLE
);
38 XRC_ADD_STYLE(wxLB_MULTIPLE
);
39 XRC_ADD_STYLE(wxLB_EXTENDED
);
40 XRC_ADD_STYLE(wxLB_HSCROLL
);
41 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
42 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
43 XRC_ADD_STYLE(wxLB_SORT
);
48 wxObject
*wxCheckListBoxXmlHandler::DoCreateResource()
50 if (m_class
== wxT("wxCheckListBox")
51 #if WXWIN_COMPATIBILITY_2_4
52 || m_class
== wxT("wxCheckList")
56 #if WXWIN_COMPATIBILITY_2_4
57 if (m_class
== wxT("wxCheckList"))
58 wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
60 // need to build the list of strings from children
62 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
63 wxString
*strings
= (wxString
*) NULL
;
64 if (strList
.GetCount() > 0)
66 strings
= new wxString
[strList
.GetCount()];
67 int count
= strList
.GetCount();
68 for(int i
= 0; i
< count
; i
++)
69 strings
[i
] = strList
[i
];
72 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
74 control
->Create(m_parentAsWindow
,
76 GetPosition(), GetSize(),
83 // step through children myself (again.)
84 wxXmlNode
*n
= GetParamNode(wxT("content"));
85 if (n
) n
= n
->GetChildren();
89 if (n
->GetType() != wxXML_ELEMENT_NODE
||
90 n
->GetName() != wxT("item"))
91 { n
= n
->GetNext(); continue; }
93 // checking boolean is a bit ugly here (see GetBool() )
94 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
96 if (v
&& v
== wxT("1"))
97 control
->Check( i
, true );
103 SetupWindow(control
);
107 strList
.Clear(); // dump the strings
113 // on the inside now.
114 // handle <item checked="boolean">Label</item>
117 wxString str
= GetNodeContent(m_node
);
118 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
119 str
= wxGetTranslation(str
);
125 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
127 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
128 #if WXWIN_COMPATIBILITY_2_4
129 IsOfClass(node
, wxT("wxCheckList")) ||
131 (m_insideBox
&& node
->GetName() == wxT("item")));
134 #endif // wxUSE_CHECKLISTBOX