2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 11:29:26 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 11:29:26 +00:00
|
|
|
* $RCSfile: split.cxx,v $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-11-01 09:33:57 +00:00
|
|
|
* $Revision: 1.16 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-11-01 09:33:57 +00:00
|
|
|
* last change: $Author: kz $ $Date: 2005-11-01 10:33:57 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 11:29:26 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 11:29:26 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 11:29:26 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 11:29:26 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-09 11:29:26 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _SV_RC_H
|
2004-01-06 13:15:38 +00:00
|
|
|
#include <tools/rc.h>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SV_EVENT_HXX
|
|
|
|
#include <event.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_SPLIT_HXX
|
|
|
|
#include <split.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_SVAPP_HXX
|
|
|
|
#include <svapp.hxx>
|
|
|
|
#endif
|
2002-05-21 10:59:38 +00:00
|
|
|
#ifndef _SV_SYSWIN_HXX
|
|
|
|
#include <syswin.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_TASKPANELIST_HXX
|
|
|
|
#include <taskpanelist.hxx>
|
|
|
|
#endif
|
2002-05-21 11:44:56 +00:00
|
|
|
#ifndef _SV_GRADIENT_HXX
|
|
|
|
#include <gradient.hxx>
|
|
|
|
#endif
|
2004-01-06 13:15:38 +00:00
|
|
|
#ifndef _TL_POLY_HXX
|
|
|
|
#include <tools/poly.hxx>
|
2002-05-23 08:43:15 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _SV_LINEINFO_HXX
|
|
|
|
#include <lineinfo.hxx>
|
|
|
|
#endif
|
2004-06-25 16:09:38 +00:00
|
|
|
#ifndef INCLUDED_RTL_INSTANCE_HXX
|
|
|
|
#include <rtl/instance.hxx>
|
|
|
|
#endif
|
2005-01-13 17:05:01 +00:00
|
|
|
#ifndef _SV_WINDOW_H
|
|
|
|
#include <window.h>
|
|
|
|
#endif
|
2004-06-25 16:09:38 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2004-10-28 05:55:44 +00:00
|
|
|
struct ImplBlackWall
|
|
|
|
: public rtl::StaticWithInit<Wallpaper, ImplBlackWall> {
|
|
|
|
Wallpaper operator () () {
|
|
|
|
return Wallpaper(COL_BLACK);
|
2004-06-25 16:09:38 +00:00
|
|
|
}
|
|
|
|
};
|
2004-10-28 05:55:44 +00:00
|
|
|
struct ImplWhiteWall
|
|
|
|
: public rtl::StaticWithInit<Wallpaper, ImplWhiteWall> {
|
|
|
|
Wallpaper operator () () {
|
|
|
|
return Wallpaper(COL_LIGHTGRAY);
|
2004-06-25 16:09:38 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2002-07-15 11:13:40 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
void Splitter::ImplInitData()
|
|
|
|
{
|
2005-11-01 09:33:57 +00:00
|
|
|
ImplGetWindowImpl()->mbSplitter = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
mpRefWin = NULL;
|
|
|
|
mnSplitPos = 0;
|
|
|
|
mnLastSplitPos = 0;
|
|
|
|
mnStartSplitPos = 0;
|
|
|
|
mbDragFull = FALSE;
|
2002-05-23 08:43:15 +00:00
|
|
|
mbKbdSplitting = FALSE;
|
|
|
|
mbInKeyEvent = 0;
|
2002-07-19 14:24:32 +00:00
|
|
|
mnKeyboardStepSize = SPLITTER_DEFAULTSTEPSIZE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::ImplInit( Window* pParent, WinBits nWinStyle )
|
|
|
|
{
|
|
|
|
Window::ImplInit( pParent, nWinStyle, NULL );
|
|
|
|
|
|
|
|
mpRefWin = pParent;
|
|
|
|
|
|
|
|
const StyleSettings& rSettings = GetSettings().GetStyleSettings();
|
|
|
|
long nA = rSettings.GetScrollBarSize();
|
|
|
|
long nB = rSettings.GetSplitSize();
|
|
|
|
|
|
|
|
PointerStyle ePointerStyle;
|
|
|
|
|
|
|
|
if ( nWinStyle & WB_HSCROLL )
|
|
|
|
{
|
|
|
|
ePointerStyle = POINTER_HSPLIT;
|
|
|
|
mbHorzSplit = TRUE;
|
|
|
|
SetSizePixel( Size( nB, nA ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ePointerStyle = POINTER_VSPLIT;
|
|
|
|
mbHorzSplit = FALSE;
|
|
|
|
SetSizePixel( Size( nA, nB ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPointer( Pointer( ePointerStyle ) );
|
2002-08-14 13:05:52 +00:00
|
|
|
|
2002-07-15 11:13:40 +00:00
|
|
|
if( GetSettings().GetStyleSettings().GetFaceColor().IsDark() )
|
2004-06-25 16:09:38 +00:00
|
|
|
SetBackground( ImplWhiteWall::get() );
|
2002-07-15 11:13:40 +00:00
|
|
|
else
|
2004-06-25 16:09:38 +00:00
|
|
|
SetBackground( ImplBlackWall::get() );
|
2002-05-23 08:43:15 +00:00
|
|
|
|
|
|
|
TaskPaneList *pTList = GetSystemWindow()->GetTaskPaneList();
|
|
|
|
pTList->AddWindow( this );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::ImplSplitMousePos( Point& rPos )
|
|
|
|
{
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
{
|
|
|
|
if ( rPos.X() > maDragRect.Right()-1 )
|
|
|
|
rPos.X() = maDragRect.Right()-1;
|
|
|
|
if ( rPos.X() < maDragRect.Left()+1 )
|
|
|
|
rPos.X() = maDragRect.Left()+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( rPos.Y() > maDragRect.Bottom()-1 )
|
|
|
|
rPos.Y() = maDragRect.Bottom()-1;
|
|
|
|
if ( rPos.Y() < maDragRect.Top()+1 )
|
|
|
|
rPos.Y() = maDragRect.Top()+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::ImplDrawSplitter()
|
|
|
|
{
|
|
|
|
Rectangle aInvRect( maDragRect );
|
|
|
|
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
{
|
|
|
|
aInvRect.Left() = maDragPos.X() - 1;
|
|
|
|
aInvRect.Right() = maDragPos.X() + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aInvRect.Top() = maDragPos.Y() - 1;
|
|
|
|
aInvRect.Bottom() = maDragPos.Y() + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mpRefWin->InvertTracking( aInvRect, SHOWTRACK_SPLIT );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Splitter::Splitter( Window* pParent, WinBits nStyle ) :
|
|
|
|
Window( WINDOW_SPLITTER )
|
|
|
|
{
|
|
|
|
ImplInitData();
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Splitter::Splitter( Window* pParent, const ResId& rResId ) :
|
|
|
|
Window( WINDOW_SPLITTER )
|
|
|
|
{
|
|
|
|
ImplInitData();
|
|
|
|
rResId.SetRT( RSC_SPLITTER );
|
|
|
|
WinBits nStyle = ImplInitRes( rResId );
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
ImplLoadRes( rResId );
|
|
|
|
|
|
|
|
if ( !(nStyle & WB_HIDE) )
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Splitter::~Splitter()
|
|
|
|
{
|
2002-05-23 08:43:15 +00:00
|
|
|
TaskPaneList *pTList = GetSystemWindow()->GetTaskPaneList();
|
|
|
|
pTList->RemoveWindow( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-07-19 14:24:32 +00:00
|
|
|
void Splitter::SetKeyboardStepSize( long nStepSize )
|
|
|
|
{
|
|
|
|
mnKeyboardStepSize = nStepSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
long Splitter::GetKeyboardStepSize() const
|
|
|
|
{
|
|
|
|
return mnKeyboardStepSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-05-23 08:43:15 +00:00
|
|
|
Splitter* Splitter::ImplFindSibling()
|
|
|
|
{
|
|
|
|
// look for another splitter with the same parent but different orientation
|
|
|
|
Window *pWin = GetParent()->GetWindow( WINDOW_FIRSTCHILD );
|
|
|
|
Splitter *pSplitter = NULL;
|
|
|
|
while( pWin )
|
|
|
|
{
|
|
|
|
if( pWin->ImplIsSplitter() )
|
|
|
|
{
|
|
|
|
pSplitter = (Splitter*) pWin;
|
|
|
|
if( pSplitter != this && IsHorizontal() != pSplitter->IsHorizontal() )
|
|
|
|
return pSplitter;
|
|
|
|
}
|
|
|
|
pWin = pWin->GetWindow( WINDOW_NEXT );
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL Splitter::ImplSplitterActive()
|
|
|
|
{
|
|
|
|
// is splitter in document or at scrollbar handle ?
|
|
|
|
|
|
|
|
BOOL bActive = TRUE;
|
|
|
|
const StyleSettings& rSettings = GetSettings().GetStyleSettings();
|
|
|
|
long nA = rSettings.GetScrollBarSize();
|
|
|
|
long nB = rSettings.GetSplitSize();
|
|
|
|
|
|
|
|
Size aSize = GetOutputSize();
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
{
|
|
|
|
if( aSize.Width() == nB && aSize.Height() == nA )
|
|
|
|
bActive = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( aSize.Width() == nA && aSize.Height() == nB )
|
|
|
|
bActive = FALSE;
|
|
|
|
}
|
|
|
|
return bActive;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
|
|
|
if ( rMEvt.GetClicks() == 2 )
|
|
|
|
{
|
|
|
|
if ( mnLastSplitPos != mnSplitPos )
|
|
|
|
{
|
|
|
|
StartSplit();
|
|
|
|
Point aPos = rMEvt.GetPosPixel();
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
aPos.X() = mnLastSplitPos;
|
|
|
|
else
|
|
|
|
aPos.Y() = mnLastSplitPos;
|
|
|
|
ImplSplitMousePos( aPos );
|
|
|
|
Splitting( aPos );
|
|
|
|
ImplSplitMousePos( aPos );
|
|
|
|
long nTemp = mnSplitPos;
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
SetSplitPosPixel( aPos.X() );
|
|
|
|
else
|
|
|
|
SetSplitPosPixel( aPos.Y() );
|
|
|
|
mnLastSplitPos = nTemp;
|
|
|
|
Split();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
StartDrag();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
|
|
|
if ( rTEvt.IsTrackingEnded() )
|
|
|
|
{
|
|
|
|
if ( !mbDragFull )
|
|
|
|
ImplDrawSplitter();
|
|
|
|
|
|
|
|
if ( !rTEvt.IsTrackingCanceled() )
|
|
|
|
{
|
|
|
|
long nNewPos;
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
nNewPos = maDragPos.X();
|
|
|
|
else
|
|
|
|
nNewPos = maDragPos.Y();
|
|
|
|
if ( nNewPos != mnStartSplitPos )
|
|
|
|
{
|
|
|
|
SetSplitPosPixel( nNewPos );
|
|
|
|
mnLastSplitPos = 0;
|
|
|
|
Split();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( mbDragFull )
|
|
|
|
{
|
|
|
|
SetSplitPosPixel( mnStartSplitPos );
|
|
|
|
Split();
|
|
|
|
}
|
|
|
|
mnStartSplitPos = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-03 10:54:27 +00:00
|
|
|
//Point aNewPos = mpRefWin->ScreenToOutputPixel( OutputToScreenPixel( rTEvt.GetMouseEvent().GetPosPixel() ) );
|
|
|
|
Point aNewPos = mpRefWin->NormalizedScreenToOutputPixel( OutputToNormalizedScreenPixel( rTEvt.GetMouseEvent().GetPosPixel() ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplSplitMousePos( aNewPos );
|
|
|
|
Splitting( aNewPos );
|
|
|
|
ImplSplitMousePos( aNewPos );
|
|
|
|
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
{
|
|
|
|
if ( aNewPos.X() == maDragPos.X() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( aNewPos.Y() == maDragPos.Y() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( mbDragFull )
|
|
|
|
{
|
|
|
|
maDragPos = aNewPos;
|
|
|
|
long nNewPos;
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
nNewPos = maDragPos.X();
|
|
|
|
else
|
|
|
|
nNewPos = maDragPos.Y();
|
|
|
|
if ( nNewPos != mnSplitPos )
|
|
|
|
{
|
|
|
|
SetSplitPosPixel( nNewPos );
|
|
|
|
mnLastSplitPos = 0;
|
|
|
|
Split();
|
|
|
|
}
|
|
|
|
|
|
|
|
GetParent()->Update();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ImplDrawSplitter();
|
|
|
|
maDragPos = aNewPos;
|
|
|
|
ImplDrawSplitter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-05-23 08:43:15 +00:00
|
|
|
void Splitter::ImplKbdTracking( KeyCode aKeyCode )
|
|
|
|
{
|
|
|
|
USHORT nCode = aKeyCode.GetCode();
|
|
|
|
if ( nCode == KEY_ESCAPE || nCode == KEY_RETURN )
|
|
|
|
{
|
|
|
|
if( !mbKbdSplitting )
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
mbKbdSplitting = FALSE;
|
|
|
|
|
|
|
|
if ( nCode != KEY_ESCAPE )
|
|
|
|
{
|
|
|
|
long nNewPos;
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
nNewPos = maDragPos.X();
|
|
|
|
else
|
|
|
|
nNewPos = maDragPos.Y();
|
|
|
|
if ( nNewPos != mnStartSplitPos )
|
|
|
|
{
|
|
|
|
SetSplitPosPixel( nNewPos );
|
|
|
|
mnLastSplitPos = 0;
|
|
|
|
Split();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetSplitPosPixel( mnStartSplitPos );
|
|
|
|
Split();
|
|
|
|
}
|
|
|
|
mnStartSplitPos = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Point aNewPos;
|
|
|
|
Size aSize = mpRefWin->GetOutputSize();
|
|
|
|
Point aPos = GetPosPixel();
|
|
|
|
// depending on the position calc allows continous moves or snaps to row/columns
|
|
|
|
// continous mode is active when position is at the origin or end of the splitter
|
|
|
|
// otherwise snap mode is active
|
|
|
|
// default here is snap, holding shift sets continous mode
|
|
|
|
if( mbHorzSplit )
|
|
|
|
aNewPos = Point( ImplSplitterActive() ? aPos.X() : mnSplitPos, aKeyCode.IsShift() ? 0 : aSize.Height()/2);
|
|
|
|
else
|
|
|
|
aNewPos = Point( aKeyCode.IsShift() ? 0 : aSize.Width()/2, ImplSplitterActive() ? aPos.Y() : mnSplitPos );
|
|
|
|
|
|
|
|
Point aOldWindowPos = GetPosPixel();
|
|
|
|
|
|
|
|
int maxiter = 500; // avoid endless loop
|
|
|
|
int delta=0;
|
2002-07-19 14:24:32 +00:00
|
|
|
int delta_step = mbHorzSplit ? aSize.Width()/10 : aSize.Height()/10;
|
|
|
|
|
|
|
|
// use the specified step size if it was set
|
|
|
|
if( mnKeyboardStepSize != SPLITTER_DEFAULTSTEPSIZE )
|
|
|
|
delta_step = mnKeyboardStepSize;
|
|
|
|
|
2002-05-23 08:43:15 +00:00
|
|
|
while( maxiter-- && aOldWindowPos == GetPosPixel() )
|
|
|
|
{
|
|
|
|
// inc/dec position until application performs changes
|
|
|
|
// thus a single key press really moves the splitter
|
2002-07-19 14:24:32 +00:00
|
|
|
if( aKeyCode.IsShift() )
|
|
|
|
delta++;
|
|
|
|
else
|
|
|
|
delta += delta_step;
|
|
|
|
|
2002-05-23 08:43:15 +00:00
|
|
|
switch( nCode )
|
|
|
|
{
|
|
|
|
case KEY_LEFT:
|
|
|
|
aNewPos.X()-=delta;
|
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
|
|
|
aNewPos.X()+=delta;
|
|
|
|
break;
|
|
|
|
case KEY_UP:
|
|
|
|
aNewPos.Y()-=delta;
|
|
|
|
break;
|
|
|
|
case KEY_DOWN:
|
|
|
|
aNewPos.Y()+=delta;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
maxiter = 0; // leave loop
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ImplSplitMousePos( aNewPos );
|
|
|
|
Splitting( aNewPos );
|
|
|
|
ImplSplitMousePos( aNewPos );
|
|
|
|
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
{
|
|
|
|
if ( aNewPos.X() == maDragPos.X() )
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( aNewPos.Y() == maDragPos.Y() )
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
maDragPos = aNewPos;
|
|
|
|
long nNewPos;
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
nNewPos = maDragPos.X();
|
|
|
|
else
|
|
|
|
nNewPos = maDragPos.Y();
|
|
|
|
if ( nNewPos != mnSplitPos )
|
|
|
|
{
|
|
|
|
SetSplitPosPixel( nNewPos );
|
|
|
|
mnLastSplitPos = 0;
|
|
|
|
Split();
|
|
|
|
}
|
|
|
|
GetParent()->Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void Splitter::StartSplit()
|
|
|
|
{
|
|
|
|
maStartSplitHdl.Call( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::Split()
|
|
|
|
{
|
|
|
|
maSplitHdl.Call( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::Splitting( Point& /* rSplitPos */ )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::SetDragRectPixel( const Rectangle& rDragRect, Window* _pRefWin )
|
|
|
|
{
|
|
|
|
maDragRect = rDragRect;
|
|
|
|
if ( !_pRefWin )
|
|
|
|
mpRefWin = GetParent();
|
|
|
|
else
|
|
|
|
mpRefWin = _pRefWin;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::SetSplitPosPixel( long nNewPos )
|
|
|
|
{
|
|
|
|
mnSplitPos = nNewPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::SetLastSplitPosPixel( long nNewPos )
|
|
|
|
{
|
|
|
|
mnLastSplitPos = nNewPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::StartDrag()
|
|
|
|
{
|
|
|
|
if ( IsTracking() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
StartSplit();
|
|
|
|
|
|
|
|
// Tracking starten
|
|
|
|
StartTracking();
|
|
|
|
|
|
|
|
// Start-Positon ermitteln
|
|
|
|
maDragPos = mpRefWin->GetPointerPosPixel();
|
|
|
|
ImplSplitMousePos( maDragPos );
|
|
|
|
Splitting( maDragPos );
|
|
|
|
ImplSplitMousePos( maDragPos );
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
mnStartSplitPos = maDragPos.X();
|
|
|
|
else
|
|
|
|
mnStartSplitPos = maDragPos.Y();
|
|
|
|
|
|
|
|
mbDragFull = (Application::GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_SPLIT) != 0;
|
|
|
|
if ( !mbDragFull )
|
|
|
|
ImplDrawSplitter();
|
|
|
|
}
|
2002-05-21 10:59:38 +00:00
|
|
|
|
|
|
|
|
2002-05-23 08:43:15 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::ImplStartKbdSplitting()
|
|
|
|
{
|
|
|
|
if( mbKbdSplitting )
|
|
|
|
return;
|
|
|
|
|
|
|
|
mbKbdSplitting = TRUE;
|
|
|
|
|
|
|
|
StartSplit();
|
|
|
|
|
|
|
|
// determine start position
|
|
|
|
// because we have no mouse position we take either the position
|
|
|
|
// of the splitter window or the last split position
|
|
|
|
// the other coordinate is just the center of the reference window
|
|
|
|
Size aSize = mpRefWin->GetOutputSize();
|
|
|
|
Point aPos = GetPosPixel();
|
|
|
|
if( mbHorzSplit )
|
|
|
|
maDragPos = Point( ImplSplitterActive() ? aPos.X() : mnSplitPos, aSize.Height()/2 );
|
|
|
|
else
|
|
|
|
maDragPos = Point( aSize.Width()/2, ImplSplitterActive() ? aPos.Y() : mnSplitPos );
|
|
|
|
ImplSplitMousePos( maDragPos );
|
|
|
|
Splitting( maDragPos );
|
|
|
|
ImplSplitMousePos( maDragPos );
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
mnStartSplitPos = maDragPos.X();
|
|
|
|
else
|
|
|
|
mnStartSplitPos = maDragPos.Y();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::ImplRestoreSplitter()
|
|
|
|
{
|
|
|
|
// set splitter in the center of the ref window
|
|
|
|
StartSplit();
|
|
|
|
Size aSize = mpRefWin->GetOutputSize();
|
|
|
|
Point aPos = Point( aSize.Width()/2 , aSize.Height()/2);
|
|
|
|
if ( mnLastSplitPos != mnSplitPos && mnLastSplitPos > 5 )
|
|
|
|
{
|
|
|
|
// restore last pos if it was a useful position (>5)
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
aPos.X() = mnLastSplitPos;
|
|
|
|
else
|
|
|
|
aPos.Y() = mnLastSplitPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImplSplitMousePos( aPos );
|
|
|
|
Splitting( aPos );
|
|
|
|
ImplSplitMousePos( aPos );
|
|
|
|
long nTemp = mnSplitPos;
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
SetSplitPosPixel( aPos.X() );
|
|
|
|
else
|
|
|
|
SetSplitPosPixel( aPos.Y() );
|
|
|
|
mnLastSplitPos = nTemp;
|
|
|
|
Split();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-21 10:59:38 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::GetFocus()
|
|
|
|
{
|
2002-05-23 08:43:15 +00:00
|
|
|
if( !ImplSplitterActive() )
|
|
|
|
ImplRestoreSplitter();
|
|
|
|
|
|
|
|
Invalidate();
|
2002-05-21 10:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::LoseFocus()
|
|
|
|
{
|
2002-05-23 08:43:15 +00:00
|
|
|
if( mbKbdSplitting )
|
|
|
|
{
|
|
|
|
KeyCode aReturnKey( KEY_RETURN );
|
|
|
|
ImplKbdTracking( aReturnKey );
|
|
|
|
mbKbdSplitting = FALSE;
|
|
|
|
}
|
|
|
|
Invalidate();
|
2002-05-21 10:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Splitter::KeyInput( const KeyEvent& rKEvt )
|
|
|
|
{
|
2002-05-23 08:43:15 +00:00
|
|
|
if( mbInKeyEvent )
|
|
|
|
return;
|
|
|
|
|
|
|
|
mbInKeyEvent = 1;
|
|
|
|
|
|
|
|
Splitter *pSibling = ImplFindSibling();
|
|
|
|
KeyCode aKeyCode = rKEvt.GetKeyCode();
|
|
|
|
USHORT nCode = aKeyCode.GetCode();
|
|
|
|
switch ( nCode )
|
|
|
|
{
|
|
|
|
case KEY_UP:
|
|
|
|
case KEY_DOWN:
|
|
|
|
if( !mbHorzSplit )
|
|
|
|
{
|
|
|
|
ImplStartKbdSplitting();
|
|
|
|
ImplKbdTracking( aKeyCode );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( pSibling )
|
|
|
|
{
|
|
|
|
pSibling->GrabFocus();
|
|
|
|
pSibling->KeyInput( rKEvt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
|
|
|
case KEY_LEFT:
|
|
|
|
if( mbHorzSplit )
|
|
|
|
{
|
|
|
|
ImplStartKbdSplitting();
|
|
|
|
ImplKbdTracking( aKeyCode );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( pSibling )
|
|
|
|
{
|
|
|
|
pSibling->GrabFocus();
|
|
|
|
pSibling->KeyInput( rKEvt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_DELETE:
|
|
|
|
if( ImplSplitterActive() )
|
|
|
|
{
|
|
|
|
if( mbKbdSplitting )
|
|
|
|
{
|
|
|
|
KeyCode aKey( KEY_ESCAPE );
|
|
|
|
ImplKbdTracking( aKey );
|
|
|
|
}
|
|
|
|
|
|
|
|
StartSplit();
|
|
|
|
Point aPos;
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
aPos.X() = 0;
|
|
|
|
else
|
|
|
|
aPos.Y() = 0;
|
|
|
|
ImplSplitMousePos( aPos );
|
|
|
|
Splitting( aPos );
|
|
|
|
ImplSplitMousePos( aPos );
|
|
|
|
long nTemp = mnSplitPos;
|
|
|
|
if ( mbHorzSplit )
|
|
|
|
SetSplitPosPixel( aPos.X() );
|
|
|
|
else
|
|
|
|
SetSplitPosPixel( aPos.Y() );
|
|
|
|
mnLastSplitPos = nTemp;
|
|
|
|
Split();
|
|
|
|
|
|
|
|
// Shift-Del deletes both splitters
|
|
|
|
if( aKeyCode.IsShift() && pSibling )
|
|
|
|
pSibling->KeyInput( rKEvt );
|
|
|
|
|
|
|
|
GrabFocusToDocument();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_ESCAPE:
|
|
|
|
if( mbKbdSplitting )
|
|
|
|
ImplKbdTracking( aKeyCode );
|
|
|
|
else
|
|
|
|
GrabFocusToDocument();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_RETURN:
|
|
|
|
ImplKbdTracking( aKeyCode );
|
|
|
|
GrabFocusToDocument();
|
|
|
|
break;
|
|
|
|
default: // let any key input fix the splitter
|
|
|
|
Window::KeyInput( rKEvt );
|
|
|
|
GrabFocusToDocument();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mbInKeyEvent = 0;
|
2002-05-21 10:59:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
long Splitter::Notify( NotifyEvent& rNEvt )
|
|
|
|
{
|
|
|
|
return Window::Notify( rNEvt );
|
|
|
|
}
|
|
|
|
|
2002-05-21 11:44:56 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-08-14 13:05:52 +00:00
|
|
|
void Splitter::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Window::DataChanged( rDCEvt );
|
|
|
|
if( rDCEvt.GetType() == DATACHANGED_SETTINGS )
|
|
|
|
{
|
|
|
|
Color oldFaceColor = ((AllSettings *) rDCEvt.GetData())->GetStyleSettings().GetFaceColor();
|
|
|
|
Color newFaceColor = Application::GetSettings().GetStyleSettings().GetFaceColor();
|
|
|
|
if( oldFaceColor.IsDark() != newFaceColor.IsDark() )
|
|
|
|
{
|
|
|
|
if( newFaceColor.IsDark() )
|
2004-06-25 16:09:38 +00:00
|
|
|
SetBackground( ImplWhiteWall::get() );
|
2002-08-14 13:05:52 +00:00
|
|
|
else
|
2004-06-25 16:09:38 +00:00
|
|
|
SetBackground( ImplBlackWall::get() );
|
2002-08-14 13:05:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-05-21 11:44:56 +00:00
|
|
|
void Splitter::Paint( const Rectangle& rPaintRect )
|
|
|
|
{
|
2002-05-23 08:43:15 +00:00
|
|
|
if( HasFocus() || mbKbdSplitting )
|
|
|
|
{
|
|
|
|
Color oldFillCol = GetFillColor();
|
|
|
|
Color oldLineCol = GetLineColor();
|
|
|
|
|
|
|
|
SetLineColor();
|
|
|
|
SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
|
|
|
|
DrawRect( rPaintRect );
|
|
|
|
|
|
|
|
Color aSelectionBorderCol( GetSettings().GetStyleSettings().GetActiveColor() );
|
|
|
|
SetFillColor( aSelectionBorderCol );
|
|
|
|
SetLineColor();
|
|
|
|
|
|
|
|
Polygon aPoly( rPaintRect );
|
|
|
|
PolyPolygon aPolyPoly( aPoly );
|
|
|
|
DrawTransparent( aPolyPoly, 85 );
|
|
|
|
|
|
|
|
SetLineColor( aSelectionBorderCol );
|
|
|
|
SetFillColor();
|
|
|
|
|
|
|
|
if( mbKbdSplitting )
|
|
|
|
{
|
|
|
|
LineInfo aInfo( LINE_DASH );
|
|
|
|
//aInfo.SetDashLen( 2 );
|
|
|
|
//aInfo.SetDashCount( 1 );
|
|
|
|
aInfo.SetDistance( 1 );
|
|
|
|
aInfo.SetDotLen( 2 );
|
|
|
|
aInfo.SetDotCount( 1 );
|
|
|
|
|
|
|
|
DrawPolyLine( aPoly, aInfo );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DrawRect( rPaintRect );
|
|
|
|
|
|
|
|
SetFillColor( oldFillCol);
|
|
|
|
SetLineColor( oldLineCol);
|
|
|
|
}
|
|
|
|
else
|
2002-07-15 11:13:40 +00:00
|
|
|
{
|
2002-05-23 08:43:15 +00:00
|
|
|
Window::Paint( rPaintRect );
|
2002-07-15 11:13:40 +00:00
|
|
|
}
|
2002-05-21 11:44:56 +00:00
|
|
|
}
|