LibreOffice Module vcl (master)  1
toolbox2.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 <sal/config.h>
21 #include <vcl/uitest/logger.hxx>
22 #include <sal/log.hxx>
23 
24 #include <comphelper/base64.hxx>
26 #include <boost/property_tree/ptree.hpp>
27 
28 #include <vcl/cvtgrf.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vcl/idle.hxx>
31 #include <vcl/bitmap.hxx>
32 #include <vcl/toolkit/floatwin.hxx>
33 #include <vcl/toolbox.hxx>
34 #include <vcl/mnemonic.hxx>
35 #include <vcl/menu.hxx>
36 #include <vcl/settings.hxx>
37 #include <vcl/IconThemeInfo.hxx>
39 
40 #include <svdata.hxx>
41 #include <brdwin.hxx>
42 #include <toolbox.h>
43 
44 #include <unotools/confignode.hxx>
45 #include <tools/json_writer.hxx>
46 
47 #include <vcl/uitest/uiobject.hxx>
48 
49 #include "impldockingwrapper.hxx"
50 
51 using namespace vcl;
52 
53 #define TB_SEP_SIZE 8 // Separator size
54 
55 
57 {
58  meButtonSize = ToolBoxButtonSize::DontCare;
59  mpMenu = VclPtr<PopupMenu>::Create();
60 
61  maMenuType = ToolBoxMenuType::NONE;
63  maMenubuttonItem.meState = TRISTATE_FALSE;
64  mnMenuButtonWidth = TB_MENUBUTTON_SIZE;
65 
66  mbIsLocked = false;
67  mbNativeButtons = false;
68  mbIsPaintLocked = false;
69  mbAssumeDocked = false;
70  mbAssumePopupMode = false;
71  mbAssumeFloating = false;
72  mbKeyInputDisabled = false;
73  mbMenubuttonSelected = false;
74  mbMenubuttonWasLastSelected = false;
75  mbWillUsePopupMode = false;
76  mbDropDownByKeyboard = false;
77 }
78 
80 {
81  m_pLayoutData.reset();
82  mpMenu.disposeAndClear();
83 }
84 
86  bool bEmptyBtn)
87 {
88  mnId = nItemId;
89  mpWindow = nullptr;
90  mbNonInteractiveWindow = false;
91  mpUserData = nullptr;
93  mnBits = nItemBits;
94  meState = TRISTATE_FALSE;
95  mbEnabled = true;
96  mbVisible = true;
97  mbEmptyBtn = bEmptyBtn;
98  mbShowWindow = false;
99  mbBreak = false;
100  mnSepSize = TB_SEP_SIZE;
101  mnDropDownArrowWidth = TB_DROPDOWNARROWWIDTH;
102  mnImageAngle = 0_deg10;
103  mbMirrorMode = false;
104  mbVisibleText = false;
105  mbExpand = false;
106 }
107 
109 {
111 }
112 
114  ToolBoxItemBits nItemBits ) :
115  maImage( rImage )
116 {
117  init(nItemId, nItemBits, false);
118 }
119 
120 ImplToolItem::ImplToolItem( ToolBoxItemId nItemId, const OUString& rText,
121  ToolBoxItemBits nItemBits ) :
122  maText( rText )
123 {
124  init(nItemId, nItemBits, false);
125 }
126 
128  const OUString& rText, ToolBoxItemBits nItemBits ) :
129  maImage( rImage ),
130  maText( rText )
131 {
132  init(nItemId, nItemBits, false);
133 }
134 
135 Size ImplToolItem::GetSize( bool bHorz, bool bCheckMaxWidth, tools::Long maxWidth, const Size& rDefaultSize )
136 {
137  Size aSize( rDefaultSize ); // the size of 'standard' toolbox items
138  // non-standard items are eg windows or buttons with text
139 
141  {
142  aSize = maItemSize;
143 
144  if ( mpWindow && bHorz )
145  {
146  // get size of item window and check if it fits
147  // no windows in vertical toolbars (the default is mbShowWindow=false)
148  Size aWinSize = mpWindow->GetSizePixel();
149 
150  if (mpWindow->GetStyle() & WB_NOLABEL)
151  // Window wants no label? Then don't check width, it'll be just
152  // clipped.
153  bCheckMaxWidth = false;
154 
155  if ( !bCheckMaxWidth || (aWinSize.Width() <= maxWidth) )
156  {
157  aSize.setWidth( aWinSize.Width() );
158  aSize.setHeight( aWinSize.Height() );
159  mbShowWindow = true;
160  }
161  else
162  {
163  if ( mbEmptyBtn )
164  {
165  aSize.setWidth( 0 );
166  aSize.setHeight( 0 );
167  }
168  }
169  }
170  }
171  else if ( meType == ToolBoxItemType::SEPARATOR )
172  {
173  if ( bHorz )
174  {
175  aSize.setWidth( mnSepSize );
176  aSize.setHeight( rDefaultSize.Height() );
177  }
178  else
179  {
180  aSize.setWidth( rDefaultSize.Width() );
181  aSize.setHeight( mnSepSize );
182  }
183  }
184  else if ( meType == ToolBoxItemType::BREAK )
185  {
186  aSize.setWidth( 0 );
187  aSize.setHeight( 0 );
188  }
189 
190  return aSize;
191 }
192 
193 void ImplToolItem::DetermineButtonDrawStyle( ButtonType eButtonType, bool& rbImage, bool& rbText ) const
194 {
196  {
197  // no button -> draw nothing
198  rbImage = rbText = false;
199  return;
200  }
201 
202  bool bHasImage;
203  bool bHasText;
204 
205  // check for image and/or text
206  bHasImage = !!maImage;
207  bHasText = !maText.isEmpty();
208 
209  // prefer images if symbolonly buttons are drawn
210  // prefer texts if textonly buttons are drawn
211 
212  if ( eButtonType == ButtonType::SYMBOLONLY ) // drawing icons only
213  {
214  if( bHasImage || !bHasText )
215  {
216  rbImage = true;
217  rbText = false;
218  }
219  else
220  {
221  rbImage = false;
222  rbText = true;
223  }
224  }
225  else if ( eButtonType == ButtonType::TEXT ) // drawing text only
226  {
227  if( bHasText || !bHasImage )
228  {
229  rbImage = false;
230  rbText = true;
231  }
232  else
233  {
234  rbImage = true;
235  rbText = false;
236  }
237  }
238  else // drawing icons and text both
239  {
240  rbImage = true;
241  rbText = true;
242  }
243 }
244 
246 {
247  tools::Rectangle aRect;
249  {
250  aRect = maRect;
251  if( mbVisibleText && !bHorz )
252  // item will be rotated -> place dropdown to the bottom
253  aRect.SetTop( aRect.Bottom() - mnDropDownArrowWidth );
254  else
255  // place dropdown to the right
256  aRect.SetLeft( aRect.Right() - mnDropDownArrowWidth );
257  }
258  return aRect;
259 }
260 
262 {
263  return ( meType == ToolBoxItemType::BUTTON && mbVisible && maRect.IsEmpty() );
264 }
265 
267 {
268  return ( meType == ToolBoxItemType::BUTTON && !mbVisible );
269 }
270 
271 void ToolBox::ImplInvalidate( bool bNewCalc, bool bFullPaint )
272 {
274 
275  if ( bNewCalc )
276  mbCalc = true;
277 
278  if ( bFullPaint )
279  {
280  mbFormat = true;
281 
282  // do we need to redraw?
283  if ( IsReallyVisible() && IsUpdateMode() )
284  {
287  mpIdle->Stop();
288  }
289  }
290  else
291  {
292  if ( !mbFormat )
293  {
294  mbFormat = true;
295 
296  // do we need to redraw?
297  if ( IsReallyVisible() && IsUpdateMode() )
298  mpIdle->Start();
299  }
300  }
301 
302  // request new layout by layoutmanager
304 }
305 
306 void ToolBox::ImplUpdateItem( ImplToolItems::size_type nIndex )
307 {
308  // do we need to redraw?
309  if ( !(IsReallyVisible() && IsUpdateMode()) )
310  return;
311 
312  if ( nIndex == ITEM_NOTFOUND )
313  {
314  // #i52217# no immediate draw as this might lead to paint problems
316  }
317  else
318  {
319  if ( !mbFormat )
320  {
321  // #i52217# no immediate draw as this might lead to paint problems
322  Invalidate( mpData->m_aItems[nIndex].maRect );
323  }
324  else
325  maPaintRect.Union( mpData->m_aItems[nIndex].maRect );
326  }
327 }
328 
330 {
332  maClickHdl.Call( this );
334 }
335 
337 {
339  maDoubleClickHdl.Call( this );
340 }
341 
343 {
344  mnActivateCount++;
346  maActivateHdl.Call( this );
347 }
348 
350 {
351  mnActivateCount--;
353  maDeactivateHdl.Call( this );
354 }
355 
357 {
359 }
360 
362 {
364 }
365 
367 {
368  VclPtr<vcl::Window> xWindow = this;
369 
371  maSelectHdl.Call( this );
372 
373  if ( xWindow->isDisposed() )
374  return;
375 
376  // TODO: GetFloatingWindow in DockingWindow is currently inline, change it to check dockingwrapper
378  if( pWrapper && pWrapper->GetFloatingWindow() && static_cast<FloatingWindow*>(pWrapper->GetFloatingWindow())->IsInPopupMode() )
379  static_cast<FloatingWindow*>(pWrapper->GetFloatingWindow())->EndPopupMode();
380 }
381 
382 void ToolBox::InsertItem( ToolBoxItemId nItemId, const Image& rImage, ToolBoxItemBits nBits, ImplToolItems::size_type nPos )
383 {
384  SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" );
385  SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
386  "ToolBox::InsertItem(): ItemId already exists" );
387 
388  // create item and add to list
389  mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(),
390  ImplToolItem( nItemId, rImage, nBits ) );
391  mpData->ImplClearLayoutData();
392 
393  ImplInvalidate( true );
394 
395  // Notify
396  ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
397  CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >(nNewPos ) );
398 }
399 
400 void ToolBox::InsertItem( ToolBoxItemId nItemId, const Image& rImage, const OUString& rText, ToolBoxItemBits nBits,
401  ImplToolItems::size_type nPos )
402 {
403  SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" );
404  SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
405  "ToolBox::InsertItem(): ItemId already exists" );
406 
407  // create item and add to list
408  mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(),
409  ImplToolItem( nItemId, rImage, MnemonicGenerator::EraseAllMnemonicChars(rText), nBits ) );
410  mpData->ImplClearLayoutData();
411 
412  ImplInvalidate( true );
413 
414  // Notify
415  ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
416  CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
417 }
418 
419 void ToolBox::InsertItem( ToolBoxItemId nItemId, const OUString& rText, ToolBoxItemBits nBits, ImplToolItems::size_type nPos )
420 {
421  SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertItem(): ItemId == 0" );
422  SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
423  "ToolBox::InsertItem(): ItemId already exists" );
424 
425  // create item and add to list
426  mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(),
427  ImplToolItem( nItemId, MnemonicGenerator::EraseAllMnemonicChars(rText), nBits ) );
428  mpData->ImplClearLayoutData();
429 
430  ImplInvalidate( true );
431 
432  // Notify
433  ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
434  CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
435 }
436 
437 void ToolBox::InsertItem(const OUString& rCommand, const css::uno::Reference<css::frame::XFrame>& rFrame, ToolBoxItemBits nBits,
438  const Size& rRequestedSize, ImplToolItems::size_type nPos)
439 {
440  OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(rFrame));
441  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(rCommand, aModuleName);
443  OUString aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(rCommand, aProperties, rFrame));
444  Image aImage(CommandInfoProvider::GetImageForCommand(rCommand, rFrame, GetImageSize()));
445 
446  ToolBoxItemId nItemId(GetItemCount() + 1);
447  //TODO: ImplToolItems::size_type -> sal_uInt16!
448  InsertItem(nItemId, aImage, aLabel, nBits, nPos);
449  SetItemCommand(nItemId, rCommand);
450  SetQuickHelpText(nItemId, aTooltip);
451 
452  // set the minimal size
453  ImplToolItem* pItem = ImplGetItem( nItemId );
454  if ( pItem )
455  pItem->maMinimalItemSize = rRequestedSize;
456 }
457 
459  ToolBoxItemBits nBits, ImplToolItems::size_type nPos )
460 {
461  SAL_WARN_IF( !nItemId, "vcl", "ToolBox::InsertWindow(): ItemId == 0" );
462  SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
463  "ToolBox::InsertWindow(): ItemId already exists" );
464 
465  // create item and add to list
466  ImplToolItem aItem;
467  aItem.mnId = nItemId;
469  aItem.mnBits = nBits;
470  aItem.mpWindow = pWindow;
471  mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(), aItem );
472  mpData->ImplClearLayoutData();
473 
474  if ( pWindow )
475  pWindow->Hide();
476 
477  ImplInvalidate( true );
478 
479  // Notify
480  ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
481  CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
482 }
483 
485 {
486  // create item and add to list
487  ImplToolItem aItem;
489  aItem.mbEnabled = false;
490  mpData->m_aItems.push_back( aItem );
491  mpData->ImplClearLayoutData();
492 
493  ImplInvalidate();
494 
495  // Notify
496  ImplToolItems::size_type nNewPos = mpData->m_aItems.size() - 1;
497  CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
498 }
499 
500 void ToolBox::InsertSeparator( ImplToolItems::size_type nPos, sal_uInt16 nPixSize )
501 {
502  // create item and add to list
503  ImplToolItem aItem;
505  aItem.mbEnabled = false;
506  if ( nPixSize )
507  aItem.mnSepSize = nPixSize;
508  mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(), aItem );
509  mpData->ImplClearLayoutData();
510 
511  ImplInvalidate();
512 
513  // Notify
514  ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
515  CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
516 }
517 
518 void ToolBox::InsertBreak( ImplToolItems::size_type nPos )
519 {
520  // create item and add to list
521  ImplToolItem aItem;
523  aItem.mbEnabled = false;
524  mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(), aItem );
525  mpData->ImplClearLayoutData();
526 
527  ImplInvalidate();
528 
529  // Notify
530  ImplToolItems::size_type nNewPos = ( nPos == APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos;
531  CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos ) );
532 }
533 
534 void ToolBox::RemoveItem( ImplToolItems::size_type nPos )
535 {
536  if( nPos >= mpData->m_aItems.size() )
537  return;
538 
539  bool bMustCalc;
540  bMustCalc = mpData->m_aItems[nPos].meType == ToolBoxItemType::BUTTON;
541 
542  if ( mpData->m_aItems[nPos].mpWindow )
543  mpData->m_aItems[nPos].mpWindow->Hide();
544 
545  // add the removed item to PaintRect
546  maPaintRect.Union( mpData->m_aItems[nPos].maRect );
547 
548  // ensure not to delete in the Select-Handler
549  if ( mpData->m_aItems[nPos].mnId == mnCurItemId )
551  if ( mpData->m_aItems[nPos].mnId == mnHighItemId )
553 
554  ImplInvalidate( bMustCalc );
555 
556  mpData->m_aItems.erase( mpData->m_aItems.begin()+nPos );
557  mpData->ImplClearLayoutData();
558 
559  // Notify
560  CallEventListeners( VclEventId::ToolboxItemRemoved, reinterpret_cast< void* >( nPos ) );
561 }
562 
563 void ToolBox::CopyItem( const ToolBox& rToolBox, ToolBoxItemId nItemId )
564 {
565  SAL_WARN_IF( GetItemPos( nItemId ) != ITEM_NOTFOUND, "vcl",
566  "ToolBox::CopyItem(): ItemId already exists" );
567 
568  ImplToolItems::size_type nPos = rToolBox.GetItemPos( nItemId );
569 
570  // found item
571  if ( nPos == ITEM_NOTFOUND )
572  return;
573 
574  // push ToolBox item onto the list
575  ImplToolItem aNewItem = rToolBox.mpData->m_aItems[nPos];
576  // reset state
577  aNewItem.mpWindow = nullptr;
578  aNewItem.mbShowWindow = false;
579 
580  mpData->m_aItems.push_back( aNewItem );
581  mpData->ImplClearLayoutData();
582  // redraw ToolBox
583  ImplInvalidate();
584 
585  // Notify
586  ImplToolItems::size_type nNewPos2 = mpData->m_aItems.size() - 1;
587  CallEventListeners( VclEventId::ToolboxItemAdded, reinterpret_cast< void* >( nNewPos2 ) );
588 }
589 
591 {
592  mpData->m_aItems.clear();
593  mpData->ImplClearLayoutData();
594 
595  // ensure not to delete in the Select-Handler
598 
599  ImplInvalidate( true, true );
600 
601  // Notify
603 }
604 
606 {
607  if ( meButtonType != eNewType )
608  {
609  meButtonType = eNewType;
610 
611  // better redraw everything, as otherwise there might be problems
612  // with regions that were copied with CopyBits
613  ImplInvalidate( true );
614  }
615 }
616 
618 {
619  if( mpData->meButtonSize != eSize )
620  {
621  mpData->meButtonSize = eSize;
622  mbCalc = true;
623  mbFormat = true;
624  }
625 }
626 
628 {
629  return mpData->meButtonSize;
630 }
631 
633 {
634  ImageType eImageType = ImageType::Size16;
635  if (mpData->meButtonSize == ToolBoxButtonSize::Large)
636  eImageType = ImageType::Size26;
637  else if (mpData->meButtonSize == ToolBoxButtonSize::Size32)
638  eImageType = ImageType::Size32;
639 
640  return eImageType;
641 }
642 
644 {
646  float fScaleFactor = pDefault ? pDefault->GetDPIScaleFactor() : 1.0;
647 
648  Size aUnscaledSize(16, 16);
649 
650  if (eToolBoxButtonSize == ToolBoxButtonSize::Large)
651  {
653  aUnscaledSize = vcl::IconThemeInfo::SizeByThemeName(iconTheme);
654  }
655  else if (eToolBoxButtonSize == ToolBoxButtonSize::Size32)
656  {
657  aUnscaledSize = Size(32, 32);
658  }
659  return Size(aUnscaledSize.Width() * fScaleFactor,
660  aUnscaledSize.Height() * fScaleFactor);
661 }
662 
664 {
666 }
667 
669 {
670  if ( meAlign == eNewAlign )
671  return;
672 
673  meAlign = eNewAlign;
674 
675  if ( ImplIsFloatingMode() )
676  return;
677 
678  // set horizontal/vertical alignment
679  if ( (eNewAlign == WindowAlign::Left) || (eNewAlign == WindowAlign::Right) )
680  mbHorz = false;
681  else
682  mbHorz = true;
683 
684  // Update the background according to Persona if necessary
685  ImplInitSettings( false, false, true );
686 
687  // redraw everything, as the border has changed
688  mbCalc = true;
689  mbFormat = true;
690  if ( IsReallyVisible() && IsUpdateMode() )
691  Invalidate();
692 }
693 
694 void ToolBox::SetLineCount( ImplToolItems::size_type nNewLines )
695 {
696  if ( !nNewLines )
697  nNewLines = 1;
698 
699  if ( mnLines != nNewLines )
700  {
701  mnLines = nNewLines;
702 
703  // better redraw everything, as otherwise there might be problems
704  // with regions that were copied with CopyBits
705  Invalidate();
706  }
707 }
708 
709 ToolBox::ImplToolItems::size_type ToolBox::GetItemCount() const
710 {
711  return mpData ? mpData->m_aItems.size() : 0;
712 }
713 
714 ToolBoxItemType ToolBox::GetItemType( ImplToolItems::size_type nPos ) const
715 {
716  return (nPos < mpData->m_aItems.size()) ? mpData->m_aItems[nPos].meType : ToolBoxItemType::DONTKNOW;
717 }
718 
719 ToolBox::ImplToolItems::size_type ToolBox::GetItemPos( ToolBoxItemId nItemId ) const
720 {
721  if (mpData)
722  {
723  ImplToolItems::size_type nCount = mpData->m_aItems.size();
724  for( ImplToolItems::size_type nPos = 0; nPos < nCount; nPos++ )
725  if( mpData->m_aItems[nPos].mnId == nItemId )
726  return nPos;
727  }
728  return ITEM_NOTFOUND;
729 }
730 
731 ToolBox::ImplToolItems::size_type ToolBox::GetItemPos( const Point& rPos ) const
732 {
733  // search the item position on the given point
734  auto it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
735  [&rPos](const ImplToolItem& rItem) { return rItem.maRect.Contains( rPos ); });
736 
737  if( it != mpData->m_aItems.end() )
738  return std::distance(mpData->m_aItems.begin(), it);
739 
740  return ITEM_NOTFOUND;
741 }
742 
743 ToolBoxItemId ToolBox::GetItemId( ImplToolItems::size_type nPos ) const
744 {
745  return (nPos < mpData->m_aItems.size()) ? mpData->m_aItems[nPos].mnId : ToolBoxItemId(0);
746 }
747 
748 ToolBoxItemId ToolBox::GetItemId( const Point& rPos ) const
749 {
750  // find item that was clicked
751  auto it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
752  [&rPos](const ImplToolItem& rItem) { return rItem.maRect.Contains( rPos ); });
753 
754  if( (it != mpData->m_aItems.end()) && (it->meType == ToolBoxItemType::BUTTON) )
755  return it->mnId;
756 
757  return ToolBoxItemId(0);
758 }
759 
761 {
762  if ( mbCalc || mbFormat )
763  ImplFormat();
764 
765  ImplToolItems::size_type nPos = GetItemPos( nItemId );
766  if ( nPos < mpData->m_aItems.size() )
767  return mpData->m_aItems[nPos].maContentSize;
768  else
769  return Size();
770 }
771 
772 ToolBoxItemId ToolBox::GetItemId(const OUString &rCommand) const
773 {
774  if (!mpData)
775  return ToolBoxItemId(0);
776 
777  auto it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
778  [&rCommand](const ImplToolItem& rItem) { return rItem.maCommandStr == rCommand; });
779  if (it != mpData->m_aItems.end())
780  return it->mnId;
781 
782  return ToolBoxItemId(0);
783 }
784 
786 {
787  Point aPos;
788  if( !rRect.IsEmpty() )
789  {
791 
792  // the popup should be positioned so that it will not cover
793  // the item rect and that it fits the desktop
794  // the preferred direction is always towards the center of
795  // the application window
796 
797  Point devPos; // the position in device coordinates for screen comparison
798  switch( meAlign )
799  {
800  case WindowAlign::Top:
801  aPos = rRect.BottomLeft();
802  aPos.AdjustY( 1 );
803  devPos = OutputToAbsoluteScreenPixel( aPos );
804  if( devPos.Y() >= aScreen.Bottom() )
805  aPos.setY( rRect.Top() );
806  break;
807  case WindowAlign::Bottom:
808  aPos = rRect.TopLeft();
809  aPos.AdjustY( -1 );
810  devPos = OutputToAbsoluteScreenPixel( aPos );
811  if( devPos.Y() <= aScreen.Top() )
812  aPos.setY( rRect.Bottom() );
813  break;
814  case WindowAlign::Left:
815  aPos = rRect.TopRight();
816  aPos.AdjustX( 1 );
817  devPos = OutputToAbsoluteScreenPixel( aPos );
818  if( devPos.X() >= aScreen.Right() )
819  aPos.setX( rRect.Left() );
820  break;
821  case WindowAlign::Right:
822  aPos = rRect.TopLeft();
823  aPos.AdjustX( -1 );
824  devPos = OutputToAbsoluteScreenPixel( aPos );
825  if( devPos.X() <= aScreen.Left() )
826  aPos.setX( rRect.Right() );
827  break;
828  default:
829  break;
830  }
831  }
832  return aPos;
833 }
834 
836 {
837  if ( mbCalc || mbFormat )
838  ImplFormat();
839 
840  ImplToolItems::size_type nPos = GetItemPos( nItemId );
841  return GetItemPosRect( nPos );
842 }
843 
844 tools::Rectangle ToolBox::GetItemPosRect( ImplToolItems::size_type nPos )
845 {
846  if ( mbCalc || mbFormat )
847  ImplFormat();
848 
849  if ( nPos < mpData->m_aItems.size() )
850  return mpData->m_aItems[nPos].maRect;
851  else
852  return tools::Rectangle();
853 }
854 
856 {
857  return mpData->maMenubuttonItem.maRect;
858 }
859 
861 {
862  // check if the borderwindow (i.e. the decoration) provides the menu button
863  bool bRet = false;
864  if( ImplIsFloatingMode() )
865  {
866  // custom menu is placed in the decoration
867  ImplBorderWindow *pBorderWin = dynamic_cast<ImplBorderWindow*>( GetWindow( GetWindowType::Border ) );
868  if( pBorderWin && !pBorderWin->GetMenuRect().IsEmpty() )
869  bRet = true;
870  }
871  return bRet;
872 }
873 
875 {
876  ImplToolItems::size_type nPos = GetItemPos( nItemId );
877 
878  if ( nPos < GetItemCount() )
879  {
880  ToolBoxItemBits nOldBits = mpData->m_aItems[nPos].mnBits;
881  mpData->m_aItems[nPos].mnBits = nBits;
884  // trigger reformat when the item width has changed (dropdown arrow)
885  bool bFormat = ToolBoxItemBits(nBits & ToolBoxItemBits::DROPDOWN) != ToolBoxItemBits(nOldBits & ToolBoxItemBits::DROPDOWN);
886  if ( nBits != nOldBits )
887  ImplInvalidate( true, bFormat );
888  }
889 }
890 
891 void ToolBox::SetItemWindowNonInteractive(ToolBoxItemId nItemId, bool bNonInteractive)
892 {
893  ImplToolItems::size_type nPos = GetItemPos( nItemId );
894 
895  if ( nPos < GetItemCount() )
896  {
897  mpData->m_aItems[nPos].mbNonInteractiveWindow = bNonInteractive;
898  }
899 }
900 
902 {
903  ImplToolItem* pItem = ImplGetItem( nItemId );
904 
905  if ( pItem )
906  return pItem->mnBits;
907  else
908  return ToolBoxItemBits::NONE;
909 }
910 
911 void ToolBox::SetItemExpand( ToolBoxItemId nItemId, bool bExpand )
912 {
913  ImplToolItem* pItem = ImplGetItem( nItemId );
914  if (!pItem)
915  return;
916 
917  if (pItem->mbExpand != bExpand)
918  {
919  pItem->mbExpand = bExpand;
920  ImplInvalidate(true, true);
921  }
922 }
923 
924 void ToolBox::SetItemData( ToolBoxItemId nItemId, void* pNewData )
925 {
926  ImplToolItems::size_type nPos = GetItemPos( nItemId );
927 
928  if ( nPos < mpData->m_aItems.size() )
929  {
930  mpData->m_aItems[nPos].mpUserData = pNewData;
931  ImplUpdateItem( nPos );
932  }
933 }
934 
935 void* ToolBox::GetItemData( ToolBoxItemId nItemId ) const
936 {
937  ImplToolItem* pItem = ImplGetItem( nItemId );
938 
939  if ( pItem )
940  return pItem->mpUserData;
941  else
942  return nullptr;
943 }
944 
945 void ToolBox::SetItemImage( ToolBoxItemId nItemId, const Image& rImage )
946 {
947  ImplToolItems::size_type nPos = GetItemPos( nItemId );
948 
949  if ( nPos == ITEM_NOTFOUND )
950  return;
951 
952  ImplToolItem* pItem = &mpData->m_aItems[nPos];
953  Size aOldSize = pItem->maImage.GetSizePixel();
954 
955  pItem->maImage = rImage;
956 
957  // only once all is calculated, do extra work
958  if (!mbCalc)
959  {
960  if (aOldSize != pItem->maImage.GetSizePixel())
961  ImplInvalidate( true );
962  else
963  ImplUpdateItem( nPos );
964  }
965 }
966 
967 static Image ImplRotImage( const Image& rImage, Degree10 nAngle10 )
968 {
969  BitmapEx aRotBitmapEx( rImage.GetBitmapEx() );
970 
971  aRotBitmapEx.Rotate( nAngle10, COL_WHITE );
972 
973  return Image( aRotBitmapEx );
974 }
975 
977 {
978  ImplToolItems::size_type nPos = GetItemPos( nItemId );
979 
980  if ( nPos == ITEM_NOTFOUND )
981  return;
982 
983  ImplToolItem* pItem = &mpData->m_aItems[nPos];
984  Size aOldSize = pItem->maImage.GetSizePixel();
985 
986  Degree10 nDeltaAngle = (nAngle10 - pItem->mnImageAngle) % 3600_deg10;
987  while( nDeltaAngle < 0_deg10 )
988  nDeltaAngle += 3600_deg10;
989 
990  pItem->mnImageAngle = nAngle10;
991  if( nDeltaAngle && !!pItem->maImage )
992  {
993  pItem->maImage = ImplRotImage( pItem->maImage, nDeltaAngle );
994  }
995 
996  if (!mbCalc)
997  {
998  if (aOldSize != pItem->maImage.GetSizePixel())
999  ImplInvalidate(true);
1000  else
1001  ImplUpdateItem(nPos);
1002  }
1003 }
1004 
1005 static Image ImplMirrorImage( const Image& rImage )
1006 {
1007  BitmapEx aMirrBitmapEx( rImage.GetBitmapEx() );
1008 
1009  aMirrBitmapEx.Mirror( BmpMirrorFlags::Horizontal );
1010 
1011  return Image( aMirrBitmapEx );
1012 }
1013 
1014 void ToolBox::SetItemImageMirrorMode( ToolBoxItemId nItemId, bool bMirror )
1015 {
1016  ImplToolItems::size_type nPos = GetItemPos( nItemId );
1017 
1018  if ( nPos == ITEM_NOTFOUND )
1019  return;
1020 
1021  ImplToolItem* pItem = &mpData->m_aItems[nPos];
1022 
1023  if (pItem->mbMirrorMode != bMirror)
1024  {
1025  pItem->mbMirrorMode = bMirror;
1026  if (!!pItem->maImage)
1027  {
1028  pItem->maImage = ImplMirrorImage(pItem->maImage);
1029  }
1030 
1031  if (!mbCalc)
1032  ImplUpdateItem(nPos);
1033  }
1034 }
1035 
1037 {
1038  ImplToolItem* pItem = ImplGetItem(nItemId);
1039  return pItem ? pItem->maImage : Image();
1040 }
1041 
1042 void ToolBox::SetItemText( ToolBoxItemId nItemId, const OUString& rText )
1043 {
1044  ImplToolItems::size_type nPos = GetItemPos( nItemId );
1045 
1046  if ( nPos == ITEM_NOTFOUND )
1047  return;
1048 
1049  ImplToolItem* pItem = &mpData->m_aItems[nPos];
1050  // only once all is calculated, do extra work
1051  if ( !mbCalc &&
1052  ((meButtonType != ButtonType::SYMBOLONLY) || !pItem->maImage) )
1053  {
1054  tools::Long nOldWidth = GetOutDev()->GetCtrlTextWidth( pItem->maText );
1056  mpData->ImplClearLayoutData();
1057  if ( nOldWidth != GetOutDev()->GetCtrlTextWidth( pItem->maText ) )
1058  ImplInvalidate( true );
1059  else
1060  ImplUpdateItem( nPos );
1061  }
1062  else
1064 
1065  // Notify button changed event to prepare accessibility bridge
1066  CallEventListeners( VclEventId::ToolboxButtonStateChanged, reinterpret_cast< void* >( nPos ) );
1067 
1068  // Notify
1069  CallEventListeners( VclEventId::ToolboxItemTextChanged, reinterpret_cast< void* >( nPos ) );
1070 }
1071 
1072 const OUString& ToolBox::GetItemText( ToolBoxItemId nItemId ) const
1073 {
1074 
1075  ImplToolItem* pItem = ImplGetItem( nItemId );
1076 
1077  assert( pItem );
1078 
1079  return pItem->maText;
1080 }
1081 
1083 {
1084  ImplToolItems::size_type nPos = GetItemPos( nItemId );
1085 
1086  if ( nPos != ITEM_NOTFOUND )
1087  {
1088  ImplToolItem* pItem = &mpData->m_aItems[nPos];
1089  pItem->mpWindow = pNewWindow;
1090  if ( pNewWindow )
1091  pNewWindow->Hide();
1092  ImplInvalidate( true );
1093  CallEventListeners( VclEventId::ToolboxItemWindowChanged, reinterpret_cast< void* >( nPos ) );
1094  }
1095 }
1096 
1098 {
1099  ImplToolItem* pItem = ImplGetItem( nItemId );
1100 
1101  if ( pItem )
1102  return pItem->mpWindow;
1103  else
1104  return nullptr;
1105 }
1106 
1108 {
1109  if ( mbDrag )
1110  {
1111  // reset
1112  mbDrag = false;
1113  if (mnCurPos != ITEM_NOTFOUND)
1115  EndTracking();
1116  if (IsMouseCaptured())
1117  ReleaseMouse();
1118  Deactivate();
1119  }
1120 
1124  mnMouseModifier = 0;
1125 }
1126 
1127 void ToolBox::SetItemDown( ToolBoxItemId nItemId, bool bDown )
1128 {
1129  ImplToolItems::size_type nPos = GetItemPos( nItemId );
1130 
1131  if ( nPos == ITEM_NOTFOUND )
1132  return;
1133 
1134  if ( bDown )
1135  {
1136  if ( nPos != mnCurPos )
1137  {
1138  mnCurPos = nPos;
1140  GetOutDev()->Flush();
1141  }
1142  }
1143  else
1144  {
1145  if ( nPos == mnCurPos )
1146  {
1148  GetOutDev()->Flush();
1150  }
1151  }
1152 
1153  if ( mbDrag )
1154  {
1155  mbDrag = false;
1156  EndTracking();
1157  if (IsMouseCaptured())
1158  ReleaseMouse();
1159  Deactivate();
1160  }
1161 
1164  mnMouseModifier = 0;
1165 }
1166 
1168 {
1169  ImplToolItems::size_type nPos = GetItemPos( nItemId );
1170 
1171  if ( nPos == ITEM_NOTFOUND )
1172  return;
1173 
1174  ImplToolItem* pItem = &mpData->m_aItems[nPos];
1175 
1176  // the state has changed
1177  if ( pItem->meState == eState )
1178  return;
1179 
1180  // if RadioCheck, un-check the previous
1181  if ( (eState == TRISTATE_TRUE) && (pItem->mnBits & ToolBoxItemBits::AUTOCHECK) &&
1182  (pItem->mnBits & ToolBoxItemBits::RADIOCHECK) )
1183  {
1184  ImplToolItem* pGroupItem;
1185  ImplToolItems::size_type nGroupPos;
1186  ImplToolItems::size_type nItemCount = GetItemCount();
1187 
1188  nGroupPos = nPos;
1189  while ( nGroupPos )
1190  {
1191  pGroupItem = &mpData->m_aItems[nGroupPos-1];
1192  if ( pGroupItem->mnBits & ToolBoxItemBits::RADIOCHECK )
1193  {
1194  if ( pGroupItem->meState != TRISTATE_FALSE )
1195  SetItemState( pGroupItem->mnId, TRISTATE_FALSE );
1196  }
1197  else
1198  break;
1199  nGroupPos--;
1200  }
1201 
1202  nGroupPos = nPos+1;
1203  while ( nGroupPos < nItemCount )
1204  {
1205  pGroupItem = &mpData->m_aItems[nGroupPos];
1206  if ( pGroupItem->mnBits & ToolBoxItemBits::RADIOCHECK )
1207  {
1208  if ( pGroupItem->meState != TRISTATE_FALSE )
1209  SetItemState( pGroupItem->mnId, TRISTATE_FALSE );
1210  }
1211  else
1212  break;
1213  nGroupPos++;
1214  }
1215  }
1216 
1217  pItem->meState = eState;
1218  ImplUpdateItem( nPos );
1219 
1220  // Notify button changed event to prepare accessibility bridge
1221  CallEventListeners( VclEventId::ToolboxButtonStateChanged, reinterpret_cast< void* >( nPos ) );
1222 
1223  // Call accessible listener to notify state_changed event
1224  CallEventListeners( VclEventId::ToolboxItemUpdated, reinterpret_cast< void* >(nPos) );
1225 }
1226 
1228 {
1229  ImplToolItem* pItem = ImplGetItem( nItemId );
1230 
1231  if ( pItem )
1232  return pItem->meState;
1233  else
1234  return TRISTATE_FALSE;
1235 }
1236 
1237 void ToolBox::EnableItem( ToolBoxItemId nItemId, bool bEnable )
1238 {
1239  ImplToolItems::size_type nPos = GetItemPos( nItemId );
1240 
1241  if ( nPos == ITEM_NOTFOUND )
1242  return;
1243 
1244  ImplToolItem* pItem = &mpData->m_aItems[nPos];
1245  if ( pItem->mbEnabled == bEnable )
1246  return;
1247 
1248  pItem->mbEnabled = bEnable;
1249 
1250  // if existing, also redraw the window
1251  if ( pItem->mpWindow )
1252  pItem->mpWindow->Enable( pItem->mbEnabled );
1253 
1254  // update item
1255  ImplUpdateItem( nPos );
1256 
1258 
1259  // Notify button changed event to prepare accessibility bridge
1260  CallEventListeners( VclEventId::ToolboxButtonStateChanged, reinterpret_cast< void* >( nPos ) );
1261 
1262  CallEventListeners( bEnable ? VclEventId::ToolboxItemEnabled : VclEventId::ToolboxItemDisabled, reinterpret_cast< void* >( nPos ) );
1263 }
1264 
1266 {
1267  ImplToolItem* pItem = ImplGetItem( nItemId );
1268 
1269  if ( pItem )
1270  return pItem->mbEnabled;
1271  else
1272  return false;
1273 }
1274 
1275 void ToolBox::ShowItem( ToolBoxItemId nItemId, bool bVisible )
1276 {
1277  ImplToolItems::size_type nPos = GetItemPos( nItemId );
1278  mpData->ImplClearLayoutData();
1279 
1280  if ( nPos != ITEM_NOTFOUND )
1281  {
1282  ImplToolItem* pItem = &mpData->m_aItems[nPos];
1283  if ( pItem->mbVisible != bVisible )
1284  {
1285  pItem->mbVisible = bVisible;
1286  ImplInvalidate();
1287  }
1288  }
1289 }
1290 
1292 {
1293  ImplToolItem* pItem = ImplGetItem( nItemId );
1294 
1295  if ( pItem )
1296  return pItem->IsClipped();
1297  else
1298  return false;
1299 }
1300 
1302 {
1303  ImplToolItem* pItem = ImplGetItem( nItemId );
1304 
1305  if ( pItem )
1306  return pItem->mbVisible;
1307  else
1308  return false;
1309 }
1310 
1312 {
1313  // is the item on the visible area of the toolbox?
1314  bool bRet = false;
1316  ImplToolItem* pItem = ImplGetItem( nItemId );
1317 
1318  if ( pItem && pItem->mbVisible &&
1319  !pItem->maRect.IsEmpty() && aRect.Overlaps( pItem->maRect ) )
1320  {
1321  bRet = true;
1322  }
1323 
1324  return bRet;
1325 }
1326 
1327 void ToolBox::SetItemCommand(ToolBoxItemId nItemId, const OUString& rCommand)
1328 {
1329  ImplToolItem* pItem = ImplGetItem( nItemId );
1330 
1331  if (pItem)
1332  pItem->maCommandStr = rCommand;
1333 }
1334 
1335 OUString ToolBox::GetItemCommand( ToolBoxItemId nItemId ) const
1336 {
1337  ImplToolItem* pItem = ImplGetItem( nItemId );
1338 
1339  if (pItem)
1340  return pItem->maCommandStr;
1341 
1342  return OUString();
1343 }
1344 
1345 void ToolBox::SetQuickHelpText( ToolBoxItemId nItemId, const OUString& rText )
1346 {
1347  ImplToolItem* pItem = ImplGetItem( nItemId );
1348 
1349  if ( pItem )
1350  pItem->maQuickHelpText = rText;
1351 }
1352 
1353 OUString ToolBox::GetQuickHelpText( ToolBoxItemId nItemId ) const
1354 {
1355  ImplToolItem* pItem = ImplGetItem( nItemId );
1356 
1357  if ( pItem )
1358  return pItem->maQuickHelpText;
1359  else
1360  return OUString();
1361 }
1362 
1363 void ToolBox::SetHelpText( ToolBoxItemId nItemId, const OUString& rText )
1364 {
1365  ImplToolItem* pItem = ImplGetItem( nItemId );
1366 
1367  if ( pItem )
1368  pItem->maHelpText = rText;
1369 }
1370 
1371 const OUString& ToolBox::GetHelpText( ToolBoxItemId nItemId ) const
1372 {
1373  return ImplGetHelpText( nItemId );
1374 }
1375 
1376 void ToolBox::SetHelpId( ToolBoxItemId nItemId, const OString& rHelpId )
1377 {
1378  ImplToolItem* pItem = ImplGetItem( nItemId );
1379 
1380  if ( pItem )
1381  pItem->maHelpId = rHelpId;
1382 }
1383 
1384 // disable key input if all items are disabled
1386 {
1387  mpData->mbKeyInputDisabled = std::none_of(mpData->m_aItems.begin(), mpData->m_aItems.end(),
1388  [](const ImplToolItem& rItem) {
1389  // at least one useful entry
1390  return rItem.mbEnabled;
1391  });
1392 }
1393 
1395 {
1396  mpData->m_pLayoutData.emplace();
1397 
1398  ImplToolItems::size_type nCount = mpData->m_aItems.size();
1399  for( ImplToolItems::size_type i = 0; i < nCount; i++ )
1400  {
1401  ImplToolItem* pItem = &mpData->m_aItems[i];
1402 
1403  // only draw, if the rectangle is within PaintRectangle
1404  if (!pItem->maRect.IsEmpty())
1405  InvalidateItem(i);
1406  }
1407 }
1408 
1409 OUString ToolBox::GetDisplayText() const
1410 {
1411  if( ! mpData->m_pLayoutData )
1412  const_cast<ToolBox *>(this)->ImplFillLayoutData();
1413  return mpData->m_pLayoutData ? mpData->m_pLayoutData->m_aDisplayText : OUString();
1414 }
1415 
1417 {
1418  tools::Long nItemIndex = -1;
1419  if( ! mpData->m_pLayoutData )
1421  if( mpData->m_pLayoutData )
1422  {
1423  for( size_t i = 0; i < mpData->m_pLayoutData->m_aLineItemIds.size(); i++ )
1424  {
1425  if( mpData->m_pLayoutData->m_aLineItemIds[i] == nItemID )
1426  {
1427  nItemIndex = mpData->m_pLayoutData->m_aLineIndices[i];
1428  break;
1429  }
1430  }
1431  }
1432  return (mpData->m_pLayoutData && nItemIndex != -1) ? mpData->m_pLayoutData->GetCharacterBounds( nItemIndex+nIndex ) : tools::Rectangle();
1433 }
1434 
1435 tools::Long ToolBox::GetIndexForPoint( const Point& rPoint, ToolBoxItemId& rItemID )
1436 {
1437  tools::Long nIndex = -1;
1438  rItemID = ToolBoxItemId(0);
1439  if( ! mpData->m_pLayoutData )
1441  if( mpData->m_pLayoutData )
1442  {
1443  nIndex = mpData->m_pLayoutData->GetIndexForPoint( rPoint );
1444  for( size_t i = 0; i < mpData->m_pLayoutData->m_aLineIndices.size(); i++ )
1445  {
1446  if( mpData->m_pLayoutData->m_aLineIndices[i] <= nIndex &&
1447  (i == mpData->m_pLayoutData->m_aLineIndices.size()-1 || mpData->m_pLayoutData->m_aLineIndices[i+1] > nIndex) )
1448  {
1449  rItemID = mpData->m_pLayoutData->m_aLineItemIds[i];
1450  break;
1451  }
1452  }
1453  }
1454  return nIndex;
1455 }
1456 
1458 {
1459  if (mpData != nullptr) {
1460  mpData->maDropdownClickHdl = rLink;
1461  }
1462 }
1463 
1465 {
1466  if( aType == mpData->maMenuType )
1467  return;
1468 
1469  mpData->maMenuType = aType;
1470  if( IsFloatingMode() )
1471  {
1472  // the menu button may have to be moved into the decoration which changes the layout
1474  if( pWrapper )
1475  pWrapper->ShowMenuTitleButton( bool( aType & ToolBoxMenuType::Customize) );
1476 
1477  mbFormat = true;
1478  ImplFormat();
1480  }
1481  else
1482  {
1483  // trigger redraw of menu button
1484  if( !mpData->maMenubuttonItem.maRect.IsEmpty() )
1485  Invalidate(mpData->maMenubuttonItem.maRect);
1486  }
1487 }
1488 
1490 {
1491  return mpData->maMenuType;
1492 }
1493 
1495 {
1496  return mpData->maMenuType != ToolBoxMenuType::NONE;
1497 }
1498 
1500 {
1501  return mpData == nullptr ? nullptr : mpData->mpMenu;
1502 }
1503 
1505 {
1506  mpData->maMenuButtonHdl = rLink;
1507 }
1508 
1510 {
1511  // are any items currently clipped ?
1512  ImplFormat();
1513  return std::any_of(mpData->m_aItems.begin(), mpData->m_aItems.end(),
1514  [](const ImplToolItem& rItem) { return rItem.IsClipped(); });
1515 }
1516 
1517 namespace
1518 {
1519  MenuItemBits ConvertBitsFromToolBoxToMenu(ToolBoxItemBits nToolItemBits)
1520  {
1521  MenuItemBits nMenuItemBits = MenuItemBits::NONE;
1522  if ((nToolItemBits & ToolBoxItemBits::CHECKABLE) ||
1523  (nToolItemBits & ToolBoxItemBits::DROPDOWN))
1524  {
1525  nMenuItemBits |= MenuItemBits::CHECKABLE;
1526  }
1527  return nMenuItemBits;
1528  }
1529 }
1530 
1532 {
1533  // fill clipped items into menu
1534  PopupMenu *pMenu = GetMenu();
1535  pMenu->Clear();
1536 
1537  // add menu items: first the overflow items, then hidden items, both in the
1538  // order they would usually appear in the toolbar. Separators that would be
1539  // in the toolbar are ignored as they would introduce too much clutter,
1540  // instead we have a single separator to help distinguish between overflow
1541  // and hidden items.
1542  if ( mpData->m_aItems.empty() )
1543  return;
1544 
1545  // nStartPos will hold the number of clipped items appended from first loop
1546  for ( const auto& rItem : mpData->m_aItems )
1547  {
1548  if( rItem.IsClipped() )
1549  {
1550  sal_uInt16 id = sal_uInt16(rItem.mnId) + TOOLBOX_MENUITEM_START;
1551  MenuItemBits nMenuItemBits = ConvertBitsFromToolBoxToMenu(rItem.mnBits);
1552  pMenu->InsertItem( id, rItem.maText, rItem.maImage, nMenuItemBits);
1553  pMenu->SetItemCommand( id, rItem.maCommandStr );
1554  pMenu->EnableItem( id, rItem.mbEnabled );
1555  pMenu->CheckItem ( id, rItem.meState == TRISTATE_TRUE );
1556  }
1557  }
1558 
1559  // add a separator below the inserted clipped-items
1560  pMenu->InsertSeparator();
1561 
1562  // now append the items that are explicitly disabled
1563  for ( const auto& rItem : mpData->m_aItems )
1564  {
1565  if( rItem.IsItemHidden() )
1566  {
1567  sal_uInt16 id = sal_uInt16(rItem.mnId) + TOOLBOX_MENUITEM_START;
1568  MenuItemBits nMenuItemBits = ConvertBitsFromToolBoxToMenu(rItem.mnBits);
1569  pMenu->InsertItem( id, rItem.maText, rItem.maImage, nMenuItemBits );
1570  pMenu->SetItemCommand( id, rItem.maCommandStr );
1571  pMenu->EnableItem( id, rItem.mbEnabled );
1572  pMenu->CheckItem( id, rItem.meState == TRISTATE_TRUE );
1573  }
1574  }
1575 }
1576 
1577 IMPL_LINK( ToolBox, ImplCustomMenuListener, VclMenuEvent&, rEvent, void )
1578 {
1579  if( rEvent.GetMenu() == GetMenu() && rEvent.GetId() == VclEventId::MenuSelect )
1580  {
1581  sal_uInt16 id = GetMenu()->GetItemId( rEvent.GetItemPos() );
1582  if( id >= TOOLBOX_MENUITEM_START )
1583  TriggerItem( ToolBoxItemId(id - TOOLBOX_MENUITEM_START) );
1584  }
1585 }
1586 
1588 {
1589  if ( !IsMenuEnabled() || ImplIsInPopupMode() )
1590  return;
1591 
1592  UpdateCustomMenu();
1593 
1595  // call button handler to allow for menu customization
1596  mpData->maMenuButtonHdl.Call( this );
1597 
1598  GetMenu()->AddEventListener( LINK( this, ToolBox, ImplCustomMenuListener ) );
1599 
1600  // make sure all disabled entries will be shown
1601  GetMenu()->SetMenuFlags(
1602  GetMenu()->GetMenuFlags() | MenuFlags::AlwaysShowDisabledEntries );
1603 
1604  // toolbox might be destroyed during execute
1605  bool bBorderDel = false;
1606 
1607  VclPtr<vcl::Window> pWin = this;
1608  tools::Rectangle aMenuRect = rRect;
1609  VclPtr<ImplBorderWindow> pBorderWin;
1610  if( aMenuRect.IsEmpty() && IsFloatingMode() )
1611  {
1612  // custom menu is placed in the decoration
1613  pBorderWin = dynamic_cast<ImplBorderWindow*>( GetWindow( GetWindowType::Border ) );
1614  if( pBorderWin && !pBorderWin->GetMenuRect().IsEmpty() )
1615  {
1616  pWin = pBorderWin;
1617  aMenuRect = pBorderWin->GetMenuRect();
1618  bBorderDel = true;
1619  }
1620  }
1621 
1622  sal_uInt16 uId = GetMenu()->Execute( pWin, tools::Rectangle( ImplGetPopupPosition( aMenuRect ), Size() ),
1624 
1625  if ( pWin->isDisposed() )
1626  return;
1627 
1628  if( GetMenu() )
1629  GetMenu()->RemoveEventListener( LINK( this, ToolBox, ImplCustomMenuListener ) );
1630  if( bBorderDel )
1631  {
1632  if( pBorderWin->isDisposed() )
1633  return;
1634  }
1635 
1636  pWin->Invalidate( aMenuRect );
1637 
1638  if( uId )
1640 }
1641 
1642 // checks override first, useful during calculation of sizes
1644 {
1645  SAL_WARN_IF( mpData->mbAssumeDocked && mpData->mbAssumeFloating, "vcl",
1646  "cannot assume docked and floating" );
1647 
1648  if( mpData->mbAssumeDocked )
1649  return false;
1650  else if( mpData->mbAssumeFloating )
1651  return true;
1652  else
1653  return IsFloatingMode();
1654 }
1655 
1656 // checks override first, useful during calculation of sizes
1658 {
1659  if( mpData->mbAssumePopupMode )
1660  return true;
1661  else
1662  {
1664  return ( pWrapper && pWrapper->GetFloatingWindow() && static_cast<FloatingWindow*>(pWrapper->GetFloatingWindow())->IsInPopupMode() );
1665  }
1666 }
1667 
1668 void ToolBox::Lock( bool bLock )
1669 {
1671  if( !pWrapper )
1672  return;
1673  if( mpData->mbIsLocked != bLock )
1674  {
1675  mpData->mbIsLocked = bLock;
1676  if( !ImplIsFloatingMode() )
1677  {
1678  mbCalc = true;
1679  mbFormat = true;
1681  Invalidate();
1682  }
1683  }
1684 }
1685 
1687 {
1688  // read config item to determine toolbox behaviour, used for subtoolbars
1689 
1690  static int nAlwaysLocked = -1;
1691 
1692  if( nAlwaysLocked == -1 )
1693  {
1694  nAlwaysLocked = 0; // ask configuration only once
1695 
1698  "/org.openoffice.Office.UI.GlobalSettings/Toolbars" ); // note: case sensitive !
1699  if ( aNode.isValid() )
1700  {
1701  // feature enabled ?
1702  bool bStatesEnabled = bool();
1703  css::uno::Any aValue = aNode.getNodeValue( "StatesEnabled" );
1704  if( aValue >>= bStatesEnabled )
1705  {
1706  if( bStatesEnabled )
1707  {
1708  // now read the locking state
1711  "/org.openoffice.Office.UI.GlobalSettings/Toolbars/States" ); // note: case sensitive !
1712 
1713  bool bLocked = bool();
1714  css::uno::Any aValue2 = aNode2.getNodeValue( "Locked" );
1715  if( aValue2 >>= bLocked )
1716  nAlwaysLocked = bLocked ? 1 : 0;
1717  }
1718  }
1719  }
1720  }
1721 
1722  return nAlwaysLocked == 1;
1723 }
1724 
1726 {
1727  return mpData->mbWillUsePopupMode;
1728 }
1729 
1731 {
1732  mpData->mbWillUsePopupMode = b;
1733 }
1734 
1736 {
1737  DockingWindow::DumpAsPropertyTree(rJsonWriter);
1738 
1739  if (!GetChildCount())
1740  {
1741  auto childrenNode = rJsonWriter.startArray("children");
1742  for (ToolBox::ImplToolItems::size_type i = 0; i < GetItemCount(); ++i)
1743  {
1744  auto childNode = rJsonWriter.startStruct();
1746 
1747  vcl::Window* pWindow = GetItemWindow(nId);
1748  if (pWindow)
1749  {
1750  pWindow->DumpAsPropertyTree(rJsonWriter);
1751  }
1752  else
1753  {
1754  OUString sCommand = GetItemCommand(nId);
1755  rJsonWriter.put("type", "toolitem");
1756  rJsonWriter.put("text", GetItemText(nId));
1757  rJsonWriter.put("command", sCommand);
1758  if (IsItemChecked(nId))
1759  rJsonWriter.put("selected", true);
1760  if (!IsItemVisible(nId))
1761  rJsonWriter.put("visible", false);
1763  rJsonWriter.put("dropdown", true);
1764  if (!IsItemEnabled(nId))
1765  rJsonWriter.put("enabled", false);
1766 
1767  Image aImage = GetItemImage(nId);
1768  if (!sCommand.startsWith(".uno:") && !!aImage)
1769  {
1770  SvMemoryStream aOStm(6535, 6535);
1772  {
1773  css::uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell());
1774  OUStringBuffer aBuffer("data:image/png;base64,");
1776  rJsonWriter.put("image", aBuffer.makeStringAndClear());
1777  }
1778  }
1779  }
1780  }
1781  }
1782 }
1783 
1784 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetHelpId(ToolBoxItemId nItemId, const OString &rHelpId)
Definition: toolbox2.cxx:1376
void init(ToolBoxItemId nItemId, ToolBoxItemBits nItemBits, bool bEmptyBtn)
Definition: toolbox2.cxx:85
void DetermineButtonDrawStyle(ButtonType eButtonType, bool &rbImage, bool &rbText) const
Definition: toolbox2.cxx:193
WindowAlign
void SetItemWindowNonInteractive(ToolBoxItemId nItemId, bool bNonInteractive)
Definition: toolbox2.cxx:891
Size GetSizePixel() const
Definition: Image.cxx:86
void Clear()
Definition: menu.cxx:593
virtual void Flush()
Definition: outdev.hxx:426
void SetMenuExecuteHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox2.cxx:1504
tools::Long mnTopBorder
Definition: toolbox.hxx:121
sal_Int32 nIndex
OUString maQuickHelpText
Definition: toolbox.h:44
WinBits const WB_NOLABEL
ToolBoxItemId mnHighItemId
Definition: toolbox.hxx:128
OString maHelpId
Definition: toolbox.h:47
ToolBoxButtonSize
Definition: vclenum.hxx:293
SAL_DLLPRIVATE bool ImplHasClippedItems()
Definition: toolbox2.cxx:1509
void UpdateCustomMenu()
Definition: toolbox2.cxx:1531
void SetItemImageAngle(ToolBoxItemId nItemId, Degree10 nAngle10)
Definition: toolbox2.cxx:976
void setWidth(tools::Long nWidth)
OUString DetermineIconTheme() const
Determine which icon theme should be used.
void SetMenuType(ToolBoxMenuType aType=ToolBoxMenuType::Customize)
Definition: toolbox2.cxx:1464
bool mbMirrorMode
Definition: toolbox.h:42
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:901
vcl::Window * GetItemWindow(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1097
tools::Long mnSepSize
Definition: toolbox.h:54
ScopedJsonWriterStruct startStruct()
SAL_DLLPRIVATE void ImplUpdateItem(ImplToolItems::size_type nIndex=ITEM_NOTFOUND)
Definition: toolbox2.cxx:306
Link< ToolBox *, void > maActivateHdl
Definition: toolbox.hxx:165
OUString GetItemCommand(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1335
constexpr tools::Long Left() const
void AddEventListener(const Link< VclMenuEvent &, void > &rEventListener)
Definition: menu.cxx:407
ToolBoxMenuType
Definition: toolbox.hxx:50
Size GetSize(bool bHorz, bool bCheckMaxWidth, tools::Long maxWidth, const Size &rDefaultSize)
Definition: toolbox2.cxx:135
virtual FactoryFunction GetUITestFactory() const override
Definition: toolbox2.cxx:361
void DoubleClick()
Definition: toolbox2.cxx:336
void SetHelpText(ToolBoxItemId nItemId, const OUString &rText)
Definition: toolbox2.cxx:1363
bool IsMenuEnabled() const
Definition: toolbox2.cxx:1494
void ExecuteCustomMenu(const tools::Rectangle &rRect=tools::Rectangle())
Definition: toolbox2.cxx:1587
long Long
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:733
ScopedJsonWriterArray startArray(const char *)
OUString GetLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
Return a label for the given command.
const OUString & GetHelpText() const
Definition: window.cxx:3087
const OUString & GetQuickHelpText() const
Definition: window2.cxx:1226
static constexpr auto ITEM_NOTFOUND
Definition: toolbox.hxx:98
Degree10 mnImageAngle
Definition: toolbox.h:41
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual Size GetSizePixel() const
Definition: window.cxx:2399
Link< ToolBox *, void > maSelectHdl
Definition: toolbox.hxx:167
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1256
sal_uInt16 mnMouseModifier
Definition: toolbox.hxx:138
WindowAlign meAlign
Definition: toolbox.hxx:156
sal_Int16 nId
bool WillUsePopupMode() const
Definition: toolbox2.cxx:1725
std::unique_ptr< ImplToolBoxPrivateData > mpData
Definition: toolbox.hxx:108
void * mpUserData
Definition: toolbox.h:39
ToolBoxItemType GetItemType(ImplToolItems::size_type nPos) const
Definition: toolbox2.cxx:714
static Size SizeByThemeName(std::u16string_view)
Obtain the icon size by theme name.
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
Definition: menu.cxx:2779
tools::Rectangle GetDesktopRectPixel() const
Definition: window.cxx:2793
void Highlight()
Definition: toolbox2.cxx:356
#define TB_SEP_SIZE
Definition: toolbox2.cxx:53
SAL_DLLPRIVATE void ImplSetMinMaxFloatSize()
Definition: toolbox.cxx:861
sal_uInt16 mnId
TRISTATE_TRUE
tools::Rectangle GetCharacterBounds(ToolBoxItemId nItemId, tools::Long nIndex)
Definition: toolbox2.cxx:1416
ButtonType
Definition: vclenum.hxx:71
void SetButtonType(ButtonType eNewType)
Definition: toolbox2.cxx:605
ToolBoxItemType
Definition: vclenum.hxx:69
tools::Rectangle GetItemRect(ToolBoxItemId nItemId)
Definition: toolbox2.cxx:835
MenuItemBits
Definition: vclenum.hxx:32
tools::Long mnLeftBorder
Definition: toolbox.hxx:120
tools::Rectangle const & GetOverflowRect() const
Definition: toolbox2.cxx:855
void * GetItemData(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:935
void logAction(VclPtr< Control > const &xUIElement, VclEventId nEvent)
Definition: logger.cxx:147
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1069
SAL_DLLPRIVATE bool ImplIsInPopupMode() const
Definition: toolbox2.cxx:1657
constexpr tools::Long Width() const
static UITestLogger & getInstance()
Definition: logger.cxx:611
SAL_DLLPRIVATE void ImplUpdateInputEnable()
Definition: toolbox2.cxx:1385
Size CalcWindowSizePixel()
Definition: toolbox.hxx:532
tools::Long mnBottomBorder
Definition: toolbox.hxx:123
static constexpr auto APPEND
Definition: toolbox.hxx:95
#define TB_MENUBUTTON_SIZE
Definition: toolbox.h:30
virtual void Activate() override
Definition: toolbox2.cxx:342
void SetDropdownClickHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox2.cxx:1457
void Enable(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2430
void SetItemDown(ToolBoxItemId nItemId, bool bDown)
Definition: toolbox2.cxx:1127
PropertiesInfo aProperties
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3355
o3tl::strong_int< sal_uInt16, struct ToolBoxItemIdTag > ToolBoxItemId
Definition: toolbox.hxx:71
bool mbDrag
Definition: toolbox.hxx:139
void SetItemText(ToolBoxItemId nItemId, const OUString &rText)
Definition: toolbox2.cxx:1042
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:272
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
Definition: toolbox2.cxx:874
constexpr Point BottomLeft() const
Link< ToolBox *, void > maDeactivateHdl
Definition: toolbox.hxx:166
int nCount
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
Definition: menu.cxx:1064
void Hide()
Definition: window.hxx:884
void SetMenuFlags(MenuFlags nFlags)
Definition: menu.hxx:259
bool mbEmptyBtn
Definition: toolbox.h:62
void SetAlign(WindowAlign eNewAlign=WindowAlign::Top)
Definition: toolbox2.cxx:668
Link< ToolBox *, void > maClickHdl
Definition: toolbox.hxx:163
tools::Rectangle GetDropDownRect(bool bHorz) const
Definition: toolbox2.cxx:245
SAL_DLLPRIVATE void ImplFormat(bool bResize=false)
Definition: toolbox.cxx:1898
tools::Long GetCtrlTextWidth(const OUString &rStr, const SalLayoutGlyphs *pLayoutCache=nullptr) const
Definition: text.cxx:2181
void InsertSeparator(const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
Definition: menu.cxx:494
static void encode(OUStringBuffer &aStrBuffer, const css::uno::Sequence< sal_Int8 > &aPass)
virtual void InsertItem(const OUString &rCommand, const css::uno::Reference< css::frame::XFrame > &rFrame, ToolBoxItemBits nBits, const Size &rRequestedSize, ImplToolItems::size_type nPos=APPEND)
Insert a command (like '.uno:Save').
Definition: toolbox2.cxx:437
void SetItemWindow(ToolBoxItemId nItemId, vcl::Window *pNewWindow)
Definition: toolbox2.cxx:1082
bool IsItemEnabled(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1265
SystemWindow * GetFloatingWindow() const
Definition: dockmgr.cxx:1071
Size GetItemContentSize(ToolBoxItemId nItemId)
Returns size of the bitmap / text that is inside this toolbox item.
Definition: toolbox2.cxx:760
constexpr bool IsEmpty() const
SAL_DLLPRIVATE void ImplInvalidate(bool bNewCalc=false, bool bFullPaint=false)
Definition: toolbox2.cxx:271
constexpr void SetLeft(tools::Long v)
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
Definition: BitmapEx.cxx:259
void SetItemExpand(ToolBoxItemId nItemId, bool bExpand)
Definition: toolbox2.cxx:911
bool IsItemChecked(ToolBoxItemId nItemId) const
Definition: toolbox.hxx:527
Image GetImageForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
bool mbHorz
Definition: toolbox.hxx:139
ToolBoxButtonSize GetToolboxButtonSize() const
Definition: toolbox2.cxx:627
PopupMenu * GetMenu() const
Definition: toolbox2.cxx:1499
void SetToolboxButtonSize(ToolBoxButtonSize eSize)
Definition: toolbox2.cxx:617
ToolBoxItemBits
Definition: vclenum.hxx:50
VclPtr< vcl::Window > mpWindow
ImplToolItems::size_type mnCurPos
Definition: toolbox.hxx:131
void RemoveItem(ImplToolItems::size_type nPos)
Definition: toolbox2.cxx:534
void EndSelection()
Definition: toolbox2.cxx:1107
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
tools::Long mnDropDownArrowWidth
Definition: toolbox.h:55
bool IsFloatingMode() const
Definition: dockwin.cxx:943
ToolBoxMenuType GetMenuType() const
Definition: toolbox2.cxx:1489
int i
virtual void DumpAsPropertyTree(tools::JsonWriter &) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: toolbox2.cxx:1735
static bool AlwaysLocked()
Definition: toolbox2.cxx:1686
void SetQuickHelpText(ToolBoxItemId nItemId, const OUString &rText)
Definition: toolbox2.cxx:1345
ImageType
Definition: vclenum.hxx:324
IMPL_LINK(ToolBox, ImplCustomMenuListener, VclMenuEvent &, rEvent, void)
Definition: toolbox2.cxx:1577
ImplToolItems::size_type GetItemPos(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:719
bool mbVisible
Definition: toolbox.h:62
css::uno::Any getNodeValue(const OUString &_rPath) const noexcept
bool Overlaps(const tools::Rectangle &rRect) const
void SetItemImage(ToolBoxItemId nItemId, const Image &rImage)
Definition: toolbox2.cxx:945
ImplDockingWindowWrapper.
SAL_DLLPRIVATE ImplToolItem * ImplGetItem(ToolBoxItemId nId) const
Definition: toolbox.cxx:1336
void SetItemData(ToolBoxItemId nItemId, void *pNewData)
Definition: toolbox2.cxx:924
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1164
TRISTATE_FALSE
bool mbCalc
Definition: toolbox.hxx:139
void Lock(bool bLock)
Definition: toolbox2.cxx:1668
bool IsItemClipped(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1291
bool IsUpdateMode() const
Definition: window2.cxx:1167
bool mbExpand
Definition: toolbox.h:62
constexpr tools::Long Right() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
ToolBoxItemId mnId
Definition: toolbox.h:61
bool mbEnabled
Definition: toolbox.h:62
SAL_DLLPRIVATE Point ImplGetPopupPosition(const tools::Rectangle &rRect) const
Definition: toolbox2.cxx:785
OUString maCommandStr
Definition: toolbox.h:46
bool IsClipped() const
Definition: toolbox2.cxx:261
Image maImage
Definition: toolbox.h:40
constexpr tools::Long Top() const
void GrabFocusToDocument()
Definition: window.cxx:2983
virtual void Click()
Definition: toolbox2.cxx:329
static OConfigurationTreeRoot tryCreateWithComponentContext(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &_rPath, sal_Int32 _nDepth=-1, CREATION_MODE _eMode=CM_UPDATABLE)
SAL_DLLPRIVATE void ImplFillLayoutData()
Definition: toolbox2.cxx:1394
void CopyItem(const ToolBox &rToolBox, ToolBoxItemId nItemId)
Definition: toolbox2.cxx:563
SAL_DLLPRIVATE bool ImplHasExternalMenubutton()
Definition: toolbox2.cxx:860
bool IsMouseCaptured() const
Definition: mouse.cxx:475
void SetItemState(ToolBoxItemId nItemId, TriState eState)
Definition: toolbox2.cxx:1167
SAL_DLLPRIVATE bool ImplIsFloatingMode() const
Definition: toolbox2.cxx:1643
ToolBoxItemId mnCurItemId
Definition: toolbox.hxx:129
tools::Rectangle GetMenuRect() const
Definition: brdwin.cxx:1971
VclPtr< vcl::Window > mpWindow
Definition: toolbox.h:37
void ShowItem(ToolBoxItemId nItemId, bool bVisible=true)
Shows or hides items.
Definition: toolbox2.cxx:1275
static Image ImplRotImage(const Image &rImage, Degree10 nAngle10)
Definition: toolbox2.cxx:967
bool IsItemReallyVisible(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1311
bool mbFormat
Definition: toolbox.hxx:139
bool Rotate(Degree10 nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
Definition: BitmapEx.cxx:316
Size maItemSize
The overall horizontal item size, including one or more of [image size + textlength + dropdown arrow]...
Definition: toolbox.h:53
constexpr void SetTop(tools::Long v)
tools::Long GetIndexForPoint(const Point &rPoint, ToolBoxItemId &rItemID)
Definition: toolbox2.cxx:1435
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
Definition: window.cxx:2849
ToolBoxItemBits mnBits
Definition: toolbox.h:59
void put(const char *pPropName, const OUString &rPropValue)
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
Definition: menu.cxx:916
float GetDPIScaleFactor() const
Definition: outdev.hxx:393
void CheckItem(sal_uInt16 nItemId, bool bCheck=true)
Definition: menu.cxx:835
constexpr Point TopLeft() const
std::vector< SvtDynMenuEntry > GetMenu(EDynamicMenuType eMenu)
constexpr sal_uInt16 TOOLBOX_MENUITEM_START
Definition: toolbox.hxx:47
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1035
virtual void Deactivate() override
Definition: toolbox2.cxx:349
void EnableItem(ToolBoxItemId nItemId, bool bEnable=true)
Definition: toolbox2.cxx:1237
constexpr tools::Long Bottom() const
void ReleaseMouse()
Definition: mouse.cxx:463
void InsertWindow(ToolBoxItemId nItemId, vcl::Window *pWindow, ToolBoxItemBits nBits=ToolBoxItemBits::NONE, ImplToolItems::size_type nPos=APPEND)
Definition: toolbox2.cxx:458
tools::Rectangle maRect
Definition: toolbox.h:48
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
Return a label for the given command.
SAL_DLLPRIVATE void InvalidateItem(ImplToolItems::size_type nPosition)
Definition: toolbox.cxx:3409
static ErrCode Export(SvStream &rOStm, const Graphic &rGraphic, ConvertDataFormat nFormat)
Definition: cvtgrf.cxx:55
void InsertItem(sal_uInt16 nItemId, const OUString &rStr, MenuItemBits nItemBits=MenuItemBits::NONE, const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
Definition: menu.cxx:432
sal_uInt16 GetChildCount() const
Definition: stacking.cxx:1001
std::unique_ptr< char[]> aBuffer
SAL_DLLPRIVATE void ImplInitSettings()
Definition: dockwin.cxx:328
bool mbVisible
void SetLineCount(ImplToolItems::size_type nNewLines)
Definition: toolbox2.cxx:694
Text maText
bool mbVisibleText
Definition: toolbox.h:62
DockingManager * ImplGetDockingManager()
Definition: svdata.cxx:299
TriState GetItemState(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1227
void RemoveEventListener(const Link< VclMenuEvent &, void > &rEventListener)
Definition: menu.cxx:412
tools::Rectangle GetItemPosRect(ImplToolItems::size_type nPos)
Definition: toolbox2.cxx:844
tools::Rectangle & Union(const tools::Rectangle &rRect)
#define SAL_WARN_IF(condition, area, stream)
#define ERRCODE_NONE
Definition: errcode.hxx:196
constexpr tools::Long Height() const
std::unique_ptr< Idle > mpIdle
Definition: toolbox.hxx:110
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
OUString GetDisplayText() const override
Definition: toolbox2.cxx:1409
void ShowMenuTitleButton(bool bVisible)
Definition: dockmgr.cxx:757
constexpr Point TopRight() const
::OutputDevice const * GetOutDev() const
Definition: window.cxx:565
tools::Long mnDY
Definition: toolbox.hxx:116
ImplDockingWindowWrapper * GetDockingWindowWrapper(const vcl::Window *pWin)
Definition: dockmgr.cxx:280
const OUString & GetItemText(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1072
Definition: image.hxx:39
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
SAL_DLLPRIVATE const OUString & ImplGetHelpText(ToolBoxItemId nItemId) const
Definition: toolbox.cxx:3605
void InsertSeparator(ImplToolItems::size_type nPos=APPEND, sal_uInt16 nPixSize=0)
Definition: toolbox2.cxx:500
void SetItemCommand(ToolBoxItemId nItemId, const OUString &rCommand)
Definition: toolbox2.cxx:1327
ButtonType meButtonType
Definition: toolbox.hxx:158
OUString aLabel
sal_uInt64 Tell() const
Reference< XComponentContext > getProcessComponentContext()
Sequence< sal_Int8 > aSeq
OUString maHelpText
Definition: toolbox.h:45
tools::Long mnDX
Definition: toolbox.hxx:115
FILE * init(int, char **)
BitmapEx GetBitmapEx() const
Definition: Image.cxx:94
void InsertBreak(ImplToolItems::size_type nPos=APPEND)
Definition: toolbox2.cxx:518
#define TB_MENUBUTTON_OFFSET
Definition: toolbox.h:31
void setHeight(tools::Long nHeight)
void InsertSpace()
Definition: toolbox2.cxx:484
Link< ToolBox *, void > maDoubleClickHdl
Definition: toolbox.hxx:164
bool mbShowWindow
Definition: toolbox.h:62
WinBits GetStyle() const
Definition: window2.cxx:947
virtual void Select()
Definition: toolbox2.cxx:366
bool IsItemVisible(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1301
static OUString EraseAllMnemonicChars(const OUString &rStr)
Definition: mnemonic.cxx:312
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: event.cxx:218
bool IsReallyVisible() const
Definition: window2.cxx:1101
ToolBoxItemId GetItemId(ImplToolItems::size_type nPos) const
Definition: toolbox2.cxx:743
Size GetDefaultImageSize() const
Definition: toolbox2.cxx:663
TriState
#define TB_DROPDOWNARROWWIDTH
Definition: toolbox.h:28
Image GetItemImage(ToolBoxItemId nItemId) const
Definition: toolbox2.cxx:1036
TriState meState
Definition: toolbox.h:60
OUString maText
Definition: toolbox.h:43
void SetItemImageMirrorMode(ToolBoxItemId nItemId, bool bMirror)
Definition: toolbox2.cxx:1014
static Image ImplMirrorImage(const Image &rImage)
Definition: toolbox2.cxx:1005
OUString GetTooltipForCommand(const OUString &rsCommandName, const css::uno::Sequence< css::beans::PropertyValue > &rProperties, const Reference< frame::XFrame > &rxFrame)
RedlineType meType
ToolBoxItemId mnDownItemId
Definition: toolbox.hxx:130
void Clear()
Definition: toolbox2.cxx:590
bool IsItemHidden() const
Definition: toolbox2.cxx:266
Size maMinimalItemSize
Widget layout may request size; set it as the minimal size (like, the item will always have at least ...
Definition: toolbox.h:51
bool isDisposed() const
ImplToolItems::size_type GetItemCount() const
Definition: toolbox2.cxx:709
tools::Rectangle maPaintRect
Definition: toolbox.hxx:113
vcl::ImageType GetImageSize() const
Definition: toolbox2.cxx:632
ImplToolItems::size_type mnLines
Definition: toolbox.hxx:132
sal_uInt16 nPos
tools::Long mnRightBorder
Definition: toolbox.hxx:122
tools::Long mnActivateCount
Definition: toolbox.hxx:125
const void * GetData()
ToolBoxItemType meType
Definition: toolbox.h:58