]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_statbar.cpp
fixed float to short int casting warnings
[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: $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 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
31
32 wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
33 wxXmlResourceHandler()
34 {
35 XRC_ADD_STYLE(wxST_SIZEGRIP);
36 AddWindowStyles();
37 }
38
39 wxObject *wxStatusBarXmlHandler::DoCreateResource()
40 {
41 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
42
43 statbar->Create(m_parentAsWindow,
44 GetID(),
45 GetStyle(),
46 GetName());
47
48 int fields = GetLong(wxT("fields"), 1);
49 wxString widths = GetParamValue(wxT("widths"));
50
51 if (fields > 1 && !widths.IsEmpty())
52 {
53 int *width = new int[fields];
54
55 for (int i = 0; i < fields; ++i)
56 {
57 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
58 if(widths.Find(wxT(',')))
59 widths.Remove(0, widths.Find(wxT(',')) + 1);
60 }
61 statbar->SetFieldsCount(fields, width);
62 delete[] width;
63 }
64 else
65 statbar->SetFieldsCount(fields);
66
67 if (m_parentAsWindow)
68 {
69 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
70 if (parentFrame)
71 parentFrame->SetStatusBar(statbar);
72 }
73
74 return statbar;
75 }
76
77 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
78 {
79 return IsOfClass(node, wxT("wxStatusBar"));
80 }
81
82 #endif
83