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 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 // ============================================================================
42 // ============================================================================
44 // ----------------------------------------------------------------------------
45 // wxStatusBarPalm class
46 // ----------------------------------------------------------------------------
48 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);
76 wxStatusBarPalm::~wxStatusBarPalm()
83 bool wxStatusBarPalm::IsShown() const
85 return StatGetAttribute ( statAttrBarVisible
, NULL
);
88 bool wxStatusBarPalm::Show( bool show
)
95 status_t rc
= StatShow();
96 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
103 status_t rc
= StatHide();
104 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
109 void wxStatusBarPalm::SetFieldsCount(int nFields
, const int *widths
)
111 // this is a Windows limitation
112 wxASSERT_MSG( (nFields
> 0) && (nFields
< 255), _T("too many fields") );
114 wxStatusBarBase::SetFieldsCount(nFields
, widths
);
119 void wxStatusBarPalm::SetStatusWidths(int n
, const int widths
[])
121 wxStatusBarBase::SetStatusWidths(n
, widths
);
126 void wxStatusBarPalm::SetFieldsWidth()
128 // clear the status bar
129 DeleteStatusBuffer();
132 void wxStatusBarPalm::SetStatusText(const wxString
& strText
, int nField
)
134 wxCHECK_RET( (nField
>= 0) && (nField
< m_nFields
),
135 _T("invalid statusbar field index") );
137 SetStatusBufferText(strText
,nField
);
141 wxString
wxStatusBarPalm::GetStatusText(int nField
) const
143 wxCHECK_MSG( (nField
>= 0) && (nField
< m_nFields
), wxEmptyString
,
144 _T("invalid statusbar field index") );
150 void wxStatusBarPalm::DrawStatusBar()
155 wxArrayInt widthsAbs
;
158 RectangleType EraseRect
;
159 EraseRect
.topLeft
.x
=0;
160 EraseRect
.topLeft
.y
=160-FntCharHeight()-1;
161 EraseRect
.extent
.x
=159;
162 EraseRect
.extent
.y
=159;
163 WinEraseRectangle(&EraseRect
,0);
166 widthsAbs
=CalculateAbsWidths(160 - 2*(m_nFields
- 1));
168 for(i
=0;i
<m_nFields
;i
++)
170 text
=GetStatusBufferText(i
);
171 WinDrawTruncChars(text
,StrLen(text
),leftPos
,160-FntCharHeight(),widthsAbs
[i
]);
172 leftPos
+=widthsAbs
[i
]+2;
174 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
178 void wxStatusBarPalm::SetStatusBufferText(const wxString
& text
, int number
)
180 wxListString
* st
= GetOrCreateStatusBuffer(number
);
183 wxString
* tmp
= new wxString(tmp1
);
187 wxString
wxStatusBarPalm::GetStatusBufferText(int number
)
189 wxListString
*st
= GetStatusBufferStack(number
);
191 return wxEmptyString
;
193 wxListString::compatibility_iterator top
= st
->GetFirst();
194 return(*top
->GetData());
197 wxListString
*wxStatusBarPalm::GetOrCreateStatusBuffer(int i
)
199 if(!StatusTextBuffer
)
201 StatusTextBuffer
= new wxListString
*[m_nFields
];
204 for(j
= 0; j
< (size_t)m_nFields
; ++j
) StatusTextBuffer
[j
] = 0;
207 if(!StatusTextBuffer
[i
])
209 StatusTextBuffer
[i
] = new wxListString();
213 wxListString
*st
=StatusTextBuffer
[i
];
214 wxListString::compatibility_iterator top
= st
->GetFirst();
215 delete top
->GetData();
219 StatusTextBuffer
[i
] = new wxListString();
222 return StatusTextBuffer
[i
];
225 wxListString
*wxStatusBarPalm::GetStatusBufferStack(int i
) const
227 if(!StatusTextBuffer
)
229 return StatusTextBuffer
[i
];
232 void wxStatusBarPalm::DeleteStatusBuffer()
234 if(!StatusTextBuffer
)
239 for(int i
=0;i
<m_nFields
;i
++)
241 if(StatusTextBuffer
[i
])
243 wxListString
*st
=StatusTextBuffer
[i
];
244 wxListString::compatibility_iterator top
= st
->GetFirst();
245 delete top
->GetData();
248 StatusTextBuffer
[i
]=0;
251 delete[] m_statusTextStacks
;
254 int wxStatusBarPalm::GetBorderX() const
259 int wxStatusBarPalm::GetBorderY() const
264 void wxStatusBarPalm::SetMinHeight(int height
)
268 bool wxStatusBarPalm::GetFieldRect(int i
, wxRect
& rect
) const
272 void wxStatusBarPalm::DoMoveWindow(int x
, int y
, int width
, int height
)
276 #endif // wxUSE_NATIVE_STATUSBAR