]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_statbar.cpp
Reflect changes in stc.cpp in stc.cpp.in from which it's generated.
[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 // Copyright: (c) 2004 Brian Ravnsgaard Riis
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #if wxUSE_XRC && wxUSE_STATUSBAR
18
19 #include "wx/xrc/xh_statbar.h"
20
21 #ifndef WX_PRECOMP
22 #include "wx/string.h"
23 #include "wx/log.h"
24 #include "wx/frame.h"
25 #include "wx/statusbr.h"
26 #endif
27
28 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
29
30 wxStatusBarXmlHandler::wxStatusBarXmlHandler()
31 :wxXmlResourceHandler()
32 {
33 XRC_ADD_STYLE(wxSTB_SIZEGRIP);
34 XRC_ADD_STYLE(wxSTB_SHOW_TIPS);
35 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_START);
36 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_MIDDLE);
37 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_END);
38 XRC_ADD_STYLE(wxSTB_DEFAULT_STYLE);
39
40 // compat style name:
41 XRC_ADD_STYLE(wxST_SIZEGRIP);
42
43 AddWindowStyles();
44 }
45
46 wxObject *wxStatusBarXmlHandler::DoCreateResource()
47 {
48 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
49
50 statbar->Create(m_parentAsWindow,
51 GetID(),
52 GetStyle(),
53 GetName());
54
55 int fields = GetLong(wxT("fields"), 1);
56 wxString widths = GetParamValue(wxT("widths"));
57 wxString styles = GetParamValue(wxT("styles"));
58
59 if (fields > 1 && !widths.IsEmpty())
60 {
61 int *width = new int[fields];
62
63 for (int i = 0; i < fields; ++i)
64 {
65 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
66 if(widths.Find(wxT(',')))
67 widths.Remove(0, widths.Find(wxT(',')) + 1);
68 }
69 statbar->SetFieldsCount(fields, width);
70 delete[] width;
71 }
72 else
73 statbar->SetFieldsCount(fields);
74
75 if (!styles.empty())
76 {
77 int *style = new int[fields];
78 for (int i = 0; i < fields; ++i)
79 {
80 style[i] = wxSB_NORMAL;
81
82 wxString first = styles.BeforeFirst(wxT(','));
83 if (first == wxT("wxSB_NORMAL"))
84 style[i] = wxSB_NORMAL;
85 else if (first == wxT("wxSB_FLAT"))
86 style[i] = wxSB_FLAT;
87 else if (first == wxT("wxSB_RAISED"))
88 style[i] = wxSB_RAISED;
89 else if (first == wxT("wxSB_SUNKEN"))
90 style[i] = wxSB_SUNKEN;
91 else if (!first.empty())
92 {
93 ReportParamError
94 (
95 "styles",
96 wxString::Format
97 (
98 "unknown status bar field style \"%s\"",
99 first
100 )
101 );
102 }
103
104 if(styles.Find(wxT(',')))
105 styles.Remove(0, styles.Find(wxT(',')) + 1);
106 }
107 statbar->SetStatusStyles(fields, style);
108 delete [] style;
109 }
110
111 CreateChildren(statbar);
112
113 if (m_parentAsWindow)
114 {
115 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
116 if (parentFrame)
117 parentFrame->SetStatusBar(statbar);
118 }
119
120 return statbar;
121 }
122
123 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
124 {
125 return IsOfClass(node, wxT("wxStatusBar"));
126 }
127
128 #endif // wxUSE_XRC && wxUSE_STATUSBAR