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"
19 #if wxUSE_NATIVE_STATUSBAR
21 #include "wx/statusbr.h"
25 #include "wx/settings.h"
26 #include "wx/dcclient.h"
32 #include <StatusBar.h>
34 #include <PenInputMgr.h>
35 #endif // __WXPALMOS6__
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 // ============================================================================
43 // ============================================================================
45 // ----------------------------------------------------------------------------
46 // wxStatusBarPalm class
47 // ----------------------------------------------------------------------------
49 wxStatusBarPalm::wxStatusBarPalm()
54 bool wxStatusBarPalm::Create(wxWindow
*parent
,
59 wxCHECK_MSG( parent
, false, wxT("status bar must have a parent") );
61 StatusTextBuffer
= NULL
;
65 SetId( id
== wxID_ANY
? NewControlId() : id
);
67 parent
->AddChild(this);
74 wxStatusBarPalm::~wxStatusBarPalm()
81 bool wxStatusBarPalm::IsShown() const
83 return StatGetAttribute ( statAttrBarVisible
, NULL
);
86 bool wxStatusBarPalm::Show( bool show
)
93 status_t rc
= StatShow();
94 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
101 status_t rc
= StatHide();
102 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
107 void wxStatusBarPalm::SetFieldsCount(int nFields
, const int *widths
)
109 // this is a Windows limitation
110 wxASSERT_MSG( (nFields
> 0) && (nFields
< 255), _T("too many fields") );
112 wxStatusBarBase::SetFieldsCount(nFields
, widths
);
117 void wxStatusBarPalm::SetStatusWidths(int n
, const int widths
[])
119 wxStatusBarBase::SetStatusWidths(n
, widths
);
124 void wxStatusBarPalm::SetFieldsWidth()
126 // clear the status bar
127 DeleteStatusBuffer();
130 void wxStatusBarPalm::SetStatusText(const wxString
& strText
, int nField
)
132 wxCHECK_RET( (nField
>= 0) && (nField
< m_nFields
),
133 _T("invalid statusbar field index") );
135 SetStatusBufferText(strText
,nField
);
139 wxString
wxStatusBarPalm::GetStatusText(int nField
) const
141 wxCHECK_MSG( (nField
>= 0) && (nField
< m_nFields
), wxEmptyString
,
142 _T("invalid statusbar field index") );
148 void wxStatusBarPalm::DrawStatusBar()
153 wxArrayInt widthsAbs
;
156 RectangleType EraseRect
;
157 EraseRect
.topLeft
.x
=0;
158 EraseRect
.topLeft
.y
=160-FntCharHeight()-1;
159 EraseRect
.extent
.x
=159;
160 EraseRect
.extent
.y
=159;
161 WinEraseRectangle(&EraseRect
,0);
164 widthsAbs
=CalculateAbsWidths(160 - 2*(m_nFields
- 1));
166 for(i
=0;i
<m_nFields
;i
++)
168 text
=GetStatusBufferText(i
);
169 WinDrawTruncChars(text
,StrLen(text
),leftPos
,160-FntCharHeight(),widthsAbs
[i
]);
170 leftPos
+=widthsAbs
[i
]+2;
172 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
176 void wxStatusBarPalm::SetStatusBufferText(const wxString
& text
, int number
)
178 wxListString
* st
= GetOrCreateStatusBuffer(number
);
181 wxString
* tmp
= new wxString(tmp1
);
185 wxString
wxStatusBarPalm::GetStatusBufferText(int number
)
187 wxListString
*st
= GetStatusBufferStack(number
);
189 return wxEmptyString
;
191 wxListString::compatibility_iterator top
= st
->GetFirst();
192 return(*top
->GetData());
195 wxListString
*wxStatusBarPalm::GetOrCreateStatusBuffer(int i
)
197 if(!StatusTextBuffer
)
199 StatusTextBuffer
= new wxListString
*[m_nFields
];
202 for(j
= 0; j
< (size_t)m_nFields
; ++j
) StatusTextBuffer
[j
] = 0;
205 if(!StatusTextBuffer
[i
])
207 StatusTextBuffer
[i
] = new wxListString();
211 wxListString
*st
=StatusTextBuffer
[i
];
212 wxListString::compatibility_iterator top
= st
->GetFirst();
213 delete top
->GetData();
217 StatusTextBuffer
[i
] = new wxListString();
220 return StatusTextBuffer
[i
];
223 wxListString
*wxStatusBarPalm::GetStatusBufferStack(int i
) const
225 if(!StatusTextBuffer
)
227 return StatusTextBuffer
[i
];
230 void wxStatusBarPalm::DeleteStatusBuffer()
232 if(!StatusTextBuffer
)
237 for(int i
=0;i
<m_nFields
;i
++)
239 if(StatusTextBuffer
[i
])
241 wxListString
*st
=StatusTextBuffer
[i
];
242 wxListString::compatibility_iterator top
= st
->GetFirst();
243 delete top
->GetData();
246 StatusTextBuffer
[i
]=0;
249 delete[] m_statusTextStacks
;
252 int wxStatusBarPalm::GetBorderX() const
257 int wxStatusBarPalm::GetBorderY() const
262 void wxStatusBarPalm::SetMinHeight(int height
)
266 bool wxStatusBarPalm::GetFieldRect(int i
, wxRect
& rect
) const
270 void wxStatusBarPalm::DoMoveWindow(int x
, int y
, int width
, int height
)
274 #endif // wxUSE_NATIVE_STATUSBAR