]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_statbar.cpp
Pressing build-in joystick on WinCE phones fires wxEVT_JOY_BUTTON_DOWN event.
[wxWidgets.git] / src / xrc / xh_statbar.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xh_statbar.cpp
3 // Purpose: XRC resource for wxStatusBar
4 // Author: Brian Ravnsgaard Riis
5 // Created: 2004/01/21
6 // RCS-ID: $Id$
7 // Copyright: (c) 2004 Brian Ravnsgaard Riis
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #if wxUSE_XRC && wxUSE_STATUSBAR
19
20 #include "wx/frame.h"
21 #include "wx/string.h"
22 #include "wx/log.h"
23
24 #include "wx/xrc/xh_statbar.h"
25 #include "wx/statusbr.h"
26
27 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler)
28
29 wxStatusBarXmlHandler::wxStatusBarXmlHandler() :
30 wxXmlResourceHandler()
31 {
32 XRC_ADD_STYLE(wxST_SIZEGRIP);
33 AddWindowStyles();
34 }
35
36 wxObject *wxStatusBarXmlHandler::DoCreateResource()
37 {
38 XRC_MAKE_INSTANCE(statbar, wxStatusBar)
39
40 statbar->Create(m_parentAsWindow,
41 GetID(),
42 GetStyle(),
43 GetName());
44
45 int fields = GetLong(wxT("fields"), 1);
46 wxString widths = GetParamValue(wxT("widths"));
47 wxString styles = GetParamValue(wxT("styles"));
48
49 if (fields > 1 && !widths.IsEmpty())
50 {
51 int *width = new int[fields];
52
53 for (int i = 0; i < fields; ++i)
54 {
55 width[i] = wxAtoi(widths.BeforeFirst(wxT(',')));
56 if(widths.Find(wxT(',')))
57 widths.Remove(0, widths.Find(wxT(',')) + 1);
58 }
59 statbar->SetFieldsCount(fields, width);
60 delete[] width;
61 }
62 else
63 statbar->SetFieldsCount(fields);
64
65 if (!styles.IsEmpty())
66 {
67 int *style = new int[fields];
68 for (int i = 0; i < fields; ++i)
69 {
70 style[i] = wxSB_NORMAL;
71
72 wxString first = styles.BeforeFirst(wxT(','));
73 if (first == wxT("wxSB_NORMAL"))
74 style[i] = wxSB_NORMAL;
75 else if (first == wxT("wxSB_FLAT"))
76 style[i] = wxSB_FLAT;
77 else if (first == wxT("wxSB_RAISED"))
78 style[i] = wxSB_RAISED;
79
80 if (!first.IsEmpty())
81 wxLogError(wxT("Error in resource, unknown statusbar field style: ") + first);
82 if(styles.Find(wxT(',')))
83 styles.Remove(0, styles.Find(wxT(',')) + 1);
84 }
85 statbar->SetStatusStyles(fields, style);
86 delete [] style;
87 }
88
89 if (m_parentAsWindow)
90 {
91 wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
92 if (parentFrame)
93 parentFrame->SetStatusBar(statbar);
94 }
95
96 return statbar;
97 }
98
99 bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node)
100 {
101 return IsOfClass(node, wxT("wxStatusBar"));
102 }
103
104 #endif // wxUSE_XRC && wxUSE_STATUSBAR
105