diff options
author | Ocke Janssen <oj@openoffice.org> | 2002-03-26 08:20:37 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2002-03-26 08:20:37 +0000 |
commit | 76687efc525d82edadf922eabf50085ccae36d8d (patch) | |
tree | 40c435a2b3279200944413512e543261694247de /dbaccess/source/ui/querydesign/TableWindowListBox.cxx | |
parent | #98347# recalc lines before invalidate (diff) | |
download | core-76687efc525d82edadf922eabf50085ccae36d8d.tar.gz core-76687efc525d82edadf922eabf50085ccae36d8d.zip |
#93306# new helper class to scroll while dragging
Diffstat (limited to 'dbaccess/source/ui/querydesign/TableWindowListBox.cxx')
-rw-r--r-- | dbaccess/source/ui/querydesign/TableWindowListBox.cxx | 102 |
1 files changed, 31 insertions, 71 deletions
diff --git a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx index 27e5d0201407..ecaf4065888b 100644 --- a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx +++ b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableWindowListBox.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: oj $ $Date: 2002-03-26 07:56:42 $ + * last change: $Author: oj $ $Date: 2002-03-26 09:19:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -115,9 +115,11 @@ OTableWindowListBox::OTableWindowListBox( OTableWindow* pParent, const String& r ,m_nDropEvent(0) { DBG_CTOR(OTableWindowListBox,NULL); - m_aScrollTimer.SetTimeout( SCROLLING_TIMESPAN ); SetDoubleClickHdl( LINK(this, OTableWindowListBox, DoubleClickHdl) ); + m_aScrollHelper.setUpScrollMethod( LINK(this, OTableWindowListBox, ScrollUpHdl) ); + m_aScrollHelper.setDownScrollMethod( LINK(this, OTableWindowListBox, ScrollDownHdl) ); + SetHighlightRange( ); } @@ -136,8 +138,7 @@ OTableWindowListBox::~OTableWindowListBox() { if (m_nDropEvent) Application::RemoveUserEvent(m_nDropEvent); - if( m_aScrollTimer.IsActive() ) - m_aScrollTimer.Stop(); + m_pTabWin = NULL; DBG_DTOR(OTableWindowListBox,NULL); } @@ -225,40 +226,30 @@ long OTableWindowListBox::PreNotify(NotifyEvent& rNEvt) return SvTreeListBox::PreNotify(rNEvt); return 1L; } - -//------------------------------------------------------------------------------ -IMPL_LINK( OTableWindowListBox, ScrollUpHdl, SvTreeListBox*, pBox ) +// ----------------------------------------------------------------------------- +void scrollWindow(OTableWindowListBox* _pListBox, const Point& _rPos,sal_Bool _bUp) { - SvLBoxEntry* pEntry = GetEntry( m_aMousePos ); - if( !pEntry ) - return 0; + SvLBoxEntry* pEntry = _pListBox->GetEntry( _rPos ); - if( pEntry != Last() ) + if( pEntry && pEntry != _pListBox->Last() ) { - ScrollOutputArea( -1 ); - pEntry = GetEntry( m_aMousePos ); - Select( pEntry, TRUE ); -// m_aScrollTimer.Start(); + _pListBox->ScrollOutputArea( _bUp ? -1 : 1 ); + pEntry = _pListBox->GetEntry( _rPos ); + _pListBox->Select( pEntry, TRUE ); } +} +//------------------------------------------------------------------------------ +IMPL_LINK( OTableWindowListBox, ScrollUpHdl, SvTreeListBox*, EMPTY_ARG ) +{ + scrollWindow(this,m_aMousePos,sal_True); return 0; } //------------------------------------------------------------------------------ -IMPL_LINK( OTableWindowListBox, ScrollDownHdl, SvTreeListBox*, pBox ) +IMPL_LINK( OTableWindowListBox, ScrollDownHdl, SvTreeListBox*, EMPTY_ARG ) { - SvLBoxEntry* pEntry = GetEntry( m_aMousePos ); - if( !pEntry ) - return 0; - - if( pEntry != Last() ) - { - ScrollOutputArea( 1 ); - pEntry = GetEntry( m_aMousePos ); - Select( pEntry, TRUE ); -// m_aScrollTimer.Start(); - } - + scrollWindow(this,m_aMousePos,sal_False); return 0; } @@ -291,7 +282,6 @@ sal_Int8 OTableWindowListBox::AcceptDrop( const AcceptDropEvent& _rEvt ) if (!m_bDragSource && OJoinExchObj::isFormatAvailable(GetDataFlavorExVector())) { // don't drop into the window if it's the drag source itself - // remove the selection if the dragging operation is leaving the window if (_rEvt.mbLeaving) SelectAll(FALSE); @@ -299,49 +289,19 @@ sal_Int8 OTableWindowListBox::AcceptDrop( const AcceptDropEvent& _rEvt ) { // hit test m_aMousePos = _rEvt.maPosPixel; - Size aOutputSize = GetOutputSizePixel(); SvLBoxEntry* pEntry = GetEntry( m_aMousePos ); - if( !pEntry ) - return DND_ACTION_NONE; - - // Scrolling Areas - Rectangle aBottomScrollArea( Point(0, aOutputSize.Height()-LISTBOX_SCROLLING_AREA), - Size(aOutputSize.Width(), LISTBOX_SCROLLING_AREA) ); - Rectangle aTopScrollArea( Point(0,0), Size(aOutputSize.Width(), LISTBOX_SCROLLING_AREA) ); - - // Wenn Zeiger auf der oberen ScrollingArea steht, nach oben scrollen - if( aBottomScrollArea.IsInside(m_aMousePos) ) + if( pEntry ) { - if( !m_aScrollTimer.IsActive() ) - { - m_aScrollTimer.SetTimeoutHdl( LINK(this, OTableWindowListBox, ScrollUpHdl) ); - ScrollUpHdl( this ); - } + m_aScrollHelper.scroll(m_aMousePos,GetOutputSizePixel()); + // Beim Drag automatisch den richtigen Eintrag selektieren + if ((FirstSelected() != pEntry) || (FirstSelected() && NextSelected(FirstSelected()))) + SelectAll(FALSE); + Select(pEntry, TRUE); + + // Auf den ersten Eintrag (*) kann nicht gedroppt werden + if(!( m_pTabWin->GetData()->IsShowAll() && (pEntry==First()) )) + nDND_Action = DND_ACTION_LINK; } - - // Wenn Zeiger auf der oberen ScrollingArea steht, nach unten scrollen - else if( aTopScrollArea.IsInside(m_aMousePos) ) - { - if( !m_aScrollTimer.IsActive() ) - { - m_aScrollTimer.SetTimeoutHdl( LINK(this, OTableWindowListBox, ScrollDownHdl) ); - ScrollDownHdl( this ); - } - } - else - { - if( m_aScrollTimer.IsActive() ) - m_aScrollTimer.Stop(); - } - - // Beim Drag automatisch den richtigen Eintrag selektieren - if ((FirstSelected() != pEntry) || (FirstSelected() && NextSelected(FirstSelected()))) - SelectAll(FALSE); - Select(pEntry, TRUE); - - // Auf den ersten Eintrag (*) kann nicht gedroppt werden - if(!( m_pTabWin->GetData()->IsShowAll() && (pEntry==First()) )) - nDND_Action = DND_ACTION_LINK; } } return nDND_Action; @@ -357,7 +317,7 @@ IMPL_LINK( OTableWindowListBox, DropHdl, void *, EMPTY_ARG) try { OJoinTableView* pCont = m_pTabWin->getTableView(); - OSL_ENSURE(pCont,"No QueryTableView!"); + OSL_ENSURE(pCont,"No OJoinTableView!"); pCont->AddConnection(m_aDropInfo.aSource, m_aDropInfo.aDest); } catch(const SQLException& e) |