]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/statbrpalm.cpp
Note about deprecating some wxSystemSettings members.
[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);
51 m_hWnd = 0;
52 m_windowId = 0;
53}
54
55bool wxStatusBarPalm::Create(wxWindow *parent,
b08cd3bf
WS
56 wxWindowID id,
57 long style,
58 const wxString& name)
ffecfa5a 59{
b08cd3bf 60 wxCHECK_MSG( parent, false, wxT("status bar must have a parent") );
ffecfa5a
JS
61
62 StatusTextBuffer = NULL;
63
64 SetName(name);
65 SetParent(parent);
66
67 parent->AddChild(this);
68
b08cd3bf 69 m_windowId = id == wxID_ANY ? NewControlId() : id;
ffecfa5a
JS
70
71 SetFieldsCount(1);
72 SubclassWin(m_hWnd);
73
b08cd3bf 74 return true;
ffecfa5a
JS
75}
76
77wxStatusBarPalm::~wxStatusBarPalm()
78{
b08cd3bf
WS
79 Show();
80
ffecfa5a
JS
81 DeleteStatusBuffer();
82}
83
b08cd3bf
WS
84bool wxStatusBarPalm::IsShown() const
85{
86 return StatGetAttribute ( statAttrBarVisible , NULL );
87}
88
89bool wxStatusBarPalm::Show( bool show )
90{
91 if(show)
92 {
93 // show it if hidden
94 if(IsShown())
95 return false;
96 status_t rc = StatShow();
97 wxCHECK_MSG( rc == errNone, false, wxT("cannot hide status bar") );
98 }
99 else
100 {
101 // hide it if shown
102 if(!IsShown())
103 return false;
104 status_t rc = StatHide();
105 wxCHECK_MSG( rc == errNone, false, wxT("cannot hide status bar") );
106 }
107 return true;
108}
109
ffecfa5a
JS
110void wxStatusBarPalm::SetFieldsCount(int nFields, const int *widths)
111{
112 // this is a Windows limitation
113 wxASSERT_MSG( (nFields > 0) && (nFields < 255), _T("too many fields") );
114
115 wxStatusBarBase::SetFieldsCount(nFields, widths);
116
117 SetFieldsWidth();
118}
119
120void wxStatusBarPalm::SetStatusWidths(int n, const int widths[])
121{
122 wxStatusBarBase::SetStatusWidths(n, widths);
123
124 SetFieldsWidth();
125}
126
127void wxStatusBarPalm::SetFieldsWidth()
128{
129 // clear the status bar
130 DeleteStatusBuffer();
131}
132
133void wxStatusBarPalm::SetStatusText(const wxString& strText, int nField)
134{
135 wxCHECK_RET( (nField >= 0) && (nField < m_nFields),
136 _T("invalid statusbar field index") );
137
138 SetStatusBufferText(strText,nField);
139 DrawStatusBar();
140}
141
142wxString wxStatusBarPalm::GetStatusText(int nField) const
143{
144 wxCHECK_MSG( (nField >= 0) && (nField < m_nFields), wxEmptyString,
145 _T("invalid statusbar field index") );
146
147 wxString text;
148 return text;
149}
150
151void wxStatusBarPalm::DrawStatusBar()
152{
153 int i=0;
154 int leftPos=0;
155 wxArrayInt widthsAbs;
156 wxString text;
771be77f 157
ffecfa5a
JS
158 RectangleType EraseRect;
159 EraseRect.topLeft.x=0;
771be77f 160 EraseRect.topLeft.y=160-FntCharHeight()-1;
ffecfa5a 161 EraseRect.extent.x=159;
771be77f 162 EraseRect.extent.y=159;
ffecfa5a
JS
163 WinEraseRectangle(&EraseRect,0);
164
165 if(m_nFields>0)
166 widthsAbs=CalculateAbsWidths(160 - 2*(m_nFields - 1));
771be77f 167
ffecfa5a
JS
168 for(i=0;i<m_nFields;i++)
169 {
170 text=GetStatusBufferText(i);
171 WinDrawTruncChars(text,StrLen(text),leftPos,160-FntCharHeight(),widthsAbs[i]);
172 leftPos+=widthsAbs[i]+2;
173 }
174 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
175}
176
177void wxStatusBarPalm::SetStatusBufferText(const wxString& text, int number)
178{
179 wxListString* st = GetOrCreateStatusBuffer(number);
180
181 wxString tmp1(text);
182 wxString* tmp = new wxString(tmp1);
183 st->Insert(tmp);
184}
185
186wxString wxStatusBarPalm::GetStatusBufferText(int number)
187{
188 wxListString *st = GetStatusBufferStack(number);
189 if(st==0)
190 return "";
191
192 wxListString::compatibility_iterator top = st->GetFirst();
193 return(*top->GetData());
194}
195
196wxListString *wxStatusBarPalm::GetOrCreateStatusBuffer(int i)
197{
198 if(!StatusTextBuffer)
199 {
200 StatusTextBuffer = new wxListString*[m_nFields];
201
202 size_t j;
203 for(j = 0; j < (size_t)m_nFields; ++j) StatusTextBuffer[j] = 0;
204 }
205
206 if(!StatusTextBuffer[i])
207 {
208 StatusTextBuffer[i] = new wxListString();
209 }
210 else
211 {
212 wxListString *st=StatusTextBuffer[i];
213 wxListString::compatibility_iterator top = st->GetFirst();
214 delete top->GetData();
215 st->Erase(top);
216 delete st;
771be77f 217
ffecfa5a
JS
218 StatusTextBuffer[i] = new wxListString();
219 }
220
221 return StatusTextBuffer[i];
222}
223
224wxListString *wxStatusBarPalm::GetStatusBufferStack(int i) const
225{
226 if(!StatusTextBuffer)
227 return 0;
228 return StatusTextBuffer[i];
229}
230
231void wxStatusBarPalm::DeleteStatusBuffer()
232{
ffecfa5a
JS
233 if(!StatusTextBuffer)
234 {
235 return;
236 }
237
771be77f 238 for(int i=0;i<m_nFields;i++)
ffecfa5a
JS
239 {
240 if(StatusTextBuffer[i])
241 {
242 wxListString *st=StatusTextBuffer[i];
243 wxListString::compatibility_iterator top = st->GetFirst();
244 delete top->GetData();
245 st->Erase(top);
246 delete st;
247 StatusTextBuffer[i]=0;
248 }
249 }
250 delete[] m_statusTextStacks;
251}
252
253int wxStatusBarPalm::GetBorderX() const
254{
255 return 0;
256}
257
258int wxStatusBarPalm::GetBorderY() const
259{
260 return 0;
261}
262
263void wxStatusBarPalm::SetMinHeight(int height)
264{
265}
266
267bool wxStatusBarPalm::GetFieldRect(int i, wxRect& rect) const
268{
269}
270
271void wxStatusBarPalm::DoMoveWindow(int x, int y, int width, int height)
272{
273}
274
b08cd3bf 275#endif // wxUSE_NATIVE_STATUSBAR
ffecfa5a 276