/////////////////////////////////////////////////////////////////////////////
-// Name: No names yet.
+// Name: tabpgwin.cpp
// Purpose: Contrib. demo
// Author: Aleksandras Gluchovas
// Modified by: 19990908 : mj
// - restruction of Variable declaration
// - to prevent Warnings under MingW32
// Modified by: 19990909 : mj
-// - mNoVertScroll TRUE = no / FALSE = Original Code
+// - mNoVertScroll true = no / false = Original Code
// the Original Code Paints a Vertical Scroll in wxPagedWindow
-// which is not needed in this Version. Use TRUE for this.
+// which is not needed in this Version. Use true for this.
// Created: 07/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleksandras Gluchovas
#ifdef __GNUG__
#pragma implementation
-// #pragma interface
+//#pragma interface
#endif
// For compilers that support precompilation, includes "wx.h".
//---------------------------------------------------------------------------
wxTabbedWindow::~wxTabbedWindow()
{
- wxNode* pTab = mTabs.First();
+ wxObjectList::compatibility_iterator pTab = mTabs.GetFirst();
while( pTab )
{
- delete ((twTabInfo*)pTab->Data());
- pTab = pTab->Next();
+ delete ((twTabInfo*)pTab->GetData());
+ pTab = pTab->GetNext();
}
}
//---------------------------------------------------------------------------
-void wxTabbedWindow::SizeTabs(int x,int y, int width, int height, bool repant)
+void wxTabbedWindow::SizeTabs(int x,int y, int width, int height, bool WXUNUSED(repant))
{
- wxNode* pTabNode = mTabs.First();
- int n = 0;
+ wxObjectList::compatibility_iterator pTabNode = mTabs.GetFirst();
+ size_t n = 0;
while( pTabNode )
{
- twTabInfo& info = *((twTabInfo*)pTabNode->Data());
+ twTabInfo& info = *((twTabInfo*)pTabNode->GetData());
if ( n == mActiveTab )
{
//info.mpContent->GetEventHandler()->ProcessEvent( evt );
info.mpContent->SetSize( x, y, width, height, 0 );
- info.mpContent->Show(TRUE);
+ info.mpContent->Show(true);
info.mpContent->Refresh();
}
else
{
- info.mpContent->Show(FALSE);
+ info.mpContent->Show(false);
}
- pTabNode = pTabNode->Next();
+ pTabNode = pTabNode->GetNext();
++n;
}
}
//---------------------------------------------------------------------------
-void wxTabbedWindow::AddTab( wxWindow* pContent,
- wxString tabText,
- wxString imageFileName,
- long imageType )
+void wxTabbedWindow::AddTab( wxWindow* pContent,
+ wxString tabText,
+ wxString imageFileName,
+ wxBitmapType imageType )
{
twTabInfo* pTab = new twTabInfo();
if ( pContent->GetParent() == NULL )
- pContent->Create( this, -1 );
+ pContent->Create( this, wxID_ANY );
mTabs.Append( (wxObject*)pTab );
- RecalcLayout(TRUE);
+ RecalcLayout(true);
OnTabAdded( pTab );
}
pTab->mBitMap = *pImage;
if ( pContent->GetParent() == NULL )
- pContent->Create( this, -1 );
+ pContent->Create( this, wxID_ANY );
mTabs.Append( (wxObject*)pTab );
- RecalcLayout(TRUE);
+ RecalcLayout(true);
OnTabAdded( pTab );
}
//---------------------------------------------------------------------------
void wxTabbedWindow::RemoveTab( int tabNo )
{
- twTabInfo* pTab = ((twTabInfo*)(mTabs.Nth( tabNo )->Data()));
+ twTabInfo* pTab = ((twTabInfo*)(mTabs.Item( tabNo )->GetData()));
pTab->mpContent->Destroy();
delete pTab;
- mTabs.DeleteNode( mTabs.Nth( tabNo ) );
- // if ( mActiveTab >= mTabs.Number() );
- if ( mActiveTab >= mTabs.Number() )
- mActiveTab = mTabs.Number() - 1;
+ mTabs.Erase( mTabs.Item( tabNo ) );
+ // if ( mActiveTab >= mTabs.GetCount() );
+ if ( mActiveTab >= mTabs.GetCount() )
+ mActiveTab = mTabs.GetCount() - 1;
SetActiveTab( mActiveTab );
}
//---------------------------------------------------------------------------
int wxTabbedWindow::GetTabCount()
{
- return mTabs.Number();
+ return mTabs.GetCount();
}
//---------------------------------------------------------------------------
wxWindow* wxTabbedWindow::GetTab( int tabNo )
{
- return ((twTabInfo*)(mTabs.Nth( tabNo )->Data()))->mpContent;
+ return ((twTabInfo*)(mTabs.Item( tabNo )->GetData()))->mpContent;
}
//---------------------------------------------------------------------------
void wxTabbedWindow::SetActiveTab( int tabNo )
{
mActiveTab = tabNo;
- RecalcLayout(TRUE);
+ RecalcLayout(true);
Refresh();
}
curX = mFirstTitleGap;
curY = height - mVertGap - mTitleHeight;
- int tabNo = 0;
- wxNode* pNode = mTabs.First();
+ size_t tabNo = 0;
+ wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
while( pNode )
{
// "hard-coded metafile" for decorations
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
xSize = tab.mDims.x;
ySize = mTitleHeight;
dc.DrawLine( curX+xSize-2, curY+ySize-2, curX+xSize-3, curY+ySize-2 );
dc.DrawLine( curX+xSize-3, curY+ySize-1, curX+1, curY+ySize-1 );
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
++tabNo;
// darw image and (or without) text centered within the
int curY = height - mVertGap - mTitleHeight;
int tabNo = 0;
- wxNode* pNode = mTabs.First();
+ wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
while( pNode )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
- int w,h;
- w = tab.mDims.x;
- h = tab.mDims.y;
// hit test rectangle of the currnet tab title bar
if ( pos.x >= curX && pos.x < curX + tab.mDims.x &&
pos.y >= curY && pos.y < curY + tab.mDims.y
curX += tab.mDims.x;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
++tabNo;
}
if ( !andRepaint )
return;
- wxNode* pNode = mTabs.First();
- int tabNo = 0;
+ wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
+ size_t tabNo = 0;
while( pNode )
{
if ( tabNo != mActiveTab )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
- tab.mpContent->Show(FALSE);
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
+ tab.mpContent->Show(false);
}
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
++tabNo;
}
} // wxTabbedWindow::HideInactiveTabs()
{
wxFont font;
#ifdef __WINDOWS__
- font.SetFaceName("MS Sans Serif");
+ font.SetFaceName(_T("MS Sans Serif"));
#else
font.SetFamily( wxSWISS );
#endif
mLayoutType = wxTITLE_IMG_AND_TEXT;
- wxNode* pNode = mTabs.First();
+ wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
curX = mFirstTitleGap; // the left-side gap
mTitleHeight = 0;
while( pNode )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
wxWindowDC dc(this);
curX += tab.mDims.x;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
curX += mHorizGap; // the right-side gap
// make all title bars of equel height
- pNode = mTabs.First();
+ pNode = mTabs.GetFirst();
while( pNode )
{
- ((twTabInfo*)(pNode->Data()))->mDims.y = mTitleHeight;;
- pNode = pNode->Next();
+ ((twTabInfo*)(pNode->GetData()))->mDims.y = mTitleHeight;;
+ pNode = pNode->GetNext();
}
// if curX has'nt ran out of bounds, leave TITLE_IMG layout and return
mLayoutType = wxTITLE_IMG_ONLY;
- pNode = mTabs.First();
+ pNode = mTabs.GetFirst();
curX = mFirstTitleGap; // the left-side gap
- int denomiator = mTabs.Number();
+ int denomiator = mTabs.GetCount();
if ( denomiator == 0 )
++denomiator;
while( pNode )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
if ( tab.HasImg() )
{
curX += tab.mDims.x;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
curX += mHorizGap; // the right-side gap
mLayoutType = wxTITLE_BORDER_ONLY;
- pNode = mTabs.First();
+ pNode = mTabs.GetFirst();
while( pNode )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
tab.mDims.x = mBorderOnlyWidth;
tab.mDims.y = mTitleHeight;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
} // wxTabbedWindow::RecalcLayout()
//---------------------------------------------------------------------------
// wx event handlers
//---------------------------------------------------------------------------
-void wxTabbedWindow::OnPaint( wxPaintEvent& event )
+void wxTabbedWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
wxPaintDC dc(this);
DrawDecorations( dc );
}
//---------------------------------------------------------------------------
-void wxTabbedWindow::OnSize ( wxSizeEvent& event )
+void wxTabbedWindow::OnSize ( wxSizeEvent& WXUNUSED(event) )
{
SetBackgroundColour( wxColour( 192,192,192 ) );
- RecalcLayout(TRUE);
+ RecalcLayout(true);
}
//---------------------------------------------------------------------------
-void wxTabbedWindow::OnBkErase( wxEraseEvent& event )
+void wxTabbedWindow::OnBkErase( wxEraseEvent& WXUNUSED(event) )
{
// do nothing
}
//---------------------------------------------------------------------------
wxPagedWindow::wxPagedWindow()
-: mScrollEventInProgress( FALSE ),
+: mScrollEventInProgress( false ),
mTabTrianGap(4),
mWhiteBrush( wxColour(255,255,255), wxSOLID ),
mGrayBrush ( wxColour(192,192,192), wxSOLID ),
mCurentRowOfs( 0 ),
mAdjustableTitleRowLen( 300 ),
- mIsDragged ( FALSE ),
+ mIsDragged ( false ),
mDagOrigin ( 0 ),
- mCursorChanged( FALSE ),
+ mCursorChanged( false ),
mResizeCursor ( wxCURSOR_SIZEWE ),
mNormalCursor ( wxCURSOR_ARROW )
{
mTitleVertGap = 2;
mTitleHorizGap = 10;
- mNoVertScroll = TRUE; // Horizontale Scroll abschalten
+ mNoVertScroll = true; // Horizontale Scroll abschalten
}
//---------------------------------------------------------------------------
wxFont font;
#ifdef __WINDOWS__
- font.SetFaceName("Comic Sans MS");
+ font.SetFaceName(_T("Comic Sans MS"));
#else
font.SetFamily( wxSWISS );
#endif
}
//---------------------------------------------------------------------------
-void wxPagedWindow::OnTabAdded( twTabInfo* pInfo )
+void wxPagedWindow::OnTabAdded( twTabInfo* WXUNUSED(pInfo) )
{
int units = GetWholeTabRowLen() / 20;
- mpTabScroll->SetScrollbar( 0, 1, units, 1, FALSE );
+ mpTabScroll->SetScrollbar( 0, 1, units, 1, false );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int wxPagedWindow::GetWholeTabRowLen()
{
- wxNode* pNode = mTabs.First();
+ wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
int len = 0;
while( pNode )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
len += tab.mDims.x;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
return len;
// draw inactive tab title bars frist (left-to-right)
- wxNode* pNode = mTabs.First();
- int tabNo = 0;
+ wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
+ size_t tabNo = 0;
/* OLD STUFF::
curX = mTitleRowStart;
while( pNode )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
if ( tabNo != mActiveTab )
DrawPaperBar( tab, curX, curY, mGrayBrush, mBlackPen, tmpDc );
curX += tab.mDims.x;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
++tabNo;
}
// finally, draw the active tab (white-filled)
- pNode = mTabs.First();
+ pNode = mTabs.GetFirst();
tabNo = 0;
curX = mTabTrianGap;
while( pNode )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
if ( tabNo == mActiveTab )
{
}
curX += tab.mDims.x;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
++tabNo;
}
if ( !mpTabScroll )
{
mpTabScroll =
- new wxScrollBar( this, -1, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
+ new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
mpHorizScroll =
- new wxScrollBar( this, -1, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
+ new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
if (!mNoVertScroll) // Vertical Scroll (Original)
- mpVertScroll = new wxScrollBar( this, -1, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL );
+ mpVertScroll = new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL );
}
{
int units = GetWholeTabRowLen() / 20;
- mpTabScroll->SetScrollbar( 0, 1, units, 1, FALSE );
+ mpTabScroll->SetScrollbar( 0, 1, units, 1, false );
}
// resetup position of the active tab
mLayoutType = wxTITLE_IMG_AND_TEXT;
- wxNode* pNode = mTabs.First();
+ wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
while( pNode )
{
- twTabInfo& tab = *((twTabInfo*)(pNode->Data()));
+ twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
wxWindowDC dc(this);
tab.mDims.y = mTitleHeight;
- pNode = pNode->Next();
+ pNode = pNode->GetNext();
}
// disable title-bar scroller if there's nowhere to scroll to
//---------------------------------------------------------------------------
// event handlers
//---------------------------------------------------------------------------
-void wxPagedWindow::OnPaint( wxPaintEvent& event )
+void wxPagedWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
wxPaintDC dc(this);
DrawDecorations( dc );
{
if ( mCursorChanged )
{
- mIsDragged = TRUE;
+ mIsDragged = true;
mDagOrigin = event.m_x;
mOriginalTitleRowLen = mAdjustableTitleRowLen;
} // wxPagedWindow::OnLButtonDown()
//---------------------------------------------------------------------------
-void wxPagedWindow::OnLButtonUp( wxMouseEvent& event )
+void wxPagedWindow::OnLButtonUp( wxMouseEvent& WXUNUSED(event) )
{
if ( mIsDragged )
{
- mIsDragged = FALSE;
- mCursorChanged = FALSE;
+ mIsDragged = false;
+ mCursorChanged = false;
SetCursor( mNormalCursor );
ReleaseMouse();
{
SetCursor( mResizeCursor );
- mCursorChanged = TRUE;
+ mCursorChanged = true;
}
}
else
{
SetCursor( mNormalCursor );
- mCursorChanged = FALSE;
+ mCursorChanged = false;
}
}
else
wxWindowDC dc(this);
DrawDecorations( dc );
- RecalcLayout(FALSE);
+ RecalcLayout(false);
//Refresh();
}
{
if ( !mScrollEventInProgress )
{
- mScrollEventInProgress = TRUE;
+ mScrollEventInProgress = true;
GetActiveTab()->GetEventHandler()->ProcessEvent( event );
}
// event bounced back to us, from here we
// know that it has traveled the loop - thus it's processed!
- mScrollEventInProgress = FALSE;
+ mScrollEventInProgress = false;
}
}
} // wxPagedWindow::OnScroll()