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