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
;
67 parent
->AddChild(this);
69 m_windowId
= id
== wxID_ANY
? NewControlId() : id
;
77 wxStatusBarPalm::~wxStatusBarPalm()
84 bool wxStatusBarPalm::IsShown() const
86 return StatGetAttribute ( statAttrBarVisible
, NULL
);
89 bool wxStatusBarPalm::Show( bool show
)
96 status_t rc
= StatShow();
97 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
104 status_t rc
= StatHide();
105 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
110 void wxStatusBarPalm::SetFieldsCount(int nFields
, const int *widths
)
112 // this is a Windows limitation
113 wxASSERT_MSG( (nFields
> 0) && (nFields
< 255), _T("too many fields") );
115 wxStatusBarBase::SetFieldsCount(nFields
, widths
);
120 void wxStatusBarPalm::SetStatusWidths(int n
, const int widths
[])
122 wxStatusBarBase::SetStatusWidths(n
, widths
);
127 void wxStatusBarPalm::SetFieldsWidth()
129 // clear the status bar
130 DeleteStatusBuffer();
133 void wxStatusBarPalm::SetStatusText(const wxString
& strText
, int nField
)
135 wxCHECK_RET( (nField
>= 0) && (nField
< m_nFields
),
136 _T("invalid statusbar field index") );
138 SetStatusBufferText(strText
,nField
);
142 wxString
wxStatusBarPalm::GetStatusText(int nField
) const
144 wxCHECK_MSG( (nField
>= 0) && (nField
< m_nFields
), wxEmptyString
,
145 _T("invalid statusbar field index") );
151 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);
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
);
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