]>
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
6 // Copyright: (c) 2004 Brian Ravnsgaard Riis
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_XRC && wxUSE_STATUSBAR
19 #include "wx/xrc/xh_statbar.h"
22 #include "wx/string.h"
25 #include "wx/statusbr.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler
, wxXmlResourceHandler
)
30 wxStatusBarXmlHandler::wxStatusBarXmlHandler()
31 :wxXmlResourceHandler()
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
);
41 XRC_ADD_STYLE(wxST_SIZEGRIP
);
46 wxObject
*wxStatusBarXmlHandler::DoCreateResource()
48 XRC_MAKE_INSTANCE(statbar
, wxStatusBar
)
50 statbar
->Create(m_parentAsWindow
,
55 int fields
= GetLong(wxT("fields"), 1);
56 wxString widths
= GetParamValue(wxT("widths"));
57 wxString styles
= GetParamValue(wxT("styles"));
59 if (fields
> 1 && !widths
.IsEmpty())
61 int *width
= new int[fields
];
63 for (int i
= 0; i
< fields
; ++i
)
65 width
[i
] = wxAtoi(widths
.BeforeFirst(wxT(',')));
66 if(widths
.Find(wxT(',')))
67 widths
.Remove(0, widths
.Find(wxT(',')) + 1);
69 statbar
->SetFieldsCount(fields
, width
);
73 statbar
->SetFieldsCount(fields
);
77 int *style
= new int[fields
];
78 for (int i
= 0; i
< fields
; ++i
)
80 style
[i
] = wxSB_NORMAL
;
82 wxString first
= styles
.BeforeFirst(wxT(','));
83 if (first
== wxT("wxSB_NORMAL"))
84 style
[i
] = wxSB_NORMAL
;
85 else if (first
== wxT("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())
98 "unknown status bar field style \"%s\"",
104 if(styles
.Find(wxT(',')))
105 styles
.Remove(0, styles
.Find(wxT(',')) + 1);
107 statbar
->SetStatusStyles(fields
, style
);
111 CreateChildren(statbar
);
113 if (m_parentAsWindow
)
115 wxFrame
*parentFrame
= wxDynamicCast(m_parent
, wxFrame
);
117 parentFrame
->SetStatusBar(statbar
);
123 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode
*node
)
125 return IsOfClass(node
, wxT("wxStatusBar"));
128 #endif // wxUSE_XRC && wxUSE_STATUSBAR