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