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
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
22 #include "wx/settings.h"
23 #include "wx/dcclient.h"
26 #if wxUSE_NATIVE_STATUSBAR
30 #include "wx/statusbr.h"
32 #include <StatusBar.h>
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 // ============================================================================
40 // ============================================================================
42 // ----------------------------------------------------------------------------
43 // wxStatusBarPalm class
44 // ----------------------------------------------------------------------------
46 wxStatusBarPalm::wxStatusBarPalm()
51 bool wxStatusBarPalm::Create(wxWindow
*parent
,
56 wxCHECK_MSG( parent
, false, wxT("status bar must have a parent") );
58 StatusTextBuffer
= NULL
;
62 SetId( id
== wxID_ANY
? NewControlId() : id
);
64 parent
->AddChild(this);
71 wxStatusBarPalm::~wxStatusBarPalm()
78 bool wxStatusBarPalm::IsShown() const
80 return StatGetAttribute ( statAttrBarVisible
, NULL
);
83 bool wxStatusBarPalm::Show( bool show
)
90 status_t rc
= StatShow();
91 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
98 status_t rc
= StatHide();
99 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
104 void wxStatusBarPalm::SetFieldsCount(int nFields
, const int *widths
)
106 // this is a Windows limitation
107 wxASSERT_MSG( (nFields
> 0) && (nFields
< 255), _T("too many fields") );
109 wxStatusBarBase::SetFieldsCount(nFields
, widths
);
114 void wxStatusBarPalm::SetStatusWidths(int n
, const int widths
[])
116 wxStatusBarBase::SetStatusWidths(n
, widths
);
121 void wxStatusBarPalm::SetFieldsWidth()
123 // clear the status bar
124 DeleteStatusBuffer();
127 void wxStatusBarPalm::SetStatusText(const wxString
& strText
, int nField
)
129 wxCHECK_RET( (nField
>= 0) && (nField
< m_nFields
),
130 _T("invalid statusbar field index") );
132 SetStatusBufferText(strText
,nField
);
136 wxString
wxStatusBarPalm::GetStatusText(int nField
) const
138 wxCHECK_MSG( (nField
>= 0) && (nField
< m_nFields
), wxEmptyString
,
139 _T("invalid statusbar field index") );
145 void wxStatusBarPalm::DrawStatusBar()
150 wxArrayInt widthsAbs
;
153 RectangleType EraseRect
;
154 EraseRect
.topLeft
.x
=0;
155 EraseRect
.topLeft
.y
=160-FntCharHeight()-1;
156 EraseRect
.extent
.x
=159;
157 EraseRect
.extent
.y
=159;
158 WinEraseRectangle(&EraseRect
,0);
161 widthsAbs
=CalculateAbsWidths(160 - 2*(m_nFields
- 1));
163 for(i
=0;i
<m_nFields
;i
++)
165 text
=GetStatusBufferText(i
);
166 WinDrawTruncChars(text
,StrLen(text
),leftPos
,160-FntCharHeight(),widthsAbs
[i
]);
167 leftPos
+=widthsAbs
[i
]+2;
169 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
173 void wxStatusBarPalm::SetStatusBufferText(const wxString
& text
, int number
)
175 wxListString
* st
= GetOrCreateStatusBuffer(number
);
178 wxString
* tmp
= new wxString(tmp1
);
182 wxString
wxStatusBarPalm::GetStatusBufferText(int number
)
184 wxListString
*st
= GetStatusBufferStack(number
);
186 return wxEmptyString
;
188 wxListString::compatibility_iterator top
= st
->GetFirst();
189 return(*top
->GetData());
192 wxListString
*wxStatusBarPalm::GetOrCreateStatusBuffer(int i
)
194 if(!StatusTextBuffer
)
196 StatusTextBuffer
= new wxListString
*[m_nFields
];
199 for(j
= 0; j
< (size_t)m_nFields
; ++j
) StatusTextBuffer
[j
] = 0;
202 if(!StatusTextBuffer
[i
])
204 StatusTextBuffer
[i
] = new wxListString();
208 wxListString
*st
=StatusTextBuffer
[i
];
209 wxListString::compatibility_iterator top
= st
->GetFirst();
210 delete top
->GetData();
214 StatusTextBuffer
[i
] = new wxListString();
217 return StatusTextBuffer
[i
];
220 wxListString
*wxStatusBarPalm::GetStatusBufferStack(int i
) const
222 if(!StatusTextBuffer
)
224 return StatusTextBuffer
[i
];
227 void wxStatusBarPalm::DeleteStatusBuffer()
229 if(!StatusTextBuffer
)
234 for(int i
=0;i
<m_nFields
;i
++)
236 if(StatusTextBuffer
[i
])
238 wxListString
*st
=StatusTextBuffer
[i
];
239 wxListString::compatibility_iterator top
= st
->GetFirst();
240 delete top
->GetData();
243 StatusTextBuffer
[i
]=0;
246 delete[] m_statusTextStacks
;
249 int wxStatusBarPalm::GetBorderX() const
254 int wxStatusBarPalm::GetBorderY() const
259 void wxStatusBarPalm::SetMinHeight(int height
)
263 bool wxStatusBarPalm::GetFieldRect(int i
, wxRect
& rect
) const
267 void wxStatusBarPalm::DoMoveWindow(int x
, int y
, int width
, int height
)
271 #endif // wxUSE_NATIVE_STATUSBAR