1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svtools.hxx" 30*cdf0e10cSrcweir #include <tools/debug.hxx> 31*cdf0e10cSrcweir #include <svtools/brwbox.hxx> 32*cdf0e10cSrcweir #include "datwin.hxx" 33*cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 34*cdf0e10cSrcweir #include <vcl/salgtype.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #ifndef GCC 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir #include <tools/multisel.hxx> 39*cdf0e10cSrcweir #include <algorithm> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #define getDataWindow() ((BrowserDataWin*)pDataWin) 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //=================================================================== 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir DBG_NAMEEX(BrowseBox) 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir //=================================================================== 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir extern const char* BrowseBoxCheckInvariants( const void * pVoid ); 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir DECLARE_LIST( BrowserColumns, BrowserColumn* ) 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir //=================================================================== 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir void BrowseBox::StartDrag( sal_Int8 /* _nAction */, const Point& /* _rPosPixel */ ) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 61*cdf0e10cSrcweir // not interested in this event 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir //=================================================================== 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir sal_Int8 BrowseBox::AcceptDrop( const AcceptDropEvent& _rEvt ) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir BrowserDataWin* pDataWindow = static_cast<BrowserDataWin*>(pDataWin); 69*cdf0e10cSrcweir AcceptDropEvent aTransformed( _rEvt ); 70*cdf0e10cSrcweir aTransformed.maPosPixel = pDataWindow->ScreenToOutputPixel( OutputToScreenPixel( _rEvt.maPosPixel ) ); 71*cdf0e10cSrcweir return pDataWindow->AcceptDrop( aTransformed ); 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir //=================================================================== 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir sal_Int8 BrowseBox::ExecuteDrop( const ExecuteDropEvent& _rEvt ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir BrowserDataWin* pDataWindow = static_cast<BrowserDataWin*>(pDataWin); 79*cdf0e10cSrcweir ExecuteDropEvent aTransformed( _rEvt ); 80*cdf0e10cSrcweir aTransformed.maPosPixel = pDataWindow->ScreenToOutputPixel( OutputToScreenPixel( _rEvt.maPosPixel ) ); 81*cdf0e10cSrcweir return pDataWindow->ExecuteDrop( aTransformed ); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir //=================================================================== 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir sal_Int8 BrowseBox::AcceptDrop( const BrowserAcceptDropEvent& ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 89*cdf0e10cSrcweir // not interested in this event 90*cdf0e10cSrcweir return DND_ACTION_NONE; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir //=================================================================== 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir sal_Int8 BrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& ) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 98*cdf0e10cSrcweir // not interested in this event 99*cdf0e10cSrcweir return DND_ACTION_NONE; 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir //=================================================================== 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir void* BrowseBox::implGetDataFlavors() const 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir if (static_cast<BrowserDataWin*>(pDataWin)->bCallingDropCallback) 107*cdf0e10cSrcweir return &static_cast<BrowserDataWin*>(pDataWin)->GetDataFlavorExVector(); 108*cdf0e10cSrcweir return &GetDataFlavorExVector(); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir //=================================================================== 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir sal_Bool BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir if ( static_cast< BrowserDataWin* >( pDataWin )->bCallingDropCallback ) 116*cdf0e10cSrcweir return static_cast< BrowserDataWin* >( pDataWin )->IsDropFormatSupported( _nFormat ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir return DropTargetHelper::IsDropFormatSupported( _nFormat ); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir //=================================================================== 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir sal_Bool BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat ) const 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir return const_cast< BrowseBox* >( this )->IsDropFormatSupported( _nFormat ); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir //=================================================================== 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir sal_Bool BrowseBox::IsDropFormatSupported( const DataFlavor& _rFlavor ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir if ( static_cast< BrowserDataWin* >( pDataWin )->bCallingDropCallback ) 133*cdf0e10cSrcweir return static_cast< BrowserDataWin* >( pDataWin )->IsDropFormatSupported( _rFlavor ); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir return DropTargetHelper::IsDropFormatSupported( _rFlavor ); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir //=================================================================== 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir sal_Bool BrowseBox::IsDropFormatSupported( const DataFlavor& _rFlavor ) const 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir return const_cast< BrowseBox* >( this )->IsDropFormatSupported( _rFlavor ); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir //=================================================================== 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir void BrowseBox::Command( const CommandEvent& rEvt ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir if ( !getDataWindow()->bInCommand ) 150*cdf0e10cSrcweir Control::Command( rEvt ); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir //=================================================================== 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir bool BrowseBox::IsInCommandEvent() const 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir return getDataWindow()->bInCommand; 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir //=================================================================== 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir void BrowseBox::StateChanged( StateChangedType nStateChange ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir Control::StateChanged( nStateChange ); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir if ( STATE_CHANGE_MIRRORING == nStateChange ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir getDataWindow()->EnableRTL( IsRTLEnabled() ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar; 171*cdf0e10cSrcweir if ( pHeaderBar ) 172*cdf0e10cSrcweir pHeaderBar->EnableRTL( IsRTLEnabled() ); 173*cdf0e10cSrcweir aHScroll.EnableRTL( IsRTLEnabled() ); 174*cdf0e10cSrcweir if( pVScroll ) 175*cdf0e10cSrcweir pVScroll->EnableRTL( IsRTLEnabled() ); 176*cdf0e10cSrcweir Resize(); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir else if ( STATE_CHANGE_INITSHOW == nStateChange ) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir bBootstrapped = sal_True; // muss zuerst gesetzt werden! 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir Resize(); 183*cdf0e10cSrcweir if ( bMultiSelection ) 184*cdf0e10cSrcweir uRow.pSel->SetTotalRange( Range( 0, nRowCount - 1 ) ); 185*cdf0e10cSrcweir if ( nRowCount == 0 ) 186*cdf0e10cSrcweir nCurRow = BROWSER_ENDOFSELECTION; 187*cdf0e10cSrcweir else if ( nCurRow == BROWSER_ENDOFSELECTION ) 188*cdf0e10cSrcweir nCurRow = 0; 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir if ( HasFocus() ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir bSelectionIsVisible = sal_True; 194*cdf0e10cSrcweir bHasFocus = sal_True; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir UpdateScrollbars(); 197*cdf0e10cSrcweir AutoSizeLastColumn(); 198*cdf0e10cSrcweir CursorMoved(); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir else if (STATE_CHANGE_ZOOM == nStateChange) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir pDataWin->SetZoom(GetZoom()); 203*cdf0e10cSrcweir HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar; 204*cdf0e10cSrcweir if (pHeaderBar) 205*cdf0e10cSrcweir pHeaderBar->SetZoom(GetZoom()); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // let the cols calc their new widths and adjust the header bar 208*cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pCols->Count(); ++nPos ) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir pCols->GetObject(nPos)->ZoomChanged(GetZoom()); 211*cdf0e10cSrcweir if ( pHeaderBar ) 212*cdf0e10cSrcweir pHeaderBar->SetItemSize( pCols->GetObject(nPos)->GetId(), pCols->GetObject(nPos)->Width() ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir // all our controls have to be repositioned 216*cdf0e10cSrcweir Resize(); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir else if (STATE_CHANGE_ENABLE == nStateChange) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir // do we have a handle column? 221*cdf0e10cSrcweir sal_Bool bHandleCol = pCols->Count() && (0 == pCols->GetObject(0)->GetId()); 222*cdf0e10cSrcweir // do we have a header bar 223*cdf0e10cSrcweir sal_Bool bHeaderBar = (NULL != static_cast<BrowserDataWin&>(GetDataWindow()).pHeaderBar); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir if ( nTitleLines 226*cdf0e10cSrcweir && ( !bHeaderBar 227*cdf0e10cSrcweir || bHandleCol 228*cdf0e10cSrcweir ) 229*cdf0e10cSrcweir ) 230*cdf0e10cSrcweir // we draw the text in our header bar in a color dependent on the enabled state. So if this state changed 231*cdf0e10cSrcweir // -> redraw 232*cdf0e10cSrcweir Invalidate(Rectangle(Point(0, 0), Size(GetOutputSizePixel().Width(), GetTitleHeight() - 1))); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir //=================================================================== 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir void BrowseBox::Select() 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir //------------------------------------------------------------------- 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir void BrowseBox::DoubleClick( const BrowserMouseEvent & ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir //------------------------------------------------------------------- 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir long BrowseBox::QueryMinimumRowHeight() 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 255*cdf0e10cSrcweir return CalcZoom( 5 ); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir //------------------------------------------------------------------- 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir void BrowseBox::ImplStartTracking() 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir //------------------------------------------------------------------- 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir void BrowseBox::ImplTracking() 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants ); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir //------------------------------------------------------------------- 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir void BrowseBox::ImplEndTracking() 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants ); 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir //------------------------------------------------------------------- 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir void BrowseBox::RowHeightChanged() 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir //------------------------------------------------------------------- 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir long BrowseBox::QueryColumnResize( sal_uInt16, long nWidth ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 291*cdf0e10cSrcweir return nWidth; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir //------------------------------------------------------------------- 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir void BrowseBox::ColumnResized( sal_uInt16 ) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir //------------------------------------------------------------------- 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir void BrowseBox::ColumnMoved( sal_uInt16 ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir //------------------------------------------------------------------- 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir void BrowseBox::StartScroll() 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 313*cdf0e10cSrcweir //((Control*)pDataWin)->HideFocus(); 314*cdf0e10cSrcweir DoHideCursor( "StartScroll" ); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir //------------------------------------------------------------------- 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir void BrowseBox::EndScroll() 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 322*cdf0e10cSrcweir UpdateScrollbars(); 323*cdf0e10cSrcweir AutoSizeLastColumn(); 324*cdf0e10cSrcweir DoShowCursor( "EndScroll" ); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir //------------------------------------------------------------------- 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir #ifdef _MSC_VER 330*cdf0e10cSrcweir #pragma optimize( "", off ) 331*cdf0e10cSrcweir #endif 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir void BrowseBox::ToggleSelection( sal_Bool bForce ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir // selection highlight-toggling allowed? 338*cdf0e10cSrcweir if ( bHideSelect ) 339*cdf0e10cSrcweir return; 340*cdf0e10cSrcweir if ( !bForce && 341*cdf0e10cSrcweir ( bNotToggleSel || !IsUpdateMode() || !bSelectionIsVisible ) ) 342*cdf0e10cSrcweir return; 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir // only highlight painted areas! 345*cdf0e10cSrcweir bNotToggleSel = sal_True; 346*cdf0e10cSrcweir if ( sal_False && !getDataWindow()->bInPaint ) 347*cdf0e10cSrcweir pDataWin->Update(); 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir // accumulate areas of rows to highlight 350*cdf0e10cSrcweir RectangleList aHighlightList; 351*cdf0e10cSrcweir long nLastRowInRect = 0; // fuer den CFront 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir // Handle-Column nicht highlighten 354*cdf0e10cSrcweir BrowserColumn *pFirstCol = pCols->GetObject(0); 355*cdf0e10cSrcweir long nOfsX = (!pFirstCol || pFirstCol->GetId()) ? 0 : pFirstCol->Width(); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir // accumulate old row selection 358*cdf0e10cSrcweir long nBottomRow = nTopRow + 359*cdf0e10cSrcweir pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight(); 360*cdf0e10cSrcweir if ( nBottomRow > GetRowCount() && GetRowCount() ) 361*cdf0e10cSrcweir nBottomRow = GetRowCount(); 362*cdf0e10cSrcweir for ( long nRow = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel; 363*cdf0e10cSrcweir nRow != BROWSER_ENDOFSELECTION && nRow <= nBottomRow; 364*cdf0e10cSrcweir nRow = bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION ) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir if ( nRow < nTopRow ) 367*cdf0e10cSrcweir continue; 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir Rectangle aAddRect( 370*cdf0e10cSrcweir Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ), 371*cdf0e10cSrcweir Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) ); 372*cdf0e10cSrcweir if ( aHighlightList.Count() && nLastRowInRect == ( nRow - 1 ) ) 373*cdf0e10cSrcweir aHighlightList.First()->Union( aAddRect ); 374*cdf0e10cSrcweir else 375*cdf0e10cSrcweir aHighlightList.Insert( new Rectangle( aAddRect ), (sal_uLong) 0 ); 376*cdf0e10cSrcweir nLastRowInRect = nRow; 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir // unhighlight the old selection (if any) 380*cdf0e10cSrcweir while ( aHighlightList.Count() ) 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir Rectangle *pRect = aHighlightList.Remove( aHighlightList.Count() - 1 ); 383*cdf0e10cSrcweir pDataWin->Invalidate( *pRect ); 384*cdf0e10cSrcweir delete pRect; 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir // unhighlight old column selection (if any) 388*cdf0e10cSrcweir for ( long nColId = pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION; 389*cdf0e10cSrcweir nColId != BROWSER_ENDOFSELECTION; 390*cdf0e10cSrcweir nColId = pColSel->NextSelected() ) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir Rectangle aRect( GetFieldRectPixel(nCurRow, 393*cdf0e10cSrcweir pCols->GetObject(nColId)->GetId(), 394*cdf0e10cSrcweir sal_False ) ); 395*cdf0e10cSrcweir aRect.Left() -= MIN_COLUMNWIDTH; 396*cdf0e10cSrcweir aRect.Right() += MIN_COLUMNWIDTH; 397*cdf0e10cSrcweir aRect.Top() = 0; 398*cdf0e10cSrcweir aRect.Bottom() = pDataWin->GetOutputSizePixel().Height(); 399*cdf0e10cSrcweir pDataWin->Invalidate( aRect ); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir bNotToggleSel = sal_False; 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir #ifdef _MSC_VER 406*cdf0e10cSrcweir #pragma optimize( "", on ) 407*cdf0e10cSrcweir #endif 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir //------------------------------------------------------------------- 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir void BrowseBox::DrawCursor() 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir sal_Bool bReallyHide = sal_False; 414*cdf0e10cSrcweir if ( SMART_CURSOR_HIDE == bHideCursor ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir if ( !GetSelectRowCount() && !GetSelectColumnCount() ) 417*cdf0e10cSrcweir bReallyHide = sal_True; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir else if ( HARD_CURSOR_HIDE == bHideCursor ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir bReallyHide = sal_True; 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir bReallyHide |= !bSelectionIsVisible || !IsUpdateMode() || bScrolling || nCurRow < 0; 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir if (PaintCursorIfHiddenOnce()) 427*cdf0e10cSrcweir bReallyHide |= ( GetCursorHideCount() > 1 ); 428*cdf0e10cSrcweir else 429*cdf0e10cSrcweir bReallyHide |= ( GetCursorHideCount() > 0 ); 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir // keine Cursor auf Handle-Column 432*cdf0e10cSrcweir if ( nCurColId == 0 ) 433*cdf0e10cSrcweir nCurColId = GetColumnId(1); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir // Cursor-Rechteck berechnen 436*cdf0e10cSrcweir Rectangle aCursor; 437*cdf0e10cSrcweir if ( bColumnCursor ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir aCursor = GetFieldRectPixel( nCurRow, nCurColId, sal_False ); 440*cdf0e10cSrcweir //! --aCursor.Bottom(); 441*cdf0e10cSrcweir aCursor.Left() -= MIN_COLUMNWIDTH; 442*cdf0e10cSrcweir aCursor.Right() += 1; 443*cdf0e10cSrcweir aCursor.Bottom() += 1; 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir else 446*cdf0e10cSrcweir aCursor = Rectangle( 447*cdf0e10cSrcweir Point( ( pCols->Count() && pCols->GetObject(0)->GetId() == 0 ) ? 448*cdf0e10cSrcweir pCols->GetObject(0)->Width() : 0, 449*cdf0e10cSrcweir (nCurRow - nTopRow) * GetDataRowHeight() + 1 ), 450*cdf0e10cSrcweir Size( pDataWin->GetOutputSizePixel().Width() + 1, 451*cdf0e10cSrcweir GetDataRowHeight() - 2 ) ); 452*cdf0e10cSrcweir if ( bHLines ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir if ( !bMultiSelection ) 455*cdf0e10cSrcweir --aCursor.Top(); 456*cdf0e10cSrcweir --aCursor.Bottom(); 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir //!mi_mac pDataWin->Update(); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir if (m_aCursorColor == COL_TRANSPARENT) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir // auf diesem Plattformen funktioniert der StarView-Focus richtig 464*cdf0e10cSrcweir if ( bReallyHide ) 465*cdf0e10cSrcweir ((Control*)pDataWin)->HideFocus(); 466*cdf0e10cSrcweir else 467*cdf0e10cSrcweir ((Control*)pDataWin)->ShowFocus( aCursor ); 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir else 470*cdf0e10cSrcweir { 471*cdf0e10cSrcweir Color rCol = bReallyHide ? pDataWin->GetFillColor() : m_aCursorColor; 472*cdf0e10cSrcweir Color aOldFillColor = pDataWin->GetFillColor(); 473*cdf0e10cSrcweir Color aOldLineColor = pDataWin->GetLineColor(); 474*cdf0e10cSrcweir pDataWin->SetFillColor(); 475*cdf0e10cSrcweir pDataWin->SetLineColor( rCol ); 476*cdf0e10cSrcweir pDataWin->DrawRect( aCursor ); 477*cdf0e10cSrcweir pDataWin->SetLineColor( aOldLineColor ); 478*cdf0e10cSrcweir pDataWin->SetFillColor( aOldFillColor ); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir //------------------------------------------------------------------- 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir sal_uLong BrowseBox::GetColumnWidth( sal_uInt16 nId ) const 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir sal_uInt16 nItemPos = GetColumnPos( nId ); 489*cdf0e10cSrcweir if ( nItemPos >= pCols->Count() ) 490*cdf0e10cSrcweir return 0; 491*cdf0e10cSrcweir return pCols->GetObject(nItemPos)->Width(); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir //------------------------------------------------------------------- 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir sal_uInt16 BrowseBox::GetColumnId( sal_uInt16 nPos ) const 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir if ( nPos >= pCols->Count() ) 501*cdf0e10cSrcweir return 0; 502*cdf0e10cSrcweir return pCols->GetObject(nPos)->GetId(); 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir //------------------------------------------------------------------- 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir sal_uInt16 BrowseBox::GetColumnPos( sal_uInt16 nId ) const 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pCols->Count(); ++nPos ) 512*cdf0e10cSrcweir if ( pCols->GetObject(nPos)->GetId() == nId ) 513*cdf0e10cSrcweir return nPos; 514*cdf0e10cSrcweir return BROWSER_INVALIDID; 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir //------------------------------------------------------------------- 518*cdf0e10cSrcweir 519*cdf0e10cSrcweir sal_Bool BrowseBox::IsFrozen( sal_uInt16 nColumnId ) const 520*cdf0e10cSrcweir { 521*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pCols->Count(); ++nPos ) 524*cdf0e10cSrcweir if ( pCols->GetObject(nPos)->GetId() == nColumnId ) 525*cdf0e10cSrcweir return pCols->GetObject(nPos)->IsFrozen(); 526*cdf0e10cSrcweir return sal_False; 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir //------------------------------------------------------------------- 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir void BrowseBox::ExpandRowSelection( const BrowserMouseEvent& rEvt ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir DoHideCursor( "ExpandRowSelection" ); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir // expand the last selection 538*cdf0e10cSrcweir if ( bMultiSelection ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir Range aJustifiedRange( aSelRange ); 541*cdf0e10cSrcweir aJustifiedRange.Justify(); 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir sal_Bool bSelectThis = ( bSelect != aJustifiedRange.IsInside( rEvt.GetRow() ) ); 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir if ( aJustifiedRange.IsInside( rEvt.GetRow() ) ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir // down and up 548*cdf0e10cSrcweir while ( rEvt.GetRow() < aSelRange.Max() ) 549*cdf0e10cSrcweir { // ZTC/Mac bug - dont put these statemants together! 550*cdf0e10cSrcweir SelectRow( aSelRange.Max(), bSelectThis, sal_True ); 551*cdf0e10cSrcweir --aSelRange.Max(); 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir while ( rEvt.GetRow() > aSelRange.Max() ) 554*cdf0e10cSrcweir { // ZTC/Mac bug - dont put these statemants together! 555*cdf0e10cSrcweir SelectRow( aSelRange.Max(), bSelectThis, sal_True ); 556*cdf0e10cSrcweir ++aSelRange.Max(); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir else 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir // up and down 562*cdf0e10cSrcweir sal_Bool bOldSelecting = bSelecting; 563*cdf0e10cSrcweir bSelecting = sal_True; 564*cdf0e10cSrcweir while ( rEvt.GetRow() < aSelRange.Max() ) 565*cdf0e10cSrcweir { // ZTC/Mac bug - dont put these statemants together! 566*cdf0e10cSrcweir --aSelRange.Max(); 567*cdf0e10cSrcweir if ( !IsRowSelected( aSelRange.Max() ) ) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir SelectRow( aSelRange.Max(), bSelectThis, sal_True ); 570*cdf0e10cSrcweir bSelect = sal_True; 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir while ( rEvt.GetRow() > aSelRange.Max() ) 574*cdf0e10cSrcweir { // ZTC/Mac bug - dont put these statemants together! 575*cdf0e10cSrcweir ++aSelRange.Max(); 576*cdf0e10cSrcweir if ( !IsRowSelected( aSelRange.Max() ) ) 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir SelectRow( aSelRange.Max(), bSelectThis, sal_True ); 579*cdf0e10cSrcweir bSelect = sal_True; 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir bSelecting = bOldSelecting; 583*cdf0e10cSrcweir if ( bSelect ) 584*cdf0e10cSrcweir Select(); 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir else 588*cdf0e10cSrcweir if ( !bMultiSelection || !IsRowSelected( rEvt.GetRow() ) ) 589*cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_True ); 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir GoToRow( rEvt.GetRow(), sal_False ); 592*cdf0e10cSrcweir DoShowCursor( "ExpandRowSelection" ); 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir //------------------------------------------------------------------- 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir void BrowseBox::Resize() 598*cdf0e10cSrcweir { 599*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 600*cdf0e10cSrcweir if ( !bBootstrapped && IsReallyVisible() ) 601*cdf0e10cSrcweir BrowseBox::StateChanged( STATE_CHANGE_INITSHOW ); 602*cdf0e10cSrcweir if ( !pCols->Count() ) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir getDataWindow()->bResizeOnPaint = sal_True; 605*cdf0e10cSrcweir return; 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir getDataWindow()->bResizeOnPaint = sal_False; 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir // calc the size of the scrollbars 610*cdf0e10cSrcweir // (we can't ask the scrollbars for their widths cause if we're zoomed they still have to be 611*cdf0e10cSrcweir // resized - which is done in UpdateScrollbars) 612*cdf0e10cSrcweir sal_uLong nSBSize = GetSettings().GetStyleSettings().GetScrollBarSize(); 613*cdf0e10cSrcweir if (IsZoom()) 614*cdf0e10cSrcweir nSBSize = (sal_uLong)(nSBSize * (double)GetZoom()); 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir DoHideCursor( "Resize" ); 617*cdf0e10cSrcweir sal_uInt16 nOldVisibleRows = 618*cdf0e10cSrcweir (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir // did we need a horiz. scroll bar oder gibt es eine Control Area? 621*cdf0e10cSrcweir if ( !getDataWindow()->bNoHScroll && 622*cdf0e10cSrcweir ( ( pCols->Count() - FrozenColCount() ) > 1 ) ) 623*cdf0e10cSrcweir aHScroll.Show(); 624*cdf0e10cSrcweir else 625*cdf0e10cSrcweir aHScroll.Hide(); 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir // calculate the size of the data window 628*cdf0e10cSrcweir long nDataHeight = GetOutputSizePixel().Height() - GetTitleHeight(); 629*cdf0e10cSrcweir if ( aHScroll.IsVisible() || ( nControlAreaWidth != USHRT_MAX ) ) 630*cdf0e10cSrcweir nDataHeight -= nSBSize; 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir long nDataWidth = GetOutputSizePixel().Width(); 633*cdf0e10cSrcweir if ( pVScroll->IsVisible() ) 634*cdf0e10cSrcweir nDataWidth -= nSBSize; 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir // adjust position and size of data window 637*cdf0e10cSrcweir pDataWin->SetPosSizePixel( 638*cdf0e10cSrcweir Point( 0, GetTitleHeight() ), 639*cdf0e10cSrcweir Size( nDataWidth, nDataHeight ) ); 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir sal_uInt16 nVisibleRows = 642*cdf0e10cSrcweir (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir // TopRow ist unveraendert, aber die Anzahl sichtbarer Zeilen hat sich 645*cdf0e10cSrcweir // geaendert 646*cdf0e10cSrcweir if ( nVisibleRows != nOldVisibleRows ) 647*cdf0e10cSrcweir VisibleRowsChanged(nTopRow, nVisibleRows); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir UpdateScrollbars(); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir // Control-Area 652*cdf0e10cSrcweir Rectangle aInvalidArea( GetControlArea() ); 653*cdf0e10cSrcweir aInvalidArea.Right() = GetOutputSizePixel().Width(); 654*cdf0e10cSrcweir aInvalidArea.Left() = 0; 655*cdf0e10cSrcweir Invalidate( aInvalidArea ); 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir // external header-bar 658*cdf0e10cSrcweir HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar; 659*cdf0e10cSrcweir if ( pHeaderBar ) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir // Handle-Column beruecksichtigen 662*cdf0e10cSrcweir BrowserColumn *pFirstCol = pCols->GetObject(0); 663*cdf0e10cSrcweir long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width(); 664*cdf0e10cSrcweir pHeaderBar->SetPosSizePixel( Point( nOfsX, 0 ), Size( GetOutputSizePixel().Width() - nOfsX, GetTitleHeight() ) ); 665*cdf0e10cSrcweir } 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir AutoSizeLastColumn(); // adjust last column width 668*cdf0e10cSrcweir DoShowCursor( "Resize" ); 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir //------------------------------------------------------------------- 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir void BrowseBox::Paint( const Rectangle& rRect ) 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir // initializations 678*cdf0e10cSrcweir if ( !bBootstrapped && IsReallyVisible() ) 679*cdf0e10cSrcweir BrowseBox::StateChanged( STATE_CHANGE_INITSHOW ); 680*cdf0e10cSrcweir if ( !pCols->Count() ) 681*cdf0e10cSrcweir return; 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir BrowserColumn *pFirstCol = pCols->GetObject(0); 684*cdf0e10cSrcweir sal_Bool bHandleCol = pFirstCol && pFirstCol->GetId() == 0; 685*cdf0e10cSrcweir sal_Bool bHeaderBar = getDataWindow()->pHeaderBar != NULL; 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir // draw delimitational lines 688*cdf0e10cSrcweir if ( !getDataWindow()->bNoHScroll ) 689*cdf0e10cSrcweir DrawLine( Point( 0, aHScroll.GetPosPixel().Y() ), 690*cdf0e10cSrcweir Point( GetOutputSizePixel().Width(), 691*cdf0e10cSrcweir aHScroll.GetPosPixel().Y() ) ); 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir if ( nTitleLines ) 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir if ( !bHeaderBar ) 696*cdf0e10cSrcweir DrawLine( Point( 0, GetTitleHeight() - 1 ), 697*cdf0e10cSrcweir Point( GetOutputSizePixel().Width(), 698*cdf0e10cSrcweir GetTitleHeight() - 1 ) ); 699*cdf0e10cSrcweir else if ( bHandleCol ) 700*cdf0e10cSrcweir DrawLine( Point( 0, GetTitleHeight() - 1 ), 701*cdf0e10cSrcweir Point( pFirstCol->Width(), GetTitleHeight() - 1 ) ); 702*cdf0e10cSrcweir } 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir // Title Bar 705*cdf0e10cSrcweir // Wenn es eine Handle Column gibt und die Headerbar verfuegbar ist, dann nur 706*cdf0e10cSrcweir // die HandleColumn 707*cdf0e10cSrcweir // Handle-Column beruecksichtigen 708*cdf0e10cSrcweir if ( nTitleLines && (!bHeaderBar || bHandleCol) ) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir // iterate through columns to redraw 711*cdf0e10cSrcweir long nX = 0; 712*cdf0e10cSrcweir sal_uInt16 nCol; 713*cdf0e10cSrcweir for ( nCol = 0; 714*cdf0e10cSrcweir nCol < pCols->Count() && nX < rRect.Right(); 715*cdf0e10cSrcweir ++nCol ) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir // skip invisible colums between frozen and scrollable area 718*cdf0e10cSrcweir if ( nCol < nFirstCol && !pCols->GetObject(nCol)->IsFrozen() ) 719*cdf0e10cSrcweir nCol = nFirstCol; 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir // nur die HandleCol ? 722*cdf0e10cSrcweir if (bHeaderBar && bHandleCol && nCol > 0) 723*cdf0e10cSrcweir break; 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol); 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir // draw the column and increment position 728*cdf0e10cSrcweir if ( pCol->Width() > 4 ) 729*cdf0e10cSrcweir { 730*cdf0e10cSrcweir ButtonFrame aButtonFrame( Point( nX, 0 ), 731*cdf0e10cSrcweir Size( pCol->Width()-1, GetTitleHeight()-1 ), 732*cdf0e10cSrcweir pCol->Title(), sal_False, sal_False, 733*cdf0e10cSrcweir 0 != (BROWSER_COLUMN_TITLEABBREVATION&pCol->Flags()), 734*cdf0e10cSrcweir !IsEnabled()); 735*cdf0e10cSrcweir aButtonFrame.Draw( *this ); 736*cdf0e10cSrcweir DrawLine( Point( nX + pCol->Width() - 1, 0 ), 737*cdf0e10cSrcweir Point( nX + pCol->Width() - 1, GetTitleHeight()-1 ) ); 738*cdf0e10cSrcweir } 739*cdf0e10cSrcweir else 740*cdf0e10cSrcweir { 741*cdf0e10cSrcweir Color aOldFillColor = GetFillColor(); 742*cdf0e10cSrcweir SetFillColor( Color( COL_BLACK ) ); 743*cdf0e10cSrcweir DrawRect( Rectangle( Point( nX, 0 ), Size( pCol->Width(), GetTitleHeight() - 1 ) ) ); 744*cdf0e10cSrcweir SetFillColor( aOldFillColor ); 745*cdf0e10cSrcweir } 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir // skip column 748*cdf0e10cSrcweir nX += pCol->Width(); 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir // retouching 752*cdf0e10cSrcweir if ( !bHeaderBar && nCol == pCols->Count() ) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir const StyleSettings &rSettings = GetSettings().GetStyleSettings(); 755*cdf0e10cSrcweir Color aColFace( rSettings.GetFaceColor() ); 756*cdf0e10cSrcweir Color aOldFillColor = GetFillColor(); 757*cdf0e10cSrcweir Color aOldLineColor = GetLineColor(); 758*cdf0e10cSrcweir SetFillColor( aColFace ); 759*cdf0e10cSrcweir SetLineColor( aColFace ); 760*cdf0e10cSrcweir DrawRect( Rectangle( 761*cdf0e10cSrcweir Point( nX, 0 ), 762*cdf0e10cSrcweir Point( rRect.Right(), GetTitleHeight() - 2 ) ) ); 763*cdf0e10cSrcweir SetFillColor( aOldFillColor); // aOldLineColor ); oj 09.02.00 seems to be a copy&paste bug 764*cdf0e10cSrcweir SetLineColor( aOldLineColor); // aOldFillColor ); 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir //------------------------------------------------------------------- 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir void BrowseBox::PaintRow( OutputDevice&, const Rectangle& ) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir } 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir //------------------------------------------------------------------- 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir void BrowseBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) 778*cdf0e10cSrcweir { 779*cdf0e10cSrcweir sal_Bool bDrawSelection = (nFlags & WINDOW_DRAW_NOSELECTION) == 0; 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir // we need pixel coordinates 782*cdf0e10cSrcweir Size aRealSize = pDev->LogicToPixel(rSize); 783*cdf0e10cSrcweir Point aRealPos = pDev->LogicToPixel(rPos); 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir if ((rSize.Width() < 3) || (rSize.Height() < 3)) 786*cdf0e10cSrcweir // we want to have two pixels frame ... 787*cdf0e10cSrcweir return; 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir Font aFont = GetDataWindow().GetDrawPixelFont( pDev ); 790*cdf0e10cSrcweir // the 'normal' painting uses always the data window as device to output to, so we have to calc the new font 791*cdf0e10cSrcweir // relative to the data wins current settings 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir pDev->Push(); 794*cdf0e10cSrcweir pDev->SetMapMode(); 795*cdf0e10cSrcweir pDev->SetFont( aFont ); 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir // draw a frame 798*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 799*cdf0e10cSrcweir pDev->SetLineColor(rStyleSettings.GetDarkShadowColor()); 800*cdf0e10cSrcweir pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()), 801*cdf0e10cSrcweir Point(aRealPos.X(), aRealPos.Y() + aRealSize.Height() - 1)); 802*cdf0e10cSrcweir pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()), 803*cdf0e10cSrcweir Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y())); 804*cdf0e10cSrcweir pDev->SetLineColor(rStyleSettings.GetShadowColor()); 805*cdf0e10cSrcweir pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + 1), 806*cdf0e10cSrcweir Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1)); 807*cdf0e10cSrcweir pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1), 808*cdf0e10cSrcweir Point(aRealPos.X() + 1, aRealPos.Y() + aRealSize.Height() - 1)); 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir HeaderBar* pBar = getDataWindow()->pHeaderBar; 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir // we're drawing onto a foreign device, so we have to fake the DataRowHeight for the subsequent ImplPaintData 813*cdf0e10cSrcweir // (as it is based on the settings of our data window, not the foreign device) 814*cdf0e10cSrcweir if (!nDataRowHeight) 815*cdf0e10cSrcweir ImpGetDataRowHeight(); 816*cdf0e10cSrcweir long nHeightLogic = PixelToLogic(Size(0, nDataRowHeight), MAP_10TH_MM).Height(); 817*cdf0e10cSrcweir long nForeignHeightPixel = pDev->LogicToPixel(Size(0, nHeightLogic), MAP_10TH_MM).Height(); 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir long nOriginalHeight = nDataRowHeight; 820*cdf0e10cSrcweir nDataRowHeight = nForeignHeightPixel; 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir // this counts for the column widths, too 823*cdf0e10cSrcweir sal_uInt16 nPos; 824*cdf0e10cSrcweir for ( nPos = 0; nPos < pCols->Count(); ++nPos ) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir BrowserColumn* pCurrent = pCols->GetObject(nPos); 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir long nWidthLogic = PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width(); 829*cdf0e10cSrcweir long nForeignWidthPixel = pDev->LogicToPixel(Size(nWidthLogic, 0), MAP_10TH_MM).Width(); 830*cdf0e10cSrcweir 831*cdf0e10cSrcweir pCurrent->SetWidth(nForeignWidthPixel, GetZoom()); 832*cdf0e10cSrcweir if ( pBar ) 833*cdf0e10cSrcweir pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() ); 834*cdf0e10cSrcweir } 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir // a smaller area for the content 837*cdf0e10cSrcweir ++aRealPos.X(); 838*cdf0e10cSrcweir ++aRealPos.Y(); 839*cdf0e10cSrcweir aRealSize.Width() -= 2; 840*cdf0e10cSrcweir aRealSize.Height() -= 2; 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir // let the header bar draw itself 843*cdf0e10cSrcweir if ( pBar ) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir // the title height with respect to the font set for the given device 846*cdf0e10cSrcweir long nTitleHeight = PixelToLogic(Size(0, GetTitleHeight()), MAP_10TH_MM).Height(); 847*cdf0e10cSrcweir nTitleHeight = pDev->LogicToPixel(Size(0, nTitleHeight), MAP_10TH_MM).Height(); 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir BrowserColumn* pFirstCol = pCols->Count() ? pCols->GetObject(0) : NULL; 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir Point aHeaderPos(pFirstCol && (pFirstCol->GetId() == 0) ? pFirstCol->Width() : 0, 0); 852*cdf0e10cSrcweir Size aHeaderSize(aRealSize.Width() - aHeaderPos.X(), nTitleHeight); 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir aHeaderPos += aRealPos; 855*cdf0e10cSrcweir // do this before converting to logics ! 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir // the header's draw expects logic coordinates, again 858*cdf0e10cSrcweir aHeaderPos = pDev->PixelToLogic(aHeaderPos); 859*cdf0e10cSrcweir aHeaderSize = pDev->PixelToLogic(aHeaderSize); 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir pBar->Draw(pDev, aHeaderPos, aHeaderSize, nFlags); 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir // draw the "upper left cell" (the intersection between the header bar and the handle column) 864*cdf0e10cSrcweir if (( pFirstCol->GetId() == 0 ) && ( pFirstCol->Width() > 4 )) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir ButtonFrame aButtonFrame( aRealPos, 867*cdf0e10cSrcweir Size( pFirstCol->Width()-1, nTitleHeight-1 ), 868*cdf0e10cSrcweir pFirstCol->Title(), sal_False, sal_False, sal_False, !IsEnabled()); 869*cdf0e10cSrcweir aButtonFrame.Draw( *pDev ); 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir pDev->Push( PUSH_LINECOLOR ); 872*cdf0e10cSrcweir pDev->SetLineColor( Color( COL_BLACK ) ); 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir pDev->DrawLine( Point( aRealPos.X(), aRealPos.Y() + nTitleHeight-1 ), 875*cdf0e10cSrcweir Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) ); 876*cdf0e10cSrcweir pDev->DrawLine( Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() ), 877*cdf0e10cSrcweir Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) ); 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir pDev->Pop(); 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir aRealPos.Y() += aHeaderSize.Height(); 883*cdf0e10cSrcweir aRealSize.Height() -= aHeaderSize.Height(); 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir // draw our own content (with clipping) 887*cdf0e10cSrcweir Region aRegion(Rectangle(aRealPos, aRealSize)); 888*cdf0e10cSrcweir pDev->SetClipRegion( pDev->PixelToLogic( aRegion ) ); 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir // do we have to paint the background 891*cdf0e10cSrcweir sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && GetDataWindow().IsControlBackground(); 892*cdf0e10cSrcweir if ( bBackground ) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir Rectangle aRect( aRealPos, aRealSize ); 895*cdf0e10cSrcweir pDev->SetFillColor( GetDataWindow().GetControlBackground() ); 896*cdf0e10cSrcweir pDev->DrawRect( aRect ); 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir ImplPaintData( *pDev, Rectangle( aRealPos, aRealSize ), sal_True, bDrawSelection ); 900*cdf0e10cSrcweir 901*cdf0e10cSrcweir // restore the column widths/data row height 902*cdf0e10cSrcweir nDataRowHeight = nOriginalHeight; 903*cdf0e10cSrcweir for ( nPos = 0; nPos < pCols->Count(); ++nPos ) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir BrowserColumn* pCurrent = pCols->GetObject(nPos); 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir long nForeignWidthLogic = pDev->PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width(); 908*cdf0e10cSrcweir long nWidthPixel = LogicToPixel(Size(nForeignWidthLogic, 0), MAP_10TH_MM).Width(); 909*cdf0e10cSrcweir 910*cdf0e10cSrcweir pCurrent->SetWidth(nWidthPixel, GetZoom()); 911*cdf0e10cSrcweir if ( pBar ) 912*cdf0e10cSrcweir pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() ); 913*cdf0e10cSrcweir } 914*cdf0e10cSrcweir 915*cdf0e10cSrcweir pDev->Pop(); 916*cdf0e10cSrcweir } 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir //------------------------------------------------------------------- 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir void BrowseBox::ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, sal_Bool _bForeignDevice, sal_Bool _bDrawSelections) 921*cdf0e10cSrcweir { 922*cdf0e10cSrcweir Point aOverallAreaPos = _bForeignDevice ? _rRect.TopLeft() : Point(0,0); 923*cdf0e10cSrcweir Size aOverallAreaSize = _bForeignDevice ? _rRect.GetSize() : GetDataWindow().GetOutputSizePixel(); 924*cdf0e10cSrcweir Point aOverallAreaBRPos = _bForeignDevice ? _rRect.BottomRight() : Point( aOverallAreaSize.Width(), aOverallAreaSize.Height() ); 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir long nDataRowHeigt = GetDataRowHeight(); 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir // compute relative rows to redraw 929*cdf0e10cSrcweir sal_uLong nRelTopRow = _bForeignDevice ? 0 : ((sal_uLong)_rRect.Top() / nDataRowHeigt); 930*cdf0e10cSrcweir sal_uLong nRelBottomRow = (sal_uLong)(_bForeignDevice ? aOverallAreaSize.Height() : _rRect.Bottom()) / nDataRowHeigt; 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir // cache frequently used values 933*cdf0e10cSrcweir Point aPos( aOverallAreaPos.X(), nRelTopRow * nDataRowHeigt + aOverallAreaPos.Y() ); 934*cdf0e10cSrcweir _rOut.SetLineColor( Color( COL_WHITE ) ); 935*cdf0e10cSrcweir const AllSettings& rAllSets = _rOut.GetSettings(); 936*cdf0e10cSrcweir const StyleSettings &rSettings = rAllSets.GetStyleSettings(); 937*cdf0e10cSrcweir const Color &rHighlightTextColor = rSettings.GetHighlightTextColor(); 938*cdf0e10cSrcweir const Color &rHighlightFillColor = rSettings.GetHighlightColor(); 939*cdf0e10cSrcweir Color aOldTextColor = _rOut.GetTextColor(); 940*cdf0e10cSrcweir Color aOldFillColor = _rOut.GetFillColor(); 941*cdf0e10cSrcweir Color aOldLineColor = _rOut.GetLineColor(); 942*cdf0e10cSrcweir long nHLineX = 0 == pCols->GetObject(0)->GetId() 943*cdf0e10cSrcweir ? pCols->GetObject(0)->Width() 944*cdf0e10cSrcweir : 0; 945*cdf0e10cSrcweir nHLineX += aOverallAreaPos.X(); 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir Color aDelimiterLineColor( ::svtools::ColorConfig().GetColorValue( ::svtools::CALCGRID ).nColor ); 948*cdf0e10cSrcweir 949*cdf0e10cSrcweir // redraw the invalid fields 950*cdf0e10cSrcweir sal_Bool bRetouching = sal_False; 951*cdf0e10cSrcweir for ( sal_uLong nRelRow = nRelTopRow; 952*cdf0e10cSrcweir nRelRow <= nRelBottomRow && (sal_uLong)nTopRow+nRelRow < (sal_uLong)nRowCount; 953*cdf0e10cSrcweir ++nRelRow, aPos.Y() += nDataRowHeigt ) 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir // get row 956*cdf0e10cSrcweir // Zur Sicherheit auf zul"assigen Bereich abfragen: 957*cdf0e10cSrcweir DBG_ASSERT( (sal_uInt16)(nTopRow+nRelRow) < nRowCount, "BrowseBox::ImplPaintData: invalid seek" ); 958*cdf0e10cSrcweir if ( (nTopRow+long(nRelRow)) < 0 || (sal_uInt16)(nTopRow+nRelRow) >= nRowCount ) 959*cdf0e10cSrcweir continue; 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir // prepare row 962*cdf0e10cSrcweir sal_uLong nRow = nTopRow+nRelRow; 963*cdf0e10cSrcweir if ( !SeekRow( nRow) ) { 964*cdf0e10cSrcweir DBG_ERROR("BrowseBox::ImplPaintData: SeekRow gescheitert"); 965*cdf0e10cSrcweir } 966*cdf0e10cSrcweir _rOut.SetClipRegion(); 967*cdf0e10cSrcweir aPos.X() = aOverallAreaPos.X(); 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir // #73325# don't paint the row outside the painting rectangle (DG) 971*cdf0e10cSrcweir // prepare auto-highlight 972*cdf0e10cSrcweir Rectangle aRowRect( Point( _rRect.TopLeft().X(), aPos.Y() ), 973*cdf0e10cSrcweir Size( _rRect.GetSize().Width(), nDataRowHeigt ) ); 974*cdf0e10cSrcweir PaintRow( _rOut, aRowRect ); 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir sal_Bool bRowSelected = _bDrawSelections 977*cdf0e10cSrcweir && !bHideSelect 978*cdf0e10cSrcweir && IsRowSelected( nRow ); 979*cdf0e10cSrcweir if ( bRowSelected ) 980*cdf0e10cSrcweir { 981*cdf0e10cSrcweir _rOut.SetTextColor( rHighlightTextColor ); 982*cdf0e10cSrcweir _rOut.SetFillColor( rHighlightFillColor ); 983*cdf0e10cSrcweir _rOut.SetLineColor(); 984*cdf0e10cSrcweir _rOut.DrawRect( aRowRect ); 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir 987*cdf0e10cSrcweir // iterate through columns to redraw 988*cdf0e10cSrcweir sal_uInt16 nCol; 989*cdf0e10cSrcweir for ( nCol = 0; nCol < pCols->Count(); ++nCol ) 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir // get column 992*cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol); 993*cdf0e10cSrcweir 994*cdf0e10cSrcweir // at end of invalid area 995*cdf0e10cSrcweir if ( aPos.X() >= _rRect.Right() ) 996*cdf0e10cSrcweir break; 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir // skip invisible colums between frozen and scrollable area 999*cdf0e10cSrcweir if ( nCol < nFirstCol && !pCol->IsFrozen() ) 1000*cdf0e10cSrcweir { 1001*cdf0e10cSrcweir nCol = nFirstCol; 1002*cdf0e10cSrcweir pCol = pCols->GetObject(nCol); 1003*cdf0e10cSrcweir if (!pCol) 1004*cdf0e10cSrcweir { // FS - 21.05.99 - 66325 1005*cdf0e10cSrcweir // ist zwar eigentlich woanders (an der richtigen Stelle) gefixt, aber sicher ist sicher ... 1006*cdf0e10cSrcweir DBG_ERROR("BrowseBox::PaintData : nFirstCol is probably invalid !"); 1007*cdf0e10cSrcweir break; 1008*cdf0e10cSrcweir } 1009*cdf0e10cSrcweir } 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir // prepare Column-AutoHighlight 1012*cdf0e10cSrcweir sal_Bool bColAutoHighlight = _bDrawSelections 1013*cdf0e10cSrcweir && bColumnCursor 1014*cdf0e10cSrcweir && IsColumnSelected( pCol->GetId() ); 1015*cdf0e10cSrcweir if ( bColAutoHighlight ) 1016*cdf0e10cSrcweir { 1017*cdf0e10cSrcweir _rOut.SetClipRegion(); 1018*cdf0e10cSrcweir _rOut.SetTextColor( rHighlightTextColor ); 1019*cdf0e10cSrcweir _rOut.SetFillColor( rHighlightFillColor ); 1020*cdf0e10cSrcweir _rOut.SetLineColor(); 1021*cdf0e10cSrcweir Rectangle aFieldRect( aPos, 1022*cdf0e10cSrcweir Size( pCol->Width(), nDataRowHeigt ) ); 1023*cdf0e10cSrcweir _rOut.DrawRect( aFieldRect ); 1024*cdf0e10cSrcweir } 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir if (!m_bFocusOnlyCursor && (pCol->GetId() == GetCurColumnId()) && (nRow == (sal_uLong)GetCurRow())) 1027*cdf0e10cSrcweir DrawCursor(); 1028*cdf0e10cSrcweir 1029*cdf0e10cSrcweir // draw a single field 1030*cdf0e10cSrcweir // #63864#, Sonst wird auch etwas gezeichnet, bsp Handle Column 1031*cdf0e10cSrcweir if (pCol->Width()) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir // clip the column's output to the field area 1034*cdf0e10cSrcweir if (_bForeignDevice) 1035*cdf0e10cSrcweir { // (not neccessary if painting onto the data window) 1036*cdf0e10cSrcweir Size aFieldSize(pCol->Width(), nDataRowHeigt); 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir if (aPos.X() + aFieldSize.Width() > aOverallAreaBRPos.X()) 1039*cdf0e10cSrcweir aFieldSize.Width() = aOverallAreaBRPos.X() - aPos.X(); 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir if (aPos.Y() + aFieldSize.Height() > aOverallAreaBRPos.Y() + 1) 1042*cdf0e10cSrcweir { 1043*cdf0e10cSrcweir // for non-handle cols we don't clip vertically : we just don't draw the cell if the line isn't completely visible 1044*cdf0e10cSrcweir if (pCol->GetId() != 0) 1045*cdf0e10cSrcweir continue; 1046*cdf0e10cSrcweir aFieldSize.Height() = aOverallAreaBRPos.Y() + 1 - aPos.Y(); 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir Region aClipToField(Rectangle(aPos, aFieldSize)); 1050*cdf0e10cSrcweir _rOut.SetClipRegion(aClipToField); 1051*cdf0e10cSrcweir } 1052*cdf0e10cSrcweir pCol->Draw( *this, _rOut, aPos, sal_False ); 1053*cdf0e10cSrcweir if (_bForeignDevice) 1054*cdf0e10cSrcweir _rOut.SetClipRegion(); 1055*cdf0e10cSrcweir } 1056*cdf0e10cSrcweir 1057*cdf0e10cSrcweir // reset Column-auto-highlight 1058*cdf0e10cSrcweir if ( bColAutoHighlight ) 1059*cdf0e10cSrcweir { 1060*cdf0e10cSrcweir _rOut.SetTextColor( aOldTextColor ); 1061*cdf0e10cSrcweir _rOut.SetFillColor( aOldFillColor ); 1062*cdf0e10cSrcweir _rOut.SetLineColor( aOldLineColor ); 1063*cdf0e10cSrcweir } 1064*cdf0e10cSrcweir 1065*cdf0e10cSrcweir // skip column 1066*cdf0e10cSrcweir aPos.X() += pCol->Width(); 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir if ( nCol == pCols->Count() ) 1070*cdf0e10cSrcweir bRetouching = sal_True; 1071*cdf0e10cSrcweir 1072*cdf0e10cSrcweir // reset auto-highlight 1073*cdf0e10cSrcweir if ( bRowSelected ) 1074*cdf0e10cSrcweir { 1075*cdf0e10cSrcweir _rOut.SetTextColor( aOldTextColor ); 1076*cdf0e10cSrcweir _rOut.SetFillColor( aOldFillColor ); 1077*cdf0e10cSrcweir _rOut.SetLineColor( aOldLineColor ); 1078*cdf0e10cSrcweir } 1079*cdf0e10cSrcweir 1080*cdf0e10cSrcweir if ( bHLines ) 1081*cdf0e10cSrcweir { 1082*cdf0e10cSrcweir // draw horizontal delimitation lines 1083*cdf0e10cSrcweir _rOut.SetClipRegion(); 1084*cdf0e10cSrcweir _rOut.Push( PUSH_LINECOLOR ); 1085*cdf0e10cSrcweir _rOut.SetLineColor( aDelimiterLineColor ); 1086*cdf0e10cSrcweir long nY = aPos.Y() + nDataRowHeigt - 1; 1087*cdf0e10cSrcweir if (nY <= aOverallAreaBRPos.Y()) 1088*cdf0e10cSrcweir _rOut.DrawLine( Point( nHLineX, nY ), 1089*cdf0e10cSrcweir Point( bVLines 1090*cdf0e10cSrcweir ? std::min(long(long(aPos.X()) - 1), aOverallAreaBRPos.X()) 1091*cdf0e10cSrcweir : aOverallAreaBRPos.X(), 1092*cdf0e10cSrcweir nY ) ); 1093*cdf0e10cSrcweir _rOut.Pop(); 1094*cdf0e10cSrcweir } 1095*cdf0e10cSrcweir } 1096*cdf0e10cSrcweir 1097*cdf0e10cSrcweir if (aPos.Y() > aOverallAreaBRPos.Y() + 1) 1098*cdf0e10cSrcweir aPos.Y() = aOverallAreaBRPos.Y() + 1; 1099*cdf0e10cSrcweir // needed for some of the following drawing 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir // retouching 1102*cdf0e10cSrcweir _rOut.SetClipRegion(); 1103*cdf0e10cSrcweir aOldLineColor = _rOut.GetLineColor(); 1104*cdf0e10cSrcweir aOldFillColor = _rOut.GetFillColor(); 1105*cdf0e10cSrcweir _rOut.SetFillColor( rSettings.GetFaceColor() ); 1106*cdf0e10cSrcweir if ( pCols->Count() && ( pCols->GetObject(0)->GetId() == 0 ) && ( aPos.Y() <= _rRect.Bottom() ) ) 1107*cdf0e10cSrcweir { 1108*cdf0e10cSrcweir // fill rectangle gray below handle column 1109*cdf0e10cSrcweir // DG: fill it only until the end of the drawing rect and not to the end, as this may overpaint handle columns 1110*cdf0e10cSrcweir _rOut.SetLineColor( Color( COL_BLACK ) ); 1111*cdf0e10cSrcweir _rOut.DrawRect( Rectangle( 1112*cdf0e10cSrcweir Point( aOverallAreaPos.X() - 1, aPos.Y() - 1 ), 1113*cdf0e10cSrcweir Point( aOverallAreaPos.X() + pCols->GetObject(0)->Width() - 1, 1114*cdf0e10cSrcweir _rRect.Bottom() + 1) ) ); 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir _rOut.SetFillColor( aOldFillColor ); 1117*cdf0e10cSrcweir 1118*cdf0e10cSrcweir // draw vertical delimitational line between frozen and scrollable cols 1119*cdf0e10cSrcweir _rOut.SetLineColor( COL_BLACK ); 1120*cdf0e10cSrcweir long nFrozenWidth = GetFrozenWidth()-1; 1121*cdf0e10cSrcweir _rOut.DrawLine( Point( aOverallAreaPos.X() + nFrozenWidth, aPos.Y() ), 1122*cdf0e10cSrcweir Point( aOverallAreaPos.X() + nFrozenWidth, bHLines 1123*cdf0e10cSrcweir ? aPos.Y() - 1 1124*cdf0e10cSrcweir : aOverallAreaBRPos.Y() ) ); 1125*cdf0e10cSrcweir 1126*cdf0e10cSrcweir // draw vertical delimitational lines? 1127*cdf0e10cSrcweir if ( bVLines ) 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir _rOut.SetLineColor( aDelimiterLineColor ); 1130*cdf0e10cSrcweir Point aVertPos( aOverallAreaPos.X() - 1, aOverallAreaPos.Y() ); 1131*cdf0e10cSrcweir long nDeltaY = aOverallAreaBRPos.Y(); 1132*cdf0e10cSrcweir for ( sal_uInt16 nCol = 0; nCol < pCols->Count(); ++nCol ) 1133*cdf0e10cSrcweir { 1134*cdf0e10cSrcweir // get column 1135*cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol); 1136*cdf0e10cSrcweir 1137*cdf0e10cSrcweir // skip invisible colums between frozen and scrollable area 1138*cdf0e10cSrcweir if ( nCol < nFirstCol && !pCol->IsFrozen() ) 1139*cdf0e10cSrcweir { 1140*cdf0e10cSrcweir nCol = nFirstCol; 1141*cdf0e10cSrcweir pCol = pCols->GetObject(nCol); 1142*cdf0e10cSrcweir } 1143*cdf0e10cSrcweir 1144*cdf0e10cSrcweir // skip column 1145*cdf0e10cSrcweir aVertPos.X() += pCol->Width(); 1146*cdf0e10cSrcweir 1147*cdf0e10cSrcweir // at end of invalid area 1148*cdf0e10cSrcweir // invalid area is first reached when X > Right 1149*cdf0e10cSrcweir // and not >= 1150*cdf0e10cSrcweir if ( aVertPos.X() > _rRect.Right() ) 1151*cdf0e10cSrcweir break; 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir // draw a single line 1154*cdf0e10cSrcweir if ( pCol->GetId() != 0 ) 1155*cdf0e10cSrcweir _rOut.DrawLine( aVertPos, Point( aVertPos.X(), 1156*cdf0e10cSrcweir bHLines 1157*cdf0e10cSrcweir ? aPos.Y() - 1 1158*cdf0e10cSrcweir : aPos.Y() + nDeltaY ) ); 1159*cdf0e10cSrcweir } 1160*cdf0e10cSrcweir } 1161*cdf0e10cSrcweir 1162*cdf0e10cSrcweir _rOut.SetLineColor( aOldLineColor ); 1163*cdf0e10cSrcweir } 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir //------------------------------------------------------------------- 1166*cdf0e10cSrcweir 1167*cdf0e10cSrcweir void BrowseBox::PaintData( Window& rWin, const Rectangle& rRect ) 1168*cdf0e10cSrcweir { 1169*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1170*cdf0e10cSrcweir if ( !bBootstrapped && IsReallyVisible() ) 1171*cdf0e10cSrcweir BrowseBox::StateChanged( STATE_CHANGE_INITSHOW ); 1172*cdf0e10cSrcweir 1173*cdf0e10cSrcweir // initializations 1174*cdf0e10cSrcweir if ( !pCols || !pCols->Count() || !rWin.IsUpdateMode() ) 1175*cdf0e10cSrcweir return; 1176*cdf0e10cSrcweir if ( getDataWindow()->bResizeOnPaint ) 1177*cdf0e10cSrcweir Resize(); 1178*cdf0e10cSrcweir // MI: wer war das denn? Window::Update(); 1179*cdf0e10cSrcweir 1180*cdf0e10cSrcweir ImplPaintData(rWin, rRect, sal_False, sal_True); 1181*cdf0e10cSrcweir } 1182*cdf0e10cSrcweir 1183*cdf0e10cSrcweir //------------------------------------------------------------------- 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir void BrowseBox::UpdateScrollbars() 1186*cdf0e10cSrcweir { 1187*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir if ( !bBootstrapped || !IsUpdateMode() ) 1190*cdf0e10cSrcweir return; 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir // Rekursionsschutz 1193*cdf0e10cSrcweir BrowserDataWin *pBDW = (BrowserDataWin*) pDataWin; 1194*cdf0e10cSrcweir if ( pBDW->bInUpdateScrollbars ) 1195*cdf0e10cSrcweir { 1196*cdf0e10cSrcweir pBDW->bHadRecursion = sal_True; 1197*cdf0e10cSrcweir return; 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir pBDW->bInUpdateScrollbars = sal_True; 1200*cdf0e10cSrcweir 1201*cdf0e10cSrcweir // the size of the corner window (and the width of the VSB/height of the HSB) 1202*cdf0e10cSrcweir sal_uLong nCornerSize = GetSettings().GetStyleSettings().GetScrollBarSize(); 1203*cdf0e10cSrcweir if (IsZoom()) 1204*cdf0e10cSrcweir nCornerSize = (sal_uLong)(nCornerSize * (double)GetZoom()); 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir // needs VScroll? 1207*cdf0e10cSrcweir long nMaxRows = (pDataWin->GetSizePixel().Height()) / GetDataRowHeight(); 1208*cdf0e10cSrcweir sal_Bool bNeedsVScroll = getDataWindow()->bAutoVScroll 1209*cdf0e10cSrcweir ? nTopRow || ( nRowCount > nMaxRows ) 1210*cdf0e10cSrcweir : !getDataWindow()->bNoVScroll; 1211*cdf0e10cSrcweir Size aDataWinSize = pDataWin->GetSizePixel(); 1212*cdf0e10cSrcweir if ( !bNeedsVScroll ) 1213*cdf0e10cSrcweir { 1214*cdf0e10cSrcweir if ( pVScroll->IsVisible() ) 1215*cdf0e10cSrcweir { 1216*cdf0e10cSrcweir pVScroll->Hide(); 1217*cdf0e10cSrcweir Size aNewSize( aDataWinSize ); 1218*cdf0e10cSrcweir aNewSize.Width() = GetOutputSizePixel().Width(); 1219*cdf0e10cSrcweir aDataWinSize = aNewSize; 1220*cdf0e10cSrcweir } 1221*cdf0e10cSrcweir } 1222*cdf0e10cSrcweir else if ( !pVScroll->IsVisible() ) 1223*cdf0e10cSrcweir { 1224*cdf0e10cSrcweir Size aNewSize( aDataWinSize ); 1225*cdf0e10cSrcweir aNewSize.Width() = GetOutputSizePixel().Width() - nCornerSize; 1226*cdf0e10cSrcweir aDataWinSize = aNewSize; 1227*cdf0e10cSrcweir } 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir // needs HScroll? 1230*cdf0e10cSrcweir sal_uLong nLastCol = GetColumnAtXPosPixel( aDataWinSize.Width() - 1 ); 1231*cdf0e10cSrcweir 1232*cdf0e10cSrcweir sal_uInt16 nFrozenCols = FrozenColCount(); 1233*cdf0e10cSrcweir sal_Bool bNeedsHScroll = getDataWindow()->bAutoHScroll 1234*cdf0e10cSrcweir ? ( nFirstCol > nFrozenCols ) || ( nLastCol <= pCols->Count() ) 1235*cdf0e10cSrcweir : !getDataWindow()->bNoHScroll; 1236*cdf0e10cSrcweir if ( !bNeedsHScroll ) 1237*cdf0e10cSrcweir { 1238*cdf0e10cSrcweir if ( aHScroll.IsVisible() ) 1239*cdf0e10cSrcweir { 1240*cdf0e10cSrcweir aHScroll.Hide(); 1241*cdf0e10cSrcweir } 1242*cdf0e10cSrcweir aDataWinSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight(); 1243*cdf0e10cSrcweir if ( nControlAreaWidth != USHRT_MAX ) 1244*cdf0e10cSrcweir aDataWinSize.Height() -= nCornerSize; 1245*cdf0e10cSrcweir } 1246*cdf0e10cSrcweir else if ( !aHScroll.IsVisible() ) 1247*cdf0e10cSrcweir { 1248*cdf0e10cSrcweir Size aNewSize( aDataWinSize ); 1249*cdf0e10cSrcweir aNewSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight() - nCornerSize; 1250*cdf0e10cSrcweir aDataWinSize = aNewSize; 1251*cdf0e10cSrcweir } 1252*cdf0e10cSrcweir 1253*cdf0e10cSrcweir // adjust position and Width of horizontal scrollbar 1254*cdf0e10cSrcweir sal_uLong nHScrX = nControlAreaWidth == USHRT_MAX 1255*cdf0e10cSrcweir ? 0 1256*cdf0e10cSrcweir : nControlAreaWidth; 1257*cdf0e10cSrcweir 1258*cdf0e10cSrcweir aHScroll.SetPosSizePixel( 1259*cdf0e10cSrcweir Point( nHScrX, GetOutputSizePixel().Height() - nCornerSize ), 1260*cdf0e10cSrcweir Size( aDataWinSize.Width() - nHScrX, nCornerSize ) ); 1261*cdf0e10cSrcweir 1262*cdf0e10cSrcweir // Scrollable Columns insgesamt 1263*cdf0e10cSrcweir short nScrollCols = short(pCols->Count()) - (short)nFrozenCols; 1264*cdf0e10cSrcweir /*short nVisibleHSize= std::max(nLastCol == BROWSER_INVALIDID 1265*cdf0e10cSrcweir ? pCols->Count() - nFirstCol -1 1266*cdf0e10cSrcweir : nLastCol - nFirstCol - 1, 0); 1267*cdf0e10cSrcweir 1268*cdf0e10cSrcweir aHScroll.SetVisibleSize( nVisibleHSize ); 1269*cdf0e10cSrcweir aHScroll.SetRange( Range( 0, Max( std::min(nScrollCols, nVisibleHSize), (short)0 ) ) ); 1270*cdf0e10cSrcweir if ( bNeedsHScroll && !aHScroll.IsVisible() ) 1271*cdf0e10cSrcweir aHScroll.Show();*/ 1272*cdf0e10cSrcweir 1273*cdf0e10cSrcweir // Sichtbare Columns 1274*cdf0e10cSrcweir short nVisibleHSize = nLastCol == BROWSER_INVALIDID 1275*cdf0e10cSrcweir ? (short)( pCols->Count() - nFirstCol ) 1276*cdf0e10cSrcweir : (short)( nLastCol - nFirstCol ); 1277*cdf0e10cSrcweir 1278*cdf0e10cSrcweir short nRange = Max( nScrollCols, (short)0 ); 1279*cdf0e10cSrcweir aHScroll.SetVisibleSize( nVisibleHSize ); 1280*cdf0e10cSrcweir aHScroll.SetRange( Range( 0, nRange )); 1281*cdf0e10cSrcweir if ( bNeedsHScroll && !aHScroll.IsVisible() ) 1282*cdf0e10cSrcweir aHScroll.Show(); 1283*cdf0e10cSrcweir 1284*cdf0e10cSrcweir // adjust position and height of vertical scrollbar 1285*cdf0e10cSrcweir pVScroll->SetPageSize( nMaxRows ); 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir if ( nTopRow > nRowCount ) 1288*cdf0e10cSrcweir { 1289*cdf0e10cSrcweir nTopRow = nRowCount - 1; 1290*cdf0e10cSrcweir DBG_ERROR("BrowseBox: nTopRow > nRowCount"); 1291*cdf0e10cSrcweir } 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir if ( pVScroll->GetThumbPos() != nTopRow ) 1294*cdf0e10cSrcweir pVScroll->SetThumbPos( nTopRow ); 1295*cdf0e10cSrcweir long nVisibleSize = Min( Min( nRowCount, nMaxRows ), long(nRowCount-nTopRow) ); 1296*cdf0e10cSrcweir pVScroll->SetVisibleSize( nVisibleSize ? nVisibleSize : 1 ); 1297*cdf0e10cSrcweir pVScroll->SetRange( Range( 0, nRowCount ) ); 1298*cdf0e10cSrcweir pVScroll->SetPosSizePixel( 1299*cdf0e10cSrcweir Point( aDataWinSize.Width(), GetTitleHeight() ), 1300*cdf0e10cSrcweir Size( nCornerSize, aDataWinSize.Height()) ); 1301*cdf0e10cSrcweir if ( nRowCount < 1302*cdf0e10cSrcweir long( aDataWinSize.Height() / GetDataRowHeight() ) ) 1303*cdf0e10cSrcweir ScrollRows( -nTopRow ); 1304*cdf0e10cSrcweir if ( bNeedsVScroll && !pVScroll->IsVisible() ) 1305*cdf0e10cSrcweir pVScroll->Show(); 1306*cdf0e10cSrcweir 1307*cdf0e10cSrcweir pDataWin->SetPosSizePixel( 1308*cdf0e10cSrcweir Point( 0, GetTitleHeight() ), 1309*cdf0e10cSrcweir aDataWinSize ); 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir // needs corner-window? 1312*cdf0e10cSrcweir // (do that AFTER positioning BOTH scrollbars) 1313*cdf0e10cSrcweir sal_uLong nActualCorderWidth = 0; 1314*cdf0e10cSrcweir if (aHScroll.IsVisible() && pVScroll && pVScroll->IsVisible() ) 1315*cdf0e10cSrcweir { 1316*cdf0e10cSrcweir // if we have both scrollbars, the corner window fills the point of intersection of these two 1317*cdf0e10cSrcweir nActualCorderWidth = nCornerSize; 1318*cdf0e10cSrcweir } 1319*cdf0e10cSrcweir else if ( !aHScroll.IsVisible() && ( nControlAreaWidth != USHRT_MAX ) ) 1320*cdf0e10cSrcweir { 1321*cdf0e10cSrcweir // if we have no horizontal scrollbar, but a control area, we need the corner window to 1322*cdf0e10cSrcweir // fill the space between the control are and the right border 1323*cdf0e10cSrcweir nActualCorderWidth = GetOutputSizePixel().Width() - nControlAreaWidth; 1324*cdf0e10cSrcweir } 1325*cdf0e10cSrcweir if ( nActualCorderWidth ) 1326*cdf0e10cSrcweir { 1327*cdf0e10cSrcweir if ( !getDataWindow()->pCornerWin ) 1328*cdf0e10cSrcweir getDataWindow()->pCornerWin = new ScrollBarBox( this, 0 ); 1329*cdf0e10cSrcweir getDataWindow()->pCornerWin->SetPosSizePixel( 1330*cdf0e10cSrcweir Point( GetOutputSizePixel().Width() - nActualCorderWidth, aHScroll.GetPosPixel().Y() ), 1331*cdf0e10cSrcweir Size( nActualCorderWidth, nCornerSize ) ); 1332*cdf0e10cSrcweir getDataWindow()->pCornerWin->Show(); 1333*cdf0e10cSrcweir } 1334*cdf0e10cSrcweir else 1335*cdf0e10cSrcweir DELETEZ( getDataWindow()->pCornerWin ); 1336*cdf0e10cSrcweir 1337*cdf0e10cSrcweir // ggf. Headerbar mitscrollen 1338*cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar ) 1339*cdf0e10cSrcweir { 1340*cdf0e10cSrcweir long nWidth = 0; 1341*cdf0e10cSrcweir for ( sal_uInt16 nCol = 0; 1342*cdf0e10cSrcweir nCol < pCols->Count() && nCol < nFirstCol; 1343*cdf0e10cSrcweir ++nCol ) 1344*cdf0e10cSrcweir { 1345*cdf0e10cSrcweir // HandleColumn nicht 1346*cdf0e10cSrcweir if ( pCols->GetObject(nCol)->GetId() ) 1347*cdf0e10cSrcweir nWidth += pCols->GetObject(nCol)->Width(); 1348*cdf0e10cSrcweir } 1349*cdf0e10cSrcweir 1350*cdf0e10cSrcweir getDataWindow()->pHeaderBar->SetOffset( nWidth ); 1351*cdf0e10cSrcweir } 1352*cdf0e10cSrcweir 1353*cdf0e10cSrcweir pBDW->bInUpdateScrollbars = sal_False; 1354*cdf0e10cSrcweir if ( pBDW->bHadRecursion ) 1355*cdf0e10cSrcweir { 1356*cdf0e10cSrcweir pBDW->bHadRecursion = sal_False; 1357*cdf0e10cSrcweir UpdateScrollbars(); 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir } 1360*cdf0e10cSrcweir 1361*cdf0e10cSrcweir //------------------------------------------------------------------- 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir void BrowseBox::SetUpdateMode( sal_Bool bUpdate ) 1364*cdf0e10cSrcweir { 1365*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1366*cdf0e10cSrcweir 1367*cdf0e10cSrcweir sal_Bool bWasUpdate = IsUpdateMode(); 1368*cdf0e10cSrcweir if ( bWasUpdate == bUpdate ) 1369*cdf0e10cSrcweir return; 1370*cdf0e10cSrcweir 1371*cdf0e10cSrcweir Control::SetUpdateMode( bUpdate ); 1372*cdf0e10cSrcweir // OV 1373*cdf0e10cSrcweir // Wenn an der BrowseBox WB_CLIPCHILDREN gesetzt ist (wg. Flackerminimierung), 1374*cdf0e10cSrcweir // wird das Datenfenster nicht von SetUpdateMode invalidiert. 1375*cdf0e10cSrcweir if( bUpdate ) 1376*cdf0e10cSrcweir getDataWindow()->Invalidate(); 1377*cdf0e10cSrcweir getDataWindow()->SetUpdateMode( bUpdate ); 1378*cdf0e10cSrcweir 1379*cdf0e10cSrcweir 1380*cdf0e10cSrcweir if ( bUpdate ) 1381*cdf0e10cSrcweir { 1382*cdf0e10cSrcweir if ( bBootstrapped ) 1383*cdf0e10cSrcweir { 1384*cdf0e10cSrcweir UpdateScrollbars(); 1385*cdf0e10cSrcweir AutoSizeLastColumn(); 1386*cdf0e10cSrcweir } 1387*cdf0e10cSrcweir DoShowCursor( "SetUpdateMode" ); 1388*cdf0e10cSrcweir } 1389*cdf0e10cSrcweir else 1390*cdf0e10cSrcweir DoHideCursor( "SetUpdateMode" ); 1391*cdf0e10cSrcweir } 1392*cdf0e10cSrcweir 1393*cdf0e10cSrcweir //------------------------------------------------------------------- 1394*cdf0e10cSrcweir 1395*cdf0e10cSrcweir sal_Bool BrowseBox::GetUpdateMode() const 1396*cdf0e10cSrcweir { 1397*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1398*cdf0e10cSrcweir 1399*cdf0e10cSrcweir return getDataWindow()->IsUpdateMode(); 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir 1402*cdf0e10cSrcweir //------------------------------------------------------------------- 1403*cdf0e10cSrcweir 1404*cdf0e10cSrcweir long BrowseBox::GetFrozenWidth() const 1405*cdf0e10cSrcweir { 1406*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1407*cdf0e10cSrcweir 1408*cdf0e10cSrcweir long nWidth = 0; 1409*cdf0e10cSrcweir for ( sal_uInt16 nCol = 0; 1410*cdf0e10cSrcweir nCol < pCols->Count() && pCols->GetObject(nCol)->IsFrozen(); 1411*cdf0e10cSrcweir ++nCol ) 1412*cdf0e10cSrcweir nWidth += pCols->GetObject(nCol)->Width(); 1413*cdf0e10cSrcweir return nWidth; 1414*cdf0e10cSrcweir } 1415*cdf0e10cSrcweir 1416*cdf0e10cSrcweir //------------------------------------------------------------------- 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir void BrowseBox::ColumnInserted( sal_uInt16 nPos ) 1419*cdf0e10cSrcweir { 1420*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1421*cdf0e10cSrcweir 1422*cdf0e10cSrcweir if ( pColSel ) 1423*cdf0e10cSrcweir pColSel->Insert( nPos ); 1424*cdf0e10cSrcweir UpdateScrollbars(); 1425*cdf0e10cSrcweir } 1426*cdf0e10cSrcweir 1427*cdf0e10cSrcweir //------------------------------------------------------------------- 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir sal_uInt16 BrowseBox::FrozenColCount() const 1430*cdf0e10cSrcweir { 1431*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1432*cdf0e10cSrcweir sal_uInt16 nCol; 1433*cdf0e10cSrcweir for ( nCol = 0; 1434*cdf0e10cSrcweir nCol < pCols->Count() && pCols->GetObject(nCol)->IsFrozen(); 1435*cdf0e10cSrcweir ++nCol ) 1436*cdf0e10cSrcweir /* empty loop */; 1437*cdf0e10cSrcweir return nCol; 1438*cdf0e10cSrcweir } 1439*cdf0e10cSrcweir 1440*cdf0e10cSrcweir //------------------------------------------------------------------- 1441*cdf0e10cSrcweir 1442*cdf0e10cSrcweir IMPL_LINK(BrowseBox,ScrollHdl,ScrollBar*,pBar) 1443*cdf0e10cSrcweir { 1444*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir if ( pBar->GetDelta() == 0 ) 1447*cdf0e10cSrcweir return 0; 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir if ( pBar->GetDelta() < 0 && getDataWindow()->bNoScrollBack ) 1450*cdf0e10cSrcweir { 1451*cdf0e10cSrcweir UpdateScrollbars(); 1452*cdf0e10cSrcweir return 0; 1453*cdf0e10cSrcweir } 1454*cdf0e10cSrcweir 1455*cdf0e10cSrcweir if ( pBar == &aHScroll ) 1456*cdf0e10cSrcweir ScrollColumns( aHScroll.GetDelta() ); 1457*cdf0e10cSrcweir if ( pBar == pVScroll ) 1458*cdf0e10cSrcweir ScrollRows( pVScroll->GetDelta() ); 1459*cdf0e10cSrcweir 1460*cdf0e10cSrcweir return 0; 1461*cdf0e10cSrcweir } 1462*cdf0e10cSrcweir 1463*cdf0e10cSrcweir //------------------------------------------------------------------- 1464*cdf0e10cSrcweir 1465*cdf0e10cSrcweir IMPL_LINK( BrowseBox,EndScrollHdl,ScrollBar*, EMPTYARG ) 1466*cdf0e10cSrcweir { 1467*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir // kein Focus grabben! 1470*cdf0e10cSrcweir /// GrabFocus(); 1471*cdf0e10cSrcweir 1472*cdf0e10cSrcweir if ( /*pBar->GetDelta() <= 0 &&*/ getDataWindow()->bNoScrollBack ) 1473*cdf0e10cSrcweir { 1474*cdf0e10cSrcweir // UpdateScrollbars(); 1475*cdf0e10cSrcweir EndScroll(); 1476*cdf0e10cSrcweir return 0; 1477*cdf0e10cSrcweir } 1478*cdf0e10cSrcweir 1479*cdf0e10cSrcweir return 0; 1480*cdf0e10cSrcweir } 1481*cdf0e10cSrcweir 1482*cdf0e10cSrcweir //------------------------------------------------------------------- 1483*cdf0e10cSrcweir 1484*cdf0e10cSrcweir IMPL_LINK( BrowseBox, StartDragHdl, HeaderBar*, pBar ) 1485*cdf0e10cSrcweir { 1486*cdf0e10cSrcweir pBar->SetDragSize( pDataWin->GetOutputSizePixel().Height() ); 1487*cdf0e10cSrcweir return 0; 1488*cdf0e10cSrcweir } 1489*cdf0e10cSrcweir 1490*cdf0e10cSrcweir //------------------------------------------------------------------- 1491*cdf0e10cSrcweir // MI: es wurde immer nur die 1. Spalte resized 1492*cdf0e10cSrcweir #ifdef _MSC_VER 1493*cdf0e10cSrcweir #pragma optimize("",off) 1494*cdf0e10cSrcweir #endif 1495*cdf0e10cSrcweir 1496*cdf0e10cSrcweir void BrowseBox::MouseButtonDown( const MouseEvent& rEvt ) 1497*cdf0e10cSrcweir { 1498*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1499*cdf0e10cSrcweir 1500*cdf0e10cSrcweir GrabFocus(); 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir // onl< mouse events in the title-line are supported 1503*cdf0e10cSrcweir const Point &rEvtPos = rEvt.GetPosPixel(); 1504*cdf0e10cSrcweir if ( rEvtPos.Y() >= GetTitleHeight() ) 1505*cdf0e10cSrcweir return; 1506*cdf0e10cSrcweir 1507*cdf0e10cSrcweir long nX = 0; 1508*cdf0e10cSrcweir long nWidth = GetOutputSizePixel().Width(); 1509*cdf0e10cSrcweir for ( sal_uInt16 nCol = 0; nCol < pCols->Count() && nX < nWidth; ++nCol ) 1510*cdf0e10cSrcweir { 1511*cdf0e10cSrcweir // is this column visible? 1512*cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol); 1513*cdf0e10cSrcweir if ( pCol->IsFrozen() || nCol >= nFirstCol ) 1514*cdf0e10cSrcweir { 1515*cdf0e10cSrcweir // compute right end of column 1516*cdf0e10cSrcweir long nR = nX + pCol->Width() - 1; 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir // at the end of a column (and not handle column)? 1519*cdf0e10cSrcweir if ( pCol->GetId() && Abs( nR - rEvtPos.X() ) < 2 ) 1520*cdf0e10cSrcweir { 1521*cdf0e10cSrcweir // start resizing the column 1522*cdf0e10cSrcweir bResizing = sal_True; 1523*cdf0e10cSrcweir nResizeCol = nCol; 1524*cdf0e10cSrcweir nDragX = nResizeX = rEvtPos.X(); 1525*cdf0e10cSrcweir SetPointer( Pointer( POINTER_HSPLIT ) ); 1526*cdf0e10cSrcweir CaptureMouse(); 1527*cdf0e10cSrcweir pDataWin->DrawLine( Point( nDragX, 0 ), 1528*cdf0e10cSrcweir Point( nDragX, pDataWin->GetSizePixel().Height() ) ); 1529*cdf0e10cSrcweir nMinResizeX = nX + MIN_COLUMNWIDTH; 1530*cdf0e10cSrcweir return; 1531*cdf0e10cSrcweir } 1532*cdf0e10cSrcweir else if ( nX < rEvtPos.X() && nR > rEvtPos.X() ) 1533*cdf0e10cSrcweir { 1534*cdf0e10cSrcweir MouseButtonDown( BrowserMouseEvent( 1535*cdf0e10cSrcweir this, rEvt, -1, nCol, pCol->GetId(), Rectangle() ) ); 1536*cdf0e10cSrcweir return; 1537*cdf0e10cSrcweir } 1538*cdf0e10cSrcweir nX = nR + 1; 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir } 1541*cdf0e10cSrcweir 1542*cdf0e10cSrcweir // event occured out of data area 1543*cdf0e10cSrcweir if ( rEvt.IsRight() ) 1544*cdf0e10cSrcweir pDataWin->Command( 1545*cdf0e10cSrcweir CommandEvent( Point( 1, LONG_MAX ), COMMAND_CONTEXTMENU, sal_True ) ); 1546*cdf0e10cSrcweir else 1547*cdf0e10cSrcweir SetNoSelection(); 1548*cdf0e10cSrcweir } 1549*cdf0e10cSrcweir 1550*cdf0e10cSrcweir #ifdef _MSC_VER 1551*cdf0e10cSrcweir #pragma optimize("",on) 1552*cdf0e10cSrcweir #endif 1553*cdf0e10cSrcweir 1554*cdf0e10cSrcweir //------------------------------------------------------------------- 1555*cdf0e10cSrcweir 1556*cdf0e10cSrcweir void BrowseBox::MouseMove( const MouseEvent& rEvt ) 1557*cdf0e10cSrcweir { 1558*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1559*cdf0e10cSrcweir DBG_TRACE( "BrowseBox::MouseMove( MouseEvent )" ); 1560*cdf0e10cSrcweir 1561*cdf0e10cSrcweir Pointer aNewPointer; 1562*cdf0e10cSrcweir 1563*cdf0e10cSrcweir sal_uInt16 nX = 0; 1564*cdf0e10cSrcweir for ( sal_uInt16 nCol = 0; 1565*cdf0e10cSrcweir nCol < sal_uInt16(pCols->Count()) && 1566*cdf0e10cSrcweir ( nX + pCols->GetObject(nCol)->Width() ) < sal_uInt16(GetOutputSizePixel().Width()); 1567*cdf0e10cSrcweir ++nCol ) 1568*cdf0e10cSrcweir // is this column visible? 1569*cdf0e10cSrcweir if ( pCols->GetObject(nCol)->IsFrozen() || nCol >= nFirstCol ) 1570*cdf0e10cSrcweir { 1571*cdf0e10cSrcweir // compute right end of column 1572*cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol); 1573*cdf0e10cSrcweir sal_uInt16 nR = (sal_uInt16)(nX + pCol->Width() - 1); 1574*cdf0e10cSrcweir 1575*cdf0e10cSrcweir // show resize-pointer? 1576*cdf0e10cSrcweir if ( bResizing || ( pCol->GetId() && 1577*cdf0e10cSrcweir Abs( ((long) nR ) - rEvt.GetPosPixel().X() ) < MIN_COLUMNWIDTH ) ) 1578*cdf0e10cSrcweir { 1579*cdf0e10cSrcweir aNewPointer = Pointer( POINTER_HSPLIT ); 1580*cdf0e10cSrcweir if ( bResizing ) 1581*cdf0e10cSrcweir { 1582*cdf0e10cSrcweir // alte Hilfslinie loeschen 1583*cdf0e10cSrcweir pDataWin->HideTracking() ; 1584*cdf0e10cSrcweir 1585*cdf0e10cSrcweir // erlaubte breite abholen und neues Delta 1586*cdf0e10cSrcweir nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX ); 1587*cdf0e10cSrcweir long nDeltaX = nDragX - nResizeX; 1588*cdf0e10cSrcweir sal_uInt16 nId = GetColumnId(nResizeCol); 1589*cdf0e10cSrcweir sal_uLong nOldWidth = GetColumnWidth(nId); 1590*cdf0e10cSrcweir nDragX = QueryColumnResize( GetColumnId(nResizeCol), 1591*cdf0e10cSrcweir nOldWidth + nDeltaX ) 1592*cdf0e10cSrcweir + nResizeX - nOldWidth; 1593*cdf0e10cSrcweir 1594*cdf0e10cSrcweir // neue Hilfslinie zeichnen 1595*cdf0e10cSrcweir pDataWin->ShowTracking( Rectangle( Point( nDragX, 0 ), 1596*cdf0e10cSrcweir Size( 1, pDataWin->GetSizePixel().Height() ) ), 1597*cdf0e10cSrcweir SHOWTRACK_SPLIT|SHOWTRACK_WINDOW ); 1598*cdf0e10cSrcweir } 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir } 1601*cdf0e10cSrcweir 1602*cdf0e10cSrcweir nX = nR + 1; 1603*cdf0e10cSrcweir } 1604*cdf0e10cSrcweir 1605*cdf0e10cSrcweir SetPointer( aNewPointer ); 1606*cdf0e10cSrcweir } 1607*cdf0e10cSrcweir 1608*cdf0e10cSrcweir //------------------------------------------------------------------- 1609*cdf0e10cSrcweir 1610*cdf0e10cSrcweir void BrowseBox::MouseButtonUp( const MouseEvent & rEvt ) 1611*cdf0e10cSrcweir { 1612*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir if ( bResizing ) 1615*cdf0e10cSrcweir { 1616*cdf0e10cSrcweir // Hilfslinie loeschen 1617*cdf0e10cSrcweir pDataWin->HideTracking(); 1618*cdf0e10cSrcweir 1619*cdf0e10cSrcweir // width changed? 1620*cdf0e10cSrcweir nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX ); 1621*cdf0e10cSrcweir if ( (nDragX - nResizeX) != (long)pCols->GetObject(nResizeCol)->Width() ) 1622*cdf0e10cSrcweir { 1623*cdf0e10cSrcweir // resize column 1624*cdf0e10cSrcweir long nMaxX = pDataWin->GetSizePixel().Width(); 1625*cdf0e10cSrcweir nDragX = Min( nDragX, nMaxX ); 1626*cdf0e10cSrcweir long nDeltaX = nDragX - nResizeX; 1627*cdf0e10cSrcweir sal_uInt16 nId = GetColumnId(nResizeCol); 1628*cdf0e10cSrcweir SetColumnWidth( GetColumnId(nResizeCol), GetColumnWidth(nId) + nDeltaX ); 1629*cdf0e10cSrcweir ColumnResized( nId ); 1630*cdf0e10cSrcweir } 1631*cdf0e10cSrcweir 1632*cdf0e10cSrcweir // end action 1633*cdf0e10cSrcweir SetPointer( Pointer() ); 1634*cdf0e10cSrcweir ReleaseMouse(); 1635*cdf0e10cSrcweir bResizing = sal_False; 1636*cdf0e10cSrcweir } 1637*cdf0e10cSrcweir else 1638*cdf0e10cSrcweir MouseButtonUp( BrowserMouseEvent( (BrowserDataWin*)pDataWin, 1639*cdf0e10cSrcweir MouseEvent( Point( rEvt.GetPosPixel().X(), 1640*cdf0e10cSrcweir rEvt.GetPosPixel().Y() - pDataWin->GetPosPixel().Y() ), 1641*cdf0e10cSrcweir rEvt.GetClicks(), rEvt.GetMode(), rEvt.GetButtons(), 1642*cdf0e10cSrcweir rEvt.GetModifier() ) ) ); 1643*cdf0e10cSrcweir } 1644*cdf0e10cSrcweir 1645*cdf0e10cSrcweir //------------------------------------------------------------------- 1646*cdf0e10cSrcweir 1647*cdf0e10cSrcweir sal_Bool bExtendedMode = sal_False; 1648*cdf0e10cSrcweir sal_Bool bFieldMode = sal_False; 1649*cdf0e10cSrcweir 1650*cdf0e10cSrcweir void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt ) 1651*cdf0e10cSrcweir { 1652*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1653*cdf0e10cSrcweir 1654*cdf0e10cSrcweir GrabFocus(); 1655*cdf0e10cSrcweir 1656*cdf0e10cSrcweir // adjust selection while and after double-click 1657*cdf0e10cSrcweir if ( rEvt.GetClicks() == 2 ) 1658*cdf0e10cSrcweir { 1659*cdf0e10cSrcweir SetNoSelection(); 1660*cdf0e10cSrcweir if ( rEvt.GetRow() >= 0 ) 1661*cdf0e10cSrcweir { 1662*cdf0e10cSrcweir GoToRow( rEvt.GetRow() ); 1663*cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_True, sal_False ); 1664*cdf0e10cSrcweir } 1665*cdf0e10cSrcweir else 1666*cdf0e10cSrcweir { 1667*cdf0e10cSrcweir if ( bColumnCursor && rEvt.GetColumn() != 0 ) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir if ( rEvt.GetColumn() < pCols->Count() ) 1670*cdf0e10cSrcweir SelectColumnPos( rEvt.GetColumn(), sal_True, sal_False); 1671*cdf0e10cSrcweir } 1672*cdf0e10cSrcweir } 1673*cdf0e10cSrcweir DoubleClick( rEvt ); 1674*cdf0e10cSrcweir } 1675*cdf0e10cSrcweir // selections 1676*cdf0e10cSrcweir else if ( ( rEvt.GetMode() & ( MOUSE_SELECT | MOUSE_SIMPLECLICK ) ) && 1677*cdf0e10cSrcweir ( bColumnCursor || rEvt.GetRow() >= 0 ) ) 1678*cdf0e10cSrcweir { 1679*cdf0e10cSrcweir if ( rEvt.GetClicks() == 1 ) 1680*cdf0e10cSrcweir { 1681*cdf0e10cSrcweir // initialise flags 1682*cdf0e10cSrcweir bHit = sal_False; 1683*cdf0e10cSrcweir a1stPoint = 1684*cdf0e10cSrcweir a2ndPoint = PixelToLogic( rEvt.GetPosPixel() ); 1685*cdf0e10cSrcweir 1686*cdf0e10cSrcweir // selection out of range? 1687*cdf0e10cSrcweir if ( rEvt.GetRow() >= nRowCount || 1688*cdf0e10cSrcweir rEvt.GetColumnId() == BROWSER_INVALIDID ) 1689*cdf0e10cSrcweir { 1690*cdf0e10cSrcweir SetNoSelection(); 1691*cdf0e10cSrcweir return; 1692*cdf0e10cSrcweir } 1693*cdf0e10cSrcweir 1694*cdf0e10cSrcweir // while selecting, no cursor 1695*cdf0e10cSrcweir bSelecting = sal_True; 1696*cdf0e10cSrcweir DoHideCursor( "MouseButtonDown" ); 1697*cdf0e10cSrcweir 1698*cdf0e10cSrcweir // DataRow? 1699*cdf0e10cSrcweir if ( rEvt.GetRow() >= 0 ) 1700*cdf0e10cSrcweir { 1701*cdf0e10cSrcweir // Zeilenselektion? 1702*cdf0e10cSrcweir if ( rEvt.GetColumnId() == 0 || !bColumnCursor ) 1703*cdf0e10cSrcweir { 1704*cdf0e10cSrcweir if ( bMultiSelection ) 1705*cdf0e10cSrcweir { 1706*cdf0e10cSrcweir // remove column-selection, if exists 1707*cdf0e10cSrcweir if ( pColSel && pColSel->GetSelectCount() ) 1708*cdf0e10cSrcweir { 1709*cdf0e10cSrcweir ToggleSelection(); 1710*cdf0e10cSrcweir if ( bMultiSelection ) 1711*cdf0e10cSrcweir uRow.pSel->SelectAll(sal_False); 1712*cdf0e10cSrcweir else 1713*cdf0e10cSrcweir uRow.nSel = BROWSER_ENDOFSELECTION; 1714*cdf0e10cSrcweir if ( pColSel ) 1715*cdf0e10cSrcweir pColSel->SelectAll(sal_False); 1716*cdf0e10cSrcweir bSelect = sal_True; 1717*cdf0e10cSrcweir } 1718*cdf0e10cSrcweir 1719*cdf0e10cSrcweir // expanding mode? 1720*cdf0e10cSrcweir if ( rEvt.GetMode() & MOUSE_RANGESELECT ) 1721*cdf0e10cSrcweir { 1722*cdf0e10cSrcweir // select the further touched rows too 1723*cdf0e10cSrcweir bSelect = sal_True; 1724*cdf0e10cSrcweir ExpandRowSelection( rEvt ); 1725*cdf0e10cSrcweir return; 1726*cdf0e10cSrcweir } 1727*cdf0e10cSrcweir 1728*cdf0e10cSrcweir // click in the selected area? 1729*cdf0e10cSrcweir else if ( IsRowSelected( rEvt.GetRow() ) ) 1730*cdf0e10cSrcweir { 1731*cdf0e10cSrcweir // auf Drag&Drop warten 1732*cdf0e10cSrcweir bHit = sal_True; 1733*cdf0e10cSrcweir bExtendedMode = MOUSE_MULTISELECT == 1734*cdf0e10cSrcweir ( rEvt.GetMode() & MOUSE_MULTISELECT ); 1735*cdf0e10cSrcweir return; 1736*cdf0e10cSrcweir } 1737*cdf0e10cSrcweir 1738*cdf0e10cSrcweir // extension mode? 1739*cdf0e10cSrcweir else if ( rEvt.GetMode() & MOUSE_MULTISELECT ) 1740*cdf0e10cSrcweir { 1741*cdf0e10cSrcweir // determine the new selection range 1742*cdf0e10cSrcweir // and selection/deselection 1743*cdf0e10cSrcweir aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() ); 1744*cdf0e10cSrcweir SelectRow( rEvt.GetRow(), 1745*cdf0e10cSrcweir !uRow.pSel->IsSelected( rEvt.GetRow() ) ); 1746*cdf0e10cSrcweir bSelect = sal_True; 1747*cdf0e10cSrcweir return; 1748*cdf0e10cSrcweir } 1749*cdf0e10cSrcweir } 1750*cdf0e10cSrcweir 1751*cdf0e10cSrcweir // select directly 1752*cdf0e10cSrcweir SetNoSelection(); 1753*cdf0e10cSrcweir GoToRow( rEvt.GetRow() ); 1754*cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_True ); 1755*cdf0e10cSrcweir aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() ); 1756*cdf0e10cSrcweir bSelect = sal_True; 1757*cdf0e10cSrcweir } 1758*cdf0e10cSrcweir else // Column/Field-Selection 1759*cdf0e10cSrcweir { 1760*cdf0e10cSrcweir // click in selected column 1761*cdf0e10cSrcweir if ( IsColumnSelected( rEvt.GetColumn() ) || 1762*cdf0e10cSrcweir IsRowSelected( rEvt.GetRow() ) ) 1763*cdf0e10cSrcweir { 1764*cdf0e10cSrcweir bHit = sal_True; 1765*cdf0e10cSrcweir bFieldMode = sal_True; 1766*cdf0e10cSrcweir return; 1767*cdf0e10cSrcweir } 1768*cdf0e10cSrcweir 1769*cdf0e10cSrcweir SetNoSelection(); 1770*cdf0e10cSrcweir GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() ); 1771*cdf0e10cSrcweir bSelect = sal_True; 1772*cdf0e10cSrcweir } 1773*cdf0e10cSrcweir } 1774*cdf0e10cSrcweir else 1775*cdf0e10cSrcweir { 1776*cdf0e10cSrcweir if ( bMultiSelection && rEvt.GetColumnId() == 0 ) 1777*cdf0e10cSrcweir { 1778*cdf0e10cSrcweir // toggle all-selection 1779*cdf0e10cSrcweir if ( uRow.pSel->GetSelectCount() > ( GetRowCount() / 2 ) ) 1780*cdf0e10cSrcweir SetNoSelection(); 1781*cdf0e10cSrcweir else 1782*cdf0e10cSrcweir SelectAll(); 1783*cdf0e10cSrcweir } 1784*cdf0e10cSrcweir else 1785*cdf0e10cSrcweir SelectColumnId( rEvt.GetColumnId(), sal_True, sal_False ); 1786*cdf0e10cSrcweir } 1787*cdf0e10cSrcweir 1788*cdf0e10cSrcweir // ggf. Cursor wieder an 1789*cdf0e10cSrcweir bSelecting = sal_False; 1790*cdf0e10cSrcweir DoShowCursor( "MouseButtonDown" ); 1791*cdf0e10cSrcweir if ( bSelect ) 1792*cdf0e10cSrcweir Select(); 1793*cdf0e10cSrcweir } 1794*cdf0e10cSrcweir } 1795*cdf0e10cSrcweir } 1796*cdf0e10cSrcweir 1797*cdf0e10cSrcweir //------------------------------------------------------------------- 1798*cdf0e10cSrcweir 1799*cdf0e10cSrcweir void BrowseBox::MouseMove( const BrowserMouseEvent& ) 1800*cdf0e10cSrcweir { 1801*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1802*cdf0e10cSrcweir } 1803*cdf0e10cSrcweir 1804*cdf0e10cSrcweir //------------------------------------------------------------------- 1805*cdf0e10cSrcweir 1806*cdf0e10cSrcweir void BrowseBox::MouseButtonUp( const BrowserMouseEvent &rEvt ) 1807*cdf0e10cSrcweir { 1808*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1809*cdf0e10cSrcweir 1810*cdf0e10cSrcweir // D&D was possible, but did not occur 1811*cdf0e10cSrcweir if ( bHit ) 1812*cdf0e10cSrcweir { 1813*cdf0e10cSrcweir aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() ); 1814*cdf0e10cSrcweir if ( bExtendedMode ) 1815*cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_False ); 1816*cdf0e10cSrcweir else 1817*cdf0e10cSrcweir { 1818*cdf0e10cSrcweir SetNoSelection(); 1819*cdf0e10cSrcweir if ( bFieldMode ) 1820*cdf0e10cSrcweir GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() ); 1821*cdf0e10cSrcweir else 1822*cdf0e10cSrcweir { 1823*cdf0e10cSrcweir GoToRow( rEvt.GetRow() ); 1824*cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_True ); 1825*cdf0e10cSrcweir } 1826*cdf0e10cSrcweir } 1827*cdf0e10cSrcweir bSelect = sal_True; 1828*cdf0e10cSrcweir bExtendedMode = sal_False; 1829*cdf0e10cSrcweir bFieldMode = sal_False; 1830*cdf0e10cSrcweir bHit = sal_False; 1831*cdf0e10cSrcweir } 1832*cdf0e10cSrcweir 1833*cdf0e10cSrcweir // activate cursor 1834*cdf0e10cSrcweir if ( bSelecting ) 1835*cdf0e10cSrcweir { 1836*cdf0e10cSrcweir bSelecting = sal_False; 1837*cdf0e10cSrcweir DoShowCursor( "MouseButtonUp" ); 1838*cdf0e10cSrcweir if ( bSelect ) 1839*cdf0e10cSrcweir Select(); 1840*cdf0e10cSrcweir } 1841*cdf0e10cSrcweir } 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir //------------------------------------------------------------------- 1844*cdf0e10cSrcweir 1845*cdf0e10cSrcweir void BrowseBox::KeyInput( const KeyEvent& rEvt ) 1846*cdf0e10cSrcweir { 1847*cdf0e10cSrcweir if ( !ProcessKey( rEvt ) ) 1848*cdf0e10cSrcweir Control::KeyInput( rEvt ); 1849*cdf0e10cSrcweir } 1850*cdf0e10cSrcweir 1851*cdf0e10cSrcweir //------------------------------------------------------------------- 1852*cdf0e10cSrcweir 1853*cdf0e10cSrcweir sal_Bool BrowseBox::ProcessKey( const KeyEvent& rEvt ) 1854*cdf0e10cSrcweir { 1855*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1856*cdf0e10cSrcweir 1857*cdf0e10cSrcweir sal_uInt16 nCode = rEvt.GetKeyCode().GetCode(); 1858*cdf0e10cSrcweir sal_Bool bShift = rEvt.GetKeyCode().IsShift(); 1859*cdf0e10cSrcweir sal_Bool bCtrl = rEvt.GetKeyCode().IsMod1(); 1860*cdf0e10cSrcweir sal_Bool bAlt = rEvt.GetKeyCode().IsMod2(); 1861*cdf0e10cSrcweir 1862*cdf0e10cSrcweir sal_uInt16 nId = BROWSER_NONE; 1863*cdf0e10cSrcweir 1864*cdf0e10cSrcweir if ( !bAlt && !bCtrl && !bShift ) 1865*cdf0e10cSrcweir { 1866*cdf0e10cSrcweir switch ( nCode ) 1867*cdf0e10cSrcweir { 1868*cdf0e10cSrcweir case KEY_DOWN: nId = BROWSER_CURSORDOWN; break; 1869*cdf0e10cSrcweir case KEY_UP: nId = BROWSER_CURSORUP; break; 1870*cdf0e10cSrcweir case KEY_HOME: nId = BROWSER_CURSORHOME; break; 1871*cdf0e10cSrcweir case KEY_END: nId = BROWSER_CURSOREND; break; 1872*cdf0e10cSrcweir case KEY_TAB: 1873*cdf0e10cSrcweir if ( !bColumnCursor ) 1874*cdf0e10cSrcweir break; 1875*cdf0e10cSrcweir case KEY_RIGHT: nId = BROWSER_CURSORRIGHT; break; 1876*cdf0e10cSrcweir case KEY_LEFT: nId = BROWSER_CURSORLEFT; break; 1877*cdf0e10cSrcweir case KEY_SPACE: nId = BROWSER_SELECT; break; 1878*cdf0e10cSrcweir } 1879*cdf0e10cSrcweir if ( BROWSER_NONE != nId ) 1880*cdf0e10cSrcweir SetNoSelection(); 1881*cdf0e10cSrcweir 1882*cdf0e10cSrcweir switch ( nCode ) 1883*cdf0e10cSrcweir { 1884*cdf0e10cSrcweir case KEY_PAGEDOWN: nId = BROWSER_CURSORPAGEDOWN; break; 1885*cdf0e10cSrcweir case KEY_PAGEUP: nId = BROWSER_CURSORPAGEUP; break; 1886*cdf0e10cSrcweir } 1887*cdf0e10cSrcweir } 1888*cdf0e10cSrcweir 1889*cdf0e10cSrcweir if ( !bAlt && !bCtrl && bShift ) 1890*cdf0e10cSrcweir switch ( nCode ) 1891*cdf0e10cSrcweir { 1892*cdf0e10cSrcweir case KEY_DOWN: nId = BROWSER_SELECTDOWN; break; 1893*cdf0e10cSrcweir case KEY_UP: nId = BROWSER_SELECTUP; break; 1894*cdf0e10cSrcweir case KEY_TAB: 1895*cdf0e10cSrcweir if ( !bColumnCursor ) 1896*cdf0e10cSrcweir break; 1897*cdf0e10cSrcweir nId = BROWSER_CURSORLEFT; break; 1898*cdf0e10cSrcweir case KEY_HOME: nId = BROWSER_SELECTHOME; break; 1899*cdf0e10cSrcweir case KEY_END: nId = BROWSER_SELECTEND; break; 1900*cdf0e10cSrcweir } 1901*cdf0e10cSrcweir 1902*cdf0e10cSrcweir 1903*cdf0e10cSrcweir if ( !bAlt && bCtrl && !bShift ) 1904*cdf0e10cSrcweir switch ( nCode ) 1905*cdf0e10cSrcweir { 1906*cdf0e10cSrcweir case KEY_DOWN: nId = BROWSER_CURSORDOWN; break; 1907*cdf0e10cSrcweir case KEY_UP: nId = BROWSER_CURSORUP; break; 1908*cdf0e10cSrcweir case KEY_PAGEDOWN: nId = BROWSER_CURSORENDOFFILE; break; 1909*cdf0e10cSrcweir case KEY_PAGEUP: nId = BROWSER_CURSORTOPOFFILE; break; 1910*cdf0e10cSrcweir case KEY_HOME: nId = BROWSER_CURSORTOPOFSCREEN; break; 1911*cdf0e10cSrcweir case KEY_END: nId = BROWSER_CURSORENDOFSCREEN; break; 1912*cdf0e10cSrcweir case KEY_SPACE: nId = BROWSER_ENHANCESELECTION; break; 1913*cdf0e10cSrcweir case KEY_LEFT: nId = BROWSER_MOVECOLUMNLEFT; break; 1914*cdf0e10cSrcweir case KEY_RIGHT: nId = BROWSER_MOVECOLUMNRIGHT; break; 1915*cdf0e10cSrcweir } 1916*cdf0e10cSrcweir 1917*cdf0e10cSrcweir if ( nId != BROWSER_NONE ) 1918*cdf0e10cSrcweir Dispatch( nId ); 1919*cdf0e10cSrcweir return nId != BROWSER_NONE; 1920*cdf0e10cSrcweir } 1921*cdf0e10cSrcweir 1922*cdf0e10cSrcweir //------------------------------------------------------------------- 1923*cdf0e10cSrcweir 1924*cdf0e10cSrcweir void BrowseBox::Dispatch( sal_uInt16 nId ) 1925*cdf0e10cSrcweir { 1926*cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); 1927*cdf0e10cSrcweir 1928*cdf0e10cSrcweir long nRowsOnPage = pDataWin->GetSizePixel().Height() / GetDataRowHeight(); 1929*cdf0e10cSrcweir sal_Bool bDone = sal_False; 1930*cdf0e10cSrcweir 1931*cdf0e10cSrcweir switch ( nId ) 1932*cdf0e10cSrcweir { 1933*cdf0e10cSrcweir case BROWSER_SELECTCOLUMN: 1934*cdf0e10cSrcweir if ( ColCount() ) 1935*cdf0e10cSrcweir SelectColumnId( GetCurColumnId() ); 1936*cdf0e10cSrcweir break; 1937*cdf0e10cSrcweir 1938*cdf0e10cSrcweir case BROWSER_CURSORDOWN: 1939*cdf0e10cSrcweir if ( ( GetCurRow() + 1 ) < nRowCount ) 1940*cdf0e10cSrcweir bDone = GoToRow( GetCurRow() + 1, sal_False ); 1941*cdf0e10cSrcweir break; 1942*cdf0e10cSrcweir case BROWSER_CURSORUP: 1943*cdf0e10cSrcweir if ( GetCurRow() > 0 ) 1944*cdf0e10cSrcweir bDone = GoToRow( GetCurRow() - 1, sal_False ); 1945*cdf0e10cSrcweir break; 1946*cdf0e10cSrcweir case BROWSER_SELECTHOME: 1947*cdf0e10cSrcweir if ( GetRowCount() ) 1948*cdf0e10cSrcweir { 1949*cdf0e10cSrcweir DoHideCursor( "BROWSER_SELECTHOME" ); 1950*cdf0e10cSrcweir for ( long nRow = GetCurRow(); nRow >= 0; --nRow ) 1951*cdf0e10cSrcweir SelectRow( nRow ); 1952*cdf0e10cSrcweir GoToRow( 0, sal_True ); 1953*cdf0e10cSrcweir DoShowCursor( "BROWSER_SELECTHOME" ); 1954*cdf0e10cSrcweir } 1955*cdf0e10cSrcweir break; 1956*cdf0e10cSrcweir case BROWSER_SELECTEND: 1957*cdf0e10cSrcweir if ( GetRowCount() ) 1958*cdf0e10cSrcweir { 1959*cdf0e10cSrcweir DoHideCursor( "BROWSER_SELECTEND" ); 1960*cdf0e10cSrcweir long nRows = GetRowCount(); 1961*cdf0e10cSrcweir for ( long nRow = GetCurRow(); nRow < nRows; ++nRow ) 1962*cdf0e10cSrcweir SelectRow( nRow ); 1963*cdf0e10cSrcweir GoToRow( GetRowCount() - 1, sal_True ); 1964*cdf0e10cSrcweir DoShowCursor( "BROWSER_SELECTEND" ); 1965*cdf0e10cSrcweir } 1966*cdf0e10cSrcweir break; 1967*cdf0e10cSrcweir case BROWSER_SELECTDOWN: 1968*cdf0e10cSrcweir { 1969*cdf0e10cSrcweir if ( GetRowCount() && ( GetCurRow() + 1 ) < nRowCount ) 1970*cdf0e10cSrcweir { 1971*cdf0e10cSrcweir // deselect the current row, if it isn't the first 1972*cdf0e10cSrcweir // and there is no other selected row above 1973*cdf0e10cSrcweir long nRow = GetCurRow(); 1974*cdf0e10cSrcweir sal_Bool bLocalSelect = ( !IsRowSelected( nRow ) || 1975*cdf0e10cSrcweir GetSelectRowCount() == 1 || IsRowSelected( nRow - 1 ) ); 1976*cdf0e10cSrcweir SelectRow( nRow, bLocalSelect, sal_True ); 1977*cdf0e10cSrcweir bDone = GoToRow( GetCurRow() + 1 , sal_False ); 1978*cdf0e10cSrcweir if ( bDone ) 1979*cdf0e10cSrcweir SelectRow( GetCurRow(), sal_True, sal_True ); 1980*cdf0e10cSrcweir } 1981*cdf0e10cSrcweir else 1982*cdf0e10cSrcweir bDone = ScrollRows( 1 ) != 0; 1983*cdf0e10cSrcweir break; 1984*cdf0e10cSrcweir } 1985*cdf0e10cSrcweir case BROWSER_SELECTUP: 1986*cdf0e10cSrcweir if ( GetRowCount() ) 1987*cdf0e10cSrcweir { 1988*cdf0e10cSrcweir // deselect the current row, if it isn't the first 1989*cdf0e10cSrcweir // and there is no other selected row under 1990*cdf0e10cSrcweir long nRow = GetCurRow(); 1991*cdf0e10cSrcweir sal_Bool bLocalSelect = ( !IsRowSelected( nRow ) || 1992*cdf0e10cSrcweir GetSelectRowCount() == 1 || IsRowSelected( nRow + 1 ) ); 1993*cdf0e10cSrcweir SelectRow( nCurRow, bLocalSelect, sal_True ); 1994*cdf0e10cSrcweir bDone = GoToRow( nRow - 1 , sal_False ); 1995*cdf0e10cSrcweir if ( bDone ) 1996*cdf0e10cSrcweir SelectRow( GetCurRow(), sal_True, sal_True ); 1997*cdf0e10cSrcweir } 1998*cdf0e10cSrcweir break; 1999*cdf0e10cSrcweir case BROWSER_CURSORPAGEDOWN: 2000*cdf0e10cSrcweir bDone = (sal_Bool)ScrollRows( nRowsOnPage ); 2001*cdf0e10cSrcweir break; 2002*cdf0e10cSrcweir case BROWSER_CURSORPAGEUP: 2003*cdf0e10cSrcweir bDone = (sal_Bool)ScrollRows( -nRowsOnPage ); 2004*cdf0e10cSrcweir break; 2005*cdf0e10cSrcweir case BROWSER_CURSOREND: 2006*cdf0e10cSrcweir if ( bColumnCursor ) 2007*cdf0e10cSrcweir { 2008*cdf0e10cSrcweir sal_uInt16 nNewId = GetColumnId(ColCount() -1); 2009*cdf0e10cSrcweir bDone = (nNewId != 0) && GoToColumnId( nNewId ); 2010*cdf0e10cSrcweir break; 2011*cdf0e10cSrcweir } 2012*cdf0e10cSrcweir case BROWSER_CURSORENDOFFILE: 2013*cdf0e10cSrcweir bDone = GoToRow( nRowCount - 1, sal_False ); 2014*cdf0e10cSrcweir break; 2015*cdf0e10cSrcweir case BROWSER_CURSORRIGHT: 2016*cdf0e10cSrcweir if ( bColumnCursor ) 2017*cdf0e10cSrcweir { 2018*cdf0e10cSrcweir sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) + 1; 2019*cdf0e10cSrcweir sal_uInt16 nNewId = GetColumnId( nNewPos ); 2020*cdf0e10cSrcweir if (nNewId != 0) // Am Zeilenende ? 2021*cdf0e10cSrcweir bDone = GoToColumnId( nNewId ); 2022*cdf0e10cSrcweir else 2023*cdf0e10cSrcweir { 2024*cdf0e10cSrcweir sal_uInt16 nColId = ( GetColumnId(0) == 0 ) ? GetColumnId(1) : GetColumnId(0); 2025*cdf0e10cSrcweir if ( GetRowCount() ) 2026*cdf0e10cSrcweir bDone = ( nCurRow < GetRowCount() - 1 ) && GoToRowColumnId( nCurRow + 1, nColId ); 2027*cdf0e10cSrcweir else if ( ColCount() ) 2028*cdf0e10cSrcweir GoToColumnId( nColId ); 2029*cdf0e10cSrcweir } 2030*cdf0e10cSrcweir } 2031*cdf0e10cSrcweir else 2032*cdf0e10cSrcweir bDone = ScrollColumns( 1 ) != 0; 2033*cdf0e10cSrcweir break; 2034*cdf0e10cSrcweir case BROWSER_CURSORHOME: 2035*cdf0e10cSrcweir if ( bColumnCursor ) 2036*cdf0e10cSrcweir { 2037*cdf0e10cSrcweir sal_uInt16 nNewId = GetColumnId(1); 2038*cdf0e10cSrcweir bDone = (nNewId != 0) && GoToColumnId( nNewId ); 2039*cdf0e10cSrcweir break; 2040*cdf0e10cSrcweir } 2041*cdf0e10cSrcweir case BROWSER_CURSORTOPOFFILE: 2042*cdf0e10cSrcweir bDone = GoToRow( 0, sal_False ); 2043*cdf0e10cSrcweir break; 2044*cdf0e10cSrcweir case BROWSER_CURSORLEFT: 2045*cdf0e10cSrcweir if ( bColumnCursor ) 2046*cdf0e10cSrcweir { 2047*cdf0e10cSrcweir sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) - 1; 2048*cdf0e10cSrcweir sal_uInt16 nNewId = GetColumnId( nNewPos ); 2049*cdf0e10cSrcweir if (nNewId != 0) 2050*cdf0e10cSrcweir bDone = GoToColumnId( nNewId ); 2051*cdf0e10cSrcweir else 2052*cdf0e10cSrcweir { 2053*cdf0e10cSrcweir if ( GetRowCount() ) 2054*cdf0e10cSrcweir bDone = (nCurRow > 0) && GoToRowColumnId(nCurRow - 1, GetColumnId(ColCount() -1)); 2055*cdf0e10cSrcweir else if ( ColCount() ) 2056*cdf0e10cSrcweir GoToColumnId( GetColumnId(ColCount() -1) ); 2057*cdf0e10cSrcweir } 2058*cdf0e10cSrcweir } 2059*cdf0e10cSrcweir else 2060*cdf0e10cSrcweir bDone = ScrollColumns( -1 ) != 0; 2061*cdf0e10cSrcweir break; 2062*cdf0e10cSrcweir case BROWSER_ENHANCESELECTION: 2063*cdf0e10cSrcweir if ( GetRowCount() ) 2064*cdf0e10cSrcweir SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), sal_True ); 2065*cdf0e10cSrcweir bDone = sal_True; 2066*cdf0e10cSrcweir break; 2067*cdf0e10cSrcweir case BROWSER_SELECT: 2068*cdf0e10cSrcweir if ( GetRowCount() ) 2069*cdf0e10cSrcweir SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), sal_False ); 2070*cdf0e10cSrcweir bDone = sal_True; 2071*cdf0e10cSrcweir break; 2072*cdf0e10cSrcweir case BROWSER_MOVECOLUMNLEFT: 2073*cdf0e10cSrcweir case BROWSER_MOVECOLUMNRIGHT: 2074*cdf0e10cSrcweir { // check if column moving is allowed 2075*cdf0e10cSrcweir BrowserHeader* pHeaderBar = getDataWindow()->pHeaderBar; 2076*cdf0e10cSrcweir if ( pHeaderBar && pHeaderBar->IsDragable() ) 2077*cdf0e10cSrcweir { 2078*cdf0e10cSrcweir sal_uInt16 nColId = GetCurColumnId(); 2079*cdf0e10cSrcweir sal_Bool bColumnSelected = IsColumnSelected(nColId); 2080*cdf0e10cSrcweir sal_uInt16 nNewPos = GetColumnPos(nColId); 2081*cdf0e10cSrcweir sal_Bool bMoveAllowed = sal_False; 2082*cdf0e10cSrcweir if ( BROWSER_MOVECOLUMNLEFT == nId && nNewPos > 1 ) 2083*cdf0e10cSrcweir --nNewPos,bMoveAllowed = sal_True; 2084*cdf0e10cSrcweir else if ( BROWSER_MOVECOLUMNRIGHT == nId && nNewPos < (ColCount()-1) ) 2085*cdf0e10cSrcweir ++nNewPos,bMoveAllowed = sal_True; 2086*cdf0e10cSrcweir 2087*cdf0e10cSrcweir if ( bMoveAllowed ) 2088*cdf0e10cSrcweir { 2089*cdf0e10cSrcweir SetColumnPos( nColId, nNewPos ); 2090*cdf0e10cSrcweir ColumnMoved( nColId ); 2091*cdf0e10cSrcweir MakeFieldVisible(GetCurRow(),nColId,sal_True); 2092*cdf0e10cSrcweir if ( bColumnSelected ) 2093*cdf0e10cSrcweir SelectColumnId(nColId); 2094*cdf0e10cSrcweir } 2095*cdf0e10cSrcweir } 2096*cdf0e10cSrcweir } 2097*cdf0e10cSrcweir break; 2098*cdf0e10cSrcweir } 2099*cdf0e10cSrcweir 2100*cdf0e10cSrcweir //! return bDone; 2101*cdf0e10cSrcweir } 2102*cdf0e10cSrcweir 2103*cdf0e10cSrcweir //------------------------------------------------------------------- 2104*cdf0e10cSrcweir 2105*cdf0e10cSrcweir void BrowseBox::SetCursorColor(const Color& _rCol) 2106*cdf0e10cSrcweir { 2107*cdf0e10cSrcweir if (_rCol == m_aCursorColor) 2108*cdf0e10cSrcweir return; 2109*cdf0e10cSrcweir 2110*cdf0e10cSrcweir // ensure the cursor is hidden 2111*cdf0e10cSrcweir DoHideCursor("SetCursorColor"); 2112*cdf0e10cSrcweir if (!m_bFocusOnlyCursor) 2113*cdf0e10cSrcweir DoHideCursor("SetCursorColor - force"); 2114*cdf0e10cSrcweir 2115*cdf0e10cSrcweir m_aCursorColor = _rCol; 2116*cdf0e10cSrcweir 2117*cdf0e10cSrcweir if (!m_bFocusOnlyCursor) 2118*cdf0e10cSrcweir DoShowCursor("SetCursorColor - force"); 2119*cdf0e10cSrcweir DoShowCursor("SetCursorColor"); 2120*cdf0e10cSrcweir } 2121*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2122*cdf0e10cSrcweir Rectangle BrowseBox::calcHeaderRect(sal_Bool _bIsColumnBar,sal_Bool _bOnScreen) 2123*cdf0e10cSrcweir { 2124*cdf0e10cSrcweir Window* pParent = NULL; 2125*cdf0e10cSrcweir if ( !_bOnScreen ) 2126*cdf0e10cSrcweir pParent = GetAccessibleParentWindow(); 2127*cdf0e10cSrcweir 2128*cdf0e10cSrcweir Point aTopLeft; 2129*cdf0e10cSrcweir long nWidth; 2130*cdf0e10cSrcweir long nHeight; 2131*cdf0e10cSrcweir if ( _bIsColumnBar ) 2132*cdf0e10cSrcweir { 2133*cdf0e10cSrcweir nWidth = GetDataWindow().GetOutputSizePixel().Width(); 2134*cdf0e10cSrcweir nHeight = GetDataRowHeight(); 2135*cdf0e10cSrcweir } 2136*cdf0e10cSrcweir else 2137*cdf0e10cSrcweir { 2138*cdf0e10cSrcweir aTopLeft.Y() = GetDataRowHeight(); 2139*cdf0e10cSrcweir nWidth = GetColumnWidth(0); 2140*cdf0e10cSrcweir nHeight = GetWindowExtentsRelative( pParent ).GetHeight() - aTopLeft.Y() - GetControlArea().GetSize().B(); 2141*cdf0e10cSrcweir } 2142*cdf0e10cSrcweir aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft(); 2143*cdf0e10cSrcweir return Rectangle(aTopLeft,Size(nWidth,nHeight)); 2144*cdf0e10cSrcweir } 2145*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2146*cdf0e10cSrcweir Rectangle BrowseBox::calcTableRect(sal_Bool _bOnScreen) 2147*cdf0e10cSrcweir { 2148*cdf0e10cSrcweir Window* pParent = NULL; 2149*cdf0e10cSrcweir if ( !_bOnScreen ) 2150*cdf0e10cSrcweir pParent = GetAccessibleParentWindow(); 2151*cdf0e10cSrcweir 2152*cdf0e10cSrcweir Rectangle aRect( GetWindowExtentsRelative( pParent ) ); 2153*cdf0e10cSrcweir Rectangle aRowBar = calcHeaderRect(sal_False,pParent == NULL); 2154*cdf0e10cSrcweir 2155*cdf0e10cSrcweir long nX = aRowBar.Right() - aRect.Left(); 2156*cdf0e10cSrcweir long nY = aRowBar.Top() - aRect.Top(); 2157*cdf0e10cSrcweir Size aSize(aRect.GetSize()); 2158*cdf0e10cSrcweir 2159*cdf0e10cSrcweir return Rectangle(aRowBar.TopRight(), Size(aSize.A() - nX, aSize.B() - nY - aHScroll.GetSizePixel().Height()) ); 2160*cdf0e10cSrcweir } 2161*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 2162*cdf0e10cSrcweir Rectangle BrowseBox::GetFieldRectPixelAbs( sal_Int32 _nRowId,sal_uInt16 _nColId, sal_Bool /*_bIsHeader*/, sal_Bool _bOnScreen ) 2163*cdf0e10cSrcweir { 2164*cdf0e10cSrcweir Window* pParent = NULL; 2165*cdf0e10cSrcweir if ( !_bOnScreen ) 2166*cdf0e10cSrcweir pParent = GetAccessibleParentWindow(); 2167*cdf0e10cSrcweir 2168*cdf0e10cSrcweir Rectangle aRect = GetFieldRectPixel(_nRowId,_nColId,_bOnScreen); 2169*cdf0e10cSrcweir 2170*cdf0e10cSrcweir Point aTopLeft = aRect.TopLeft(); 2171*cdf0e10cSrcweir aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft(); 2172*cdf0e10cSrcweir 2173*cdf0e10cSrcweir return Rectangle(aTopLeft,aRect.GetSize()); 2174*cdf0e10cSrcweir } 2175*cdf0e10cSrcweir 2176*cdf0e10cSrcweir // ------------------------------------------------------------------------- EOF 2177*cdf0e10cSrcweir 2178