]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/statbrpalm.cpp
added wxAuiNotebook::Split() documentation
[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
88a7a4e1
WS
19#if wxUSE_NATIVE_STATUSBAR
20
21#include "wx/statusbr.h"
22
ffecfa5a 23#ifndef WX_PRECOMP
521bf4ff
WS
24 #include "wx/frame.h"
25 #include "wx/settings.h"
26 #include "wx/dcclient.h"
88a7a4e1 27 #include "wx/intl.h"
e4db172a 28 #include "wx/log.h"
ffecfa5a
JS
29#endif
30
20bc5ad8
WS
31#include <StatusBar.h>
32
ffecfa5a
JS
33// ----------------------------------------------------------------------------
34// macros
35// ----------------------------------------------------------------------------
36
37// ============================================================================
38// implementation
39// ============================================================================
40
41// ----------------------------------------------------------------------------
42// wxStatusBarPalm class
43// ----------------------------------------------------------------------------
44
45wxStatusBarPalm::wxStatusBarPalm()
46{
47 SetParent(NULL);
ffecfa5a
JS
48}
49
50bool wxStatusBarPalm::Create(wxWindow *parent,
b08cd3bf
WS
51 wxWindowID id,
52 long style,
53 const wxString& name)
ffecfa5a 54{
b08cd3bf 55 wxCHECK_MSG( parent, false, wxT("status bar must have a parent") );
ffecfa5a
JS
56
57 StatusTextBuffer = NULL;
58
59 SetName(name);
60 SetParent(parent);
ba889513 61 SetId( id == wxID_ANY ? NewControlId() : id );
ffecfa5a
JS
62
63 parent->AddChild(this);
64
ffecfa5a 65 SetFieldsCount(1);
ffecfa5a 66
b08cd3bf 67 return true;
ffecfa5a
JS
68}
69
70wxStatusBarPalm::~wxStatusBarPalm()
71{
b08cd3bf
WS
72 Show();
73
ffecfa5a
JS
74 DeleteStatusBuffer();
75}
76
b08cd3bf
WS
77bool wxStatusBarPalm::IsShown() const
78{
79 return StatGetAttribute ( statAttrBarVisible , NULL );
80}
81
82bool 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
ffecfa5a
JS
103void 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
113void wxStatusBarPalm::SetStatusWidths(int n, const int widths[])
114{
115 wxStatusBarBase::SetStatusWidths(n, widths);
116
117 SetFieldsWidth();
118}
119
120void wxStatusBarPalm::SetFieldsWidth()
121{
122 // clear the status bar
123 DeleteStatusBuffer();
124}
125
126void 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
135wxString 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
144void wxStatusBarPalm::DrawStatusBar()
145{
db101bd3 146#if 0
ffecfa5a
JS
147 int i=0;
148 int leftPos=0;
149 wxArrayInt widthsAbs;
150 wxString text;
771be77f 151
ffecfa5a
JS
152 RectangleType EraseRect;
153 EraseRect.topLeft.x=0;
771be77f 154 EraseRect.topLeft.y=160-FntCharHeight()-1;
ffecfa5a 155 EraseRect.extent.x=159;
771be77f 156 EraseRect.extent.y=159;
ffecfa5a
JS
157 WinEraseRectangle(&EraseRect,0);
158
159 if(m_nFields>0)
160 widthsAbs=CalculateAbsWidths(160 - 2*(m_nFields - 1));
771be77f 161
ffecfa5a
JS
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);
db101bd3 169#endif
ffecfa5a
JS
170}
171
172void 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
181wxString wxStatusBarPalm::GetStatusBufferText(int number)
182{
183 wxListString *st = GetStatusBufferStack(number);
184 if(st==0)
db101bd3 185 return wxEmptyString;
ffecfa5a
JS
186
187 wxListString::compatibility_iterator top = st->GetFirst();
188 return(*top->GetData());
189}
190
191wxListString *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;
771be77f 212
ffecfa5a
JS
213 StatusTextBuffer[i] = new wxListString();
214 }
215
216 return StatusTextBuffer[i];
217}
218
219wxListString *wxStatusBarPalm::GetStatusBufferStack(int i) const
220{
221 if(!StatusTextBuffer)
222 return 0;
223 return StatusTextBuffer[i];
224}
225
226void wxStatusBarPalm::DeleteStatusBuffer()
227{
ffecfa5a
JS
228 if(!StatusTextBuffer)
229 {
230 return;
231 }
232
771be77f 233 for(int i=0;i<m_nFields;i++)
ffecfa5a
JS
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
248int wxStatusBarPalm::GetBorderX() const
249{
250 return 0;
251}
252
253int wxStatusBarPalm::GetBorderY() const
254{
255 return 0;
256}
257
258void wxStatusBarPalm::SetMinHeight(int height)
259{
260}
261
262bool wxStatusBarPalm::GetFieldRect(int i, wxRect& rect) const
263{
264}
265
266void wxStatusBarPalm::DoMoveWindow(int x, int y, int width, int height)
267{
268}
269
b08cd3bf 270#endif // wxUSE_NATIVE_STATUSBAR