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