]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_statbar.cpp
Added wxToggleButton handler
[wxWidgets.git] / src / xrc / xh_statbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #ifdef __GNUG__
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
22 #include "wx/frame.h"
23 #include "wx/string.h"
24 #include "wx/log.h"
25
26 #if wxUSE_STATUSBAR
27
28 #include "wx/xrc/xh_statbar.h"
29 #include "wx/statusbr.h"
30
31 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
32
33 wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
34 wxXmlResourceHandler()
35 {
36 XRC_ADD_STYLE(wxST_SIZEGRIP);
37 AddWindowStyles();
38 }
39
40 wxObject *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"));
51 wxString styles = GetParamValue(wxT("styles"));
52
53 if (fields > 1 && !widths.IsEmpty())
54 {
55 int *width = new int[fields];
56
57 for (int i = 0; i < fields; ++i)
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 }
66 else
67 statbar->SetFieldsCount(fields);
68
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
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
103 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
104 {
105 return IsOfClass(node, wxT("wxStatusBar"));
106 }
107
108 #endif
109