]>
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"
28 #include "wx/statusbr.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler
, wxXmlResourceHandler
)
32 wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
33 wxXmlResourceHandler()
35 XRC_ADD_STYLE(wxST_SIZEGRIP
);
39 wxObject
*wxStatusBarXmlHandler::DoCreateResource()
41 XRC_MAKE_INSTANCE(statbar
, wxStatusBar
)
43 statbar
->Create(m_parentAsWindow
,
48 int fields
= GetLong(wxT("fields"), 1);
49 wxString widths
= GetParamValue(wxT("widths"));
50 wxString styles
= GetParamValue(wxT("styles"));
52 if (fields
> 1 && !widths
.IsEmpty())
54 int *width
= new int[fields
];
56 for (int i
= 0; i
< fields
; ++i
)
58 width
[i
] = wxAtoi(widths
.BeforeFirst(wxT(',')));
59 if(widths
.Find(wxT(',')))
60 widths
.Remove(0, widths
.Find(wxT(',')) + 1);
62 statbar
->SetFieldsCount(fields
, width
);
66 statbar
->SetFieldsCount(fields
);
70 int *style
= new int[fields
];
71 for (int i
= 0; i
< fields
; ++i
)
73 style
[i
] = wxSB_NORMAL
;
75 wxString first
= styles
.BeforeFirst(wxT(','));
76 if (first
== wxT("wxSB_NORMAL"))
77 style
[i
] = wxSB_NORMAL
;
78 else if (first
== wxT("wxSB_FLAT"))
80 else if (first
== wxT("wxSB_RAISED"))
81 style
[i
] = wxSB_RAISED
;
84 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first
);
85 if(styles
.Find(wxT(',')))
86 styles
.Remove(0, styles
.Find(wxT(',')) + 1);
88 statbar
->SetStatusStyles(fields
, style
);
94 wxFrame
*parentFrame
= wxDynamicCast(m_parent
, wxFrame
);
96 parentFrame
->SetStatusBar(statbar
);
102 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode
*node
)
104 return IsOfClass(node
, wxT("wxStatusBar"));
107 #endif // wxUSE_XRC && wxUSE_STATUSBAR