2000-01-28 10:25:32 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2001-05-28 08:10:04 -04:00
|
|
|
// Name: tabpgwin.cpp
|
2000-01-28 10:25:32 -05:00
|
|
|
// Purpose: Contrib. demo
|
|
|
|
// Author: Aleksandras Gluchovas
|
2001-02-12 14:23:44 -05:00
|
|
|
// Modified by: 19990908 : mj
|
2000-01-28 10:25:32 -05:00
|
|
|
// - rename to tabpgwin
|
|
|
|
// - restruction of Variable declaration
|
2001-02-01 15:24:44 -05:00
|
|
|
// - to prevent Warnings under MingW32
|
2001-02-12 14:23:44 -05:00
|
|
|
// Modified by: 19990909 : mj
|
2004-06-01 14:27:09 -04:00
|
|
|
// - mNoVertScroll true = no / false = Original Code
|
2001-02-01 15:24:44 -05:00
|
|
|
// the Original Code Paints a Vertical Scroll in wxPagedWindow
|
2004-06-01 14:27:09 -04:00
|
|
|
// which is not needed in this Version. Use true for this.
|
2000-01-28 10:25:32 -05:00
|
|
|
// Created: 07/09/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Aleksandras Gluchovas
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
2004-12-14 15:52:13 -05:00
|
|
|
#include "wx/math.h"
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/utils.h" // import wxMin/wxMax macros and wxFileExist(..)
|
|
|
|
|
|
|
|
#include "tabpgwin.h"
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Implementation for class twTabInfo
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( twTabInfo, wxObject )
|
2001-02-01 15:24:44 -05:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
twTabInfo::twTabInfo()
|
|
|
|
: mpContent( 0 )
|
2000-01-28 10:25:32 -05:00
|
|
|
{}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
int twTabInfo::ImgWidth()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( mBitMap.Ok() ) return mBitMap.GetWidth();
|
|
|
|
else return 0;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
int twTabInfo::ImgHeight()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( mBitMap.Ok() )
|
|
|
|
return mBitMap.GetHeight();
|
|
|
|
else
|
|
|
|
return 0;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
int twTabInfo::ImageToTxtGap( int prefGap )
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( mBitMap.Ok() )
|
|
|
|
return prefGap;
|
|
|
|
else
|
|
|
|
return 0;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
bool twTabInfo::HasImg()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
return mBitMap.Ok();
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// bool twTabInfo::HasText();
|
|
|
|
unsigned int twTabInfo::HasText()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
return mText.Length();
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxBitmap& twTabInfo::GetImg()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
return mBitMap;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxString& twTabInfo::GetText()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
return mText;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxWindow& twTabInfo::GetContent()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
return *mpContent;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Implementation for class wxTabbedWindow
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( wxTabbedWindow, wxPanel )
|
2001-02-01 15:24:44 -05:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
BEGIN_EVENT_TABLE( wxTabbedWindow, wxPanel )
|
|
|
|
EVT_SIZE ( wxTabbedWindow::OnSize )
|
|
|
|
EVT_PAINT( wxTabbedWindow::OnPaint )
|
|
|
|
EVT_LEFT_DOWN( wxTabbedWindow::OnLButtonDown )
|
|
|
|
// TDB:: filciker reduction
|
|
|
|
// EVT_ERASE_BACKGROUND( wxTabbedWindow::OnBkErase )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxTabbedWindow::wxTabbedWindow()
|
|
|
|
|
|
|
|
: mpTabScroll ( NULL ),
|
|
|
|
mpHorizScroll( NULL ),
|
|
|
|
mpVertScroll ( NULL ),
|
|
|
|
|
|
|
|
mVertGap ( 0 ),
|
|
|
|
mHorizGap( 0 ),
|
|
|
|
|
|
|
|
mTitleVertGap ( 3 ),
|
|
|
|
mTitleHorizGap( 4 ),
|
|
|
|
mImageTextGap ( 2 ),
|
|
|
|
mFirstTitleGap( 11 ),
|
|
|
|
|
|
|
|
mBorderOnlyWidth( 8 ),
|
|
|
|
|
|
|
|
mWhitePen( wxColour(255,255,255), 1, wxSOLID ),
|
|
|
|
mGrayPen ( wxColour(192,192,192), 1, wxSOLID ),
|
|
|
|
mDarkPen ( wxColour(128,128,128), 1, wxSOLID ),
|
|
|
|
mBlackPen( wxColour( 0, 0, 0), 1, wxSOLID ),
|
|
|
|
|
|
|
|
// state variables
|
|
|
|
mActiveTab ( 0 ),
|
|
|
|
mTitleHeight( 0 ),
|
|
|
|
mLayoutType( wxTITLE_IMG_AND_TEXT )
|
2000-01-28 10:25:32 -05:00
|
|
|
{}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxTabbedWindow::~wxTabbedWindow()
|
|
|
|
{
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pTab = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pTab )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
delete ((twTabInfo*)pTab->GetData());
|
|
|
|
pTab = pTab->GetNext();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2004-02-08 06:53:48 -05:00
|
|
|
void wxTabbedWindow::SizeTabs(int x,int y, int width, int height, bool WXUNUSED(repant))
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pTabNode = mTabs.GetFirst();
|
2004-02-08 06:53:48 -05:00
|
|
|
size_t n = 0;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pTabNode )
|
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& info = *((twTabInfo*)pTabNode->GetData());
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( n == mActiveTab )
|
|
|
|
{
|
|
|
|
//wxSizeEvent evt;
|
|
|
|
//info.mpContent->GetEventHandler()->ProcessEvent( evt );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
info.mpContent->SetSize( x, y, width, height, 0 );
|
2004-06-01 14:27:09 -04:00
|
|
|
info.mpContent->Show(true);
|
2001-02-01 15:24:44 -05:00
|
|
|
info.mpContent->Refresh();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-06-01 14:27:09 -04:00
|
|
|
info.mpContent->Show(false);
|
2001-02-01 15:24:44 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pTabNode = pTabNode->GetNext();
|
2001-02-01 15:24:44 -05:00
|
|
|
++n;
|
|
|
|
}
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-07-22 10:09:23 -04:00
|
|
|
void wxTabbedWindow::AddTab( wxWindow* pContent,
|
|
|
|
wxString tabText,
|
|
|
|
wxString imageFileName,
|
|
|
|
wxBitmapType imageType )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
twTabInfo* pTab = new twTabInfo();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
pTab->mpContent = pContent;
|
|
|
|
pTab->mText = tabText;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( wxFileExists( imageFileName ) &&
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
pTab->mBitMap.LoadFile( imageFileName, imageType ) )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
pTab->mImageFile = imageFileName;
|
|
|
|
pTab->mImageType = imageType;
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( pContent->GetParent() == NULL )
|
2004-06-01 14:27:09 -04:00
|
|
|
pContent->Create( this, wxID_ANY );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mTabs.Append( (wxObject*)pTab );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
RecalcLayout(true);
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
OnTabAdded( pTab );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void wxTabbedWindow::AddTab( wxWindow* pContent,
|
2001-02-01 15:24:44 -05:00
|
|
|
wxString tabText, wxBitmap* pImage )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
twTabInfo* pTab = new twTabInfo();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
pTab->mpContent = pContent;
|
|
|
|
pTab->mText = tabText;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( pImage )
|
|
|
|
pTab->mBitMap = *pImage;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( pContent->GetParent() == NULL )
|
2004-06-01 14:27:09 -04:00
|
|
|
pContent->Create( this, wxID_ANY );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mTabs.Append( (wxObject*)pTab );
|
2004-06-01 14:27:09 -04:00
|
|
|
RecalcLayout(true);
|
2001-02-01 15:24:44 -05:00
|
|
|
OnTabAdded( pTab );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void wxTabbedWindow::RemoveTab( int tabNo )
|
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo* pTab = ((twTabInfo*)(mTabs.Item( tabNo )->GetData()));
|
2001-02-01 15:24:44 -05:00
|
|
|
pTab->mpContent->Destroy();
|
|
|
|
delete pTab;
|
2004-07-30 11:41:00 -04:00
|
|
|
mTabs.Erase( mTabs.Item( tabNo ) );
|
2004-02-08 06:53:48 -05:00
|
|
|
// if ( mActiveTab >= mTabs.GetCount() );
|
|
|
|
if ( mActiveTab >= mTabs.GetCount() )
|
|
|
|
mActiveTab = mTabs.GetCount() - 1;
|
2001-02-01 15:24:44 -05:00
|
|
|
SetActiveTab( mActiveTab );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
int wxTabbedWindow::GetTabCount()
|
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
return mTabs.GetCount();
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxWindow* wxTabbedWindow::GetTab( int tabNo )
|
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
return ((twTabInfo*)(mTabs.Item( tabNo )->GetData()))->mpContent;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxWindow* wxTabbedWindow::GetActiveTab()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
// FIMXE:: this is lame
|
|
|
|
return GetTab( mActiveTab );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void wxTabbedWindow::SetActiveTab( int tabNo )
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
mActiveTab = tabNo;
|
2004-06-01 14:27:09 -04:00
|
|
|
RecalcLayout(true);
|
2001-02-01 15:24:44 -05:00
|
|
|
Refresh();
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// width of the decorations border (4 shade-lines), should not be changed
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#define BORDER_SZ 4
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void wxTabbedWindow::DrawShadedRect( int x, int y, int width, int height,
|
2001-02-01 15:24:44 -05:00
|
|
|
wxPen& upperPen, wxPen& lowerPen, wxDC& dc
|
|
|
|
)
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
// darw the lightened upper-left sides of the rectangle
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetPen( upperPen );
|
|
|
|
dc.DrawLine( x,y, x, y + height - 1 ); // vert
|
|
|
|
dc.DrawLine( x,y, x + width - 1, y ); // horiz
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// draw the unenlightened lower-right sides of the rectangle
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetPen( lowerPen );
|
|
|
|
dc.DrawLine( x + width - 1, y, x + width - 1, y + height - 1 ); // vert
|
|
|
|
dc.DrawLine( x, y + height - 1, x + width, y + height - 1 ); // horiz
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void wxTabbedWindow::DrawDecorations( wxDC& dc )
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
// Protability NOTE::: DrawLine(..) draws a line from the first position,
|
|
|
|
// but not including the point specified by last position.
|
|
|
|
// This way Windows draws lines, not sure how Motif and Gtk
|
|
|
|
// prots behave...
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int width, height;
|
|
|
|
GetClientSize( &width, &height );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// check if there's at least a bit of space to draw things
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( width < mHorizGap*2 + BORDER_SZ*2+1 ||
|
|
|
|
height < mVertGap*2 + BORDER_SZ*2+1 + mTitleHeight
|
|
|
|
)
|
|
|
|
return;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// step #1 - draw border around the tab content area
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// setup position for kind of "pencil"
|
|
|
|
int curX = mHorizGap;
|
|
|
|
int curY = mVertGap;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int xSize = width - mHorizGap*2;
|
|
|
|
int ySize = height - mVertGap *2 - mTitleHeight;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// layer 1 (upper white)
|
|
|
|
DrawShadedRect( curX+0, curY+0, xSize-0, ySize-0,
|
|
|
|
mWhitePen, mBlackPen, dc );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// layer 2 (upper gray)
|
|
|
|
DrawShadedRect( curX+1, curY+1, xSize-2-1, ySize-2-1,
|
|
|
|
mGrayPen, mGrayPen, dc );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// layer 3 (upper darkGray)
|
|
|
|
DrawShadedRect( curX+2, curY+2, xSize-3-2, ySize-3-2,
|
|
|
|
mDarkPen, mWhitePen, dc );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// layer 4 (upper black)
|
|
|
|
DrawShadedRect( curX+3, curY+3, xSize-4-3, ySize-4-3,
|
|
|
|
mBlackPen, mGrayPen, dc );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// add non-siemtric layer from the lower-right side (confroming to MFC-look)
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetPen( mDarkPen );
|
|
|
|
dc.DrawLine( curX+1, curY + ySize - 2, curX + xSize - 1, curY + ySize - 2 ); // horiz
|
|
|
|
dc.DrawLine( curX + xSize - 2, curY + 1, curX + xSize - 2, curY + ySize - 2 ); // vert
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// step #2 - draw tab title bars
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX = mFirstTitleGap;
|
|
|
|
curY = height - mVertGap - mTitleHeight;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
size_t tabNo = 0;
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
// "hard-coded metafile" for decorations
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
xSize = tab.mDims.x;
|
|
|
|
ySize = mTitleHeight;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( tabNo == mActiveTab )
|
|
|
|
{
|
|
|
|
dc.SetPen( mGrayPen );
|
|
|
|
dc.DrawLine( curX+1, curY-2, curX+xSize-2, curY-2 );
|
|
|
|
dc.DrawLine( curX+1, curY-1, curX+xSize-2, curY-1 );
|
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetPen( mWhitePen );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( tabNo == mActiveTab )
|
|
|
|
dc.DrawLine( curX, curY-2, curX, curY+ySize-2 );
|
|
|
|
else
|
|
|
|
dc.DrawLine( curX, curY, curX, curY+ySize-2 );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetPen( mDarkPen );
|
|
|
|
dc.DrawLine( curX+1, curY+ySize-3, curX+1, curY+ySize-1 ); // to pix down
|
|
|
|
dc.DrawLine( curX+2, curY+ySize-2, curX+xSize-2, curY+ySize-2 );
|
|
|
|
dc.DrawLine( curX+xSize-3, curY+ySize-3, curX+xSize-2, curY+ySize-3 );
|
|
|
|
if ( tabNo == mActiveTab )
|
|
|
|
dc.DrawLine( curX+xSize-2, curY+ySize-3, curX+xSize-2, curY-3 );
|
|
|
|
else
|
|
|
|
dc.DrawLine( curX+xSize-2, curY+ySize-3, curX+xSize-2, curY-1 );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetPen( mBlackPen );
|
|
|
|
dc.DrawLine( curX+xSize-1, curY, curX+xSize-1, curY+ySize-2 );
|
|
|
|
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 );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2001-02-01 15:24:44 -05:00
|
|
|
++tabNo;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// darw image and (or without) text centered within the
|
|
|
|
// title bar rectangle
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( mLayoutType != wxTITLE_BORDER_ONLY && tab.HasImg() )
|
|
|
|
{
|
|
|
|
wxMemoryDC tmpDc;
|
|
|
|
tmpDc.SelectObject( tab.GetImg() );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.Blit( curX + mTitleHorizGap,
|
|
|
|
curY + ( ySize - tab.ImgHeight() ) / 2,
|
|
|
|
tab.ImgWidth(),
|
|
|
|
tab.ImgHeight(),
|
|
|
|
&tmpDc, 0, 0, wxCOPY
|
|
|
|
);
|
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( mLayoutType == wxTITLE_IMG_AND_TEXT && tab.HasText() )
|
|
|
|
{
|
|
|
|
long x,w,h;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// set select default font of the window into it's device context
|
|
|
|
//dc.SetFont( GetLabelingFont() );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetTextBackground( GetBackgroundColour() );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.GetTextExtent(tab.mText, &w, &h );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
x = curX + mTitleHorizGap +
|
|
|
|
tab.ImgWidth() + tab.ImageToTxtGap(mImageTextGap);
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.DrawText( tab.GetText(), x, curY + ( ySize - h ) / 2 );
|
|
|
|
}
|
|
|
|
curX += xSize;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2000-01-31 05:43:24 -05:00
|
|
|
} // end of `while (pNode)'
|
2001-02-01 15:24:44 -05:00
|
|
|
} // wxTabbedWindow::DrawDecorations()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
int wxTabbedWindow::HitTest( const wxPoint& pos )
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
int width, height;
|
|
|
|
GetClientSize( &width, &height );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int curX = mFirstTitleGap;
|
|
|
|
int curY = height - mVertGap - mTitleHeight;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int tabNo = 0;
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// 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
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return tabNo;
|
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX += tab.mDims.x;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2001-02-01 15:24:44 -05:00
|
|
|
++tabNo;
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
return -1;
|
|
|
|
} // wxTabbedWindow::HitTest()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void wxTabbedWindow::HideInactiveTabs( bool andRepaint )
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( !andRepaint )
|
|
|
|
return;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
|
2004-02-08 06:53:48 -05:00
|
|
|
size_t tabNo = 0;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( tabNo != mActiveTab )
|
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-06-01 14:27:09 -04:00
|
|
|
tab.mpContent->Show(false);
|
2001-02-01 15:24:44 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2001-02-01 15:24:44 -05:00
|
|
|
++tabNo;
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
} // wxTabbedWindow::HideInactiveTabs()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxFont wxTabbedWindow::GetLabelingFont()
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxFont font;
|
2000-01-28 10:25:32 -05:00
|
|
|
#ifdef __WINDOWS__
|
2004-01-11 17:08:25 -05:00
|
|
|
font.SetFaceName(_T("MS Sans Serif"));
|
2000-01-28 10:25:32 -05:00
|
|
|
#else
|
2001-02-01 15:24:44 -05:00
|
|
|
font.SetFamily( wxSWISS );
|
2000-01-28 10:25:32 -05:00
|
|
|
#endif
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
font.SetStyle(40);
|
|
|
|
font.SetWeight(40);
|
|
|
|
font.SetPointSize( 8 );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
#ifdef __WINDOWS__
|
2001-02-01 15:24:44 -05:00
|
|
|
font.RealizeResource();
|
2000-01-28 10:25:32 -05:00
|
|
|
#endif
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
return font;
|
|
|
|
} // wxTabbedWindow::GetLabelingFont()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void wxTabbedWindow::RecalcLayout(bool andRepaint)
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
HideInactiveTabs(andRepaint);
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// resetup position of the active tab
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int width, height;
|
|
|
|
GetClientSize( &width, &height );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int curX = mHorizGap + BORDER_SZ;
|
|
|
|
int curY = mVertGap + BORDER_SZ;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int xSize = width - mHorizGap*2 - BORDER_SZ*2-1;
|
|
|
|
int ySize = height - mVertGap*2 - BORDER_SZ*2-1 - mTitleHeight;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
SizeTabs( curX, curY, xSize, ySize, andRepaint );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// pass #1 - try to layout assuming it's wxTITLE_IMG_AND_TEXT
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mLayoutType = wxTITLE_IMG_AND_TEXT;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX = mFirstTitleGap; // the left-side gap
|
|
|
|
mTitleHeight = 0;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
wxWindowDC dc(this);
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
long w,h;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// set select default font of the window into it's device context
|
|
|
|
//dc.SetFont( GetLabelingFont() );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.GetTextExtent(tab.mText, &w, &h );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
tab.mDims.x = w + tab.ImageToTxtGap(mImageTextGap) +
|
|
|
|
tab.ImgWidth() + mTitleHorizGap*2;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
tab.mDims.y = wxMax( h, tab.ImgHeight() ) + mTitleVertGap*2;
|
|
|
|
mTitleHeight = wxMax( mTitleHeight, tab.mDims.y );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX += tab.mDims.x;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX += mHorizGap; // the right-side gap
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// make all title bars of equel height
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
((twTabInfo*)(pNode->GetData()))->mDims.y = mTitleHeight;;
|
|
|
|
pNode = pNode->GetNext();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// if curX has'nt ran out of bounds, leave TITLE_IMG layout and return
|
|
|
|
if ( curX < width - mHorizGap )
|
|
|
|
return;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// pass #2 - try to layout assuming wxTITLE_IMG_ONLY
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mLayoutType = wxTITLE_IMG_ONLY;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX = mFirstTitleGap; // the left-side gap
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
int denomiator = mTabs.GetCount();
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( denomiator == 0 )
|
|
|
|
++denomiator;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mBorderOnlyWidth = (width - mFirstTitleGap - mHorizGap) / denomiator;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( tab.HasImg() )
|
|
|
|
{
|
|
|
|
tab.mDims.x = tab.ImgWidth() + mTitleHorizGap*2;
|
|
|
|
tab.mDims.y = tab.ImgHeight() + mTitleVertGap*2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tab.mDims.x = mBorderOnlyWidth;
|
|
|
|
tab.mDims.y = mTitleHeight;
|
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX += tab.mDims.x;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX += mHorizGap; // the right-side gap
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// if curX has'nt ran out of bounds, leave IMG_ONLY layout and return
|
|
|
|
if ( curX < width - mHorizGap )
|
|
|
|
return;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// pass #3 - set the narrowest layout wxTITLE_BORDER_ONLY
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mLayoutType = wxTITLE_BORDER_ONLY;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
tab.mDims.x = mBorderOnlyWidth;
|
|
|
|
tab.mDims.y = mTitleHeight;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
} // wxTabbedWindow::RecalcLayout()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// wx event handlers
|
|
|
|
//---------------------------------------------------------------------------
|
2004-02-08 06:53:48 -05:00
|
|
|
void wxTabbedWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxPaintDC dc(this);
|
|
|
|
DrawDecorations( dc );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2004-02-08 06:53:48 -05:00
|
|
|
void wxTabbedWindow::OnSize ( wxSizeEvent& WXUNUSED(event) )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
SetBackgroundColour( wxColour( 192,192,192 ) );
|
2004-06-01 14:27:09 -04:00
|
|
|
RecalcLayout(true);
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2004-02-08 06:53:48 -05:00
|
|
|
void wxTabbedWindow::OnBkErase( wxEraseEvent& WXUNUSED(event) )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
// do nothing
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
void wxTabbedWindow::OnLButtonDown( wxMouseEvent& event )
|
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
// floats, why?
|
|
|
|
int x = (int)event.m_x;
|
|
|
|
int y = (int)event.m_y;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int tabNo = HitTest( wxPoint(x,y) );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( tabNo != -1 )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
SetActiveTab( tabNo );
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Implementation for class wxPagedWindow
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( wxPagedWindow, wxTabbedWindow )
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
BEGIN_EVENT_TABLE( wxPagedWindow, wxTabbedWindow )
|
|
|
|
EVT_SIZE ( wxPagedWindow::OnSize )
|
|
|
|
EVT_PAINT ( wxPagedWindow::OnPaint )
|
|
|
|
EVT_LEFT_DOWN( wxPagedWindow::OnLButtonDown )
|
|
|
|
EVT_LEFT_UP ( wxPagedWindow::OnLButtonUp )
|
|
|
|
EVT_MOTION ( wxPagedWindow::OnMouseMove )
|
|
|
|
EVT_SCROLL ( wxPagedWindow::OnScroll )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
// border for paged-window is 2 shaded-lines
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#undef BORDER_SZ
|
|
|
|
#define BORDER_SZ 2
|
2001-02-01 15:24:44 -05:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
wxPagedWindow::wxPagedWindow()
|
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
: mScrollEventInProgress( false ),
|
2001-02-01 15:24:44 -05:00
|
|
|
mTabTrianGap(4),
|
|
|
|
mWhiteBrush( wxColour(255,255,255), wxSOLID ),
|
|
|
|
mGrayBrush ( wxColour(192,192,192), wxSOLID ),
|
|
|
|
mCurentRowOfs( 0 ),
|
|
|
|
mAdjustableTitleRowLen( 300 ),
|
2004-06-01 14:27:09 -04:00
|
|
|
mIsDragged ( false ),
|
2001-02-01 15:24:44 -05:00
|
|
|
mDagOrigin ( 0 ),
|
2004-06-01 14:27:09 -04:00
|
|
|
mCursorChanged( false ),
|
2001-02-01 15:24:44 -05:00
|
|
|
mResizeCursor ( wxCURSOR_SIZEWE ),
|
|
|
|
mNormalCursor ( wxCURSOR_ARROW )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
mTitleVertGap = 2;
|
|
|
|
mTitleHorizGap = 10;
|
2004-06-01 14:27:09 -04:00
|
|
|
mNoVertScroll = true; // Horizontale Scroll abschalten
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
wxFont wxPagedWindow::GetLabelingFont()
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxFont font;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
#ifdef __WINDOWS__
|
2004-01-11 17:08:25 -05:00
|
|
|
font.SetFaceName(_T("Comic Sans MS"));
|
2000-01-28 10:25:32 -05:00
|
|
|
#else
|
2001-02-01 15:24:44 -05:00
|
|
|
font.SetFamily( wxSWISS );
|
2000-01-28 10:25:32 -05:00
|
|
|
#endif
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
font.SetStyle(40);
|
|
|
|
font.SetWeight(40);
|
|
|
|
font.SetPointSize( 8 );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
return font;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2004-02-08 06:53:48 -05:00
|
|
|
void wxPagedWindow::OnTabAdded( twTabInfo* WXUNUSED(pInfo) )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
int units = GetWholeTabRowLen() / 20;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
mpTabScroll->SetScrollbar( 0, 1, units, 1, false );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
wxScrollBar& wxPagedWindow::GetVerticalScrollBar()
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
return *mpVertScroll;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
wxScrollBar& wxPagedWindow::GetHorizontalScrollBar()
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
return *mpHorizScroll;
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
int wxPagedWindow::GetWholeTabRowLen()
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int len = 0;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
len += tab.mDims.x;
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
return len;
|
|
|
|
} // wxPagedWindow::GetWholeTabRowLen()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
void wxPagedWindow::DrawPaperBar( twTabInfo& tab, int x, int y,
|
|
|
|
wxBrush& brush, wxPen& pen, wxDC& dc )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxPoint poly[4];
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// draw organizer-style paper outlet
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
poly[0].x = x - mTabTrianGap;
|
|
|
|
poly[0].y = y;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
poly[1].x = x + mTabTrianGap;
|
|
|
|
poly[1].y = y + tab.mDims.y-1;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
poly[2].x = x + tab.mDims.x - mTabTrianGap;
|
|
|
|
poly[2].y = y + tab.mDims.y-1;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
poly[3].x = x + tab.mDims.x + mTabTrianGap;
|
|
|
|
poly[3].y = y;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetPen( pen );
|
|
|
|
dc.SetBrush( brush );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.DrawPolygon( 4, poly );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
long w,h;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// set select default font of the window into it's device context
|
|
|
|
//dc.SetFont( GetLabelingFont() );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.SetTextBackground( brush.GetColour() );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.GetTextExtent(tab.mText, &w, &h );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( tab.HasImg() )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxMemoryDC tmpDc;
|
|
|
|
tmpDc.SelectObject( tab.GetImg() );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.Blit( x + mTitleHorizGap,
|
|
|
|
y + ( tab.mDims.y - tab.ImgHeight() ) / 2,
|
|
|
|
tab.ImgWidth(),
|
|
|
|
tab.ImgHeight(),
|
|
|
|
&tmpDc, 0, 0, wxCOPY
|
|
|
|
);
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( tab.HasText() )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
int tx = x + mTitleHorizGap +
|
|
|
|
tab.ImgWidth() + tab.ImageToTxtGap(mImageTextGap);
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.DrawText( tab.GetText(), tx, y + ( tab.mDims.y - h ) / 2 );
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
} // wxPagedWindow::DrawPaperBar()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
void wxPagedWindow::DrawDecorations( wxDC& dc )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
// FIXME:: the is big body have to be split!
|
|
|
|
|
|
|
|
int width, height;
|
|
|
|
GetClientSize( &width, &height );
|
|
|
|
|
|
|
|
int curX = mHorizGap;
|
|
|
|
int curY = mVertGap;
|
|
|
|
|
|
|
|
int xSize = width - mHorizGap*2;
|
|
|
|
int ySize = height - mVertGap*2;
|
|
|
|
|
|
|
|
DrawShadedRect( curX, curY, xSize, ySize,
|
|
|
|
mDarkPen, mWhitePen, dc );
|
|
|
|
|
|
|
|
DrawShadedRect( curX+1, curY+1, xSize-2, ySize-2,
|
|
|
|
mBlackPen, mGrayPen, dc );
|
|
|
|
|
|
|
|
// draw inactive tab title bars frist (left-to-right)
|
|
|
|
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
|
2004-02-08 06:53:48 -05:00
|
|
|
size_t tabNo = 0;
|
2001-02-01 15:24:44 -05:00
|
|
|
|
|
|
|
/* OLD STUFF::
|
|
|
|
curX = mTitleRowStart;
|
|
|
|
curY = height - mVertGap - BORDER_SZ - mTitleHeight;
|
|
|
|
*/
|
|
|
|
|
|
|
|
curX = mTabTrianGap;
|
|
|
|
curY = 0;
|
|
|
|
|
|
|
|
// FOR NOW:: avoid creating bitmap with invalid dimensions
|
|
|
|
|
|
|
|
if ( mTitleRowLen < 1 || mTitleHeight < 1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxMemoryDC tmpDc;
|
|
|
|
wxBitmap tmpBmp( mTitleRowLen, mTitleHeight );
|
|
|
|
|
|
|
|
tmpDc.SelectObject( tmpBmp );
|
|
|
|
tmpDc.SetPen( mGrayPen );
|
|
|
|
tmpDc.SetBrush( mGrayBrush );
|
|
|
|
tmpDc.DrawRectangle( 0,0, mTitleRowLen, mTitleHeight );
|
|
|
|
|
|
|
|
tmpDc.SetDeviceOrigin( mCurentRowOfs, 0 );
|
|
|
|
|
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2001-02-01 15:24:44 -05:00
|
|
|
|
|
|
|
if ( tabNo != mActiveTab )
|
|
|
|
DrawPaperBar( tab, curX, curY, mGrayBrush, mBlackPen, tmpDc );
|
|
|
|
|
|
|
|
curX += tab.mDims.x;
|
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2001-02-01 15:24:44 -05:00
|
|
|
++tabNo;
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// finally, draw the active tab (white-filled)
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = mTabs.GetFirst();
|
2001-02-01 15:24:44 -05:00
|
|
|
tabNo = 0;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX = mTabTrianGap;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( tabNo == mActiveTab )
|
|
|
|
{
|
|
|
|
DrawPaperBar( tab, curX, curY, mWhiteBrush, mBlackPen, tmpDc );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
tmpDc.SetPen( mWhitePen );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
tmpDc.DrawLine( curX - mTabTrianGap+1, curY,
|
|
|
|
curX + tab.mDims.x + mTabTrianGap, curY );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
curX += tab.mDims.x;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2001-02-01 15:24:44 -05:00
|
|
|
++tabNo;
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// back to initial device origin
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
tmpDc.SetDeviceOrigin( 0, 0 );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// draw resize-hint-stick
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX = mTitleRowLen - 6;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
DrawShadedRect( curX+0, 0+0, 6, mTitleHeight, mGrayPen, mBlackPen, tmpDc );
|
|
|
|
DrawShadedRect( curX+1, 0+1, 6-2, mTitleHeight-2, mWhitePen, mDarkPen, tmpDc );
|
|
|
|
DrawShadedRect( curX+2, 0+2, 6-4, mTitleHeight-4, mGrayPen, mGrayPen, tmpDc );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
dc.Blit( mTitleRowStart,
|
|
|
|
height - mVertGap - BORDER_SZ - mTitleHeight,
|
|
|
|
mTitleRowLen, mTitleHeight,
|
|
|
|
&tmpDc, 0,0, wxCOPY );
|
|
|
|
} // wxPagedWindow::DrawDecorations()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
int wxPagedWindow::HitTest( const wxPoint& pos )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
return wxTabbedWindow::HitTest( pos );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
void wxPagedWindow::RecalcLayout(bool andRepaint)
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
mTitleRowLen = mAdjustableTitleRowLen;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( int(mpTabScroll) == -1 ) return;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// scroll bars should be created after Create() for this window is called
|
|
|
|
if ( !mpTabScroll )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
mpTabScroll =
|
2004-06-01 14:27:09 -04:00
|
|
|
new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mpHorizScroll =
|
2004-06-01 14:27:09 -04:00
|
|
|
new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
|
2001-02-01 15:24:44 -05:00
|
|
|
if (!mNoVertScroll) // Vertical Scroll (Original)
|
2004-06-01 14:27:09 -04:00
|
|
|
mpVertScroll = new wxScrollBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL );
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
int units = GetWholeTabRowLen() / 20;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
mpTabScroll->SetScrollbar( 0, 1, units, 1, false );
|
2001-02-01 15:24:44 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// resetup position of the active tab
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int thumbLen = 16; // FOR NOW:: hardcoded
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int width, height;
|
|
|
|
GetClientSize( &width, &height );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mTitleHeight = thumbLen;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int curX = mHorizGap + BORDER_SZ;
|
|
|
|
int curY = mVertGap + BORDER_SZ;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int xSize;
|
|
|
|
if (!mNoVertScroll) // Vertical Scroll (Original)
|
|
|
|
xSize = width - mHorizGap*2 - BORDER_SZ*2 - thumbLen;
|
|
|
|
else
|
|
|
|
xSize = width - mHorizGap*2 - BORDER_SZ*2;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int ySize = height - mVertGap*2 - BORDER_SZ*2 - mTitleHeight;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
SizeTabs( curX, curY, xSize, ySize, andRepaint );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// setup title bar LINES's horizontal scroll bar
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curY = height - mVertGap - BORDER_SZ - thumbLen;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mpTabScroll->SetSize( curX, curY, thumbLen*2, thumbLen );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// setup view's HORIZONTAL scroll bar
|
|
|
|
curX += thumbLen*2;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mTitleRowStart = curX;
|
|
|
|
mFirstTitleGap = curX + mCurentRowOfs + mTabTrianGap;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mTitleRowLen = wxMin( mAdjustableTitleRowLen,
|
|
|
|
width - mHorizGap - BORDER_SZ - thumbLen*4 - curX );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
curX += mTitleRowLen;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if (!mNoVertScroll) // Vertical Scroll (Original)
|
|
|
|
mpHorizScroll->SetSize( curX, curY,width - curX - mHorizGap - BORDER_SZ - thumbLen, thumbLen );
|
|
|
|
else
|
|
|
|
mpHorizScroll->SetSize( curX, curY,width - curX - mHorizGap - BORDER_SZ-4, thumbLen );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// setup view's VERTICAL scroll bar
|
|
|
|
if (!mNoVertScroll) // Vertical Scroll (Original)
|
|
|
|
{
|
|
|
|
curX = width - mHorizGap - BORDER_SZ - thumbLen;
|
|
|
|
curY = mVertGap + BORDER_SZ;
|
|
|
|
mpVertScroll->SetSize( curX, curY, thumbLen,height - curY - mVertGap - BORDER_SZ - thumbLen);
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
// layout tab title bars
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mLayoutType = wxTITLE_IMG_AND_TEXT;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-07-30 11:41:00 -04:00
|
|
|
wxObjectList::compatibility_iterator pNode = mTabs.GetFirst();
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
while( pNode )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-02-08 06:53:48 -05:00
|
|
|
twTabInfo& tab = *((twTabInfo*)(pNode->GetData()));
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
wxWindowDC dc(this);
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
long w,h;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// set select default font of the window into it's device context
|
|
|
|
//dc.SetFont( GetLabelingFont() );
|
|
|
|
dc.GetTextExtent(tab.mText, &w, &h );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
tab.mDims.x = w + tab.ImageToTxtGap(mImageTextGap) +
|
|
|
|
tab.ImgWidth() + mTitleHorizGap*2;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
tab.mDims.y = mTitleHeight;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-02-08 06:53:48 -05:00
|
|
|
pNode = pNode->GetNext();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// disable title-bar scroller if there's nowhere to scroll to
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mpTabScroll->Enable( mTitleRowLen < GetWholeTabRowLen() || mCurentRowOfs < 0 );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// event handlers
|
|
|
|
//---------------------------------------------------------------------------
|
2004-02-08 06:53:48 -05:00
|
|
|
void wxPagedWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxPaintDC dc(this);
|
|
|
|
DrawDecorations( dc );
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
void wxPagedWindow::OnSize ( wxSizeEvent& event )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxTabbedWindow::OnSize(event);
|
2000-01-28 10:25:32 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
void wxPagedWindow::OnLButtonDown( wxMouseEvent& event )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( mCursorChanged )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-06-01 14:27:09 -04:00
|
|
|
mIsDragged = true;
|
2001-02-01 15:24:44 -05:00
|
|
|
mDagOrigin = event.m_x;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mOriginalTitleRowLen = mAdjustableTitleRowLen;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
CaptureMouse();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
else
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxTabbedWindow::OnLButtonDown( event );
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
} // wxPagedWindow::OnLButtonDown()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2004-02-08 06:53:48 -05:00
|
|
|
void wxPagedWindow::OnLButtonUp( wxMouseEvent& WXUNUSED(event) )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( mIsDragged )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-06-01 14:27:09 -04:00
|
|
|
mIsDragged = false;
|
|
|
|
mCursorChanged = false;
|
2001-02-01 15:24:44 -05:00
|
|
|
SetCursor( mNormalCursor );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
ReleaseMouse();
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
} // wxPagedWindow::OnLButtonUp()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
void wxPagedWindow::OnMouseMove( wxMouseEvent& event )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
int width, height;
|
|
|
|
GetClientSize( &width, &height );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( !mIsDragged )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
int y = height - mVertGap - BORDER_SZ - mTitleHeight;
|
|
|
|
int x = mTitleRowStart + mTitleRowLen - 6;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
if ( event.m_x >= x && event.m_y >= y &&
|
|
|
|
event.m_x < x + 6 &&
|
|
|
|
event.m_y < y + mTitleHeight
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( !mCursorChanged )
|
|
|
|
{
|
|
|
|
SetCursor( mResizeCursor );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
mCursorChanged = true;
|
2001-02-01 15:24:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if ( mCursorChanged )
|
|
|
|
{
|
|
|
|
SetCursor( mNormalCursor );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
mCursorChanged = false;
|
2001-02-01 15:24:44 -05:00
|
|
|
}
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
2001-02-01 15:24:44 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( mIsDragged )
|
|
|
|
{
|
|
|
|
mAdjustableTitleRowLen = mOriginalTitleRowLen + ( event.m_x - mDagOrigin );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// FOR NOW:: fixed
|
|
|
|
if ( mAdjustableTitleRowLen < 6 ) mAdjustableTitleRowLen = 6;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
wxWindowDC dc(this);
|
|
|
|
DrawDecorations( dc );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
RecalcLayout(false);
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
//Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // wxPagedWindow::OnMouseMove()
|
|
|
|
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2001-02-01 15:24:44 -05:00
|
|
|
void wxPagedWindow::OnScroll( wxScrollEvent& event )
|
2000-01-28 10:25:32 -05:00
|
|
|
{
|
2001-02-01 15:24:44 -05:00
|
|
|
wxScrollBar* pSender = (wxScrollBar*)event.GetEventObject();
|
|
|
|
// wxMessageBox("wxPagedWindow::OnScroll","-I->");
|
|
|
|
if ( pSender == mpTabScroll )
|
2000-01-31 05:43:24 -05:00
|
|
|
{
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
int maxUnits = GetWholeTabRowLen() / 20;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mCurentRowOfs = -event.GetPosition()*maxUnits;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
mFirstTitleGap = mTitleRowStart + mCurentRowOfs + mTabTrianGap;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// let' it automatically disable itself if it's time
|
|
|
|
mpTabScroll->Enable( mTitleRowLen < GetWholeTabRowLen() || mCurentRowOfs < 0 );
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
// repaint title bars
|
|
|
|
wxWindowDC dc(this);
|
|
|
|
DrawDecorations( dc );
|
2000-01-31 05:43:24 -05:00
|
|
|
}
|
|
|
|
else
|
2001-02-01 15:24:44 -05:00
|
|
|
{
|
|
|
|
if ( !mScrollEventInProgress )
|
|
|
|
{
|
2004-06-01 14:27:09 -04:00
|
|
|
mScrollEventInProgress = true;
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2001-02-01 15:24:44 -05:00
|
|
|
GetActiveTab()->GetEventHandler()->ProcessEvent( event );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// event bounced back to us, from here we
|
|
|
|
// know that it has traveled the loop - thus it's processed!
|
2004-10-05 11:38:40 -04:00
|
|
|
|
2004-06-01 14:27:09 -04:00
|
|
|
mScrollEventInProgress = false;
|
2001-02-01 15:24:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // wxPagedWindow::OnScroll()
|
2000-01-28 10:25:32 -05:00
|
|
|
//---------------------------------------------------------------------------
|
2000-01-31 05:43:24 -05:00
|
|
|
|