]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_chckl.cpp
suppress new lines in the details pane
[wxWidgets.git] / src / xrc / xh_chckl.cpp
CommitLineData
78d14f80
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: xh_chckl.cpp
b5d6954b 3// Purpose: XRC resource for wxCheckList
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#ifdef __GNUG__
12#pragma implementation "xh_chckl.h"
13#endif
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
5e7ea8eb 22#if wxUSE_OWNER_DRAWN || !defined(__WXMSW__)
3037523a 23
78d14f80
VS
24#include "wx/xrc/xh_chckl.h"
25#include "wx/checklst.h"
02df3799 26#include "wx/intl.h"
56572188 27#include "wx/log.h"
78d14f80 28
56572188 29IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler, wxXmlResourceHandler)
854e189f 30
f80ea77b
WS
31wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
32: wxXmlResourceHandler(), m_insideBox(false)
78d14f80
VS
33{
34 // no styles
35 AddWindowStyles();
36}
37
56572188 38wxObject *wxCheckListBoxXmlHandler::DoCreateResource()
f80ea77b 39{
56572188
VS
40 if (m_class == wxT("wxCheckListBox")
41#if WXWIN_COMPATIBILITY_2_4
42 || m_class == wxT("wxCheckList")
43#endif
44 )
78d14f80 45 {
56572188
VS
46#if WXWIN_COMPATIBILITY_2_4
47 if (m_class == wxT("wxCheckList"))
48 wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
49#endif
78d14f80 50 // need to build the list of strings from children
f80ea77b 51 m_insideBox = true;
78d14f80
VS
52 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
53 wxString *strings = (wxString *) NULL;
544fee32 54 if (strList.GetCount() > 0)
78d14f80
VS
55 {
56 strings = new wxString[strList.GetCount()];
57 int count = strList.GetCount();
544fee32
VS
58 for(int i = 0; i < count; i++)
59 strings[i] = strList[i];
78d14f80
VS
60 }
61
544fee32 62 XRC_MAKE_INSTANCE(control, wxCheckListBox)
f2588180
VS
63
64 control->Create(m_parentAsWindow,
65 GetID(),
66 GetPosition(), GetSize(),
67 strList.GetCount(),
68 strings,
69 GetStyle(),
70 wxDefaultValidator,
71 GetName());
78d14f80
VS
72
73 // step through children myself (again.)
74 wxXmlNode *n = GetParamNode(wxT("content"));
75 if (n) n = n->GetChildren();
76 int i = 0;
77 while (n)
78 {
79 if (n->GetType() != wxXML_ELEMENT_NODE ||
80 n->GetName() != wxT("item"))
81 { n = n->GetNext(); continue; }
82
83 // checking boolean is a bit ugly here (see GetBool() )
84 wxString v = n->GetPropVal(wxT("checked"), wxEmptyString);
85 v.MakeLower();
86 if (v && v == wxT("1"))
f80ea77b 87 control->Check( i, true );
78d14f80 88
f80ea77b 89 i++;
78d14f80
VS
90 n = n->GetNext();
91 }
f80ea77b 92
78d14f80
VS
93 SetupWindow(control);
94
544fee32
VS
95 if (strings != NULL)
96 delete[] strings;
f80ea77b 97 strList.Clear(); // dump the strings
78d14f80
VS
98
99 return control;
100 }
101 else
102 {
103 // on the inside now.
104 // handle <item checked="boolean">Label</item>
105
106 // add to the list
74c107ba
VS
107 wxString str = GetNodeContent(m_node);
108 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
109 str = wxGetTranslation(str);
110 strList.Add(str);
78d14f80
VS
111 return NULL;
112 }
78d14f80
VS
113}
114
56572188 115bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode *node)
78d14f80 116{
56572188
VS
117 return (IsOfClass(node, wxT("wxCheckListBox")) ||
118#if WXWIN_COMPATIBILITY_2_4
119 IsOfClass(node, wxT("wxCheckList")) ||
120#endif
544fee32 121 (m_insideBox && node->GetName() == wxT("item")));
78d14f80
VS
122}
123
9a8ffadd 124#endif
84969af7 125