]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_chckl.cpp
f4e354ec5e3868aaa4723a69832c03a452d08db3
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_chckl.cpp
3 // Purpose: XRC resource for wxCheckListBox
4 // Author: Bob Mitchell
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_CHECKLISTBOX
20 #include "wx/xrc/xh_chckl.h"
25 #include "wx/checklst.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler
, wxXmlResourceHandler
)
30 wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
31 : wxXmlResourceHandler(), m_insideBox(false)
34 XRC_ADD_STYLE(wxLB_SINGLE
);
35 XRC_ADD_STYLE(wxLB_MULTIPLE
);
36 XRC_ADD_STYLE(wxLB_EXTENDED
);
37 XRC_ADD_STYLE(wxLB_HSCROLL
);
38 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
39 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
40 XRC_ADD_STYLE(wxLB_SORT
);
45 wxObject
*wxCheckListBoxXmlHandler::DoCreateResource()
47 if (m_class
== wxT("wxCheckListBox")
48 #if WXWIN_COMPATIBILITY_2_4
49 || m_class
== wxT("wxCheckList")
53 #if WXWIN_COMPATIBILITY_2_4
54 if (m_class
== wxT("wxCheckList"))
55 wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
57 // need to build the list of strings from children
59 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
60 wxString
*strings
= (wxString
*) NULL
;
61 if (strList
.GetCount() > 0)
63 strings
= new wxString
[strList
.GetCount()];
64 int count
= strList
.GetCount();
65 for(int i
= 0; i
< count
; i
++)
66 strings
[i
] = strList
[i
];
69 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
71 control
->Create(m_parentAsWindow
,
73 GetPosition(), GetSize(),
80 // step through children myself (again.)
81 wxXmlNode
*n
= GetParamNode(wxT("content"));
82 if (n
) n
= n
->GetChildren();
86 if (n
->GetType() != wxXML_ELEMENT_NODE
||
87 n
->GetName() != wxT("item"))
88 { n
= n
->GetNext(); continue; }
90 // checking boolean is a bit ugly here (see GetBool() )
91 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
93 if (v
&& v
== wxT("1"))
94 control
->Check( i
, true );
100 SetupWindow(control
);
104 strList
.Clear(); // dump the strings
110 // on the inside now.
111 // handle <item checked="boolean">Label</item>
114 wxString str
= GetNodeContent(m_node
);
115 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
116 str
= wxGetTranslation(str
, m_resource
->GetDomain());
122 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
124 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
125 #if WXWIN_COMPATIBILITY_2_4
126 IsOfClass(node
, wxT("wxCheckList")) ||
128 (m_insideBox
&& node
->GetName() == wxT("item")));
131 #endif // wxUSE_XRC && wxUSE_CHECKLISTBOX