]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_statbar.cpp
Removed no longer needed code to fix combo sizing (causes layout problems on Windows)
[wxWidgets.git] / src / xrc / xh_statbar.cpp
CommitLineData
b0fb0f3c
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: xh_statbar.cpp
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
b0fb0f3c
JS
20#include "wx/frame.h"
21#include "wx/string.h"
90dedfca 22#include "wx/log.h"
b0fb0f3c 23
b0fb0f3c
JS
24#include "wx/xrc/xh_statbar.h"
25#include "wx/statusbr.h"
26
c45b7e75
JS
27IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
28
4d073429 29wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
b0fb0f3c
JS
30 wxXmlResourceHandler()
31{
32 XRC_ADD_STYLE(wxST_SIZEGRIP);
33 AddWindowStyles();
34}
35
36wxObject *wxStatusBarXmlHandler::DoCreateResource()
37{
38 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
39
40 statbar->Create(m_parentAsWindow,
41 GetID(),
42 GetStyle(),
43 GetName());
44
45 int fields = GetLong(wxT("fields"), 1);
46 wxString widths = GetParamValue(wxT("widths"));
c2919ab3 47 wxString styles = GetParamValue(wxT("styles"));
b0fb0f3c 48
fd9e9adb 49 if (fields > 1 && !widths.IsEmpty())
b0fb0f3c
JS
50 {
51 int *width = new int[fields];
4d073429
DS
52
53 for (int i = 0; i < fields; ++i)
b0fb0f3c
JS
54 {
55 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
56 if(widths.Find(wxT(',')))
57 widths.Remove(0, widths.Find(wxT(',')) + 1);
58 }
59 statbar->SetFieldsCount(fields, width);
60 delete[] width;
61 }
adb0baf7
JS
62 else
63 statbar->SetFieldsCount(fields);
b0fb0f3c 64
c2919ab3
VZ
65 if (!styles.IsEmpty())
66 {
67 int *style = new int[fields];
68 for (int i = 0; i < fields; ++i)
69 {
70 style[i] = wxSB_NORMAL;
71
72 wxString first = styles.BeforeFirst(wxT(','));
73 if (first == wxT("wxSB_NORMAL"))
74 style[i] = wxSB_NORMAL;
75 else if (first == wxT("wxSB_FLAT"))
76 style[i] = wxSB_FLAT;
77 else if (first == wxT("wxSB_RAISED"))
78 style[i] = wxSB_RAISED;
79
80 if (!first.IsEmpty())
81 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first);
82 if(styles.Find(wxT(',')))
83 styles.Remove(0, styles.Find(wxT(',')) + 1);
84 }
85 statbar->SetStatusStyles(fields, style);
86 delete [] style;
87 }
88
b0fb0f3c
JS
89 if (m_parentAsWindow)
90 {
91 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
92 if (parentFrame)
93 parentFrame->SetStatusBar(statbar);
94 }
95
96 return statbar;
97}
98
99bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
100{
101 return IsOfClass(node, wxT("wxStatusBar"));
102}
103
621be1ec 104#endif // wxUSE_XRC && wxUSE_STATUSBAR
b0fb0f3c 105