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