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: hdrcont.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_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <sfx2/dispatch.hxx>
39 #include <vcl/help.hxx>
40 #include <tools/poly.hxx>
41 #include <svtools/colorcfg.hxx>
43 #include "scresid.hxx"
45 #include "tabvwsh.hxx"
46 #include "hdrcont.hxx"
47 #include "scmod.hxx" // Optionen
48 #include "inputopt.hxx" // Optionen
49 #include "gridmerg.hxx"
51 // -----------------------------------------------------------------------
56 // (selection left/right must be first because the continuous lines
57 // are partly overwritten later)
59 #define SC_HDRPAINT_SEL_RIGHT 0
60 #define SC_HDRPAINT_SEL_LEFT 1
61 #define SC_HDRPAINT_TOP 2
62 #define SC_HDRPAINT_SEL_TOP 3
63 #define SC_HDRPAINT_SEL_BOTTOM 4
64 #define SC_HDRPAINT_BOTTOM 5
65 #define SC_HDRPAINT_TEXT 6
66 #define SC_HDRPAINT_COUNT 7
68 //==================================================================
70 ScHeaderControl::ScHeaderControl( Window
* pParent
, SelectionEngine
* pSelectionEngine
,
71 SCCOLROW nNewSize
, USHORT nNewFlags
) :
73 pSelEngine ( pSelectionEngine
),
75 bVertical ( (nNewFlags
& HDR_VERTICAL
) != 0 ),
83 // --- RTL --- no default mirroring for this window, the spreadsheet itself
84 // is also not mirrored
85 // #107811# mirror the vertical window for correct border drawing
86 // #106948# table layout depends on sheet format, not UI setting, so the
87 // borders of the vertical window have to be handled manually, too.
90 aNormFont
= GetFont();
91 aNormFont
.SetTransparent( TRUE
); //! WEIGHT_NORMAL hart setzen ???
92 aBoldFont
= aNormFont
;
93 aBoldFont
.SetWeight( WEIGHT_BOLD
);
98 Size aSize
= LogicToPixel( Size(
99 GetTextWidth( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("8888")) ),
101 aSize
.Width() += 4; // Platz fuer hervorgehobene Umrandung
103 SetSizePixel( aSize
);
105 nWidth
= nSmallWidth
= aSize
.Width();
106 nBigWidth
= LogicToPixel( Size( GetTextWidth(
107 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("8888888")) ), 0 ) ).Width() + 5;
109 SetBackground(); // sonst Probleme auf OS/2 !?!?!
112 void ScHeaderControl::SetWidth( long nNew
)
114 DBG_ASSERT( bVertical
, "SetDigits nur fuer Zeilenkoepfe erlaubt" );
115 if ( nNew
!= nWidth
)
117 Size
aSize( nNew
, GetSizePixel().Height() ); // Hoehe nicht aendern
118 SetSizePixel( aSize
);
122 Invalidate(); // neu zentrieren
126 __EXPORT
ScHeaderControl::~ScHeaderControl()
130 void ScHeaderControl::DoPaint( SCCOLROW nStart
, SCCOLROW nEnd
)
132 BOOL bLayoutRTL
= IsLayoutRTL();
133 long nLayoutSign
= bLayoutRTL
? -1 : 1;
135 Rectangle
aRect( Point(0,0), GetOutputSizePixel() );
138 aRect
.Top() = GetScrPos( nStart
)-nLayoutSign
; // extra pixel for line at top of selection
139 aRect
.Bottom() = GetScrPos( nEnd
+1 )-nLayoutSign
;
143 aRect
.Left() = GetScrPos( nStart
)-nLayoutSign
; // extra pixel for line left of selection
144 aRect
.Right() = GetScrPos( nEnd
+1 )-nLayoutSign
;
149 void ScHeaderControl::SetMark( BOOL bNewSet
, SCCOLROW nNewStart
, SCCOLROW nNewEnd
)
151 BOOL bEnabled
= SC_MOD()->GetInputOptions().GetMarkHeader(); //! cachen?
157 BOOL bOldSet
= bMarkRange
;
158 SCCOLROW nOldStart
= nMarkStart
;
159 SCCOLROW nOldEnd
= nMarkEnd
;
160 PutInOrder( nNewStart
, nNewEnd
);
161 bMarkRange
= bNewSet
;
162 nMarkStart
= nNewStart
;
171 if ( nNewStart
== nOldStart
)
173 if ( nNewEnd
!= nOldEnd
)
174 DoPaint( Min( nNewEnd
, nOldEnd
) + 1, Max( nNewEnd
, nOldEnd
) );
177 else if ( nNewEnd
== nOldEnd
)
178 DoPaint( Min( nNewStart
, nOldStart
), Max( nNewStart
, nOldStart
) - 1 );
179 else if ( nNewStart
> nOldEnd
|| nNewEnd
< nOldStart
)
182 DoPaint( nOldStart
, nOldEnd
);
183 DoPaint( nNewStart
, nNewEnd
);
185 else // irgendwie ueberlappend... (kommt eh nicht oft vor)
186 DoPaint( Min( nNewStart
, nOldStart
), Max( nNewEnd
, nOldEnd
) );
189 DoPaint( nNewStart
, nNewEnd
); // komplett neu
192 DoPaint( nOldStart
, nOldEnd
); // komplett aufheben
194 // sonst war nix, is nix
197 long ScHeaderControl::GetScrPos( SCCOLROW nEntryNo
)
201 long nMax
= ( bVertical
? GetOutputSizePixel().Height() : GetOutputSizePixel().Width() ) + 1;
202 if (nEntryNo
>= nSize
)
207 for (SCCOLROW i
=GetPos(); i
<nEntryNo
&& nScrPos
<nMax
; i
++)
209 USHORT nAdd
= GetEntrySize(i
);
214 SCCOLROW nHidden
= GetHiddenCount(i
);
222 nScrPos
= nMax
- nScrPos
- 2;
227 // draw a rectangle across the window's width/height, with the outer part in a lighter color
229 void ScHeaderControl::DrawShadedRect( long nStart
, long nEnd
, const Color
& rBaseColor
)
231 Color
aWhite( COL_WHITE
);
233 Color
aInner( rBaseColor
); // highlight color, unchanged
234 Color
aCenter( rBaseColor
);
235 aCenter
.Merge( aWhite
, 0xd0 ); // lighten up a bit
236 Color
aOuter( rBaseColor
);
237 aOuter
.Merge( aWhite
, 0xa0 ); // lighten up more
240 std::swap( aInner
, aOuter
); // just swap colors instead of positions
242 Size aWinSize
= GetSizePixel();
243 long nBarSize
= bVertical
? aWinSize
.Width() : aWinSize
.Height();
244 long nCenterPos
= (nBarSize
/ 2) - 1;
247 SetFillColor( aOuter
);
249 DrawRect( Rectangle( 0, nStart
, nCenterPos
-1, nEnd
) );
251 DrawRect( Rectangle( nStart
, 0, nEnd
, nCenterPos
-1 ) );
252 SetFillColor( aCenter
);
254 DrawRect( Rectangle( nCenterPos
, nStart
, nCenterPos
, nEnd
) );
256 DrawRect( Rectangle( nStart
, nCenterPos
, nEnd
, nCenterPos
) );
257 SetFillColor( aInner
);
259 DrawRect( Rectangle( nCenterPos
+1, nStart
, nBarSize
-1, nEnd
) );
261 DrawRect( Rectangle( nStart
, nCenterPos
+1, nEnd
, nBarSize
-1 ) );
268 void __EXPORT
ScHeaderControl::Paint( const Rectangle
& rRect
)
270 // fuer VCL ist es wichtig, wenig Aufrufe zu haben, darum werden die aeusseren
271 // Linien zusammengefasst
273 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
274 BOOL bHighContrast
= rStyleSettings
.GetHighContrastMode();
275 BOOL bDark
= rStyleSettings
.GetFaceColor().IsDark();
276 // Use the same distinction for bDark as in Window::DrawSelectionBackground
278 Color aTextColor
= rStyleSettings
.GetButtonTextColor();
279 Color aSelTextColor
= rStyleSettings
.GetHighlightTextColor();
280 aNormFont
.SetColor( aTextColor
);
282 aBoldFont
.SetColor( aTextColor
);
284 aBoldFont
.SetColor( aSelTextColor
);
285 SetTextColor( ( bBoldSet
&& !bHighContrast
) ? aSelTextColor
: aTextColor
);
287 Color
aBlack( COL_BLACK
);
288 Color aSelLineColor
= rStyleSettings
.GetHighlightColor();
289 aSelLineColor
.Merge( aBlack
, 0xe0 ); // darken just a little bit
291 BOOL bLayoutRTL
= IsLayoutRTL();
292 long nLayoutSign
= bLayoutRTL
? -1 : 1;
293 BOOL bMirrored
= IsMirrored();
295 // const FunctionSet* pFuncSet = pSelEngine->GetFunctionSet();
300 // Size aSize = GetOutputSizePixel();
303 nBarSize
= (USHORT
) GetSizePixel().Width();
305 nBarSize
= (USHORT
) GetSizePixel().Height();
307 SCCOLROW nPos
= GetPos();
309 long nPStart
= bVertical
? rRect
.Top() : rRect
.Left();
310 long nPEnd
= bVertical
? rRect
.Bottom() : rRect
.Right();
312 long nTransStart
= nPEnd
+ 1;
315 long nInitScrPos
= 0;
318 long nTemp
= nPStart
; // swap nPStart / nPEnd
321 nTemp
= nTransStart
; // swap nTransStart / nTransEnd
322 nTransStart
= nTransEnd
;
324 if ( bVertical
) // start loops from the end
325 nInitScrPos
= GetSizePixel().Height() - 1;
327 nInitScrPos
= GetSizePixel().Width() - 1;
330 // aeussere Linien komplett durchzeichnen
331 // Zuerst Ende der letzten Zelle finden
333 // long nLineEnd = -1;
334 long nLineEnd
= nInitScrPos
- nLayoutSign
;
336 for (SCCOLROW i
=nPos
; i
<nSize
; i
++)
338 USHORT nSizePix
= GetEntrySize( i
);
341 nLineEnd
+= nSizePix
* nLayoutSign
;
343 if ( bMarkRange
&& i
>= nMarkStart
&& i
<= nMarkEnd
)
345 long nLineStart
= nLineEnd
- ( nSizePix
- 1 ) * nLayoutSign
;
346 if ( nLineStart
* nLayoutSign
< nTransStart
* nLayoutSign
)
347 nTransStart
= nLineStart
;
348 if ( nLineEnd
* nLayoutSign
> nTransEnd
* nLayoutSign
)
349 nTransEnd
= nLineEnd
;
352 if ( nLineEnd
* nLayoutSign
> nPEnd
* nLayoutSign
)
360 SCCOLROW nHidden
= GetHiddenCount(i
);
366 // background is different for entry area and behind the entries
371 if ( nLineEnd
* nLayoutSign
>= nInitScrPos
* nLayoutSign
)
375 // high contrast: single-color background
376 SetFillColor( rStyleSettings
.GetFaceColor() );
378 aFillRect
= Rectangle( 0, nInitScrPos
, nBarSize
-1, nLineEnd
);
380 aFillRect
= Rectangle( nInitScrPos
, 0, nLineEnd
, nBarSize
-1 );
381 DrawRect( aFillRect
);
385 // normal: 3-part background
386 DrawShadedRect( nInitScrPos
, nLineEnd
, rStyleSettings
.GetFaceColor() );
390 if ( nLineEnd
* nLayoutSign
< nPEnd
* nLayoutSign
)
392 SetFillColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::APPBACKGROUND
).nColor
);
394 aFillRect
= Rectangle( 0, nLineEnd
+nLayoutSign
, nBarSize
-1, nPEnd
);
396 aFillRect
= Rectangle( nLineEnd
+nLayoutSign
, 0, nPEnd
, nBarSize
-1 );
397 DrawRect( aFillRect
);
400 if ( nLineEnd
* nLayoutSign
>= nPStart
* nLayoutSign
)
402 if ( nTransEnd
* nLayoutSign
>= nTransStart
* nLayoutSign
)
408 // solid grey background for dark face color is drawn before lines
411 SetFillColor( COL_LIGHTGRAY
);
413 DrawRect( Rectangle( 0, nTransStart
, nBarSize
-1, nTransEnd
) );
415 DrawRect( Rectangle( nTransStart
, 0, nTransEnd
, nBarSize
-1 ) );
420 // background for selection
422 DrawShadedRect( nTransStart
, nTransEnd
, rStyleSettings
.GetHighlightColor() );
427 // 3D border is no longer used
428 SetLineColor( rStyleSettings
.GetLightColor() );
430 DrawLine( Point( 0, nPStart
), Point( 0, nLineEnd
) );
432 DrawLine( Point( nPStart
, 0 ), Point( nLineEnd
, 0 ) );
435 SetLineColor( rStyleSettings
.GetDarkShadowColor() );
438 long nDarkPos
= bMirrored
? 0 : nBarSize
-1;
439 DrawLine( Point( nDarkPos
, nPStart
), Point( nDarkPos
, nLineEnd
) );
442 DrawLine( Point( nPStart
, nBarSize
-1 ), Point( nLineEnd
, nBarSize
-1 ) );
444 // line in different color for selection
445 if ( nTransEnd
* nLayoutSign
>= nTransStart
* nLayoutSign
&& !bHighContrast
)
447 SetLineColor( aSelLineColor
);
450 long nDarkPos
= bMirrored
? 0 : nBarSize
-1;
451 DrawLine( Point( nDarkPos
, nTransStart
), Point( nDarkPos
, nTransEnd
) );
454 DrawLine( Point( nTransStart
, nBarSize
-1 ), Point( nTransEnd
, nBarSize
-1 ) );
459 // loop through entries several times to avoid changing the line color too often
460 // and to allow merging of lines
463 ScGridMerger
aGrid( this, 1, 1 );
465 // start at SC_HDRPAINT_BOTTOM instead of 0 - selection doesn't get different
466 // borders, light border at top isn't used anymore
467 // use SC_HDRPAINT_SEL_BOTTOM for different color
469 for (USHORT nPass
= SC_HDRPAINT_SEL_BOTTOM
; nPass
< SC_HDRPAINT_COUNT
; nPass
++)
471 // set line color etc. before entry loop
474 case SC_HDRPAINT_SEL_BOTTOM
:
475 // same as non-selected for high contrast
476 SetLineColor( bHighContrast
? rStyleSettings
.GetDarkShadowColor() : aSelLineColor
);
478 case SC_HDRPAINT_BOTTOM
:
479 SetLineColor( rStyleSettings
.GetDarkShadowColor() );
481 case SC_HDRPAINT_TEXT
:
482 // DrawSelectionBackground is used only for high contrast on light background
483 if ( nTransEnd
* nLayoutSign
>= nTransStart
* nLayoutSign
&& bHighContrast
&& !bDark
)
485 // Transparent selection background is drawn after lines, before text.
486 // #109814# Use DrawSelectionBackground to make sure there is a visible
487 // difference. The case of a dark face color, where DrawSelectionBackground
488 // would just paint over the lines, is handled separately (bDark).
489 // Otherwise, GetHighlightColor is used with 80% transparency.
490 // The window's background color (SetBackground) has to be the background
491 // of the cell area, for the contrast comparison in DrawSelectionBackground.
493 Rectangle aTransRect
;
495 aTransRect
= Rectangle( 0, nTransStart
, nBarSize
-1, nTransEnd
);
497 aTransRect
= Rectangle( nTransStart
, 0, nTransEnd
, nBarSize
-1 );
498 SetBackground( Color( rStyleSettings
.GetFaceColor() ) );
499 DrawSelectionBackground( aTransRect
, 0, TRUE
, FALSE
, FALSE
);
506 long nScrPos
=nInitScrPos
;
510 aScrPos
= Point( 0, nScrPos
);
512 aScrPos
= Point( nScrPos
, 0 );
514 SCCOLROW nEntryNo
= nCount
+ nPos
;
515 if ( nEntryNo
>= nSize
) // MAXCOL/MAXROW
516 nScrPos
= nPEnd
+ nLayoutSign
; // beyond nPEnd -> stop
519 USHORT nSizePix
= GetEntrySize( nEntryNo
);
523 SCCOLROW nHidden
= GetHiddenCount(nEntryNo
);
525 nCount
+= nHidden
- 1;
527 else if ((nScrPos
+nSizePix
*nLayoutSign
)*nLayoutSign
>= nPStart
*nLayoutSign
)
529 Point
aEndPos(aScrPos
);
531 aEndPos
= Point( aScrPos
.X()+nBarSize
-1, aScrPos
.Y()+(nSizePix
-1)*nLayoutSign
);
533 aEndPos
= Point( aScrPos
.X()+(nSizePix
-1)*nLayoutSign
, aScrPos
.Y()+nBarSize
-1 );
535 BOOL bMark
= bMarkRange
&& nEntryNo
>= nMarkStart
&& nEntryNo
<= nMarkEnd
;
536 BOOL bNextToMark
= bMarkRange
&& nEntryNo
+ 1 >= nMarkStart
&& nEntryNo
<= nMarkEnd
;
540 case SC_HDRPAINT_SEL_BOTTOM
:
541 case SC_HDRPAINT_BOTTOM
:
542 if ( nPass
== ( bNextToMark
? SC_HDRPAINT_SEL_BOTTOM
: SC_HDRPAINT_BOTTOM
) )
545 aGrid
.AddHorLine( aScrPos
.X(), aEndPos
.X(), aEndPos
.Y() );
547 aGrid
.AddVerLine( aEndPos
.X(), aScrPos
.Y(), aEndPos
.Y() );
549 // thick bottom for hidden rows
550 // (drawn directly, without aGrid)
551 if ( nEntryNo
+1 < nSize
)
552 if ( GetEntrySize(nEntryNo
+1)==0 )
555 DrawLine( Point(aScrPos
.X(),aEndPos
.Y()-nLayoutSign
),
556 Point(aEndPos
.X(),aEndPos
.Y()-nLayoutSign
) );
558 DrawLine( Point(aEndPos
.X()-nLayoutSign
,aScrPos
.Y()),
559 Point(aEndPos
.X()-nLayoutSign
,aEndPos
.Y()) );
564 case SC_HDRPAINT_TEXT
:
565 if ( nSizePix
> 1 ) // minimal check for small columns/rows
567 if ( bMark
!= bBoldSet
)
575 aString
= GetEntryText( nEntryNo
);
576 aTextSize
.Width() = GetTextWidth( aString
);
577 aTextSize
.Height() = GetTextHeight();
579 Point
aTxtPos(aScrPos
);
582 aTxtPos
.X() += (nBarSize
-aTextSize
.Width())/2;
583 aTxtPos
.Y() += (nSizePix
*nLayoutSign
-aTextSize
.Height())/2;
585 aTxtPos
.X() += 1; // dark border is left instead of right
589 aTxtPos
.X() += (nSizePix
*nLayoutSign
-aTextSize
.Width()+1)/2;
590 aTxtPos
.Y() += (nBarSize
-aTextSize
.Height())/2;
592 DrawText( aTxtPos
, aString
);
597 // bei Selektion der ganzen Zeile/Spalte:
598 // InvertRect( Rectangle( aScrPos, aEndPos ) );
600 nScrPos
+= nSizePix
* nLayoutSign
; // also if before the visible area
604 while ( nScrPos
* nLayoutSign
<= nPEnd
* nLayoutSign
);
614 SCCOLROW
ScHeaderControl::GetMousePos( const MouseEvent
& rMEvt
, BOOL
& rBorder
)
618 SCCOLROW nPos
= GetPos();
619 SCCOLROW nHitNo
= nPos
;
621 long nMousePos
= bVertical
? rMEvt
.GetPosPixel().Y() : rMEvt
.GetPosPixel().X();
623 Size aSize
= GetOutputSizePixel();
624 long nWinSize
= bVertical
? aSize
.Height() : aSize
.Width();
626 BOOL bLayoutRTL
= IsLayoutRTL();
627 long nLayoutSign
= bLayoutRTL
? -1 : 1;
628 long nEndPos
= bLayoutRTL
? -1 : nWinSize
;
630 nScrPos
= GetScrPos( nPos
) - nLayoutSign
;
633 SCCOLROW nEntryNo
= nCount
+ nPos
;
635 // nScrPos = GetScrPos( nEntryNo ) - 1;
637 if (nEntryNo
> nSize
)
638 nScrPos
= nEndPos
+ nLayoutSign
;
640 nScrPos
+= GetEntrySize( nEntryNo
- 1 ) * nLayoutSign
; //! GetHiddenCount() ??
642 nDif
= nMousePos
- nScrPos
;
643 if (nDif
>= -2 && nDif
<= 2 && nCount
> 0)
648 else if (nDif
* nLayoutSign
>= 0 && nEntryNo
< nSize
)
652 while ( nScrPos
* nLayoutSign
< nEndPos
* nLayoutSign
&& nDif
* nLayoutSign
> 0 );
658 void __EXPORT
ScHeaderControl::MouseButtonDown( const MouseEvent
& rMEvt
)
667 SCCOLROW nHitNo
= GetMousePos( rMEvt
, bFound
);
669 if ( bFound
&& rMEvt
.IsLeft() && ResizeAllowed() )
672 USHORT nClicks
= rMEvt
.GetClicks();
673 if ( nClicks
&& nClicks
%2==0 )
675 SetEntrySize( nDragNo
, HDR_SIZE_OPTIMUM
);
676 SetPointer( Pointer( POINTER_ARROW
) );
681 nDragStart
= rMEvt
.GetPosPixel().Y();
683 nDragStart
= rMEvt
.GetPosPixel().X();
684 nDragPos
= nDragStart
;
686 DrawInvert( nDragPos
);
694 else if (rMEvt
.IsLeft())
696 pSelEngine
->SetWindow( this );
698 Rectangle
aVis( aPoint
,GetOutputSizePixel() );
700 aVis
.Left() = LONG_MIN
, aVis
.Right() = LONG_MAX
;
702 aVis
.Top() = LONG_MIN
, aVis
.Bottom() = LONG_MAX
;
703 pSelEngine
->SetVisibleArea( aVis
);
705 SetMarking( TRUE
); // muss vor SelMouseButtonDown sein
706 pSelEngine
->SelMouseButtonDown( rMEvt
);
708 // #74215# In column/row headers a simple click already is a selection.
709 // -> Call SelMouseMove to ensure CreateAnchor is called (and DestroyAnchor
710 // if the next click is somewhere else with Control key).
711 pSelEngine
->SelMouseMove( rMEvt
);
713 if (IsMouseCaptured())
715 // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
716 //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
723 void __EXPORT
ScHeaderControl::MouseButtonUp( const MouseEvent
& rMEvt
)
731 // SCCOLROW nHitNo = GetMousePos( rMEvt, bFound );
735 DrawInvert( nDragPos
);
739 long nScrPos
= GetScrPos( nDragNo
);
740 long nMousePos
= bVertical
? rMEvt
.GetPosPixel().Y() : rMEvt
.GetPosPixel().X();
741 BOOL bLayoutRTL
= IsLayoutRTL();
742 long nNewWidth
= bLayoutRTL
? ( nScrPos
- nMousePos
+ 1 )
743 : ( nMousePos
+ 2 - nScrPos
);
745 if ( nNewWidth
< 0 /* && !IsSelected(nDragNo) */ )
748 SCCOLROW nEnd
= nDragNo
;
749 while (nNewWidth
< 0)
755 nNewWidth
+= GetEntrySize( nDragNo
); //! GetHiddenCount() ???
760 HideEntries( nStart
, nEnd
);
764 if (nNewWidth
<0) nNewWidth
=0;
766 SetEntrySize( nDragNo
, (USHORT
) nNewWidth
);
771 pSelEngine
->SelMouseButtonUp( rMEvt
);
776 void __EXPORT
ScHeaderControl::MouseMove( const MouseEvent
& rMEvt
)
780 SetPointer( Pointer( POINTER_ARROW
) );
785 (void)GetMousePos( rMEvt
, bFound
);
789 long nNewPos
= bVertical
? rMEvt
.GetPosPixel().Y() : rMEvt
.GetPosPixel().X();
790 if ( nNewPos
!= nDragPos
)
792 DrawInvert( nDragPos
);
795 DrawInvert( nDragPos
);
797 if (nDragPos
<= nDragStart
-SC_DRAG_MIN
|| nDragPos
>= nDragStart
+SC_DRAG_MIN
)
803 if ( bFound
&& rMEvt
.GetButtons()==0 && ResizeAllowed() )
804 SetPointer( Pointer( bVertical
? POINTER_VSIZEBAR
: POINTER_HSIZEBAR
) );
806 SetPointer( Pointer( POINTER_ARROW
) );
809 pSelEngine
->SelMouseMove( rMEvt
);
813 void ScHeaderControl::Tracking( const TrackingEvent
& rTEvt
)
815 // Weil die SelectionEngine kein Tracking kennt, die Events nur auf
816 // die verschiedenen MouseHandler verteilen...
818 if ( rTEvt
.IsTrackingCanceled() )
820 else if ( rTEvt
.IsTrackingEnded() )
821 MouseButtonUp( rTEvt
.GetMouseEvent() );
823 MouseMove( rTEvt
.GetMouseEvent() );
826 void __EXPORT
ScHeaderControl::Command( const CommandEvent
& rCEvt
)
828 USHORT nCmd
= rCEvt
.GetCommand();
829 if ( nCmd
== COMMAND_CONTEXTMENU
)
831 StopMarking(); // Selektion / Dragging beenden
835 ScTabViewShell
* pViewSh
= PTR_CAST( ScTabViewShell
,
836 SfxViewShell::Current() );
839 if ( rCEvt
.IsMouseEvent() )
841 // #i18735# select the column/row under the mouse pointer
842 ScViewData
* pViewData
= pViewSh
->GetViewData();
844 SelectWindow(); // also deselects drawing objects, stops draw text edit
845 if ( pViewData
->HasEditView( pViewData
->GetActivePart() ) )
846 SC_MOD()->InputEnterHandler(); // always end edit mode
848 MouseEvent
aMEvt( rCEvt
.GetMousePosPixel() );
850 SCCOLROW nPos
= GetMousePos( aMEvt
, bBorder
);
851 USHORT nTab
= pViewData
->GetTabNo();
855 aNewRange
= ScRange( 0, sal::static_int_cast
<SCROW
>(nPos
), nTab
,
856 MAXCOL
, sal::static_int_cast
<SCROW
>(nPos
), nTab
);
858 aNewRange
= ScRange( sal::static_int_cast
<SCCOL
>(nPos
), 0, nTab
,
859 sal::static_int_cast
<SCCOL
>(nPos
), MAXROW
, nTab
);
861 // see if any part of the range is already selected
862 BOOL bSelected
= FALSE
;
864 pViewData
->GetMarkData().FillRangeListWithMarks( &aRanges
, FALSE
);
865 ULONG nRangeCount
= aRanges
.Count();
866 for (ULONG i
=0; i
<nRangeCount
&& !bSelected
; i
++)
867 if ( aRanges
.GetObject(i
)->Intersects( aNewRange
) )
870 // select the range if no part of it was selected
872 pViewSh
->MarkRange( aNewRange
);
875 ScResId
aResId( bVertical
? RID_POPUP_ROWHEADER
: RID_POPUP_COLHEADER
);
876 pViewSh
->GetDispatcher()->ExecutePopup( aResId
);
879 else if ( nCmd
== COMMAND_STARTDRAG
)
881 pSelEngine
->Command( rCEvt
);
885 void ScHeaderControl::StopMarking()
889 DrawInvert( nDragPos
);
896 // #86260# don't call pSelEngine->Reset, so selection across the parts of
897 // a split/frozen view is possible
902 void ScHeaderControl::ShowDragHelp()
904 if (Help::IsQuickHelpEnabled())
906 long nScrPos
= GetScrPos( nDragNo
);
907 BOOL bLayoutRTL
= IsLayoutRTL();
908 long nVal
= bLayoutRTL
? ( nScrPos
- nDragPos
+ 1 )
909 : ( nDragPos
+ 2 - nScrPos
);
911 String aHelpStr
= GetDragHelp( nVal
);
912 Point aPos
= OutputToScreenPixel( Point(0,0) );
913 Size aSize
= GetSizePixel();
915 Point aMousePos
= OutputToScreenPixel(GetPointerPosPixel());
922 aRect
.Left() = aMousePos
.X();
923 aRect
.Top() = aPos
.Y() - 4;
924 nAlign
= QUICKHELP_BOTTOM
|QUICKHELP_CENTER
;
929 aRect
.Left() = aPos
.X() + aSize
.Width() + 8;
930 aRect
.Top() = aMousePos
.Y() - 2;
931 nAlign
= QUICKHELP_LEFT
|QUICKHELP_BOTTOM
;
934 aRect
.Right() = aRect
.Left();
935 aRect
.Bottom() = aRect
.Top();
937 Help::ShowQuickHelp(this, aRect
, aHelpStr
, nAlign
);
941 void __EXPORT
ScHeaderControl::RequestHelp( const HelpEvent
& rHEvt
)
943 // Wenn eigene QuickHelp angezeigt wird, nicht durch RequestHelp
944 // wieder wegnehmen lassen
946 BOOL bOwn
= bDragging
&& Help::IsQuickHelpEnabled();
948 Window::RequestHelp(rHEvt
);
951 // -----------------------------------------------------------------------
952 // Dummys fuer virtuelle Methoden
953 // -----------------------------------------------------------------------
955 SCCOLROW
ScHeaderControl::GetHiddenCount( SCCOLROW nEntryNo
)
957 SCCOLROW nHidden
= 0;
958 while ( nEntryNo
< nSize
&& GetEntrySize( nEntryNo
) == 0 )
966 BOOL
ScHeaderControl::IsLayoutRTL()
971 BOOL
ScHeaderControl::IsMirrored()
976 BOOL
ScHeaderControl::IsDisabled()
981 BOOL
ScHeaderControl::ResizeAllowed()
986 void ScHeaderControl::SelectWindow()
990 void ScHeaderControl::DrawInvert( long /* nDragPos */ )
994 String
ScHeaderControl::GetDragHelp( long /* nVal */ )
999 void ScHeaderControl::SetMarking( BOOL
/* bSet */ )