LibreOffice Module vcl (master) 1
toolbox.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <vcl/toolbox.hxx>
21#include <vcl/event.hxx>
22#include <vcl/decoview.hxx>
24#include <vcl/svapp.hxx>
25#include <vcl/help.hxx>
26#include <vcl/mnemonic.hxx>
27#include <vcl/gradient.hxx>
28#include <vcl/layout.hxx>
29#include <vcl/menu.hxx>
30#include <vcl/settings.hxx>
31#include <vcl/ptrstyle.hxx>
32#include <bitmaps.hlst>
33#include <toolbarvalue.hxx>
34
35#include <tools/poly.hxx>
36#include <sal/log.hxx>
37#include <o3tl/string_view.hxx>
38#include <osl/diagnose.h>
39
40#include <accel.hxx>
41#include <svdata.hxx>
42#include <window.h>
43#include <toolbox.h>
44#include <spin.hxx>
45#if defined(_WIN32)
46#include <svsys.h>
47#endif
48
49#include <cstdlib>
50#include <map>
51#include <string_view>
52#include <vector>
53#include <math.h>
54
56
57#define SMALLBUTTON_HSIZE 7
58#define SMALLBUTTON_VSIZE 7
59
60#define SMALLBUTTON_OFF_NORMAL_X 3
61#define SMALLBUTTON_OFF_NORMAL_Y 3
62
63#define TB_TEXTOFFSET 2
64#define TB_IMAGETEXTOFFSET 3
65#define TB_LINESPACING 3
66#define TB_SPIN_SIZE 14
67#define TB_SPIN_OFFSET 2
68#define TB_BORDER_OFFSET1 4
69#define TB_BORDER_OFFSET2 2
70#define TB_MAXLINES 5
71#define TB_MAXNOSCROLL 32765
72
73#define TB_DRAGWIDTH 8 // the default width of the drag grip
74
75#define TB_CALCMODE_HORZ 1
76#define TB_CALCMODE_VERT 2
77#define TB_CALCMODE_FLOAT 3
78
79#define TB_WBLINESIZING (WB_SIZEABLE | WB_DOCKABLE | WB_SCROLL)
80
81#define DOCK_LINEHSIZE (sal_uInt16(0x0001))
82#define DOCK_LINEVSIZE (sal_uInt16(0x0002))
83#define DOCK_LINERIGHT (sal_uInt16(0x1000))
84#define DOCK_LINEBOTTOM (sal_uInt16(0x2000))
85#define DOCK_LINELEFT (sal_uInt16(0x4000))
86#define DOCK_LINETOP (sal_uInt16(0x8000))
87#define DOCK_LINEOFFSET 3
88
90{
91private:
97 sal_uInt16 mnLineMode;
98 ToolBox::ImplToolItems::size_type mnStartLines;
99
100 ImplTBDragMgr(const ImplTBDragMgr&) = delete;
102
103public:
105
106 void StartDragging( ToolBox* pDragBox, const Point& rPos, const tools::Rectangle& rRect, sal_uInt16 nLineMode );
107 void Dragging( const Point& rPos );
108 void EndDragging( bool bOK = true );
109 DECL_LINK( SelectHdl, Accelerator&, void );
110};
111
112
114{
115 ImplSVData* pSVData = ImplGetSVData();
116 if ( !pSVData->maCtrlData.mpTBDragMgr )
117 pSVData->maCtrlData.mpTBDragMgr = new ImplTBDragMgr;
118 return pSVData->maCtrlData.mpTBDragMgr;
119}
120
121int ToolBox::ImplGetDragWidth( const vcl::Window& rWindow, bool bHorz )
122{
123 return ImplGetDragWidth(*rWindow.GetOutDev(), bHorz);
124}
125int ToolBox::ImplGetDragWidth( const vcl::RenderContext& rRenderContext, bool bHorz )
126{
127 int nWidth = TB_DRAGWIDTH;
129 {
130
131 ImplControlValue aControlValue;
132 tools::Rectangle aContent, aBound;
133 tools::Rectangle aArea( Point(), rRenderContext.GetOutputSizePixel() );
134
137 aArea, ControlState::NONE, aControlValue, aBound, aContent) )
138 {
139 nWidth = bHorz ? aContent.GetWidth() : aContent.GetHeight();
140 }
141 }
142
143 // increase the hit area of the drag handle according to DPI scale factor
144 nWidth *= rRenderContext.GetDPIScaleFactor();
145
146 return nWidth;
147}
148
150{
151 return ToolBox::ImplGetDragWidth( *this, mbHorz );
152}
153
154static ButtonType determineButtonType( ImplToolItem const * pItem, ButtonType defaultType )
155{
156 ButtonType tmpButtonType = defaultType;
158 if ( nBits != ToolBoxItemBits::NONE ) // item has custom setting
159 {
160 tmpButtonType = ButtonType::SYMBOLTEXT;
161 if ( nBits == ToolBoxItemBits::TEXT_ONLY )
162 tmpButtonType = ButtonType::TEXT;
163 else if ( nBits == ToolBoxItemBits::ICON_ONLY )
164 tmpButtonType = ButtonType::SYMBOLONLY;
165 }
166 return tmpButtonType;
167}
168
170{
172 if( pWrapper )
173 {
174 if ( ImplIsFloatingMode() || pWrapper->IsLocked() )
175 pWrapper->SetDragArea( tools::Rectangle() );
176 else
177 {
180 else
182 }
183 }
184}
185
187 tools::Long& rRight, tools::Long& rBottom ) const
188{
190 {
191 // no border in floating mode
192 rLeft = rTop = rRight = rBottom = 0;
193 return;
194 }
195
197
198 // reserve DragArea only for dockable toolbars
199 int dragwidth = ( pWrapper && !pWrapper->IsLocked() ) ? ImplGetDragWidth() : 0;
200
201 // no shadow border for dockable toolbars and toolbars with WB_NOSHADOW bit set, e.g. Calc's formulabar
202 int borderwidth = ( pWrapper || mnWinStyle & WB_NOSHADOW ) ? 0 : 2;
203
204 if ( eAlign == WindowAlign::Top )
205 {
206 rLeft = borderwidth+dragwidth;
207 rTop = borderwidth;
208 rRight = borderwidth;
209 rBottom = 0;
210 }
211 else if ( eAlign == WindowAlign::Left )
212 {
213 rLeft = borderwidth;
214 rTop = borderwidth+dragwidth;
215 rRight = 0;
216 rBottom = borderwidth;
217 }
218 else if ( eAlign == WindowAlign::Bottom )
219 {
220 rLeft = borderwidth+dragwidth;
221 rTop = 0;
222 rRight = borderwidth;
223 rBottom = borderwidth;
224 }
225 else
226 {
227 rLeft = 0;
228 rTop = borderwidth+dragwidth;
229 rRight = borderwidth;
230 rBottom = borderwidth;
231 }
232}
233
235{
236 // remove any pending invalidates to avoid
237 // have them triggered when paint is locked (see mpData->mbIsPaintLocked)
238 // which would result in erasing the background only and not painting any items
239 // this must not be done when we're already in Paint()
240
241 // this is only required for transparent toolbars (see ImplDrawTransparentBackground() )
242 if( !IsBackground() && HasPaintEvent() && !IsInPaint() )
244}
245
247 const tools::Rectangle &aDragArea, int nDragWidth, WindowAlign eAlign, bool bHorz)
248{
249 bool bNativeOk = false;
251 const Size aSz( rRenderContext.GetOutputSizePixel() );
252 if (rRenderContext.IsNativeControlSupported(ControlType::Toolbar, ePart))
253 {
254 ToolbarValue aToolbarValue;
255 aToolbarValue.maGripRect = aDragArea;
256
257 tools::Rectangle aCtrlRegion(Point(), aSz);
258
259 bNativeOk = rRenderContext.DrawNativeControl( ControlType::Toolbar, ePart,
260 aCtrlRegion, ControlState::ENABLED, aToolbarValue, OUString() );
261 }
262
263 if( bNativeOk )
264 return;
265
266 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
267 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
268 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
269
270 float fScaleFactor = rRenderContext.GetDPIScaleFactor();
271
272 if (eAlign == WindowAlign::Top || eAlign == WindowAlign::Bottom)
273 {
274 int height = static_cast<int>(0.6 * aSz.Height() + 0.5);
275 int i = (aSz.Height() - height) / 2;
276 height += i;
277 while (i <= height)
278 {
279 int x = nDragWidth / 2;
280 rRenderContext.DrawEllipse(tools::Rectangle(Point(x, i), Size(2 * fScaleFactor, 2 * fScaleFactor)));
281 i += 4 * fScaleFactor;
282 }
283 }
284 else
285 {
286 int width = static_cast<int>(0.6 * aSz.Width() + 0.5);
287 int i = (aSz.Width() - width) / 2;
288 width += i;
289 while (i <= width)
290 {
291 int y = nDragWidth / 2;
292 rRenderContext.DrawEllipse(tools::Rectangle(Point(i, y), Size(2 * fScaleFactor, 2 * fScaleFactor)));
293 i += 4 * fScaleFactor;
294 }
295 }
296}
297
299{
301 if( pWrapper && !pWrapper->GetDragArea().IsEmpty() )
302 {
303 // execute pending paint requests
305 ImplDrawGrip( rRenderContext, pWrapper->GetDragArea(),
307 }
308}
309
311{
312 // draw a nice gradient
313
314 Color startCol, endCol;
315 const StyleSettings rSettings = rRenderContext.GetSettings().GetStyleSettings();
316
317 startCol = rSettings.GetFaceGradientColor();
318 endCol = rSettings.GetFaceColor();
319 if (rSettings.GetHighContrastMode())
320 // no 'extreme' gradient when high contrast
321 startCol = endCol;
322
323 Gradient g;
324 g.SetAngle(Degree10(mbHorz ? 0 : 900));
325 g.SetStyle(css::awt::GradientStyle_LINEAR);
326
327 g.SetStartColor(startCol);
328 g.SetEndColor(endCol);
329
330 bool bLineColor = rRenderContext.IsLineColor();
331 Color aOldCol = rRenderContext.GetLineColor();
332 rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor());
333
334 Size aFullSz(GetOutputSizePixel());
335 Size aLineSz(aFullSz);
336
337 // use the linesize only when floating
338 // full window height is used when docked (single line)
339 if (ImplIsFloatingMode())
340 {
341 tools::Long nLineSize;
342 if (mbHorz)
343 {
344 nLineSize = mnMaxItemHeight;
346 nLineSize = mnWinHeight;
347
348 aLineSz.setHeight( nLineSize );
349 }
350 else
351 {
352 nLineSize = mnMaxItemWidth;
353 aLineSz.setWidth( nLineSize );
354 }
355 }
356
357 tools::Long nLeft, nTop, nRight, nBottom;
358 ImplCalcBorder(meAlign, nLeft, nTop, nRight, nBottom);
359
360 Size aTopLineSz(aLineSz);
361 Size aBottomLineSz(aLineSz);
362
363 if (mnWinStyle & WB_BORDER)
364 {
365 if (mbHorz)
366 {
367 aTopLineSz.AdjustHeight(TB_BORDER_OFFSET2 + nTop );
368 aBottomLineSz.AdjustHeight(TB_BORDER_OFFSET2 + nBottom );
369
370 if (mnCurLines == 1)
371 aTopLineSz.AdjustHeight(TB_BORDER_OFFSET2 + nBottom );
372 }
373 else
374 {
375 aTopLineSz.AdjustWidth(TB_BORDER_OFFSET1 + nLeft );
376 aBottomLineSz.AdjustWidth(TB_BORDER_OFFSET1 + nRight );
377
378 if (mnCurLines == 1)
379 aTopLineSz.AdjustWidth(TB_BORDER_OFFSET1 + nLeft );
380 }
381 }
382
383 if (mbLineSpacing)
384 {
385 if (mbHorz)
386 {
388 if (mnCurLines > 1)
389 aTopLineSz.AdjustHeight(TB_LINESPACING );
390 }
391 else
392 {
393 aLineSz.AdjustWidth(TB_LINESPACING );
394 if (mnCurLines > 1)
395 aTopLineSz.AdjustWidth(TB_LINESPACING );
396 }
397 }
398
399 if (mbHorz)
400 {
401 tools::Long y = 0;
402
403 rRenderContext.DrawGradient(tools::Rectangle(0, y, aTopLineSz.Width(), y + aTopLineSz.Height()), g);
404 y += aTopLineSz.Height();
405
406 while (y < (mnDY - aBottomLineSz.Height()))
407 {
408 rRenderContext.DrawGradient(tools::Rectangle(0, y, aLineSz.Width(), y + aLineSz.Height()), g);
409 y += aLineSz.Height();
410 }
411
412 rRenderContext.DrawGradient(tools::Rectangle(0, y, aBottomLineSz.Width(), y + aBottomLineSz.Height()), g);
413 }
414 else
415 {
416 tools::Long x = 0;
417
418 rRenderContext.DrawGradient(tools::Rectangle(x, 0, x + aTopLineSz.Width(), aTopLineSz.Height()), g);
419 x += aTopLineSz.Width();
420
421 while (x < (mnDX - aBottomLineSz.Width()))
422 {
423 rRenderContext.DrawGradient(tools::Rectangle(x, 0, x + aLineSz.Width(), aLineSz.Height()), g);
424 x += aLineSz.Width();
425 }
426
427 rRenderContext.DrawGradient(tools::Rectangle( x, 0, x + aBottomLineSz.Width(), aBottomLineSz.Height()), g);
428 }
429
430 if( bLineColor )
431 rRenderContext.SetLineColor( aOldCol );
432
433}
434
436{
437 // use NWF
438 tools::Rectangle aCtrlRegion(Point(), GetOutputSizePixel());
439
441 aCtrlRegion, ControlState::ENABLED, ImplControlValue(), OUString() );
442}
443
445{
446 // just invalidate to trigger paint of the parent
447 const bool bOldPaintLock = mpData->mbIsPaintLocked;
448 mpData->mbIsPaintLocked = true;
449
450 // send an invalidate to the first opaque parent and invalidate the whole hierarchy from there (noclipchildren)
452
453 mpData->mbIsPaintLocked = bOldPaintLock;
454}
455
456void ToolBox::ImplDrawConstantBackground(vcl::RenderContext& rRenderContext, const vcl::Region &rRegion, bool bIsInPopupMode)
457{
458 // draw a constant color
459 if (!bIsInPopupMode)
460 {
461 // default background
462 rRenderContext.Erase(rRegion.GetBoundRect());
463 }
464 else
465 {
466 // use different color in popupmode
467 const StyleSettings rSettings = rRenderContext.GetSettings().GetStyleSettings();
468 Wallpaper aWallpaper(rSettings.GetFaceGradientColor());
469 rRenderContext.DrawWallpaper(rRegion.GetBoundRect(), aWallpaper);
470 }
471}
472
474{
475 // execute pending paint requests
477
479 bool bIsInPopupMode = ImplIsInPopupMode();
480
481 vcl::Region aPaintRegion(rRect);
482
483 // make sure we do not invalidate/erase too much
484 if (IsInPaint())
485 aPaintRegion.Intersect(GetOutDev()->GetActiveClipRegion());
486
487 rRenderContext.Push(vcl::PushFlags::CLIPREGION);
488 rRenderContext.IntersectClipRegion( aPaintRegion );
489
490 if (!pWrapper)
491 {
492 // no gradient for ordinary toolbars (not dockable)
493 if( !IsBackground() && !IsInPaint() )
494 ImplDrawTransparentBackground(aPaintRegion);
495 else
496 ImplDrawConstantBackground(rRenderContext, aPaintRegion, bIsInPopupMode);
497 }
498 else
499 {
500 // toolbars known to the dockingmanager will be drawn using NWF or a gradient
501 // docked toolbars are transparent and NWF is already used in the docking area which is their common background
502 // so NWF is used here for floating toolbars only
503 bool bNativeOk = false;
505 bNativeOk = ImplDrawNativeBackground(rRenderContext);
506 if (!bNativeOk)
507 {
509 const bool isHeader = GetAlign() == WindowAlign::Top && !rSetting.GetPersonaHeader().IsEmpty();
510 const bool isFooter = GetAlign() == WindowAlign::Bottom && !rSetting.GetPersonaFooter().IsEmpty();
511 if (!IsBackground() || isHeader || isFooter)
512 {
513 if (!IsInPaint())
514 ImplDrawTransparentBackground(aPaintRegion);
515 }
516 else
517 ImplDrawGradientBackground(rRenderContext);
518 }
519 }
520
521 // restore clip region
522 rRenderContext.Pop();
523}
524
525void ToolBox::ImplErase(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, bool bHighlight, bool bHasOpenPopup)
526{
527 // the background of non NWF buttons is painted in a constant color
528 // to have the same highlight color (transparency in DrawSelectionBackground())
529 // items with open popups will also painted using a constant color
530 if (!mpData->mbNativeButtons &&
531 (bHighlight || !(GetStyle() & WB_3DLOOK)))
532 {
533 if (GetStyle() & WB_3DLOOK)
534 {
536 rRenderContext.SetLineColor();
537 if (bHasOpenPopup)
538 // choose the same color as the popup will use
539 rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor());
540 else
541 rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetWindowColor());
542
543 rRenderContext.DrawRect(rRect);
544 rRenderContext.Pop();
545 }
546 else
547 ImplDrawBackground(rRenderContext, rRect);
548 }
549 else
550 ImplDrawBackground(rRenderContext, rRect);
551}
552
554{
555 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
556 tools::Long nDX = mnDX;
557 tools::Long nDY = mnDY;
558
560
561 // draw borders for ordinary toolbars only (not dockable), do not draw borders for toolbars with WB_NOSHADOW bit set,
562 // e.g. Calc's formulabar
563
564 if( pWrapper || mnWinStyle & WB_NOSHADOW )
565 return;
566
568 {
569 // draw bottom border
570 rRenderContext.SetLineColor( rStyleSettings.GetShadowColor() );
571 rRenderContext.DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
572 rRenderContext.SetLineColor( rStyleSettings.GetLightColor() );
573 rRenderContext.DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
574 }
575 else
576 {
577 // draw top border
578 rRenderContext.SetLineColor( rStyleSettings.GetShadowColor() );
579 rRenderContext.DrawLine( Point( 0, 0 ), Point( nDX-1, 0 ) );
580 rRenderContext.SetLineColor( rStyleSettings.GetLightColor() );
581 rRenderContext.DrawLine( Point( 0, 1 ), Point( nDX-1, 1 ) );
582
584 {
586 {
587 // draw left-bottom border
588 rRenderContext.SetLineColor( rStyleSettings.GetShadowColor() );
589 rRenderContext.DrawLine( Point( 0, 0 ), Point( 0, nDY-1 ) );
590 rRenderContext.DrawLine( Point( 0, nDY-2 ), Point( nDX-1, nDY-2 ) );
591 rRenderContext.SetLineColor( rStyleSettings.GetLightColor() );
592 rRenderContext.DrawLine( Point( 1, 1 ), Point( 1, nDY-3 ) );
593 rRenderContext.DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
594 }
595 else
596 {
597 // draw right-bottom border
598 rRenderContext.SetLineColor( rStyleSettings.GetShadowColor() );
599 rRenderContext.DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-3 ) );
600 rRenderContext.DrawLine( Point( 0, nDY-2 ), Point( nDX-2, nDY-2 ) );
601 rRenderContext.SetLineColor( rStyleSettings.GetLightColor() );
602 rRenderContext.DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
603 rRenderContext.DrawLine( Point( 0, nDY-1 ), Point( nDX-1, nDY-1 ) );
604 }
605 }
606 }
607
609 {
610 // draw right border
611 rRenderContext.SetLineColor( rStyleSettings.GetShadowColor() );
612 rRenderContext.DrawLine( Point( nDX-2, 0 ), Point( nDX-2, nDY-1 ) );
613 rRenderContext.SetLineColor( rStyleSettings.GetLightColor() );
614 rRenderContext.DrawLine( Point( nDX-1, 0 ), Point( nDX-1, nDY-1 ) );
615 }
616}
617
618static bool ImplIsFixedControl( const ImplToolItem *pItem )
619{
620 return ( pItem->mpWindow &&
621 (pItem->mbNonInteractiveWindow ||
624 pItem->mpWindow->GetType() == WindowType::GROUPBOX) );
625}
626
628{
629 for (auto & item : mpData->m_aItems)
630 {
631 if( item.IsClipped() )
632 return &item;
633 }
634 return nullptr;
635}
636
637Size ToolBox::ImplCalcSize( ImplToolItems::size_type nCalcLines, sal_uInt16 nCalcMode )
638{
639 sal_Int32 nMax;
640 tools::Long nLeft = 0;
641 tools::Long nTop = 0;
642 tools::Long nRight = 0;
643 tools::Long nBottom = 0;
644 Size aSize;
645 WindowAlign eOldAlign = meAlign;
646 bool bOldHorz = mbHorz;
647 bool bOldAssumeDocked = mpData->mbAssumeDocked;
648 bool bOldAssumeFloating = mpData->mbAssumeFloating;
649
650 if ( nCalcMode )
651 {
652 bool bOldFloatingMode = ImplIsFloatingMode();
653
654 mpData->mbAssumeDocked = false;
655 mpData->mbAssumeFloating = false;
656
657 if ( nCalcMode == TB_CALCMODE_HORZ )
658 {
659 mpData->mbAssumeDocked = true; // force non-floating mode during calculation
660 ImplCalcBorder( WindowAlign::Top, nLeft, nTop, nRight, nBottom );
661 mbHorz = true;
662 if ( mbHorz != bOldHorz )
664 }
665 else if ( nCalcMode == TB_CALCMODE_VERT )
666 {
667 mpData->mbAssumeDocked = true; // force non-floating mode during calculation
668 ImplCalcBorder( WindowAlign::Left, nLeft, nTop, nRight, nBottom );
669 mbHorz = false;
670 if ( mbHorz != bOldHorz )
672 }
673 else if ( nCalcMode == TB_CALCMODE_FLOAT )
674 {
675 mpData->mbAssumeFloating = true; // force non-floating mode during calculation
676 nLeft = nTop = nRight = nBottom = 0;
677 mbHorz = true;
678 if ( mbHorz != bOldHorz )
680 }
681
682 if ( (meAlign != eOldAlign) || (mbHorz != bOldHorz) ||
683 (ImplIsFloatingMode() != bOldFloatingMode ) )
684 mbCalc = true;
685 }
686 else
687 ImplCalcBorder( meAlign, nLeft, nTop, nRight, nBottom );
688
689 ImplCalcItem();
690
691 if( !nCalcMode && ImplIsFloatingMode() )
692 {
693 aSize = ImplCalcFloatSize( nCalcLines );
694 }
695 else
696 {
697 if ( mbHorz )
698 {
700 aSize.setHeight( nCalcLines * mnWinHeight );
701 else
702 aSize.setHeight( nCalcLines * mnMaxItemHeight );
703
704 if ( mbLineSpacing )
705 aSize.AdjustHeight((nCalcLines-1)*TB_LINESPACING );
706
707 if ( mnWinStyle & WB_BORDER )
708 aSize.AdjustHeight((TB_BORDER_OFFSET2*2) + nTop + nBottom );
709
710 nMax = 0;
712 if ( nMax )
713 aSize.AdjustWidth(nMax );
714
715 if ( mnWinStyle & WB_BORDER )
716 aSize.AdjustWidth((TB_BORDER_OFFSET1*2) + nLeft + nRight );
717 }
718 else
719 {
720 aSize.setWidth( nCalcLines * mnMaxItemWidth );
721
722 if ( mbLineSpacing )
723 aSize.AdjustWidth((nCalcLines-1)*TB_LINESPACING );
724
725 if ( mnWinStyle & WB_BORDER )
726 aSize.AdjustWidth((TB_BORDER_OFFSET2*2) + nLeft + nRight );
727
728 nMax = 0;
730 if ( nMax )
731 aSize.AdjustHeight(nMax );
732
733 if ( mnWinStyle & WB_BORDER )
734 aSize.AdjustHeight((TB_BORDER_OFFSET1*2) + nTop + nBottom );
735 }
736 }
737 // restore previous values
738 if ( nCalcMode )
739 {
740 mpData->mbAssumeDocked = bOldAssumeDocked;
741 mpData->mbAssumeFloating = bOldAssumeFloating;
742 if ( (meAlign != eOldAlign) || (mbHorz != bOldHorz) )
743 {
744 meAlign = eOldAlign;
745 mbHorz = bOldHorz;
746 mbCalc = true;
747 }
748 }
749
750 return aSize;
751}
752
754{
755 if ( !maFloatSizes.empty() )
756 return;
757
758 // calculate the minimal size, i.e. where the biggest item just fits
759 tools::Long nCalcSize = 0;
760
761 for (auto const& item : mpData->m_aItems)
762 {
763 if ( item.mbVisible )
764 {
765 if ( item.mpWindow )
766 {
767 tools::Long nTempSize = item.mpWindow->GetSizePixel().Width();
768 if ( nTempSize > nCalcSize )
769 nCalcSize = nTempSize;
770 }
771 else
772 {
773 if( item.maItemSize.Width() > nCalcSize )
774 nCalcSize = item.maItemSize.Width();
775 }
776 }
777 }
778
779 // calc an upper bound for ImplCalcBreaks below
780 tools::Long upperBoundWidth = nCalcSize * mpData->m_aItems.size();
781
782 ImplToolItems::size_type nLines;
783 ImplToolItems::size_type nCalcLines;
784 ImplToolItems::size_type nTempLines;
785 sal_Int32 nMaxLineWidth;
786 nCalcLines = ImplCalcBreaks( nCalcSize, &nMaxLineWidth, true );
787
788 maFloatSizes.reserve( nCalcLines );
789
790 nTempLines = nLines = nCalcLines;
791 while ( nLines )
792 {
793 tools::Long nHeight = ImplCalcSize( nTempLines, TB_CALCMODE_FLOAT ).Height();
794
795 ImplToolSize aSize;
796 aSize.mnWidth = nMaxLineWidth+(TB_BORDER_OFFSET1*2);
797 aSize.mnHeight = nHeight;
798 aSize.mnLines = nTempLines;
799 maFloatSizes.push_back( aSize );
800 nLines--;
801 if ( nLines )
802 {
803 do
804 {
805 nCalcSize += mnMaxItemWidth;
806 nTempLines = ImplCalcBreaks( nCalcSize, &nMaxLineWidth, true );
807 }
808 while ((nCalcSize < upperBoundWidth) && (nLines < nTempLines)); // implies nTempLines>1
809 if ( nTempLines < nLines )
810 nLines = nTempLines;
811 }
812 }
813}
814
815Size ToolBox::ImplCalcFloatSize( ImplToolItems::size_type& rLines )
816{
818
819 if ( !rLines )
820 {
821 rLines = mnFloatLines;
822 if ( !rLines )
823 rLines = mnLines;
824 }
825
826 sal_uInt16 i = 0;
827 while ( i + 1u < maFloatSizes.size() && rLines < maFloatSizes[i].mnLines )
828 {
829 i++;
830 }
831
833 rLines = maFloatSizes[i].mnLines;
834
835 return aSize;
836}
837
838void ToolBox::ImplCalcMinMaxFloatSize( Size& rMinSize, Size& rMaxSize )
839{
841
842 sal_uInt16 i = 0;
845 while ( ++i < maFloatSizes.size() )
846 {
847 if( maFloatSizes[i].mnWidth < rMinSize.Width() )
848 rMinSize.setWidth( maFloatSizes[i].mnWidth );
849 if( maFloatSizes[i].mnHeight < rMinSize.Height() )
850 rMinSize.setHeight( maFloatSizes[i].mnHeight );
851
852 if( maFloatSizes[i].mnWidth > rMaxSize.Width() )
853 rMaxSize.setWidth( maFloatSizes[i].mnWidth );
854 if( maFloatSizes[i].mnHeight > rMaxSize.Height() )
855 rMaxSize.setHeight( maFloatSizes[i].mnHeight );
856 }
857}
858
860{
862 Size aMinSize, aMaxSize;
863 ImplCalcMinMaxFloatSize( aMinSize, aMaxSize );
864 if( pWrapper )
865 {
866 pWrapper->SetMinOutputSizePixel( aMinSize );
867 pWrapper->SetMaxOutputSizePixel( aMaxSize );
869 }
870 else
871 {
872 // TODO: change SetMinOutputSizePixel to be not inline
873 SetMinOutputSizePixel( aMinSize );
874 SetMaxOutputSizePixel( aMaxSize );
875 }
876}
877
878ToolBox::ImplToolItems::size_type ToolBox::ImplCalcLines( tools::Long nToolSize ) const
879{
880 tools::Long nLineHeight;
881
882 if ( mbHorz )
883 {
885 nLineHeight = mnWinHeight;
886 else
887 nLineHeight = mnMaxItemHeight;
888 }
889 else
890 nLineHeight = mnMaxItemWidth;
891
892 if ( mnWinStyle & WB_BORDER )
893 nToolSize -= TB_BORDER_OFFSET2*2;
894
895 if ( mbLineSpacing )
896 {
897 nLineHeight += TB_LINESPACING;
898 nToolSize += TB_LINESPACING;
899 }
900
901 // #i91917# always report at least one line
902 tools::Long nLines = nToolSize/nLineHeight;
903 if( nLines < 1 )
904 nLines = 1;
905
906 return nLines;
907}
908
909sal_uInt16 ToolBox::ImplTestLineSize( const Point& rPos ) const
910{
911 if ( !ImplIsFloatingMode() &&
912 (!mbScroll || (mnLines > 1) || (mnCurLines > mnVisLines)) )
913 {
914 WindowAlign eAlign = GetAlign();
915
916 if ( eAlign == WindowAlign::Left )
917 {
918 if ( rPos.X() > mnDX-DOCK_LINEOFFSET )
920 }
921 else if ( eAlign == WindowAlign::Top )
922 {
923 if ( rPos.Y() > mnDY-DOCK_LINEOFFSET )
925 }
926 else if ( eAlign == WindowAlign::Right )
927 {
928 if ( rPos.X() < DOCK_LINEOFFSET )
930 }
931 else if ( eAlign == WindowAlign::Bottom )
932 {
933 if ( rPos.Y() < DOCK_LINEOFFSET )
935 }
936 }
937
938 return 0;
939}
940
941void ToolBox::ImplLineSizing( const Point& rPos, tools::Rectangle& rRect, sal_uInt16 nLineMode )
942{
943 bool bHorz;
944 tools::Long nOneLineSize;
945 tools::Long nCurSize;
946 tools::Long nMaxSize;
947 tools::Long nSize;
948 Size aSize;
949
950 if ( nLineMode & DOCK_LINERIGHT )
951 {
952 nCurSize = rPos.X() - rRect.Left();
953 bHorz = false;
954 }
955 else if ( nLineMode & DOCK_LINEBOTTOM )
956 {
957 nCurSize = rPos.Y() - rRect.Top();
958 bHorz = true;
959 }
960 else if ( nLineMode & DOCK_LINELEFT )
961 {
962 nCurSize = rRect.Right() - rPos.X();
963 bHorz = false;
964 }
965 else if ( nLineMode & DOCK_LINETOP )
966 {
967 nCurSize = rRect.Bottom() - rPos.Y();
968 bHorz = true;
969 }
970 else {
971 OSL_FAIL( "ImplLineSizing: Trailing else" );
972 nCurSize = 0;
973 bHorz = false;
974 }
975
976 Size aWinSize = GetSizePixel();
977 ImplToolItems::size_type nMaxLines = std::max(mnLines, mnCurLines);
978 if ( nMaxLines > TB_MAXLINES )
979 nMaxLines = TB_MAXLINES;
980 if ( bHorz )
981 {
982 nOneLineSize = ImplCalcSize( 1 ).Height();
983 nMaxSize = - 20;
984 if ( nMaxSize < aWinSize.Height() )
985 nMaxSize = aWinSize.Height();
986 }
987 else
988 {
989 nOneLineSize = ImplCalcSize( 1 ).Width();
990 nMaxSize = - 20;
991 if ( nMaxSize < aWinSize.Width() )
992 nMaxSize = aWinSize.Width();
993 }
994
995 ImplToolItems::size_type i = 1;
996 if ( nCurSize <= nOneLineSize )
997 nSize = nOneLineSize;
998 else
999 {
1000 nSize = 0;
1001 while ( (nSize < nCurSize) && (i < nMaxLines) )
1002 {
1003 i++;
1004 aSize = ImplCalcSize( i );
1005 if ( bHorz )
1006 nSize = aSize.Height();
1007 else
1008 nSize = aSize.Width();
1009 if ( nSize > nMaxSize )
1010 {
1011 i--;
1012 aSize = ImplCalcSize( i );
1013 if ( bHorz )
1014 nSize = aSize.Height();
1015 else
1016 nSize = aSize.Width();
1017 break;
1018 }
1019 }
1020 }
1021
1022 if ( nLineMode & DOCK_LINERIGHT )
1023 rRect.SetRight( rRect.Left()+nSize-1 );
1024 else if ( nLineMode & DOCK_LINEBOTTOM )
1025 rRect.SetBottom( rRect.Top()+nSize-1 );
1026 else if ( nLineMode & DOCK_LINELEFT )
1027 rRect.SetLeft( rRect.Right()-nSize );
1028 else
1029 rRect.SetTop( rRect.Bottom()-nSize );
1030
1031 mnDockLines = i;
1032}
1033
1035 : mpDragBox(nullptr)
1036 , mnLineMode(0)
1037 , mnStartLines(0)
1038{
1041 maAccel.SetSelectHdl( LINK( this, ImplTBDragMgr, SelectHdl ) );
1042}
1043
1045 const Point& rPos, const tools::Rectangle& rRect,
1046 sal_uInt16 nDragLineMode )
1047{
1048 mpDragBox = pToolBox;
1049 pToolBox->CaptureMouse();
1050 pToolBox->mbDragging = true;
1052
1053 mnLineMode = nDragLineMode;
1054 mnStartLines = pToolBox->mnDockLines;
1055
1056 // calculate MouseOffset
1057 maMouseOff.setX( rRect.Left() - rPos.X() );
1058 maMouseOff.setY( rRect.Top() - rPos.Y() );
1059 maRect = rRect;
1060 maStartRect = rRect;
1061 pToolBox->ShowTracking( maRect );
1062}
1063
1065{
1068 maRect.Move( aOff.X(), aOff.Y() );
1069 mpDragBox->Docking( rPos, maRect );
1070 maRect.Move( -aOff.X(), -aOff.Y() );
1072}
1073
1075{
1079 mpDragBox->mbDragging = false;
1081
1082 if ( !bOK )
1083 {
1085 mpDragBox->EndDocking( maStartRect, false );
1086 }
1087 else
1088 mpDragBox->EndDocking( maRect, false );
1089 mnStartLines = 0;
1090
1091 mpDragBox = nullptr;
1092}
1093
1094IMPL_LINK( ImplTBDragMgr, SelectHdl, Accelerator&, rAccel, void )
1095{
1096 if ( rAccel.GetCurItemId() == KEY_ESCAPE )
1097 EndDragging( false );
1098 else
1099 EndDragging();
1100}
1101
1103{
1104 // initialize variables
1105 ImplGetWindowImpl()->mbToolBox = true;
1106 mpData.reset(new ImplToolBoxPrivateData);
1107
1108 mpFloatWin = nullptr;
1109 mnDX = 0;
1110 mnDY = 0;
1111 mnMaxItemWidth = 0;
1112 mnMaxItemHeight = 0;
1113 mnWinHeight = 0;
1114 mnLeftBorder = 0;
1115 mnTopBorder = 0;
1116 mnRightBorder = 0;
1117 mnBottomBorder = 0;
1118 mnLastResizeDY = 0;
1123 mnLines = 1;
1124 mnCurLine = 1;
1125 mnCurLines = 1;
1126 mnVisLines = 1;
1127 mnFloatLines = 0;
1128 mnDockLines = 0;
1129 mnMouseModifier = 0;
1130 mbDrag = false;
1131 mbUpper = false;
1132 mbLower = false;
1133 mbIn = false;
1134 mbCalc = true;
1135 mbFormat = false;
1136 mbFullPaint = false;
1137 mbHorz = true;
1138 mbScroll = false;
1139 mbLastFloatMode = false;
1140 mbCustomize = false;
1141 mbDragging = false;
1142 mbIsKeyEvent = false;
1143 mbChangingHighlight = false;
1144 mbLineSpacing = false;
1145 mbIsArranged = false;
1150 mnWinStyle = 0;
1154 mnActivateCount = 0;
1155
1156 mpIdle.reset(new Idle("vcl::ToolBox maIdle update"));
1157 mpIdle->SetPriority( TaskPriority::RESIZE );
1158 mpIdle->SetInvokeHandler( LINK( this, ToolBox, ImplUpdateHdl ) );
1159
1160 // set timeout and handler for dropdown items
1161 mpData->maDropdownTimer.SetTimeout( 250 );
1162 mpData->maDropdownTimer.SetInvokeHandler( LINK( this, ToolBox, ImplDropdownLongClickHdl ) );
1163}
1164
1165void ToolBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
1166{
1167 // initialize variables
1168 mbScroll = (nStyle & WB_SCROLL) != 0;
1169 mnWinStyle = nStyle;
1170
1171 DockingWindow::ImplInit( pParent, nStyle & ~WB_BORDER );
1172
1173 // dockingwindow's ImplInit removes some bits, so restore them here to allow keyboard handling for toolbars
1174 ImplGetWindowImpl()->mnStyle |= WB_TABSTOP|WB_NODIALOGCONTROL; // always set WB_TABSTOP for ToolBars
1175 ImplGetWindowImpl()->mnStyle &= ~WB_DIALOGCONTROL;
1176
1177 ImplInitSettings(true, true, true);
1178}
1179
1180void ToolBox::ApplyForegroundSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings)
1181{
1182 Color aColor;
1183 if (IsControlForeground())
1184 aColor = GetControlForeground();
1185 else if (Window::GetStyle() & WB_3DLOOK)
1186 aColor = rStyleSettings.GetButtonTextColor();
1187 else
1188 aColor = rStyleSettings.GetWindowTextColor();
1189 rRenderContext.SetTextColor(aColor);
1190 rRenderContext.SetTextFillColor();
1191}
1192
1193void ToolBox::ApplyBackgroundSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings)
1194{
1195 if (IsControlBackground())
1196 {
1197 rRenderContext.SetBackground(GetControlBackground());
1198 SetPaintTransparent(false);
1200 }
1201 else
1202 {
1204 || (GetAlign() == WindowAlign::Top && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty())
1205 || (GetAlign() == WindowAlign::Bottom && !Application::GetSettings().GetStyleSettings().GetPersonaFooter().IsEmpty()))
1206 {
1207 rRenderContext.SetBackground();
1208 rRenderContext.SetTextColor(rStyleSettings.GetToolTextColor());
1209 SetPaintTransparent(true);
1211 mpData->maDisplayBackground = Wallpaper(rStyleSettings.GetFaceColor());
1212 }
1213 else
1214 {
1215 Color aColor;
1216 if (Window::GetStyle() & WB_3DLOOK)
1217 aColor = rStyleSettings.GetFaceColor();
1218 else
1219 aColor = rStyleSettings.GetWindowColor();
1220 rRenderContext.SetBackground(aColor);
1221 SetPaintTransparent(false);
1223 }
1224 }
1225}
1226
1228{
1229 mpData->mbNativeButtons = rRenderContext.IsNativeControlSupported(ControlType::Toolbar, ControlPart::Button);
1230
1231 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1232
1233 ApplyControlFont(rRenderContext, rStyleSettings.GetToolFont());
1234 ApplyForegroundSettings(rRenderContext, rStyleSettings);
1235 ApplyBackgroundSettings(rRenderContext, rStyleSettings);
1236}
1237
1238void ToolBox::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
1239{
1241
1242 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1243
1244 if (bFont)
1245 ApplyControlFont(*GetOutDev(), rStyleSettings.GetToolFont());
1246 if (bForeground || bFont)
1247 ApplyForegroundSettings(*GetOutDev(), rStyleSettings);
1248 if (bBackground)
1249 {
1250 ApplyBackgroundSettings(*GetOutDev(), rStyleSettings);
1252 }
1253}
1254
1256{
1258 mpDialogParent = nullptr;
1259 ImplInit(pParent, nBits);
1260 mbIsDeferredInit = false;
1261}
1262
1264{
1265 Window::queue_resize(eReason);
1266}
1267
1269 DockingWindow( WindowType::TOOLBOX, "vcl::ToolBox maLayoutIdle" )
1270{
1272 ImplInit( pParent, nStyle );
1273}
1274
1275ToolBox::ToolBox(vcl::Window* pParent, const OUString& rID,
1276 const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame)
1277 : DockingWindow(WindowType::TOOLBOX, "vcl::ToolBox maLayoutIdle")
1278{
1280
1281 loadUI(pParent, rID, rUIXMLDescription, rFrame);
1282
1283 // calculate size of floating windows and switch if the
1284 // toolbox is initially in floating mode
1285 if ( ImplIsFloatingMode() )
1286 mbHorz = true;
1287 else
1288 Resize();
1289
1290 if (!(GetStyle() & WB_HIDE))
1291 Show();
1292}
1293
1295{
1296 disposeOnce();
1297}
1298
1300{
1301 // #103005# make sure our activate/deactivate balance is right
1302 while( mnActivateCount > 0 )
1303 Deactivate();
1304
1305 // terminate popupmode if the floating window is
1306 // still connected
1307 if ( mpFloatWin )
1309 mpFloatWin = nullptr;
1310
1311 // delete private data
1312 mpData.reset();
1313
1314 ImplSVData* pSVData = ImplGetSVData();
1315 delete pSVData->maCtrlData.mpTBDragMgr;
1316 pSVData->maCtrlData.mpTBDragMgr = nullptr;
1317
1318 mpFloatWin.clear();
1319
1320 mpIdle.reset();
1321
1323}
1324
1326{
1327 if (!mpData)
1328 return nullptr;
1329
1330 for (auto & item : mpData->m_aItems)
1331 {
1332 if ( item.mnId == nItemId )
1333 return &item;
1334 }
1335
1336 return nullptr;
1337}
1338
1339static void ImplAddButtonBorder( tools::Long &rWidth, tools::Long& rHeight, bool bNativeButtons )
1340{
1341 rWidth += SMALLBUTTON_HSIZE;
1342 rHeight += SMALLBUTTON_VSIZE;
1343
1344 if( bNativeButtons )
1345 {
1346 // give more border space for rounded buttons
1347 rWidth += 2;
1348 rHeight += 4;
1349 }
1350}
1351
1353{
1354 // recalc required ?
1355 if ( !mbCalc )
1356 return false;
1357
1359 float fScaleFactor = pDefault ? pDefault->GetDPIScaleFactor() : 1.0;
1360
1361 tools::Long nDefWidth;
1362 tools::Long nDefHeight;
1363 tools::Long nMaxWidth = 0;
1364 tools::Long nMaxHeight = 0;
1365 tools::Long nMinWidth = 6;
1366 tools::Long nMinHeight = 6;
1367 tools::Long nDropDownArrowWidth = TB_DROPDOWNARROWWIDTH * fScaleFactor;
1368#ifdef IOS
1369 nDropDownArrowWidth *= 3;
1370#endif
1371
1372 // set defaults if image or text is needed but empty
1373 nDefWidth = GetDefaultImageSize().Width();
1374 nDefHeight = GetDefaultImageSize().Height();
1375
1376 mnWinHeight = 0;
1377 // determine minimum size necessary in NWF
1378 {
1379 tools::Rectangle aRect( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
1380 tools::Rectangle aReg( aRect );
1381 ImplControlValue aVal;
1382 tools::Rectangle aNativeBounds, aNativeContent;
1384 {
1386 aReg,
1388 aVal,
1389 aNativeBounds, aNativeContent ) )
1390 {
1391 aRect = aNativeBounds;
1392 if( aRect.GetWidth() > nMinWidth )
1393 nMinWidth = aRect.GetWidth();
1394 if( aRect.GetHeight() > nMinHeight )
1395 nMinHeight = aRect.GetHeight();
1396 if( nDropDownArrowWidth < nMinWidth )
1397 nDropDownArrowWidth = nMinWidth;
1398 if( nMinWidth > mpData->mnMenuButtonWidth )
1399 mpData->mnMenuButtonWidth = nMinWidth;
1400 else if( nMinWidth < TB_MENUBUTTON_SIZE )
1401 mpData->mnMenuButtonWidth = TB_MENUBUTTON_SIZE;
1402 }
1403 }
1404
1405 // also calculate the area for comboboxes, drop down list boxes and spinfields
1406 // as these are often inserted into toolboxes; set mnWinHeight to the
1407 // greater of those values to prevent toolbar flickering (#i103385#)
1408 aRect = tools::Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
1409 aReg = aRect;
1411 aReg,
1413 aVal,
1414 aNativeBounds, aNativeContent ) )
1415 {
1416 aRect = aNativeBounds;
1417 if( aRect.GetHeight() > mnWinHeight )
1418 mnWinHeight = aRect.GetHeight();
1419 }
1420 aRect = tools::Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
1421 aReg = aRect;
1423 aReg,
1425 aVal,
1426 aNativeBounds, aNativeContent ) )
1427 {
1428 aRect = aNativeBounds;
1429 if( aRect.GetHeight() > mnWinHeight )
1430 mnWinHeight = aRect.GetHeight();
1431 }
1432 aRect = tools::Rectangle( Point( 0, 0 ), Size( nMinWidth, nMinHeight ) );
1433 aReg = aRect;
1435 aReg,
1437 aVal,
1438 aNativeBounds, aNativeContent ) )
1439 {
1440 aRect = aNativeBounds;
1441 if( aRect.GetHeight() > mnWinHeight )
1442 mnWinHeight = aRect.GetHeight();
1443 }
1444 }
1445
1446 if ( ! mpData->m_aItems.empty() )
1447 {
1448 for (auto & item : mpData->m_aItems)
1449 {
1450 item.mbVisibleText = false; // indicates if text will definitely be drawn, influences dropdown pos
1451
1452 if ( item.meType == ToolBoxItemType::BUTTON )
1453 {
1454 bool bImage;
1455 bool bText;
1456
1457 // check if image and/or text exists
1458 bImage = !!item.maImage;
1459 bText = !item.maText.isEmpty();
1460 ButtonType tmpButtonType = determineButtonType( &item, meButtonType ); // default to toolbox setting
1461 if ( bImage || bText )
1462 {
1463
1464 item.mbEmptyBtn = false;
1465
1466 if ( tmpButtonType == ButtonType::SYMBOLONLY )
1467 {
1468 // we're drawing images only
1469 if ( bImage || !bText )
1470 {
1471 item.maItemSize = item.maImage.GetSizePixel();
1472 }
1473 else
1474 {
1475 item.maItemSize = Size( GetOutDev()->GetCtrlTextWidth( item.maText )+TB_TEXTOFFSET,
1476 GetTextHeight() );
1477 item.mbVisibleText = true;
1478 }
1479 }
1480 else if ( tmpButtonType == ButtonType::TEXT )
1481 {
1482 // we're drawing text only
1483 if ( bText || !bImage )
1484 {
1485 item.maItemSize = Size( GetOutDev()->GetCtrlTextWidth( item.maText )+TB_TEXTOFFSET,
1486 GetTextHeight() );
1487 item.mbVisibleText = true;
1488 }
1489 else
1490 {
1491 item.maItemSize = item.maImage.GetSizePixel();
1492 }
1493 }
1494 else
1495 {
1496 // we're drawing images and text
1497 item.maItemSize.setWidth( bText ? GetOutDev()->GetCtrlTextWidth( item.maText )+TB_TEXTOFFSET : 0 );
1498 item.maItemSize.setHeight( bText ? GetTextHeight() : 0 );
1499
1501 {
1502 // leave space between image and text
1503 if( bText )
1504 item.maItemSize.AdjustWidth(TB_IMAGETEXTOFFSET );
1505
1506 // image and text side by side
1507 item.maItemSize.AdjustWidth(item.maImage.GetSizePixel().Width() );
1508 if ( item.maImage.GetSizePixel().Height() > item.maItemSize.Height() )
1509 item.maItemSize.setHeight( item.maImage.GetSizePixel().Height() );
1510 }
1511 else
1512 {
1513 // leave space between image and text
1514 if( bText )
1515 item.maItemSize.AdjustHeight(TB_IMAGETEXTOFFSET );
1516
1517 // text below image
1518 item.maItemSize.AdjustHeight(item.maImage.GetSizePixel().Height() );
1519 if ( item.maImage.GetSizePixel().Width() > item.maItemSize.Width() )
1520 item.maItemSize.setWidth( item.maImage.GetSizePixel().Width() );
1521 }
1522
1523 item.mbVisibleText = bText;
1524 }
1525 }
1526 else
1527 { // no image and no text
1528 item.maItemSize = Size( nDefWidth, nDefHeight );
1529 item.mbEmptyBtn = true;
1530 }
1531
1532 // save the content size
1533 item.maContentSize = item.maItemSize;
1534
1535 // if required, take window height into consideration
1536 if ( item.mpWindow )
1537 {
1538 tools::Long nHeight = item.mpWindow->GetSizePixel().Height();
1539 if ( nHeight > mnWinHeight )
1540 mnWinHeight = nHeight;
1541 }
1542
1543 // add in drop down arrow
1544 if( item.mnBits & ToolBoxItemBits::DROPDOWN )
1545 {
1546 item.maItemSize.AdjustWidth(nDropDownArrowWidth );
1547 item.mnDropDownArrowWidth = nDropDownArrowWidth;
1548 }
1549
1550 // text items will be rotated in vertical mode
1551 // -> swap width and height
1552 if( item.mbVisibleText && !mbHorz )
1553 {
1554 tools::Long tmp = item.maItemSize.Width();
1555 item.maItemSize.setWidth( item.maItemSize.Height() );
1556 item.maItemSize.setHeight( tmp );
1557
1558 tmp = item.maContentSize.Width();
1559 item.maContentSize.setWidth( item.maContentSize.Height() );
1560 item.maContentSize.setHeight( tmp );
1561 }
1562 }
1563 else if ( item.meType == ToolBoxItemType::SPACE )
1564 {
1565 item.maItemSize = Size( nDefWidth, nDefHeight );
1566 item.maContentSize = item.maItemSize;
1567 }
1568
1569 if ( item.meType == ToolBoxItemType::BUTTON || item.meType == ToolBoxItemType::SPACE )
1570 {
1571 // add borders
1572 tools::Long w = item.maItemSize.Width();
1573 tools::Long h = item.maItemSize.Height();
1574 ImplAddButtonBorder( w, h, mpData->mbNativeButtons );
1575 item.maItemSize.setWidth(w);
1576 item.maItemSize.setHeight(h);
1577
1578 if( item.meType == ToolBoxItemType::BUTTON )
1579 {
1580 tools::Long nMinW = std::max(nMinWidth, item.maMinimalItemSize.Width());
1581 tools::Long nMinH = std::max(nMinHeight, item.maMinimalItemSize.Height());
1582
1583 tools::Long nGrowContentWidth = 0;
1584 tools::Long nGrowContentHeight = 0;
1585
1586 if( item.maItemSize.Width() < nMinW )
1587 {
1588 nGrowContentWidth = nMinW - item.maItemSize.Width();
1589 item.maItemSize.setWidth( nMinW );
1590 }
1591 if( item.maItemSize.Height() < nMinH )
1592 {
1593 nGrowContentHeight = nMinH - item.maItemSize.Height();
1594 item.maItemSize.setHeight( nMinH );
1595 }
1596
1597 // grow the content size by the additional available space
1598 item.maContentSize.AdjustWidth(nGrowContentWidth );
1599 item.maContentSize.AdjustHeight(nGrowContentHeight );
1600 }
1601
1602 // keep track of max item size
1603 if ( item.maItemSize.Width() > nMaxWidth )
1604 nMaxWidth = item.maItemSize.Width();
1605 if ( item.maItemSize.Height() > nMaxHeight )
1606 nMaxHeight = item.maItemSize.Height();
1607 }
1608 }
1609 }
1610 else
1611 {
1612 nMaxWidth = nDefWidth;
1613 nMaxHeight = nDefHeight;
1614
1615 ImplAddButtonBorder( nMaxWidth, nMaxHeight, mpData->mbNativeButtons );
1616 }
1617
1620 {
1621 // make sure all vertical toolbars have the same width and horizontal have the same height
1622 // this depends on the used button sizes
1623 // as this is used for alignment of multiple toolbars
1624 // it is only required for docked toolbars
1625
1626 tools::Long nFixedWidth = nDefWidth+nDropDownArrowWidth;
1627 tools::Long nFixedHeight = nDefHeight;
1628 ImplAddButtonBorder( nFixedWidth, nFixedHeight, mpData->mbNativeButtons );
1629
1630 if( mbHorz )
1631 nMaxHeight = nFixedHeight;
1632 else
1633 nMaxWidth = nFixedWidth;
1634 }
1635
1636 mbCalc = false;
1637 mbFormat = true;
1638
1639 // do we have to recalc the sizes ?
1640 if ( (nMaxWidth != mnMaxItemWidth) || (nMaxHeight != mnMaxItemHeight) )
1641 {
1642 mnMaxItemWidth = nMaxWidth;
1643 mnMaxItemHeight = nMaxHeight;
1644
1645 return true;
1646 }
1647 else
1648 return false;
1649}
1650
1651ToolBox::ImplToolItems::size_type ToolBox::ImplCalcBreaks( tools::Long nWidth, sal_Int32* pMaxLineWidth, bool bCalcHorz ) const
1652{
1653 sal_uLong nLineStart = 0;
1654 sal_uLong nGroupStart = 0;
1656 tools::Long nCurWidth;
1657 tools::Long nLastGroupLineWidth = 0;
1658 tools::Long nMaxLineWidth = 0;
1659 ImplToolItems::size_type nLines = 1;
1660 bool bWindow;
1661 bool bBreak = false;
1662 tools::Long nWidthTotal = nWidth;
1663 tools::Long nMenuWidth = 0;
1664
1665 // when docked the menubutton will be in the first line
1666 if( IsMenuEnabled() && !ImplIsFloatingMode() )
1667 nMenuWidth = mpData->maMenubuttonItem.maItemSize.Width();
1668
1669 // we need to know which item is the last visible one to be able to add
1670 // the menu width in case we are unable to show all the items
1671 ImplToolItems::iterator it, lastVisible;
1672 for ( it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it )
1673 {
1674 if ( it->mbVisible )
1675 lastVisible = it;
1676 }
1677
1678 it = mpData->m_aItems.begin();
1679 while ( it != mpData->m_aItems.end() )
1680 {
1681 it->mbBreak = bBreak;
1682 bBreak = false;
1683
1684 if ( it->mbVisible )
1685 {
1686 bWindow = false;
1687 bBreak = false;
1688 nCurWidth = 0;
1689
1690 if ( it->meType == ToolBoxItemType::BUTTON || it->meType == ToolBoxItemType::SPACE )
1691 {
1692 if ( bCalcHorz )
1693 nCurWidth = it->maItemSize.Width();
1694 else
1695 nCurWidth = it->maItemSize.Height();
1696
1697 if ( it->mpWindow && bCalcHorz )
1698 {
1699 tools::Long nWinItemWidth = it->mpWindow->GetSizePixel().Width();
1700 if ( !mbScroll || (nWinItemWidth <= nWidthTotal) )
1701 {
1702 nCurWidth = nWinItemWidth;
1703 bWindow = true;
1704 }
1705 else
1706 {
1707 if ( it->mbEmptyBtn )
1708 {
1709 nCurWidth = 0;
1710 }
1711 }
1712 }
1713
1714 // in case we are able to show all the items, we do not want
1715 // to show the toolbar's menu; otherwise yes
1716 if ( ( ( it == lastVisible ) && (nLineWidth+nCurWidth > nWidthTotal) && mbScroll ) ||
1717 ( ( it != lastVisible ) && (nLineWidth+nCurWidth+nMenuWidth > nWidthTotal) && mbScroll ) )
1718 bBreak = true;
1719 }
1720 else if ( it->meType == ToolBoxItemType::SEPARATOR )
1721 {
1722 nCurWidth = it->mnSepSize;
1723 if ( !ImplIsFloatingMode() && ( it != lastVisible ) && (nLineWidth+nCurWidth+nMenuWidth > nWidthTotal) )
1724 bBreak = true;
1725 }
1726 // treat breaks as separators, except when using old style toolbars (ie. no menu button)
1727 else if ( (it->meType == ToolBoxItemType::BREAK) && !IsMenuEnabled() )
1728 bBreak = true;
1729
1730 if ( bBreak )
1731 {
1732 nLines++;
1733
1734 // Add break before the entire group or take group apart?
1735 if ( (it->meType == ToolBoxItemType::BREAK) ||
1736 (nLineStart == nGroupStart) )
1737 {
1738 if ( nLineWidth > nMaxLineWidth )
1739 nMaxLineWidth = nLineWidth;
1740
1741 nLineWidth = 0;
1742 nLineStart = it - mpData->m_aItems.begin();
1743 nGroupStart = nLineStart;
1744 it->mbBreak = true;
1745 bBreak = false;
1746 }
1747 else
1748 {
1749 if ( nLastGroupLineWidth > nMaxLineWidth )
1750 nMaxLineWidth = nLastGroupLineWidth;
1751
1752 // if the break is added before the group, set it to
1753 // beginning of line and re-calculate
1754 nLineWidth = 0;
1755 nLineStart = nGroupStart;
1756 it = mpData->m_aItems.begin() + nGroupStart;
1757 continue;
1758 }
1759 }
1760 else
1761 {
1762 if( ImplIsFloatingMode() || !IsMenuEnabled() ) // no group breaking when being docked single-line
1763 {
1764 if ( (it->meType != ToolBoxItemType::BUTTON) || bWindow )
1765 {
1766 // found separator or break
1767 nLastGroupLineWidth = nLineWidth;
1768 nGroupStart = it - mpData->m_aItems.begin();
1769 if ( !bWindow )
1770 nGroupStart++;
1771 }
1772 }
1773 }
1774
1775 nLineWidth += nCurWidth;
1776 }
1777
1778 ++it;
1779 }
1780
1781 if ( pMaxLineWidth )
1782 {
1783 if ( nLineWidth > nMaxLineWidth )
1784 nMaxLineWidth = nLineWidth;
1785
1787 {
1788 // leave enough space to display buttons in the decoration
1790 if( nMaxLineWidth < aMinWidth )
1791 nMaxLineWidth = aMinWidth;
1792 }
1793 *pMaxLineWidth = nMaxLineWidth;
1794 }
1795
1796 return nLines;
1797}
1798
1800{
1801 if( !ImplIsFloatingMode() )
1802 return Size();
1803
1804 Size aCurrentSize( mnDX, mnDY );
1805 Size aSize1( aCurrentSize );
1806 Size aSize2( aCurrentSize );
1807
1808 // try to preserve current height
1809
1810 // calc number of floating lines for current window height
1811 ImplToolItems::size_type nFloatLinesHeight = ImplCalcLines( mnDY );
1812 // calc window size according to this number
1813 aSize1 = ImplCalcFloatSize( nFloatLinesHeight );
1814
1815 if( aCurrentSize == aSize1 )
1816 return aSize1;
1817
1818 // try to preserve current width
1819
1820 tools::Long nLineHeight = std::max( mnWinHeight, mnMaxItemHeight );
1821 int nBorderX = 2*TB_BORDER_OFFSET1 + mnLeftBorder + mnRightBorder;
1822 int nBorderY = 2*TB_BORDER_OFFSET2 + mnTopBorder + mnBottomBorder;
1823 Size aSz( aCurrentSize );
1824 sal_Int32 maxX;
1825 ImplToolItems::size_type nLines = ImplCalcBreaks( aSz.Width()-nBorderX, &maxX, mbHorz );
1826
1827 ImplToolItems::size_type manyLines = 1000;
1828 Size aMinimalFloatSize = ImplCalcFloatSize( manyLines );
1829
1830 aSz.setHeight( nBorderY + nLineHeight * nLines );
1831 // line space when more than one line
1832 if ( mbLineSpacing )
1833 aSz.AdjustHeight((nLines-1)*TB_LINESPACING );
1834
1835 aSz.setWidth( nBorderX + maxX );
1836
1837 // avoid clipping of any items
1838 if( aSz.Width() < aMinimalFloatSize.Width() )
1839 aSize2 = ImplCalcFloatSize( nLines );
1840 else
1841 aSize2 = aSz;
1842
1843 if( aCurrentSize == aSize2 )
1844 return aSize2;
1845
1846 // set the size with the smallest delta as the current size
1847 tools::Long dx1 = std::abs( mnDX - aSize1.Width() );
1848 tools::Long dy1 = std::abs( mnDY - aSize1.Height() );
1849
1850 tools::Long dx2 = std::abs( mnDX - aSize2.Width() );
1851 tools::Long dy2 = std::abs( mnDY - aSize2.Height() );
1852
1853 if( dx1*dy1 < dx2*dy2 )
1854 aCurrentSize = aSize1;
1855 else
1856 aCurrentSize = aSize2;
1857
1858 return aCurrentSize;
1859}
1860
1861namespace
1862{
1863void lcl_hideDoubleSeparators( ToolBox::ImplToolItems& rItems )
1864{
1865 bool bLastSep( true );
1866 ToolBox::ImplToolItems::iterator it;
1867 for ( it = rItems.begin(); it != rItems.end(); ++it )
1868 {
1869 if ( it->meType == ToolBoxItemType::SEPARATOR )
1870 {
1871 it->mbVisible = false;
1872 if ( !bLastSep )
1873 {
1874 // check if any visible items have to appear behind it
1875 if (std::any_of(it + 1, rItems.end(), [](const ImplToolItem& rItem) {
1876 return (rItem.meType == ToolBoxItemType::BUTTON) && rItem.mbVisible; }))
1877 it->mbVisible = true;
1878 }
1879 bLastSep = true;
1880 }
1881 else if ( it->mbVisible )
1882 bLastSep = false;
1883 }
1884}
1885}
1886
1887void ToolBox::ImplFormat( bool bResize )
1888{
1889 // Has to re-formatted
1890 if ( !mbFormat )
1891 return;
1892
1893 mpData->ImplClearLayoutData();
1894
1895 // recalculate positions and sizes
1896 tools::Rectangle aEmptyRect;
1897 tools::Long nLineSize;
1898 tools::Long nLeft;
1899 tools::Long nTop;
1900 tools::Long nMax; // width of layoutarea in pixels
1901 ImplToolItems::size_type nFormatLine;
1902 bool bMustFullPaint;
1903
1905 bool bIsInPopupMode = ImplIsInPopupMode();
1906
1907 maFloatSizes.clear();
1908
1909 // compute border sizes
1911
1912 // update drag area (where the 'grip' will be placed)
1913 tools::Rectangle aOldDragRect;
1914 if( pWrapper )
1915 aOldDragRect = pWrapper->GetDragArea();
1917
1918 bMustFullPaint = ImplCalcItem();
1919
1920 // calculate new size during interactive resize or
1921 // set computed size when formatting only
1922 if ( ImplIsFloatingMode() )
1923 {
1924 if ( bResize )
1926 else
1928 }
1929
1930 // Horizontal
1931 if ( mbHorz )
1932 {
1933 tools::Long nBottom;
1934 // nLineSize: height of a single line, will fit highest item
1935 nLineSize = mnMaxItemHeight;
1936
1938 nLineSize = mnWinHeight;
1939
1940 if ( mbScroll )
1941 {
1942 nMax = mnDX;
1944 }
1945 else
1946 {
1947 // layout over all lines
1949 nMax = TB_MAXNOSCROLL;
1950 }
1951
1952 // add in all border offsets
1953 if ( mnWinStyle & WB_BORDER )
1954 {
1958 nMax -= nLeft + TB_BORDER_OFFSET1 + mnRightBorder;
1959 }
1960 else
1961 {
1962 nLeft = 0;
1963 nTop = 0;
1964 nBottom = 0;
1965 }
1966
1967 // adjust linesize if docked in single-line mode (i.e. when using a clipped item menu)
1968 // we have to center all items in the window height
1969 if( IsMenuEnabled() && !ImplIsFloatingMode() )
1970 {
1971 tools::Long nWinHeight = mnDY - nTop - nBottom;
1972 if( nWinHeight > nLineSize )
1973 nLineSize = nWinHeight;
1974 }
1975 }
1976 else
1977 {
1978 tools::Long nRight;
1979 nLineSize = mnMaxItemWidth;
1980
1981 if ( mbScroll )
1982 {
1984 nMax = mnDY;
1985 }
1986 else
1987 {
1989 nMax = TB_MAXNOSCROLL;
1990 }
1991
1992 if ( mnWinStyle & WB_BORDER )
1993 {
1997 nMax -= nTop + TB_BORDER_OFFSET1 + mnBottomBorder;
1998 }
1999 else
2000 {
2001 nLeft = 0;
2002 nTop = 0;
2003 nRight = 0;
2004 }
2005
2006 // adjust linesize if docked in single-line mode (i.e. when using a clipped item menu)
2007 // we have to center all items in the window height
2008 if( !ImplIsFloatingMode() && IsMenuEnabled() )
2009 {
2010 tools::Long nWinWidth = mnDX - nLeft - nRight;
2011 if( nWinWidth > nLineSize )
2012 nLineSize = nWinWidth;
2013 }
2014 }
2015
2016 // no calculation if the window has no size (nMax=0)
2017 // non scrolling toolboxes must be computed though
2018 if ( (nMax <= 0) && mbScroll )
2019 {
2020 mnVisLines = 1;
2021 mnCurLine = 1;
2022 mnCurLines = 1;
2023
2024 for (auto & item : mpData->m_aItems)
2025 {
2026 item.maRect = aEmptyRect;
2027 }
2028
2029 maLowerRect = aEmptyRect;
2030 maUpperRect = aEmptyRect;
2031 }
2032 else
2033 {
2034 // init start values
2035 tools::Long nX = nLeft; // top-left offset
2036 tools::Long nY = nTop;
2037 nFormatLine = 1;
2038
2039 // save old scroll rectangles and reset them
2040 tools::Rectangle aOldLowerRect = maLowerRect;
2041 tools::Rectangle aOldUpperRect = maUpperRect;
2042 tools::Rectangle aOldMenubuttonRect = mpData->maMenubuttonItem.maRect;
2043 maUpperRect = aEmptyRect;
2044 maLowerRect = aEmptyRect;
2045 mpData->maMenubuttonItem.maRect = aEmptyRect;
2046
2047 // do we have any toolbox items at all ?
2048 if ( !mpData->m_aItems.empty() || IsMenuEnabled() )
2049 {
2050 lcl_hideDoubleSeparators( mpData->m_aItems );
2051
2052 // compute line breaks and visible lines give the current window width (nMax)
2053 // the break indicators will be stored within each item (it->mbBreak)
2054 mnCurLines = ImplCalcBreaks( nMax, nullptr, mbHorz );
2055
2056 // check for scrollbar buttons or dropdown menu
2057 // (if a menu is enabled, this will be used to store clipped
2058 // items and no scroll buttons will appear)
2059 if ( (!ImplIsFloatingMode() && (mnCurLines > mnVisLines) && mbScroll ) ||
2060 IsMenuEnabled() )
2061 {
2062 // compute linebreaks again, incorporating scrollbar buttons
2063 if( !IsMenuEnabled() )
2064 {
2066 mnCurLines = ImplCalcBreaks( nMax, nullptr, mbHorz );
2067 }
2068
2069 // compute scroll rectangles or menu button
2070 if ( mbHorz )
2071 {
2072 if( IsMenuEnabled() && !ImplHasExternalMenubutton() && !bIsInPopupMode )
2073 {
2074 if( !ImplIsFloatingMode() )
2075 {
2076 mpData->maMenubuttonItem.maRect.SetRight( mnDX - 2 );
2077 mpData->maMenubuttonItem.maRect.SetTop( nTop );
2078 mpData->maMenubuttonItem.maRect.SetBottom( mnDY-mnBottomBorder-TB_BORDER_OFFSET2-1 );
2079 }
2080 else
2081 {
2082 mpData->maMenubuttonItem.maRect.SetRight( mnDX - mnRightBorder-TB_BORDER_OFFSET1-1 );
2083 mpData->maMenubuttonItem.maRect.SetTop( nTop );
2084 mpData->maMenubuttonItem.maRect.SetBottom( mnDY-mnBottomBorder-TB_BORDER_OFFSET2-1 );
2085 }
2086 mpData->maMenubuttonItem.maRect.SetLeft( mpData->maMenubuttonItem.maRect.Right() - mpData->mnMenuButtonWidth );
2087 }
2088 else
2089 {
2090 maUpperRect.SetLeft( nLeft+nMax+TB_SPIN_OFFSET );
2092 maUpperRect.SetTop( nTop );
2099 }
2100 }
2101 else
2102 {
2103 if( IsMenuEnabled() && !ImplHasExternalMenubutton() && !bIsInPopupMode )
2104 {
2105 if( !ImplIsFloatingMode() )
2106 {
2107 mpData->maMenubuttonItem.maRect.SetBottom( mnDY - 2 );
2108 mpData->maMenubuttonItem.maRect.SetLeft( nLeft );
2109 mpData->maMenubuttonItem.maRect.SetRight( mnDX-mnRightBorder-TB_BORDER_OFFSET2-1 );
2110 }
2111 else
2112 {
2113 mpData->maMenubuttonItem.maRect.SetBottom( mnDY - mnBottomBorder-TB_BORDER_OFFSET1-1 );
2114 mpData->maMenubuttonItem.maRect.SetLeft( nLeft );
2115 mpData->maMenubuttonItem.maRect.SetRight( mnDX-mnRightBorder-TB_BORDER_OFFSET2-1 );
2116 }
2117 mpData->maMenubuttonItem.maRect.SetTop( mpData->maMenubuttonItem.maRect.Bottom() - mpData->mnMenuButtonWidth );
2118 }
2119 else
2120 {
2121 maUpperRect.SetTop( nTop+nMax+TB_SPIN_OFFSET );
2123 maUpperRect.SetLeft( nLeft );
2130 }
2131 }
2132 }
2133
2134 // no scrolling when there is a "more"-menu
2135 // anything will "fit" in a single line then
2136 if( IsMenuEnabled() )
2137 mnCurLines = 1;
2138
2139 // determine the currently visible line
2140 if ( mnVisLines >= mnCurLines )
2141 mnCurLine = 1;
2142 else if ( mnCurLine+mnVisLines-1 > mnCurLines )
2144
2145 tools::Long firstItemCenter = 0;
2146 for (auto & item : mpData->m_aItems)
2147 {
2148 item.mbShowWindow = false;
2149
2150 // check for line break and advance nX/nY accordingly
2151 if ( item.mbBreak )
2152 {
2153 nFormatLine++;
2154
2155 // increment starting with the second line
2156 if ( nFormatLine > mnCurLine )
2157 {
2158 if ( mbHorz )
2159 {
2160 nX = nLeft;
2161 if ( mbLineSpacing )
2162 nY += nLineSize+TB_LINESPACING;
2163 else
2164 nY += nLineSize;
2165 }
2166 else
2167 {
2168 nY = nTop;
2169 if ( mbLineSpacing )
2170 nX += nLineSize+TB_LINESPACING;
2171 else
2172 nX += nLineSize;
2173 }
2174 }
2175 }
2176
2177 if ( !item.mbVisible || (nFormatLine < mnCurLine) ||
2178 (nFormatLine > mnCurLine+mnVisLines-1) )
2179 // item is not visible
2180 item.maCalcRect = aEmptyRect;
2181 else
2182 {
2183 // 1. determine current item width/height
2184 // take window size and orientation into account, because this affects the size of item windows
2185
2186 Size aCurrentItemSize( item.GetSize( mbHorz, mbScroll, nMax, Size(mnMaxItemWidth, mnMaxItemHeight) ) );
2187
2188 // 2. position item rect and use size from step 1
2189 // items will be centered horizontally (if mbHorz) or vertically
2190 // advance nX and nY accordingly
2191
2192 if ( mbHorz )
2193 {
2194 // In special mode Locked horizontal positions of all items remain unchanged.
2195
2196 if ( mbIsArranged && meLayoutMode == ToolBoxLayoutMode::Locked && mnLines == 1 && item.maRect.Left() > 0 )
2197 nX = item.maRect.Left();
2198 item.maCalcRect.SetLeft( nX );
2199
2200 // In special mode Locked first item's vertical position remains unchanged. Consecutive items vertical
2201 // positions are centered around first item's vertical position. If an item's height exceeds available
2202 // space, item's vertical position remains unchanged too.
2203
2205 if ( firstItemCenter > 0 )
2206 if ( firstItemCenter-aCurrentItemSize.Height()/2 > nY )
2207 item.maCalcRect.SetTop( firstItemCenter-aCurrentItemSize.Height()/2 );
2208 else
2209 item.maCalcRect.SetTop( item.maRect.Top() );
2210 else
2211 {
2212 item.maCalcRect.SetTop( item.maRect.Top() );
2213 firstItemCenter = item.maRect.Top()+aCurrentItemSize.Height()/2;
2214 }
2215 else
2216 item.maCalcRect.SetTop( nY+(nLineSize-aCurrentItemSize.Height())/2 );
2217 item.maCalcRect.SetRight( nX+aCurrentItemSize.Width()-1 );
2218 item.maCalcRect.SetBottom( item.maCalcRect.Top()+aCurrentItemSize.Height()-1 );
2219 nX += aCurrentItemSize.Width();
2220 }
2221 else
2222 {
2223 item.maCalcRect.SetLeft( nX+(nLineSize-aCurrentItemSize.Width())/2 );
2224 item.maCalcRect.SetTop( nY );
2225 item.maCalcRect.SetRight( item.maCalcRect.Left()+aCurrentItemSize.Width()-1 );
2226 item.maCalcRect.SetBottom( nY+aCurrentItemSize.Height()-1 );
2227 nY += aCurrentItemSize.Height();
2228 }
2229 }
2230
2231 // position window items into calculated item rect
2232 if ( item.mpWindow )
2233 {
2234 if ( item.mbShowWindow )
2235 {
2236 Point aPos( item.maCalcRect.Left(), item.maCalcRect.Top() );
2237
2238 assert( item.maCalcRect.Top() >= 0 );
2239
2240 item.mpWindow->SetPosPixel( aPos );
2241 item.mpWindow->Show();
2242 }
2243 else
2244 item.mpWindow->Hide();
2245 }
2246 } // end of loop over all items
2247 mbIsArranged = true;
2248 }
2249 else
2250 // we have no toolbox items
2251 mnCurLines = 1;
2252
2253 if( IsMenuEnabled() && ImplIsFloatingMode() && !ImplHasExternalMenubutton() && !bIsInPopupMode )
2254 {
2255 // custom menu will be the last button in floating mode
2256 ImplToolItem &rIt = mpData->maMenubuttonItem;
2257
2258 if ( mbHorz )
2259 {
2261 rIt.maRect.SetTop( nY );
2262 rIt.maRect.SetRight( rIt.maRect.Left() + mpData->mnMenuButtonWidth );
2263 rIt.maRect.SetBottom( nY+nLineSize-1 );
2264 nX += rIt.maItemSize.Width();
2265 }
2266 else
2267 {
2268 rIt.maRect.SetLeft( nX );
2270 rIt.maRect.SetRight( nX+nLineSize-1 );
2271 rIt.maRect.SetBottom( rIt.maRect.Top() + mpData->mnMenuButtonWidth );
2272 nY += rIt.maItemSize.Height();
2273 }
2274 }
2275
2276 // if toolbox visible trigger paint for changed regions
2277 if ( IsVisible() && !mbFullPaint )
2278 {
2279 if ( bMustFullPaint )
2280 {
2283 }
2284 else
2285 {
2286 if ( aOldLowerRect != maLowerRect )
2287 {
2289 maPaintRect.Union( aOldLowerRect );
2290 }
2291 if ( aOldUpperRect != maUpperRect )
2292 {
2294 maPaintRect.Union( aOldUpperRect );
2295 }
2296 if ( aOldMenubuttonRect != mpData->maMenubuttonItem.maRect )
2297 {
2298 maPaintRect.Union( mpData->maMenubuttonItem.maRect );
2299 maPaintRect.Union( aOldMenubuttonRect );
2300 }
2301 if ( pWrapper && aOldDragRect != pWrapper->GetDragArea() )
2302 {
2303 maPaintRect.Union( pWrapper->GetDragArea() );
2304 maPaintRect.Union( aOldDragRect );
2305 }
2306
2307 for (auto const& item : mpData->m_aItems)
2308 {
2309 if ( item.maRect != item.maCalcRect )
2310 {
2311 maPaintRect.Union( item.maRect );
2312 maPaintRect.Union( item.maCalcRect );
2313 }
2314 }
2315 }
2316
2318 }
2319
2320 // store the new calculated item rects
2321 maPaintRect = aEmptyRect;
2322 for (auto & item : mpData->m_aItems)
2323 item.maRect = item.maCalcRect;
2324 }
2325
2326 // indicate formatting is done
2327 mbFormat = false;
2328}
2329
2330IMPL_LINK_NOARG(ToolBox, ImplDropdownLongClickHdl, Timer *, void)
2331{
2332 if (mnCurPos == ITEM_NOTFOUND ||
2333 !(mpData->m_aItems[ mnCurPos ].mnBits & ToolBoxItemBits::DROPDOWN))
2334 return;
2335
2336 mpData->mbDropDownByKeyboard = false;
2337 mpData->maDropdownClickHdl.Call( this );
2338
2339 // do not reset data if the dropdown handler opened a floating window
2340 // see ImplFloatControl()
2341 if( !mpFloatWin )
2342 {
2343 // no floater was opened
2344 Deactivate();
2345 InvalidateItem(mnCurPos);
2346
2347 mnCurPos = ITEM_NOTFOUND;
2348 mnCurItemId = ToolBoxItemId(0);
2349 mnDownItemId = ToolBoxItemId(0);
2350 mnMouseModifier = 0;
2351 mnHighItemId = ToolBoxItemId(0);
2352 }
2353}
2354
2355IMPL_LINK_NOARG(ToolBox, ImplUpdateHdl, Timer *, void)
2356{
2357
2358 if( mbFormat && mpData )
2359 ImplFormat();
2360}
2361
2362static void ImplDrawMoreIndicator(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
2363{
2364 const Image pImage(StockImage::Yes, CHEVRON);
2365 Size aImageSize = pImage.GetSizePixel();
2366 tools::Long x = rRect.Left() + (rRect.getOpenWidth() - aImageSize.Width())/2;
2367 tools::Long y = rRect.Top() + (rRect.getOpenHeight() - aImageSize.Height())/2;
2369
2370 rRenderContext.DrawImage(Point(x,y), pImage, nImageStyle);
2371}
2372
2373static void ImplDrawDropdownArrow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rDropDownRect, bool bSetColor, bool bRotate )
2374{
2375 bool bLineColor = rRenderContext.IsLineColor();
2376 bool bFillColor = rRenderContext.IsFillColor();
2377 Color aOldFillColor = rRenderContext.GetFillColor();
2378 Color aOldLineColor = rRenderContext.GetLineColor();
2379 rRenderContext.SetLineColor();
2380
2381 if ( bSetColor )
2382 {
2383 if (rRenderContext.GetSettings().GetStyleSettings().GetFaceColor().IsDark())
2384 rRenderContext.SetFillColor(COL_WHITE);
2385 else
2386 rRenderContext.SetFillColor(COL_BLACK);
2387 }
2388
2389 tools::Polygon aPoly(4);
2390
2391 // the assumption is, that the width always specifies the size of the expected arrow.
2392 const tools::Long nMargin = round(2 * rRenderContext.GetDPIScaleFactor());
2393 const tools::Long nSize = rDropDownRect.getOpenWidth() - 2 * nMargin;
2394 const tools::Long nHalfSize = (nSize + 1) / 2;
2395 const tools::Long x = rDropDownRect.Left() + nMargin + (bRotate ? (rDropDownRect.getOpenWidth() - nHalfSize) / 2 : 0);
2396 const tools::Long y = rDropDownRect.Top() + nMargin + (rDropDownRect.getOpenHeight() - (bRotate ? nSize : nHalfSize)) / 2;
2397
2398 aPoly.SetPoint(Point(x, y), 0);
2399 if (bRotate) // >
2400 {
2401 aPoly.SetPoint(Point(x, y + nSize), 1);
2402 aPoly.SetPoint(Point(x + nHalfSize, y + nHalfSize), 2);
2403 }
2404 else // v
2405 {
2406 aPoly.SetPoint(Point(x + nHalfSize, y + nHalfSize), 1);
2407 aPoly.SetPoint(Point(x + nSize, y), 2);
2408 }
2409 aPoly.SetPoint(Point(x, y), 3);
2410
2411 auto aaflags = rRenderContext.GetAntialiasing();
2413 rRenderContext.DrawPolygon( aPoly );
2414 rRenderContext.SetAntialiasing(aaflags);
2415
2416 if( bFillColor )
2417 rRenderContext.SetFillColor(aOldFillColor);
2418 else
2419 rRenderContext.SetFillColor();
2420 if( bLineColor )
2421 rRenderContext.SetLineColor(aOldLineColor);
2422 else
2423 rRenderContext.SetLineColor();
2424}
2425
2426void ToolBox::ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight)
2427{
2428 if (mpData->maMenubuttonItem.maRect.IsEmpty())
2429 return;
2430
2431 // #i53937# paint menu button only if necessary
2432 if (!ImplHasClippedItems())
2433 return;
2434
2435 // execute pending paint requests
2437
2439
2440 // draw the 'more' indicator / button (>>)
2441 ImplErase(rRenderContext, mpData->maMenubuttonItem.maRect, bHighlight);
2442
2443 if (bHighlight)
2444 ImplDrawButton(rRenderContext, mpData->maMenubuttonItem.maRect, 2, false, true, false );
2445
2446 if (ImplHasClippedItems())
2447 ImplDrawMoreIndicator(rRenderContext, mpData->maMenubuttonItem.maRect);
2448
2449 // store highlight state
2450 mpData->mbMenubuttonSelected = bHighlight;
2451
2452 // restore colors
2453 rRenderContext.Pop();
2454}
2455
2457{
2458 bool bTmpUpper;
2459 bool bTmpLower;
2460
2462 return;
2463
2464 bTmpUpper = mnCurLine > 1;
2465
2466 bTmpLower = mnCurLine+mnVisLines-1 < mnCurLines;
2467
2468 if ( !IsEnabled() )
2469 {
2470 bTmpUpper = false;
2471 bTmpLower = false;
2472 }
2473
2475 false/*bUpperIn*/, false/*bLowerIn*/, bTmpUpper, bTmpLower, !mbHorz);
2476}
2477
2478void ToolBox::ImplDrawSeparator(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, const tools::Rectangle& rRect)
2479{
2480 if ( nPos >= mpData->m_aItems.size() - 1 )
2481 // no separator if it's the last item
2482 return;
2483
2484 ImplToolItem* pItem = &mpData->m_aItems[nPos];
2485 ImplToolItem* pPreviousItem = &mpData->m_aItems[nPos-1];
2486 ImplToolItem* pNextItem = &mpData->m_aItems[nPos+1];
2487
2488 if ( ( pPreviousItem->mbShowWindow && pNextItem->mbShowWindow ) || pNextItem->mbBreak )
2489 // no separator between two windows or before a break
2490 return;
2491
2492 bool bNativeOk = false;
2494 if (rRenderContext.IsNativeControlSupported(ControlType::Toolbar, nPart))
2495 {
2496 ImplControlValue aControlValue;
2497 bNativeOk = rRenderContext.DrawNativeControl(ControlType::Toolbar, nPart, rRect, ControlState::NONE, aControlValue, OUString());
2498 }
2499
2500 /* Draw the widget only if it can't be drawn natively. */
2501 if (bNativeOk)
2502 return;
2503
2504 tools::Long nCenterPos, nSlim;
2505 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
2506 rRenderContext.SetLineColor(rStyleSettings.GetSeparatorColor());
2507 if (IsHorizontal())
2508 {
2509 nSlim = (pItem->maRect.Bottom() - pItem->maRect.Top ()) / 4;
2510 nCenterPos = pItem->maRect.Center().X();
2511 rRenderContext.DrawLine(Point(nCenterPos, pItem->maRect.Top() + nSlim),
2512 Point(nCenterPos, pItem->maRect.Bottom() - nSlim));
2513 }
2514 else
2515 {
2516 nSlim = (pItem->maRect.Right() - pItem->maRect.Left ()) / 4;
2517 nCenterPos = pItem->maRect.Center().Y();
2518 rRenderContext.DrawLine(Point(pItem->maRect.Left() + nSlim, nCenterPos),
2519 Point(pItem->maRect.Right() - nSlim, nCenterPos));
2520 }
2521}
2522
2523void ToolBox::ImplDrawButton(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, sal_uInt16 highlight,
2524 bool bChecked, bool bEnabled, bool bIsWindow )
2525{
2526 // draws toolbar button background either native or using a coloured selection
2527 // if bIsWindow is true, the corresponding item is a control and only a selection border will be drawn
2528
2529 bool bNativeOk = false;
2530 if( !bIsWindow && rRenderContext.IsNativeControlSupported( ControlType::Toolbar, ControlPart::Button ) )
2531 {
2532 ImplControlValue aControlValue;
2534
2535 if ( highlight == 1 ) nState |= ControlState::PRESSED;
2536 if ( highlight == 2 ) nState |= ControlState::ROLLOVER;
2537 if ( bEnabled ) nState |= ControlState::ENABLED;
2538
2539 aControlValue.setTristateVal( bChecked ? ButtonValue::On : ButtonValue::Off );
2540
2541 bNativeOk = rRenderContext.DrawNativeControl( ControlType::Toolbar, ControlPart::Button,
2542 rRect, nState, aControlValue, OUString() );
2543 }
2544
2545 if (!bNativeOk)
2546 vcl::RenderTools::DrawSelectionBackground(rRenderContext, *this, rRect, bIsWindow ? 3 : highlight,
2547 bChecked, true, bIsWindow, nullptr, 2);
2548}
2549
2550void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, sal_uInt16 nHighlight)
2551{
2552 if (nPos >= mpData->m_aItems.size())
2553 return;
2554
2555 // execute pending paint requests
2557
2558 rRenderContext.SetFillColor();
2559
2560 ImplToolItem* pItem = &mpData->m_aItems[nPos];
2561
2562 if (!pItem->mbEnabled)
2563 nHighlight = 0;
2564
2565 // if the rectangle is outside visible area
2566 if (pItem->maRect.IsEmpty())
2567 return;
2568
2569 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
2570
2571 // no gradient background for items that have a popup open
2572 bool bHasOpenPopup = mpFloatWin && (mnDownItemId==pItem->mnId);
2573
2574 bool bHighContrastWhite = false;
2575 // check the face color as highcontrast indicator
2576 // because the toolbox itself might have a gradient
2577 if (rStyleSettings.GetFaceColor() == COL_WHITE)
2578 bHighContrastWhite = true;
2579
2580 // Compute buttons area.
2581 Size aBtnSize = pItem->maRect.GetSize();
2582
2583 /* Compute the button/separator rectangle here, we'll need it for
2584 * both the buttons and the separators. */
2585 tools::Rectangle aButtonRect( pItem->maRect.TopLeft(), aBtnSize );
2588 tools::Long nImageOffX = 0;
2589 tools::Long nImageOffY = 0;
2591
2592 // draw separators
2593 if ( (pItem->meType == ToolBoxItemType::SEPARATOR) && nPos > 0 )
2594 {
2595 ImplDrawSeparator(rRenderContext, nPos, aButtonRect);
2596 }
2597
2598 // do nothing if item is no button or will be displayed as window
2599 if ( (pItem->meType != ToolBoxItemType::BUTTON) || pItem->mbShowWindow )
2600 return;
2601
2602 if ( pItem->meState == TRISTATE_TRUE )
2603 {
2604 nStyle |= DrawButtonFlags::Checked;
2605 }
2606 else if ( pItem->meState == TRISTATE_INDET )
2607 {
2608 nStyle |= DrawButtonFlags::DontKnow;
2609 }
2610 if ( nHighlight == 1 )
2611 {
2612 nStyle |= DrawButtonFlags::Pressed;
2613 }
2614
2615 ImplErase(rRenderContext, pItem->maRect, nHighlight != 0, bHasOpenPopup );
2616
2617 nOffX += pItem->maRect.Left();
2618 nOffY += pItem->maRect.Top();
2619
2620 // determine what has to be drawn on the button: image, text or both
2621 bool bImage;
2622 bool bText;
2623 ButtonType tmpButtonType = determineButtonType( pItem, meButtonType ); // default to toolbox setting
2624 pItem->DetermineButtonDrawStyle( tmpButtonType, bImage, bText );
2625
2626 // compute output values
2627 tools::Long nBtnWidth = aBtnSize.Width()-SMALLBUTTON_HSIZE;
2628 tools::Long nBtnHeight = aBtnSize.Height()-SMALLBUTTON_VSIZE;
2629 Size aImageSize;
2630
2631 const bool bDropDown = (pItem->mnBits & ToolBoxItemBits::DROPDOWN) == ToolBoxItemBits::DROPDOWN;
2632 tools::Rectangle aDropDownRect;
2633 if (bDropDown)
2634 aDropDownRect = pItem->GetDropDownRect(mbHorz);
2635
2636 if ( bImage )
2637 {
2638 const Image* pImage = &(pItem->maImage);
2639 aImageSize = pImage->GetSizePixel();
2640
2641 // determine drawing flags
2643
2644 if ( !pItem->mbEnabled || !IsEnabled() )
2645 nImageStyle |= DrawImageFlags::Disable;
2646
2647 // #i35563# the dontknow state indicates different states at the same time
2648 // which should not be rendered disabled but normal
2649
2650 // draw the image
2651 nImageOffX = nOffX;
2652 nImageOffY = nOffY;
2653 if ( ( (pItem->mnBits & (ToolBoxItemBits::LEFT|ToolBoxItemBits::DROPDOWN)) || bText )
2655 {
2656 // left align also to leave space for drop down arrow
2657 // and when drawing text+image
2658 // just center in y, except for vertical (ie rotated text)
2659 if( mbHorz || !bText )
2660 nImageOffY += (nBtnHeight-aImageSize.Height())/2;
2661 }
2662 else
2663 {
2664 nImageOffX += (nBtnWidth-(bDropDown ? aDropDownRect.getOpenWidth() : 0)+SMALLBUTTON_OFF_NORMAL_X-aImageSize.Width())/2;
2666 nImageOffY += (nBtnHeight-aImageSize.Height())/2;
2667 }
2668 if ( nHighlight != 0 || (pItem->meState == TRISTATE_TRUE) )
2669 {
2670 if( bHasOpenPopup )
2671 ImplDrawFloatwinBorder(rRenderContext, pItem);
2672 else
2673 ImplDrawButton(rRenderContext, aButtonRect, nHighlight, pItem->meState == TRISTATE_TRUE,
2674 pItem->mbEnabled && IsEnabled(), pItem->mbShowWindow);
2675
2676 if( nHighlight != 0 )
2677 {
2678 if( bHighContrastWhite )
2679 nImageStyle |= DrawImageFlags::ColorTransform;
2680 }
2681 }
2682 rRenderContext.DrawImage(Point( nImageOffX, nImageOffY ), *pImage, nImageStyle);
2683 }
2684
2685 // draw the text
2686 bool bRotate = false;
2687 if ( bText )
2688 {
2689 const Size aTxtSize(GetOutDev()->GetCtrlTextWidth(pItem->maText), GetTextHeight());
2690 tools::Long nTextOffX = nOffX;
2691 tools::Long nTextOffY = nOffY;
2692
2693 // rotate text when vertically docked
2694 vcl::Font aOldFont = rRenderContext.GetFont();
2695 if( pItem->mbVisibleText && !ImplIsFloatingMode() &&
2697 {
2698 bRotate = true;
2699
2700 vcl::Font aRotateFont = aOldFont;
2701 aRotateFont.SetOrientation( 2700_deg10 );
2702
2703 // center horizontally
2704 nTextOffX += aTxtSize.Height();
2705 nTextOffX += (nBtnWidth-aTxtSize.Height())/2;
2706
2707 // add in image offset
2708 if( bImage )
2709 nTextOffY = nImageOffY + aImageSize.Height() + TB_IMAGETEXTOFFSET;
2710
2711 rRenderContext.SetFont(aRotateFont);
2712 }
2713 else
2714 {
2716 {
2717 // center vertically
2718 nTextOffY += (nBtnHeight-aTxtSize.Height())/2;
2719
2720 // add in image offset
2721 if( bImage )
2722 nTextOffX = nImageOffX + aImageSize.Width() + TB_IMAGETEXTOFFSET;
2723 }
2724 else
2725 {
2726 // center horizontally
2727 nTextOffX += (nBtnWidth-(bDropDown ? aDropDownRect.getOpenWidth() : 0)+SMALLBUTTON_OFF_NORMAL_X-aTxtSize.Width() - TB_IMAGETEXTOFFSET)/2;
2728 // set vertical position
2729 nTextOffY += nBtnHeight - aTxtSize.Height();
2730 }
2731 }
2732
2733 // draw selection only if not already drawn during image output (see above)
2734 if ( !bImage && (nHighlight != 0 || (pItem->meState == TRISTATE_TRUE) ) )
2735 {
2736 if( bHasOpenPopup )
2737 ImplDrawFloatwinBorder(rRenderContext, pItem);
2738 else
2739 ImplDrawButton(rRenderContext, pItem->maRect, nHighlight, pItem->meState == TRISTATE_TRUE,
2740 pItem->mbEnabled && IsEnabled(), pItem->mbShowWindow );
2741 }
2742
2744 if ( !pItem->mbEnabled )
2745 nTextStyle |= DrawTextFlags::Disable;
2746 rRenderContext.DrawCtrlText( Point( nTextOffX, nTextOffY ), pItem->maText,
2747 0, pItem->maText.getLength(), nTextStyle );
2748 if ( bRotate )
2749 SetFont( aOldFont );
2750 }
2751
2752 // paint optional drop down arrow
2753 if (!bDropDown)
2754 return;
2755
2756 bool bSetColor = true;
2757 if ( !pItem->mbEnabled || !IsEnabled() )
2758 {
2759 bSetColor = false;
2760 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
2761 }
2762
2763 // dropdown only will be painted without inner border
2765 {
2766 ImplErase(rRenderContext, aDropDownRect, nHighlight != 0, bHasOpenPopup);
2767
2768 if( nHighlight != 0 || (pItem->meState == TRISTATE_TRUE) )
2769 {
2770 if( bHasOpenPopup )
2771 ImplDrawFloatwinBorder(rRenderContext, pItem);
2772 else
2773 ImplDrawButton(rRenderContext, aDropDownRect, nHighlight, pItem->meState == TRISTATE_TRUE,
2774 pItem->mbEnabled && IsEnabled(), false);
2775 }
2776 }
2777 ImplDrawDropdownArrow(rRenderContext, aDropDownRect, bSetColor, bRotate);
2778}
2779
2781{
2782 if ( pItem->maRect.IsEmpty() )
2783 return;
2784
2785 rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor());
2786 Point p1, p2;
2787
2788 p1 = pItem->maRect.TopLeft();
2789 p1.AdjustX( 1 );
2790 p2 = pItem->maRect.TopRight();
2791 p2.AdjustX( -1 );
2792 rRenderContext.DrawLine( p1, p2);
2793 p1 = pItem->maRect.BottomLeft();
2794 p1.AdjustX( 1 );
2795 p2 = pItem->maRect.BottomRight();
2796 p2.AdjustX( -1 );
2797 rRenderContext.DrawLine( p1, p2);
2798
2799 p1 = pItem->maRect.TopLeft();
2800 p1.AdjustY( 1 );
2801 p2 = pItem->maRect.BottomLeft();
2802 p2.AdjustY( -1 );
2803 rRenderContext.DrawLine( p1, p2);
2804 p1 = pItem->maRect.TopRight();
2805 p1.AdjustY( 1 );
2806 p2 = pItem->maRect.BottomRight();
2807 p2.AdjustY( -1 );
2808 rRenderContext.DrawLine( p1, p2);
2809
2810}
2811
2812void ToolBox::ImplFloatControl( bool bStart, FloatingWindow* pFloatWindow )
2813{
2814
2815 if ( bStart )
2816 {
2817 mpFloatWin = pFloatWindow;
2818
2819 // redraw item, to trigger drawing of a special border
2821
2822 mbDrag = false;
2823 EndTracking();
2824 if (IsMouseCaptured())
2825 ReleaseMouse();
2826 }
2827 else
2828 {
2829 mpFloatWin = nullptr;
2830
2831 // if focus is still in this toolbox, then the floater was opened by keyboard
2832 // draw current item with highlight and keep old state
2833 bool bWasKeyboardActivate = mpData->mbDropDownByKeyboard;
2834
2835 if ( mnCurPos != ITEM_NOTFOUND )
2837 Deactivate();
2838
2839 if( !bWasKeyboardActivate )
2840 {
2844 }
2846
2847 }
2848}
2849
2850void ToolBox::ShowLine( bool bNext )
2851{
2852 mbFormat = true;
2853
2854 if ( bNext )
2855 mnCurLine++;
2856 else
2857 mnCurLine--;
2858
2859 ImplFormat();
2860}
2861
2862bool ToolBox::ImplHandleMouseMove( const MouseEvent& rMEvt, bool bRepeat )
2863{
2864 Point aMousePos = rMEvt.GetPosPixel();
2865
2866 if ( !mpData )
2867 return false;
2868
2869 // ToolBox active?
2870 if ( mbDrag && mnCurPos != ITEM_NOTFOUND )
2871 {
2872 // is the cursor over the item?
2873 ImplToolItem* pItem = &mpData->m_aItems[mnCurPos];
2874 if ( pItem->maRect.Contains( aMousePos ) )
2875 {
2876 if ( !mnCurItemId )
2877 {
2879 mnCurItemId = pItem->mnId;
2880 Highlight();
2881 }
2882
2883 if ( (pItem->mnBits & ToolBoxItemBits::REPEAT) && bRepeat )
2884 Select();
2885 }
2886 else
2887 {
2888 if ( mnCurItemId )
2889 {
2893 Highlight();
2894 }
2895 }
2896
2897 return true;
2898 }
2899
2900 if ( mbUpper )
2901 {
2902 bool bNewIn = maUpperRect.Contains( aMousePos );
2903 if ( bNewIn != mbIn )
2904 {
2905 mbIn = bNewIn;
2906 InvalidateSpin(true, false);
2907 }
2908 return true;
2909 }
2910
2911 if ( mbLower )
2912 {
2913 bool bNewIn = maLowerRect.Contains( aMousePos );
2914 if ( bNewIn != mbIn )
2915 {
2916 mbIn = bNewIn;
2917 InvalidateSpin(false);
2918 }
2919 return true;
2920 }
2921
2922 return false;
2923}
2924
2925bool ToolBox::ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel )
2926{
2927 if ( !mpData )
2928 return false;
2929
2930 // stop eventual running dropdown timer
2931 if( mnCurPos < mpData->m_aItems.size() &&
2932 (mpData->m_aItems[mnCurPos].mnBits & ToolBoxItemBits::DROPDOWN ) )
2933 {
2934 mpData->maDropdownTimer.Stop();
2935 }
2936
2937 if ( mbDrag )
2938 {
2939 Deactivate();
2940
2941 if ( mbDrag )
2942 mbDrag = false;
2943 else
2944 {
2945 if ( mnCurPos == ITEM_NOTFOUND )
2946 return true;
2947 }
2948
2949 // has mouse been released on top of item?
2950 if( mnCurPos < mpData->m_aItems.size() )
2951 {
2952 ImplToolItem* pItem = &mpData->m_aItems[mnCurPos];
2953 if ( pItem->maRect.Contains( rMEvt.GetPosPixel() ) )
2954 {
2955 mnCurItemId = pItem->mnId;
2956 if ( !bCancel )
2957 {
2958 // execute AutoCheck if required
2959 if ( pItem->mnBits & ToolBoxItemBits::AUTOCHECK )
2960 {
2961 if ( pItem->mnBits & ToolBoxItemBits::RADIOCHECK )
2962 {
2963 if ( pItem->meState != TRISTATE_TRUE )
2964 SetItemState( pItem->mnId, TRISTATE_TRUE );
2965 }
2966 else
2967 {
2968 if ( pItem->meState != TRISTATE_TRUE )
2969 pItem->meState = TRISTATE_TRUE;
2970 else
2971 pItem->meState = TRISTATE_FALSE;
2972 }
2973 }
2974
2975 // do not call Select when Repeat is active, as in this
2976 // case that was triggered already in MouseButtonDown
2977 if ( !(pItem->mnBits & ToolBoxItemBits::REPEAT) )
2978 {
2979 // prevent from being destroyed in the select handler
2980 VclPtr<vcl::Window> xWindow = this;
2981 Select();
2982 if ( xWindow->isDisposed() )
2983 return true;
2984 }
2985 }
2986
2987 {
2988 }
2989
2990 // Items not destroyed, in Select handler
2991 if ( mnCurItemId )
2992 {
2993 // Get current pos for the case that items are inserted/removed
2994 // in the toolBox
2996 if ( mnCurPos != ITEM_NOTFOUND )
2997 {
2999 GetOutDev()->Flush();
3000 }
3001 }
3002 }
3003 }
3004
3008 mnMouseModifier = 0;
3009 return true;
3010 }
3011 else if ( mbUpper || mbLower )
3012 {
3013 if ( mbIn )
3014 ShowLine( !mbUpper );
3015 mbUpper = false;
3016 mbLower = false;
3017 mbIn = false;
3019 return true;
3020 }
3021
3022 return false;
3023}
3024
3025void ToolBox::MouseMove( const MouseEvent& rMEvt )
3026{
3027 // pressing a modifier generates synthetic mouse moves
3028 // ignore it if keyboard selection is active
3030 return;
3031
3032 if ( ImplHandleMouseMove( rMEvt ) )
3033 return;
3034
3035 Point aMousePos = rMEvt.GetPosPixel();
3036
3037 // only highlight when the focus is not inside a child window of a toolbox
3038 // eg, in an edit control
3039 // and do not highlight when focus is in a different toolbox
3040 bool bDrawHotSpot = true;
3042
3043 bool bFocusWindowIsAToolBoxChild = false;
3044 if (pFocusWin)
3045 {
3046 vcl::Window *pWin = pFocusWin->GetParent();
3047 while (pWin)
3048 {
3049 if(pWin->ImplGetWindowImpl() && pWin->ImplGetWindowImpl()->mbToolBox)
3050 {
3051 bFocusWindowIsAToolBoxChild = true;
3052 break;
3053 }
3054 pWin = pWin->GetParent();
3055 }
3056 }
3057
3058 if( bFocusWindowIsAToolBoxChild || (pFocusWin && pFocusWin->ImplGetWindowImpl() && pFocusWin->ImplGetWindowImpl()->mbToolBox && pFocusWin != this) )
3059 bDrawHotSpot = false;
3060
3061 if ( mbDragging )
3062 {
3064 pMgr->Dragging( aMousePos );
3065 return;
3066 }
3067
3069
3070 // change mouse cursor over drag area
3072 if( pWrapper && pWrapper->GetDragArea().Contains( rMEvt.GetPosPixel() ) )
3073 eStyle = PointerStyle::Move;
3074
3076 {
3078 {
3079 sal_uInt16 nLinePtr = ImplTestLineSize( rMEvt.GetPosPixel() );
3080 if ( nLinePtr & DOCK_LINEHSIZE )
3081 {
3082 if ( meAlign == WindowAlign::Left )
3084 else
3086 }
3087 else if ( nLinePtr & DOCK_LINEVSIZE )
3088 {
3089 if ( meAlign == WindowAlign::Top )
3091 else
3093 }
3094 }
3095 }
3096
3097 if ( bDrawHotSpot )
3098 {
3099 bool bClearHigh = true;
3100 if ( !rMEvt.IsLeaveWindow() && (mnCurPos == ITEM_NOTFOUND) )
3101 {
3102 ImplToolItems::size_type nTempPos = 0;
3103 for (auto const& item : mpData->m_aItems)
3104 {
3105 if ( item.maRect.Contains( aMousePos ) )
3106 {
3107 if ( (item.meType == ToolBoxItemType::BUTTON) && item.mbEnabled )
3108 {
3109 bClearHigh = false;
3110 if ( mnHighItemId != item.mnId )
3111 {
3112 if ( mnHighItemId )
3113 {
3114 ImplHideFocus();
3115 ImplToolItems::size_type nPos = GetItemPos( mnHighItemId );
3117 CallEventListeners( VclEventId::ToolboxHighlightOff, reinterpret_cast< void* >( nPos ) );
3118 }
3119 if ( mpData->mbMenubuttonSelected )
3120 {
3121 // remove highlight from menubutton
3123 }
3124 mnHighItemId = item.mnId;
3125 InvalidateItem(nTempPos);
3126 ImplShowFocus();
3128 }
3129 }
3130 break;
3131 }
3132 ++nTempPos;
3133 }
3134 }
3135
3136 // only clear highlight when focus is not in toolbar
3137 bool bMenuButtonHit = mpData->maMenubuttonItem.maRect.Contains( aMousePos ) && ImplHasClippedItems();
3138 if ( !HasFocus() && (bClearHigh || bMenuButtonHit) )
3139 {
3140 if ( !bMenuButtonHit && mpData->mbMenubuttonSelected )
3141 {
3142 // remove highlight from menubutton
3144 }
3145
3146 if( mnHighItemId )
3147 {
3148 ImplToolItems::size_type nClearPos = GetItemPos( mnHighItemId );
3149 if ( nClearPos != ITEM_NOTFOUND )
3150 {
3151 InvalidateItem(nClearPos);
3152 if( nClearPos != mnCurPos )
3153 CallEventListeners( VclEventId::ToolboxHighlightOff, reinterpret_cast< void* >( nClearPos ) );
3154 }
3155 ImplHideFocus();
3157 }
3158
3159 if( bMenuButtonHit )
3160 {
3162 }
3163 }
3164 }
3165
3166 if ( meLastStyle != eStyle )
3167 {
3168 meLastStyle = eStyle;
3169 SetPointer( eStyle );
3170 }
3171
3172 DockingWindow::MouseMove( rMEvt );
3173}
3174
3176{
3177 // only trigger toolbox for left mouse button and when
3178 // we're not in normal operation
3179 if ( rMEvt.IsLeft() && !mbDrag && (mnCurPos == ITEM_NOTFOUND) )
3180 {
3181 // call activate already here, as items could
3182 // be exchanged
3183 Activate();
3184
3185 // update ToolBox here, such that user knows it
3186 if ( mbFormat )
3187 {
3188 ImplFormat();
3190 }
3191
3192 Point aMousePos = rMEvt.GetPosPixel();
3193 ImplToolItems::size_type i = 0;
3194 ImplToolItems::size_type nNewPos = ITEM_NOTFOUND;
3195
3196 // search for item that was clicked
3197 for (auto const& item : mpData->m_aItems)
3198 {
3199 // is this the item?
3200 if ( item.maRect.Contains( aMousePos ) )
3201 {
3202 // do nothing if it is a separator or
3203 // if the item has been disabled
3204 if ( (item.meType == ToolBoxItemType::BUTTON) &&
3205 !item.mbShowWindow )
3206 nNewPos = i;
3207
3208 break;
3209 }
3210
3211 i++;
3212 }
3213
3214 // item found
3215 if ( nNewPos != ITEM_NOTFOUND )
3216 {
3217 if ( !mpData->m_aItems[nNewPos].mbEnabled )
3218 {
3219 Deactivate();
3220 return;
3221 }
3222
3223 // update actual data
3225 mnCurPos = i;
3226 mnCurItemId = mpData->m_aItems[nNewPos].mnId;
3228 mnMouseModifier = rMEvt.GetModifier();
3229 if ( mpData->m_aItems[nNewPos].mnBits & ToolBoxItemBits::REPEAT )
3230 nTrackFlags |= StartTrackingFlags::ButtonRepeat;
3231
3232 // update bDrag here, as it is evaluated in the EndSelection
3233 mbDrag = true;
3234
3235 // on double-click: only call the handler, but do so before the button
3236 // is hit, as in the handler dragging
3237 // can be terminated
3238 if ( rMEvt.GetClicks() == 2 )
3239 DoubleClick();
3240
3241 if ( mbDrag )
3242 {
3244 Highlight();
3245 }
3246
3247 // was dropdown arrow pressed
3248 if( mpData->m_aItems[nNewPos].mnBits & ToolBoxItemBits::DROPDOWN )
3249 {
3250 if( ( (mpData->m_aItems[nNewPos].mnBits & ToolBoxItemBits::DROPDOWNONLY) == ToolBoxItemBits::DROPDOWNONLY)
3251 || mpData->m_aItems[nNewPos].GetDropDownRect( mbHorz ).Contains( aMousePos ))
3252 {
3253 // dropdownonly always triggers the dropdown handler, over the whole button area
3254
3255 // the drop down arrow should not trigger the item action
3256 mpData->mbDropDownByKeyboard = false;
3257 mpData->maDropdownClickHdl.Call( this );
3258
3259 // do not reset data if the dropdown handler opened a floating window
3260 // see ImplFloatControl()
3261 if( !mpFloatWin )
3262 {
3263 // no floater was opened
3264 Deactivate();
3266
3270 mnMouseModifier = 0;
3272 }
3273 return;
3274 }
3275 else // activate long click timer
3276 mpData->maDropdownTimer.Start();
3277 }
3278
3279 // call Click handler
3280 if ( rMEvt.GetClicks() != 2 )
3281 Click();
3282
3283 // also call Select handler at repeat
3284 if ( nTrackFlags & StartTrackingFlags::ButtonRepeat )
3285 Select();
3286
3287 // if the actions was not aborted in Click handler
3288 if ( mbDrag )
3289 StartTracking( nTrackFlags );
3290
3291 // if mouse was clicked over an item we
3292 // can abort here
3293 return;
3294 }
3295
3296 Deactivate();
3297
3298 // menu button hit ?
3299 if( mpData->maMenubuttonItem.maRect.Contains( aMousePos ) && ImplHasClippedItems() )
3300 {
3301 if ( maMenuButtonHdl.IsSet() )
3302 maMenuButtonHdl.Call( this );
3303 else
3304 ExecuteCustomMenu( mpData->maMenubuttonItem.maRect );
3305 return;
3306 }
3307
3308 // check scroll- and next-buttons here
3309 if ( maUpperRect.Contains( aMousePos ) )
3310 {
3311 if ( mnCurLine > 1 )
3312 {
3313 StartTracking();
3314 mbUpper = true;
3315 mbIn = true;
3316 InvalidateSpin(true, false);
3317 }
3318 return;
3319 }
3320 if ( maLowerRect.Contains( aMousePos ) )
3321 {
3323 {
3324 StartTracking();
3325 mbLower = true;
3326 mbIn = true;
3327 InvalidateSpin(false);
3328 }
3329 return;
3330 }
3331
3332 // Linesizing testen
3334 {
3335 sal_uInt16 nLineMode = ImplTestLineSize( aMousePos );
3336 if ( nLineMode )
3337 {
3339
3340 // call handler, such that we can set the
3341 // dock rectangles
3342 StartDocking();
3343
3345 Size aSize = GetSizePixel();
3346 aPos = ScreenToOutputPixel( aPos );
3347
3348 // start dragging
3349 pMgr->StartDragging( this, aMousePos, tools::Rectangle( aPos, aSize ),
3350 nLineMode );
3351 return;
3352 }
3353 }
3354
3355 // no item, then only click or double click
3356 if ( rMEvt.GetClicks() == 2 )
3357 DoubleClick();
3358 else
3359 Click();
3360 }
3361
3362 if ( !mbDrag && (mnCurPos == ITEM_NOTFOUND) )
3364}
3365
3367{
3368 if ( ImplHandleMouseButtonUp( rMEvt ) )
3369 return;
3370
3371 if ( mbDragging && rMEvt.IsLeft() )
3372 {
3374 pMgr->EndDragging();
3375 return;
3376 }
3377
3379}
3380
3382{
3383 VclPtr<vcl::Window> xWindow = this;
3384
3385 if ( rTEvt.IsTrackingEnded() )
3387 else
3389
3390 if ( xWindow->isDisposed() )
3391 // toolbox was deleted
3392 return;
3393 DockingWindow::Tracking( rTEvt );
3394}
3395
3396void ToolBox::InvalidateItem(ImplToolItems::size_type nPosition)
3397{
3398 if (mpData && nPosition < mpData->m_aItems.size())
3399 {
3400 ImplToolItem* pItem = &mpData->m_aItems[nPosition];
3401 Invalidate(pItem->maRect);
3402 }
3403}
3404
3406{
3407 if (!mpData->maMenubuttonItem.maRect.IsEmpty())
3408 Invalidate(mpData->maMenubuttonItem.maRect);
3409}
3410
3411void ToolBox::InvalidateSpin(bool bUpperIn, bool bLowerIn)
3412{
3413 if (bUpperIn && !maUpperRect.IsEmpty())
3415
3416 if (bLowerIn && !maLowerRect.IsEmpty())
3418}
3419
3420void ToolBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rPaintRect)
3421{
3422 if( mpData->mbIsPaintLocked )
3423 return;
3424
3425 if (rPaintRect == tools::Rectangle(0, 0, mnDX-1, mnDY-1))
3426 mbFullPaint = true;
3427 ImplFormat();
3428 mbFullPaint = false;
3429
3430 ImplDrawBackground(rRenderContext, rPaintRect);
3431
3432 if ( (mnWinStyle & WB_BORDER) && !ImplIsFloatingMode() )
3433 ImplDrawBorder(rRenderContext);
3434
3435 if( !ImplIsFloatingMode() )
3436 ImplDrawGrip(rRenderContext);
3437
3438 ImplDrawMenuButton(rRenderContext, mpData->mbMenubuttonSelected);
3439
3440 // draw SpinButtons
3441 if (mnWinStyle & WB_SCROLL)
3442 {
3443 if (mnCurLines > mnLines)
3444 ImplDrawSpin(rRenderContext);
3445 }
3446
3447 // draw buttons
3448 ImplToolItems::size_type nHighPos;
3449 if ( mnHighItemId )
3450 nHighPos = GetItemPos( mnHighItemId );
3451 else
3452 nHighPos = ITEM_NOTFOUND;
3453
3454 ImplToolItems::size_type nCount = mpData->m_aItems.size();
3455 for( ImplToolItems::size_type i = 0; i < nCount; i++ )
3456 {
3457 ImplToolItem* pItem = &mpData->m_aItems[i];
3458
3459 // only draw when the rectangle is in the draw rectangle
3460 if ( !pItem->maRect.IsEmpty() && rPaintRect.Overlaps( pItem->maRect ) )
3461 {
3462 sal_uInt16 nHighlight = 0;
3463 if ( i == mnCurPos )
3464 nHighlight = 1;
3465 else if ( i == nHighPos )
3466 nHighlight = 2;
3467 ImplDrawItem(rRenderContext, i, nHighlight);
3468 }
3469 }
3470 ImplShowFocus();
3471}
3472
3474{
3475 Size aSize = GetOutputSizePixel();
3476 // #i31422# some WindowManagers send (0,0) sizes when
3477 // switching virtual desktops - ignore this and avoid reformatting
3478 if( !aSize.Width() && !aSize.Height() )
3479 return;
3480
3481 tools::Long nOldDX = mnDX;
3482 tools::Long nOldDY = mnDY;
3483 mnDX = aSize.Width();
3484 mnDY = aSize.Height();
3485
3486 mnLastResizeDY = 0;
3487
3488 // invalidate everything to have gradient backgrounds properly drawn
3489 Invalidate();
3490
3491 // If we have any expandable entries, then force a reformat first using
3492 // their optimal sizes, then share out the excess space evenly across those
3493 // expandables and reformat again
3494 std::vector<size_t> aExpandables;
3495 for (size_t i = 0; i < mpData->m_aItems.size(); ++i)
3496 {
3497 if (mpData->m_aItems[i].mbExpand)
3498 {
3499 vcl::Window *pWindow = mpData->m_aItems[i].mpWindow;
3500 SAL_INFO_IF(!pWindow, "vcl.layout", "only tabitems with window supported at the moment");
3501 if (!pWindow)
3502 continue;
3503 Size aWinSize(pWindow->GetSizePixel());
3504 Size aPrefSize(pWindow->get_preferred_size());
3505 aWinSize.setWidth( aPrefSize.Width() );
3506 pWindow->SetSizePixel(aWinSize);
3507 aExpandables.push_back(i);
3508 }
3509 }
3510
3511 // re-format or re-draw
3512 if ( mbScroll || !aExpandables.empty() )
3513 {
3514 if ( !mbFormat || !aExpandables.empty() )
3515 {
3516 mbFormat = true;
3517 if( IsReallyVisible() || !aExpandables.empty() )
3518 {
3519 ImplFormat(true);
3520
3521 if (!aExpandables.empty())
3522 {
3523 //Get how big the optimal size is
3524 tools::Rectangle aBounds;
3525 for (const ImplToolItem & rItem : mpData->m_aItems)
3526 {
3527 aBounds.Union( rItem.maRect );
3528 }
3529
3530 auto nOptimalWidth = aBounds.GetWidth();
3531 auto nDiff = aSize.Width() - nOptimalWidth;
3532 decltype(nDiff) nExpandablesSize = aExpandables.size();
3533 nDiff /= nExpandablesSize;
3534
3535 //share out the diff from optimal to real across
3536 //expandable entries
3537 for (size_t nIndex : aExpandables)
3538 {
3539 vcl::Window *pWindow = mpData->m_aItems[nIndex].mpWindow;
3540 Size aWinSize(pWindow->GetSizePixel());
3541 Size aPrefSize(pWindow->get_preferred_size());
3542 aWinSize.setWidth( aPrefSize.Width() + nDiff );
3543 pWindow->SetSizePixel(aWinSize);
3544 }
3545
3546 //now reformat with final sizes
3547 mbFormat = true;
3548 ImplFormat(true);
3549 }
3550 }
3551 }
3552 }
3553
3554 // redraw border
3555 if ( !(mnWinStyle & WB_BORDER) )
3556 return;
3557
3558 // as otherwise, when painting we might think we have to re-draw everything
3559 if ( mbFormat && IsReallyVisible() )
3560 Invalidate();
3561 else
3562 {
3563 if ( mnRightBorder )
3564 {
3565 if ( nOldDX > mnDX )
3567 else
3568 Invalidate( tools::Rectangle( nOldDX-mnRightBorder-1, 0, nOldDX, nOldDY ) );
3569 }
3570
3571 if ( mnBottomBorder )
3572 {
3573 if ( nOldDY > mnDY )
3575 else
3576 Invalidate( tools::Rectangle( 0, nOldDY-mnBottomBorder-1, nOldDX, nOldDY ) );
3577 }
3578 }
3579}
3580
3581namespace
3582{
3583 bool DispatchableCommand(std::u16string_view rName)
3584 {
3585 return o3tl::starts_with(rName, u".uno") ||
3586 o3tl::starts_with(rName, u"slot:") ||
3587 o3tl::starts_with(rName, u"macro:") ||
3588 o3tl::starts_with(rName, u"vnd.sun.star.script");
3589 }
3590}
3591
3592const OUString& ToolBox::ImplGetHelpText( ToolBoxItemId nItemId ) const
3593{
3594 ImplToolItem* pItem = ImplGetItem( nItemId );
3595
3596 assert( pItem );
3597
3598 if ( pItem->maHelpText.isEmpty() && ( !pItem->maHelpId.isEmpty() || pItem->maCommandStr.getLength() ))
3599 {
3600 Help* pHelp = Application::GetHelp();
3601 if ( pHelp )
3602 {
3603 if (DispatchableCommand(pItem->maCommandStr))
3604 pItem->maHelpText = pHelp->GetHelpText( pItem->maCommandStr, this );
3605 if ( pItem->maHelpText.isEmpty() && !pItem->maHelpId.isEmpty() )
3606 pItem->maHelpText = pHelp->GetHelpText( pItem->maHelpId, this );
3607 }
3608 }
3609
3610 return pItem->maHelpText;
3611}
3612
3614{
3615 ToolBoxItemId nItemId;
3616 Point aHelpPos;
3617
3618 if( !rHEvt.KeyboardActivated() )
3619 {
3620 nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
3621 aHelpPos = rHEvt.GetMousePosPixel();
3622 }
3623 else
3624 {
3625 if( !mnHighItemId )
3626 return;
3627 else
3628 nItemId = mnHighItemId;
3629 tools::Rectangle aRect( GetItemRect( nItemId ) );
3630 if( aRect.IsEmpty() )
3631 return;
3632 else
3633 aHelpPos = OutputToScreenPixel( aRect.Center() );
3634 }
3635
3636 if ( nItemId )
3637 {
3639 {
3640 // get rectangle
3641 tools::Rectangle aTempRect = GetItemRect( nItemId );
3642 Point aPt = OutputToScreenPixel( aTempRect.TopLeft() );
3643 aTempRect.SetLeft( aPt.X() );
3644 aTempRect.SetTop( aPt.Y() );
3645 aPt = OutputToScreenPixel( aTempRect.BottomRight() );
3646 aTempRect.SetRight( aPt.X() );
3647 aTempRect.SetBottom( aPt.Y() );
3648
3649 // get text and display it
3650 OUString aStr = GetQuickHelpText( nItemId );
3651 if (aStr.isEmpty())
3653 if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
3654 {
3655 const OUString& rHelpStr = GetHelpText( nItemId );
3656 if (!rHelpStr.isEmpty())
3657 aStr = rHelpStr;
3658 Help::ShowBalloon( this, aHelpPos, aTempRect, aStr );
3659 }
3660 else
3662 return;
3663 }
3664 }
3665
3667}
3668
3670{
3671 if ( rNEvt.GetType() == NotifyEventType::KEYINPUT )
3672 {
3673 KeyEvent aKEvt = *rNEvt.GetKeyEvent();
3674 vcl::KeyCode aKeyCode = aKEvt.GetKeyCode();
3675 sal_uInt16 nKeyCode = aKeyCode.GetCode();
3676 switch( nKeyCode )
3677 {
3678 case KEY_TAB:
3679 {
3680 // internal TAB cycling only if parent is not a dialog or if we are the only child
3681 // otherwise the dialog control will take over
3682 vcl::Window *pParent = ImplGetParent();
3683 bool bOldSchoolContainer =
3685 pParent->GetChildCount() != 1);
3686 bool bNoTabCycling = bOldSchoolContainer || isContainerWindow(pParent);
3687
3688 if( bNoTabCycling )
3689 return DockingWindow::EventNotify( rNEvt );
3690 else if( ImplChangeHighlightUpDn( aKeyCode.IsShift() , bNoTabCycling ) )
3691 return true;
3692 else
3693 return DockingWindow::EventNotify( rNEvt );
3694 }
3695 default:
3696 break;
3697 }
3698 }
3699 else if( rNEvt.GetType() == NotifyEventType::GETFOCUS )
3700 {
3701 if( rNEvt.GetWindow() == this )
3702 {
3703 // the toolbar itself got the focus
3704 if( mnLastFocusItemId != ToolBoxItemId(0) || mpData->mbMenubuttonWasLastSelected )
3705 {
3706 // restore last item
3707 if( mpData->mbMenubuttonWasLastSelected )
3708 {
3709 ImplChangeHighlight( nullptr );
3710 mpData->mbMenubuttonSelected = true;
3712 }
3713 else
3714 {
3717 }
3718 }
3720 // Shift-TAB was pressed in the parent
3721 ImplChangeHighlightUpDn( false );
3722 else
3724
3726
3727 return true;
3728 }
3729 else
3730 {
3731 // a child window got the focus so update current item to
3732 // allow for proper lose focus handling in keyboard navigation
3733 for (auto const& item : mpData->m_aItems)
3734 {
3735 if ( item.mbVisible )
3736 {
3737 if ( item.mpWindow && item.mpWindow->ImplIsWindowOrChild( rNEvt.GetWindow() ) )
3738 {
3739 mnHighItemId = item.mnId;
3740 break;
3741 }
3742 }
3743 }
3744 return DockingWindow::EventNotify( rNEvt );
3745 }
3746 }
3747 else if( rNEvt.GetType() == NotifyEventType::LOSEFOCUS )
3748 {
3749 // deselect
3750 ImplHideFocus();
3751 mpData->mbMenubuttonWasLastSelected = false;
3754 }
3755
3756 return DockingWindow::EventNotify( rNEvt );
3757}
3758
3759void ToolBox::Command( const CommandEvent& rCEvt )
3760{
3761 if ( rCEvt.GetCommand() == CommandEventId::Wheel )
3762 {
3763 if ( (mnCurLine > 1) || (mnCurLine+mnVisLines-1 < mnCurLines) )
3764 {
3765 const CommandWheelData* pData = rCEvt.GetWheelData();
3766 if ( pData->GetMode() == CommandWheelMode::SCROLL )
3767 {
3768 if ( (mnCurLine > 1) && (pData->GetDelta() > 0) )
3769 ShowLine( false );
3770 else if ( (mnCurLine+mnVisLines-1 < mnCurLines) && (pData->GetDelta() < 0) )
3771 ShowLine( true );
3773 return;
3774 }
3775 }
3776 }
3777 else if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
3778 {
3780 return;
3781 }
3782
3783 DockingWindow::Command( rCEvt );
3784}
3785
3787{
3789
3791 ImplFormat();
3792 else if ( nType == StateChangedType::Enable )
3794 else if ( nType == StateChangedType::UpdateMode )
3795 {
3796 if ( IsUpdateMode() )
3797 Invalidate();
3798 }
3799 else if ( (nType == StateChangedType::Zoom) ||
3801 {
3802 mbCalc = true;
3803 mbFormat = true;
3804 ImplInitSettings( true, false, false );
3805 Invalidate();
3806 }
3808 {
3809 ImplInitSettings( false, true, false );
3810 Invalidate();
3811 }
3813 {
3814 ImplInitSettings( false, false, true ); // font, foreground, background
3815 Invalidate();
3816 }
3817
3819}
3820
3822{
3824
3825 if ( (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
3826 (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
3828 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
3829 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
3830 {
3831 mbCalc = true;
3832 mbFormat = true;
3833 ImplInitSettings( true, true, true );
3834 Invalidate();
3835 }
3836
3837 maDataChangedHandler.Call( &rDCEvt );
3838}
3839
3841{
3842 mnWinStyle = nNewStyle;
3843 if (!ImplIsFloatingMode())
3844 {
3845 bool bOldScroll = mbScroll;
3846 mbScroll = (mnWinStyle & WB_SCROLL) != 0;
3847 if (mbScroll != bOldScroll)
3848 {
3849 mbFormat = true;
3850 ImplFormat();
3851 }
3852 }
3853}
3854
3856{
3858
3859 if (!mpData)
3860 return;
3861
3862 bool bOldHorz = mbHorz;
3863
3864 if ( ImplIsFloatingMode() )
3865 {
3866 mbHorz = true;
3868 mbScroll = true;
3869
3870 if( bOldHorz != mbHorz )
3871 mbCalc = true; // orientation was changed !
3872
3875 }
3876 else
3877 {
3878 mbScroll = (mnWinStyle & WB_SCROLL) != 0;
3880 mbHorz = true;
3881 else
3882 mbHorz = false;
3883
3884 // set focus back to document
3886 }
3887
3888 if( bOldHorz != mbHorz )
3889 {
3890 // if orientation changes, the toolbox has to be initialized again
3891 // to update the direction of the gradient
3892 mbCalc = true;
3893 ImplInitSettings( true, true, true );
3894 }
3895
3896 mbFormat = true;
3897 ImplFormat();
3898}
3899
3901{
3906}
3907
3908bool ToolBox::Docking( const Point& rPos, tools::Rectangle& rRect )
3909{
3910 // do nothing during dragging, it was calculated before
3911 if ( mbDragging )
3912 return false;
3913
3914 bool bFloatMode = false;
3915
3916 DockingWindow::Docking( rPos, rRect );
3917
3918 // if the mouse is outside the area, it can only become a floating window
3919 tools::Rectangle aDockingRect( rRect );
3920 if ( !ImplIsFloatingMode() )
3921 {
3922 // don't use tracking rectangle for alignment check, because it will be too large
3923 // to get a floating mode as result - switch to floating size
3924 // so the calculation only depends on the position of the rectangle, not the current
3925 // docking state of the window
3926 ImplToolItems::size_type nTemp = 0;
3927 aDockingRect.SetSize( ImplCalcFloatSize( nTemp ) );
3928
3929 // in this mode docking is never done by keyboard, so it's OK to use the mouse position
3930 aDockingRect.SetPos( ImplGetFrameWindow()->GetPointerPosPixel() );
3931 }
3932
3933 bFloatMode = true;
3934
3936 if ( !mbLastFloatMode )
3937 {
3938 ImplToolItems::size_type nTemp = 0;
3939 aDockingRect.SetSize( ImplCalcFloatSize( nTemp ) );
3940 }
3941
3942 rRect = aDockingRect;
3943 mbLastFloatMode = bFloatMode;
3944
3945 return bFloatMode;
3946}
3947
3948void ToolBox::EndDocking( const tools::Rectangle& rRect, bool bFloatMode )
3949{
3950 if ( !IsDockingCanceled() )
3951 {
3952 if ( mnLines != mnDockLines )
3954 if ( meAlign != meDockAlign )
3956 }
3957 if ( bFloatMode || (bFloatMode != ImplIsFloatingMode()) )
3958 DockingWindow::EndDocking( rRect, bFloatMode );
3959}
3960
3962{
3963 ImplToolItems::size_type nCalcLines;
3964 ImplToolItems::size_type nTemp;
3965
3966 // calculate all floating sizes
3968
3969 if ( !mnLastResizeDY )
3971
3972 // is vertical resizing needed
3973 if ( (mnLastResizeDY != rSize.Height()) && (mnDY != rSize.Height()) )
3974 {
3975 nCalcLines = ImplCalcLines( rSize.Height() );
3976 if ( nCalcLines < 1 )
3977 nCalcLines = 1;
3978 rSize = ImplCalcFloatSize( nCalcLines );
3979 }
3980 else
3981 {
3982 nCalcLines = 1;
3983 nTemp = nCalcLines;
3984 Size aTempSize = ImplCalcFloatSize( nTemp );
3985 while ( (aTempSize.Width() > rSize.Width()) &&
3986 (nCalcLines <= maFloatSizes[0].mnLines) )
3987 {
3988 nCalcLines++;
3989 nTemp = nCalcLines;
3990 aTempSize = ImplCalcFloatSize( nTemp );
3991 }
3992 rSize = aTempSize;
3993 }
3994
3995 mnLastResizeDY = rSize.Height();
3996}
3997
3999{
4000 // If we have any expandable entries, then force them to their
4001 // optimal sizes, then reset them afterwards
4002 std::map<vcl::Window*, Size> aExpandables;
4003 for (const ImplToolItem & rItem : mpData->m_aItems)
4004 {
4005 if (rItem.mbExpand)
4006 {
4007 vcl::Window *pWindow = rItem.mpWindow;
4008 SAL_INFO_IF(!pWindow, "vcl.layout", "only tabitems with window supported at the moment");
4009 if (!pWindow)
4010 continue;
4011 Size aWinSize(pWindow->GetSizePixel());
4012 aExpandables[pWindow] = aWinSize;
4013 Size aPrefSize(pWindow->get_preferred_size());
4014 aWinSize.setWidth( aPrefSize.Width() );
4015 pWindow->SetSizePixel(aWinSize);
4016 }
4017 }
4018
4019 Size aSize(const_cast<ToolBox *>(this)->ImplCalcSize( mnLines ));
4020
4021 for (auto const& [pWindow, aWinSize] : aExpandables)
4022 pWindow->SetSizePixel(aWinSize);
4023
4024 return aSize;
4025}
4026
4027Size ToolBox::CalcWindowSizePixel( ImplToolItems::size_type nCalcLines )
4028{
4029 return ImplCalcSize( nCalcLines );
4030}
4031
4032Size ToolBox::CalcWindowSizePixel( ImplToolItems::size_type nCalcLines, WindowAlign eAlign )
4033{
4034 return ImplCalcSize( nCalcLines,
4036}
4037
4038ToolBox::ImplToolItems::size_type ToolBox::ImplCountLineBreaks() const
4039{
4040 ImplToolItems::size_type nLines = 0;
4041
4042 for (auto const& item : mpData->m_aItems)
4043 {
4044 if( item.meType == ToolBoxItemType::BREAK )
4045 ++nLines;
4046 }
4047 return nLines;
4048}
4049
4051{
4052 // count number of breaks and calc corresponding floating window size
4053 ImplToolItems::size_type nLines = ImplCountLineBreaks();
4054
4055 if( nLines )
4056 ++nLines; // add the first line
4057 else
4058 {
4059 // no breaks found: use quadratic layout
4060 nLines = static_cast<ImplToolItems::size_type>(ceil( sqrt( static_cast<double>(GetItemCount()) ) ));
4061 }
4062
4063 bool bPopup = mpData->mbAssumePopupMode;
4064 mpData->mbAssumePopupMode = true;
4065
4066 Size aSize = CalcFloatingWindowSizePixel( nLines );
4067
4068 mpData->mbAssumePopupMode = bPopup;
4069 return aSize;
4070}
4071
4073{
4074 ImplToolItems::size_type nLines = ImplCountLineBreaks();
4075 ++nLines; // add the first line
4076 return CalcFloatingWindowSizePixel( nLines );
4077}
4078
4079Size ToolBox::CalcFloatingWindowSizePixel( ImplToolItems::size_type nCalcLines )
4080{
4081 bool bFloat = mpData->mbAssumeFloating;
4082 bool bDocking = mpData->mbAssumeDocked;
4083
4084 // simulate floating mode and force reformat before calculating
4085 mpData->mbAssumeFloating = true;
4086 mpData->mbAssumeDocked = false;
4087
4088 Size aSize = ImplCalcFloatSize( nCalcLines );
4089
4090 mbFormat = true;
4091 mpData->mbAssumeFloating = bFloat;
4092 mpData->mbAssumeDocked = bDocking;
4093
4094 return aSize;
4095}
4096
4098{
4099 if( ImplIsFloatingMode() )
4100 return ImplCalcSize( mnFloatLines );
4101 else
4102 {
4103 // create dummy toolbox for measurements
4105
4106 // copy until first useful item
4107 for (auto const& item : mpData->m_aItems)
4108 {
4109 pToolBox->CopyItem( *this, item.mnId );
4110 if( (item.meType == ToolBoxItemType::BUTTON) &&
4111 item.mbVisible && !ImplIsFixedControl( &item ) )
4112 break;
4113 }
4114
4115 // add to docking manager if required to obtain a drag area
4116 // (which is accounted for in calcwindowsizepixel)
4117 if( ImplGetDockingManager()->GetDockingWindowWrapper( this ) )
4118 ImplGetDockingManager()->AddWindow( pToolBox );
4119
4120 // account for menu
4121 if( IsMenuEnabled() )
4122 pToolBox->SetMenuType( GetMenuType() );
4123
4124 pToolBox->SetAlign( GetAlign() );
4125 Size aSize = pToolBox->CalcWindowSizePixel( 1 );
4126
4127 ImplGetDockingManager()->RemoveWindow( pToolBox );
4128 pToolBox->Clear();
4129
4130 pToolBox.disposeAndClear();
4131
4132 return aSize;
4133 }
4134}
4135
4136void ToolBox::EnableCustomize( bool bEnable )
4137{
4138 mbCustomize = bEnable;
4139}
4140
4142{
4143 ImplChangeHighlight( nullptr, true );
4144
4146}
4147
4148// performs the action associated with an item, ie simulates clicking the item
4150{
4151 mnHighItemId = nItemId;
4152 vcl::KeyCode aKeyCode( 0, 0 );
4153 ImplActivateItem( aKeyCode );
4154}
4155
4156// calls the button's action handler
4157// returns true if action was called
4159{
4160 bool bRet = true;
4161 if( mnHighItemId )
4162 {
4163 ImplToolItem *pToolItem = ImplGetItem( mnHighItemId );
4164
4165 // #107712#, activate can also be called for disabled entries
4166 if( pToolItem && !pToolItem->mbEnabled )
4167 return true;
4168
4169 if( pToolItem && pToolItem->mpWindow && HasFocus() )
4170 {
4171 ImplHideFocus();
4172 mbChangingHighlight = true; // avoid focus change due to loss of focus
4174 mbChangingHighlight = false;
4175 }
4176 else
4177 {
4179 if (pToolItem && (pToolItem->mnBits & ToolBoxItemBits::AUTOCHECK))
4180 {
4181 if ( pToolItem->mnBits & ToolBoxItemBits::RADIOCHECK )
4182 {
4183 if ( pToolItem->meState != TRISTATE_TRUE )
4184 SetItemState( pToolItem->mnId, TRISTATE_TRUE );
4185 }
4186 else
4187 {
4188 if ( pToolItem->meState != TRISTATE_TRUE )
4189 pToolItem->meState = TRISTATE_TRUE;
4190 else
4191 pToolItem->meState = TRISTATE_FALSE;
4192 }
4193 }
4194 mnMouseModifier = aKeyCode.GetModifier();
4195 mbIsKeyEvent = true;
4196 Activate();
4197 Click();
4198
4199 // #107776# we might be destroyed in the selecthandler
4200 VclPtr<vcl::Window> xWindow = this;
4201 Select();
4202 if ( xWindow->isDisposed() )
4203 return bRet;
4204
4205 Deactivate();
4206 mbIsKeyEvent = false;
4207 mnMouseModifier = 0;
4208 }
4209 }
4210 else
4211 bRet = false;
4212 return bRet;
4213}
4214
4215static bool ImplCloseLastPopup( vcl::Window const *pParent )
4216{
4217 // close last popup toolbox (see also:
4218 // ImplHandleMouseFloatMode(...) in winproc.cxx )
4219
4220 if (ImplGetSVData()->mpWinData->mpFirstFloat)
4221 {
4223 // only close the floater if it is not our direct parent, which would kill ourself
4224 if( pLastLevelFloat && pLastLevelFloat != pParent )
4225 {
4227 return true;
4228 }
4229 }
4230 return false;
4231}
4232
4233// opens a drop down toolbox item
4234// returns true if item was opened
4236{
4237 sal_uInt16 nCode = aKeyCode.GetCode();
4238 bool bRet = true;
4239
4240 // arrow keys should work only in the opposite direction of alignment (to not break cursor travelling)
4241 if ( ((nCode == KEY_LEFT || nCode == KEY_RIGHT) && IsHorizontal())
4242 || ((nCode == KEY_UP || nCode == KEY_DOWN) && !IsHorizontal()) )
4243 return false;
4244
4245 if( mpData->mbMenubuttonSelected )
4246 {
4247 if( ImplCloseLastPopup( GetParent() ) )
4248 return bRet;
4249 mbIsKeyEvent = true;
4250 if ( maMenuButtonHdl.IsSet() )
4251 maMenuButtonHdl.Call( this );
4252 else
4253 ExecuteCustomMenu( mpData->maMenubuttonItem.maRect );
4254 mpData->mbMenubuttonWasLastSelected = true;
4255 mbIsKeyEvent = false;
4256 }
4257 else if( mnHighItemId && ImplGetItem( mnHighItemId ) &&
4259 {
4262 mnLastFocusItemId = mnCurItemId; // save item id for possible later focus restore
4263 mnMouseModifier = aKeyCode.GetModifier();
4264 mbIsKeyEvent = true;
4265 Activate();
4266
4267 mpData->mbDropDownByKeyboard = true;
4268 mpData->maDropdownClickHdl.Call( this );
4269
4270 mbIsKeyEvent = false;
4271 mnMouseModifier = 0;
4272 }
4273 else
4274 bRet = false;
4275
4276 return bRet;
4277}
4278
4279void ToolBox::KeyInput( const KeyEvent& rKEvt )
4280{
4281 vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
4282 sal_uInt16 nCode = aKeyCode.GetCode();
4283
4284 vcl::Window *pParent = ImplGetParent();
4285 bool bOldSchoolContainer = ((pParent->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL);
4286 bool bParentIsContainer = bOldSchoolContainer || isContainerWindow(pParent);
4287
4288 bool bForwardKey = false;
4289 bool bGrabFocusToDocument = false;
4290
4291 // #107776# we might be destroyed in the keyhandler
4292 VclPtr<vcl::Window> xWindow = this;
4293
4294 switch ( nCode )
4295 {
4296 case KEY_UP:
4297 {
4298 // Ctrl-Cursor activates next toolbox, indicated by a blue arrow pointing to the left/up
4299 if( aKeyCode.GetModifier() ) // allow only pure cursor keys
4300 break;
4301 if( !IsHorizontal() )
4303 else
4304 ImplOpenItem( aKeyCode );
4305 }
4306 break;
4307 case KEY_LEFT:
4308 {
4309 if( aKeyCode.GetModifier() ) // allow only pure cursor keys
4310 break;
4311 if( IsHorizontal() )
4313 else
4314 ImplOpenItem( aKeyCode );
4315 }
4316 break;
4317 case KEY_DOWN:
4318 {
4319 if( aKeyCode.GetModifier() ) // allow only pure cursor keys
4320 break;
4321 if( !IsHorizontal() )
4322 ImplChangeHighlightUpDn( false );
4323 else
4324 ImplOpenItem( aKeyCode );
4325 }
4326 break;
4327 case KEY_RIGHT:
4328 {
4329 if( aKeyCode.GetModifier() ) // allow only pure cursor keys
4330 break;
4331 if( IsHorizontal() )
4332 ImplChangeHighlightUpDn( false );
4333 else
4334 ImplOpenItem( aKeyCode );
4335 }
4336 break;
4337 case KEY_PAGEUP:
4338 if ( mnCurLine > 1 )
4339 {
4340 if( mnCurLine > mnVisLines )
4342 else
4343 mnCurLine = 1;
4344 mbFormat = true;
4345 ImplFormat();
4348 }
4349 break;
4350 case KEY_PAGEDOWN:
4352 {
4353 if( mnCurLine + 2*mnVisLines-1 < mnCurLines )
4355 else
4357 mbFormat = true;
4358 ImplFormat();
4361 }
4362 break;
4363 case KEY_END:
4364 {
4365 ImplChangeHighlight( nullptr );
4366 ImplChangeHighlightUpDn( false );
4367 }
4368 break;
4369 case KEY_HOME:
4370 {
4371 ImplChangeHighlight( nullptr );
4373 }
4374 break;
4375 case KEY_ESCAPE:
4376 {
4377 if( !ImplIsFloatingMode() && bParentIsContainer )
4378 DockingWindow::KeyInput( rKEvt );
4379 else
4380 {
4381 // send focus to document pane
4382 vcl::Window *pWin = this;
4383 while( pWin )
4384 {
4385 if( !pWin->GetParent() )
4386 {
4388 break;
4389 }
4390 pWin = pWin->GetParent();
4391 }
4392 }
4393 }
4394 break;
4395 case KEY_RETURN:
4396 {
4397 // #107712#, disabled entries are selectable now
4398 // leave toolbox and move focus to document
4399 if( mnHighItemId )
4400 {
4402 if (!pItem || !pItem->mbEnabled)
4403 {
4404 bGrabFocusToDocument = true;
4405 }
4406 }
4407 if( !bGrabFocusToDocument )
4408 bForwardKey = !ImplActivateItem( aKeyCode );
4409 }
4410 break;
4411 case KEY_SPACE:
4412 {
4413 ImplOpenItem( aKeyCode );
4414 }
4415 break;
4416 default:
4417 {
4418 sal_uInt16 aKeyGroup = aKeyCode.GetGroup();
4419 ImplToolItem *pItem = nullptr;
4420 if( mnHighItemId )
4421 pItem = ImplGetItem( mnHighItemId );
4422 // #i13931# forward alphanum keyinput into embedded control
4423 if( (aKeyGroup == KEYGROUP_NUM || aKeyGroup == KEYGROUP_ALPHA ) && pItem && pItem->mpWindow && pItem->mbEnabled )
4424 {
4425 vcl::Window *pFocusWindow = Application::GetFocusWindow();
4426 ImplHideFocus();
4427 mbChangingHighlight = true; // avoid focus change due to loss of focus
4429 mbChangingHighlight = false;
4430 if( pFocusWindow != Application::GetFocusWindow() )
4432 }
4433 else
4434 {
4435 // do nothing to avoid key presses going into the document
4436 // while the toolbox has the focus
4437 // just forward function and special keys and combinations with Alt-key
4438 if( aKeyGroup == KEYGROUP_FKEYS || aKeyGroup == KEYGROUP_MISC || aKeyCode.IsMod2() )
4439 bForwardKey = true;
4440 }
4441 }
4442 }
4443
4444 if ( xWindow->isDisposed() )
4445 return;
4446
4447 // #107251# move focus away if this toolbox was disabled during keyinput
4448 if (HasFocus() && mpData->mbKeyInputDisabled && bParentIsContainer)
4449 {
4450 vcl::Window *pFocusControl = pParent->ImplGetDlgWindow( 0, GetDlgWindowType::First );
4451 if ( pFocusControl && pFocusControl != this )
4452 pFocusControl->ImplControlFocus( GetFocusFlags::Init );
4453 }
4454
4455 // #107712#, leave toolbox
4456 if( bGrabFocusToDocument )
4457 {
4459 return;
4460 }
4461
4462 if( bForwardKey )
4463 DockingWindow::KeyInput( rKEvt );
4464}
4465
4466// returns the current toolbox line of the item
4467ToolBox::ImplToolItems::size_type ToolBox::ImplGetItemLine( ImplToolItem const * pCurrentItem )
4468{
4469 ImplToolItems::size_type nLine = 1;
4470 for (auto const& item : mpData->m_aItems)
4471 {
4472 if ( item.mbBreak )
4473 ++nLine;
4474 if( &item == pCurrentItem)
4475 break;
4476 }
4477 return nLine;
4478}
4479
4480// returns the first displayable item in the given line
4481ImplToolItem* ToolBox::ImplGetFirstValidItem( ImplToolItems::size_type nLine )
4482{
4483 if( !nLine || nLine > mnCurLines )
4484 return nullptr;
4485
4486 nLine--;
4487
4488 ImplToolItems::iterator it = mpData->m_aItems.begin();
4489 while( it != mpData->m_aItems.end() )
4490 {
4491 // find correct line
4492 if ( it->mbBreak )
4493 nLine--;
4494 if( !nLine )
4495 {
4496 // find first useful item
4497 while( it != mpData->m_aItems.end() && ((it->meType != ToolBoxItemType::BUTTON) || !it->mbVisible || ImplIsFixedControl( &(*it) )) )
4499 {
4500 ++it;
4501 if( it == mpData->m_aItems.end() || it->mbBreak )
4502 return nullptr; // no valid items in this line
4503 }
4504 return &(*it);
4505 }
4506 ++it;
4507 }
4508
4509 return (it == mpData->m_aItems.end()) ? nullptr : &(*it);
4510}
4511
4512ToolBox::ImplToolItems::size_type ToolBox::ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList )
4513{
4514 if( pItem )
4515 {
4516 for( ImplToolItems::size_type nPos = 0; nPos < rList.size(); ++nPos )
4517 if( &rList[ nPos ] == pItem )
4518 return nPos;
4519 }
4520 return ITEM_NOTFOUND;
4521}
4522
4523void ToolBox::ChangeHighlight( ImplToolItems::size_type nPos )
4524{
4525 if ( nPos < GetItemCount() ) {
4528 }
4529}
4530
4531void ToolBox::ImplChangeHighlight( ImplToolItem const * pItem, bool bNoGrabFocus )
4532{
4533 // avoid recursion due to focus change
4535 return;
4536
4537 mbChangingHighlight = true;
4538
4539 ImplToolItem* pOldItem = nullptr;
4540
4541 if ( mnHighItemId )
4542 {
4543 ImplHideFocus();
4544 ImplToolItems::size_type nPos = GetItemPos( mnHighItemId );
4545 pOldItem = ImplGetItem( mnHighItemId );
4546 // #i89962# ImplDrawItem can cause Invalidate/Update
4547 // which will in turn ImplShowFocus again
4548 // set mnHighItemId to 0 already to prevent this hen/egg problem
4551 CallEventListeners( VclEventId::ToolboxHighlightOff, reinterpret_cast< void* >( nPos ) );
4552 }
4553
4554 if( !bNoGrabFocus && pItem != pOldItem && pOldItem && pOldItem->mpWindow )
4555 {
4556 // move focus into toolbox
4557 GrabFocus();
4558 }
4559
4560 if( pItem )
4561 {
4562 ImplToolItems::size_type aPos = ToolBox::ImplFindItemPos( pItem, mpData->m_aItems );
4563 if( aPos != ITEM_NOTFOUND)
4564 {
4565 // check for line breaks
4566 ImplToolItems::size_type nLine = ImplGetItemLine( pItem );
4567
4568 if( nLine >= mnCurLine + mnVisLines )
4569 {
4570 mnCurLine = nLine - mnVisLines + 1;
4571 mbFormat = true;
4572 }
4573 else if ( nLine < mnCurLine )
4574 {
4575 mnCurLine = nLine;
4576 mbFormat = true;
4577 }
4578
4579 if( mbFormat )
4580 {
4581 ImplFormat();
4582 }
4583
4584 mnHighItemId = pItem->mnId;
4585 InvalidateItem(aPos);
4586
4587 ImplShowFocus();
4588
4589 if( pItem->mpWindow )
4590 pItem->mpWindow->GrabFocus();
4591 if( pItem != pOldItem )
4593 }
4594 }
4595 else
4596 {
4597 ImplHideFocus();
4600 }
4601
4602 mbChangingHighlight = false;
4603}
4604
4605// check for keyboard accessible items
4606static bool ImplIsValidItem( const ImplToolItem* pItem, bool bNotClipped )
4607{
4608 bool bValid = (pItem && pItem->meType == ToolBoxItemType::BUTTON && pItem->mbVisible && !ImplIsFixedControl( pItem )
4609 && pItem->mbEnabled);
4610 if( bValid && bNotClipped && pItem->IsClipped() )
4611 bValid = false;
4612 return bValid;
4613}
4614
4615bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
4616{
4617 ImplToolItem* pToolItem = ImplGetItem( mnHighItemId );
4618
4619 if( !pToolItem || !mnHighItemId )
4620 {
4621 // menubutton highlighted ?
4622 if( mpData->mbMenubuttonSelected )
4623 {
4624 mpData->mbMenubuttonSelected = false;
4625 if( bUp )
4626 {
4627 // select last valid non-clipped item
4628 ImplToolItem* pItem = nullptr;
4629 auto it = std::find_if(mpData->m_aItems.rbegin(), mpData->m_aItems.rend(),
4630 [](const ImplToolItem& rItem) { return ImplIsValidItem( &rItem, true ); });
4631 if( it != mpData->m_aItems.rend() )
4632 pItem = &(*it);
4633
4635 ImplChangeHighlight( pItem );
4636 }
4637 else
4638 {
4639 // select first valid non-clipped item
4640 ImplToolItems::iterator it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
4641 [](const ImplToolItem& rItem) { return ImplIsValidItem( &rItem, true ); });
4642 if( it != mpData->m_aItems.end() )
4643 {
4645 ImplChangeHighlight( &(*it) );
4646 }
4647 }
4648 return true;
4649 }
4650
4651 if( bUp )
4652 {
4653 // Select first valid item
4654 ImplToolItems::iterator it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
4655 [](const ImplToolItem& rItem) { return ImplIsValidItem( &rItem, false ); });
4656
4657 // select the menu button if a clipped item would be selected
4658 if( (it != mpData->m_aItems.end() && &(*it) == ImplGetFirstClippedItem()) && IsMenuEnabled() )
4659 {
4660 ImplChangeHighlight( nullptr );
4661 mpData->mbMenubuttonSelected = true;
4663 }
4664 else
4665 ImplChangeHighlight( (it != mpData->m_aItems.end()) ? &(*it) : nullptr );
4666 return true;
4667 }
4668 else
4669 {
4670 // Select last valid item
4671
4672 // docked toolbars have the menubutton as last item - if this button is enabled
4674 {
4675 ImplChangeHighlight( nullptr );
4676 mpData->mbMenubuttonSelected = true;
4678 }
4679 else
4680 {
4681 ImplToolItem* pItem = nullptr;
4682 auto it = std::find_if(mpData->m_aItems.rbegin(), mpData->m_aItems.rend(),
4683 [](const ImplToolItem& rItem) { return ImplIsValidItem( &rItem, false ); });
4684 if( it != mpData->m_aItems.rend() )
4685 pItem = &(*it);
4686
4687 ImplChangeHighlight( pItem );
4688 }
4689 return true;
4690 }
4691 }
4692
4693 assert(pToolItem);
4694
4695 ImplToolItems::size_type pos = ToolBox::ImplFindItemPos( pToolItem, mpData->m_aItems );
4696 ImplToolItems::size_type nCount = mpData->m_aItems.size();
4697
4698 ImplToolItems::size_type i=0;
4699 do
4700 {
4701 if( bUp )
4702 {
4703 if( !pos-- )
4704 {
4705 if( bNoCycle )
4706 return false;
4707
4708 // highlight the menu button if it is the last item
4710 {
4711 ImplChangeHighlight( nullptr );
4712 mpData->mbMenubuttonSelected = true;
4714 return true;
4715 }
4716 else
4717 pos = nCount-1;
4718 }
4719 }
4720 else
4721 {
4722 if( ++pos >= nCount )
4723 {
4724 if( bNoCycle )
4725 return false;
4726
4727 // highlight the menu button if it is the last item
4729 {
4730 ImplChangeHighlight( nullptr );
4731 mpData->mbMenubuttonSelected = true;
4733 return true;
4734 }
4735 else
4736 pos = 0;
4737 }
4738 }
4739
4740 pToolItem = &mpData->m_aItems[pos];
4741
4742 if ( ImplIsValidItem( pToolItem, false ) )
4743 break;
4744
4745 } while( ++i < nCount);
4746
4747 if( pToolItem->IsClipped() && IsMenuEnabled() )
4748 {
4749 // select the menu button if a clipped item would be selected
4750 ImplChangeHighlight( nullptr );
4751 mpData->mbMenubuttonSelected = true;
4753 }
4754 else if( i != nCount )
4755 ImplChangeHighlight( pToolItem );
4756 else
4757 return false;
4758
4759 return true;
4760}
4761
4763{
4764 if( mnHighItemId && HasFocus() )
4765 {
4767 if (pItem && pItem->mpWindow && !pItem->mpWindow->isDisposed())
4768 {
4771 pWin->Invalidate();
4772 }
4773 }
4774}
4775
4777{
4778 if( mnHighItemId )
4779 {
4780 mpData->mbMenubuttonWasLastSelected = false;
4782 if( pItem && pItem->mpWindow )
4783 {
4786 pWin->Invalidate();
4787 }
4788 }
4789
4790 if ( mpData && mpData->mbMenubuttonSelected )
4791 {
4792 mpData->mbMenubuttonWasLastSelected = true;
4793 // remove highlight from menubutton
4794 mpData->mbMenubuttonSelected = false;
4796 }
4797}
4798
4800{
4801 if ( meLayoutMode != eLayout )
4802 meLayoutMode = eLayout;
4803}
4804
4806{
4807 meTextPosition = ePosition;
4808}
4809
4810/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawImageFlags
DrawTextFlags
sal_Int32 nLineWidth
void SetSelectHdl(const Link< Accelerator &, void > &rLink)
Definition: accel.hxx:88
void InsertItem(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: accel.cxx:233
const StyleSettings & GetStyleSettings() const
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1043
static bool InsertAccel(Accelerator *pAccel)
Insert accelerator.
Definition: svapp.cxx:1323
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:638
static void RemoveAccel(Accelerator const *pAccel)
Remove accelerator.
Definition: svapp.cxx:1332
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1352
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1038
bool IsEmpty() const
Definition: BitmapEx.cxx:186
bool IsDark() const
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
const Point & GetMousePosPixel() const
DataChangedEventType GetType() const
Definition: event.hxx:362
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
void RemoveWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:394
void AddWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:386
ImplDockingWindowWrapper * GetDockingWindowWrapper(const vcl::Window *pWin)
Definition: dockmgr.cxx:280
void SetMinOutputSizePixel(const Size &rSize)
Definition: dockwin.cxx:1063
bool mbIsDeferredInit
Definition: dockwin.hxx:144
void SetOutputSizePixel(const Size &rNewSize) override
Definition: dockwin.cxx:883
Point GetPosPixel() const override
Definition: dockwin.cxx:849
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: dockwin.cxx:686
virtual void StateChanged(StateChangedType nType) override
Definition: dockwin.cxx:662
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: dockwin.cxx:313
Size GetSizePixel() const override
Definition: dockwin.cxx:866
virtual void StartDocking()
Definition: dockwin.cxx:583
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: dockwin.cxx:525
Size GetOutputSizePixel() const
Definition: dockwin.cxx:901
virtual void EndDocking(const tools::Rectangle &rRect, bool bFloatMode)
Definition: dockwin.cxx:593
virtual bool Docking(const Point &rPos, tools::Rectangle &rRect)
Definition: dockwin.cxx:588
void SetMaxOutputSizePixel(const Size &rSize)
Definition: dockwin.cxx:960
void loadUI(vcl::Window *pParent, const OUString &rID, const OUString &rUIXMLDescription, const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: dockwin.cxx:371
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: dockwin.cxx:410
bool IsDockingCanceled() const
Definition: dockwin.hxx:203
VclPtr< vcl::Window > mpDialogParent
Definition: dockwin.hxx:145
virtual void ToggleFloatingMode()
Definition: dockwin.cxx:639
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: dockwin.cxx:395
SAL_DLLPRIVATE FloatingWindow * ImplFindLastLevelFloat()
Definition: floatwin.cxx:589
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:964
void SetStyle(css::awt::GradientStyle eStyle)
void SetStartColor(const Color &rColor)
void SetAngle(Degree10 nAngle)
void SetEndColor(const Color &rColor)
HelpEventMode GetMode() const
Definition: event.hxx:208
bool KeyboardActivated() const
Definition: event.hxx:209
const Point & GetMousePosPixel() const
Definition: event.hxx:207
Definition: help.hxx:61
virtual OUString GetHelpText(const OUString &aHelpURL, const weld::Widget *pWidget)
Definition: help.cxx:72
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
Definition: help.cxx:180
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
Definition: help.cxx:157
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:35
Definition: image.hxx:40
Size GetSizePixel() const
Definition: Image.cxx:88
void setTristateVal(ButtonValue nTristate)
ImplDockingWindowWrapper.
void SetDragArea(const tools::Rectangle &rRect)
Definition: dockmgr.cxx:1044
const tools::Rectangle & GetDragArea() const
void ShowMenuTitleButton(bool bVisible)
Definition: dockmgr.cxx:757
void SetMinOutputSizePixel(const Size &rSize)
Definition: dockmgr.cxx:1025
void SetMaxOutputSizePixel(const Size &rSize)
Definition: dockmgr.cxx:1032
DECL_LINK(SelectHdl, Accelerator &, void)
ImplTBDragMgr(const ImplTBDragMgr &)=delete
Point maMouseOff
Definition: toolbox.cxx:93
sal_uInt16 mnLineMode
Definition: toolbox.cxx:97
tools::Rectangle maRect
Definition: toolbox.cxx:94
Accelerator maAccel
Definition: toolbox.cxx:96
tools::Rectangle maStartRect
Definition: toolbox.cxx:95
void StartDragging(ToolBox *pDragBox, const Point &rPos, const tools::Rectangle &rRect, sal_uInt16 nLineMode)
Definition: toolbox.cxx:1044
void EndDragging(bool bOK=true)
Definition: toolbox.cxx:1074
ImplTBDragMgr & operator=(const ImplTBDragMgr &)=delete
void Dragging(const Point &rPos)
Definition: toolbox.cxx:1064
VclPtr< ToolBox > mpDragBox
Definition: toolbox.cxx:92
ToolBox::ImplToolItems::size_type mnStartLines
Definition: toolbox.cxx:98
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
static OUString EraseAllMnemonicChars(const OUString &rStr)
MouseEventModifiers GetMode() const
Definition: event.hxx:124
bool IsLeaveWindow() const
Definition: event.hxx:140
sal_uInt16 GetModifier() const
Definition: event.hxx:156
sal_uInt16 GetClicks() const
Definition: event.hxx:126
const Point & GetPosPixel() const
Definition: event.hxx:123
bool IsLeft() const
Definition: event.hxx:149
const KeyEvent * GetKeyEvent() const
Definition: event.hxx:316
vcl::Window * GetWindow() const
Definition: event.hxx:309
NotifyEventType GetType() const
Definition: event.hxx:308
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
void DrawCtrlText(const Point &rPos, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, DrawTextFlags nStyle=DrawTextFlags::Mnemonic, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr)
Definition: text.cxx:2149
const vcl::Font & GetFont() const
Definition: outdev.hxx:529
void SetAntialiasing(AntialiasingFlags nMode)
Definition: outdev.cxx:349
float GetDPIScaleFactor() const
Definition: outdev.hxx:396
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
void DrawEllipse(const tools::Rectangle &rRect)
Size GetOutputSizePixel() const
Definition: outdev.hxx:314
bool IsFillColor() const
Definition: outdev.hxx:516
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:50
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:161
void SetLineColor()
Definition: line.cxx:37
void DrawPolygon(const tools::Polygon &rPoly)
Render the given polygon.
Definition: polygon.cxx:154
bool IsLineColor() const
Definition: outdev.hxx:511
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void SetFillColor()
Definition: fill.cxx:29
const Color & GetLineColor() const
Definition: outdev.hxx:510
void SetTextFillColor()
Definition: text.cxx:734
void DrawWallpaper(const tools::Rectangle &rRect, const Wallpaper &rWallpaper)
Definition: wallpaper.cxx:35
virtual void Flush()
Definition: outdev.hxx:429
void Erase()
Definition: wallpaper.cxx:96
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:32
void DrawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
void SetBackground()
Definition: background.cxx:27
void Pop()
Definition: stack.cxx:91
AntialiasingFlags GetAntialiasing() const
Definition: outdev.hxx:484
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
const AllSettings & GetSettings() const
Definition: outdev.hxx:288
void IntersectClipRegion(const tools::Rectangle &rRect)
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
const Color & GetFillColor() const
Definition: outdev.hxx:515
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
BitmapEx const & GetPersonaHeader() const
const Color & GetWindowColor() const
bool GetHighContrastMode() const
const Color & GetShadowColor() const
BitmapEx const & GetPersonaFooter() const
Color GetSeparatorColor() const
const Color & GetWindowTextColor() const
const Color & GetLightColor() const
const vcl::Font & GetToolFont() const
Color GetFaceGradientColor() const
sal_Int32 GetFloatTitleHeight() const
const Color & GetFaceColor() const
const Color & GetToolTextColor() const
const Color & GetButtonTextColor() const
Definition: timer.hxx:27
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:74
SAL_DLLPRIVATE bool ImplIsFloatingMode() const
Definition: toolbox2.cxx:1619
SAL_DLLPRIVATE void ApplyForegroundSettings(vcl::RenderContext &, const StyleSettings &)
Definition: toolbox.cxx:1180
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: toolbox.cxx:1165
SAL_DLLPRIVATE ImplToolItems::size_type ImplCountLineBreaks() const
Definition: toolbox.cxx:4038
bool mbUpper
Definition: toolbox.hxx:130
bool mbLastFloatMode
Definition: toolbox.hxx:138
ToolBoxItemId GetItemId(ImplToolItems::size_type nPos) const
Definition: toolbox2.cxx:746
SAL_DLLPRIVATE bool ImplHandleMouseButtonUp(const MouseEvent &rMEvt, bool bCancel=false)
Definition: toolbox.cxx:2925
ImplToolItems::size_type mnCurLine
Definition: toolbox.hxx:123
SAL_DLLPRIVATE ImplToolItem * ImplGetFirstValidItem(ImplToolItems::size_type nLine)
Definition: toolbox.cxx:4481
ToolBoxItemId mnCurItemId
Definition: toolbox.hxx:119
void ChangeHighlight(ImplToolItems::size_type nPos)
Definition: toolbox.cxx:4523
virtual void StartDocking() override
Definition: toolbox.cxx:3900
bool mbIsArranged
Definition: toolbox.hxx:144
SAL_DLLPRIVATE void ImplUpdateDragArea() const
Definition: toolbox.cxx:169
virtual Size GetOptimalSize() const override
Definition: toolbox.cxx:3998
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: toolbox.cxx:3613
ImplToolItems::size_type mnCurPos
Definition: toolbox.hxx:121
WindowAlign meDockAlign
Definition: toolbox.hxx:146
virtual void Resizing(Size &rSize) override
Definition: toolbox.cxx:3961
virtual void Click()
Definition: toolbox2.cxx:331
static SAL_DLLPRIVATE void ImplDrawConstantBackground(vcl::RenderContext &rRenderContext, const vcl::Region &rRegion, bool bIsInPopupMode)
Definition: toolbox.cxx:456
tools::Long mnBottomBorder
Definition: toolbox.hxx:114
SAL_DLLPRIVATE void ImplDrawGradientBackground(vcl::RenderContext &rRenderContext)
Definition: toolbox.cxx:310
SAL_DLLPRIVATE bool ImplHandleMouseMove(const MouseEvent &rMEvt, bool bRepeat=false)
Definition: toolbox.cxx:2862
Size GetDefaultImageSize() const
Definition: toolbox2.cxx:666
ImplToolItems::size_type mnVisLines
Definition: toolbox.hxx:125
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: toolbox.cxx:3821
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: toolbox.cxx:3025
static SAL_DLLPRIVATE ImplToolItems::size_type ImplFindItemPos(const ImplToolItem *pItem, const ImplToolItems &rList)
Definition: toolbox.cxx:4512
SAL_DLLPRIVATE bool ImplHasExternalMenubutton() const
Definition: toolbox2.cxx:863
Size CalcMinimumWindowSizePixel()
Definition: toolbox.cxx:4097
virtual void StateChanged(StateChangedType nType) override
Definition: toolbox.cxx:3786
tools::Long mnWinHeight
Definition: toolbox.hxx:110
Link< StateChangedType const *, void > maStateChangedHandler
Definition: toolbox.hxx:158
virtual void doDeferredInit(WinBits nBits) override
Definition: toolbox.cxx:1255
ImplToolItems::size_type mnDockLines
Definition: toolbox.hxx:127
SAL_DLLPRIVATE bool ImplActivateItem(vcl::KeyCode aKeyCode)
Definition: toolbox.cxx:4158
virtual void Activate() override
Definition: toolbox2.cxx:344
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: toolbox.cxx:3175
tools::Rectangle maUpperRect
Definition: toolbox.hxx:102
SAL_DLLPRIVATE bool ImplDrawNativeBackground(vcl::RenderContext &rRenderContext) const
Definition: toolbox.cxx:435
bool mbDrag
Definition: toolbox.hxx:129
bool mbCustomize
Definition: toolbox.hxx:139
ImplToolItems::size_type mnCurLines
Definition: toolbox.hxx:124
ButtonType meButtonType
Definition: toolbox.hxx:147
SAL_DLLPRIVATE void ApplyBackgroundSettings(vcl::RenderContext &, const StyleSettings &)
Definition: toolbox.cxx:1193
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: toolbox.cxx:1263
SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow)
Definition: toolbox.cxx:2523
std::vector< ImplToolSize > maFloatSizes
Definition: toolbox.hxx:100
ToolBoxMenuType GetMenuType() const
Definition: toolbox2.cxx:1465
SAL_DLLPRIVATE int ImplGetDragWidth() const
Definition: toolbox.cxx:149
SAL_DLLPRIVATE void ImplDrawSpin(vcl::RenderContext &rRenderContext)
Definition: toolbox.cxx:2456
SAL_DLLPRIVATE void ImplErase(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect, bool bHighlight, bool bHasOpenPopup=false)
Definition: toolbox.cxx:525
bool mbCalc
Definition: toolbox.hxx:133
tools::Long mnActivateCount
Definition: toolbox.hxx:116
std::unique_ptr< Idle > mpIdle
Definition: toolbox.hxx:101
SAL_DLLPRIVATE void ImplDrawBorder(vcl::RenderContext &rRenderContext)
Definition: toolbox.cxx:553
Size CalcWindowSizePixel()
Definition: toolbox.hxx:519
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: toolbox.cxx:1299
std::vector< ImplToolItem > ImplToolItems
Definition: toolbox.hxx:79
SAL_DLLPRIVATE void ImplInitToolBoxData()
Definition: toolbox.cxx:1102
tools::Long mnDY
Definition: toolbox.hxx:107
SAL_DLLPRIVATE void ImplDrawBackground(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: toolbox.cxx:473
static SAL_DLLPRIVATE void ImplDrawFloatwinBorder(vcl::RenderContext &rRenderContext, ImplToolItem const *pItem)
Definition: toolbox.cxx:2780
PointerStyle meLastStyle
Definition: toolbox.hxx:148
virtual void ToggleFloatingMode() override
Definition: toolbox.cxx:3855
SAL_DLLPRIVATE void InvalidateItem(ImplToolItems::size_type nPosition)
Definition: toolbox.cxx:3396
ToolBoxLayoutMode meLayoutMode
Definition: toolbox.hxx:150
SAL_DLLPRIVATE bool ImplHasClippedItems()
Definition: toolbox2.cxx:1485
void TriggerItem(ToolBoxItemId nItemId)
Definition: toolbox.cxx:4149
WinBits mnWinStyle
Definition: toolbox.hxx:149
virtual void EndDocking(const tools::Rectangle &rRect, bool bFloatMode) override
Definition: toolbox.cxx:3948
bool mbIn
Definition: toolbox.hxx:132
VclPtr< FloatingWindow > mpFloatWin
Definition: toolbox.hxx:105
SAL_DLLPRIVATE void ImplCheckUpdate()
Definition: toolbox.cxx:234
SAL_DLLPRIVATE bool ImplChangeHighlightUpDn(bool bUp, bool bNoCycle=false)
Definition: toolbox.cxx:4615
SAL_DLLPRIVATE void ImplShowFocus()
Definition: toolbox.cxx:4762
SAL_DLLPRIVATE void InvalidateMenuButton()
Definition: toolbox.cxx:3405
virtual void Resize() override
Definition: toolbox.cxx:3473
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: toolbox.cxx:3366
ImplToolItems::size_type GetItemCount() const
Definition: toolbox2.cxx:712
ImplToolItems::size_type mnLines
Definition: toolbox.hxx:122
virtual void LoseFocus() override
Definition: toolbox.cxx:4141
void SetStyle(WinBits nNewStyle)
Definition: toolbox.cxx:3840
tools::Long mnRightBorder
Definition: toolbox.hxx:113
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: toolbox.cxx:3669
SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext &rRenderContext, bool bHighlight)
Definition: toolbox.cxx:2426
void SetToolBoxTextPosition(ToolBoxTextPosition ePosition)
Definition: toolbox.cxx:4805
virtual void Deactivate() override
Definition: toolbox2.cxx:351
SAL_DLLPRIVATE void ImplCalcMinMaxFloatSize(Size &rMinSize, Size &rMaxSize)
Definition: toolbox.cxx:838
ImplToolItems::size_type mnFloatLines
Definition: toolbox.hxx:126
tools::Rectangle maPaintRect
Definition: toolbox.hxx:104
bool mbLineSpacing
Definition: toolbox.hxx:143
Link< ToolBox *, void > maMenuButtonHdl
Definition: toolbox.hxx:157
Size CalcPopupWindowSizePixel()
Definition: toolbox.cxx:4050
ToolBoxItemId mnDownItemId
Definition: toolbox.hxx:120
SAL_DLLPRIVATE Size ImplCalcSize(ImplToolItems::size_type nCalcLines, sal_uInt16 nCalcMode=0)
Definition: toolbox.cxx:637
tools::Long mnLeftBorder
Definition: toolbox.hxx:111
void SetItemState(ToolBoxItemId nItemId, TriState eState)
Definition: toolbox2.cxx:1143
bool mbChangingHighlight
Definition: toolbox.hxx:142
void ExecuteCustomMenu(const tools::Rectangle &rRect=tools::Rectangle())
Definition: toolbox2.cxx:1563
void SetLineCount(ImplToolItems::size_type nNewLines)
Definition: toolbox2.cxx:697
SAL_DLLPRIVATE bool ImplIsInPopupMode() const
Definition: toolbox2.cxx:1633
SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcLines(tools::Long nToolSize) const
Definition: toolbox.cxx:878
virtual bool Docking(const Point &rPos, tools::Rectangle &rRect) override
Definition: toolbox.cxx:3908
SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcBreaks(tools::Long nWidth, sal_Int32 *pMaxLineWidth, bool bCalcHorz) const
Definition: toolbox.cxx:1651
SAL_DLLPRIVATE Size ImplGetOptimalFloatingSize()
Definition: toolbox.cxx:1799
SAL_DLLPRIVATE void ImplChangeHighlight(ImplToolItem const *pItem, bool bNoGrabFocus=false)
Definition: toolbox.cxx:4531
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: toolbox.cxx:4279
tools::Long mnLastResizeDY
Definition: toolbox.hxx:115
SAL_DLLPRIVATE ImplToolItem * ImplGetItem(ToolBoxItemId nId) const
Definition: toolbox.cxx:1325
SAL_DLLPRIVATE ImplToolItems::size_type ImplGetItemLine(ImplToolItem const *pCurrentItem)
Definition: toolbox.cxx:4467
void DoubleClick()
Definition: toolbox2.cxx:338
SAL_DLLPRIVATE bool ImplOpenItem(vcl::KeyCode aKeyCode)
Definition: toolbox.cxx:4235
static SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext &rRenderContext, const tools::Rectangle &aDragArea, int nDragWidth, WindowAlign eAlign, bool bHorz)
Definition: toolbox.cxx:246
WindowAlign meAlign
Definition: toolbox.hxx:145
void SetToolbarLayoutMode(ToolBoxLayoutMode eLayout)
Definition: toolbox.cxx:4799
SAL_DLLPRIVATE void ImplDrawTransparentBackground(const vcl::Region &rRegion)
Definition: toolbox.cxx:444
bool mbIsKeyEvent
Definition: toolbox.hxx:141
SAL_DLLPRIVATE Size ImplCalcFloatSize(ImplToolItems::size_type &rLines)
Definition: toolbox.cxx:815
void Highlight()
Definition: toolbox2.cxx:358
SAL_DLLPRIVATE void ImplHideFocus()
Definition: toolbox.cxx:4776
bool IsMenuEnabled() const
Definition: toolbox2.cxx:1470
tools::Rectangle GetItemRect(ToolBoxItemId nItemId)
Definition: toolbox2.cxx:838
bool mbFullPaint
Definition: toolbox.hxx:135
tools::Long mnMaxItemHeight
Definition: toolbox.hxx:109
Size CalcFloatingWindowSizePixel()
Definition: toolbox.cxx:4072
SAL_DLLPRIVATE const OUString & ImplGetHelpText(ToolBoxItemId nItemId) const
Definition: toolbox.cxx:3592
std::unique_ptr< ImplToolBoxPrivateData > mpData
Definition: toolbox.hxx:99
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: toolbox.cxx:1227
bool mbFormat
Definition: toolbox.hxx:134
SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize(const Point &rPos) const
Definition: toolbox.cxx:909
bool mbDragging
Definition: toolbox.hxx:140
SAL_DLLPRIVATE void ImplInitSettings()
Definition: dockwin.cxx:328
void ShowLine(bool bNext)
Definition: toolbox.cxx:2850
bool IsHorizontal() const
Definition: toolbox.hxx:333
sal_uInt16 mnMouseModifier
Definition: toolbox.hxx:128
virtual ~ToolBox() override
Definition: toolbox.cxx:1294
ToolBoxTextPosition meTextPosition
Definition: toolbox.hxx:151
virtual void Command(const CommandEvent &rCEvt) override
Definition: toolbox.cxx:3759
virtual void Select()
Definition: toolbox2.cxx:368
tools::Long mnMaxItemWidth
Definition: toolbox.hxx:108
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: toolbox.cxx:3420
ToolBox(const ToolBox &)=delete
ToolBoxButtonSize GetToolboxButtonSize() const
Definition: toolbox2.cxx:630
tools::Long mnTopBorder
Definition: toolbox.hxx:112
SAL_DLLPRIVATE void ImplLineSizing(const Point &rPos, tools::Rectangle &rRect, sal_uInt16 nLineMode)
Definition: toolbox.cxx:941
SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext &rRenderContext, ImplToolItems::size_type nPos, sal_uInt16 nHighlight)
Definition: toolbox.cxx:2550
ToolBoxItemId mnHighItemId
Definition: toolbox.hxx:118
SAL_DLLPRIVATE void InvalidateSpin(bool bInvalidateUpper=true, bool bInvalidateLower=true)
Definition: toolbox.cxx:3411
SAL_DLLPRIVATE void ImplUpdateItem(ImplToolItems::size_type nIndex=ITEM_NOTFOUND)
Definition: toolbox2.cxx:308
SAL_DLLPRIVATE const ImplToolItem * ImplGetFirstClippedItem() const
Definition: toolbox.cxx:627
SAL_DLLPRIVATE void ImplDrawSeparator(vcl::RenderContext &rRenderContext, ImplToolItems::size_type nPos, const tools::Rectangle &rRect)
Definition: toolbox.cxx:2478
SAL_DLLPRIVATE void ImplFormat(bool bResize=false)
Definition: toolbox.cxx:1887
bool mbLower
Definition: toolbox.hxx:131
static constexpr auto ITEM_NOTFOUND
Definition: toolbox.hxx:89
void SetAlign(WindowAlign eNewAlign=WindowAlign::Top)
Definition: toolbox2.cxx:671
tools::Rectangle maLowerRect
Definition: toolbox.hxx:103
SAL_DLLPRIVATE void ImplCalcFloatSizes()
Definition: toolbox.cxx:753
bool mbHorz
Definition: toolbox.hxx:136
void EnableCustomize(bool bEnable=true)
Definition: toolbox.cxx:4136
SAL_DLLPRIVATE void ImplCalcBorder(WindowAlign eAlign, tools::Long &rLeft, tools::Long &rTop, tools::Long &rRight, tools::Long &rBottom) const
Definition: toolbox.cxx:186
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: toolbox.cxx:3381
ToolBoxItemId mnLastFocusItemId
Definition: toolbox.hxx:117
WindowAlign GetAlign() const
Definition: toolbox.hxx:332
bool mbScroll
Definition: toolbox.hxx:137
const OUString & GetItemText(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1048
SAL_DLLPRIVATE bool ImplCalcItem()
Definition: toolbox.cxx:1352
WinBits GetStyle() const
Definition: toolbox.hxx:434
Link< DataChangedEvent const *, void > maDataChangedHandler
Definition: toolbox.hxx:159
ImplToolItems::size_type GetItemPos(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:722
tools::Long mnDX
Definition: toolbox.hxx:106
SAL_DLLPRIVATE void ImplFloatControl(bool bStart, FloatingWindow *pWindow)
Definition: toolbox.cxx:2812
SAL_DLLPRIVATE void ImplSetMinMaxFloatSize()
Definition: toolbox.cxx:859
tools::Rectangle maGripRect
bool IsTrackingEnded() const
Definition: event.hxx:261
bool IsTrackingRepeat() const
Definition: event.hxx:259
bool IsTrackingCanceled() const
Definition: event.hxx:263
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:257
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:277
void disposeAndClear()
Definition: vclptr.hxx:200
void clear()
Definition: vclptr.hxx:190
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
bool isDisposed() const
bool mbToolBox
Definition: window.h:377
WinBits mnStyle
Definition: window.h:294
VclPtr< vcl::Window > mpBorderWindow
Definition: window.h:233
bool mbDrawSelectionBackground
Definition: window.h:381
void SetPoint(const Point &rPt, sal_uInt16 nPos)
constexpr Point Center() const
constexpr tools::Long GetWidth() const
bool Contains(const Point &rPOINT) const
constexpr void SetLeft(tools::Long v)
bool Overlaps(const tools::Rectangle &rRect) const
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
void SetSize(const Size &)
constexpr Point TopLeft() const
tools::Long getOpenHeight() const
void SetPos(const Point &rPoint)
constexpr void SetRight(tools::Long v)
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Right() const
constexpr void SetBottom(tools::Long v)
constexpr Point BottomRight() const
constexpr Point TopRight() const
constexpr tools::Long GetHeight() const
tools::Rectangle & Union(const tools::Rectangle &rRect)
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
constexpr Point BottomLeft() const
void SetOrientation(Degree10 nLineOrientation)
Definition: font/font.cxx:197
sal_uInt16 GetGroup() const
Definition: keycod.hxx:62
sal_uInt16 GetCode() const
Definition: keycod.hxx:49
sal_uInt16 GetModifier() const
Definition: keycod.hxx:52
bool IsShift() const
Definition: keycod.hxx:54
bool IsMod2() const
Definition: keycod.hxx:58
void Intersect(const tools::Rectangle &rRegion)
Definition: region.cxx:583
tools::Rectangle GetBoundRect() const
Definition: region.cxx:1219
static void DrawSelectionBackground(vcl::RenderContext &rRenderContext, vcl::Window const &rWindow, const tools::Rectangle &rRect, sal_uInt16 nHighlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly, Color *pSelectionTextColor=nullptr, tools::Long nCornerRadius=0, Color const *pPaintColor=nullptr)
Definition: paint.cxx:324
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2806
void SetFont(const vcl::Font &rNewFont)
Definition: window3.cxx:59
SAL_DLLPRIVATE void ImplGrabFocus(GetFocusFlags nFlags)
Definition: mouse.cxx:195
bool IsReallyVisible() const
Definition: window2.cxx:1133
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:252
vcl::Window * GetParent() const
Definition: window2.cxx:1123
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1869
GetFocusFlags GetGetFocusFlags() const
Definition: window2.cxx:1214
void PaintImmediately()
Definition: paint.cxx:1268
SAL_DLLPRIVATE vcl::Window * ImplGetDlgWindow(sal_uInt16 n, GetDlgWindowType nType, sal_uInt16 nStart=0, sal_uInt16 nEnd=0xFFFF, sal_uInt16 *pIndex=nullptr)
Definition: dlgctrl.cxx:205
bool IsMouseCaptured() const
Definition: mouse.cxx:481
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:293
bool IsBackground() const
Definition: window3.cxx:64
sal_uInt16 GetChildCount() const
Definition: stacking.cxx:1002
void HideTracking()
Definition: window2.cxx:151
bool IsPaintTransparent() const
Definition: window2.cxx:1063
WindowType GetType() const
Definition: window2.cxx:1000
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1288
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1923
Size get_preferred_size() const
Definition: window2.cxx:1694
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1036
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
const Color & GetControlForeground() const
Definition: window2.cxx:1098
void GrabFocus()
Definition: window.cxx:2976
bool IsUpdateMode() const
Definition: window2.cxx:1199
bool HasFocus() const
Definition: window.cxx:2981
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:420
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
Definition: window3.cxx:79
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: window3.cxx:65
void GrabFocusToDocument()
Definition: window.cxx:2986
bool IsControlForeground() const
Definition: window2.cxx:1103
WinBits GetStyle() const
Definition: window2.cxx:979
const AllSettings & GetSettings() const
Definition: window3.cxx:129
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Definition: mouse.cxx:427
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2187
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1805
void ShowTracking(const tools::Rectangle &rRect, ShowTrackFlags nFlags=ShowTrackFlags::Small)
Definition: window2.cxx:128
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
Definition: window3.cxx:74
SAL_DLLPRIVATE vcl::Window * ImplGetParent() const
Definition: window2.cxx:896
::OutputDevice const * GetOutDev() const
Definition: window.cxx:567
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:528
virtual void MouseMove(const MouseEvent &rMEvt)
Definition: mouse.cxx:414
void ReleaseMouse()
Definition: mouse.cxx:469
virtual Size GetSizePixel() const
Definition: window.cxx:2402
bool IsControlBackground() const
Definition: window2.cxx:1113
Point GetPointerPosPixel()
Definition: mouse.cxx:540
virtual void LoseFocus()
Definition: window.cxx:1855
const Color & GetControlBackground() const
Definition: window2.cxx:1108
virtual void SetPointer(PointerStyle)
Definition: mouse.cxx:486
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1025
bool HasPaintEvent() const
Definition: paint.cxx:1241
bool IsVisible() const
Definition: window2.cxx:1128
void CaptureMouse()
Definition: mouse.cxx:451
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: event.cxx:219
void ApplyControlFont(vcl::RenderContext &rRenderContext, const vcl::Font &rDefaultFont)
Definition: window2.cxx:478
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2812
const OUString & GetQuickHelpText() const
Definition: window2.cxx:1258
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:937
bool IsEnabled() const
Definition: window2.cxx:1148
const OUString & GetHelpText() const
Definition: window.cxx:3090
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1048
bool IsInPaint() const
Definition: window2.cxx:1118
SAL_DLLPRIVATE void ImplControlFocus(GetFocusFlags nFlags=GetFocusFlags::NONE)
Definition: dlgctrl.cxx:516
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
int nCount
DrawButtonFlags
Definition: decoview.hxx:54
float y
float x
sal_Int32 nState
TRISTATE_FALSE
TRISTATE_INDET
TRISTATE_TRUE
sal_Int32 nIndex
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
constexpr sal_uInt16 KEYGROUP_ALPHA
Definition: keycodes.hxx:38
constexpr sal_uInt16 KEY_ESCAPE
Definition: keycodes.hxx:120
constexpr sal_uInt16 KEY_HOME
Definition: keycodes.hxx:114
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
constexpr sal_uInt16 KEY_PAGEDOWN
Definition: keycodes.hxx:117
constexpr sal_uInt16 KEY_TAB
Definition: keycodes.hxx:121
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
constexpr sal_uInt16 KEYGROUP_MISC
Definition: keycodes.hxx:41
constexpr sal_uInt16 KEYGROUP_FKEYS
Definition: keycodes.hxx:39
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
constexpr sal_uInt16 KEY_SPACE
Definition: keycodes.hxx:123
constexpr sal_uInt16 KEY_PAGEUP
Definition: keycodes.hxx:116
constexpr sal_uInt16 KEYGROUP_NUM
Definition: keycodes.hxx:37
constexpr sal_uInt16 KEY_END
Definition: keycodes.hxx:115
bool isContainerWindow(const vcl::Window &rWindow)
Definition: layout.hxx:817
sal_uInt16 nPos
#define SAL_INFO_IF(condition, area, stream)
aStr
std::unique_ptr< sal_Int32[]> pData
int i
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
long Long
sal_Int32 h
sal_Int32 w
PointerStyle
Definition: ptrstyle.hxx:26
QPRO_FUNC_TYPE nType
double mnWidth
double mnHeight
sal_uIntPtr sal_uLong
void ImplDrawUpDownButtons(vcl::RenderContext &rRenderContext, const tools::Rectangle &rUpperRect, const tools::Rectangle &rLowerRect, bool bUpperIn, bool bLowerIn, bool bUpperEnabled, bool bLowerEnabled, bool bHorz, bool bMirrorHorz)
Definition: spinfld.cxx:205
ImplTBDragMgr * mpTBDragMgr
Definition: svdata.hxx:279
ImplSVCtrlData maCtrlData
Definition: svdata.hxx:401
ImplSVWinData * mpWinData
Definition: svdata.hxx:400
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:254
OUString maCommandStr
Definition: toolbox.h:46
ToolBoxItemBits mnBits
Definition: toolbox.h:59
tools::Rectangle maRect
Definition: toolbox.h:48
bool mbExpand
Definition: toolbox.h:68
bool mbShowWindow
Definition: toolbox.h:65
bool mbEnabled
Definition: toolbox.h:62
ToolBoxItemId mnId
Definition: toolbox.h:61
OUString maText
Definition: toolbox.h:43
ToolBoxItemType meType
Definition: toolbox.h:58
tools::Rectangle GetDropDownRect(bool bHorz) const
Definition: toolbox2.cxx:247
bool mbVisibleText
Definition: toolbox.h:67
bool mbBreak
Definition: toolbox.h:66
VclPtr< vcl::Window > mpWindow
Definition: toolbox.h:37
Size maItemSize
The overall horizontal item size, including one or more of [image size + textlength + dropdown arrow]...
Definition: toolbox.h:53
bool mbVisible
Definition: toolbox.h:63
TriState meState
Definition: toolbox.h:60
bool IsClipped() const
Definition: toolbox2.cxx:263
void DetermineButtonDrawStyle(ButtonType eButtonType, bool &rbImage, bool &rbText) const
Definition: toolbox2.cxx:195
OUString maHelpText
Definition: toolbox.h:45
OUString maHelpId
Definition: toolbox.h:47
Image maImage
Definition: toolbox.h:40
bool mbNonInteractiveWindow
Definition: toolbox.h:38
tools::Long mnWidth
Definition: toolbox.hxx:94
tools::Long mnHeight
Definition: toolbox.hxx:95
ImplToolItems::size_type mnLines
Definition: toolbox.hxx:96
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:77
DockingManager * ImplGetDockingManager()
Definition: svdata.cxx:316
@ RESIZE
Resize runs before repaint, so we won't paint twice.
#define SMALLBUTTON_HSIZE
Definition: toolbox.cxx:57
#define TB_TEXTOFFSET
Definition: toolbox.cxx:63
static void ImplDrawMoreIndicator(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: toolbox.cxx:2362
#define TB_SPIN_SIZE
Definition: toolbox.cxx:66
static void ImplAddButtonBorder(tools::Long &rWidth, tools::Long &rHeight, bool bNativeButtons)
Definition: toolbox.cxx:1339
#define TB_BORDER_OFFSET1
Definition: toolbox.cxx:68
#define SMALLBUTTON_VSIZE
Definition: toolbox.cxx:58
#define TB_SPIN_OFFSET
Definition: toolbox.cxx:67
static ButtonType determineButtonType(ImplToolItem const *pItem, ButtonType defaultType)
Definition: toolbox.cxx:154
#define DOCK_LINERIGHT
Definition: toolbox.cxx:83
IMPL_LINK_NOARG(ToolBox, ImplDropdownLongClickHdl, Timer *, void)
Definition: toolbox.cxx:2330
#define SMALLBUTTON_OFF_NORMAL_X
Definition: toolbox.cxx:60
#define TB_CALCMODE_VERT
Definition: toolbox.cxx:76
#define DOCK_LINEVSIZE
Definition: toolbox.cxx:82
#define TB_CALCMODE_HORZ
Definition: toolbox.cxx:75
#define TB_LINESPACING
Definition: toolbox.cxx:65
#define TB_WBLINESIZING
Definition: toolbox.cxx:79
#define DOCK_LINEOFFSET
Definition: toolbox.cxx:87
#define TB_DRAGWIDTH
Definition: toolbox.cxx:73
#define SMALLBUTTON_OFF_NORMAL_Y
Definition: toolbox.cxx:61
static bool ImplCloseLastPopup(vcl::Window const *pParent)
Definition: toolbox.cxx:4215
#define TB_BORDER_OFFSET2
Definition: toolbox.cxx:69
#define TB_MAXLINES
Definition: toolbox.cxx:70
static ImplTBDragMgr * ImplGetTBDragMgr()
Definition: toolbox.cxx:113
#define TB_CALCMODE_FLOAT
Definition: toolbox.cxx:77
IMPL_LINK(ImplTBDragMgr, SelectHdl, Accelerator &, rAccel, void)
Definition: toolbox.cxx:1094
static bool ImplIsFixedControl(const ImplToolItem *pItem)
Definition: toolbox.cxx:618
#define DOCK_LINEBOTTOM
Definition: toolbox.cxx:84
static void ImplDrawDropdownArrow(vcl::RenderContext &rRenderContext, const tools::Rectangle &rDropDownRect, bool bSetColor, bool bRotate)
Definition: toolbox.cxx:2373
#define DOCK_LINEHSIZE
Definition: toolbox.cxx:81
#define TB_MAXNOSCROLL
Definition: toolbox.cxx:71
#define DOCK_LINETOP
Definition: toolbox.cxx:86
static bool ImplIsValidItem(const ImplToolItem *pItem, bool bNotClipped)
Definition: toolbox.cxx:4606
#define TB_IMAGETEXTOFFSET
Definition: toolbox.cxx:64
#define DOCK_LINELEFT
Definition: toolbox.cxx:85
#define TB_DROPDOWNARROWWIDTH
Definition: toolbox.h:28
#define TB_MENUBUTTON_SIZE
Definition: toolbox.h:30
#define TB_MENUBUTTON_OFFSET
Definition: toolbox.h:31
ToolBoxTextPosition
Definition: toolbox.hxx:68
ToolBoxLayoutMode
Definition: toolbox.hxx:60
o3tl::strong_int< sal_uInt16, struct ToolBoxItemIdTag > ToolBoxItemId
Definition: toolboxid.hxx:14
bool bPopup
ToolBoxItemBits
Definition: vclenum.hxx:51
ButtonType
Definition: vclenum.hxx:71
@ ToolboxHighlightOff
StartTrackingFlags
Definition: window.hxx:265
StateChangedType
Definition: window.hxx:291
@ Update
The invalidated area is updated immediately.
@ NoClipChildren
The area is invalidated regardless of overlapping child windows.
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_DIALOGCONTROL
Definition: wintypes.hxx:113
WindowType
Definition: wintypes.hxx:27
WinBits const WB_3DLOOK
Definition: wintypes.hxx:118
WinBits const WB_BORDER
Definition: wintypes.hxx:115
WinBits const WB_NODIALOGCONTROL
Definition: wintypes.hxx:114
WinBits const WB_TABSTOP
Definition: wintypes.hxx:140
WindowAlign
Definition: wintypes.hxx:232
WinBits const WB_SCROLL
Definition: wintypes.hxx:207
WinBits const WB_HIDE
Definition: wintypes.hxx:160
WinBits const WB_NOSHADOW
Definition: wintypes.hxx:171
size_t pos