2004-10-19 09:40:30 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2005-01-21 06:22:11 -05:00
|
|
|
// Name: src/palmos/statbrpalm.cpp
|
2004-10-19 09:40:30 -04:00
|
|
|
// Purpose: Implementation of wxStatusBar for PalmOS
|
2005-01-21 06:22:11 -05:00
|
|
|
// Author: William Osborne - minimal working wxPalmOS port
|
|
|
|
// Modified by: Wlodzimierz ABX Skiba - transition from faked drawing to native statusbar
|
2004-10-19 09:40:30 -04:00
|
|
|
// Created: 10/13/04
|
2005-01-21 06:22:11 -05:00
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) William Osborne, Wlodzimierz Skiba
|
2004-10-19 09:40:30 -04:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// for compilers that support precompilation, includes "wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/setup.h"
|
|
|
|
#include "wx/frame.h"
|
|
|
|
#include "wx/settings.h"
|
|
|
|
#include "wx/dcclient.h"
|
|
|
|
#endif
|
|
|
|
|
2005-01-21 06:22:11 -05:00
|
|
|
#if wxUSE_NATIVE_STATUSBAR
|
2004-10-19 09:40:30 -04:00
|
|
|
|
|
|
|
#include "wx/intl.h"
|
|
|
|
#include "wx/log.h"
|
|
|
|
#include "wx/statusbr.h"
|
|
|
|
|
2005-07-01 15:36:58 -04:00
|
|
|
#include <StatusBar.h>
|
|
|
|
|
2004-10-19 09:40:30 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxStatusBarPalm class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
wxStatusBarPalm::wxStatusBarPalm()
|
|
|
|
{
|
|
|
|
SetParent(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxStatusBarPalm::Create(wxWindow *parent,
|
2005-01-21 06:22:11 -05:00
|
|
|
wxWindowID id,
|
|
|
|
long style,
|
|
|
|
const wxString& name)
|
2004-10-19 09:40:30 -04:00
|
|
|
{
|
2005-01-21 06:22:11 -05:00
|
|
|
wxCHECK_MSG( parent, false, wxT("status bar must have a parent") );
|
2004-10-19 09:40:30 -04:00
|
|
|
|
|
|
|
StatusTextBuffer = NULL;
|
|
|
|
|
|
|
|
SetName(name);
|
|
|
|
SetParent(parent);
|
2005-01-27 06:01:06 -05:00
|
|
|
SetId( id == wxID_ANY ? NewControlId() : id );
|
2004-10-19 09:40:30 -04:00
|
|
|
|
|
|
|
parent->AddChild(this);
|
|
|
|
|
|
|
|
SetFieldsCount(1);
|
|
|
|
|
2005-01-21 06:22:11 -05:00
|
|
|
return true;
|
2004-10-19 09:40:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
wxStatusBarPalm::~wxStatusBarPalm()
|
|
|
|
{
|
2005-01-21 06:22:11 -05:00
|
|
|
Show();
|
|
|
|
|
2004-10-19 09:40:30 -04:00
|
|
|
DeleteStatusBuffer();
|
|
|
|
}
|
|
|
|
|
2005-01-21 06:22:11 -05:00
|
|
|
bool wxStatusBarPalm::IsShown() const
|
|
|
|
{
|
|
|
|
return StatGetAttribute ( statAttrBarVisible , NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxStatusBarPalm::Show( bool show )
|
|
|
|
{
|
|
|
|
if(show)
|
|
|
|
{
|
|
|
|
// show it if hidden
|
|
|
|
if(IsShown())
|
|
|
|
return false;
|
|
|
|
status_t rc = StatShow();
|
|
|
|
wxCHECK_MSG( rc == errNone, false, wxT("cannot hide status bar") );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// hide it if shown
|
|
|
|
if(!IsShown())
|
|
|
|
return false;
|
|
|
|
status_t rc = StatHide();
|
|
|
|
wxCHECK_MSG( rc == errNone, false, wxT("cannot hide status bar") );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-10-19 09:40:30 -04:00
|
|
|
void wxStatusBarPalm::SetFieldsCount(int nFields, const int *widths)
|
|
|
|
{
|
|
|
|
// this is a Windows limitation
|
|
|
|
wxASSERT_MSG( (nFields > 0) && (nFields < 255), _T("too many fields") );
|
|
|
|
|
|
|
|
wxStatusBarBase::SetFieldsCount(nFields, widths);
|
|
|
|
|
|
|
|
SetFieldsWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxStatusBarPalm::SetStatusWidths(int n, const int widths[])
|
|
|
|
{
|
|
|
|
wxStatusBarBase::SetStatusWidths(n, widths);
|
|
|
|
|
|
|
|
SetFieldsWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxStatusBarPalm::SetFieldsWidth()
|
|
|
|
{
|
|
|
|
// clear the status bar
|
|
|
|
DeleteStatusBuffer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxStatusBarPalm::SetStatusText(const wxString& strText, int nField)
|
|
|
|
{
|
|
|
|
wxCHECK_RET( (nField >= 0) && (nField < m_nFields),
|
|
|
|
_T("invalid statusbar field index") );
|
|
|
|
|
|
|
|
SetStatusBufferText(strText,nField);
|
|
|
|
DrawStatusBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString wxStatusBarPalm::GetStatusText(int nField) const
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( (nField >= 0) && (nField < m_nFields), wxEmptyString,
|
|
|
|
_T("invalid statusbar field index") );
|
|
|
|
|
|
|
|
wxString text;
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxStatusBarPalm::DrawStatusBar()
|
|
|
|
{
|
2005-01-24 02:38:52 -05:00
|
|
|
#if 0
|
2004-10-19 09:40:30 -04:00
|
|
|
int i=0;
|
|
|
|
int leftPos=0;
|
|
|
|
wxArrayInt widthsAbs;
|
|
|
|
wxString text;
|
2004-10-19 19:17:30 -04:00
|
|
|
|
2004-10-19 09:40:30 -04:00
|
|
|
RectangleType EraseRect;
|
|
|
|
EraseRect.topLeft.x=0;
|
2004-10-19 19:17:30 -04:00
|
|
|
EraseRect.topLeft.y=160-FntCharHeight()-1;
|
2004-10-19 09:40:30 -04:00
|
|
|
EraseRect.extent.x=159;
|
2004-10-19 19:17:30 -04:00
|
|
|
EraseRect.extent.y=159;
|
2004-10-19 09:40:30 -04:00
|
|
|
WinEraseRectangle(&EraseRect,0);
|
|
|
|
|
|
|
|
if(m_nFields>0)
|
|
|
|
widthsAbs=CalculateAbsWidths(160 - 2*(m_nFields - 1));
|
2004-10-19 19:17:30 -04:00
|
|
|
|
2004-10-19 09:40:30 -04:00
|
|
|
for(i=0;i<m_nFields;i++)
|
|
|
|
{
|
|
|
|
text=GetStatusBufferText(i);
|
|
|
|
WinDrawTruncChars(text,StrLen(text),leftPos,160-FntCharHeight(),widthsAbs[i]);
|
|
|
|
leftPos+=widthsAbs[i]+2;
|
|
|
|
}
|
|
|
|
WinDrawLine(0,160-FntCharHeight()-1,159,160-FntCharHeight()-1);
|
2005-01-24 02:38:52 -05:00
|
|
|
#endif
|
2004-10-19 09:40:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxStatusBarPalm::SetStatusBufferText(const wxString& text, int number)
|
|
|
|
{
|
|
|
|
wxListString* st = GetOrCreateStatusBuffer(number);
|
|
|
|
|
|
|
|
wxString tmp1(text);
|
|
|
|
wxString* tmp = new wxString(tmp1);
|
|
|
|
st->Insert(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString wxStatusBarPalm::GetStatusBufferText(int number)
|
|
|
|
{
|
|
|
|
wxListString *st = GetStatusBufferStack(number);
|
|
|
|
if(st==0)
|
2005-01-24 02:38:52 -05:00
|
|
|
return wxEmptyString;
|
2004-10-19 09:40:30 -04:00
|
|
|
|
|
|
|
wxListString::compatibility_iterator top = st->GetFirst();
|
|
|
|
return(*top->GetData());
|
|
|
|
}
|
|
|
|
|
|
|
|
wxListString *wxStatusBarPalm::GetOrCreateStatusBuffer(int i)
|
|
|
|
{
|
|
|
|
if(!StatusTextBuffer)
|
|
|
|
{
|
|
|
|
StatusTextBuffer = new wxListString*[m_nFields];
|
|
|
|
|
|
|
|
size_t j;
|
|
|
|
for(j = 0; j < (size_t)m_nFields; ++j) StatusTextBuffer[j] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!StatusTextBuffer[i])
|
|
|
|
{
|
|
|
|
StatusTextBuffer[i] = new wxListString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxListString *st=StatusTextBuffer[i];
|
|
|
|
wxListString::compatibility_iterator top = st->GetFirst();
|
|
|
|
delete top->GetData();
|
|
|
|
st->Erase(top);
|
|
|
|
delete st;
|
2004-10-19 19:17:30 -04:00
|
|
|
|
2004-10-19 09:40:30 -04:00
|
|
|
StatusTextBuffer[i] = new wxListString();
|
|
|
|
}
|
|
|
|
|
|
|
|
return StatusTextBuffer[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
wxListString *wxStatusBarPalm::GetStatusBufferStack(int i) const
|
|
|
|
{
|
|
|
|
if(!StatusTextBuffer)
|
|
|
|
return 0;
|
|
|
|
return StatusTextBuffer[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxStatusBarPalm::DeleteStatusBuffer()
|
|
|
|
{
|
|
|
|
if(!StatusTextBuffer)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-10-19 19:17:30 -04:00
|
|
|
for(int i=0;i<m_nFields;i++)
|
2004-10-19 09:40:30 -04:00
|
|
|
{
|
|
|
|
if(StatusTextBuffer[i])
|
|
|
|
{
|
|
|
|
wxListString *st=StatusTextBuffer[i];
|
|
|
|
wxListString::compatibility_iterator top = st->GetFirst();
|
|
|
|
delete top->GetData();
|
|
|
|
st->Erase(top);
|
|
|
|
delete st;
|
|
|
|
StatusTextBuffer[i]=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] m_statusTextStacks;
|
|
|
|
}
|
|
|
|
|
|
|
|
int wxStatusBarPalm::GetBorderX() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int wxStatusBarPalm::GetBorderY() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxStatusBarPalm::SetMinHeight(int height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxStatusBarPalm::GetFieldRect(int i, wxRect& rect) const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxStatusBarPalm::DoMoveWindow(int x, int y, int width, int height)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-01-21 06:22:11 -05:00
|
|
|
#endif // wxUSE_NATIVE_STATUSBAR
|
2004-10-19 09:40:30 -04:00
|
|
|
|