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