1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <o3tl/safeint.hxx>
23 #include <sal/log.hxx>
25 #include <vcl/event.hxx>
26 #include <vcl/wall.hxx>
27 #include <vcl/help.hxx>
28 #include <vcl/splitwin.hxx>
29 #include <vcl/settings.hxx>
30 #include <vcl/ptrstyle.hxx>
33 #include <strings.hrc>
36 #define SPLITWIN_SPLITSIZEEX 4
37 #define SPLITWIN_SPLITSIZEAUTOHIDE 72
38 #define SPLITWIN_SPLITSIZEFADE 72
40 #define SPLIT_HORZ (sal_uInt16(0x0001))
41 #define SPLIT_VERT (sal_uInt16(0x0002))
42 #define SPLIT_WINDOW (sal_uInt16(0x0004))
43 #define SPLIT_NOSPLIT (sal_uInt16(0x8000))
53 tools::Long mnPixSize
;
58 tools::Long mnSplitPos
;
59 tools::Long mnSplitSize
;
60 tools::Long mnOldSplitPos
;
61 tools::Long mnOldSplitSize
;
62 tools::Long mnOldWidth
;
63 tools::Long mnOldHeight
;
64 std::unique_ptr
<ImplSplitSet
> mpSet
;
65 VclPtr
<vcl::Window
> mpWindow
;
66 VclPtr
<vcl::Window
> mpOrgParent
;
68 SplitWindowItemFlags mnBits
;
71 /// Minimal width or height of the item. -1 means no restriction.
72 tools::Long mnMinSize
;
73 /// Maximal width or height of the item. -1 means no restriction.
74 tools::Long mnMaxSize
;
84 std::vector
< ImplSplitItem
> mvItems
;
85 tools::Long mnLastSize
;
86 tools::Long mnSplitSize
;
91 ImplSplitItem::ImplSplitItem()
105 , mnBits(SplitWindowItemFlags::NONE
)
113 ImplSplitSet::ImplSplitSet() :
115 mnSplitSize( SPLITWIN_SPLITSIZE
),
121 /** Check whether the given size is inside the valid range defined by
122 [rItem.mnMinSize,rItem.mnMaxSize]. When it is not inside it then return
123 the upper or lower bound, respectively. Otherwise return the given size
125 Note that either mnMinSize and/or mnMaxSize can be -1 in which case the
126 size has not lower or upper bound.
129 tools::Long
ValidateSize (const tools::Long nSize
, const ImplSplitItem
& rItem
)
131 if (rItem
.mnMinSize
>=0 && nSize
<rItem
.mnMinSize
)
132 return rItem
.mnMinSize
;
133 else if (rItem
.mnMaxSize
>0 && nSize
>rItem
.mnMaxSize
)
134 return rItem
.mnMaxSize
;
140 static void ImplCalcBorder( WindowAlign eAlign
,
141 tools::Long
& rLeft
, tools::Long
& rTop
,
142 tools::Long
& rRight
, tools::Long
& rBottom
)
146 case WindowAlign::Top
:
152 case WindowAlign::Left
:
158 case WindowAlign::Bottom
:
173 void SplitWindow::ImplDrawBorder(vcl::RenderContext
& rRenderContext
)
175 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
176 tools::Long nDX
= mnDX
;
177 tools::Long nDY
= mnDY
;
181 case WindowAlign::Bottom
:
183 case WindowAlign::Top
:
185 case WindowAlign::Left
:
188 rRenderContext
.SetLineColor(rStyleSettings
.GetShadowColor());
189 rRenderContext
.DrawLine(Point(0, 0), Point( 0, nDY
));
190 rRenderContext
.DrawLine(Point(0, nDY
), Point(nDX
, nDY
));
194 void SplitWindow::ImplDrawBorderLine(vcl::RenderContext
& rRenderContext
)
199 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
200 tools::Long nDX
= mnDX
;
201 tools::Long nDY
= mnDY
;
205 case WindowAlign::Left
:
206 rRenderContext
.SetLineColor( rStyleSettings
.GetShadowColor() );
207 rRenderContext
.DrawLine( Point( nDX
-SPLITWIN_SPLITSIZEEXLN
-1, 1 ), Point( nDX
-SPLITWIN_SPLITSIZEEXLN
-1, nDY
-2 ) );
209 rRenderContext
.SetLineColor( rStyleSettings
.GetLightColor() );
210 rRenderContext
.DrawLine( Point( nDX
-SPLITWIN_SPLITSIZEEXLN
, 1 ), Point( nDX
-SPLITWIN_SPLITSIZEEXLN
, nDY
-3 ) );
212 case WindowAlign::Right
:
214 case WindowAlign::Top
:
215 rRenderContext
.SetLineColor( rStyleSettings
.GetShadowColor() );
216 rRenderContext
.DrawLine( Point( 0, nDY
-SPLITWIN_SPLITSIZEEXLN
-1 ), Point( nDX
-1, nDY
-SPLITWIN_SPLITSIZEEXLN
-1 ) );
218 rRenderContext
.SetLineColor( rStyleSettings
.GetLightColor() );
219 rRenderContext
.DrawLine( Point( 0, nDY
-SPLITWIN_SPLITSIZEEXLN
), Point( nDX
-1, nDY
-SPLITWIN_SPLITSIZEEXLN
) );
221 case WindowAlign::Bottom
:
222 rRenderContext
.SetLineColor( rStyleSettings
.GetShadowColor() );
223 rRenderContext
.DrawLine( Point( 0, 5 ), Point( nDX
-1, 5 ) );
225 rRenderContext
.SetLineColor( rStyleSettings
.GetLightColor() );
226 rRenderContext
.DrawLine( Point( 0, SPLITWIN_SPLITSIZEEXLN
), Point( nDX
-1, SPLITWIN_SPLITSIZEEXLN
) );
231 static ImplSplitSet
* ImplFindSet( ImplSplitSet
* pSet
, sal_uInt16 nId
)
233 if ( pSet
->mnId
== nId
)
236 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
238 for ( const auto& rItem
: rItems
)
240 if ( rItem
.mnId
== nId
)
241 return rItem
.mpSet
.get();
244 for ( auto& rItem
: rItems
)
248 ImplSplitSet
* pFindSet
= ImplFindSet( rItem
.mpSet
.get(), nId
);
257 static ImplSplitSet
* ImplFindItem( ImplSplitSet
* pSet
, sal_uInt16 nId
, sal_uInt16
& rPos
)
259 size_t nItems
= pSet
->mvItems
.size();
260 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
262 for ( size_t i
= 0; i
< nItems
; i
++ )
264 if ( rItems
[i
].mnId
== nId
)
271 for ( auto& rItem
: rItems
)
275 ImplSplitSet
* pFindSet
= ImplFindItem( rItem
.mpSet
.get(), nId
, rPos
);
284 static sal_uInt16
ImplFindItem( ImplSplitSet
* pSet
, vcl::Window
* pWindow
)
286 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
288 for ( auto& rItem
: rItems
)
290 if ( rItem
.mpWindow
== pWindow
)
296 sal_uInt16 nId
= ImplFindItem( rItem
.mpSet
.get(), pWindow
);
306 static sal_uInt16
ImplFindItem( ImplSplitSet
* pSet
, const Point
& rPos
,
307 bool bRows
, bool bDown
= true )
309 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
311 for ( auto& rItem
: rItems
)
313 if ( rItem
.mnWidth
&& rItem
.mnHeight
)
315 Point
aPoint( rItem
.mnLeft
, rItem
.mnTop
);
316 Size
aSize( rItem
.mnWidth
, rItem
.mnHeight
);
317 tools::Rectangle
aRect( aPoint
, aSize
);
321 aRect
.AdjustBottom(pSet
->mnSplitSize
);
323 aRect
.AdjustTop( -(pSet
->mnSplitSize
) );
328 aRect
.AdjustRight(pSet
->mnSplitSize
);
330 aRect
.AdjustLeft( -(pSet
->mnSplitSize
) );
333 if ( aRect
.Contains( rPos
) )
335 if ( rItem
.mpSet
&& !rItem
.mpSet
->mvItems
.empty() )
337 return ImplFindItem( rItem
.mpSet
.get(), rPos
,
338 !(rItem
.mnBits
& SplitWindowItemFlags::ColSet
) );
349 static void ImplCalcSet( ImplSplitSet
* pSet
,
350 tools::Long nSetLeft
, tools::Long nSetTop
,
351 tools::Long nSetWidth
, tools::Long nSetHeight
,
352 bool bRows
, bool bDown
= true )
354 if ( pSet
->mvItems
.empty() )
358 sal_uInt16 nCalcItems
;
359 size_t nItems
= pSet
->mvItems
.size();
360 sal_uInt16 nAbsItems
;
361 tools::Long nCalcSize
;
364 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
369 nCalcSize
= nSetHeight
;
371 nCalcSize
= nSetWidth
;
372 nCalcSize
-= (rItems
.size()-1)*pSet
->mnSplitSize
;
373 if ( pSet
->mbCalcPix
|| (pSet
->mnLastSize
!= nCalcSize
) )
375 tools::Long nPercentFactor
= 10;
376 tools::Long nRelCount
= 0;
377 tools::Long nPercent
= 0;
378 tools::Long nRelPercent
= 0;
379 tools::Long nAbsSize
= 0;
380 tools::Long nCurSize
= 0;
381 for ( const auto& rItem
: rItems
)
383 if ( rItem
.mnBits
& SplitWindowItemFlags::RelativeSize
)
384 nRelCount
+= rItem
.mnSize
;
385 else if ( rItem
.mnBits
& SplitWindowItemFlags::PercentSize
)
386 nPercent
+= rItem
.mnSize
;
388 nAbsSize
+= rItem
.mnSize
;
390 // map relative values to percentages (percentage here one tenth of a percent)
391 nPercent
*= nPercentFactor
;
394 tools::Long nRelPercentBase
= 1000;
395 while ( (nRelCount
> nRelPercentBase
) && (nPercentFactor
< 100000) )
397 nRelPercentBase
*= 10;
398 nPercentFactor
*= 10;
400 if ( nPercent
< nRelPercentBase
)
402 nRelPercent
= (nRelPercentBase
-nPercent
)/nRelCount
;
403 nPercent
+= nRelPercent
*nRelCount
;
410 tools::Long nSizeDelta
= nCalcSize
-nAbsSize
;
411 for ( auto& rItem
: rItems
)
413 if ( rItem
.mnBits
& SplitWindowItemFlags::RelativeSize
)
415 if ( nSizeDelta
<= 0 )
418 rItem
.mnPixSize
= (nSizeDelta
*rItem
.mnSize
*nRelPercent
)/nPercent
;
420 else if ( rItem
.mnBits
& SplitWindowItemFlags::PercentSize
)
422 if ( nSizeDelta
<= 0 )
425 rItem
.mnPixSize
= (nSizeDelta
*rItem
.mnSize
*nPercentFactor
)/nPercent
;
428 rItem
.mnPixSize
= rItem
.mnSize
;
429 nCurSize
+= rItem
.mnPixSize
;
432 pSet
->mbCalcPix
= false;
433 pSet
->mnLastSize
= nCalcSize
;
436 nSizeDelta
= nCalcSize
-nCurSize
;
440 tools::Long nSizeWinSize
= 0;
442 // first resize absolute items relative
443 for ( const auto& rItem
: rItems
)
445 if ( !(rItem
.mnBits
& (SplitWindowItemFlags::RelativeSize
| SplitWindowItemFlags::PercentSize
)) )
448 nSizeWinSize
+= rItem
.mnPixSize
;
451 // do not compensate rounding errors here
452 if ( (nAbsItems
< o3tl::make_unsigned(std::abs( nSizeDelta
))) && nSizeWinSize
)
454 tools::Long nNewSizeWinSize
= 0;
456 for ( auto& rItem
: rItems
)
458 if ( !(rItem
.mnBits
& (SplitWindowItemFlags::RelativeSize
| SplitWindowItemFlags::PercentSize
)) )
460 rItem
.mnPixSize
+= (nSizeDelta
*rItem
.mnPixSize
)/nSizeWinSize
;
461 nNewSizeWinSize
+= rItem
.mnPixSize
;
465 nSizeDelta
-= nNewSizeWinSize
-nSizeWinSize
;
468 // compensate rounding errors now
471 while ( nSizeDelta
&& (nItems
!= nMins
) )
473 // determine which items we can calculate
475 while ( !nCalcItems
)
477 for ( auto& rItem
: rItems
)
479 rItem
.mbSubSize
= false;
482 rItem
.mbSubSize
= true;
485 if ( (nSizeDelta
> 0) || rItem
.mnPixSize
)
488 rItem
.mbSubSize
= true;
491 if ( (j
== 0) && (rItem
.mnBits
& (SplitWindowItemFlags::RelativeSize
| SplitWindowItemFlags::PercentSize
)) )
492 rItem
.mbSubSize
= true;
497 if ( rItem
.mbSubSize
)
504 // subtract size of individual items
505 tools::Long nErrorSum
= nSizeDelta
% nCalcItems
;
506 tools::Long nCurSizeDelta
= nSizeDelta
/ nCalcItems
;
508 for ( auto& rItem
: rItems
)
510 if ( rItem
.mbSubSize
)
512 tools::Long
* pSize
= &(rItem
.mnPixSize
);
513 tools::Long nTempErr
;
525 if ( (*pSize
+nCurSizeDelta
+nTempErr
) <= 0 )
527 tools::Long nTemp
= *pSize
;
537 *pSize
+= nCurSizeDelta
;
538 nSizeDelta
-= nCurSizeDelta
;
539 if ( nTempErr
&& (*pSize
|| (nTempErr
> 0)) )
542 nSizeDelta
-= nTempErr
;
543 nErrorSum
-= nTempErr
;
552 // calculate maximum size
557 nMaxPos
= nSetTop
-nSetHeight
;
559 nMaxPos
= nSetTop
+nSetHeight
;
565 nMaxPos
= nSetLeft
-nSetWidth
;
567 nMaxPos
= nSetLeft
+nSetWidth
;
570 // order windows and adapt values
571 for ( size_t i
= 0; i
< nItems
; i
++ )
573 rItems
[i
].mnOldSplitPos
= rItems
[i
].mnSplitPos
;
574 rItems
[i
].mnOldSplitSize
= rItems
[i
].mnSplitSize
;
575 rItems
[i
].mnOldWidth
= rItems
[i
].mnWidth
;
576 rItems
[i
].mnOldHeight
= rItems
[i
].mnHeight
;
581 if ( nPos
+rItems
[i
].mnPixSize
> nMaxPos
)
586 nPos
-= rItems
[i
].mnPixSize
;
587 if ( nPos
< nMaxPos
)
593 rItems
[i
].mnWidth
= 0;
594 rItems
[i
].mnHeight
= 0;
595 rItems
[i
].mnSplitSize
= 0;
601 rItems
[i
].mnLeft
= nSetLeft
;
602 rItems
[i
].mnTop
= nPos
;
603 rItems
[i
].mnWidth
= nSetWidth
;
604 rItems
[i
].mnHeight
= rItems
[i
].mnPixSize
;
608 rItems
[i
].mnLeft
= nPos
;
609 rItems
[i
].mnTop
= nSetTop
;
610 rItems
[i
].mnWidth
= rItems
[i
].mnPixSize
;
611 rItems
[i
].mnHeight
= nSetHeight
;
615 rItems
[i
].mnSplitSize
= 0;
618 rItems
[i
].mnSplitSize
= pSet
->mnSplitSize
;
621 rItems
[i
].mnSplitPos
= nPos
+rItems
[i
].mnPixSize
;
622 if ( rItems
[i
].mnSplitPos
+rItems
[i
].mnSplitSize
> nMaxPos
)
623 rItems
[i
].mnSplitSize
= nMaxPos
-rItems
[i
].mnSplitPos
;
627 rItems
[i
].mnSplitPos
= nPos
-pSet
->mnSplitSize
;
628 if ( rItems
[i
].mnSplitPos
< nMaxPos
)
629 rItems
[i
].mnSplitSize
= rItems
[i
].mnSplitPos
+pSet
->mnSplitSize
-nMaxPos
;
635 nPos
-= pSet
->mnSplitSize
;
637 nPos
+= rItems
[i
].mnPixSize
+pSet
->mnSplitSize
;
640 // calculate Sub-Set's
641 for ( auto& rItem
: rItems
)
643 if ( rItem
.mpSet
&& rItem
.mnWidth
&& rItem
.mnHeight
)
645 ImplCalcSet( rItem
.mpSet
.get(),
646 rItem
.mnLeft
, rItem
.mnTop
,
647 rItem
.mnWidth
, rItem
.mnHeight
,
648 !(rItem
.mnBits
& SplitWindowItemFlags::ColSet
) );
653 for ( auto& rItem
: rItems
)
655 rItem
.mbFixed
= false;
656 if ( rItem
.mnBits
& SplitWindowItemFlags::Fixed
)
657 rItem
.mbFixed
= true;
660 // this item is also fixed if Child-Set is available,
661 // if a child is fixed
664 for ( auto const & j
: rItem
.mpSet
->mvItems
)
668 rItem
.mbFixed
= true;
677 void SplitWindow::ImplCalcSet2( SplitWindow
* pWindow
, ImplSplitSet
* pSet
, bool bHide
,
680 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
682 if ( pWindow
->IsReallyVisible() && pWindow
->IsUpdateMode() && pWindow
->mbInvalidate
)
684 for ( const auto& rItem
: rItems
)
686 if ( rItem
.mnSplitSize
)
688 // invalidate all, if applicable or only a small part
689 if ( (rItem
.mnOldSplitPos
!= rItem
.mnSplitPos
) ||
690 (rItem
.mnOldSplitSize
!= rItem
.mnSplitSize
) ||
691 (rItem
.mnOldWidth
!= rItem
.mnWidth
) ||
692 (rItem
.mnOldHeight
!= rItem
.mnHeight
) )
694 tools::Rectangle aRect
;
696 // invalidate old rectangle
699 aRect
.SetLeft( rItem
.mnLeft
);
700 aRect
.SetRight( rItem
.mnLeft
+rItem
.mnOldWidth
-1 );
701 aRect
.SetTop( rItem
.mnOldSplitPos
);
702 aRect
.SetBottom( aRect
.Top() + rItem
.mnOldSplitSize
);
706 aRect
.SetTop( rItem
.mnTop
);
707 aRect
.SetBottom( rItem
.mnTop
+rItem
.mnOldHeight
-1 );
708 aRect
.SetLeft( rItem
.mnOldSplitPos
);
709 aRect
.SetRight( aRect
.Left() + rItem
.mnOldSplitSize
);
711 pWindow
->Invalidate( aRect
);
712 // invalidate new rectangle
715 aRect
.SetLeft( rItem
.mnLeft
);
716 aRect
.SetRight( rItem
.mnLeft
+rItem
.mnWidth
-1 );
717 aRect
.SetTop( rItem
.mnSplitPos
);
718 aRect
.SetBottom( aRect
.Top() + rItem
.mnSplitSize
);
722 aRect
.SetTop( rItem
.mnTop
);
723 aRect
.SetBottom( rItem
.mnTop
+rItem
.mnHeight
-1 );
724 aRect
.SetLeft( rItem
.mnSplitPos
);
725 aRect
.SetRight( aRect
.Left() + rItem
.mnSplitSize
);
727 pWindow
->Invalidate( aRect
);
729 // invalidate complete set, as these areas
730 // are not cluttered by windows
731 if ( rItem
.mpSet
&& rItem
.mpSet
->mvItems
.empty() )
733 aRect
.SetLeft( rItem
.mnLeft
);
734 aRect
.SetTop( rItem
.mnTop
);
735 aRect
.SetRight( rItem
.mnLeft
+rItem
.mnWidth
-1 );
736 aRect
.SetBottom( rItem
.mnTop
+rItem
.mnHeight
-1 );
737 pWindow
->Invalidate( aRect
);
745 for ( auto& rItem
: rItems
)
749 bool bTempHide
= bHide
;
750 if ( !rItem
.mnWidth
|| !rItem
.mnHeight
)
752 ImplCalcSet2( pWindow
, rItem
.mpSet
.get(), bTempHide
,
753 !(rItem
.mnBits
& SplitWindowItemFlags::ColSet
) );
757 if ( rItem
.mnWidth
&& rItem
.mnHeight
&& !bHide
)
759 Point
aPos( rItem
.mnLeft
, rItem
.mnTop
);
760 Size
aSize( rItem
.mnWidth
, rItem
.mnHeight
);
761 rItem
.mpWindow
->SetPosSizePixel( aPos
, aSize
);
764 rItem
.mpWindow
->Hide();
768 // show windows and reset flag
769 for ( auto& rItem
: rItems
)
771 if ( rItem
.mpWindow
&& rItem
.mnWidth
&& rItem
.mnHeight
&& !bHide
)
772 rItem
.mpWindow
->Show();
776 static void ImplCalcLogSize( std::vector
< ImplSplitItem
> & rItems
, size_t nItems
)
778 // update original sizes
780 tools::Long nRelSize
= 0;
781 tools::Long nPerSize
= 0;
783 for ( i
= 0; i
< nItems
; i
++ )
785 if ( rItems
[i
].mnBits
& SplitWindowItemFlags::RelativeSize
)
786 nRelSize
+= rItems
[i
].mnPixSize
;
787 else if ( rItems
[i
].mnBits
& SplitWindowItemFlags::PercentSize
)
788 nPerSize
+= rItems
[i
].mnPixSize
;
790 nPerSize
+= nRelSize
;
791 for ( i
= 0; i
< nItems
; i
++ )
793 if ( rItems
[i
].mnBits
& SplitWindowItemFlags::RelativeSize
)
796 rItems
[i
].mnSize
= (rItems
[i
].mnPixSize
+(nRelSize
/2))/nRelSize
;
798 rItems
[i
].mnSize
= 1;
800 else if ( rItems
[i
].mnBits
& SplitWindowItemFlags::PercentSize
)
803 rItems
[i
].mnSize
= (rItems
[i
].mnPixSize
*100)/nPerSize
;
805 rItems
[i
].mnSize
= 1;
808 rItems
[i
].mnSize
= rItems
[i
].mnPixSize
;
812 static void ImplDrawSplit(vcl::RenderContext
& rRenderContext
, ImplSplitSet
* pSet
, bool bRows
, bool bDown
)
814 if (pSet
->mvItems
.empty())
817 size_t nItems
= pSet
->mvItems
.size();
821 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
822 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
824 for (size_t i
= 0; i
< nItems
-1; i
++)
826 if (rItems
[i
].mnSplitSize
)
828 nPos
= rItems
[i
].mnSplitPos
;
830 tools::Long nItemSplitSize
= rItems
[i
].mnSplitSize
;
831 tools::Long nSplitSize
= pSet
->mnSplitSize
;
834 nTop
= rItems
[i
].mnLeft
;
835 nBottom
= rItems
[i
].mnLeft
+rItems
[i
].mnWidth
-1;
837 if (bDown
|| (nItemSplitSize
>= nSplitSize
))
839 rRenderContext
.SetLineColor(rStyleSettings
.GetLightColor());
840 rRenderContext
.DrawLine(Point(nTop
, nPos
+ 1), Point(nBottom
, nPos
+ 1));
842 nPos
+= nSplitSize
-2;
843 if ((!bDown
&& (nItemSplitSize
>= 2)) ||
844 (bDown
&& (nItemSplitSize
>= nSplitSize
- 1)))
846 rRenderContext
.SetLineColor(rStyleSettings
.GetShadowColor());
847 rRenderContext
.DrawLine(Point(nTop
, nPos
), Point(nBottom
, nPos
));
850 if (!bDown
|| (nItemSplitSize
>= nSplitSize
))
852 rRenderContext
.SetLineColor(rStyleSettings
.GetDarkShadowColor());
853 rRenderContext
.DrawLine(Point(nTop
, nPos
), Point(nBottom
, nPos
));
858 nTop
= rItems
[i
].mnTop
;
859 nBottom
= rItems
[i
].mnTop
+pSet
->mvItems
[i
].mnHeight
-1;
861 if (bDown
|| (nItemSplitSize
>= nSplitSize
))
863 rRenderContext
.SetLineColor(rStyleSettings
.GetLightColor());
864 rRenderContext
.DrawLine(Point(nPos
+ 1, nTop
), Point(nPos
+1, nBottom
));
866 nPos
+= pSet
->mnSplitSize
- 2;
867 if ((!bDown
&& (nItemSplitSize
>= 2)) ||
868 (bDown
&& (nItemSplitSize
>= nSplitSize
- 1)))
870 rRenderContext
.SetLineColor(rStyleSettings
.GetShadowColor());
871 rRenderContext
.DrawLine(Point(nPos
, nTop
), Point(nPos
, nBottom
));
874 if (!bDown
|| (nItemSplitSize
>= nSplitSize
))
876 rRenderContext
.SetLineColor(rStyleSettings
.GetDarkShadowColor());
877 rRenderContext
.DrawLine(Point(nPos
, nTop
), Point(nPos
, nBottom
));
883 for ( auto& rItem
: rItems
)
885 if (rItem
.mpSet
&& rItem
.mnWidth
&& rItem
.mnHeight
)
887 ImplDrawSplit(rRenderContext
, rItem
.mpSet
.get(), !(rItem
.mnBits
& SplitWindowItemFlags::ColSet
), true/*bDown*/);
892 sal_uInt16
SplitWindow::ImplTestSplit( ImplSplitSet
* pSet
, const Point
& rPos
,
893 tools::Long
& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
,
896 if ( pSet
->mvItems
.empty() )
899 sal_uInt16 nSplitTest
;
900 size_t nItems
= pSet
->mvItems
.size();
906 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
919 for ( size_t i
= 0; i
< nItems
-1; i
++ )
921 if ( rItems
[i
].mnSplitSize
)
925 nTop
= rItems
[i
].mnLeft
;
926 nBottom
= rItems
[i
].mnLeft
+rItems
[i
].mnWidth
-1;
930 nTop
= rItems
[i
].mnTop
;
931 nBottom
= rItems
[i
].mnTop
+rItems
[i
].mnHeight
-1;
933 nPos
= rItems
[i
].mnSplitPos
;
935 if ( (nMPos1
>= nTop
) && (nMPos1
<= nBottom
) &&
936 (nMPos2
>= nPos
) && (nMPos2
<= nPos
+rItems
[i
].mnSplitSize
) )
938 if ( !rItems
[i
].mbFixed
&& !rItems
[i
+1].mbFixed
)
940 rMouseOff
= nMPos2
-nPos
;
949 return SPLIT_NOSPLIT
;
954 for ( auto& rItem
: rItems
)
958 nSplitTest
= ImplTestSplit( rItem
.mpSet
.get(), rPos
,
959 rMouseOff
, ppFoundSet
, rFoundPos
,
960 !(rItem
.mnBits
& SplitWindowItemFlags::ColSet
) );
969 sal_uInt16
SplitWindow::ImplTestSplit( const SplitWindow
* pWindow
, const Point
& rPos
,
970 tools::Long
& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
)
972 // Resizable SplitWindow should be treated different
973 if ( pWindow
->mnWinStyle
& WB_SIZEABLE
)
979 if ( pWindow
->mbHorz
)
981 if ( pWindow
->mbBottomRight
)
983 nBorder
= pWindow
->mnBottomBorder
;
988 nBorder
= pWindow
->mnTopBorder
;
989 nPos
= pWindow
->mnDY
-nBorder
;
995 if ( pWindow
->mbBottomRight
)
997 nBorder
= pWindow
->mnRightBorder
;
1002 nBorder
= pWindow
->mnLeftBorder
;
1003 nPos
= pWindow
->mnDX
-nBorder
;
1007 tools::Long nSplitSize
= pWindow
->mpMainSet
->mnSplitSize
-2;
1008 if (pWindow
->mbFadeOut
)
1009 nSplitSize
+= SPLITWIN_SPLITSIZEEXLN
;
1010 if ( !pWindow
->mbBottomRight
)
1012 if ( (nTPos
>= nPos
) && (nTPos
<= nPos
+nSplitSize
+nBorder
) )
1014 rMouseOff
= nTPos
-nPos
;
1015 *ppFoundSet
= pWindow
->mpMainSet
.get();
1016 if ( !pWindow
->mpMainSet
->mvItems
.empty() )
1017 rFoundPos
= pWindow
->mpMainSet
->mvItems
.size() - 1;
1020 if ( pWindow
->mbHorz
)
1021 return SPLIT_VERT
| SPLIT_WINDOW
;
1023 return SPLIT_HORZ
| SPLIT_WINDOW
;
1027 return ImplTestSplit( pWindow
->mpMainSet
.get(), rPos
, rMouseOff
, ppFoundSet
, rFoundPos
,
1031 void SplitWindow::ImplDrawSplitTracking(const Point
& rPos
)
1033 tools::Rectangle aRect
;
1035 if (mnSplitTest
& SPLIT_HORZ
)
1037 aRect
.SetTop( maDragRect
.Top() );
1038 aRect
.SetBottom( maDragRect
.Bottom() );
1039 aRect
.SetLeft( rPos
.X() );
1040 aRect
.SetRight( aRect
.Left() + mpSplitSet
->mnSplitSize
- 1 );
1041 if (!(mnWinStyle
& WB_NOSPLITDRAW
))
1042 aRect
.AdjustRight( -1 );
1043 if ((mnSplitTest
& SPLIT_WINDOW
) && mbFadeOut
)
1045 aRect
.AdjustLeft(SPLITWIN_SPLITSIZEEXLN
);
1046 aRect
.AdjustRight(SPLITWIN_SPLITSIZEEXLN
);
1051 aRect
.SetLeft( maDragRect
.Left() );
1052 aRect
.SetRight( maDragRect
.Right() );
1053 aRect
.SetTop( rPos
.Y() );
1054 aRect
.SetBottom( aRect
.Top() + mpSplitSet
->mnSplitSize
- 1 );
1055 if (!(mnWinStyle
& WB_NOSPLITDRAW
))
1056 aRect
.AdjustBottom( -1 );
1057 if ((mnSplitTest
& SPLIT_WINDOW
) && mbFadeOut
)
1059 aRect
.AdjustTop(SPLITWIN_SPLITSIZEEXLN
);
1060 aRect
.AdjustBottom(SPLITWIN_SPLITSIZEEXLN
);
1063 ShowTracking(aRect
, ShowTrackFlags::Split
);
1066 void SplitWindow::ImplInit( vcl::Window
* pParent
, WinBits nStyle
)
1068 mpMainSet
.reset(new ImplSplitSet());
1069 mpBaseSet
= mpMainSet
.get();
1070 mpSplitSet
= nullptr;
1071 mpLastSizes
= nullptr;
1080 meAlign
= WindowAlign::Top
;
1081 mnWinStyle
= nStyle
;
1084 mnMouseModifier
= 0;
1089 mbBottomRight
= false;
1092 mbInvalidate
= true;
1095 mbFadeInDown
= false;
1096 mbFadeOutDown
= false;
1097 mbFadeInPressed
= false;
1098 mbFadeOutPressed
= false;
1099 mbFadeNoButtonMode
= false;
1101 if ( nStyle
& WB_NOSPLITDRAW
)
1103 mpMainSet
->mnSplitSize
-= 2;
1104 mbInvalidate
= false;
1107 if ( nStyle
& WB_BORDER
)
1109 ImplCalcBorder( meAlign
, mnLeftBorder
, mnTopBorder
,
1110 mnRightBorder
, mnBottomBorder
);
1120 DockingWindow::ImplInit( pParent
, (nStyle
| WB_CLIPCHILDREN
) & ~(WB_BORDER
| WB_SIZEABLE
) );
1125 void SplitWindow::ImplInitSettings()
1127 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
1130 if ( IsControlBackground() )
1131 aColor
= GetControlBackground();
1132 else if ( Window::GetStyle() & WB_3DLOOK
)
1133 aColor
= rStyleSettings
.GetFaceColor();
1135 aColor
= rStyleSettings
.GetWindowColor();
1136 SetBackground( aColor
);
1139 SplitWindow::SplitWindow( vcl::Window
* pParent
, WinBits nStyle
) :
1140 DockingWindow( WindowType::SPLITWINDOW
, "vcl::SplitWindow maLayoutIdle" )
1142 ImplInit( pParent
, nStyle
);
1145 SplitWindow::~SplitWindow()
1150 void SplitWindow::dispose()
1154 DockingWindow::dispose();
1157 void SplitWindow::ImplSetWindowSize( tools::Long nDelta
)
1162 Size aSize
= GetSizePixel();
1165 case WindowAlign::Top
:
1166 aSize
.AdjustHeight(nDelta
);
1167 SetSizePixel( aSize
);
1169 case WindowAlign::Bottom
:
1171 maDragRect
.AdjustTop(nDelta
);
1172 Point aPos
= GetPosPixel();
1173 aPos
.AdjustY( -nDelta
);
1174 aSize
.AdjustHeight(nDelta
);
1175 SetPosSizePixel( aPos
, aSize
);
1178 case WindowAlign::Left
:
1179 aSize
.AdjustWidth(nDelta
);
1180 SetSizePixel( aSize
);
1182 case WindowAlign::Right
:
1185 maDragRect
.AdjustLeft(nDelta
);
1186 Point aPos
= GetPosPixel();
1187 aPos
.AdjustX( -nDelta
);
1188 aSize
.AdjustWidth(nDelta
);
1189 SetPosSizePixel( aPos
, aSize
);
1197 Size
SplitWindow::CalcLayoutSizePixel( const Size
& aNewSize
)
1199 Size
aSize( aNewSize
);
1200 tools::Long nSplitSize
= mpMainSet
->mnSplitSize
-2;
1203 nSplitSize
+= SPLITWIN_SPLITSIZEEXLN
;
1205 // if the window is sizeable and if it does not contain a relative window,
1206 // the size is determined according to MainSet
1207 if ( mnWinStyle
& WB_SIZEABLE
)
1209 tools::Long nCalcSize
= 0;
1210 std::vector
< ImplSplitItem
* >::size_type i
;
1212 for ( i
= 0; i
< mpMainSet
->mvItems
.size(); i
++ )
1214 if ( mpMainSet
->mvItems
[i
].mnBits
& (SplitWindowItemFlags::RelativeSize
| SplitWindowItemFlags::PercentSize
) )
1217 nCalcSize
+= mpMainSet
->mvItems
[i
].mnSize
;
1220 if ( i
== mpMainSet
->mvItems
.size() )
1222 tools::Long nDelta
= 0;
1223 tools::Long nCurSize
;
1226 nCurSize
= aNewSize
.Height()-mnTopBorder
-mnBottomBorder
;
1228 nCurSize
= aNewSize
.Width()-mnLeftBorder
-mnRightBorder
;
1229 nCurSize
-= nSplitSize
;
1230 nCurSize
-= (mpMainSet
->mvItems
.size()-1)*mpMainSet
->mnSplitSize
;
1232 nDelta
= nCalcSize
-nCurSize
;
1238 case WindowAlign::Top
:
1239 aSize
.AdjustHeight(nDelta
);
1241 case WindowAlign::Bottom
:
1242 aSize
.AdjustHeight(nDelta
);
1244 case WindowAlign::Left
:
1245 aSize
.AdjustWidth(nDelta
);
1247 case WindowAlign::Right
:
1249 aSize
.AdjustWidth(nDelta
);
1258 void SplitWindow::ImplCalcLayout()
1260 if ( !mbCalc
|| !mbRecalc
|| mpMainSet
->mvItems
.empty() )
1263 tools::Long nSplitSize
= mpMainSet
->mnSplitSize
-2;
1265 nSplitSize
+= SPLITWIN_SPLITSIZEEXLN
;
1267 // if the window is sizeable and if it does not contain a relative window,
1268 // the size is determined according to MainSet
1269 if ( mnWinStyle
& WB_SIZEABLE
)
1271 tools::Long nCalcSize
= 0;
1272 std::vector
<ImplSplitItem
*>::size_type i
;
1274 for ( i
= 0; i
< mpMainSet
->mvItems
.size(); i
++ )
1276 if ( mpMainSet
->mvItems
[i
].mnBits
& (SplitWindowItemFlags::RelativeSize
| SplitWindowItemFlags::PercentSize
) )
1279 nCalcSize
+= mpMainSet
->mvItems
[i
].mnSize
;
1282 if ( i
== mpMainSet
->mvItems
.size() )
1284 tools::Long nCurSize
;
1286 nCurSize
= mnDY
-mnTopBorder
-mnBottomBorder
;
1288 nCurSize
= mnDX
-mnLeftBorder
-mnRightBorder
;
1289 nCurSize
-= nSplitSize
;
1290 nCurSize
-= (mpMainSet
->mvItems
.size()-1)*mpMainSet
->mnSplitSize
;
1293 ImplSetWindowSize( nCalcSize
-nCurSize
);
1298 if ( (mnDX
<= 0) || (mnDY
<= 0) )
1301 // pre-calculate sizes/position
1309 if ( mbBottomRight
)
1310 nT
= mnDY
-mnBottomBorder
;
1317 if ( mbBottomRight
)
1318 nL
= mnDX
-mnRightBorder
;
1323 nW
= mnDX
-mnLeftBorder
-mnRightBorder
;
1324 nH
= mnDY
-mnTopBorder
-mnBottomBorder
;
1325 if ( mnWinStyle
& WB_SIZEABLE
)
1333 // calculate sets recursive
1334 ImplCalcSet( mpMainSet
.get(), nL
, nT
, nW
, nH
, mbHorz
, !mbBottomRight
);
1335 ImplCalcSet2( this, mpMainSet
.get(), false, mbHorz
);
1339 void SplitWindow::ImplUpdate()
1343 if ( IsReallyShown() && IsUpdateMode() && mbRecalc
)
1345 if ( !mpMainSet
->mvItems
.empty() )
1352 void SplitWindow::ImplSplitMousePos( Point
& rMousePos
)
1354 if ( mnSplitTest
& SPLIT_HORZ
)
1356 rMousePos
.AdjustX( -mnMouseOff
);
1357 if ( rMousePos
.X() < maDragRect
.Left() )
1358 rMousePos
.setX( maDragRect
.Left() );
1359 else if ( rMousePos
.X()+mpSplitSet
->mnSplitSize
+1 > maDragRect
.Right() )
1360 rMousePos
.setX( maDragRect
.Right()-mpSplitSet
->mnSplitSize
+1 );
1361 // store in screen coordinates due to FullDrag
1362 mnMSplitPos
= OutputToScreenPixel( rMousePos
).X();
1366 rMousePos
.AdjustY( -mnMouseOff
);
1367 if ( rMousePos
.Y() < maDragRect
.Top() )
1368 rMousePos
.setY( maDragRect
.Top() );
1369 else if ( rMousePos
.Y()+mpSplitSet
->mnSplitSize
+1 > maDragRect
.Bottom() )
1370 rMousePos
.setY( maDragRect
.Bottom()-mpSplitSet
->mnSplitSize
+1 );
1371 mnMSplitPos
= OutputToScreenPixel( rMousePos
).Y();
1375 void SplitWindow::ImplGetButtonRect( tools::Rectangle
& rRect
, bool bTest
) const
1377 tools::Long nSplitSize
= mpMainSet
->mnSplitSize
-1;
1378 if (mbFadeOut
|| mbFadeIn
)
1379 nSplitSize
+= SPLITWIN_SPLITSIZEEX
;
1381 tools::Long nButtonSize
= 0;
1383 nButtonSize
+= SPLITWIN_SPLITSIZEFADE
+1;
1385 nButtonSize
+= SPLITWIN_SPLITSIZEFADE
+1;
1386 tools::Long nCenterEx
= 0;
1388 nCenterEx
+= ((mnDX
-mnLeftBorder
-mnRightBorder
)-nButtonSize
)/2;
1390 nCenterEx
+= ((mnDY
-mnTopBorder
-mnBottomBorder
)-nButtonSize
)/2;
1391 tools::Long nEx
= 0;
1392 if ( nCenterEx
> 0 )
1397 case WindowAlign::Top
:
1398 rRect
.SetLeft( mnLeftBorder
+nEx
);
1399 rRect
.SetTop( mnDY
-mnBottomBorder
-nSplitSize
);
1400 rRect
.SetRight( rRect
.Left()+SPLITWIN_SPLITSIZEAUTOHIDE
);
1401 rRect
.SetBottom( mnDY
-mnBottomBorder
-1 );
1404 rRect
.AdjustTop( -mnTopBorder
);
1405 rRect
.AdjustBottom(mnBottomBorder
);
1408 case WindowAlign::Bottom
:
1409 rRect
.SetLeft( mnLeftBorder
+nEx
);
1410 rRect
.SetTop( mnTopBorder
);
1411 rRect
.SetRight( rRect
.Left()+SPLITWIN_SPLITSIZEAUTOHIDE
);
1412 rRect
.SetBottom( mnTopBorder
+nSplitSize
-1 );
1415 rRect
.AdjustTop( -mnTopBorder
);
1416 rRect
.AdjustBottom(mnBottomBorder
);
1419 case WindowAlign::Left
:
1420 rRect
.SetLeft( mnDX
-mnRightBorder
-nSplitSize
);
1421 rRect
.SetTop( mnTopBorder
+nEx
);
1422 rRect
.SetRight( mnDX
-mnRightBorder
-1 );
1423 rRect
.SetBottom( rRect
.Top()+SPLITWIN_SPLITSIZEAUTOHIDE
);
1426 rRect
.AdjustLeft( -mnLeftBorder
);
1427 rRect
.AdjustRight(mnRightBorder
);
1430 case WindowAlign::Right
:
1431 rRect
.SetLeft( mnLeftBorder
);
1432 rRect
.SetTop( mnTopBorder
+nEx
);
1433 rRect
.SetRight( mnLeftBorder
+nSplitSize
-1 );
1434 rRect
.SetBottom( rRect
.Top()+SPLITWIN_SPLITSIZEAUTOHIDE
);
1437 rRect
.AdjustLeft( -mnLeftBorder
);
1438 rRect
.AdjustRight(mnRightBorder
);
1444 void SplitWindow::ImplGetFadeInRect( tools::Rectangle
& rRect
, bool bTest
) const
1446 tools::Rectangle aRect
;
1449 ImplGetButtonRect( aRect
, bTest
);
1454 void SplitWindow::ImplGetFadeOutRect( tools::Rectangle
& rRect
) const
1456 tools::Rectangle aRect
;
1459 ImplGetButtonRect( aRect
, false );
1464 void SplitWindow::ImplDrawGrip(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
, bool bHorizontal
, bool bLeft
)
1466 const StyleSettings
& rStyleSettings
= rRenderContext
.GetSettings().GetStyleSettings();
1470 if (rRect
.Contains(GetPointerPosPixel()))
1472 vcl::RenderTools::DrawSelectionBackground(rRenderContext
, *this, rRect
, 2, false, false, false);
1474 aColor
= rStyleSettings
.GetDarkShadowColor();
1478 rRenderContext
.SetLineColor(rStyleSettings
.GetDarkShadowColor());
1479 rRenderContext
.SetFillColor(rStyleSettings
.GetDarkShadowColor());
1481 rRenderContext
.DrawRect(rRect
);
1483 aColor
= rStyleSettings
.GetFaceColor();
1486 AntialiasingFlags nAA
= rRenderContext
.GetAntialiasing();
1487 rRenderContext
.SetAntialiasing(nAA
| AntialiasingFlags::PixelSnapHairline
| AntialiasingFlags::Enable
);
1489 tools::Long nWidth
= rRect
.getOpenWidth();
1490 tools::Long nWidthHalf
= nWidth
/ 2;
1491 tools::Long nHeight
= rRect
.getOpenHeight();
1492 tools::Long nHeightHalf
= nHeight
/ 2;
1494 tools::Long nLeft
= rRect
.Left();
1495 tools::Long nRight
= rRect
.Right();
1496 tools::Long nTop
= rRect
.Top();
1497 tools::Long nBottom
= rRect
.Bottom();
1498 tools::Long nMargin
= 1;
1500 rRenderContext
.SetLineColor(aColor
);
1501 rRenderContext
.SetFillColor(aColor
);
1503 tools::Polygon
aPoly(3);
1507 tools::Long nCenter
= nLeft
+ nWidthHalf
;
1511 aPoly
.SetPoint(Point(nCenter
, nTop
+ nMargin
), 0);
1512 aPoly
.SetPoint(Point(nCenter
- nHeightHalf
, nBottom
- nMargin
), 1);
1513 aPoly
.SetPoint(Point(nCenter
- nHeightHalf
, nBottom
- nMargin
), 2);
1517 aPoly
.SetPoint(Point(nCenter
, nBottom
- nMargin
), 0);
1518 aPoly
.SetPoint(Point(nCenter
- nHeightHalf
, nTop
+ nMargin
), 1);
1519 aPoly
.SetPoint(Point(nCenter
+ nHeightHalf
, nTop
+ nMargin
), 2);
1521 rRenderContext
.DrawPolygon(aPoly
);
1525 tools::Long nCenter
= nTop
+ nHeightHalf
;
1529 aPoly
.SetPoint(Point(nLeft
+ nMargin
, nCenter
), 0);
1530 aPoly
.SetPoint(Point(nRight
- nMargin
, nCenter
- nWidthHalf
), 1);
1531 aPoly
.SetPoint(Point(nRight
- nMargin
, nCenter
+ nWidthHalf
), 2);
1535 aPoly
.SetPoint(Point(nRight
- nMargin
, nCenter
), 0);
1536 aPoly
.SetPoint(Point(nLeft
+ nMargin
, nCenter
- nWidthHalf
), 1);
1537 aPoly
.SetPoint(Point(nLeft
+ nMargin
, nCenter
+ nWidthHalf
), 2);
1539 rRenderContext
.DrawPolygon(aPoly
);
1542 rRenderContext
.SetAntialiasing(nAA
);
1545 void SplitWindow::ImplDrawFadeIn(vcl::RenderContext
& rRenderContext
)
1550 tools::Rectangle aTempRect
;
1551 ImplGetFadeInRect(aTempRect
);
1556 case WindowAlign::Top
:
1557 case WindowAlign::Left
:
1560 case WindowAlign::Bottom
:
1561 case WindowAlign::Right
:
1567 ImplDrawGrip(rRenderContext
, aTempRect
, (meAlign
== WindowAlign::Top
) || (meAlign
== WindowAlign::Bottom
), bLeft
);
1570 void SplitWindow::ImplDrawFadeOut(vcl::RenderContext
& rRenderContext
)
1575 tools::Rectangle aTempRect
;
1576 ImplGetFadeOutRect(aTempRect
);
1581 case WindowAlign::Bottom
:
1582 case WindowAlign::Right
:
1585 case WindowAlign::Top
:
1586 case WindowAlign::Left
:
1592 ImplDrawGrip(rRenderContext
, aTempRect
, (meAlign
== WindowAlign::Top
) || (meAlign
== WindowAlign::Bottom
), bLeft
);
1595 void SplitWindow::ImplStartSplit( const MouseEvent
& rMEvt
)
1597 Point aMousePosPixel
= rMEvt
.GetPosPixel();
1598 mnSplitTest
= ImplTestSplit( this, aMousePosPixel
, mnMouseOff
, &mpSplitSet
, mnSplitPos
);
1600 if ( !mnSplitTest
|| (mnSplitTest
& SPLIT_NOSPLIT
) )
1603 ImplSplitItem
* pSplitItem
;
1604 tools::Long nCurMaxSize
;
1607 mnMouseModifier
= rMEvt
.GetModifier();
1608 bPropSmaller
= (mnMouseModifier
& KEY_SHIFT
) && (o3tl::make_unsigned(mnSplitPos
+1) < mpSplitSet
->mvItems
.size());
1610 // here we can set the maximum size
1614 nCurMaxSize
= mnMaxSize
;
1617 Size aSize
= GetParent()->GetOutputSizePixel();
1619 nCurMaxSize
= aSize
.Height();
1621 nCurMaxSize
= aSize
.Width();
1624 if ( !mpSplitSet
->mvItems
.empty() )
1627 if ( (mpSplitSet
== mpMainSet
.get()) && mbBottomRight
)
1630 pSplitItem
= &mpSplitSet
->mvItems
[mnSplitPos
];
1631 maDragRect
.SetLeft( pSplitItem
->mnLeft
);
1632 maDragRect
.SetTop( pSplitItem
->mnTop
);
1633 maDragRect
.SetRight( pSplitItem
->mnLeft
+pSplitItem
->mnWidth
-1 );
1634 maDragRect
.SetBottom( pSplitItem
->mnTop
+pSplitItem
->mnHeight
-1 );
1636 if ( mnSplitTest
& SPLIT_HORZ
)
1639 maDragRect
.AdjustRight(mpSplitSet
->mnSplitSize
);
1641 maDragRect
.AdjustLeft( -(mpSplitSet
->mnSplitSize
) );
1646 maDragRect
.AdjustBottom(mpSplitSet
->mnSplitSize
);
1648 maDragRect
.AdjustTop( -(mpSplitSet
->mnSplitSize
) );
1653 tools::Long nTemp
= mnSplitPos
;
1656 pSplitItem
= &mpSplitSet
->mvItems
[nTemp
-1];
1657 if ( pSplitItem
->mbFixed
)
1661 if ( mnSplitTest
& SPLIT_HORZ
)
1664 maDragRect
.AdjustLeft( -(pSplitItem
->mnPixSize
) );
1666 maDragRect
.AdjustRight(pSplitItem
->mnPixSize
);
1671 maDragRect
.AdjustTop( -(pSplitItem
->mnPixSize
) );
1673 maDragRect
.AdjustBottom(pSplitItem
->mnPixSize
);
1680 if ( (mpSplitSet
== mpMainSet
.get()) && (mnWinStyle
& WB_SIZEABLE
) && !bPropSmaller
)
1685 maDragRect
.AdjustBottom(nCurMaxSize
-mnDY
-mnTopBorder
);
1687 maDragRect
.AdjustRight(nCurMaxSize
-mnDX
-mnLeftBorder
);
1692 maDragRect
.AdjustTop( -(nCurMaxSize
-mnDY
-mnBottomBorder
) );
1694 maDragRect
.AdjustLeft( -(nCurMaxSize
-mnDX
-mnRightBorder
) );
1699 std::vector
<ImplSplitItem
*>::size_type nTemp
= mnSplitPos
+1;
1700 while ( nTemp
< mpSplitSet
->mvItems
.size() )
1702 pSplitItem
= &mpSplitSet
->mvItems
[nTemp
];
1703 if ( pSplitItem
->mbFixed
)
1707 if ( mnSplitTest
& SPLIT_HORZ
)
1710 maDragRect
.AdjustRight(pSplitItem
->mnPixSize
);
1712 maDragRect
.AdjustLeft( -(pSplitItem
->mnPixSize
) );
1717 maDragRect
.AdjustBottom(pSplitItem
->mnPixSize
);
1719 maDragRect
.AdjustTop( -(pSplitItem
->mnPixSize
) );
1728 maDragRect
.SetLeft( mnLeftBorder
);
1729 maDragRect
.SetTop( mnTopBorder
);
1730 maDragRect
.SetRight( mnDX
-mnRightBorder
-1 );
1731 maDragRect
.SetBottom( mnDY
-mnBottomBorder
-1 );
1734 if ( mbBottomRight
)
1735 maDragRect
.AdjustTop( -(nCurMaxSize
-mnDY
-mnBottomBorder
) );
1737 maDragRect
.AdjustBottom(nCurMaxSize
-mnDY
-mnTopBorder
);
1741 if ( mbBottomRight
)
1742 maDragRect
.AdjustLeft( -(nCurMaxSize
-mnDX
-mnRightBorder
) );
1744 maDragRect
.AdjustRight(nCurMaxSize
-mnDX
-mnLeftBorder
);
1750 mbDragFull
= bool(GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Split
);
1752 ImplSplitMousePos( aMousePosPixel
);
1756 ImplDrawSplitTracking(aMousePosPixel
);
1760 std::vector
< ImplSplitItem
>& rItems
= mpSplitSet
->mvItems
;
1761 sal_uInt16 nItems
= mpSplitSet
->mvItems
.size();
1762 mpLastSizes
.reset(new tools::Long
[nItems
*2]);
1763 for ( sal_uInt16 i
= 0; i
< nItems
; i
++ )
1765 mpLastSizes
[i
*2] = rItems
[i
].mnSize
;
1766 mpLastSizes
[i
*2+1] = rItems
[i
].mnPixSize
;
1769 mnMStartPos
= mnMSplitPos
;
1771 PointerStyle eStyle
= PointerStyle::Arrow
;
1772 if ( mnSplitTest
& SPLIT_HORZ
)
1773 eStyle
= PointerStyle::HSplit
;
1774 else if ( mnSplitTest
& SPLIT_VERT
)
1775 eStyle
= PointerStyle::VSplit
;
1777 SetPointer( eStyle
);
1780 void SplitWindow::StartSplit()
1784 void SplitWindow::Split()
1786 maSplitHdl
.Call( this );
1789 void SplitWindow::SplitResize()
1793 void SplitWindow::FadeIn()
1797 void SplitWindow::FadeOut()
1801 void SplitWindow::MouseButtonDown( const MouseEvent
& rMEvt
)
1803 if ( !rMEvt
.IsLeft() || rMEvt
.IsMod2() )
1805 DockingWindow::MouseButtonDown( rMEvt
);
1809 Point aMousePosPixel
= rMEvt
.GetPosPixel();
1810 tools::Rectangle aTestRect
;
1812 mbFadeNoButtonMode
= false;
1814 ImplGetFadeOutRect( aTestRect
);
1815 if ( aTestRect
.Contains( aMousePosPixel
) )
1817 mbFadeOutDown
= true;
1818 mbFadeOutPressed
= true;
1823 ImplGetFadeInRect( aTestRect
, true );
1824 if ( aTestRect
.Contains( aMousePosPixel
) )
1826 mbFadeInDown
= true;
1827 mbFadeInPressed
= true;
1830 else if ( !aTestRect
.IsEmpty() && !(mnWinStyle
& WB_SIZEABLE
) )
1832 mbFadeNoButtonMode
= true;
1838 if ( mbFadeInDown
|| mbFadeOutDown
)
1841 ImplStartSplit( rMEvt
);
1844 void SplitWindow::MouseMove( const MouseEvent
& rMEvt
)
1849 Point aPos
= rMEvt
.GetPosPixel();
1851 ImplSplitSet
* pTempSplitSet
;
1852 sal_uInt16 nTempSplitPos
;
1853 sal_uInt16 nSplitTest
= ImplTestSplit( this, aPos
, nTemp
, &pTempSplitSet
, nTempSplitPos
);
1854 PointerStyle eStyle
= PointerStyle::Arrow
;
1855 tools::Rectangle aFadeInRect
;
1856 tools::Rectangle aFadeOutRect
;
1858 ImplGetFadeInRect( aFadeInRect
);
1859 ImplGetFadeOutRect( aFadeOutRect
);
1860 if ( !aFadeInRect
.Contains( aPos
) &&
1861 !aFadeOutRect
.Contains( aPos
) )
1863 if ( nSplitTest
&& !(nSplitTest
& SPLIT_NOSPLIT
) )
1865 if ( nSplitTest
& SPLIT_HORZ
)
1866 eStyle
= PointerStyle::HSplit
;
1867 else if ( nSplitTest
& SPLIT_VERT
)
1868 eStyle
= PointerStyle::VSplit
;
1872 SetPointer( eStyle
);
1875 void SplitWindow::Tracking( const TrackingEvent
& rTEvt
)
1877 Point aMousePosPixel
= rTEvt
.GetMouseEvent().GetPosPixel();
1881 if ( rTEvt
.IsTrackingEnded() )
1883 mbFadeInDown
= false;
1884 if ( mbFadeInPressed
)
1886 mbFadeInPressed
= false;
1889 if ( !rTEvt
.IsTrackingCanceled() )
1895 tools::Rectangle aTestRect
;
1896 ImplGetFadeInRect( aTestRect
, true );
1897 bool bNewPressed
= aTestRect
.Contains( aMousePosPixel
);
1898 if ( bNewPressed
!= mbFadeInPressed
)
1900 mbFadeInPressed
= bNewPressed
;
1905 else if ( mbFadeOutDown
)
1907 if ( rTEvt
.IsTrackingEnded() )
1909 mbFadeOutDown
= false;
1910 if ( mbFadeOutPressed
)
1912 mbFadeOutPressed
= false;
1915 if ( !rTEvt
.IsTrackingCanceled() )
1921 tools::Rectangle aTestRect
;
1922 ImplGetFadeOutRect( aTestRect
);
1923 bool bNewPressed
= aTestRect
.Contains( aMousePosPixel
);
1926 mbFadeOutPressed
= bNewPressed
;
1929 // We need a mouseevent with a position inside the button for the
1930 // ImplStartSplit function!
1931 MouseEvent aOrgMEvt
= rTEvt
.GetMouseEvent();
1932 MouseEvent
aNewMEvt( aTestRect
.Center(), aOrgMEvt
.GetClicks(),
1933 aOrgMEvt
.GetMode(), aOrgMEvt
.GetButtons(),
1934 aOrgMEvt
.GetModifier() );
1936 ImplStartSplit( aNewMEvt
);
1937 mbFadeOutDown
= false;
1943 ImplSplitMousePos( aMousePosPixel
);
1947 if ( rTEvt
.IsTrackingEnded() )
1949 if ( rTEvt
.IsTrackingCanceled() )
1951 std::vector
< ImplSplitItem
>& rItems
= mpSplitSet
->mvItems
;
1952 size_t nItems
= rItems
.size();
1953 for ( size_t i
= 0; i
< nItems
; i
++ )
1955 rItems
[i
].mnSize
= mpLastSizes
[i
*2];
1956 rItems
[i
].mnPixSize
= mpLastSizes
[i
*2+1];
1966 if ( rTEvt
.IsTrackingEnded() )
1969 bSplit
= !rTEvt
.IsTrackingCanceled();
1973 ImplDrawSplitTracking(aMousePosPixel
);
1980 bool bPropSmaller
= (mnMouseModifier
& KEY_SHIFT
) != 0;
1981 bool bPropGreater
= (mnMouseModifier
& KEY_MOD1
) != 0;
1982 tools::Long nDelta
= mnMSplitPos
-mnMStartPos
;
1984 if ( (mnSplitTest
& SPLIT_WINDOW
) && mpMainSet
->mvItems
.empty() )
1986 if ( (mpSplitSet
== mpMainSet
.get()) && mbBottomRight
)
1988 ImplSetWindowSize( nDelta
);
1992 tools::Long nNewSize
= mpSplitSet
->mvItems
[mnSplitPos
].mnPixSize
;
1993 if ( (mpSplitSet
== mpMainSet
.get()) && mbBottomRight
)
1997 SplitItem( mpSplitSet
->mvItems
[mnSplitPos
].mnId
, nNewSize
,
1998 bPropSmaller
, bPropGreater
);
2006 mnMStartPos
= mnMSplitPos
;
2010 if ( rTEvt
.IsTrackingEnded() )
2012 mpLastSizes
.reset();
2013 mpSplitSet
= nullptr;
2017 mnMouseModifier
= 0;
2024 bool SplitWindow::PreNotify( NotifyEvent
& rNEvt
)
2026 if( rNEvt
.GetType() == NotifyEventType::MOUSEMOVE
)
2028 const MouseEvent
* pMouseEvt
= rNEvt
.GetMouseEvent();
2029 if( pMouseEvt
&& !pMouseEvt
->GetButtons() && !pMouseEvt
->IsSynthetic() && !pMouseEvt
->IsModifierChanged() )
2031 // trigger redraw if mouse over state has changed
2032 tools::Rectangle aFadeInRect
;
2033 tools::Rectangle aFadeOutRect
;
2034 ImplGetFadeInRect( aFadeInRect
);
2035 ImplGetFadeOutRect( aFadeOutRect
);
2037 if ( aFadeInRect
.Contains( GetPointerPosPixel() ) != aFadeInRect
.Contains( GetLastPointerPosPixel() ) )
2038 Invalidate( aFadeInRect
);
2039 if ( aFadeOutRect
.Contains( GetPointerPosPixel() ) != aFadeOutRect
.Contains( GetLastPointerPosPixel() ) )
2040 Invalidate( aFadeOutRect
);
2042 if( pMouseEvt
->IsLeaveWindow() || pMouseEvt
->IsEnterWindow() )
2044 Invalidate( aFadeInRect
);
2045 Invalidate( aFadeOutRect
);
2049 return Window::PreNotify( rNEvt
);
2052 void SplitWindow::Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&)
2054 if (mnWinStyle
& WB_BORDER
)
2055 ImplDrawBorder(rRenderContext
);
2057 ImplDrawBorderLine(rRenderContext
);
2058 ImplDrawFadeOut(rRenderContext
);
2059 ImplDrawFadeIn(rRenderContext
);
2062 if (!(mnWinStyle
& WB_NOSPLITDRAW
))
2064 ImplDrawSplit(rRenderContext
, mpMainSet
.get(), mbHorz
, !mbBottomRight
);
2068 void SplitWindow::Resize()
2070 Size aSize
= GetOutputSizePixel();
2071 mnDX
= aSize
.Width();
2072 mnDY
= aSize
.Height();
2078 void SplitWindow::RequestHelp( const HelpEvent
& rHEvt
)
2080 // no keyboard help for splitwin
2081 if ( rHEvt
.GetMode() & (HelpEventMode::BALLOON
| HelpEventMode::QUICK
) && !rHEvt
.KeyboardActivated() )
2083 Point aMousePosPixel
= ScreenToOutputPixel( rHEvt
.GetMousePosPixel() );
2084 tools::Rectangle aHelpRect
;
2085 TranslateId pHelpResId
;
2087 ImplGetFadeInRect( aHelpRect
, true );
2088 if ( aHelpRect
.Contains( aMousePosPixel
) )
2089 pHelpResId
= SV_HELPTEXT_FADEIN
;
2092 ImplGetFadeOutRect( aHelpRect
);
2093 if ( aHelpRect
.Contains( aMousePosPixel
) )
2094 pHelpResId
= SV_HELPTEXT_FADEOUT
;
2100 Point aPt
= OutputToScreenPixel( aHelpRect
.TopLeft() );
2101 aHelpRect
.SetLeft( aPt
.X() );
2102 aHelpRect
.SetTop( aPt
.Y() );
2103 aPt
= OutputToScreenPixel( aHelpRect
.BottomRight() );
2104 aHelpRect
.SetRight( aPt
.X() );
2105 aHelpRect
.SetBottom( aPt
.Y() );
2107 // get and draw text
2108 OUString aStr
= VclResId(pHelpResId
);
2109 if ( rHEvt
.GetMode() & HelpEventMode::BALLOON
)
2110 Help::ShowBalloon( this, aHelpRect
.Center(), aHelpRect
, aStr
);
2112 Help::ShowQuickHelp( this, aHelpRect
, aStr
);
2117 DockingWindow::RequestHelp( rHEvt
);
2120 void SplitWindow::StateChanged( StateChangedType nType
)
2124 case StateChangedType::InitShow
:
2125 if ( IsUpdateMode() )
2128 case StateChangedType::UpdateMode
:
2129 if ( IsUpdateMode() && IsReallyShown() )
2132 case StateChangedType::ControlBackground
:
2139 DockingWindow::StateChanged( nType
);
2142 void SplitWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
2144 if ( (rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) &&
2145 (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
) )
2151 DockingWindow::DataChanged( rDCEvt
);
2154 void SplitWindow::InsertItem( sal_uInt16 nId
, vcl::Window
* pWindow
, tools::Long nSize
,
2155 sal_uInt16 nPos
, sal_uInt16 nIntoSetId
,
2156 SplitWindowItemFlags nBits
)
2159 sal_uInt16 nDbgDummy
;
2160 SAL_WARN_IF( ImplFindItem( mpMainSet
.get(), nId
, nDbgDummy
), "vcl", "SplitWindow::InsertItem() - Id already exists" );
2163 // Size has to be at least 1.
2167 ImplSplitSet
* pSet
= ImplFindSet( mpMainSet
.get(), nIntoSetId
);
2169 SAL_WARN_IF( !pSet
, "vcl", "SplitWindow::InsertItem() - Set not exists" );
2176 // Don't insert further than the end
2177 if ( nPos
> pSet
->mvItems
.size() )
2178 nPos
= pSet
->mvItems
.size();
2181 pSet
->mvItems
.emplace( pSet
->mvItems
.begin() + nPos
);
2184 ImplSplitItem
& aItem
= pSet
->mvItems
[nPos
];
2185 aItem
.mnSize
= nSize
;
2186 aItem
.mnPixSize
= 0;
2188 aItem
.mnBits
= nBits
;
2194 // New VclPtr reference
2195 aItem
.mpWindow
= pWindow
;
2196 aItem
.mpOrgParent
= pWindow
->GetParent();
2198 // Attach window to SplitWindow.
2200 pWindow
->SetParent( this );
2204 ImplSplitSet
* pNewSet
= new ImplSplitSet();
2205 pNewSet
->mnId
= nId
;
2206 pNewSet
->mnSplitSize
= pSet
->mnSplitSize
;
2208 aItem
.mpSet
.reset(pNewSet
);
2211 pSet
->mbCalcPix
= true;
2216 void SplitWindow::InsertItem( sal_uInt16 nId
, tools::Long nSize
,
2217 sal_uInt16 nPos
, sal_uInt16 nIntoSetId
,
2218 SplitWindowItemFlags nBits
)
2220 InsertItem( nId
, nullptr, nSize
, nPos
, nIntoSetId
, nBits
);
2223 void SplitWindow::RemoveItem( sal_uInt16 nId
)
2226 sal_uInt16 nDbgDummy
;
2227 SAL_WARN_IF( !ImplFindItem( mpMainSet
.get(), nId
, nDbgDummy
), "vcl", "SplitWindow::RemoveItem() - Id not found" );
2232 ImplSplitSet
* pSet
= ImplFindItem( mpMainSet
.get(), nId
, nPos
);
2237 ImplSplitItem
* pItem
= &pSet
->mvItems
[nPos
];
2238 VclPtr
<vcl::Window
> pWindow
= pItem
->mpWindow
;
2239 VclPtr
<vcl::Window
> pOrgParent
= pItem
->mpOrgParent
;
2241 // delete set if required
2243 pItem
->mpSet
.reset();
2246 pSet
->mbCalcPix
= true;
2247 pSet
->mvItems
.erase( pSet
->mvItems
.begin() + nPos
);
2251 // to have the least amounts of paints delete window only here
2256 pWindow
->SetParent( pOrgParent
);
2264 void SplitWindow::SplitItem( sal_uInt16 nId
, tools::Long nNewSize
,
2265 bool bPropSmall
, bool bPropGreat
)
2268 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
2273 size_t nItems
= pSet
->mvItems
.size();
2274 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
2276 // When there is an explicit minimum or maximum size then move nNewSize
2277 // into that range (when it is not yet already in it.)
2278 nNewSize
= ValidateSize(nNewSize
, rItems
[nPos
]);
2282 rItems
[nPos
].mnSize
= nNewSize
;
2286 tools::Long nDelta
= nNewSize
-rItems
[nPos
].mnPixSize
;
2290 // calculate area, which could be affected by splitting
2291 sal_uInt16 nMin
= 0;
2292 sal_uInt16 nMax
= nItems
;
2293 for (size_t i
= 0; i
< nItems
; ++i
)
2295 if ( rItems
[i
].mbFixed
)
2304 // treat TopSet different if the window is sizeable
2307 if ( (pSet
== mpMainSet
.get()) && (mnWinStyle
& WB_SIZEABLE
) )
2309 if ( nPos
< pSet
->mvItems
.size()-1 )
2311 if ( !((bPropSmall
&& bPropGreat
) ||
2312 ((nDelta
> 0) && bPropSmall
) ||
2313 ((nDelta
< 0) && bPropGreat
)) )
2329 else if ( nPos
>= nMax
)
2334 else if ( nPos
&& (nPos
>= pSet
->mvItems
.size()-1) )
2338 std::swap( bPropSmall
, bPropGreat
);
2342 // now splitt the windows
2349 tools::Long nTempDelta
= nDelta
;
2357 rItems
[n
].mnPixSize
++;
2364 while ( nTempDelta
);
2367 rItems
[nPos
+1].mnPixSize
-= nDelta
;
2379 if ( nDelta
&& rItems
[n
-1].mnPixSize
)
2381 rItems
[n
-1].mnPixSize
--;
2396 if ( rItems
[n
-1].mnPixSize
+nDelta
< 0 )
2398 nDelta
+= rItems
[n
-1].mnPixSize
;
2399 rItems
[n
-1].mnPixSize
= 0;
2403 rItems
[n
-1].mnPixSize
+= nDelta
;
2418 tools::Long nTempDelta
= nDelta
;
2426 rItems
[n
-1].mnPixSize
++;
2433 while ( nTempDelta
);
2436 rItems
[nPos
].mnPixSize
+= nDelta
;
2448 if ( nDelta
&& rItems
[n
].mnPixSize
)
2450 rItems
[n
].mnPixSize
--;
2465 if ( rItems
[n
].mnPixSize
-nDelta
< 0 )
2467 nDelta
-= rItems
[n
].mnPixSize
;
2468 rItems
[n
].mnPixSize
= 0;
2472 rItems
[n
].mnPixSize
-= nDelta
;
2482 // update original sizes
2483 ImplCalcLogSize( rItems
, nItems
);
2488 void SplitWindow::SetItemSize( sal_uInt16 nId
, tools::Long nNewSize
)
2491 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
2492 ImplSplitItem
* pItem
;
2497 // check if size is changed
2498 pItem
= &pSet
->mvItems
[nPos
];
2499 if ( pItem
->mnSize
!= nNewSize
)
2501 // set new size and re-calculate
2502 pItem
->mnSize
= nNewSize
;
2503 pSet
->mbCalcPix
= true;
2508 tools::Long
SplitWindow::GetItemSize( sal_uInt16 nId
) const
2511 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
2514 return pSet
->mvItems
[nPos
].mnSize
;
2519 tools::Long
SplitWindow::GetItemSize( sal_uInt16 nId
, SplitWindowItemFlags nBits
) const
2522 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
2526 if ( nBits
== pSet
->mvItems
[nPos
].mnBits
)
2527 return pSet
->mvItems
[nPos
].mnSize
;
2530 const_cast<SplitWindow
*>(this)->ImplCalcLayout();
2532 tools::Long nRelSize
= 0;
2533 tools::Long nPerSize
= 0;
2535 SplitWindowItemFlags nTempBits
;
2536 nItems
= pSet
->mvItems
.size();
2537 std::vector
< ImplSplitItem
>& rItems
= pSet
->mvItems
;
2538 for ( size_t i
= 0; i
< nItems
; i
++ )
2543 nTempBits
= rItems
[i
].mnBits
;
2544 if ( nTempBits
& SplitWindowItemFlags::RelativeSize
)
2545 nRelSize
+= rItems
[i
].mnPixSize
;
2546 else if ( nTempBits
& SplitWindowItemFlags::PercentSize
)
2547 nPerSize
+= rItems
[i
].mnPixSize
;
2549 nPerSize
+= nRelSize
;
2550 if ( nBits
& SplitWindowItemFlags::RelativeSize
)
2553 return (rItems
[nPos
].mnPixSize
+(nRelSize
/2))/nRelSize
;
2557 else if ( nBits
& SplitWindowItemFlags::PercentSize
)
2560 return (rItems
[nPos
].mnPixSize
*100)/nPerSize
;
2565 return rItems
[nPos
].mnPixSize
;
2572 void SplitWindow::SetItemSizeRange (sal_uInt16 nId
, const Range
& rRange
)
2575 ImplSplitSet
* pSet
= ImplFindItem(mpBaseSet
, nId
, nPos
);
2577 if (pSet
!= nullptr)
2579 pSet
->mvItems
[nPos
].mnMinSize
= rRange
.Min();
2580 pSet
->mvItems
[nPos
].mnMaxSize
= rRange
.Max();
2584 sal_uInt16
SplitWindow::GetSet( sal_uInt16 nId
) const
2587 ImplSplitSet
* pSet
= ImplFindItem( mpBaseSet
, nId
, nPos
);
2595 bool SplitWindow::IsItemValid( sal_uInt16 nId
) const
2598 ImplSplitSet
* pSet
= mpBaseSet
? ImplFindItem(mpBaseSet
, nId
, nPos
) : nullptr;
2600 return pSet
!= nullptr;
2603 sal_uInt16
SplitWindow::GetItemId( vcl::Window
* pWindow
) const
2605 return ImplFindItem( mpBaseSet
, pWindow
);
2608 sal_uInt16
SplitWindow::GetItemId( const Point
& rPos
) const
2610 return ImplFindItem( mpBaseSet
, rPos
, mbHorz
, !mbBottomRight
);
2613 sal_uInt16
SplitWindow::GetItemPos( sal_uInt16 nId
, sal_uInt16 nSetId
) const
2615 ImplSplitSet
* pSet
= ImplFindSet( mpBaseSet
, nSetId
);
2616 sal_uInt16 nPos
= SPLITWINDOW_ITEM_NOTFOUND
;
2620 for ( size_t i
= 0; i
< pSet
->mvItems
.size(); i
++ )
2622 if ( pSet
->mvItems
[i
].mnId
== nId
)
2633 sal_uInt16
SplitWindow::GetItemId( sal_uInt16 nPos
) const
2635 ImplSplitSet
* pSet
= ImplFindSet( mpBaseSet
, 0/*nSetId*/ );
2636 if ( pSet
&& (nPos
< pSet
->mvItems
.size()) )
2637 return pSet
->mvItems
[nPos
].mnId
;
2642 sal_uInt16
SplitWindow::GetItemCount( sal_uInt16 nSetId
) const
2644 ImplSplitSet
* pSet
= ImplFindSet( mpBaseSet
, nSetId
);
2646 return pSet
->mvItems
.size();
2651 void SplitWindow::ImplNewAlign()
2655 case WindowAlign::Top
:
2657 mbBottomRight
= false;
2659 case WindowAlign::Bottom
:
2661 mbBottomRight
= true;
2663 case WindowAlign::Left
:
2665 mbBottomRight
= false;
2667 case WindowAlign::Right
:
2669 mbBottomRight
= true;
2673 if ( mnWinStyle
& WB_BORDER
)
2675 ImplCalcBorder( meAlign
, mnLeftBorder
, mnTopBorder
,
2676 mnRightBorder
, mnBottomBorder
);
2679 if ( IsReallyVisible() && IsUpdateMode() )
2684 void SplitWindow::SetAlign( WindowAlign eNewAlign
)
2686 if ( meAlign
!= eNewAlign
)
2688 meAlign
= eNewAlign
;
2693 void SplitWindow::ShowFadeInHideButton()
2699 void SplitWindow::ShowFadeOutButton()
2705 tools::Long
SplitWindow::GetFadeInSize() const
2710 n
= mnTopBorder
+mnBottomBorder
;
2712 n
= mnLeftBorder
+mnRightBorder
;
2714 return n
+SPLITWIN_SPLITSIZE
+SPLITWIN_SPLITSIZEEX
-2;
2717 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */