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()
53 bool wxStatusBarPalm::Create(wxWindow
*parent
,
58 wxCHECK_MSG( parent
, false, wxT("status bar must have a parent") );
60 StatusTextBuffer
= NULL
;
64 SetId( id
== wxID_ANY
? NewControlId() : id
);
66 parent
->AddChild(this);
73 wxStatusBarPalm::~wxStatusBarPalm()
80 bool wxStatusBarPalm::IsShown() const
82 return StatGetAttribute ( statAttrBarVisible
, NULL
);
85 bool wxStatusBarPalm::Show( bool show
)
92 status_t rc
= StatShow();
93 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
100 status_t rc
= StatHide();
101 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
106 void wxStatusBarPalm::SetFieldsCount(int nFields
, const int *widths
)
108 // this is a Windows limitation
109 wxASSERT_MSG( (nFields
> 0) && (nFields
< 255), _T("too many fields") );
111 wxStatusBarBase::SetFieldsCount(nFields
, widths
);
116 void wxStatusBarPalm::SetStatusWidths(int n
, const int widths
[])
118 wxStatusBarBase::SetStatusWidths(n
, widths
);
123 void wxStatusBarPalm::SetFieldsWidth()
125 // clear the status bar
126 DeleteStatusBuffer();
129 void wxStatusBarPalm::SetStatusText(const wxString
& strText
, int nField
)
131 wxCHECK_RET( (nField
>= 0) && (nField
< m_nFields
),
132 _T("invalid statusbar field index") );
134 SetStatusBufferText(strText
,nField
);
138 wxString
wxStatusBarPalm::GetStatusText(int nField
) const
140 wxCHECK_MSG( (nField
>= 0) && (nField
< m_nFields
), wxEmptyString
,
141 _T("invalid statusbar field index") );
147 void wxStatusBarPalm::DrawStatusBar()
152 wxArrayInt widthsAbs
;
155 RectangleType EraseRect
;
156 EraseRect
.topLeft
.x
=0;
157 EraseRect
.topLeft
.y
=160-FntCharHeight()-1;
158 EraseRect
.extent
.x
=159;
159 EraseRect
.extent
.y
=159;
160 WinEraseRectangle(&EraseRect
,0);
163 widthsAbs
=CalculateAbsWidths(160 - 2*(m_nFields
- 1));
165 for(i
=0;i
<m_nFields
;i
++)
167 text
=GetStatusBufferText(i
);
168 WinDrawTruncChars(text
,StrLen(text
),leftPos
,160-FntCharHeight(),widthsAbs
[i
]);
169 leftPos
+=widthsAbs
[i
]+2;
171 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
175 void wxStatusBarPalm::SetStatusBufferText(const wxString
& text
, int number
)
177 wxListString
* st
= GetOrCreateStatusBuffer(number
);
180 wxString
* tmp
= new wxString(tmp1
);
184 wxString
wxStatusBarPalm::GetStatusBufferText(int number
)
186 wxListString
*st
= GetStatusBufferStack(number
);
188 return wxEmptyString
;
190 wxListString::compatibility_iterator top
= st
->GetFirst();
191 return(*top
->GetData());
194 wxListString
*wxStatusBarPalm::GetOrCreateStatusBuffer(int i
)
196 if(!StatusTextBuffer
)
198 StatusTextBuffer
= new wxListString
*[m_nFields
];
201 for(j
= 0; j
< (size_t)m_nFields
; ++j
) StatusTextBuffer
[j
] = 0;
204 if(!StatusTextBuffer
[i
])
206 StatusTextBuffer
[i
] = new wxListString();
210 wxListString
*st
=StatusTextBuffer
[i
];
211 wxListString::compatibility_iterator top
= st
->GetFirst();
212 delete top
->GetData();
216 StatusTextBuffer
[i
] = new wxListString();
219 return StatusTextBuffer
[i
];
222 wxListString
*wxStatusBarPalm::GetStatusBufferStack(int i
) const
224 if(!StatusTextBuffer
)
226 return StatusTextBuffer
[i
];
229 void wxStatusBarPalm::DeleteStatusBuffer()
231 if(!StatusTextBuffer
)
236 for(int i
=0;i
<m_nFields
;i
++)
238 if(StatusTextBuffer
[i
])
240 wxListString
*st
=StatusTextBuffer
[i
];
241 wxListString::compatibility_iterator top
= st
->GetFirst();
242 delete top
->GetData();
245 StatusTextBuffer
[i
]=0;
248 delete[] m_statusTextStacks
;
251 int wxStatusBarPalm::GetBorderX() const
256 int wxStatusBarPalm::GetBorderY() const
261 void wxStatusBarPalm::SetMinHeight(int height
)
265 bool wxStatusBarPalm::GetFieldRect(int i
, wxRect
& rect
) const
269 void wxStatusBarPalm::DoMoveWindow(int x
, int y
, int width
, int height
)
273 #endif // wxUSE_NATIVE_STATUSBAR