]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
12 #pragma implementation "xh_statbar.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #if wxUSE_XRC && wxUSE_STATUSBAR
25 #include "wx/string.h"
28 #include "wx/xrc/xh_statbar.h"
29 #include "wx/statusbr.h"
31 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler
, wxXmlResourceHandler
)
33 wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
34 wxXmlResourceHandler()
36 XRC_ADD_STYLE(wxST_SIZEGRIP
);
40 wxObject
*wxStatusBarXmlHandler::DoCreateResource()
42 XRC_MAKE_INSTANCE(statbar
, wxStatusBar
)
44 statbar
->Create(m_parentAsWindow
,
49 int fields
= GetLong(wxT("fields"), 1);
50 wxString widths
= GetParamValue(wxT("widths"));
51 wxString styles
= GetParamValue(wxT("styles"));
53 if (fields
> 1 && !widths
.IsEmpty())
55 int *width
= new int[fields
];
57 for (int i
= 0; i
< fields
; ++i
)
59 width
[i
] = wxAtoi(widths
.BeforeFirst(wxT(',')));
60 if(widths
.Find(wxT(',')))
61 widths
.Remove(0, widths
.Find(wxT(',')) + 1);
63 statbar
->SetFieldsCount(fields
, width
);
67 statbar
->SetFieldsCount(fields
);
69 if (!styles
.IsEmpty())
71 int *style
= new int[fields
];
72 for (int i
= 0; i
< fields
; ++i
)
74 style
[i
] = wxSB_NORMAL
;
76 wxString first
= styles
.BeforeFirst(wxT(','));
77 if (first
== wxT("wxSB_NORMAL"))
78 style
[i
] = wxSB_NORMAL
;
79 else if (first
== wxT("wxSB_FLAT"))
81 else if (first
== wxT("wxSB_RAISED"))
82 style
[i
] = wxSB_RAISED
;
85 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first
);
86 if(styles
.Find(wxT(',')))
87 styles
.Remove(0, styles
.Find(wxT(',')) + 1);
89 statbar
->SetStatusStyles(fields
, style
);
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