]>
Commit | Line | Data |
---|---|---|
b0fb0f3c | 1 | ///////////////////////////////////////////////////////////////////////////// |
df91131c | 2 | // Name: src/xrc/xh_statbar.cpp |
b0fb0f3c JS |
3 | // Purpose: XRC resource for wxStatusBar |
4 | // Author: Brian Ravnsgaard Riis | |
5 | // Created: 2004/01/21 | |
4d073429 | 6 | // RCS-ID: $Id$ |
b0fb0f3c JS |
7 | // Copyright: (c) 2004 Brian Ravnsgaard Riis |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
b0fb0f3c JS |
11 | // For compilers that support precompilation, includes "wx.h". |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
621be1ec | 18 | #if wxUSE_XRC && wxUSE_STATUSBAR |
a1e4ec87 | 19 | |
df91131c WS |
20 | #include "wx/xrc/xh_statbar.h" |
21 | ||
22 | #ifndef WX_PRECOMP | |
23 | #include "wx/string.h" | |
e4db172a | 24 | #include "wx/log.h" |
76b49cf4 | 25 | #include "wx/frame.h" |
3304646d | 26 | #include "wx/statusbr.h" |
df91131c WS |
27 | #endif |
28 | ||
c45b7e75 JS |
29 | IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXmlHandler, wxXmlResourceHandler) |
30 | ||
3304646d WS |
31 | wxStatusBarXmlHandler::wxStatusBarXmlHandler() |
32 | :wxXmlResourceHandler() | |
b0fb0f3c | 33 | { |
c4c178c1 FM |
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); | |
40 | ||
41 | // compat style name: | |
6ecc0896 | 42 | XRC_ADD_STYLE(wxST_SIZEGRIP); |
c4c178c1 | 43 | |
b0fb0f3c JS |
44 | AddWindowStyles(); |
45 | } | |
46 | ||
47 | wxObject *wxStatusBarXmlHandler::DoCreateResource() | |
48 | { | |
49 | XRC_MAKE_INSTANCE(statbar, wxStatusBar) | |
50 | ||
51 | statbar->Create(m_parentAsWindow, | |
52 | GetID(), | |
53 | GetStyle(), | |
54 | GetName()); | |
55 | ||
56 | int fields = GetLong(wxT("fields"), 1); | |
57 | wxString widths = GetParamValue(wxT("widths")); | |
c2919ab3 | 58 | wxString styles = GetParamValue(wxT("styles")); |
b0fb0f3c | 59 | |
fd9e9adb | 60 | if (fields > 1 && !widths.IsEmpty()) |
b0fb0f3c JS |
61 | { |
62 | int *width = new int[fields]; | |
4d073429 DS |
63 | |
64 | for (int i = 0; i < fields; ++i) | |
b0fb0f3c JS |
65 | { |
66 | width[i] = wxAtoi(widths.BeforeFirst(wxT(','))); | |
67 | if(widths.Find(wxT(','))) | |
68 | widths.Remove(0, widths.Find(wxT(',')) + 1); | |
69 | } | |
70 | statbar->SetFieldsCount(fields, width); | |
71 | delete[] width; | |
72 | } | |
adb0baf7 JS |
73 | else |
74 | statbar->SetFieldsCount(fields); | |
b0fb0f3c | 75 | |
df91131c | 76 | if (!styles.empty()) |
c2919ab3 VZ |
77 | { |
78 | int *style = new int[fields]; | |
79 | for (int i = 0; i < fields; ++i) | |
80 | { | |
81 | style[i] = wxSB_NORMAL; | |
82 | ||
83 | wxString first = styles.BeforeFirst(wxT(',')); | |
84 | if (first == wxT("wxSB_NORMAL")) | |
85 | style[i] = wxSB_NORMAL; | |
86 | else if (first == wxT("wxSB_FLAT")) | |
87 | style[i] = wxSB_FLAT; | |
88 | else if (first == wxT("wxSB_RAISED")) | |
89 | style[i] = wxSB_RAISED; | |
98eb2e84 VZ |
90 | else if (first == wxT("wxSB_SUNKEN")) |
91 | style[i] = wxSB_SUNKEN; | |
6f6a69cb | 92 | else if (!first.empty()) |
819559b2 VS |
93 | { |
94 | ReportParamError | |
95 | ( | |
96 | "styles", | |
97 | wxString::Format | |
98 | ( | |
99 | "unknown status bar field style \"%s\"", | |
100 | first | |
101 | ) | |
102 | ); | |
103 | } | |
6f6a69cb | 104 | |
c2919ab3 VZ |
105 | if(styles.Find(wxT(','))) |
106 | styles.Remove(0, styles.Find(wxT(',')) + 1); | |
107 | } | |
108 | statbar->SetStatusStyles(fields, style); | |
109 | delete [] style; | |
110 | } | |
111 | ||
defde6bc VZ |
112 | CreateChildren(statbar); |
113 | ||
b0fb0f3c JS |
114 | if (m_parentAsWindow) |
115 | { | |
116 | wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame); | |
117 | if (parentFrame) | |
118 | parentFrame->SetStatusBar(statbar); | |
119 | } | |
120 | ||
121 | return statbar; | |
122 | } | |
123 | ||
124 | bool wxStatusBarXmlHandler::CanHandle(wxXmlNode *node) | |
125 | { | |
126 | return IsOfClass(node, wxT("wxStatusBar")); | |
127 | } | |
128 | ||
621be1ec | 129 | #endif // wxUSE_XRC && wxUSE_STATUSBAR |