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