Applied patch [ 882493 ] Added XRC support for wxStatusBar
[wxWidgets.git] / src / xrc / xh_statbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xh_statbar.cpp
3 // Purpose: XRC resource for wxStatusBar
4 // Author: Brian Ravnsgaard Riis
5 // Created: 2004/01/21
6 // RCS-ID:
7 // Copyright: (c) 2004 Brian Ravnsgaard Riis
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "xh_statbar.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
22 #include "wx/frame.h"
23 #include "wx/string.h"
24
25 #if wxUSE_STATUSBAR
26
27 #include "wx/xrc/xh_statbar.h"
28 #include "wx/statusbr.h"
29
30 wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
31 wxXmlResourceHandler()
32 {
33 XRC_ADD_STYLE(wxST_SIZEGRIP);
34 AddWindowStyles();
35 }
36
37 wxObject *wxStatusBarXmlHandler::DoCreateResource()
38 {
39 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
40
41 statbar->Create(m_parentAsWindow,
42 GetID(),
43 GetStyle(),
44 GetName());
45
46 int fields = GetLong(wxT("fields"), 1);
47 wxString widths = GetParamValue(wxT("widths"));
48
49 if(fields > 1)
50 {
51 int *width = new int[fields];
52
53 for (unsigned int i = 0; i < fields; ++i)
54 {
55 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
56 if(widths.Find(wxT(',')))
57 widths.Remove(0, widths.Find(wxT(',')) + 1);
58 }
59 statbar->SetFieldsCount(fields, width);
60 delete[] width;
61 }
62
63 if (m_parentAsWindow)
64 {
65 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
66 if (parentFrame)
67 parentFrame->SetStatusBar(statbar);
68 }
69
70 return statbar;
71 }
72
73 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
74 {
75 return IsOfClass(node, wxT("wxStatusBar"));
76 }
77
78 #endif
79