]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_statbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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
21 #include "wx/string.h"
24 #include "wx/xrc/xh_statbar.h"
25 #include "wx/statusbr.h"
27 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler
, wxXmlResourceHandler
)
29 wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
30 wxXmlResourceHandler()
32 XRC_ADD_STYLE(wxST_SIZEGRIP
);
36 wxObject
*wxStatusBarXmlHandler::DoCreateResource()
38 XRC_MAKE_INSTANCE(statbar
, wxStatusBar
)
40 statbar
->Create(m_parentAsWindow
,
45 int fields
= GetLong(wxT("fields"), 1);
46 wxString widths
= GetParamValue(wxT("widths"));
47 wxString styles
= GetParamValue(wxT("styles"));
49 if (fields
> 1 && !widths
.IsEmpty())
51 int *width
= new int[fields
];
53 for (int i
= 0; i
< fields
; ++i
)
55 width
[i
] = wxAtoi(widths
.BeforeFirst(wxT(',')));
56 if(widths
.Find(wxT(',')))
57 widths
.Remove(0, widths
.Find(wxT(',')) + 1);
59 statbar
->SetFieldsCount(fields
, width
);
63 statbar
->SetFieldsCount(fields
);
65 if (!styles
.IsEmpty())
67 int *style
= new int[fields
];
68 for (int i
= 0; i
< fields
; ++i
)
70 style
[i
] = wxSB_NORMAL
;
72 wxString first
= styles
.BeforeFirst(wxT(','));
73 if (first
== wxT("wxSB_NORMAL"))
74 style
[i
] = wxSB_NORMAL
;
75 else if (first
== wxT("wxSB_FLAT"))
77 else if (first
== wxT("wxSB_RAISED"))
78 style
[i
] = wxSB_RAISED
;
81 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first
);
82 if(styles
.Find(wxT(',')))
83 styles
.Remove(0, styles
.Find(wxT(',')) + 1);
85 statbar
->SetStatusStyles(fields
, style
);
91 wxFrame
*parentFrame
= wxDynamicCast(m_parent
, wxFrame
);
93 parentFrame
->SetStatusBar(statbar
);
99 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode
*node
)
101 return IsOfClass(node
, wxT("wxStatusBar"));
104 #endif // wxUSE_XRC && wxUSE_STATUSBAR