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