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