]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/palmos/statbrpalm.cpp | |
3 | // Purpose: Implementation of wxStatusBar for PalmOS | |
4 | // Author: William Osborne - minimal working wxPalmOS port | |
5 | // Modified by: Wlodzimierz ABX Skiba - transition from faked drawing to native statusbar | |
6 | // Created: 10/13/04 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) William Osborne, Wlodzimierz Skiba | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // for compilers that support precompilation, includes "wx.h". | |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #if wxUSE_NATIVE_STATUSBAR | |
20 | ||
21 | #include "wx/statusbr.h" | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include "wx/frame.h" | |
25 | #include "wx/settings.h" | |
26 | #include "wx/dcclient.h" | |
27 | #include "wx/intl.h" | |
28 | #include "wx/log.h" | |
29 | #endif | |
30 | ||
31 | #ifdef __WXPALMOS6__ | |
32 | #include <StatusBar.h> | |
33 | #else | |
34 | #include <PenInputMgr.h> | |
35 | #endif // __WXPALMOS6__ | |
36 | ||
37 | // ---------------------------------------------------------------------------- | |
38 | // macros | |
39 | // ---------------------------------------------------------------------------- | |
40 | ||
41 | // ============================================================================ | |
42 | // implementation | |
43 | // ============================================================================ | |
44 | ||
45 | // ---------------------------------------------------------------------------- | |
46 | // wxStatusBarPalm class | |
47 | // ---------------------------------------------------------------------------- | |
48 | ||
49 | wxStatusBarPalm::wxStatusBarPalm() | |
50 | { | |
51 | SetParent(NULL); | |
52 | } | |
53 | ||
54 | bool wxStatusBarPalm::Create(wxWindow *parent, | |
55 | wxWindowID id, | |
56 | long style, | |
57 | const wxString& name) | |
58 | { | |
59 | wxCHECK_MSG( parent, false, wxT("status bar must have a parent") ); | |
60 | ||
61 | StatusTextBuffer = NULL; | |
62 | ||
63 | SetName(name); | |
64 | SetParent(parent); | |
65 | SetId( id == wxID_ANY ? NewControlId() : id ); | |
66 | ||
67 | parent->AddChild(this); | |
68 | ||
69 | SetFieldsCount(1); | |
70 | ||
71 | return true; | |
72 | } | |
73 | ||
74 | wxStatusBarPalm::~wxStatusBarPalm() | |
75 | { | |
76 | Show(); | |
77 | ||
78 | DeleteStatusBuffer(); | |
79 | } | |
80 | ||
81 | bool wxStatusBarPalm::IsShown() const | |
82 | { | |
83 | return StatGetAttribute ( statAttrBarVisible , NULL ); | |
84 | } | |
85 | ||
86 | bool 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 | ||
107 | void wxStatusBarPalm::SetFieldsCount(int nFields, const int *widths) | |
108 | { | |
109 | // this is a Windows limitation | |
110 | wxASSERT_MSG( (nFields > 0) && (nFields < 255), wxT("too many fields") ); | |
111 | ||
112 | wxStatusBarBase::SetFieldsCount(nFields, widths); | |
113 | ||
114 | SetFieldsWidth(); | |
115 | } | |
116 | ||
117 | void wxStatusBarPalm::SetStatusWidths(int n, const int widths[]) | |
118 | { | |
119 | wxStatusBarBase::SetStatusWidths(n, widths); | |
120 | ||
121 | SetFieldsWidth(); | |
122 | } | |
123 | ||
124 | void wxStatusBarPalm::SetFieldsWidth() | |
125 | { | |
126 | // clear the status bar | |
127 | DeleteStatusBuffer(); | |
128 | } | |
129 | ||
130 | void wxStatusBarPalm::DoUpdateStatusText(int nField) | |
131 | { | |
132 | SetStatusBufferText(strText,nField); | |
133 | DrawStatusBar(); | |
134 | } | |
135 | ||
136 | void wxStatusBarPalm::DrawStatusBar() | |
137 | { | |
138 | #if 0 | |
139 | int i=0; | |
140 | int leftPos=0; | |
141 | wxArrayInt widthsAbs; | |
142 | wxString text; | |
143 | ||
144 | RectangleType EraseRect; | |
145 | EraseRect.topLeft.x=0; | |
146 | EraseRect.topLeft.y=160-FntCharHeight()-1; | |
147 | EraseRect.extent.x=159; | |
148 | EraseRect.extent.y=159; | |
149 | WinEraseRectangle(&EraseRect,0); | |
150 | ||
151 | if(m_nFields>0) | |
152 | widthsAbs=CalculateAbsWidths(160 - 2*(m_nFields - 1)); | |
153 | ||
154 | for(i=0;i<m_nFields;i++) | |
155 | { | |
156 | text=GetStatusBufferText(i); | |
157 | WinDrawTruncChars(text,StrLen(text),leftPos,160-FntCharHeight(),widthsAbs[i]); | |
158 | leftPos+=widthsAbs[i]+2; | |
159 | } | |
160 | WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1); | |
161 | #endif | |
162 | } | |
163 | ||
164 | void wxStatusBarPalm::SetStatusBufferText(const wxString& text, int number) | |
165 | { | |
166 | wxListString* st = GetOrCreateStatusBuffer(number); | |
167 | ||
168 | wxString tmp1(text); | |
169 | wxString* tmp = new wxString(tmp1); | |
170 | st->Insert(tmp); | |
171 | } | |
172 | ||
173 | wxString wxStatusBarPalm::GetStatusBufferText(int number) | |
174 | { | |
175 | wxListString *st = GetStatusBufferStack(number); | |
176 | if(st==0) | |
177 | return wxEmptyString; | |
178 | ||
179 | wxListString::compatibility_iterator top = st->GetFirst(); | |
180 | return(*top->GetData()); | |
181 | } | |
182 | ||
183 | wxListString *wxStatusBarPalm::GetOrCreateStatusBuffer(int i) | |
184 | { | |
185 | if(!StatusTextBuffer) | |
186 | { | |
187 | StatusTextBuffer = new wxListString*[m_nFields]; | |
188 | ||
189 | size_t j; | |
190 | for(j = 0; j < (size_t)m_nFields; ++j) StatusTextBuffer[j] = 0; | |
191 | } | |
192 | ||
193 | if(!StatusTextBuffer[i]) | |
194 | { | |
195 | StatusTextBuffer[i] = new wxListString(); | |
196 | } | |
197 | else | |
198 | { | |
199 | wxListString *st=StatusTextBuffer[i]; | |
200 | wxListString::compatibility_iterator top = st->GetFirst(); | |
201 | delete top->GetData(); | |
202 | st->Erase(top); | |
203 | delete st; | |
204 | ||
205 | StatusTextBuffer[i] = new wxListString(); | |
206 | } | |
207 | ||
208 | return StatusTextBuffer[i]; | |
209 | } | |
210 | ||
211 | wxListString *wxStatusBarPalm::GetStatusBufferStack(int i) const | |
212 | { | |
213 | if(!StatusTextBuffer) | |
214 | return 0; | |
215 | return StatusTextBuffer[i]; | |
216 | } | |
217 | ||
218 | void wxStatusBarPalm::DeleteStatusBuffer() | |
219 | { | |
220 | if(!StatusTextBuffer) | |
221 | { | |
222 | return; | |
223 | } | |
224 | ||
225 | for(int i=0;i<m_nFields;i++) | |
226 | { | |
227 | if(StatusTextBuffer[i]) | |
228 | { | |
229 | wxListString *st=StatusTextBuffer[i]; | |
230 | wxListString::compatibility_iterator top = st->GetFirst(); | |
231 | delete top->GetData(); | |
232 | st->Erase(top); | |
233 | delete st; | |
234 | StatusTextBuffer[i]=0; | |
235 | } | |
236 | } | |
237 | delete[] m_statusTextStacks; | |
238 | } | |
239 | ||
240 | int wxStatusBarPalm::GetBorderX() const | |
241 | { | |
242 | return 0; | |
243 | } | |
244 | ||
245 | int wxStatusBarPalm::GetBorderY() const | |
246 | { | |
247 | return 0; | |
248 | } | |
249 | ||
250 | void wxStatusBarPalm::SetMinHeight(int height) | |
251 | { | |
252 | } | |
253 | ||
254 | bool wxStatusBarPalm::GetFieldRect(int i, wxRect& rect) const | |
255 | { | |
256 | } | |
257 | ||
258 | void wxStatusBarPalm::DoMoveWindow(int x, int y, int width, int height) | |
259 | { | |
260 | } | |
261 | ||
262 | #endif // wxUSE_NATIVE_STATUSBAR |