]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_statbar.cpp
Spell contributor name correctly.
[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 33{
c4c178c1
FM
34 XRC_ADD_STYLE(wxSTB_SIZEGRIP);
35 XRC_ADD_STYLE(wxSTB_SHOW_TIPS);
36 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_START);
37 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_MIDDLE);
38 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_END);
39 XRC_ADD_STYLE(wxSTB_DEFAULT_STYLE);
40
41 // compat style name:
6ecc0896 42 XRC_ADD_STYLE(wxST_SIZEGRIP);
c4c178c1 43
b0fb0f3c
JS
44 AddWindowStyles();
45}
46
47wxObject *wxStatusBarXmlHandler::DoCreateResource()
48{
49 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
50
51 statbar->Create(m_parentAsWindow,
52 GetID(),
53 GetStyle(),
54 GetName());
55
56 int fields = GetLong(wxT("fields"), 1);
57 wxString widths = GetParamValue(wxT("widths"));
c2919ab3 58 wxString styles = GetParamValue(wxT("styles"));
b0fb0f3c 59
fd9e9adb 60 if (fields > 1 && !widths.IsEmpty())
b0fb0f3c
JS
61 {
62 int *width = new int[fields];
4d073429
DS
63
64 for (int i = 0; i < fields; ++i)
b0fb0f3c
JS
65 {
66 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
67 if(widths.Find(wxT(',')))
68 widths.Remove(0, widths.Find(wxT(',')) + 1);
69 }
70 statbar->SetFieldsCount(fields, width);
71 delete[] width;
72 }
adb0baf7
JS
73 else
74 statbar->SetFieldsCount(fields);
b0fb0f3c 75
df91131c 76 if (!styles.empty())
c2919ab3
VZ
77 {
78 int *style = new int[fields];
79 for (int i = 0; i < fields; ++i)
80 {
81 style[i] = wxSB_NORMAL;
82
83 wxString first = styles.BeforeFirst(wxT(','));
84 if (first == wxT("wxSB_NORMAL"))
85 style[i] = wxSB_NORMAL;
86 else if (first == wxT("wxSB_FLAT"))
87 style[i] = wxSB_FLAT;
88 else if (first == wxT("wxSB_RAISED"))
89 style[i] = wxSB_RAISED;
6f6a69cb 90 else if (!first.empty())
819559b2
VS
91 {
92 ReportParamError
93 (
94 "styles",
95 wxString::Format
96 (
97 "unknown status bar field style \"%s\"",
98 first
99 )
100 );
101 }
6f6a69cb 102
c2919ab3
VZ
103 if(styles.Find(wxT(',')))
104 styles.Remove(0, styles.Find(wxT(',')) + 1);
105 }
106 statbar->SetStatusStyles(fields, style);
107 delete [] style;
108 }
109
defde6bc
VZ
110 CreateChildren(statbar);
111
b0fb0f3c
JS
112 if (m_parentAsWindow)
113 {
114 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
115 if (parentFrame)
116 parentFrame->SetStatusBar(statbar);
117 }
118
119 return statbar;
120}
121
122bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
123{
124 return IsOfClass(node, wxT("wxStatusBar"));
125}
126
621be1ec 127#endif // wxUSE_XRC && wxUSE_STATUSBAR