]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_statbar.cpp
compilation fix for Windows after the last change (misplaced #endif)
[wxWidgets.git] / src / xrc / xh_statbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_statbar.cpp
3 // Purpose: XRC resource for wxStatusBar
4 // Author: Brian Ravnsgaard Riis
5 // Created: 2004/01/21
6 // RCS-ID: $Id$
7 // Copyright: (c) 2004 Brian Ravnsgaard Riis
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #if wxUSE_XRC && wxUSE_STATUSBAR
19
20 #include "wx/xrc/xh_statbar.h"
21
22 #ifndef WX_PRECOMP
23 #include "wx/string.h"
24 #include "wx/log.h"
25 #include "wx/frame.h"
26 #include "wx/statusbr.h"
27 #endif
28
29 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
30
31 wxStatusBarXmlHandler::wxStatusBarXmlHandler()
32 :wxXmlResourceHandler()
33 {
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:
42 XRC_ADD_STYLE(wxST_SIZEGRIP);
43
44 AddWindowStyles();
45 }
46
47 wxObject *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"));
58 wxString styles = GetParamValue(wxT("styles"));
59
60 if (fields > 1 && !widths.IsEmpty())
61 {
62 int *width = new int[fields];
63
64 for (int i = 0; i < fields; ++i)
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 }
73 else
74 statbar->SetFieldsCount(fields);
75
76 if (!styles.empty())
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;
90 else if (!first.empty())
91 {
92 ReportParamError
93 (
94 "styles",
95 wxString::Format
96 (
97 "unknown status bar field style \"%s\"",
98 first
99 )
100 );
101 }
102
103 if(styles.Find(wxT(',')))
104 styles.Remove(0, styles.Find(wxT(',')) + 1);
105 }
106 statbar->SetStatusStyles(fields, style);
107 delete [] style;
108 }
109
110 CreateChildren(statbar);
111
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
122 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
123 {
124 return IsOfClass(node, wxT("wxStatusBar"));
125 }
126
127 #endif // wxUSE_XRC && wxUSE_STATUSBAR