1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/statbrpalm.cpp
3 // Purpose: Implementation of wxStatusBar for PalmOS
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
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"
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
== -1 ? NewControlId() : id
;
77 wxStatusBarPalm::~wxStatusBarPalm()
82 void wxStatusBarPalm::SetFieldsCount(int nFields
, const int *widths
)
84 // this is a Windows limitation
85 wxASSERT_MSG( (nFields
> 0) && (nFields
< 255), _T("too many fields") );
87 wxStatusBarBase::SetFieldsCount(nFields
, widths
);
92 void wxStatusBarPalm::SetStatusWidths(int n
, const int widths
[])
94 wxStatusBarBase::SetStatusWidths(n
, widths
);
99 void wxStatusBarPalm::SetFieldsWidth()
101 // clear the status bar
102 DeleteStatusBuffer();
105 void wxStatusBarPalm::SetStatusText(const wxString
& strText
, int nField
)
107 wxCHECK_RET( (nField
>= 0) && (nField
< m_nFields
),
108 _T("invalid statusbar field index") );
110 SetStatusBufferText(strText
,nField
);
114 wxString
wxStatusBarPalm::GetStatusText(int nField
) const
116 wxCHECK_MSG( (nField
>= 0) && (nField
< m_nFields
), wxEmptyString
,
117 _T("invalid statusbar field index") );
123 void wxStatusBarPalm::DrawStatusBar()
127 wxArrayInt widthsAbs
;
130 RectangleType EraseRect
;
131 EraseRect
.topLeft
.x
=0;
132 EraseRect
.topLeft
.y
=160-FntCharHeight()-1;
133 EraseRect
.extent
.x
=159;
134 EraseRect
.extent
.y
=159;
135 WinEraseRectangle(&EraseRect
,0);
138 widthsAbs
=CalculateAbsWidths(160 - 2*(m_nFields
- 1));
140 for(i
=0;i
<m_nFields
;i
++)
142 text
=GetStatusBufferText(i
);
143 WinDrawTruncChars(text
,StrLen(text
),leftPos
,160-FntCharHeight(),widthsAbs
[i
]);
144 leftPos
+=widthsAbs
[i
]+2;
146 WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
149 void wxStatusBarPalm::SetStatusBufferText(const wxString
& text
, int number
)
151 wxListString
* st
= GetOrCreateStatusBuffer(number
);
154 wxString
* tmp
= new wxString(tmp1
);
158 wxString
wxStatusBarPalm::GetStatusBufferText(int number
)
160 wxListString
*st
= GetStatusBufferStack(number
);
164 wxListString::compatibility_iterator top
= st
->GetFirst();
165 return(*top
->GetData());
168 wxListString
*wxStatusBarPalm::GetOrCreateStatusBuffer(int i
)
170 if(!StatusTextBuffer
)
172 StatusTextBuffer
= new wxListString
*[m_nFields
];
175 for(j
= 0; j
< (size_t)m_nFields
; ++j
) StatusTextBuffer
[j
] = 0;
178 if(!StatusTextBuffer
[i
])
180 StatusTextBuffer
[i
] = new wxListString();
184 wxListString
*st
=StatusTextBuffer
[i
];
185 wxListString::compatibility_iterator top
= st
->GetFirst();
186 delete top
->GetData();
190 StatusTextBuffer
[i
] = new wxListString();
193 return StatusTextBuffer
[i
];
196 wxListString
*wxStatusBarPalm::GetStatusBufferStack(int i
) const
198 if(!StatusTextBuffer
)
200 return StatusTextBuffer
[i
];
203 void wxStatusBarPalm::DeleteStatusBuffer()
205 if(!StatusTextBuffer
)
210 for(int i
=0;i
<m_nFields
;i
++)
212 if(StatusTextBuffer
[i
])
214 wxListString
*st
=StatusTextBuffer
[i
];
215 wxListString::compatibility_iterator top
= st
->GetFirst();
216 delete top
->GetData();
219 StatusTextBuffer
[i
]=0;
222 delete[] m_statusTextStacks
;
225 int wxStatusBarPalm::GetBorderX() const
230 int wxStatusBarPalm::GetBorderY() const
235 void wxStatusBarPalm::SetMinHeight(int height
)
239 bool wxStatusBarPalm::GetFieldRect(int i
, wxRect
& rect
) const
243 void wxStatusBarPalm::DoMoveWindow(int x
, int y
, int width
, int height
)
247 #endif // wxUSE_STATUSBAR