]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_statbar.cpp
Added wxRichTextTableBlock class to help with table UI operations
[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
b0fb0f3c
JS
6// Copyright: (c) 2004 Brian Ravnsgaard Riis
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
b0fb0f3c
JS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
621be1ec 17#if wxUSE_XRC && wxUSE_STATUSBAR
a1e4ec87 18
df91131c
WS
19#include "wx/xrc/xh_statbar.h"
20
21#ifndef WX_PRECOMP
22 #include "wx/string.h"
e4db172a 23 #include "wx/log.h"
76b49cf4 24 #include "wx/frame.h"
3304646d 25 #include "wx/statusbr.h"
df91131c
WS
26#endif
27
c45b7e75
JS
28IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
29
3304646d
WS
30wxStatusBarXmlHandler::wxStatusBarXmlHandler()
31 :wxXmlResourceHandler()
b0fb0f3c 32{
c4c178c1
FM
33 XRC_ADD_STYLE(wxSTB_SIZEGRIP);
34 XRC_ADD_STYLE(wxSTB_SHOW_TIPS);
35 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_START);
36 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_MIDDLE);
37 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_END);
38 XRC_ADD_STYLE(wxSTB_DEFAULT_STYLE);
39
40 // compat style name:
6ecc0896 41 XRC_ADD_STYLE(wxST_SIZEGRIP);
c4c178c1 42
b0fb0f3c
JS
43 AddWindowStyles();
44}
45
46wxObject *wxStatusBarXmlHandler::DoCreateResource()
47{
48 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
49
50 statbar->Create(m_parentAsWindow,
51 GetID(),
52 GetStyle(),
53 GetName());
54
55 int fields = GetLong(wxT("fields"), 1);
56 wxString widths = GetParamValue(wxT("widths"));
c2919ab3 57 wxString styles = GetParamValue(wxT("styles"));
b0fb0f3c 58
fd9e9adb 59 if (fields > 1 && !widths.IsEmpty())
b0fb0f3c
JS
60 {
61 int *width = new int[fields];
4d073429
DS
62
63 for (int i = 0; i < fields; ++i)
b0fb0f3c
JS
64 {
65 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
66 if(widths.Find(wxT(',')))
67 widths.Remove(0, widths.Find(wxT(',')) + 1);
68 }
69 statbar->SetFieldsCount(fields, width);
70 delete[] width;
71 }
adb0baf7
JS
72 else
73 statbar->SetFieldsCount(fields);
b0fb0f3c 74
df91131c 75 if (!styles.empty())
c2919ab3
VZ
76 {
77 int *style = new int[fields];
78 for (int i = 0; i < fields; ++i)
79 {
80 style[i] = wxSB_NORMAL;
81
82 wxString first = styles.BeforeFirst(wxT(','));
83 if (first == wxT("wxSB_NORMAL"))
84 style[i] = wxSB_NORMAL;
85 else if (first == wxT("wxSB_FLAT"))
86 style[i] = wxSB_FLAT;
87 else if (first == wxT("wxSB_RAISED"))
88 style[i] = wxSB_RAISED;
98eb2e84
VZ
89 else if (first == wxT("wxSB_SUNKEN"))
90 style[i] = wxSB_SUNKEN;
6f6a69cb 91 else if (!first.empty())
819559b2
VS
92 {
93 ReportParamError
94 (
95 "styles",
96 wxString::Format
97 (
98 "unknown status bar field style \"%s\"",
99 first
100 )
101 );
102 }
6f6a69cb 103
c2919ab3
VZ
104 if(styles.Find(wxT(',')))
105 styles.Remove(0, styles.Find(wxT(',')) + 1);
106 }
107 statbar->SetStatusStyles(fields, style);
108 delete [] style;
109 }
110
defde6bc
VZ
111 CreateChildren(statbar);
112
b0fb0f3c
JS
113 if (m_parentAsWindow)
114 {
115 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
116 if (parentFrame)
117 parentFrame->SetStatusBar(statbar);
118 }
119
120 return statbar;
121}
122
123bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
124{
125 return IsOfClass(node, wxT("wxStatusBar"));
126}
127
621be1ec 128#endif // wxUSE_XRC && wxUSE_STATUSBAR