]>
Commit | Line | Data |
---|---|---|
9ebb7cad | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: src/xrc/xh_simplehtmllbox.cpp |
9ebb7cad VZ |
3 | // Purpose: XML resource handler for wxSimpleHtmlListBox |
4 | // Author: Francesco Montorsi | |
5 | // Created: 2006/10/21 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2006 Francesco Montorsi | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // For compilers that support precompilation, includes "wx.h". | |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
18 | #if wxUSE_XRC && wxUSE_HTML | |
19 | ||
20 | #include "wx/xrc/xh_htmllbox.h" | |
21 | ||
22 | #include "wx/htmllbox.h" | |
23 | #include "wx/filesys.h" | |
24 | ||
df27f1dc VZ |
25 | #include "wx/xml/xml.h" |
26 | ||
9ebb7cad VZ |
27 | IMPLEMENT_DYNAMIC_CLASS(wxSimpleHtmlListBoxXmlHandler, wxXmlResourceHandler) |
28 | ||
29 | wxSimpleHtmlListBoxXmlHandler::wxSimpleHtmlListBoxXmlHandler() | |
30 | : wxXmlResourceHandler(), m_insideBox(false) | |
31 | { | |
32 | XRC_ADD_STYLE(wxHLB_DEFAULT_STYLE); | |
33 | XRC_ADD_STYLE(wxHLB_MULTIPLE); | |
34 | AddWindowStyles(); | |
35 | } | |
36 | ||
37 | wxObject *wxSimpleHtmlListBoxXmlHandler::DoCreateResource() | |
38 | { | |
39 | if ( m_class == wxT("wxSimpleHtmlListBox")) | |
40 | { | |
41 | // find the selection | |
42 | long selection = GetLong(wxT("selection"), -1); | |
43 | ||
44 | // need to build the list of strings from children | |
45 | m_insideBox = true; | |
46 | CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); | |
47 | m_insideBox = false; | |
48 | ||
49 | XRC_MAKE_INSTANCE(control, wxSimpleHtmlListBox) | |
50 | ||
51 | control->Create(m_parentAsWindow, | |
52 | GetID(), | |
53 | GetPosition(), GetSize(), | |
54 | strList, | |
9a83f860 | 55 | GetStyle(wxT("style"), wxHLB_DEFAULT_STYLE), |
9ebb7cad VZ |
56 | wxDefaultValidator, |
57 | GetName()); | |
58 | ||
59 | if (selection != -1) | |
60 | control->SetSelection(selection); | |
61 | ||
62 | SetupWindow(control); | |
63 | strList.Clear(); // dump the strings | |
64 | ||
65 | return control; | |
66 | } | |
67 | else | |
68 | { | |
69 | // on the inside now. | |
70 | // handle <item>Label</item> | |
71 | ||
72 | // add to the list | |
73 | wxString str = GetNodeContent(m_node); | |
74 | if (m_resource->GetFlags() & wxXRC_USE_LOCALE) | |
75 | str = wxGetTranslation(str, m_resource->GetDomain()); | |
76 | strList.Add(str); | |
77 | ||
78 | return NULL; | |
79 | } | |
80 | } | |
81 | ||
82 | bool wxSimpleHtmlListBoxXmlHandler::CanHandle(wxXmlNode *node) | |
83 | { | |
84 | return (IsOfClass(node, wxT("wxSimpleHtmlListBox")) || | |
85 | (m_insideBox && node->GetName() == wxT("item"))); | |
86 | } | |
87 | ||
88 | #endif // wxUSE_XRC && wxUSE_HTML |