]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_odcombo.cpp
[ 1523907 ] Remove unnecessary wxComboCtrl window style.
[wxWidgets.git] / src / xrc / xh_odcombo.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_odcombo.cpp
3 // Purpose: XRC resource for wxRadioBox
4 // Author: Alex Bligh - Based on src/xrc/xh_combo.cpp
5 // Created: 2006/06/19
6 // RCS-ID: $Id$
7 // Copyright: (c) 2006 Alex Bligh
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_ODCOMBOBOX
19
20 #include "wx/xrc/xh_odcombo.h"
21
22 #ifndef WX_PRECOMP
23 #include "wx/intl.h"
24 #include "wx/textctrl.h"
25 #endif
26
27 #include "wx/odcombo.h"
28
29 IMPLEMENT_DYNAMIC_CLASS(wxOwnerDrawnComboBoxXmlHandler, wxXmlResourceHandler)
30
31 wxOwnerDrawnComboBoxXmlHandler::wxOwnerDrawnComboBoxXmlHandler()
32 :wxXmlResourceHandler()
33 ,m_insideBox(false)
34 {
35 XRC_ADD_STYLE(wxCB_SIMPLE);
36 XRC_ADD_STYLE(wxCB_SORT);
37 XRC_ADD_STYLE(wxCB_READONLY);
38 XRC_ADD_STYLE(wxCB_DROPDOWN);
39 XRC_ADD_STYLE(wxODCB_STD_CONTROL_PAINT);
40 XRC_ADD_STYLE(wxODCB_DCLICK_CYCLES);
41 XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
42 AddWindowStyles();
43 }
44
45 wxObject *wxOwnerDrawnComboBoxXmlHandler::DoCreateResource()
46 {
47 if( m_class == wxT("wxOwnerDrawnComboBox"))
48 {
49 // find the selection
50 long selection = GetLong( wxT("selection"), -1 );
51
52 // need to build the list of strings from children
53 m_insideBox = true;
54 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
55 wxString *strings = (wxString *) NULL;
56 if (strList.GetCount() > 0)
57 {
58 strings = new wxString[strList.GetCount()];
59 int count = strList.GetCount();
60 for (int i = 0; i < count; i++)
61 strings[i]=strList[i];
62 }
63
64 XRC_MAKE_INSTANCE(control, wxOwnerDrawnComboBox)
65
66 control->Create(m_parentAsWindow,
67 GetID(),
68 GetText(wxT("value")),
69 GetPosition(), GetSize(),
70 strList.GetCount(),
71 strings,
72 GetStyle(),
73 wxDefaultValidator,
74 GetName());
75
76 wxSize ButtonSize=GetSize(wxT("buttonsize"));
77
78 if (ButtonSize != wxDefaultSize)
79 control->SetButtonPosition(ButtonSize.GetWidth(), ButtonSize.GetHeight());
80
81 if (selection != -1)
82 control->SetSelection(selection);
83
84 SetupWindow(control);
85
86 if (strings != NULL)
87 delete[] strings;
88 strList.Clear(); // dump the strings
89
90 return control;
91 }
92 else
93 {
94 // on the inside now.
95 // handle <item>Label</item>
96
97 // add to the list
98 wxString str = GetNodeContent(m_node);
99 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
100 str = wxGetTranslation(str);
101 strList.Add(str);
102
103 return NULL;
104 }
105 }
106
107 bool wxOwnerDrawnComboBoxXmlHandler::CanHandle(wxXmlNode *node)
108 {
109 // Avoid GCC bug - this fails on certain GCC 3.x builds for an unknown reason
110 // return (IsOfClass(node, wxT("wxOwnerDrawnComboBox")) ||
111 // (m_insideBox && node->GetName() == wxT("item")));
112
113 bool fOurClass = node->GetPropVal(wxT("class"), wxEmptyString) == wxT("wxOwnerDrawnComboBox");
114 return (fOurClass ||
115 (m_insideBox && node->GetName() == wxT("item")));
116
117 }
118
119 #endif // wxUSE_XRC && wxUSE_ODCOMBOBOX