]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/statbrpalm.cpp
Build fixes.
[wxWidgets.git] / src / palmos / statbrpalm.cpp
CommitLineData
ffecfa5a 1///////////////////////////////////////////////////////////////////////////////
771be77f 2// Name: palmos/statbrpalm.cpp
ffecfa5a
JS
3// Purpose: Implementation of wxStatusBar for PalmOS
4// Author: William Osborne
5// Modified by:
6// Created: 10/13/04
771be77f 7// RCS-ID: $Id:
ffecfa5a
JS
8// Copyright: (c) William Osborne
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
771be77f 30#if wxUSE_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,
56 wxWindowID id,
57 long style,
58 const wxString& name)
59{
60 wxCHECK_MSG( parent, FALSE, wxT("status bar must have a parent") );
61
62 StatusTextBuffer = NULL;
63
64 SetName(name);
65 SetParent(parent);
66
67 parent->AddChild(this);
68
69 m_windowId = id == -1 ? NewControlId() : id;
70
71 SetFieldsCount(1);
72 SubclassWin(m_hWnd);
73
74 return TRUE;
75}
76
77wxStatusBarPalm::~wxStatusBarPalm()
78{
79 DeleteStatusBuffer();
80}
81
82void wxStatusBarPalm::SetFieldsCount(int nFields, const int *widths)
83{
84 // this is a Windows limitation
85 wxASSERT_MSG( (nFields > 0) && (nFields < 255), _T("too many fields") );
86
87 wxStatusBarBase::SetFieldsCount(nFields, widths);
88
89 SetFieldsWidth();
90}
91
92void wxStatusBarPalm::SetStatusWidths(int n, const int widths[])
93{
94 wxStatusBarBase::SetStatusWidths(n, widths);
95
96 SetFieldsWidth();
97}
98
99void wxStatusBarPalm::SetFieldsWidth()
100{
101 // clear the status bar
102 DeleteStatusBuffer();
103}
104
105void wxStatusBarPalm::SetStatusText(const wxString& strText, int nField)
106{
107 wxCHECK_RET( (nField >= 0) && (nField < m_nFields),
108 _T("invalid statusbar field index") );
109
110 SetStatusBufferText(strText,nField);
111 DrawStatusBar();
112}
113
114wxString wxStatusBarPalm::GetStatusText(int nField) const
115{
116 wxCHECK_MSG( (nField >= 0) && (nField < m_nFields), wxEmptyString,
117 _T("invalid statusbar field index") );
118
119 wxString text;
120 return text;
121}
122
123void wxStatusBarPalm::DrawStatusBar()
124{
125 int i=0;
126 int leftPos=0;
127 wxArrayInt widthsAbs;
128 wxString text;
771be77f 129
ffecfa5a
JS
130 RectangleType EraseRect;
131 EraseRect.topLeft.x=0;
771be77f 132 EraseRect.topLeft.y=160-FntCharHeight()-1;
ffecfa5a 133 EraseRect.extent.x=159;
771be77f 134 EraseRect.extent.y=159;
ffecfa5a
JS
135 WinEraseRectangle(&EraseRect,0);
136
137 if(m_nFields>0)
138 widthsAbs=CalculateAbsWidths(160 - 2*(m_nFields - 1));
771be77f 139
ffecfa5a
JS
140 for(i=0;i<m_nFields;i++)
141 {
142 text=GetStatusBufferText(i);
143 WinDrawTruncChars(text,StrLen(text),leftPos,160-FntCharHeight(),widthsAbs[i]);
144 leftPos+=widthsAbs[i]+2;
145 }
146 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
147}
148
149void wxStatusBarPalm::SetStatusBufferText(const wxString& text, int number)
150{
151 wxListString* st = GetOrCreateStatusBuffer(number);
152
153 wxString tmp1(text);
154 wxString* tmp = new wxString(tmp1);
155 st->Insert(tmp);
156}
157
158wxString wxStatusBarPalm::GetStatusBufferText(int number)
159{
160 wxListString *st = GetStatusBufferStack(number);
161 if(st==0)
162 return "";
163
164 wxListString::compatibility_iterator top = st->GetFirst();
165 return(*top->GetData());
166}
167
168wxListString *wxStatusBarPalm::GetOrCreateStatusBuffer(int i)
169{
170 if(!StatusTextBuffer)
171 {
172 StatusTextBuffer = new wxListString*[m_nFields];
173
174 size_t j;
175 for(j = 0; j < (size_t)m_nFields; ++j) StatusTextBuffer[j] = 0;
176 }
177
178 if(!StatusTextBuffer[i])
179 {
180 StatusTextBuffer[i] = new wxListString();
181 }
182 else
183 {
184 wxListString *st=StatusTextBuffer[i];
185 wxListString::compatibility_iterator top = st->GetFirst();
186 delete top->GetData();
187 st->Erase(top);
188 delete st;
771be77f 189
ffecfa5a
JS
190 StatusTextBuffer[i] = new wxListString();
191 }
192
193 return StatusTextBuffer[i];
194}
195
196wxListString *wxStatusBarPalm::GetStatusBufferStack(int i) const
197{
198 if(!StatusTextBuffer)
199 return 0;
200 return StatusTextBuffer[i];
201}
202
203void wxStatusBarPalm::DeleteStatusBuffer()
204{
ffecfa5a
JS
205 if(!StatusTextBuffer)
206 {
207 return;
208 }
209
771be77f 210 for(int i=0;i<m_nFields;i++)
ffecfa5a
JS
211 {
212 if(StatusTextBuffer[i])
213 {
214 wxListString *st=StatusTextBuffer[i];
215 wxListString::compatibility_iterator top = st->GetFirst();
216 delete top->GetData();
217 st->Erase(top);
218 delete st;
219 StatusTextBuffer[i]=0;
220 }
221 }
222 delete[] m_statusTextStacks;
223}
224
225int wxStatusBarPalm::GetBorderX() const
226{
227 return 0;
228}
229
230int wxStatusBarPalm::GetBorderY() const
231{
232 return 0;
233}
234
235void wxStatusBarPalm::SetMinHeight(int height)
236{
237}
238
239bool wxStatusBarPalm::GetFieldRect(int i, wxRect& rect) const
240{
241}
242
243void wxStatusBarPalm::DoMoveWindow(int x, int y, int width, int height)
244{
245}
246
771be77f 247#endif // wxUSE_STATUSBAR
ffecfa5a 248