]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_chckl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_chckl.cpp
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 // 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"
27 #include "wx/checklst.h"
29 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler
, wxXmlResourceHandler
)
31 wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
32 : wxXmlResourceHandler(), m_insideBox(false)
35 XRC_ADD_STYLE(wxLB_SINGLE
);
36 XRC_ADD_STYLE(wxLB_MULTIPLE
);
37 XRC_ADD_STYLE(wxLB_EXTENDED
);
38 XRC_ADD_STYLE(wxLB_HSCROLL
);
39 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
40 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
41 XRC_ADD_STYLE(wxLB_SORT
);
46 wxObject
*wxCheckListBoxXmlHandler::DoCreateResource()
48 if (m_class
== wxT("wxCheckListBox")
49 #if WXWIN_COMPATIBILITY_2_4
50 || m_class
== wxT("wxCheckList")
54 #if WXWIN_COMPATIBILITY_2_4
55 if (m_class
== wxT("wxCheckList"))
56 wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
58 // need to build the list of strings from children
60 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
61 wxString
*strings
= (wxString
*) NULL
;
62 if (strList
.GetCount() > 0)
64 strings
= new wxString
[strList
.GetCount()];
65 int count
= strList
.GetCount();
66 for(int i
= 0; i
< count
; i
++)
67 strings
[i
] = strList
[i
];
70 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
72 control
->Create(m_parentAsWindow
,
74 GetPosition(), GetSize(),
81 // step through children myself (again.)
82 wxXmlNode
*n
= GetParamNode(wxT("content"));
83 if (n
) n
= n
->GetChildren();
87 if (n
->GetType() != wxXML_ELEMENT_NODE
||
88 n
->GetName() != wxT("item"))
89 { n
= n
->GetNext(); continue; }
91 // checking boolean is a bit ugly here (see GetBool() )
92 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
94 if (v
&& v
== wxT("1"))
95 control
->Check( i
, true );
101 SetupWindow(control
);
105 strList
.Clear(); // dump the strings
111 // on the inside now.
112 // handle <item checked="boolean">Label</item>
115 wxString str
= GetNodeContent(m_node
);
116 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
117 str
= wxGetTranslation(str
);
123 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
125 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
126 #if WXWIN_COMPATIBILITY_2_4
127 IsOfClass(node
, wxT("wxCheckList")) ||
129 (m_insideBox
&& node
->GetName() == wxT("item")));
132 #endif // wxUSE_XRC && wxUSE_CHECKLISTBOX