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