]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/statbrpalm.cpp
Removed comma
[wxWidgets.git] / src / palmos / statbrpalm.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/statbrpalm.cpp
3 // Purpose: Implementation of wxStatusBar for PalmOS
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - transition from faked drawing to native statusbar
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #if wxUSE_NATIVE_STATUSBAR
20
21 #include "wx/statusbr.h"
22
23 #ifndef WX_PRECOMP
24 #include "wx/frame.h"
25 #include "wx/settings.h"
26 #include "wx/dcclient.h"
27 #include "wx/intl.h"
28 #include "wx/log.h"
29 #endif
30
31 #include <StatusBar.h>
32
33 // ----------------------------------------------------------------------------
34 // macros
35 // ----------------------------------------------------------------------------
36
37 // ============================================================================
38 // implementation
39 // ============================================================================
40
41 // ----------------------------------------------------------------------------
42 // wxStatusBarPalm class
43 // ----------------------------------------------------------------------------
44
45 wxStatusBarPalm::wxStatusBarPalm()
46 {
47 SetParent(NULL);
48 }
49
50 bool wxStatusBarPalm::Create(wxWindow *parent,
51 wxWindowID id,
52 long style,
53 const wxString& name)
54 {
55 wxCHECK_MSG( parent, false, wxT("status bar must have a parent") );
56
57 StatusTextBuffer = NULL;
58
59 SetName(name);
60 SetParent(parent);
61 SetId( id == wxID_ANY ? NewControlId() : id );
62
63 parent->AddChild(this);
64
65 SetFieldsCount(1);
66
67 return true;
68 }
69
70 wxStatusBarPalm::~wxStatusBarPalm()
71 {
72 Show();
73
74 DeleteStatusBuffer();
75 }
76
77 bool wxStatusBarPalm::IsShown() const
78 {
79 return StatGetAttribute ( statAttrBarVisible , NULL );
80 }
81
82 bool wxStatusBarPalm::Show( bool show )
83 {
84 if(show)
85 {
86 // show it if hidden
87 if(IsShown())
88 return false;
89 status_t rc = StatShow();
90 wxCHECK_MSG( rc == errNone, false, wxT("cannot hide status bar") );
91 }
92 else
93 {
94 // hide it if shown
95 if(!IsShown())
96 return false;
97 status_t rc = StatHide();
98 wxCHECK_MSG( rc == errNone, false, wxT("cannot hide status bar") );
99 }
100 return true;
101 }
102
103 void wxStatusBarPalm::SetFieldsCount(int nFields, const int *widths)
104 {
105 // this is a Windows limitation
106 wxASSERT_MSG( (nFields > 0) && (nFields < 255), _T("too many fields") );
107
108 wxStatusBarBase::SetFieldsCount(nFields, widths);
109
110 SetFieldsWidth();
111 }
112
113 void wxStatusBarPalm::SetStatusWidths(int n, const int widths[])
114 {
115 wxStatusBarBase::SetStatusWidths(n, widths);
116
117 SetFieldsWidth();
118 }
119
120 void wxStatusBarPalm::SetFieldsWidth()
121 {
122 // clear the status bar
123 DeleteStatusBuffer();
124 }
125
126 void wxStatusBarPalm::SetStatusText(const wxString& strText, int nField)
127 {
128 wxCHECK_RET( (nField >= 0) && (nField < m_nFields),
129 _T("invalid statusbar field index") );
130
131 SetStatusBufferText(strText,nField);
132 DrawStatusBar();
133 }
134
135 wxString wxStatusBarPalm::GetStatusText(int nField) const
136 {
137 wxCHECK_MSG( (nField >= 0) && (nField < m_nFields), wxEmptyString,
138 _T("invalid statusbar field index") );
139
140 wxString text;
141 return text;
142 }
143
144 void wxStatusBarPalm::DrawStatusBar()
145 {
146 #if 0
147 int i=0;
148 int leftPos=0;
149 wxArrayInt widthsAbs;
150 wxString text;
151
152 RectangleType EraseRect;
153 EraseRect.topLeft.x=0;
154 EraseRect.topLeft.y=160-FntCharHeight()-1;
155 EraseRect.extent.x=159;
156 EraseRect.extent.y=159;
157 WinEraseRectangle(&EraseRect,0);
158
159 if(m_nFields>0)
160 widthsAbs=CalculateAbsWidths(160 - 2*(m_nFields - 1));
161
162 for(i=0;i<m_nFields;i++)
163 {
164 text=GetStatusBufferText(i);
165 WinDrawTruncChars(text,StrLen(text),leftPos,160-FntCharHeight(),widthsAbs[i]);
166 leftPos+=widthsAbs[i]+2;
167 }
168 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
169 #endif
170 }
171
172 void wxStatusBarPalm::SetStatusBufferText(const wxString& text, int number)
173 {
174 wxListString* st = GetOrCreateStatusBuffer(number);
175
176 wxString tmp1(text);
177 wxString* tmp = new wxString(tmp1);
178 st->Insert(tmp);
179 }
180
181 wxString wxStatusBarPalm::GetStatusBufferText(int number)
182 {
183 wxListString *st = GetStatusBufferStack(number);
184 if(st==0)
185 return wxEmptyString;
186
187 wxListString::compatibility_iterator top = st->GetFirst();
188 return(*top->GetData());
189 }
190
191 wxListString *wxStatusBarPalm::GetOrCreateStatusBuffer(int i)
192 {
193 if(!StatusTextBuffer)
194 {
195 StatusTextBuffer = new wxListString*[m_nFields];
196
197 size_t j;
198 for(j = 0; j < (size_t)m_nFields; ++j) StatusTextBuffer[j] = 0;
199 }
200
201 if(!StatusTextBuffer[i])
202 {
203 StatusTextBuffer[i] = new wxListString();
204 }
205 else
206 {
207 wxListString *st=StatusTextBuffer[i];
208 wxListString::compatibility_iterator top = st->GetFirst();
209 delete top->GetData();
210 st->Erase(top);
211 delete st;
212
213 StatusTextBuffer[i] = new wxListString();
214 }
215
216 return StatusTextBuffer[i];
217 }
218
219 wxListString *wxStatusBarPalm::GetStatusBufferStack(int i) const
220 {
221 if(!StatusTextBuffer)
222 return 0;
223 return StatusTextBuffer[i];
224 }
225
226 void wxStatusBarPalm::DeleteStatusBuffer()
227 {
228 if(!StatusTextBuffer)
229 {
230 return;
231 }
232
233 for(int i=0;i<m_nFields;i++)
234 {
235 if(StatusTextBuffer[i])
236 {
237 wxListString *st=StatusTextBuffer[i];
238 wxListString::compatibility_iterator top = st->GetFirst();
239 delete top->GetData();
240 st->Erase(top);
241 delete st;
242 StatusTextBuffer[i]=0;
243 }
244 }
245 delete[] m_statusTextStacks;
246 }
247
248 int wxStatusBarPalm::GetBorderX() const
249 {
250 return 0;
251 }
252
253 int wxStatusBarPalm::GetBorderY() const
254 {
255 return 0;
256 }
257
258 void wxStatusBarPalm::SetMinHeight(int height)
259 {
260 }
261
262 bool wxStatusBarPalm::GetFieldRect(int i, wxRect& rect) const
263 {
264 }
265
266 void wxStatusBarPalm::DoMoveWindow(int x, int y, int width, int height)
267 {
268 }
269
270 #endif // wxUSE_NATIVE_STATUSBAR