]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_chckl.cpp
Invalid conversion compile error fix (GTK+ 2.12.9)
[wxWidgets.git] / src / xrc / xh_chckl.cpp
CommitLineData
78d14f80 1/////////////////////////////////////////////////////////////////////////////
88a7a4e1 2// Name: src/xrc/xh_chckl.cpp
dd47af27 3// Purpose: XRC resource for wxCheckListBox
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
88a7a4e1 18#if wxUSE_XRC && wxUSE_CHECKLISTBOX
3037523a 19
78d14f80 20#include "wx/xrc/xh_chckl.h"
88a7a4e1
WS
21
22#ifndef WX_PRECOMP
23 #include "wx/intl.h"
e4db172a 24 #include "wx/log.h"
e6e83933 25 #include "wx/checklst.h"
88a7a4e1
WS
26#endif
27
df27f1dc
VZ
28#include "wx/xml/xml.h"
29
56572188 30IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler, wxXmlResourceHandler)
854e189f 31
f80ea77b
WS
32wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
33: wxXmlResourceHandler(), m_insideBox(false)
78d14f80 34{
6ea1280c
VS
35 // wxListBox styles:
36 XRC_ADD_STYLE(wxLB_SINGLE);
37 XRC_ADD_STYLE(wxLB_MULTIPLE);
38 XRC_ADD_STYLE(wxLB_EXTENDED);
39 XRC_ADD_STYLE(wxLB_HSCROLL);
40 XRC_ADD_STYLE(wxLB_ALWAYS_SB);
41 XRC_ADD_STYLE(wxLB_NEEDED_SB);
42 XRC_ADD_STYLE(wxLB_SORT);
88a7a4e1 43
78d14f80
VS
44 AddWindowStyles();
45}
46
56572188 47wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
f80ea77b 48{
c1dc9f83 49 if (m_class == wxT("wxCheckListBox"))
78d14f80
VS
50 {
51 // need to build the list of strings from children
f80ea77b 52 m_insideBox = true;
78d14f80 53 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
78d14f80 54
544fee32 55 XRC_MAKE_INSTANCE(control, wxCheckListBox)
f2588180
VS
56
57 control->Create(m_parentAsWindow,
58 GetID(),
59 GetPosition(), GetSize(),
187d8152 60 strList,
f2588180
VS
61 GetStyle(),
62 wxDefaultValidator,
63 GetName());
78d14f80
VS
64
65 // step through children myself (again.)
66 wxXmlNode *n = GetParamNode(wxT("content"));
187d8152
VZ
67 if (n)
68 n = n->GetChildren();
78d14f80
VS
69 int i = 0;
70 while (n)
71 {
72 if (n->GetType() != wxXML_ELEMENT_NODE ||
73 n->GetName() != wxT("item"))
74 { n = n->GetNext(); continue; }
75
76 // checking boolean is a bit ugly here (see GetBool() )
288b6107 77 wxString v = n->GetAttribute(wxT("checked"), wxEmptyString);
78d14f80 78 v.MakeLower();
11aac4ba 79 if (v == wxT("1"))
f80ea77b 80 control->Check( i, true );
78d14f80 81
f80ea77b 82 i++;
78d14f80
VS
83 n = n->GetNext();
84 }
f80ea77b 85
78d14f80
VS
86 SetupWindow(control);
87
f80ea77b 88 strList.Clear(); // dump the strings
78d14f80
VS
89
90 return control;
91 }
92 else
93 {
94 // on the inside now.
95 // handle <item checked="boolean">Label</item>
96
97 // add to the list
74c107ba
VS
98 wxString str = GetNodeContent(m_node);
99 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
d4a724d4 100 str = wxGetTranslation(str, m_resource->GetDomain());
74c107ba 101 strList.Add(str);
78d14f80
VS
102 return NULL;
103 }
78d14f80
VS
104}
105
56572188 106bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode *node)
78d14f80 107{
56572188 108 return (IsOfClass(node, wxT("wxCheckListBox")) ||
544fee32 109 (m_insideBox && node->GetName() == wxT("item")));
78d14f80
VS
110}
111
88a7a4e1 112#endif // wxUSE_XRC && wxUSE_CHECKLISTBOX