1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: brwbox2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <tools/debug.hxx>
34 #include <svtools/brwbox.hxx>
36 #include <svtools/colorcfg.hxx>
37 #include <vcl/salgtype.hxx>
41 #include <tools/multisel.hxx>
44 using namespace ::com::sun::star::datatransfer
;
46 #define getDataWindow() ((BrowserDataWin*)pDataWin)
49 //===================================================================
53 //===================================================================
55 extern const char* BrowseBoxCheckInvariants( const void * pVoid
);
57 DECLARE_LIST( BrowserColumns
, BrowserColumn
* )
59 //===================================================================
61 void BrowseBox::StartDrag( sal_Int8
/* _nAction */, const Point
& /* _rPosPixel */ )
63 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
64 // not interested in this event
67 //===================================================================
69 sal_Int8
BrowseBox::AcceptDrop( const AcceptDropEvent
& _rEvt
)
71 BrowserDataWin
* pDataWindow
= static_cast<BrowserDataWin
*>(pDataWin
);
72 AcceptDropEvent
aTransformed( _rEvt
);
73 aTransformed
.maPosPixel
= pDataWindow
->ScreenToOutputPixel( OutputToScreenPixel( _rEvt
.maPosPixel
) );
74 return pDataWindow
->AcceptDrop( aTransformed
);
77 //===================================================================
79 sal_Int8
BrowseBox::ExecuteDrop( const ExecuteDropEvent
& _rEvt
)
81 BrowserDataWin
* pDataWindow
= static_cast<BrowserDataWin
*>(pDataWin
);
82 ExecuteDropEvent
aTransformed( _rEvt
);
83 aTransformed
.maPosPixel
= pDataWindow
->ScreenToOutputPixel( OutputToScreenPixel( _rEvt
.maPosPixel
) );
84 return pDataWindow
->ExecuteDrop( aTransformed
);
87 //===================================================================
89 sal_Int8
BrowseBox::AcceptDrop( const BrowserAcceptDropEvent
& )
91 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
92 // not interested in this event
93 return DND_ACTION_NONE
;
96 //===================================================================
98 sal_Int8
BrowseBox::ExecuteDrop( const BrowserExecuteDropEvent
& )
100 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
101 // not interested in this event
102 return DND_ACTION_NONE
;
105 //===================================================================
107 void* BrowseBox::implGetDataFlavors() const
109 if (static_cast<BrowserDataWin
*>(pDataWin
)->bCallingDropCallback
)
110 return &static_cast<BrowserDataWin
*>(pDataWin
)->GetDataFlavorExVector();
111 return &GetDataFlavorExVector();
114 //===================================================================
116 sal_Bool
BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat
)
118 if ( static_cast< BrowserDataWin
* >( pDataWin
)->bCallingDropCallback
)
119 return static_cast< BrowserDataWin
* >( pDataWin
)->IsDropFormatSupported( _nFormat
);
121 return DropTargetHelper::IsDropFormatSupported( _nFormat
);
124 //===================================================================
126 sal_Bool
BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat
) const
128 return const_cast< BrowseBox
* >( this )->IsDropFormatSupported( _nFormat
);
131 //===================================================================
133 sal_Bool
BrowseBox::IsDropFormatSupported( const DataFlavor
& _rFlavor
)
135 if ( static_cast< BrowserDataWin
* >( pDataWin
)->bCallingDropCallback
)
136 return static_cast< BrowserDataWin
* >( pDataWin
)->IsDropFormatSupported( _rFlavor
);
138 return DropTargetHelper::IsDropFormatSupported( _rFlavor
);
141 //===================================================================
143 sal_Bool
BrowseBox::IsDropFormatSupported( const DataFlavor
& _rFlavor
) const
145 return const_cast< BrowseBox
* >( this )->IsDropFormatSupported( _rFlavor
);
148 //===================================================================
150 void BrowseBox::Command( const CommandEvent
& rEvt
)
152 if ( !getDataWindow()->bInCommand
)
153 Control::Command( rEvt
);
156 //===================================================================
158 bool BrowseBox::IsInCommandEvent() const
160 return getDataWindow()->bInCommand
;
163 //===================================================================
165 void BrowseBox::StateChanged( StateChangedType nStateChange
)
167 Control::StateChanged( nStateChange
);
169 if ( STATE_CHANGE_MIRRORING
== nStateChange
)
171 getDataWindow()->EnableRTL( IsRTLEnabled() );
173 HeaderBar
* pHeaderBar
= getDataWindow()->pHeaderBar
;
175 pHeaderBar
->EnableRTL( IsRTLEnabled() );
176 aHScroll
.EnableRTL( IsRTLEnabled() );
178 pVScroll
->EnableRTL( IsRTLEnabled() );
181 else if ( STATE_CHANGE_INITSHOW
== nStateChange
)
183 bBootstrapped
= TRUE
; // muss zuerst gesetzt werden!
186 if ( bMultiSelection
)
187 uRow
.pSel
->SetTotalRange( Range( 0, nRowCount
- 1 ) );
188 if ( nRowCount
== 0 )
189 nCurRow
= BROWSER_ENDOFSELECTION
;
190 else if ( nCurRow
== BROWSER_ENDOFSELECTION
)
196 bSelectionIsVisible
= TRUE
;
200 AutoSizeLastColumn();
203 else if (STATE_CHANGE_ZOOM
== nStateChange
)
205 pDataWin
->SetZoom(GetZoom());
206 HeaderBar
* pHeaderBar
= getDataWindow()->pHeaderBar
;
208 pHeaderBar
->SetZoom(GetZoom());
210 // let the cols calc their new widths and adjust the header bar
211 for ( USHORT nPos
= 0; nPos
< pCols
->Count(); ++nPos
)
213 pCols
->GetObject(nPos
)->ZoomChanged(GetZoom());
215 pHeaderBar
->SetItemSize( pCols
->GetObject(nPos
)->GetId(), pCols
->GetObject(nPos
)->Width() );
218 // all our controls have to be repositioned
221 else if (STATE_CHANGE_ENABLE
== nStateChange
)
223 // do we have a handle column?
224 sal_Bool bHandleCol
= pCols
->Count() && (0 == pCols
->GetObject(0)->GetId());
225 // do we have a header bar
226 sal_Bool bHeaderBar
= (NULL
!= static_cast<BrowserDataWin
&>(GetDataWindow()).pHeaderBar
);
233 // we draw the text in our header bar in a color dependent on the enabled state. So if this state changed
235 Invalidate(Rectangle(Point(0, 0), Size(GetOutputSizePixel().Width(), GetTitleHeight() - 1)));
239 //===================================================================
241 void BrowseBox::Select()
243 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
246 //-------------------------------------------------------------------
248 void BrowseBox::DoubleClick( const BrowserMouseEvent
& )
250 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
253 //-------------------------------------------------------------------
255 long BrowseBox::QueryMinimumRowHeight()
257 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
258 return CalcZoom( 5 );
261 //-------------------------------------------------------------------
263 void BrowseBox::ImplStartTracking()
265 DBG_CHKTHIS( BrowseBox
, BrowseBoxCheckInvariants
);
268 //-------------------------------------------------------------------
270 void BrowseBox::ImplTracking()
272 DBG_CHKTHIS( BrowseBox
, BrowseBoxCheckInvariants
);
275 //-------------------------------------------------------------------
277 void BrowseBox::ImplEndTracking()
279 DBG_CHKTHIS( BrowseBox
, BrowseBoxCheckInvariants
);
282 //-------------------------------------------------------------------
284 void BrowseBox::RowHeightChanged()
286 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
289 //-------------------------------------------------------------------
291 long BrowseBox::QueryColumnResize( USHORT
, long nWidth
)
293 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
297 //-------------------------------------------------------------------
299 void BrowseBox::ColumnResized( USHORT
)
301 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
304 //-------------------------------------------------------------------
306 void BrowseBox::ColumnMoved( USHORT
)
308 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
311 //-------------------------------------------------------------------
313 void BrowseBox::StartScroll()
315 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
316 //((Control*)pDataWin)->HideFocus();
317 DoHideCursor( "StartScroll" );
320 //-------------------------------------------------------------------
322 void BrowseBox::EndScroll()
324 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
326 AutoSizeLastColumn();
327 DoShowCursor( "EndScroll" );
330 //-------------------------------------------------------------------
333 #pragma optimize( "", off )
336 void BrowseBox::ToggleSelection( BOOL bForce
)
338 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
340 // selection highlight-toggling allowed?
344 ( bNotToggleSel
|| !IsUpdateMode() || !bSelectionIsVisible
) )
347 // if ( !getDataWindow()->bHighlightToggle &&
348 // !getDataWindow()->bHighlightAuto )
351 // only highlight painted areas!
352 bNotToggleSel
= TRUE
;
353 if ( FALSE
&& !getDataWindow()->bInPaint
)
356 // accumulate areas of rows to highlight
357 RectangleList aHighlightList
;
358 long nLastRowInRect
= 0; // fuer den CFront
360 // Handle-Column nicht highlighten
361 BrowserColumn
*pFirstCol
= pCols
->GetObject(0);
362 long nOfsX
= (!pFirstCol
|| pFirstCol
->GetId()) ? 0 : pFirstCol
->Width();
364 // accumulate old row selection
365 long nBottomRow
= nTopRow
+
366 pDataWin
->GetOutputSizePixel().Height() / GetDataRowHeight();
367 if ( nBottomRow
> GetRowCount() && GetRowCount() )
368 nBottomRow
= GetRowCount();
369 for ( long nRow
= bMultiSelection
? uRow
.pSel
->FirstSelected() : uRow
.nSel
;
370 nRow
!= BROWSER_ENDOFSELECTION
&& nRow
<= nBottomRow
;
371 nRow
= bMultiSelection
? uRow
.pSel
->NextSelected() : BROWSER_ENDOFSELECTION
)
373 if ( nRow
< nTopRow
)
377 Point( nOfsX
, (nRow
-nTopRow
)*GetDataRowHeight() ),
378 Size( pDataWin
->GetSizePixel().Width(), GetDataRowHeight() ) );
379 if ( aHighlightList
.Count() && nLastRowInRect
== ( nRow
- 1 ) )
380 aHighlightList
.First()->Union( aAddRect
);
382 aHighlightList
.Insert( new Rectangle( aAddRect
), (ULONG
) 0 );
383 nLastRowInRect
= nRow
;
386 // unhighlight the old selection (if any)
387 while ( aHighlightList
.Count() )
389 Rectangle
*pRect
= aHighlightList
.Remove( aHighlightList
.Count() - 1 );
390 pDataWin
->Invalidate( *pRect
);
394 // unhighlight old column selection (if any)
395 for ( long nColId
= pColSel
? pColSel
->FirstSelected() : BROWSER_ENDOFSELECTION
;
396 nColId
!= BROWSER_ENDOFSELECTION
;
397 nColId
= pColSel
->NextSelected() )
399 Rectangle
aRect( GetFieldRectPixel(nCurRow
,
400 pCols
->GetObject(nColId
)->GetId(),
402 aRect
.Left() -= MIN_COLUMNWIDTH
;
403 aRect
.Right() += MIN_COLUMNWIDTH
;
405 aRect
.Bottom() = pDataWin
->GetOutputSizePixel().Height();
406 pDataWin
->Invalidate( aRect
);
409 bNotToggleSel
= FALSE
;
413 #pragma optimize( "", on )
416 //-------------------------------------------------------------------
418 void BrowseBox::DrawCursor()
420 BOOL bReallyHide
= FALSE
;
421 if ( SMART_CURSOR_HIDE
== bHideCursor
)
423 if ( !GetSelectRowCount() && !GetSelectColumnCount() )
426 else if ( HARD_CURSOR_HIDE
== bHideCursor
)
431 bReallyHide
|= !bSelectionIsVisible
|| !IsUpdateMode() || bScrolling
|| nCurRow
< 0;
433 if (PaintCursorIfHiddenOnce())
434 bReallyHide
|= ( GetCursorHideCount() > 1 );
436 bReallyHide
|= ( GetCursorHideCount() > 0 );
438 // keine Cursor auf Handle-Column
439 if ( nCurColId
== 0 )
440 nCurColId
= GetColumnId(1);
442 // Cursor-Rechteck berechnen
446 aCursor
= GetFieldRectPixel( nCurRow
, nCurColId
, FALSE
);
447 //! --aCursor.Bottom();
448 aCursor
.Left() -= MIN_COLUMNWIDTH
;
449 aCursor
.Right() += 1;
450 aCursor
.Bottom() += 1;
454 Point( ( pCols
->Count() && pCols
->GetObject(0)->GetId() == 0 ) ?
455 pCols
->GetObject(0)->Width() : 0,
456 (nCurRow
- nTopRow
) * GetDataRowHeight() + 1 ),
457 Size( pDataWin
->GetOutputSizePixel().Width() + 1,
458 GetDataRowHeight() - 2 ) );
461 if ( !bMultiSelection
)
466 //!mi_mac pDataWin->Update();
468 if (m_aCursorColor
== COL_TRANSPARENT
)
470 // auf diesem Plattformen funktioniert der StarView-Focus richtig
472 ((Control
*)pDataWin
)->HideFocus();
474 ((Control
*)pDataWin
)->ShowFocus( aCursor
);
478 Color rCol
= bReallyHide
? pDataWin
->GetFillColor() : m_aCursorColor
;
479 Color aOldFillColor
= pDataWin
->GetFillColor();
480 Color aOldLineColor
= pDataWin
->GetLineColor();
481 pDataWin
->SetFillColor();
482 pDataWin
->SetLineColor( rCol
);
483 pDataWin
->DrawRect( aCursor
);
484 pDataWin
->SetLineColor( aOldLineColor
);
485 pDataWin
->SetFillColor( aOldFillColor
);
489 //-------------------------------------------------------------------
491 ULONG
BrowseBox::GetColumnWidth( USHORT nId
) const
493 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
495 USHORT nItemPos
= GetColumnPos( nId
);
496 if ( nItemPos
>= pCols
->Count() )
498 return pCols
->GetObject(nItemPos
)->Width();
501 //-------------------------------------------------------------------
503 USHORT
BrowseBox::GetColumnId( USHORT nPos
) const
505 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
507 if ( nPos
>= pCols
->Count() )
509 return pCols
->GetObject(nPos
)->GetId();
512 //-------------------------------------------------------------------
514 USHORT
BrowseBox::GetColumnPos( USHORT nId
) const
516 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
518 for ( USHORT nPos
= 0; nPos
< pCols
->Count(); ++nPos
)
519 if ( pCols
->GetObject(nPos
)->GetId() == nId
)
521 return BROWSER_INVALIDID
;
524 //-------------------------------------------------------------------
526 BOOL
BrowseBox::IsFrozen( USHORT nColumnId
) const
528 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
530 for ( USHORT nPos
= 0; nPos
< pCols
->Count(); ++nPos
)
531 if ( pCols
->GetObject(nPos
)->GetId() == nColumnId
)
532 return pCols
->GetObject(nPos
)->IsFrozen();
536 //-------------------------------------------------------------------
538 void BrowseBox::ExpandRowSelection( const BrowserMouseEvent
& rEvt
)
540 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
542 DoHideCursor( "ExpandRowSelection" );
544 // expand the last selection
545 if ( bMultiSelection
)
547 Range
aJustifiedRange( aSelRange
);
548 aJustifiedRange
.Justify();
550 BOOL bSelectThis
= ( bSelect
!= aJustifiedRange
.IsInside( rEvt
.GetRow() ) );
552 if ( aJustifiedRange
.IsInside( rEvt
.GetRow() ) )
555 while ( rEvt
.GetRow() < aSelRange
.Max() )
556 { // ZTC/Mac bug - dont put these statemants together!
557 SelectRow( aSelRange
.Max(), bSelectThis
, TRUE
);
560 while ( rEvt
.GetRow() > aSelRange
.Max() )
561 { // ZTC/Mac bug - dont put these statemants together!
562 SelectRow( aSelRange
.Max(), bSelectThis
, TRUE
);
569 BOOL bOldSelecting
= bSelecting
;
571 while ( rEvt
.GetRow() < aSelRange
.Max() )
572 { // ZTC/Mac bug - dont put these statemants together!
574 if ( !IsRowSelected( aSelRange
.Max() ) )
576 SelectRow( aSelRange
.Max(), bSelectThis
, TRUE
);
580 while ( rEvt
.GetRow() > aSelRange
.Max() )
581 { // ZTC/Mac bug - dont put these statemants together!
583 if ( !IsRowSelected( aSelRange
.Max() ) )
585 SelectRow( aSelRange
.Max(), bSelectThis
, TRUE
);
589 bSelecting
= bOldSelecting
;
595 if ( !bMultiSelection
|| !IsRowSelected( rEvt
.GetRow() ) )
596 SelectRow( rEvt
.GetRow(), TRUE
);
598 GoToRow( rEvt
.GetRow(), FALSE
);
599 DoShowCursor( "ExpandRowSelection" );
602 //-------------------------------------------------------------------
604 void BrowseBox::Resize()
606 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
607 if ( !bBootstrapped
&& IsReallyVisible() )
608 BrowseBox::StateChanged( STATE_CHANGE_INITSHOW
);
609 if ( !pCols
->Count() )
611 getDataWindow()->bResizeOnPaint
= TRUE
;
614 getDataWindow()->bResizeOnPaint
= FALSE
;
616 // calc the size of the scrollbars
617 // (we can't ask the scrollbars for their widths cause if we're zoomed they still have to be
618 // resized - which is done in UpdateScrollbars)
619 ULONG nSBSize
= GetSettings().GetStyleSettings().GetScrollBarSize();
621 nSBSize
= (ULONG
)(nSBSize
* (double)GetZoom());
623 long nSize
= pDataWin
->GetPosPixel().Y();
624 if( !getDataWindow()->bNoHScroll
)
625 nSize
+= aHScroll
.GetSizePixel().Height();
627 if ( GetOutputSizePixel().Height() < nSize
)
630 DoHideCursor( "Resize" );
631 USHORT nOldVisibleRows
=
632 (USHORT
)(pDataWin
->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
634 // did we need a horiz. scroll bar oder gibt es eine Control Area?
635 if ( !getDataWindow()->bNoHScroll
&&
636 ( ( pCols
->Count() - FrozenColCount() ) > 1 ) )
641 // calculate the size of the data window
642 long nDataHeight
= GetOutputSizePixel().Height() - GetTitleHeight();
643 if ( aHScroll
.IsVisible() || ( nControlAreaWidth
!= USHRT_MAX
) )
644 nDataHeight
-= nSBSize
;
646 long nDataWidth
= GetOutputSizePixel().Width();
647 if ( pVScroll
->IsVisible() )
648 nDataWidth
-= nSBSize
;
650 // adjust position and size of data window
651 pDataWin
->SetPosSizePixel(
652 Point( 0, GetTitleHeight() ),
653 Size( nDataWidth
, nDataHeight
) );
655 USHORT nVisibleRows
=
656 (USHORT
)(pDataWin
->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
658 // TopRow ist unveraendert, aber die Anzahl sichtbarer Zeilen hat sich
660 if ( nVisibleRows
!= nOldVisibleRows
)
661 VisibleRowsChanged(nTopRow
, nVisibleRows
);
666 Rectangle
aInvalidArea( GetControlArea() );
667 aInvalidArea
.Right() = GetOutputSizePixel().Width();
668 aInvalidArea
.Left() = 0;
669 Invalidate( aInvalidArea
);
671 // external header-bar
672 HeaderBar
* pHeaderBar
= getDataWindow()->pHeaderBar
;
675 // Handle-Column beruecksichtigen
676 BrowserColumn
*pFirstCol
= pCols
->GetObject(0);
677 long nOfsX
= pFirstCol
->GetId() ? 0 : pFirstCol
->Width();
678 pHeaderBar
->SetPosSizePixel( Point( nOfsX
, 0 ), Size( GetOutputSizePixel().Width() - nOfsX
, GetTitleHeight() ) );
681 AutoSizeLastColumn(); // adjust last column width
682 DoShowCursor( "Resize" );
685 //-------------------------------------------------------------------
687 void BrowseBox::Paint( const Rectangle
& rRect
)
689 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
692 if ( !bBootstrapped
&& IsReallyVisible() )
693 BrowseBox::StateChanged( STATE_CHANGE_INITSHOW
);
694 if ( !pCols
->Count() )
697 BrowserColumn
*pFirstCol
= pCols
->GetObject(0);
698 BOOL bHandleCol
= pFirstCol
&& pFirstCol
->GetId() == 0;
699 BOOL bHeaderBar
= getDataWindow()->pHeaderBar
!= NULL
;
701 // draw delimitational lines
702 if ( !getDataWindow()->bNoHScroll
)
703 DrawLine( Point( 0, aHScroll
.GetPosPixel().Y() ),
704 Point( GetOutputSizePixel().Width(),
705 aHScroll
.GetPosPixel().Y() ) );
710 DrawLine( Point( 0, GetTitleHeight() - 1 ),
711 Point( GetOutputSizePixel().Width(),
712 GetTitleHeight() - 1 ) );
713 else if ( bHandleCol
)
714 DrawLine( Point( 0, GetTitleHeight() - 1 ),
715 Point( pFirstCol
->Width(), GetTitleHeight() - 1 ) );
719 // Wenn es eine Handle Column gibt und die Headerbar verfuegbar ist, dann nur
721 // Handle-Column beruecksichtigen
722 if ( nTitleLines
&& (!bHeaderBar
|| bHandleCol
) )
724 // iterate through columns to redraw
728 nCol
< pCols
->Count() && nX
< rRect
.Right();
731 // skip invisible colums between frozen and scrollable area
732 if ( nCol
< nFirstCol
&& !pCols
->GetObject(nCol
)->IsFrozen() )
735 // nur die HandleCol ?
736 if (bHeaderBar
&& bHandleCol
&& nCol
> 0)
739 BrowserColumn
*pCol
= pCols
->GetObject(nCol
);
741 // draw the column and increment position
742 if ( pCol
->Width() > 4 )
744 ButtonFrame
aButtonFrame( Point( nX
, 0 ),
745 Size( pCol
->Width()-1, GetTitleHeight()-1 ),
746 pCol
->Title(), FALSE
, FALSE
,
747 0 != (BROWSER_COLUMN_TITLEABBREVATION
&pCol
->Flags()),
749 aButtonFrame
.Draw( *this );
750 DrawLine( Point( nX
+ pCol
->Width() - 1, 0 ),
751 Point( nX
+ pCol
->Width() - 1, GetTitleHeight()-1 ) );
755 Color aOldFillColor
= GetFillColor();
756 SetFillColor( Color( COL_BLACK
) );
757 DrawRect( Rectangle( Point( nX
, 0 ), Size( pCol
->Width(), GetTitleHeight() - 1 ) ) );
758 SetFillColor( aOldFillColor
);
766 if ( !bHeaderBar
&& nCol
== pCols
->Count() )
768 const StyleSettings
&rSettings
= GetSettings().GetStyleSettings();
769 Color
aColFace( rSettings
.GetFaceColor() );
770 Color aOldFillColor
= GetFillColor();
771 Color aOldLineColor
= GetLineColor();
772 SetFillColor( aColFace
);
773 SetLineColor( aColFace
);
776 Point( rRect
.Right(), GetTitleHeight() - 2 ) ) );
777 SetFillColor( aOldFillColor
); // aOldLineColor ); oj 09.02.00 seems to be a copy&paste bug
778 SetLineColor( aOldLineColor
); // aOldFillColor );
783 //-------------------------------------------------------------------
785 void BrowseBox::PaintRow( OutputDevice
&, const Rectangle
& )
789 //-------------------------------------------------------------------
791 void BrowseBox::Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, ULONG nFlags
)
793 BOOL bDrawSelection
= (nFlags
& WINDOW_DRAW_NOSELECTION
) == 0;
795 // we need pixel coordinates
796 Size aRealSize
= pDev
->LogicToPixel(rSize
);
797 Point aRealPos
= pDev
->LogicToPixel(rPos
);
799 if ((rSize
.Width() < 3) || (rSize
.Height() < 3))
800 // we want to have two pixels frame ...
803 Font aFont
= GetDataWindow().GetDrawPixelFont( pDev
);
804 // the 'normal' painting uses always the data window as device to output to, so we have to calc the new font
805 // relative to the data wins current settings
809 pDev
->SetFont( aFont
);
812 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
813 pDev
->SetLineColor(rStyleSettings
.GetDarkShadowColor());
814 pDev
->DrawLine(Point(aRealPos
.X(), aRealPos
.Y()),
815 Point(aRealPos
.X(), aRealPos
.Y() + aRealSize
.Height() - 1));
816 pDev
->DrawLine(Point(aRealPos
.X(), aRealPos
.Y()),
817 Point(aRealPos
.X() + aRealSize
.Width() - 1, aRealPos
.Y()));
818 pDev
->SetLineColor(rStyleSettings
.GetShadowColor());
819 pDev
->DrawLine(Point(aRealPos
.X() + aRealSize
.Width() - 1, aRealPos
.Y() + 1),
820 Point(aRealPos
.X() + aRealSize
.Width() - 1, aRealPos
.Y() + aRealSize
.Height() - 1));
821 pDev
->DrawLine(Point(aRealPos
.X() + aRealSize
.Width() - 1, aRealPos
.Y() + aRealSize
.Height() - 1),
822 Point(aRealPos
.X() + 1, aRealPos
.Y() + aRealSize
.Height() - 1));
824 HeaderBar
* pBar
= getDataWindow()->pHeaderBar
;
826 // we're drawing onto a foreign device, so we have to fake the DataRowHeight for the subsequent ImplPaintData
827 // (as it is based on the settings of our data window, not the foreign device)
829 ImpGetDataRowHeight();
830 long nHeightLogic
= PixelToLogic(Size(0, nDataRowHeight
), MAP_10TH_MM
).Height();
831 long nForeignHeightPixel
= pDev
->LogicToPixel(Size(0, nHeightLogic
), MAP_10TH_MM
).Height();
833 long nOriginalHeight
= nDataRowHeight
;
834 nDataRowHeight
= nForeignHeightPixel
;
836 // this counts for the column widths, too
838 for ( nPos
= 0; nPos
< pCols
->Count(); ++nPos
)
840 BrowserColumn
* pCurrent
= pCols
->GetObject(nPos
);
842 long nWidthLogic
= PixelToLogic(Size(pCurrent
->Width(), 0), MAP_10TH_MM
).Width();
843 long nForeignWidthPixel
= pDev
->LogicToPixel(Size(nWidthLogic
, 0), MAP_10TH_MM
).Width();
845 pCurrent
->SetWidth(nForeignWidthPixel
, GetZoom());
847 pBar
->SetItemSize( pCurrent
->GetId(), pCurrent
->Width() );
850 // a smaller area for the content
853 aRealSize
.Width() -= 2;
854 aRealSize
.Height() -= 2;
856 // let the header bar draw itself
859 // the title height with respect to the font set for the given device
860 long nTitleHeight
= PixelToLogic(Size(0, GetTitleHeight()), MAP_10TH_MM
).Height();
861 nTitleHeight
= pDev
->LogicToPixel(Size(0, nTitleHeight
), MAP_10TH_MM
).Height();
863 BrowserColumn
* pFirstCol
= pCols
->Count() ? pCols
->GetObject(0) : NULL
;
865 Point
aHeaderPos(pFirstCol
&& (pFirstCol
->GetId() == 0) ? pFirstCol
->Width() : 0, 0);
866 Size
aHeaderSize(aRealSize
.Width() - aHeaderPos
.X(), nTitleHeight
);
868 aHeaderPos
+= aRealPos
;
869 // do this before converting to logics !
871 // the header's draw expects logic coordinates, again
872 aHeaderPos
= pDev
->PixelToLogic(aHeaderPos
);
873 aHeaderSize
= pDev
->PixelToLogic(aHeaderSize
);
875 pBar
->Draw(pDev
, aHeaderPos
, aHeaderSize
, nFlags
);
877 // draw the "upper left cell" (the intersection between the header bar and the handle column)
878 if (( pFirstCol
->GetId() == 0 ) && ( pFirstCol
->Width() > 4 ))
880 ButtonFrame
aButtonFrame( aRealPos
,
881 Size( pFirstCol
->Width()-1, nTitleHeight
-1 ),
882 pFirstCol
->Title(), FALSE
, FALSE
, FALSE
, !IsEnabled());
883 aButtonFrame
.Draw( *pDev
);
885 pDev
->Push( PUSH_LINECOLOR
);
886 pDev
->SetLineColor( Color( COL_BLACK
) );
888 pDev
->DrawLine( Point( aRealPos
.X(), aRealPos
.Y() + nTitleHeight
-1 ),
889 Point( aRealPos
.X() + pFirstCol
->Width() - 1, aRealPos
.Y() + nTitleHeight
-1 ) );
890 pDev
->DrawLine( Point( aRealPos
.X() + pFirstCol
->Width() - 1, aRealPos
.Y() ),
891 Point( aRealPos
.X() + pFirstCol
->Width() - 1, aRealPos
.Y() + nTitleHeight
-1 ) );
896 aRealPos
.Y() += aHeaderSize
.Height();
897 aRealSize
.Height() -= aHeaderSize
.Height();
900 // draw our own content (with clipping)
901 Region
aRegion(Rectangle(aRealPos
, aRealSize
));
902 pDev
->SetClipRegion( pDev
->PixelToLogic( aRegion
) );
904 // do we have to paint the background
905 BOOL bBackground
= !(nFlags
& WINDOW_DRAW_NOBACKGROUND
) && GetDataWindow().IsControlBackground();
908 Rectangle
aRect( aRealPos
, aRealSize
);
909 pDev
->SetFillColor( GetDataWindow().GetControlBackground() );
910 pDev
->DrawRect( aRect
);
913 ImplPaintData( *pDev
, Rectangle( aRealPos
, aRealSize
), TRUE
, bDrawSelection
);
915 // restore the column widths/data row height
916 nDataRowHeight
= nOriginalHeight
;
917 for ( nPos
= 0; nPos
< pCols
->Count(); ++nPos
)
919 BrowserColumn
* pCurrent
= pCols
->GetObject(nPos
);
921 long nForeignWidthLogic
= pDev
->PixelToLogic(Size(pCurrent
->Width(), 0), MAP_10TH_MM
).Width();
922 long nWidthPixel
= LogicToPixel(Size(nForeignWidthLogic
, 0), MAP_10TH_MM
).Width();
924 pCurrent
->SetWidth(nWidthPixel
, GetZoom());
926 pBar
->SetItemSize( pCurrent
->GetId(), pCurrent
->Width() );
932 //-------------------------------------------------------------------
934 void BrowseBox::ImplPaintData(OutputDevice
& _rOut
, const Rectangle
& _rRect
, BOOL _bForeignDevice
, BOOL _bDrawSelections
)
936 Point aOverallAreaPos
= _bForeignDevice
? _rRect
.TopLeft() : Point(0,0);
937 Size aOverallAreaSize
= _bForeignDevice
? _rRect
.GetSize() : GetDataWindow().GetOutputSizePixel();
938 Point aOverallAreaBRPos
= _bForeignDevice
? _rRect
.BottomRight() : Point( aOverallAreaSize
.Width(), aOverallAreaSize
.Height() );
940 long nDataRowHeigt
= GetDataRowHeight();
942 // compute relative rows to redraw
943 ULONG nRelTopRow
= _bForeignDevice
? 0 : ((ULONG
)_rRect
.Top() / nDataRowHeigt
);
944 ULONG nRelBottomRow
= (ULONG
)(_bForeignDevice
? aOverallAreaSize
.Height() : _rRect
.Bottom()) / nDataRowHeigt
;
946 // cache frequently used values
947 Point
aPos( aOverallAreaPos
.X(), nRelTopRow
* nDataRowHeigt
+ aOverallAreaPos
.Y() );
948 _rOut
.SetLineColor( Color( COL_WHITE
) );
949 const AllSettings
& rAllSets
= _rOut
.GetSettings();
950 const StyleSettings
&rSettings
= rAllSets
.GetStyleSettings();
951 const Color
&rHighlightTextColor
= rSettings
.GetHighlightTextColor();
952 const Color
&rHighlightFillColor
= rSettings
.GetHighlightColor();
953 Color aOldTextColor
= _rOut
.GetTextColor();
954 Color aOldFillColor
= _rOut
.GetFillColor();
955 Color aOldLineColor
= _rOut
.GetLineColor();
956 long nHLineX
= 0 == pCols
->GetObject(0)->GetId()
957 ? pCols
->GetObject(0)->Width()
959 nHLineX
+= aOverallAreaPos
.X();
961 Color
aDelimiterLineColor( ::svtools::ColorConfig().GetColorValue( ::svtools::CALCGRID
).nColor
);
963 // redraw the invalid fields
964 BOOL bRetouching
= FALSE
;
965 for ( ULONG nRelRow
= nRelTopRow
;
966 nRelRow
<= nRelBottomRow
&& (ULONG
)nTopRow
+nRelRow
< (ULONG
)nRowCount
;
967 ++nRelRow
, aPos
.Y() += nDataRowHeigt
)
970 // Zur Sicherheit auf zul"assigen Bereich abfragen:
971 DBG_ASSERT( (USHORT
)(nTopRow
+nRelRow
) < nRowCount
, "BrowseBox::ImplPaintData: invalid seek" );
972 if ( (nTopRow
+long(nRelRow
)) < 0 || (USHORT
)(nTopRow
+nRelRow
) >= nRowCount
)
976 ULONG nRow
= nTopRow
+nRelRow
;
977 if ( !SeekRow( nRow
) ) {
978 DBG_ERROR("BrowseBox::ImplPaintData: SeekRow gescheitert");
980 _rOut
.SetClipRegion();
981 aPos
.X() = aOverallAreaPos
.X();
984 // #73325# don't paint the row outside the painting rectangle (DG)
985 // prepare auto-highlight
986 Rectangle
aRowRect( Point( _rRect
.TopLeft().X(), aPos
.Y() ),
987 Size( _rRect
.GetSize().Width(), nDataRowHeigt
) );
988 PaintRow( _rOut
, aRowRect
);
990 BOOL bRowAutoHighlight
= _bDrawSelections
992 && ((BrowserDataWin
&)GetDataWindow()).bHighlightAuto
993 && IsRowSelected( nRow
);
994 if ( bRowAutoHighlight
)
996 _rOut
.SetTextColor( rHighlightTextColor
);
997 _rOut
.SetFillColor( rHighlightFillColor
);
998 _rOut
.SetLineColor();
999 _rOut
.DrawRect( aRowRect
);
1002 // iterate through columns to redraw
1004 for ( nCol
= 0; nCol
< pCols
->Count(); ++nCol
)
1007 BrowserColumn
*pCol
= pCols
->GetObject(nCol
);
1009 // at end of invalid area
1010 if ( aPos
.X() >= _rRect
.Right() )
1013 // skip invisible colums between frozen and scrollable area
1014 if ( nCol
< nFirstCol
&& !pCol
->IsFrozen() )
1017 pCol
= pCols
->GetObject(nCol
);
1019 { // FS - 21.05.99 - 66325
1020 // ist zwar eigentlich woanders (an der richtigen Stelle) gefixt, aber sicher ist sicher ...
1021 DBG_ERROR("BrowseBox::PaintData : nFirstCol is probably invalid !");
1026 // prepare Column-AutoHighlight
1027 BOOL bColAutoHighlight
= _bDrawSelections
1029 && IsColumnSelected( pCol
->GetId() );
1030 if ( bColAutoHighlight
)
1032 _rOut
.SetClipRegion();
1033 _rOut
.SetTextColor( rHighlightTextColor
);
1034 _rOut
.SetFillColor( rHighlightFillColor
);
1035 _rOut
.SetLineColor();
1036 Rectangle
aFieldRect( aPos
,
1037 Size( pCol
->Width(), nDataRowHeigt
) );
1038 _rOut
.DrawRect( aFieldRect
);
1041 if (!m_bFocusOnlyCursor
&& (pCol
->GetId() == GetCurColumnId()) && (nRow
== (ULONG
)GetCurRow()))
1044 // draw a single field
1045 // #63864#, Sonst wird auch etwas gezeichnet, bsp Handle Column
1048 // clip the column's output to the field area
1049 if (_bForeignDevice
)
1050 { // (not neccessary if painting onto the data window)
1051 Size
aFieldSize(pCol
->Width(), nDataRowHeigt
);
1053 if (aPos
.X() + aFieldSize
.Width() > aOverallAreaBRPos
.X())
1054 aFieldSize
.Width() = aOverallAreaBRPos
.X() - aPos
.X();
1056 if (aPos
.Y() + aFieldSize
.Height() > aOverallAreaBRPos
.Y() + 1)
1058 // for non-handle cols we don't clip vertically : we just don't draw the cell if the line isn't completely visible
1059 if (pCol
->GetId() != 0)
1061 aFieldSize
.Height() = aOverallAreaBRPos
.Y() + 1 - aPos
.Y();
1064 Region
aClipToField(Rectangle(aPos
, aFieldSize
));
1065 _rOut
.SetClipRegion(aClipToField
);
1067 pCol
->Draw( *this, _rOut
, aPos
, FALSE
);
1068 if (_bForeignDevice
)
1069 _rOut
.SetClipRegion();
1072 // reset Column-auto-highlight
1073 if ( bColAutoHighlight
)
1075 _rOut
.SetTextColor( aOldTextColor
);
1076 _rOut
.SetFillColor( aOldFillColor
);
1077 _rOut
.SetLineColor( aOldLineColor
);
1081 aPos
.X() += pCol
->Width();
1084 if ( nCol
== pCols
->Count() )
1087 // reset auto-highlight
1088 if ( bRowAutoHighlight
)
1090 _rOut
.SetTextColor( aOldTextColor
);
1091 _rOut
.SetFillColor( aOldFillColor
);
1092 _rOut
.SetLineColor( aOldLineColor
);
1097 // draw horizontal delimitation lines
1098 _rOut
.SetClipRegion();
1099 _rOut
.Push( PUSH_LINECOLOR
);
1100 _rOut
.SetLineColor( aDelimiterLineColor
);
1101 long nY
= aPos
.Y() + nDataRowHeigt
- 1;
1102 if (nY
<= aOverallAreaBRPos
.Y())
1103 _rOut
.DrawLine( Point( nHLineX
, nY
),
1105 ? std::min(long(long(aPos
.X()) - 1), aOverallAreaBRPos
.X())
1106 : aOverallAreaBRPos
.X(),
1112 if (aPos
.Y() > aOverallAreaBRPos
.Y() + 1)
1113 aPos
.Y() = aOverallAreaBRPos
.Y() + 1;
1114 // needed for some of the following drawing
1117 _rOut
.SetClipRegion();
1118 aOldLineColor
= _rOut
.GetLineColor();
1119 aOldFillColor
= _rOut
.GetFillColor();
1120 _rOut
.SetFillColor( rSettings
.GetFaceColor() );
1121 if ( pCols
->Count() && ( pCols
->GetObject(0)->GetId() == 0 ) && ( aPos
.Y() <= _rRect
.Bottom() ) )
1123 // fill rectangle gray below handle column
1124 // DG: fill it only until the end of the drawing rect and not to the end, as this may overpaint handle columns
1125 _rOut
.SetLineColor( Color( COL_BLACK
) );
1126 _rOut
.DrawRect( Rectangle(
1127 Point( aOverallAreaPos
.X() - 1, aPos
.Y() - 1 ),
1128 Point( aOverallAreaPos
.X() + pCols
->GetObject(0)->Width() - 1,
1129 _rRect
.Bottom() + 1) ) );
1131 _rOut
.SetFillColor( aOldFillColor
);
1133 // draw vertical delimitational line between frozen and scrollable cols
1134 _rOut
.SetLineColor( COL_BLACK
);
1135 long nFrozenWidth
= GetFrozenWidth()-1;
1136 _rOut
.DrawLine( Point( aOverallAreaPos
.X() + nFrozenWidth
, aPos
.Y() ),
1137 Point( aOverallAreaPos
.X() + nFrozenWidth
, bHLines
1139 : aOverallAreaBRPos
.Y() ) );
1141 // draw vertical delimitational lines?
1144 _rOut
.SetLineColor( aDelimiterLineColor
);
1145 Point
aVertPos( aOverallAreaPos
.X() - 1, aOverallAreaPos
.Y() );
1146 long nDeltaY
= aOverallAreaBRPos
.Y();
1147 for ( USHORT nCol
= 0; nCol
< pCols
->Count(); ++nCol
)
1150 BrowserColumn
*pCol
= pCols
->GetObject(nCol
);
1152 // skip invisible colums between frozen and scrollable area
1153 if ( nCol
< nFirstCol
&& !pCol
->IsFrozen() )
1156 pCol
= pCols
->GetObject(nCol
);
1160 aVertPos
.X() += pCol
->Width();
1162 // at end of invalid area
1163 // invalid area is first reached when X > Right
1165 if ( aVertPos
.X() > _rRect
.Right() )
1168 // draw a single line
1169 if ( pCol
->GetId() != 0 )
1170 _rOut
.DrawLine( aVertPos
, Point( aVertPos
.X(),
1173 : aPos
.Y() + nDeltaY
) );
1177 _rOut
.SetLineColor( aOldLineColor
);
1180 //-------------------------------------------------------------------
1182 void BrowseBox::PaintData( Window
& rWin
, const Rectangle
& rRect
)
1184 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1185 if ( !bBootstrapped
&& IsReallyVisible() )
1186 BrowseBox::StateChanged( STATE_CHANGE_INITSHOW
);
1189 if ( !pCols
|| !pCols
->Count() || !rWin
.IsUpdateMode() )
1191 if ( getDataWindow()->bResizeOnPaint
)
1193 // MI: wer war das denn? Window::Update();
1195 ImplPaintData(rWin
, rRect
, FALSE
, TRUE
);
1198 //-------------------------------------------------------------------
1200 void BrowseBox::UpdateScrollbars()
1202 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1204 if ( !bBootstrapped
|| !IsUpdateMode() )
1208 BrowserDataWin
*pBDW
= (BrowserDataWin
*) pDataWin
;
1209 if ( pBDW
->bInUpdateScrollbars
)
1211 pBDW
->bHadRecursion
= TRUE
;
1214 pBDW
->bInUpdateScrollbars
= TRUE
;
1216 // the size of the corner window (and the width of the VSB/height of the HSB)
1217 ULONG nCornerSize
= GetSettings().GetStyleSettings().GetScrollBarSize();
1219 nCornerSize
= (ULONG
)(nCornerSize
* (double)GetZoom());
1222 long nMaxRows
= (pDataWin
->GetSizePixel().Height()) / GetDataRowHeight();
1223 BOOL bNeedsVScroll
= getDataWindow()->bAutoVScroll
1224 ? nTopRow
|| ( nRowCount
> nMaxRows
)
1225 : !getDataWindow()->bNoVScroll
;
1226 Size aDataWinSize
= pDataWin
->GetSizePixel();
1227 if ( !bNeedsVScroll
)
1229 if ( pVScroll
->IsVisible() )
1232 Size
aNewSize( aDataWinSize
);
1233 aNewSize
.Width() = GetOutputSizePixel().Width();
1234 aDataWinSize
= aNewSize
;
1237 else if ( !pVScroll
->IsVisible() )
1239 Size
aNewSize( aDataWinSize
);
1240 aNewSize
.Width() = GetOutputSizePixel().Width() - nCornerSize
;
1241 aDataWinSize
= aNewSize
;
1245 ULONG nLastCol
= GetColumnAtXPosPixel( aDataWinSize
.Width() - 1 );
1247 USHORT nFrozenCols
= FrozenColCount();
1248 BOOL bNeedsHScroll
= getDataWindow()->bAutoHScroll
1249 ? ( nFirstCol
> nFrozenCols
) || ( nLastCol
<= pCols
->Count() )
1250 : !getDataWindow()->bNoHScroll
;
1251 if ( !bNeedsHScroll
)
1253 if ( aHScroll
.IsVisible() )
1257 aDataWinSize
.Height() = GetOutputSizePixel().Height() - GetTitleHeight();
1258 if ( nControlAreaWidth
!= USHRT_MAX
)
1259 aDataWinSize
.Height() -= nCornerSize
;
1261 else if ( !aHScroll
.IsVisible() )
1263 Size
aNewSize( aDataWinSize
);
1264 aNewSize
.Height() = GetOutputSizePixel().Height() - GetTitleHeight() - nCornerSize
;
1265 aDataWinSize
= aNewSize
;
1268 // adjust position and Width of horizontal scrollbar
1269 ULONG nHScrX
= nControlAreaWidth
== USHRT_MAX
1271 : nControlAreaWidth
;
1273 aHScroll
.SetPosSizePixel(
1274 Point( nHScrX
, GetOutputSizePixel().Height() - nCornerSize
),
1275 Size( aDataWinSize
.Width() - nHScrX
, nCornerSize
) );
1277 // Scrollable Columns insgesamt
1278 short nScrollCols
= short(pCols
->Count()) - (short)nFrozenCols
;
1279 /*short nVisibleHSize= std::max(nLastCol == BROWSER_INVALIDID
1280 ? pCols->Count() - nFirstCol -1
1281 : nLastCol - nFirstCol - 1, 0);
1283 aHScroll.SetVisibleSize( nVisibleHSize );
1284 aHScroll.SetRange( Range( 0, Max( std::min(nScrollCols, nVisibleHSize), (short)0 ) ) );
1285 if ( bNeedsHScroll && !aHScroll.IsVisible() )
1288 // Sichtbare Columns
1289 short nVisibleHSize
= nLastCol
== BROWSER_INVALIDID
1290 ? (short)( pCols
->Count() - nFirstCol
)
1291 : (short)( nLastCol
- nFirstCol
);
1293 short nRange
= Max( nScrollCols
, (short)0 );
1294 aHScroll
.SetVisibleSize( nVisibleHSize
);
1295 aHScroll
.SetRange( Range( 0, nRange
));
1296 if ( bNeedsHScroll
&& !aHScroll
.IsVisible() )
1299 // adjust position and height of vertical scrollbar
1300 pVScroll
->SetPageSize( nMaxRows
);
1302 if ( nTopRow
> nRowCount
)
1304 nTopRow
= nRowCount
- 1;
1305 DBG_ERROR("BrowseBox: nTopRow > nRowCount");
1308 if ( pVScroll
->GetThumbPos() != nTopRow
)
1309 pVScroll
->SetThumbPos( nTopRow
);
1310 long nVisibleSize
= Min( Min( nRowCount
, nMaxRows
), long(nRowCount
-nTopRow
) );
1311 pVScroll
->SetVisibleSize( nVisibleSize
? nVisibleSize
: 1 );
1312 pVScroll
->SetRange( Range( 0, nRowCount
) );
1313 pVScroll
->SetPosSizePixel(
1314 Point( aDataWinSize
.Width(), GetTitleHeight() ),
1315 Size( nCornerSize
, aDataWinSize
.Height()) );
1317 long( aDataWinSize
.Height() / GetDataRowHeight() ) )
1318 ScrollRows( -nTopRow
);
1319 if ( bNeedsVScroll
&& !pVScroll
->IsVisible() )
1322 pDataWin
->SetPosSizePixel(
1323 Point( 0, GetTitleHeight() ),
1326 // needs corner-window?
1327 // (do that AFTER positioning BOTH scrollbars)
1328 ULONG nActualCorderWidth
= 0;
1329 if (aHScroll
.IsVisible() && pVScroll
&& pVScroll
->IsVisible() )
1331 // if we have both scrollbars, the corner window fills the point of intersection of these two
1332 nActualCorderWidth
= nCornerSize
;
1334 else if ( !aHScroll
.IsVisible() && ( nControlAreaWidth
!= USHRT_MAX
) )
1336 // if we have no horizontal scrollbar, but a control area, we need the corner window to
1337 // fill the space between the control are and the right border
1338 nActualCorderWidth
= GetOutputSizePixel().Width() - nControlAreaWidth
;
1340 if ( nActualCorderWidth
)
1342 if ( !getDataWindow()->pCornerWin
)
1343 getDataWindow()->pCornerWin
= new ScrollBarBox( this, 0 );
1344 getDataWindow()->pCornerWin
->SetPosSizePixel(
1345 Point( GetOutputSizePixel().Width() - nActualCorderWidth
, aHScroll
.GetPosPixel().Y() ),
1346 Size( nActualCorderWidth
, nCornerSize
) );
1347 getDataWindow()->pCornerWin
->Show();
1350 DELETEZ( getDataWindow()->pCornerWin
);
1352 // ggf. Headerbar mitscrollen
1353 if ( getDataWindow()->pHeaderBar
)
1356 for ( USHORT nCol
= 0;
1357 nCol
< pCols
->Count() && nCol
< nFirstCol
;
1360 // HandleColumn nicht
1361 if ( pCols
->GetObject(nCol
)->GetId() )
1362 nWidth
+= pCols
->GetObject(nCol
)->Width();
1365 getDataWindow()->pHeaderBar
->SetOffset( nWidth
);
1368 pBDW
->bInUpdateScrollbars
= FALSE
;
1369 if ( pBDW
->bHadRecursion
)
1371 pBDW
->bHadRecursion
= FALSE
;
1376 //-------------------------------------------------------------------
1378 void BrowseBox::SetUpdateMode( BOOL bUpdate
)
1380 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1382 BOOL bWasUpdate
= IsUpdateMode();
1383 if ( bWasUpdate
== bUpdate
)
1386 Control::SetUpdateMode( bUpdate
);
1388 // Wenn an der BrowseBox WB_CLIPCHILDREN gesetzt ist (wg. Flackerminimierung),
1389 // wird das Datenfenster nicht von SetUpdateMode invalidiert.
1391 getDataWindow()->Invalidate();
1392 getDataWindow()->SetUpdateMode( bUpdate
);
1397 if ( bBootstrapped
)
1400 AutoSizeLastColumn();
1402 DoShowCursor( "SetUpdateMode" );
1405 DoHideCursor( "SetUpdateMode" );
1408 //-------------------------------------------------------------------
1410 BOOL
BrowseBox::GetUpdateMode() const
1412 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1414 return getDataWindow()->IsUpdateMode();
1417 //-------------------------------------------------------------------
1419 long BrowseBox::GetFrozenWidth() const
1421 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1424 for ( USHORT nCol
= 0;
1425 nCol
< pCols
->Count() && pCols
->GetObject(nCol
)->IsFrozen();
1427 nWidth
+= pCols
->GetObject(nCol
)->Width();
1431 //-------------------------------------------------------------------
1433 void BrowseBox::ColumnInserted( USHORT nPos
)
1435 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1438 pColSel
->Insert( nPos
);
1442 //-------------------------------------------------------------------
1444 USHORT
BrowseBox::FrozenColCount() const
1446 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1449 nCol
< pCols
->Count() && pCols
->GetObject(nCol
)->IsFrozen();
1455 //-------------------------------------------------------------------
1457 IMPL_LINK(BrowseBox
,ScrollHdl
,ScrollBar
*,pBar
)
1459 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1461 if ( pBar
->GetDelta() == 0 )
1464 if ( pBar
->GetDelta() < 0 && getDataWindow()->bNoScrollBack
)
1470 if ( pBar
== &aHScroll
)
1471 ScrollColumns( aHScroll
.GetDelta() );
1472 if ( pBar
== pVScroll
)
1473 ScrollRows( pVScroll
->GetDelta() );
1478 //-------------------------------------------------------------------
1480 IMPL_LINK( BrowseBox
,EndScrollHdl
,ScrollBar
*, EMPTYARG
)
1482 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1484 // kein Focus grabben!
1487 if ( /*pBar->GetDelta() <= 0 &&*/ getDataWindow()->bNoScrollBack
)
1489 // UpdateScrollbars();
1497 //-------------------------------------------------------------------
1499 IMPL_LINK( BrowseBox
, StartDragHdl
, HeaderBar
*, pBar
)
1501 pBar
->SetDragSize( pDataWin
->GetOutputSizePixel().Height() );
1505 //-------------------------------------------------------------------
1506 // MI: es wurde immer nur die 1. Spalte resized
1508 #pragma optimize("",off)
1511 void BrowseBox::MouseButtonDown( const MouseEvent
& rEvt
)
1513 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1517 // onl< mouse events in the title-line are supported
1518 const Point
&rEvtPos
= rEvt
.GetPosPixel();
1519 if ( rEvtPos
.Y() >= GetTitleHeight() )
1523 long nWidth
= GetOutputSizePixel().Width();
1524 for ( USHORT nCol
= 0; nCol
< pCols
->Count() && nX
< nWidth
; ++nCol
)
1526 // is this column visible?
1527 BrowserColumn
*pCol
= pCols
->GetObject(nCol
);
1528 if ( pCol
->IsFrozen() || nCol
>= nFirstCol
)
1530 // compute right end of column
1531 long nR
= nX
+ pCol
->Width() - 1;
1533 // at the end of a column (and not handle column)?
1534 if ( pCol
->GetId() && Abs( nR
- rEvtPos
.X() ) < 2 )
1536 // start resizing the column
1539 nDragX
= nResizeX
= rEvtPos
.X();
1540 SetPointer( Pointer( POINTER_HSPLIT
) );
1542 pDataWin
->DrawLine( Point( nDragX
, 0 ),
1543 Point( nDragX
, pDataWin
->GetSizePixel().Height() ) );
1544 nMinResizeX
= nX
+ MIN_COLUMNWIDTH
;
1547 else if ( nX
< rEvtPos
.X() && nR
> rEvtPos
.X() )
1549 MouseButtonDown( BrowserMouseEvent(
1550 this, rEvt
, -1, nCol
, pCol
->GetId(), Rectangle() ) );
1557 // event occured out of data area
1558 if ( rEvt
.IsRight() )
1560 CommandEvent( Point( 1, LONG_MAX
), COMMAND_CONTEXTMENU
, TRUE
) );
1566 #pragma optimize("",on)
1569 //-------------------------------------------------------------------
1571 void BrowseBox::MouseMove( const MouseEvent
& rEvt
)
1573 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1574 DBG_TRACE( "BrowseBox::MouseMove( MouseEvent )" );
1576 Pointer aNewPointer
;
1579 for ( USHORT nCol
= 0;
1580 nCol
< USHORT(pCols
->Count()) &&
1581 ( nX
+ pCols
->GetObject(nCol
)->Width() ) < USHORT(GetOutputSizePixel().Width());
1583 // is this column visible?
1584 if ( pCols
->GetObject(nCol
)->IsFrozen() || nCol
>= nFirstCol
)
1586 // compute right end of column
1587 BrowserColumn
*pCol
= pCols
->GetObject(nCol
);
1588 USHORT nR
= (USHORT
)(nX
+ pCol
->Width() - 1);
1590 // show resize-pointer?
1591 if ( bResizing
|| ( pCol
->GetId() &&
1592 Abs( ((long) nR
) - rEvt
.GetPosPixel().X() ) < MIN_COLUMNWIDTH
) )
1594 aNewPointer
= Pointer( POINTER_HSPLIT
);
1597 // alte Hilfslinie loeschen
1598 pDataWin
->HideTracking() ;
1600 // erlaubte breite abholen und neues Delta
1601 nDragX
= Max( rEvt
.GetPosPixel().X(), nMinResizeX
);
1602 long nDeltaX
= nDragX
- nResizeX
;
1603 USHORT nId
= GetColumnId(nResizeCol
);
1604 ULONG nOldWidth
= GetColumnWidth(nId
);
1605 nDragX
= QueryColumnResize( GetColumnId(nResizeCol
),
1606 nOldWidth
+ nDeltaX
)
1607 + nResizeX
- nOldWidth
;
1609 // neue Hilfslinie zeichnen
1610 pDataWin
->ShowTracking( Rectangle( Point( nDragX
, 0 ),
1611 Size( 1, pDataWin
->GetSizePixel().Height() ) ),
1612 SHOWTRACK_SPLIT
|SHOWTRACK_WINDOW
);
1620 SetPointer( aNewPointer
);
1623 //-------------------------------------------------------------------
1625 void BrowseBox::MouseButtonUp( const MouseEvent
& rEvt
)
1627 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1631 // Hilfslinie loeschen
1632 pDataWin
->HideTracking();
1635 nDragX
= Max( rEvt
.GetPosPixel().X(), nMinResizeX
);
1636 if ( (nDragX
- nResizeX
) != (long)pCols
->GetObject(nResizeCol
)->Width() )
1639 long nMaxX
= pDataWin
->GetSizePixel().Width();
1640 nDragX
= Min( nDragX
, nMaxX
);
1641 long nDeltaX
= nDragX
- nResizeX
;
1642 USHORT nId
= GetColumnId(nResizeCol
);
1643 SetColumnWidth( GetColumnId(nResizeCol
), GetColumnWidth(nId
) + nDeltaX
);
1644 ColumnResized( nId
);
1648 SetPointer( Pointer() );
1653 MouseButtonUp( BrowserMouseEvent( (BrowserDataWin
*)pDataWin
,
1654 MouseEvent( Point( rEvt
.GetPosPixel().X(),
1655 rEvt
.GetPosPixel().Y() - pDataWin
->GetPosPixel().Y() ),
1656 rEvt
.GetClicks(), rEvt
.GetMode(), rEvt
.GetButtons(),
1657 rEvt
.GetModifier() ) ) );
1660 //-------------------------------------------------------------------
1662 BOOL bExtendedMode
= FALSE
;
1663 BOOL bFieldMode
= FALSE
;
1665 void BrowseBox::MouseButtonDown( const BrowserMouseEvent
& rEvt
)
1667 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1671 // adjust selection while and after double-click
1672 if ( rEvt
.GetClicks() == 2 )
1675 if ( rEvt
.GetRow() >= 0 )
1677 GoToRow( rEvt
.GetRow() );
1678 SelectRow( rEvt
.GetRow(), TRUE
, FALSE
);
1682 if ( bColumnCursor
&& rEvt
.GetColumn() != 0 )
1684 if ( rEvt
.GetColumn() < pCols
->Count() )
1685 SelectColumnPos( rEvt
.GetColumn(), TRUE
, FALSE
);
1688 DoubleClick( rEvt
);
1691 else if ( ( rEvt
.GetMode() & ( MOUSE_SELECT
| MOUSE_SIMPLECLICK
) ) &&
1692 ( bColumnCursor
|| rEvt
.GetRow() >= 0 ) )
1694 if ( rEvt
.GetClicks() == 1 )
1699 a2ndPoint
= PixelToLogic( rEvt
.GetPosPixel() );
1701 // selection out of range?
1702 if ( rEvt
.GetRow() >= nRowCount
||
1703 rEvt
.GetColumnId() == BROWSER_INVALIDID
)
1709 // while selecting, no cursor
1711 DoHideCursor( "MouseButtonDown" );
1714 if ( rEvt
.GetRow() >= 0 )
1717 if ( rEvt
.GetColumnId() == 0 || !bColumnCursor
)
1719 if ( bMultiSelection
)
1721 // remove column-selection, if exists
1722 if ( pColSel
&& pColSel
->GetSelectCount() )
1725 if ( bMultiSelection
)
1726 uRow
.pSel
->SelectAll(FALSE
);
1728 uRow
.nSel
= BROWSER_ENDOFSELECTION
;
1730 pColSel
->SelectAll(FALSE
);
1735 if ( rEvt
.GetMode() & MOUSE_RANGESELECT
)
1737 // select the further touched rows too
1739 ExpandRowSelection( rEvt
);
1743 // click in the selected area?
1744 else if ( IsRowSelected( rEvt
.GetRow() ) )
1746 // auf Drag&Drop warten
1748 bExtendedMode
= MOUSE_MULTISELECT
==
1749 ( rEvt
.GetMode() & MOUSE_MULTISELECT
);
1754 else if ( rEvt
.GetMode() & MOUSE_MULTISELECT
)
1756 // determine the new selection range
1757 // and selection/deselection
1758 aSelRange
= Range( rEvt
.GetRow(), rEvt
.GetRow() );
1759 SelectRow( rEvt
.GetRow(),
1760 !uRow
.pSel
->IsSelected( rEvt
.GetRow() ) );
1768 GoToRow( rEvt
.GetRow() );
1769 SelectRow( rEvt
.GetRow(), TRUE
);
1770 aSelRange
= Range( rEvt
.GetRow(), rEvt
.GetRow() );
1773 else // Column/Field-Selection
1775 // click in selected column
1776 if ( IsColumnSelected( rEvt
.GetColumn() ) ||
1777 IsRowSelected( rEvt
.GetRow() ) )
1785 GoToRowColumnId( rEvt
.GetRow(), rEvt
.GetColumnId() );
1791 if ( bMultiSelection
&& rEvt
.GetColumnId() == 0 )
1793 // toggle all-selection
1794 if ( uRow
.pSel
->GetSelectCount() > ( GetRowCount() / 2 ) )
1800 SelectColumnId( rEvt
.GetColumnId(), TRUE
, FALSE
);
1803 // ggf. Cursor wieder an
1805 DoShowCursor( "MouseButtonDown" );
1812 //-------------------------------------------------------------------
1814 void BrowseBox::MouseMove( const BrowserMouseEvent
& )
1816 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1819 //-------------------------------------------------------------------
1821 void BrowseBox::MouseButtonUp( const BrowserMouseEvent
&rEvt
)
1823 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1825 // D&D was possible, but did not occur
1828 aSelRange
= Range( rEvt
.GetRow(), rEvt
.GetRow() );
1829 if ( bExtendedMode
)
1830 SelectRow( rEvt
.GetRow(), FALSE
);
1835 GoToRowColumnId( rEvt
.GetRow(), rEvt
.GetColumnId() );
1838 GoToRow( rEvt
.GetRow() );
1839 SelectRow( rEvt
.GetRow(), TRUE
);
1843 bExtendedMode
= FALSE
;
1852 DoShowCursor( "MouseButtonUp" );
1858 //-------------------------------------------------------------------
1860 void BrowseBox::KeyInput( const KeyEvent
& rEvt
)
1862 if ( !ProcessKey( rEvt
) )
1863 Control::KeyInput( rEvt
);
1866 //-------------------------------------------------------------------
1868 BOOL
BrowseBox::ProcessKey( const KeyEvent
& rEvt
)
1870 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1872 USHORT nCode
= rEvt
.GetKeyCode().GetCode();
1873 BOOL bShift
= rEvt
.GetKeyCode().IsShift();
1874 BOOL bCtrl
= rEvt
.GetKeyCode().IsMod1();
1875 BOOL bAlt
= rEvt
.GetKeyCode().IsMod2();
1877 USHORT nId
= BROWSER_NONE
;
1879 if ( !bAlt
&& !bCtrl
&& !bShift
)
1883 case KEY_DOWN
: nId
= BROWSER_CURSORDOWN
; break;
1884 case KEY_UP
: nId
= BROWSER_CURSORUP
; break;
1885 case KEY_HOME
: nId
= BROWSER_CURSORHOME
; break;
1886 case KEY_END
: nId
= BROWSER_CURSOREND
; break;
1888 if ( !bColumnCursor
)
1890 case KEY_RIGHT
: nId
= BROWSER_CURSORRIGHT
; break;
1891 case KEY_LEFT
: nId
= BROWSER_CURSORLEFT
; break;
1892 case KEY_SPACE
: nId
= BROWSER_SELECT
; break;
1894 if ( BROWSER_NONE
!= nId
)
1899 case KEY_PAGEDOWN
: nId
= BROWSER_CURSORPAGEDOWN
; break;
1900 case KEY_PAGEUP
: nId
= BROWSER_CURSORPAGEUP
; break;
1904 if ( !bAlt
&& !bCtrl
&& bShift
)
1907 case KEY_DOWN
: nId
= BROWSER_SELECTDOWN
; break;
1908 case KEY_UP
: nId
= BROWSER_SELECTUP
; break;
1910 if ( !bColumnCursor
)
1912 nId
= BROWSER_CURSORLEFT
; break;
1913 case KEY_HOME
: nId
= BROWSER_SELECTHOME
; break;
1914 case KEY_END
: nId
= BROWSER_SELECTEND
; break;
1918 if ( !bAlt
&& bCtrl
&& !bShift
)
1921 case KEY_DOWN
: nId
= BROWSER_CURSORDOWN
; break;
1922 case KEY_UP
: nId
= BROWSER_CURSORUP
; break;
1923 case KEY_PAGEDOWN
: nId
= BROWSER_CURSORENDOFFILE
; break;
1924 case KEY_PAGEUP
: nId
= BROWSER_CURSORTOPOFFILE
; break;
1925 case KEY_HOME
: nId
= BROWSER_CURSORTOPOFSCREEN
; break;
1926 case KEY_END
: nId
= BROWSER_CURSORENDOFSCREEN
; break;
1927 case KEY_SPACE
: nId
= BROWSER_ENHANCESELECTION
; break;
1928 case KEY_LEFT
: nId
= BROWSER_MOVECOLUMNLEFT
; break;
1929 case KEY_RIGHT
: nId
= BROWSER_MOVECOLUMNRIGHT
; break;
1932 if ( nId
!= BROWSER_NONE
)
1934 return nId
!= BROWSER_NONE
;
1937 //-------------------------------------------------------------------
1939 void BrowseBox::Dispatch( USHORT nId
)
1941 DBG_CHKTHIS(BrowseBox
,BrowseBoxCheckInvariants
);
1943 long nRowsOnPage
= pDataWin
->GetSizePixel().Height() / GetDataRowHeight();
1948 case BROWSER_SELECTCOLUMN
:
1950 SelectColumnId( GetCurColumnId() );
1953 case BROWSER_CURSORDOWN
:
1954 if ( ( GetCurRow() + 1 ) < nRowCount
)
1955 bDone
= GoToRow( GetCurRow() + 1, FALSE
);
1957 case BROWSER_CURSORUP
:
1958 if ( GetCurRow() > 0 )
1959 bDone
= GoToRow( GetCurRow() - 1, FALSE
);
1961 case BROWSER_SELECTHOME
:
1962 if ( GetRowCount() )
1964 DoHideCursor( "BROWSER_SELECTHOME" );
1965 for ( long nRow
= GetCurRow(); nRow
>= 0; --nRow
)
1968 DoShowCursor( "BROWSER_SELECTHOME" );
1971 case BROWSER_SELECTEND
:
1972 if ( GetRowCount() )
1974 DoHideCursor( "BROWSER_SELECTEND" );
1975 long nRows
= GetRowCount();
1976 for ( long nRow
= GetCurRow(); nRow
< nRows
; ++nRow
)
1978 GoToRow( GetRowCount() - 1, TRUE
);
1979 DoShowCursor( "BROWSER_SELECTEND" );
1982 case BROWSER_SELECTDOWN
:
1984 if ( GetRowCount() && ( GetCurRow() + 1 ) < nRowCount
)
1986 // deselect the current row, if it isn't the first
1987 // and there is no other selected row above
1988 long nRow
= GetCurRow();
1989 BOOL bLocalSelect
= ( !IsRowSelected( nRow
) ||
1990 GetSelectRowCount() == 1 || IsRowSelected( nRow
- 1 ) );
1991 SelectRow( nRow
, bLocalSelect
, TRUE
);
1992 bDone
= GoToRow( GetCurRow() + 1 , FALSE
);
1994 SelectRow( GetCurRow(), TRUE
, TRUE
);
1997 bDone
= ScrollRows( 1 ) != 0;
2000 case BROWSER_SELECTUP
:
2001 if ( GetRowCount() )
2003 // deselect the current row, if it isn't the first
2004 // and there is no other selected row under
2005 long nRow
= GetCurRow();
2006 BOOL bLocalSelect
= ( !IsRowSelected( nRow
) ||
2007 GetSelectRowCount() == 1 || IsRowSelected( nRow
+ 1 ) );
2008 SelectRow( nCurRow
, bLocalSelect
, TRUE
);
2009 bDone
= GoToRow( nRow
- 1 , FALSE
);
2011 SelectRow( GetCurRow(), TRUE
, TRUE
);
2014 case BROWSER_CURSORPAGEDOWN
:
2015 bDone
= (BOOL
)ScrollRows( nRowsOnPage
);
2017 case BROWSER_CURSORPAGEUP
:
2018 bDone
= (BOOL
)ScrollRows( -nRowsOnPage
);
2020 case BROWSER_CURSOREND
:
2021 if ( bColumnCursor
)
2023 USHORT nNewId
= GetColumnId(ColCount() -1);
2024 bDone
= (nNewId
!= 0) && GoToColumnId( nNewId
);
2027 case BROWSER_CURSORENDOFFILE
:
2028 bDone
= GoToRow( nRowCount
- 1, FALSE
);
2030 case BROWSER_CURSORRIGHT
:
2031 if ( bColumnCursor
)
2033 USHORT nNewPos
= GetColumnPos( GetCurColumnId() ) + 1;
2034 USHORT nNewId
= GetColumnId( nNewPos
);
2035 if (nNewId
!= 0) // Am Zeilenende ?
2036 bDone
= GoToColumnId( nNewId
);
2039 USHORT nColId
= ( GetColumnId(0) == 0 ) ? GetColumnId(1) : GetColumnId(0);
2040 if ( GetRowCount() )
2041 bDone
= ( nCurRow
< GetRowCount() - 1 ) && GoToRowColumnId( nCurRow
+ 1, nColId
);
2042 else if ( ColCount() )
2043 GoToColumnId( nColId
);
2047 bDone
= ScrollColumns( 1 ) != 0;
2049 case BROWSER_CURSORHOME
:
2050 if ( bColumnCursor
)
2052 USHORT nNewId
= GetColumnId(1);
2053 bDone
= (nNewId
!= 0) && GoToColumnId( nNewId
);
2056 case BROWSER_CURSORTOPOFFILE
:
2057 bDone
= GoToRow( 0, FALSE
);
2059 case BROWSER_CURSORLEFT
:
2060 if ( bColumnCursor
)
2062 USHORT nNewPos
= GetColumnPos( GetCurColumnId() ) - 1;
2063 USHORT nNewId
= GetColumnId( nNewPos
);
2065 bDone
= GoToColumnId( nNewId
);
2068 if ( GetRowCount() )
2069 bDone
= (nCurRow
> 0) && GoToRowColumnId(nCurRow
- 1, GetColumnId(ColCount() -1));
2070 else if ( ColCount() )
2071 GoToColumnId( GetColumnId(ColCount() -1) );
2075 bDone
= ScrollColumns( -1 ) != 0;
2077 case BROWSER_ENHANCESELECTION
:
2078 if ( GetRowCount() )
2079 SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), TRUE
);
2082 case BROWSER_SELECT
:
2083 if ( GetRowCount() )
2084 SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), FALSE
);
2087 case BROWSER_MOVECOLUMNLEFT
:
2088 case BROWSER_MOVECOLUMNRIGHT
:
2089 { // check if column moving is allowed
2090 BrowserHeader
* pHeaderBar
= getDataWindow()->pHeaderBar
;
2091 if ( pHeaderBar
&& pHeaderBar
->IsDragable() )
2093 USHORT nColId
= GetCurColumnId();
2094 BOOL bColumnSelected
= IsColumnSelected(nColId
);
2095 USHORT nNewPos
= GetColumnPos(nColId
);
2096 BOOL bMoveAllowed
= FALSE
;
2097 if ( BROWSER_MOVECOLUMNLEFT
== nId
&& nNewPos
> 1 )
2098 --nNewPos
,bMoveAllowed
= TRUE
;
2099 else if ( BROWSER_MOVECOLUMNRIGHT
== nId
&& nNewPos
< (ColCount()-1) )
2100 ++nNewPos
,bMoveAllowed
= TRUE
;
2104 SetColumnPos( nColId
, nNewPos
);
2105 ColumnMoved( nColId
);
2106 MakeFieldVisible(GetCurRow(),nColId
,TRUE
);
2107 if ( bColumnSelected
)
2108 SelectColumnId(nColId
);
2118 //-------------------------------------------------------------------
2120 void BrowseBox::SetCursorColor(const Color
& _rCol
)
2122 if (_rCol
== m_aCursorColor
)
2125 // ensure the cursor is hidden
2126 DoHideCursor("SetCursorColor");
2127 if (!m_bFocusOnlyCursor
)
2128 DoHideCursor("SetCursorColor - force");
2130 m_aCursorColor
= _rCol
;
2132 if (!m_bFocusOnlyCursor
)
2133 DoShowCursor("SetCursorColor - force");
2134 DoShowCursor("SetCursorColor");
2136 // -----------------------------------------------------------------------------
2137 Rectangle
BrowseBox::calcHeaderRect(sal_Bool _bIsColumnBar
,BOOL _bOnScreen
)
2139 Window
* pParent
= NULL
;
2141 pParent
= GetAccessibleParentWindow();
2146 if ( _bIsColumnBar
)
2148 nWidth
= GetDataWindow().GetOutputSizePixel().Width();
2149 nHeight
= GetDataRowHeight();
2153 aTopLeft
.Y() = GetDataRowHeight();
2154 nWidth
= GetColumnWidth(0);
2155 nHeight
= GetWindowExtentsRelative( pParent
).GetHeight() - aTopLeft
.Y() - GetControlArea().GetSize().B();
2157 aTopLeft
+= GetWindowExtentsRelative( pParent
).TopLeft();
2158 return Rectangle(aTopLeft
,Size(nWidth
,nHeight
));
2160 // -----------------------------------------------------------------------------
2161 Rectangle
BrowseBox::calcTableRect(BOOL _bOnScreen
)
2163 Window
* pParent
= NULL
;
2165 pParent
= GetAccessibleParentWindow();
2167 Rectangle
aRect( GetWindowExtentsRelative( pParent
) );
2168 Rectangle aRowBar
= calcHeaderRect(FALSE
,pParent
== NULL
);
2170 long nX
= aRowBar
.Right() - aRect
.Left();
2171 long nY
= aRowBar
.Top() - aRect
.Top();
2172 Size
aSize(aRect
.GetSize());
2174 return Rectangle(aRowBar
.TopRight(), Size(aSize
.A() - nX
, aSize
.B() - nY
- aHScroll
.GetSizePixel().Height()) );
2176 // -----------------------------------------------------------------------------
2177 Rectangle
BrowseBox::GetFieldRectPixelAbs( sal_Int32 _nRowId
,sal_uInt16 _nColId
, BOOL
/*_bIsHeader*/, BOOL _bOnScreen
)
2179 Window
* pParent
= NULL
;
2181 pParent
= GetAccessibleParentWindow();
2183 Rectangle aRect
= GetFieldRectPixel(_nRowId
,_nColId
,_bOnScreen
);
2185 Point aTopLeft
= aRect
.TopLeft();
2186 aTopLeft
+= GetWindowExtentsRelative( pParent
).TopLeft();
2188 return Rectangle(aTopLeft
,aRect
.GetSize());
2191 // ------------------------------------------------------------------------- EOF