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