]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_statbar.cpp
Include wx/checklst.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / xrc / xh_statbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/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 // 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_STATUSBAR
19
20 #include "wx/xrc/xh_statbar.h"
21
22 #ifndef WX_PRECOMP
23 #include "wx/string.h"
24 #include "wx/log.h"
25 #include "wx/frame.h"
26 #endif
27
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 wxString styles = GetParamValue(wxT("styles"));
51
52 if (fields > 1 && !widths.IsEmpty())
53 {
54 int *width = new int[fields];
55
56 for (int i = 0; i < fields; ++i)
57 {
58 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
59 if(widths.Find(wxT(',')))
60 widths.Remove(0, widths.Find(wxT(',')) + 1);
61 }
62 statbar->SetFieldsCount(fields, width);
63 delete[] width;
64 }
65 else
66 statbar->SetFieldsCount(fields);
67
68 if (!styles.empty())
69 {
70 int *style = new int[fields];
71 for (int i = 0; i < fields; ++i)
72 {
73 style[i] = wxSB_NORMAL;
74
75 wxString first = styles.BeforeFirst(wxT(','));
76 if (first == wxT("wxSB_NORMAL"))
77 style[i] = wxSB_NORMAL;
78 else if (first == wxT("wxSB_FLAT"))
79 style[i] = wxSB_FLAT;
80 else if (first == wxT("wxSB_RAISED"))
81 style[i] = wxSB_RAISED;
82
83 if (!first.empty())
84 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first);
85 if(styles.Find(wxT(',')))
86 styles.Remove(0, styles.Find(wxT(',')) + 1);
87 }
88 statbar->SetStatusStyles(fields, style);
89 delete [] style;
90 }
91
92 if (m_parentAsWindow)
93 {
94 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
95 if (parentFrame)
96 parentFrame->SetStatusBar(statbar);
97 }
98
99 return statbar;
100 }
101
102 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
103 {
104 return IsOfClass(node, wxT("wxStatusBar"));
105 }
106
107 #endif // wxUSE_XRC && wxUSE_STATUSBAR