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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "statusbr.h"
16 // for compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/settings.h"
27 #include "wx/dcclient.h"
30 #if wxUSE_NATIVE_STATUSBAR
34 #include "wx/statusbr.h"
36 #include <StatusBar.h>
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 // ============================================================================
44 // ============================================================================
46 // ----------------------------------------------------------------------------
47 // wxStatusBarPalm class
48 // ----------------------------------------------------------------------------
50 wxStatusBarPalm::wxStatusBarPalm()
55 bool wxStatusBarPalm::Create(wxWindow
*parent
,
60 wxCHECK_MSG( parent
, false, wxT("status bar must have a parent") );
62 StatusTextBuffer
= NULL
;
66 SetId( id
== wxID_ANY
? NewControlId() : id
);
68 parent
->AddChild(this);
75 wxStatusBarPalm::~wxStatusBarPalm()
82 bool wxStatusBarPalm::IsShown() const
84 return StatGetAttribute ( statAttrBarVisible
, NULL
);
87 bool wxStatusBarPalm::Show( bool show
)
94 status_t rc
= StatShow();
95 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
102 status_t rc
= StatHide();
103 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
108 void wxStatusBarPalm::SetFieldsCount(int nFields
, const int *widths
)
110 // this is a Windows limitation
111 wxASSERT_MSG( (nFields
> 0) && (nFields
< 255), _T("too many fields") );
113 wxStatusBarBase::SetFieldsCount(nFields
, widths
);
118 void wxStatusBarPalm::SetStatusWidths(int n
, const int widths
[])
120 wxStatusBarBase::SetStatusWidths(n
, widths
);
125 void wxStatusBarPalm::SetFieldsWidth()
127 // clear the status bar
128 DeleteStatusBuffer();
131 void wxStatusBarPalm::SetStatusText(const wxString
& strText
, int nField
)
133 wxCHECK_RET( (nField
>= 0) && (nField
< m_nFields
),
134 _T("invalid statusbar field index") );
136 SetStatusBufferText(strText
,nField
);
140 wxString
wxStatusBarPalm::GetStatusText(int nField
) const
142 wxCHECK_MSG( (nField
>= 0) && (nField
< m_nFields
), wxEmptyString
,
143 _T("invalid statusbar field index") );
149 void wxStatusBarPalm::DrawStatusBar()
154 wxArrayInt widthsAbs
;
157 RectangleType EraseRect
;
158 EraseRect
.topLeft
.x
=0;
159 EraseRect
.topLeft
.y
=160-FntCharHeight()-1;
160 EraseRect
.extent
.x
=159;
161 EraseRect
.extent
.y
=159;
162 WinEraseRectangle(&EraseRect
,0);
165 widthsAbs
=CalculateAbsWidths(160 - 2*(m_nFields
- 1));
167 for(i
=0;i
<m_nFields
;i
++)
169 text
=GetStatusBufferText(i
);
170 WinDrawTruncChars(text
,StrLen(text
),leftPos
,160-FntCharHeight(),widthsAbs
[i
]);
171 leftPos
+=widthsAbs
[i
]+2;
173 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
177 void wxStatusBarPalm::SetStatusBufferText(const wxString
& text
, int number
)
179 wxListString
* st
= GetOrCreateStatusBuffer(number
);
182 wxString
* tmp
= new wxString(tmp1
);
186 wxString
wxStatusBarPalm::GetStatusBufferText(int number
)
188 wxListString
*st
= GetStatusBufferStack(number
);
190 return wxEmptyString
;
192 wxListString::compatibility_iterator top
= st
->GetFirst();
193 return(*top
->GetData());
196 wxListString
*wxStatusBarPalm::GetOrCreateStatusBuffer(int i
)
198 if(!StatusTextBuffer
)
200 StatusTextBuffer
= new wxListString
*[m_nFields
];
203 for(j
= 0; j
< (size_t)m_nFields
; ++j
) StatusTextBuffer
[j
] = 0;
206 if(!StatusTextBuffer
[i
])
208 StatusTextBuffer
[i
] = new wxListString();
212 wxListString
*st
=StatusTextBuffer
[i
];
213 wxListString::compatibility_iterator top
= st
->GetFirst();
214 delete top
->GetData();
218 StatusTextBuffer
[i
] = new wxListString();
221 return StatusTextBuffer
[i
];
224 wxListString
*wxStatusBarPalm::GetStatusBufferStack(int i
) const
226 if(!StatusTextBuffer
)
228 return StatusTextBuffer
[i
];
231 void wxStatusBarPalm::DeleteStatusBuffer()
233 if(!StatusTextBuffer
)
238 for(int i
=0;i
<m_nFields
;i
++)
240 if(StatusTextBuffer
[i
])
242 wxListString
*st
=StatusTextBuffer
[i
];
243 wxListString::compatibility_iterator top
= st
->GetFirst();
244 delete top
->GetData();
247 StatusTextBuffer
[i
]=0;
250 delete[] m_statusTextStacks
;
253 int wxStatusBarPalm::GetBorderX() const
258 int wxStatusBarPalm::GetBorderY() const
263 void wxStatusBarPalm::SetMinHeight(int height
)
267 bool wxStatusBarPalm::GetFieldRect(int i
, wxRect
& rect
) const
271 void wxStatusBarPalm::DoMoveWindow(int x
, int y
, int width
, int height
)
275 #endif // wxUSE_NATIVE_STATUSBAR