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), wxT("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::DoUpdateStatusText(int nField
)
132 SetStatusBufferText(strText
,nField
);
136 void wxStatusBarPalm::DrawStatusBar()
141 wxArrayInt widthsAbs
;
144 RectangleType EraseRect
;
145 EraseRect
.topLeft
.x
=0;
146 EraseRect
.topLeft
.y
=160-FntCharHeight()-1;
147 EraseRect
.extent
.x
=159;
148 EraseRect
.extent
.y
=159;
149 WinEraseRectangle(&EraseRect
,0);
152 widthsAbs
=CalculateAbsWidths(160 - 2*(m_nFields
- 1));
154 for(i
=0;i
<m_nFields
;i
++)
156 text
=GetStatusBufferText(i
);
157 WinDrawTruncChars(text
,StrLen(text
),leftPos
,160-FntCharHeight(),widthsAbs
[i
]);
158 leftPos
+=widthsAbs
[i
]+2;
160 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
164 void wxStatusBarPalm::SetStatusBufferText(const wxString
& text
, int number
)
166 wxListString
* st
= GetOrCreateStatusBuffer(number
);
169 wxString
* tmp
= new wxString(tmp1
);
173 wxString
wxStatusBarPalm::GetStatusBufferText(int number
)
175 wxListString
*st
= GetStatusBufferStack(number
);
177 return wxEmptyString
;
179 wxListString::compatibility_iterator top
= st
->GetFirst();
180 return(*top
->GetData());
183 wxListString
*wxStatusBarPalm::GetOrCreateStatusBuffer(int i
)
185 if(!StatusTextBuffer
)
187 StatusTextBuffer
= new wxListString
*[m_nFields
];
190 for(j
= 0; j
< (size_t)m_nFields
; ++j
) StatusTextBuffer
[j
] = 0;
193 if(!StatusTextBuffer
[i
])
195 StatusTextBuffer
[i
] = new wxListString();
199 wxListString
*st
=StatusTextBuffer
[i
];
200 wxListString::compatibility_iterator top
= st
->GetFirst();
201 delete top
->GetData();
205 StatusTextBuffer
[i
] = new wxListString();
208 return StatusTextBuffer
[i
];
211 wxListString
*wxStatusBarPalm::GetStatusBufferStack(int i
) const
213 if(!StatusTextBuffer
)
215 return StatusTextBuffer
[i
];
218 void wxStatusBarPalm::DeleteStatusBuffer()
220 if(!StatusTextBuffer
)
225 for(int i
=0;i
<m_nFields
;i
++)
227 if(StatusTextBuffer
[i
])
229 wxListString
*st
=StatusTextBuffer
[i
];
230 wxListString::compatibility_iterator top
= st
->GetFirst();
231 delete top
->GetData();
234 StatusTextBuffer
[i
]=0;
237 delete[] m_statusTextStacks
;
240 int wxStatusBarPalm::GetBorderX() const
245 int wxStatusBarPalm::GetBorderY() const
250 void wxStatusBarPalm::SetMinHeight(int height
)
254 bool wxStatusBarPalm::GetFieldRect(int i
, wxRect
& rect
) const
258 void wxStatusBarPalm::DoMoveWindow(int x
, int y
, int width
, int height
)
262 #endif // wxUSE_NATIVE_STATUSBAR