]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_statbar.cpp
don't strip &s from tooltips (patch 1488318)
[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"
df91131c
WS
26#endif
27
b0fb0f3c
JS
28#include "wx/statusbr.h"
29
c45b7e75
JS
30IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
31
4d073429 32wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
b0fb0f3c
JS
33 wxXmlResourceHandler()
34{
35 XRC_ADD_STYLE(wxST_SIZEGRIP);
36 AddWindowStyles();
37}
38
39wxObject *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"));
c2919ab3 50 wxString styles = GetParamValue(wxT("styles"));
b0fb0f3c 51
fd9e9adb 52 if (fields > 1 && !widths.IsEmpty())
b0fb0f3c
JS
53 {
54 int *width = new int[fields];
4d073429
DS
55
56 for (int i = 0; i < fields; ++i)
b0fb0f3c
JS
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 }
adb0baf7
JS
65 else
66 statbar->SetFieldsCount(fields);
b0fb0f3c 67
df91131c 68 if (!styles.empty())
c2919ab3
VZ
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
df91131c 83 if (!first.empty())
c2919ab3
VZ
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
b0fb0f3c
JS
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
102bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
103{
104 return IsOfClass(node, wxT("wxStatusBar"));
105}
106
621be1ec 107#endif // wxUSE_XRC && wxUSE_STATUSBAR