]>
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(wxSTB_SIZEGRIP
);
35 XRC_ADD_STYLE(wxSTB_SHOW_TIPS
);
36 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_START
);
37 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_MIDDLE
);
38 XRC_ADD_STYLE(wxSTB_ELLIPSIZE_END
);
39 XRC_ADD_STYLE(wxSTB_DEFAULT_STYLE
);
42 XRC_ADD_STYLE(wxST_SIZEGRIP
);
47 wxObject
*wxStatusBarXmlHandler::DoCreateResource()
49 XRC_MAKE_INSTANCE(statbar
, wxStatusBar
)
51 statbar
->Create(m_parentAsWindow
,
56 int fields
= GetLong(wxT("fields"), 1);
57 wxString widths
= GetParamValue(wxT("widths"));
58 wxString styles
= GetParamValue(wxT("styles"));
60 if (fields
> 1 && !widths
.IsEmpty())
62 int *width
= new int[fields
];
64 for (int i
= 0; i
< fields
; ++i
)
66 width
[i
] = wxAtoi(widths
.BeforeFirst(wxT(',')));
67 if(widths
.Find(wxT(',')))
68 widths
.Remove(0, widths
.Find(wxT(',')) + 1);
70 statbar
->SetFieldsCount(fields
, width
);
74 statbar
->SetFieldsCount(fields
);
78 int *style
= new int[fields
];
79 for (int i
= 0; i
< fields
; ++i
)
81 style
[i
] = wxSB_NORMAL
;
83 wxString first
= styles
.BeforeFirst(wxT(','));
84 if (first
== wxT("wxSB_NORMAL"))
85 style
[i
] = wxSB_NORMAL
;
86 else if (first
== wxT("wxSB_FLAT"))
88 else if (first
== wxT("wxSB_RAISED"))
89 style
[i
] = wxSB_RAISED
;
90 else if (!first
.empty())
97 "unknown status bar field style \"%s\"",
103 if(styles
.Find(wxT(',')))
104 styles
.Remove(0, styles
.Find(wxT(',')) + 1);
106 statbar
->SetStatusStyles(fields
, style
);
110 CreateChildren(statbar
);
112 if (m_parentAsWindow
)
114 wxFrame
*parentFrame
= wxDynamicCast(m_parent
, wxFrame
);
116 parentFrame
->SetStatusBar(statbar
);
122 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode
*node
)
124 return IsOfClass(node
, wxT("wxStatusBar"));
127 #endif // wxUSE_XRC && wxUSE_STATUSBAR