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"
31 #include <StatusBar.h>
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 // ============================================================================
39 // ============================================================================
41 // ----------------------------------------------------------------------------
42 // wxStatusBarPalm class
43 // ----------------------------------------------------------------------------
45 wxStatusBarPalm::wxStatusBarPalm()
50 bool wxStatusBarPalm::Create(wxWindow
*parent
,
55 wxCHECK_MSG( parent
, false, wxT("status bar must have a parent") );
57 StatusTextBuffer
= NULL
;
61 SetId( id
== wxID_ANY
? NewControlId() : id
);
63 parent
->AddChild(this);
70 wxStatusBarPalm::~wxStatusBarPalm()
77 bool wxStatusBarPalm::IsShown() const
79 return StatGetAttribute ( statAttrBarVisible
, NULL
);
82 bool wxStatusBarPalm::Show( bool show
)
89 status_t rc
= StatShow();
90 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
97 status_t rc
= StatHide();
98 wxCHECK_MSG( rc
== errNone
, false, wxT("cannot hide status bar") );
103 void wxStatusBarPalm::SetFieldsCount(int nFields
, const int *widths
)
105 // this is a Windows limitation
106 wxASSERT_MSG( (nFields
> 0) && (nFields
< 255), _T("too many fields") );
108 wxStatusBarBase::SetFieldsCount(nFields
, widths
);
113 void wxStatusBarPalm::SetStatusWidths(int n
, const int widths
[])
115 wxStatusBarBase::SetStatusWidths(n
, widths
);
120 void wxStatusBarPalm::SetFieldsWidth()
122 // clear the status bar
123 DeleteStatusBuffer();
126 void wxStatusBarPalm::SetStatusText(const wxString
& strText
, int nField
)
128 wxCHECK_RET( (nField
>= 0) && (nField
< m_nFields
),
129 _T("invalid statusbar field index") );
131 SetStatusBufferText(strText
,nField
);
135 wxString
wxStatusBarPalm::GetStatusText(int nField
) const
137 wxCHECK_MSG( (nField
>= 0) && (nField
< m_nFields
), wxEmptyString
,
138 _T("invalid statusbar field index") );
144 void wxStatusBarPalm::DrawStatusBar()
149 wxArrayInt widthsAbs
;
152 RectangleType EraseRect
;
153 EraseRect
.topLeft
.x
=0;
154 EraseRect
.topLeft
.y
=160-FntCharHeight()-1;
155 EraseRect
.extent
.x
=159;
156 EraseRect
.extent
.y
=159;
157 WinEraseRectangle(&EraseRect
,0);
160 widthsAbs
=CalculateAbsWidths(160 - 2*(m_nFields
- 1));
162 for(i
=0;i
<m_nFields
;i
++)
164 text
=GetStatusBufferText(i
);
165 WinDrawTruncChars(text
,StrLen(text
),leftPos
,160-FntCharHeight(),widthsAbs
[i
]);
166 leftPos
+=widthsAbs
[i
]+2;
168 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
172 void wxStatusBarPalm::SetStatusBufferText(const wxString
& text
, int number
)
174 wxListString
* st
= GetOrCreateStatusBuffer(number
);
177 wxString
* tmp
= new wxString(tmp1
);
181 wxString
wxStatusBarPalm::GetStatusBufferText(int number
)
183 wxListString
*st
= GetStatusBufferStack(number
);
185 return wxEmptyString
;
187 wxListString::compatibility_iterator top
= st
->GetFirst();
188 return(*top
->GetData());
191 wxListString
*wxStatusBarPalm::GetOrCreateStatusBuffer(int i
)
193 if(!StatusTextBuffer
)
195 StatusTextBuffer
= new wxListString
*[m_nFields
];
198 for(j
= 0; j
< (size_t)m_nFields
; ++j
) StatusTextBuffer
[j
] = 0;
201 if(!StatusTextBuffer
[i
])
203 StatusTextBuffer
[i
] = new wxListString();
207 wxListString
*st
=StatusTextBuffer
[i
];
208 wxListString::compatibility_iterator top
= st
->GetFirst();
209 delete top
->GetData();
213 StatusTextBuffer
[i
] = new wxListString();
216 return StatusTextBuffer
[i
];
219 wxListString
*wxStatusBarPalm::GetStatusBufferStack(int i
) const
221 if(!StatusTextBuffer
)
223 return StatusTextBuffer
[i
];
226 void wxStatusBarPalm::DeleteStatusBuffer()
228 if(!StatusTextBuffer
)
233 for(int i
=0;i
<m_nFields
;i
++)
235 if(StatusTextBuffer
[i
])
237 wxListString
*st
=StatusTextBuffer
[i
];
238 wxListString::compatibility_iterator top
= st
->GetFirst();
239 delete top
->GetData();
242 StatusTextBuffer
[i
]=0;
245 delete[] m_statusTextStacks
;
248 int wxStatusBarPalm::GetBorderX() const
253 int wxStatusBarPalm::GetBorderY() const
258 void wxStatusBarPalm::SetMinHeight(int height
)
262 bool wxStatusBarPalm::GetFieldRect(int i
, wxRect
& rect
) const
266 void wxStatusBarPalm::DoMoveWindow(int x
, int y
, int width
, int height
)
270 #endif // wxUSE_NATIVE_STATUSBAR