]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_statbar.cpp
Fixed Cygwin double definition
[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
c575e45a 11#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
b0fb0f3c
JS
12#pragma implementation "xh_statbar.h"
13#endif
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
621be1ec 22#if wxUSE_XRC && wxUSE_STATUSBAR
a1e4ec87 23
b0fb0f3c
JS
24#include "wx/frame.h"
25#include "wx/string.h"
90dedfca 26#include "wx/log.h"
b0fb0f3c 27
b0fb0f3c
JS
28#include "wx/xrc/xh_statbar.h"
29#include "wx/statusbr.h"
30
c45b7e75
JS
31IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
32
4d073429 33wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
b0fb0f3c
JS
34 wxXmlResourceHandler()
35{
36 XRC_ADD_STYLE(wxST_SIZEGRIP);
37 AddWindowStyles();
38}
39
40wxObject *wxStatusBarXmlHandler::DoCreateResource()
41{
42 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
43
44 statbar->Create(m_parentAsWindow,
45 GetID(),
46 GetStyle(),
47 GetName());
48
49 int fields = GetLong(wxT("fields"), 1);
50 wxString widths = GetParamValue(wxT("widths"));
c2919ab3 51 wxString styles = GetParamValue(wxT("styles"));
b0fb0f3c 52
fd9e9adb 53 if (fields > 1 && !widths.IsEmpty())
b0fb0f3c
JS
54 {
55 int *width = new int[fields];
4d073429
DS
56
57 for (int i = 0; i < fields; ++i)
b0fb0f3c
JS
58 {
59 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
60 if(widths.Find(wxT(',')))
61 widths.Remove(0, widths.Find(wxT(',')) + 1);
62 }
63 statbar->SetFieldsCount(fields, width);
64 delete[] width;
65 }
adb0baf7
JS
66 else
67 statbar->SetFieldsCount(fields);
b0fb0f3c 68
c2919ab3
VZ
69 if (!styles.IsEmpty())
70 {
71 int *style = new int[fields];
72 for (int i = 0; i < fields; ++i)
73 {
74 style[i] = wxSB_NORMAL;
75
76 wxString first = styles.BeforeFirst(wxT(','));
77 if (first == wxT("wxSB_NORMAL"))
78 style[i] = wxSB_NORMAL;
79 else if (first == wxT("wxSB_FLAT"))
80 style[i] = wxSB_FLAT;
81 else if (first == wxT("wxSB_RAISED"))
82 style[i] = wxSB_RAISED;
83
84 if (!first.IsEmpty())
85 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first);
86 if(styles.Find(wxT(',')))
87 styles.Remove(0, styles.Find(wxT(',')) + 1);
88 }
89 statbar->SetStatusStyles(fields, style);
90 delete [] style;
91 }
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
b0fb0f3c 109