]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_statbar.cpp
no changes, just a typo
[wxWidgets.git] / src / xrc / xh_statbar.cpp
CommitLineData
b0fb0f3c 1/////////////////////////////////////////////////////////////////////////////
df91131c 2// Name: src/xrc/xh_statbar.cpp
b0fb0f3c
JS
3// Purpose: XRC resource for wxStatusBar
4// Author: Brian Ravnsgaard Riis
5// Created: 2004/01/21
4d073429 6// RCS-ID: $Id$
b0fb0f3c
JS
7// Copyright: (c) 2004 Brian Ravnsgaard Riis
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
b0fb0f3c
JS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
621be1ec 18#if wxUSE_XRC && wxUSE_STATUSBAR
a1e4ec87 19
df91131c
WS
20#include "wx/xrc/xh_statbar.h"
21
22#ifndef WX_PRECOMP
23 #include "wx/string.h"
e4db172a 24 #include "wx/log.h"
76b49cf4 25 #include "wx/frame.h"
3304646d 26 #include "wx/statusbr.h"
df91131c
WS
27#endif
28
c45b7e75
JS
29IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
30
3304646d
WS
31wxStatusBarXmlHandler::wxStatusBarXmlHandler()
32 :wxXmlResourceHandler()
b0fb0f3c
JS
33{
34 XRC_ADD_STYLE(wxST_SIZEGRIP);
35 AddWindowStyles();
36}
37
38wxObject *wxStatusBarXmlHandler::DoCreateResource()
39{
40 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
41
42 statbar->Create(m_parentAsWindow,
43 GetID(),
44 GetStyle(),
45 GetName());
46
47 int fields = GetLong(wxT("fields"), 1);
48 wxString widths = GetParamValue(wxT("widths"));
c2919ab3 49 wxString styles = GetParamValue(wxT("styles"));
b0fb0f3c 50
fd9e9adb 51 if (fields > 1 && !widths.IsEmpty())
b0fb0f3c
JS
52 {
53 int *width = new int[fields];
4d073429
DS
54
55 for (int i = 0; i < fields; ++i)
b0fb0f3c
JS
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 }
adb0baf7
JS
64 else
65 statbar->SetFieldsCount(fields);
b0fb0f3c 66
df91131c 67 if (!styles.empty())
c2919ab3
VZ
68 {
69 int *style = new int[fields];
70 for (int i = 0; i < fields; ++i)
71 {
72 style[i] = wxSB_NORMAL;
73
74 wxString first = styles.BeforeFirst(wxT(','));
75 if (first == wxT("wxSB_NORMAL"))
76 style[i] = wxSB_NORMAL;
77 else if (first == wxT("wxSB_FLAT"))
78 style[i] = wxSB_FLAT;
79 else if (first == wxT("wxSB_RAISED"))
80 style[i] = wxSB_RAISED;
6f6a69cb 81 else if (!first.empty())
c2919ab3 82 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first);
6f6a69cb 83
c2919ab3
VZ
84 if(styles.Find(wxT(',')))
85 styles.Remove(0, styles.Find(wxT(',')) + 1);
86 }
87 statbar->SetStatusStyles(fields, style);
88 delete [] style;
89 }
90
defde6bc
VZ
91 CreateChildren(statbar);
92
b0fb0f3c
JS
93 if (m_parentAsWindow)
94 {
95 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
96 if (parentFrame)
97 parentFrame->SetStatusBar(statbar);
98 }
99
100 return statbar;
101}
102
103bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
104{
105 return IsOfClass(node, wxT("wxStatusBar"));
106}
107
621be1ec 108#endif // wxUSE_XRC && wxUSE_STATUSBAR