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