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