]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_statbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_statbar.cpp
3 // Purpose: XRC resource for wxStatusBar
4 // Author: Brian Ravnsgaard Riis
7 // Copyright: (c) 2004 Brian Ravnsgaard Riis
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_STATUSBAR
20 #include "wx/xrc/xh_statbar.h"
23 #include "wx/string.h"
26 #include "wx/statusbr.h"
29 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler
, wxXmlResourceHandler
)
31 wxStatusBarXmlHandler::wxStatusBarXmlHandler()
32 :wxXmlResourceHandler()
34 XRC_ADD_STYLE(wxST_SIZEGRIP
);
38 wxObject
*wxStatusBarXmlHandler::DoCreateResource()
40 XRC_MAKE_INSTANCE(statbar
, wxStatusBar
)
42 statbar
->Create(m_parentAsWindow
,
47 int fields
= GetLong(wxT("fields"), 1);
48 wxString widths
= GetParamValue(wxT("widths"));
49 wxString styles
= GetParamValue(wxT("styles"));
51 if (fields
> 1 && !widths
.IsEmpty())
53 int *width
= new int[fields
];
55 for (int i
= 0; i
< fields
; ++i
)
57 width
[i
] = wxAtoi(widths
.BeforeFirst(wxT(',')));
58 if(widths
.Find(wxT(',')))
59 widths
.Remove(0, widths
.Find(wxT(',')) + 1);
61 statbar
->SetFieldsCount(fields
, width
);
65 statbar
->SetFieldsCount(fields
);
69 int *style
= new int[fields
];
70 for (int i
= 0; i
< fields
; ++i
)
72 style
[i
] = wxSB_NORMAL
;
74 wxString first
= styles
.BeforeFirst(wxT(','));
75 if (first
== wxT("wxSB_NORMAL"))
76 style
[i
] = wxSB_NORMAL
;
77 else if (first
== wxT("wxSB_FLAT"))
79 else if (first
== wxT("wxSB_RAISED"))
80 style
[i
] = wxSB_RAISED
;
83 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first
);
84 if(styles
.Find(wxT(',')))
85 styles
.Remove(0, styles
.Find(wxT(',')) + 1);
87 statbar
->SetStatusStyles(fields
, style
);
91 CreateChildren(statbar
);
95 wxFrame
*parentFrame
= wxDynamicCast(m_parent
, wxFrame
);
97 parentFrame
->SetStatusBar(statbar
);
103 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode
*node
)
105 return IsOfClass(node
, wxT("wxStatusBar"));
108 #endif // wxUSE_XRC && wxUSE_STATUSBAR