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