LibreOffice Module vcl (master)  1
menubarwindow.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 "menubarwindow.hxx"
21 #include "menuitemlist.hxx"
22 #include "menufloatingwindow.hxx"
23 
24 #include <vcl/dockingarea.hxx>
25 #include <vcl/settings.hxx>
26 #include <vcl/taskpanelist.hxx>
27 #include <sal/log.hxx>
28 
29 #include <salframe.hxx>
30 #include <salmenu.hxx>
31 #include <svdata.hxx>
32 #include <strings.hrc>
33 #include <bitmaps.hlst>
34 #include <window.h>
35 #include "bufferdevice.hxx"
36 
37 // document closing button
38 #define IID_DOCUMENTCLOSE 1
39 
41  ToolBox( pParent, 0 ),
42  lastSize(-1)
43 {
44  calcMinSize();
45 }
46 
48 {
49  Window::DataChanged( rDCEvt );
50 
51  if ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )
52  {
53  calcMinSize();
54  SetBackground();
55  SetImages( 0, true);
56  }
57 }
58 
60 {
62  if( GetItemCount() == 0 )
63  {
64  aTbx->InsertItem(IID_DOCUMENTCLOSE, Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC));
65  }
66  else
67  {
68  ImplToolItems::size_type nItems = GetItemCount();
69  for( ImplToolItems::size_type i = 0; i < nItems; i++ )
70  {
71  sal_uInt16 nId = GetItemId( i );
72  aTbx->InsertItem( nId, GetItemImage( nId ) );
73  }
74  }
76 
77  aTbx.disposeAndClear();
78 }
79 
80 void DecoToolBox::SetImages( tools::Long nMaxHeight, bool bForce )
81 {
83 
84  if( !nMaxHeight && lastSize != -1 )
85  nMaxHeight = lastSize + border; // don't change anything if called with 0
86 
87  if( nMaxHeight < getMinSize().Height() )
88  nMaxHeight = getMinSize().Height();
89 
90  if( (lastSize == nMaxHeight - border) && !bForce )
91  return;
92 
93  lastSize = nMaxHeight - border;
94 
95  Color aEraseColor( 255, 255, 255, 255 );
96  BitmapEx aBmpExDst( maImage.GetBitmapEx() );
97  BitmapEx aBmpExSrc( aBmpExDst );
98 
99  aEraseColor.SetAlpha( 0 );
100  aBmpExDst.Erase( aEraseColor );
101  aBmpExDst.Scale( Size( lastSize, lastSize ) );
102 
103  tools::Rectangle aSrcRect( Point(0,0), maImage.GetSizePixel() );
105  (lastSize - maImage.GetSizePixel().Height())/2 ),
106  maImage.GetSizePixel() );
107 
108  aBmpExDst.CopyPixel( aDestRect, aSrcRect, &aBmpExSrc );
109  SetItemImage( IID_DOCUMENTCLOSE, Image( aBmpExDst ) );
110 
111 }
112 
114  Window( pParent, 0 ),
115  m_aCloseBtn(VclPtr<DecoToolBox>::Create(this)),
118 {
119  SetType(WindowType::MENUBARWINDOW);
120  m_pMenu = nullptr;
121  m_pActivePopup = nullptr;
124  mbAutoPopup = true;
125  m_bIgnoreFirstMove = true;
126  SetMBWHideAccel(true);
127  SetMBWMenuKey(false);
128 
129  m_aCloseBtn->maImage = Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC);
130 
134 
136  m_aCloseBtn->SetSelectHdl(LINK(this, MenuBarWindow, CloseHdl));
137  m_aCloseBtn->AddEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
138  m_aCloseBtn->SetQuickHelpText(IID_DOCUMENTCLOSE, VclResId(SV_HELPTEXT_CLOSEDOCUMENT));
139 
141  m_aFloatBtn->SetQuickHelpText(VclResId(SV_HELPTEXT_RESTORE));
142 
144  m_aHideBtn->SetQuickHelpText(VclResId(SV_HELPTEXT_MINIMIZE));
145 
147 
148  AddEventListener(LINK(this, MenuBarWindow, ShowHideListener));
149 }
150 
152 {
153  disposeOnce();
154 }
155 
157 {
158  m_aCloseBtn->RemoveEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
159  RemoveEventListener(LINK(this, MenuBarWindow, ShowHideListener));
160 
165  m_pMenu.clear();
168 
169  Window::dispose();
170 }
171 
173 {
174  m_pMenu = pMen;
175  KillActivePopup();
177  if (pMen)
178  {
180  m_aCloseBtn->Show(pMen->HasCloseButton() || !m_aAddButtons.empty());
181  m_aFloatBtn->Show(pMen->HasFloatButton());
182  m_aHideBtn->Show(pMen->HasHideButton());
183  }
184  Invalidate();
185 
186  // show and connect native menubar
187  if( m_pMenu && m_pMenu->ImplGetSalMenu() )
188  {
191 
193  }
194 }
195 
197 {
198  setPosSizePixel(0, 0, 0, nHeight, PosSizeFlags::Height);
199 }
200 
201 void MenuBarWindow::ShowButtons( bool bClose, bool bFloat, bool bHide )
202 {
204  m_aCloseBtn->Show(bClose || !m_aAddButtons.empty());
205  if (m_pMenu->mpSalMenu)
206  m_pMenu->mpSalMenu->ShowCloseButton(bClose);
207  m_aFloatBtn->Show( bFloat );
208  m_aHideBtn->Show( bHide );
209  Resize();
210 }
211 
213 {
214  return m_aCloseBtn->getMinSize();
215 }
216 
218 {
219  if( ! m_pMenu )
220  return;
221 
222  if( m_aCloseBtn->GetCurItemId() == IID_DOCUMENTCLOSE )
223  {
224  // #i106052# call close hdl asynchronously to ease handler implementation
225  // this avoids still being in the handler while the DecoToolBox already
226  // gets destroyed
227  Application::PostUserEvent(static_cast<MenuBar*>(m_pMenu.get())->GetCloseButtonClickHdl());
228  }
229  else
230  {
231  std::map<sal_uInt16,AddButtonEntry>::iterator it = m_aAddButtons.find(m_aCloseBtn->GetCurItemId());
232  if( it != m_aAddButtons.end() )
233  {
235  aArg.nId = it->first;
236  aArg.bHighlight = (m_aCloseBtn->GetHighlightItemId() == it->first);
237  it->second.m_aSelectLink.Call( aArg );
238  }
239  }
240 }
241 
242 IMPL_LINK( MenuBarWindow, ToolboxEventHdl, VclWindowEvent&, rEvent, void )
243 {
244  if( ! m_pMenu )
245  return;
246 
248  aArg.nId = 0xffff;
249  aArg.bHighlight = (rEvent.GetId() == VclEventId::ToolboxHighlight);
250  if( rEvent.GetId() == VclEventId::ToolboxHighlight )
251  aArg.nId = m_aCloseBtn->GetHighlightItemId();
252  else if( rEvent.GetId() == VclEventId::ToolboxHighlightOff )
253  {
254  auto nPos = static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rEvent.GetData()));
255  aArg.nId = m_aCloseBtn->GetItemId(nPos);
256  }
257  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( aArg.nId );
258  if( it != m_aAddButtons.end() )
259  {
260  it->second.m_aHighlightLink.Call( aArg );
261  }
262 }
263 
264 IMPL_LINK( MenuBarWindow, ShowHideListener, VclWindowEvent&, rEvent, void )
265 {
266  if( ! m_pMenu )
267  return;
268 
269  if( rEvent.GetId() == VclEventId::WindowShow )
270  m_pMenu->ImplCallEventListeners( VclEventId::MenuShow, ITEMPOS_INVALID );
271  else if( rEvent.GetId() == VclEventId::WindowHide )
272  m_pMenu->ImplCallEventListeners( VclEventId::MenuHide, ITEMPOS_INVALID );
273 }
274 
275 void MenuBarWindow::ImplCreatePopup( bool bPreSelectFirst )
276 {
278  if ( !pItemData )
279  return;
280 
281  m_bIgnoreFirstMove = true;
282  if ( m_pActivePopup && ( m_pActivePopup != pItemData->pSubMenu ) )
283  {
284  KillActivePopup();
285  }
286  if ( !(pItemData->bEnabled && pItemData->pSubMenu && ( m_nHighlightedItem != ITEMPOS_INVALID ) &&
287  ( pItemData->pSubMenu != m_pActivePopup )) )
288  return;
289 
290  m_pActivePopup = static_cast<PopupMenu*>(pItemData->pSubMenu.get());
291  tools::Long nX = 0;
292  MenuItemData* pData = nullptr;
293  for ( sal_uLong n = 0; n < m_nHighlightedItem; n++ )
294  {
295  pData = m_pMenu->GetItemList()->GetDataFromPos( n );
296  nX += pData->aSz.Width();
297  }
298  pData = m_pMenu->pItemList->GetDataFromPos( m_nHighlightedItem );
299  Point aItemTopLeft( nX, 0 );
300  Point aItemBottomRight( aItemTopLeft );
301  aItemBottomRight.AdjustX(pData->aSz.Width() );
302 
303  if (pData->bHiddenOnGUI)
304  {
308 
309  for (sal_uInt16 i = m_nHighlightedItem; i < m_pMenu->GetItemCount(); ++i)
310  {
311  sal_uInt16 nId = m_pMenu->GetItemId(i);
312 
313  MenuItemData* pParentItemData = m_pMenu->GetItemList()->GetData(nId);
314  assert(pParentItemData);
315  mpParentPopup->InsertItem(nId, pParentItemData->aText, pParentItemData->nBits, pParentItemData->sIdent);
316  mpParentPopup->SetHelpId(nId, pParentItemData->aHelpId);
317  mpParentPopup->SetHelpText(nId, pParentItemData->aHelpText);
318  mpParentPopup->SetAccelKey(nId, pParentItemData->aAccelKey);
319  mpParentPopup->SetItemCommand(nId, pParentItemData->aCommandStr);
320  mpParentPopup->SetHelpCommand(nId, pParentItemData->aHelpCommandStr);
321 
322  PopupMenu* pPopup = m_pMenu->GetPopupMenu(nId);
323  mpParentPopup->SetPopupMenu(nId, pPopup);
324  }
325  }
326  // the menu bar could have height 0 in fullscreen mode:
327  // so do not use always WindowHeight, as ItemHeight < WindowHeight.
328  if ( GetSizePixel().Height() )
329  {
330  // #107747# give menuitems the height of the menubar
331  aItemBottomRight.AdjustY(GetOutputSizePixel().Height()-1 );
332  }
333 
334  // ImplExecute is not modal...
335  // #99071# do not grab the focus, otherwise it will be restored to the menubar
336  // when the frame is reactivated later
337  //GrabFocus();
338  m_pActivePopup->ImplExecute( this, tools::Rectangle( aItemTopLeft, aItemBottomRight ), FloatWinPopupFlags::Down | FloatWinPopupFlags::NoHorzPlacement, m_pMenu, bPreSelectFirst );
339  // does not have a window, if aborted before or if there are no entries
342  else
343  m_pActivePopup = nullptr;
344 }
345 
347 {
348  if ( !m_pActivePopup )
349  return;
350 
351  if( m_pActivePopup->pWindow )
352  if( static_cast<FloatingWindow *>(m_pActivePopup->pWindow.get())->IsInCleanUp() )
353  return; // kill it later
354 
355  if ( m_pActivePopup->bInCallback )
356  m_pActivePopup->bCanceled = true;
357 
358  m_pActivePopup->bInCallback = true;
360  m_pActivePopup->bInCallback = false;
361  // check for pActivePopup, if stopped by deactivate...
362  if ( m_pActivePopup->ImplGetWindow() )
363  {
364  if (mpParentPopup)
365  {
366  for (sal_uInt16 i = 0; i < mpParentPopup->GetItemCount(); ++i)
367  {
368  sal_uInt16 nId = mpParentPopup->GetItemId(i);
369  MenuItemData* pParentItemData = mpParentPopup->GetItemList()->GetData(nId);
370  assert(pParentItemData);
371  pParentItemData->pSubMenu = nullptr;
372  }
373  }
376  m_pActivePopup->pWindow->SetParentToDefaultWindow();
377  m_pActivePopup->pWindow.disposeAndClear();
378  }
379  m_pActivePopup = nullptr;
380 }
381 
382 void MenuBarWindow::PopupClosed( Menu const * pPopup )
383 {
384  if ( pPopup == m_pActivePopup )
385  {
386  KillActivePopup();
387  ChangeHighlightItem( ITEMPOS_INVALID, false, ImplGetFrameWindow()->ImplGetFrameData()->mbHasFocus, false );
388  }
389 }
390 
392 {
393  mbAutoPopup = true;
394  SetMBWMenuKey(false);
395  sal_uInt16 nEntry = ImplFindEntry( rMEvt.GetPosPixel() );
396  if ( ( nEntry != ITEMPOS_INVALID ) && !m_pActivePopup )
397  {
398  ChangeHighlightItem( nEntry, false );
399  }
400  else
401  {
402  KillActivePopup();
404  }
405 }
406 
408 {
409 }
410 
412 {
413  if ( rMEvt.IsSynthetic() || rMEvt.IsEnterWindow() )
414  return;
415 
416  if ( rMEvt.IsLeaveWindow() )
417  {
419  {
420  // there is a spurious MouseMove generated after a menu is launched from the keyboard, hence this...
422  {
423  bool hide = GetMBWHideAccel();
424  SetMBWHideAccel(true);
425  Invalidate(); //HighlightItem( nRolloveredItem, false );
426  SetMBWHideAccel(hide);
427  }
428  else
429  Invalidate(); //HighlightItem( nRolloveredItem, false );
430  }
431 
433  return;
434  }
435 
436  sal_uInt16 nEntry = ImplFindEntry( rMEvt.GetPosPixel() );
438  {
439  if ( m_nRolloveredItem != nEntry )
440  {
442  Invalidate(); //HighlightItem( nRolloveredItem, false );
443 
444  m_nRolloveredItem = nEntry;
445  Invalidate(); //HighlightItem( nRolloveredItem, true );
446  }
447  return;
448  }
449  m_nRolloveredItem = nEntry;
450 
451  if( m_bIgnoreFirstMove )
452  {
453  m_bIgnoreFirstMove = false;
454  return;
455  }
456 
457  if ( ( nEntry != ITEMPOS_INVALID )
458  && ( nEntry != m_nHighlightedItem ) )
459  ChangeHighlightItem( nEntry, false );
460 }
461 
462 void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool bAllowRestoreFocus, bool bDefaultToDocument)
463 {
464  if( ! m_pMenu )
465  return;
466 
467  // always hide accelerators when updating the menu bar...
468  SetMBWHideAccel(true);
469 
470  // #57934# close active popup if applicable, as TH's background storage works.
471  MenuItemData* pNextData = m_pMenu->pItemList->GetDataFromPos( n );
472  if ( m_pActivePopup && m_pActivePopup->ImplGetWindow() && ( !pNextData || ( m_pActivePopup != pNextData->pSubMenu ) ) )
473  KillActivePopup(); // pActivePopup when applicable without pWin, if Rescheduled in Activate()
474 
475  // activate menubar only ones per cycle...
476  bool bJustActivated = false;
477  if ( ( m_nHighlightedItem == ITEMPOS_INVALID ) && ( n != ITEMPOS_INVALID ) )
478  {
480  // #105406# avoid saving the focus when we already have the focus
481  bool bNoSaveFocus = (this == ImplGetSVData()->mpWinData->mpFocusWin.get());
482 
483  if( m_xSaveFocusId != nullptr )
484  {
486  {
487  m_xSaveFocusId = nullptr;
488  if( !bNoSaveFocus )
489  m_xSaveFocusId = Window::SaveFocus(); // only save focus when initially activated
490  }
491  else {
492  ; // do nothing: we 're activated again from taskpanelist, focus was already saved
493  }
494  }
495  else
496  {
497  if( !bNoSaveFocus )
498  m_xSaveFocusId = Window::SaveFocus(); // only save focus when initially activated
499  }
500  m_pMenu->bInCallback = true; // set here if Activate overridden
501  m_pMenu->Activate();
502  m_pMenu->bInCallback = false;
503  bJustActivated = true;
504  }
505  else if ( ( m_nHighlightedItem != ITEMPOS_INVALID ) && ( n == ITEMPOS_INVALID ) )
506  {
507  m_pMenu->bInCallback = true;
508  m_pMenu->Deactivate();
509  m_pMenu->bInCallback = false;
511  if (!ImplGetSVData()->mpWinData->mbNoSaveFocus)
512  {
513  VclPtr<vcl::Window> xTempFocusId;
515  xTempFocusId = m_xSaveFocusId;
516  m_xSaveFocusId = nullptr;
517 
518  if (bAllowRestoreFocus)
519  {
520  // tdf#115227 the popup is already killed, so temporarily set us as the
521  // focus window, so we could avoid sending superfluous activate events
522  // to top window listeners.
523  if (xTempFocusId || bDefaultToDocument)
525 
526  // #105406# restore focus to document if we could not save focus before
527  if (!xTempFocusId && bDefaultToDocument)
529  else
530  Window::EndSaveFocus(xTempFocusId);
531  }
532  }
533  }
534 
536  {
538  Invalidate(); //HighlightItem( nHighlightedItem, false );
539 
541  }
542 
543  m_nHighlightedItem = n;
544  SAL_WARN_IF( ( m_nHighlightedItem != ITEMPOS_INVALID ) && !m_pMenu->ImplIsVisible( m_nHighlightedItem ), "vcl", "ChangeHighlightItem: Not visible!" );
546  Invalidate(); //HighlightItem( nHighlightedItem, true );
547  else if ( m_nRolloveredItem != ITEMPOS_INVALID )
548  Invalidate(); //HighlightItem( nRolloveredItem, true );
550 
551  if( mbAutoPopup )
552  ImplCreatePopup( bSelectEntry );
553 
554  // #58935# #73659# Focus, if no popup underneath...
555  if ( bJustActivated && !m_pActivePopup )
556  GrabFocus();
557 }
558 
559 static int ImplGetTopDockingAreaHeight( vcl::Window const *pWindow )
560 {
561  // find docking area that is top aligned and return its height
562  // note: dockingareas are direct children of the SystemWindow
563  if( pWindow->ImplGetFrameWindow() )
564  {
565  vcl::Window *pWin = pWindow->ImplGetFrameWindow()->GetWindow( GetWindowType::FirstChild ); //mpWindowImpl->mpFirstChild;
566  while( pWin )
567  {
568  if( pWin->IsSystemWindow() )
569  {
570  vcl::Window *pChildWin = pWin->GetWindow( GetWindowType::FirstChild ); //mpWindowImpl->mpFirstChild;
571  while( pChildWin )
572  {
573  DockingAreaWindow *pDockingArea = nullptr;
574  if ( pChildWin->GetType() == WindowType::DOCKINGAREA )
575  pDockingArea = static_cast< DockingAreaWindow* >( pChildWin );
576 
577  if( pDockingArea && pDockingArea->GetAlign() == WindowAlign::Top &&
578  pDockingArea->IsVisible() && pDockingArea->GetOutputSizePixel().Height() != 0 )
579  {
580  return pDockingArea->GetOutputSizePixel().Height();
581  }
582 
583  pChildWin = pChildWin->GetWindow( GetWindowType::Next ); //mpWindowImpl->mpNext;
584  }
585 
586  }
587 
588  pWin = pWin->GetWindow( GetWindowType::Next ); //mpWindowImpl->mpNext;
589  }
590  }
591  return 0;
592 }
593 
594 static void ImplAddNWFSeparator(vcl::RenderContext& rRenderContext, const Size& rSize, const MenubarValue& rMenubarValue)
595 {
596  // add a separator if
597  // - we have an adjacent docking area
598  // - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx)
599  if (rMenubarValue.maTopDockingAreaHeight
600  && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB
601  && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames)
602  {
603  // note: the menubar only provides the upper (dark) half of it, the rest (bright part) is drawn by the docking area
604 
605  rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor());
606  tools::Rectangle aRect(Point(), rSize);
607  rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
608  }
609 }
610 
611 void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos)
612 {
613  if (!m_pMenu)
614  return;
615 
616  tools::Long nX = 0;
617  size_t nCount = m_pMenu->pItemList->size();
618 
619  Size aOutputSize = GetOutputSizePixel();
620  aOutputSize.AdjustWidth( -(m_aCloseBtn->GetSizePixel().Width()) );
621 
622  for (size_t n = 0; n < nCount; n++)
623  {
624  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
625  if (n == nPos)
626  {
627  if (pData->eType != MenuItemType::SEPARATOR)
628  {
629  // #107747# give menuitems the height of the menubar
630  tools::Rectangle aRect(Point(nX, 1), Size(pData->aSz.Width(), aOutputSize.Height() - 2));
631  rRenderContext.Push(PushFlags::CLIPREGION);
632  rRenderContext.IntersectClipRegion(aRect);
633  bool bRollover, bHighlight;
634  if (!ImplGetSVData()->maNWFData.mbRolloverMenubar)
635  {
636  bHighlight = true;
637  bRollover = nPos != m_nHighlightedItem;
638  }
639  else
640  {
641  bRollover = nPos == m_nRolloveredItem;
642  bHighlight = nPos == m_nHighlightedItem;
643  }
646  {
647  // draw background (transparency)
648  MenubarValue aControlValue;
649  aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
650 
651  if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
652  Erase(rRenderContext);
653  else
654  {
655  tools::Rectangle aBgRegion(Point(), aOutputSize);
657  ControlState::ENABLED, aControlValue, OUString());
658  }
659 
660  ImplAddNWFSeparator(rRenderContext, aOutputSize, aControlValue);
661 
662  // draw selected item
664  if (bRollover)
665  nState |= ControlState::ROLLOVER;
666  else
667  nState |= ControlState::SELECTED;
669  aRect, nState, aControlValue, OUString() );
670  }
671  else
672  {
673  if (bRollover)
674  rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuBarRolloverColor());
675  else
676  rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
677  rRenderContext.SetLineColor();
678  rRenderContext.DrawRect(aRect);
679  }
680  rRenderContext.Pop();
681 
682  m_pMenu->ImplPaint(rRenderContext, aOutputSize, 0, 0, pData, bHighlight, false, bRollover);
683  }
684  return;
685  }
686 
687  nX += pData->aSz.Width();
688  }
689 }
690 
692 {
693  tools::Rectangle aRect;
694  if( m_pMenu )
695  {
696  tools::Long nX = 0;
697  size_t nCount = m_pMenu->pItemList->size();
698  for ( size_t n = 0; n < nCount; n++ )
699  {
700  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
701  if ( n == nPos )
702  {
703  if ( pData->eType != MenuItemType::SEPARATOR )
704  // #107747# give menuitems the height of the menubar
705  aRect = tools::Rectangle( Point( nX, 1 ), Size( pData->aSz.Width(), GetOutputSizePixel().Height()-2 ) );
706  break;
707  }
708 
709  nX += pData->aSz.Width();
710  }
711  }
712  return aRect;
713 }
714 
715 void MenuBarWindow::KeyInput( const KeyEvent& rKEvent )
716 {
717  if ( !HandleKeyEvent( rKEvent ) )
718  Window::KeyInput( rKEvent );
719 }
720 
721 bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
722 {
723  if (!m_pMenu)
724  return false;
725 
726  if (m_pMenu->bInCallback)
727  return true; // swallow
728 
729  bool bDone = false;
730  sal_uInt16 nCode = rKEvent.GetKeyCode().GetCode();
731 
732  if( GetParent() )
733  {
735  {
736  SystemWindow *pSysWin = static_cast<SystemWindow*>(GetParent()->GetWindow( GetWindowType::Client ));
737  if( pSysWin->GetTaskPaneList() )
738  if( pSysWin->GetTaskPaneList()->HandleKeyEvent( rKEvent ) )
739  return true;
740  }
741  }
742 
743  // no key events if native menus
745  {
746  return false;
747  }
748 
749  if ( nCode == KEY_MENU && !rKEvent.GetKeyCode().IsShift() ) // only F10, not Shift-F10
750  {
751  mbAutoPopup = false;
753  {
754  ChangeHighlightItem( 0, false );
755  GrabFocus();
756  }
757  else
758  {
760  m_xSaveFocusId = nullptr;
761  }
762  bDone = true;
763  }
764  else if ( bFromMenu )
765  {
766  if ( ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) ||
767  ( nCode == KEY_HOME ) || ( nCode == KEY_END ) )
768  {
769  sal_uInt16 n = m_nHighlightedItem;
770  if ( n == ITEMPOS_INVALID )
771  {
772  if ( nCode == KEY_LEFT)
773  n = 0;
774  else
775  n = m_pMenu->GetItemCount()-1;
776  }
777 
778  sal_uInt16 nLoop = n;
779 
780  if( nCode == KEY_HOME )
781  { n = sal_uInt16(-1); nLoop = n+1; }
782  if( nCode == KEY_END )
783  { n = m_pMenu->GetItemCount(); nLoop = n-1; }
784 
785  do
786  {
787  if ( nCode == KEY_LEFT || nCode == KEY_END )
788  {
789  if ( n )
790  n--;
791  else
792  n = m_pMenu->GetItemCount()-1;
793  }
794  if ( nCode == KEY_RIGHT || nCode == KEY_HOME )
795  {
796  n++;
797  if ( n >= m_pMenu->GetItemCount() )
798  n = 0;
799  }
800 
802  if (pData->eType != MenuItemType::SEPARATOR &&
803  m_pMenu->ImplIsVisible(n) &&
805  {
806  ChangeHighlightItem( n, true );
807  break;
808  }
809  } while ( n != nLoop );
810  bDone = true;
811  }
812  else if ( nCode == KEY_RETURN )
813  {
815  else
816  if ( !mbAutoPopup )
817  {
818  ImplCreatePopup( true );
819  mbAutoPopup = true;
820  }
821  bDone = true;
822  }
823  else if ( ( nCode == KEY_UP ) || ( nCode == KEY_DOWN ) )
824  {
825  if ( !mbAutoPopup )
826  {
827  ImplCreatePopup( true );
828  mbAutoPopup = true;
829  }
830  bDone = true;
831  }
832  else if ( nCode == KEY_ESCAPE || ( nCode == KEY_F6 && rKEvent.GetKeyCode().IsMod1() ) )
833  {
834  if( m_pActivePopup )
835  {
836  // hide the menu and remove the focus...
837  mbAutoPopup = false;
838  KillActivePopup();
839  }
840 
842 
843  if( nCode == KEY_F6 && rKEvent.GetKeyCode().IsMod1() )
844  {
845  // put focus into document
847  }
848 
849  bDone = true;
850  }
851  }
852 
853  bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel;
854 
855  if ( !bDone && ( bFromMenu || rKEvent.GetKeyCode().IsMod2() ) )
856  {
857  sal_Unicode nCharCode = rKEvent.GetCharCode();
858  if ( nCharCode )
859  {
860  size_t nEntry, nDuplicates;
861  MenuItemData* pData = m_pMenu->GetItemList()->SearchItem( nCharCode, rKEvent.GetKeyCode(), nEntry, nDuplicates, m_nHighlightedItem );
862  if ( pData && (nEntry != ITEMPOS_INVALID) )
863  {
864  mbAutoPopup = true;
865  ChangeHighlightItem( nEntry, true );
866  bDone = true;
867  }
868  }
869  }
870 
871  const bool bShowAccels = nCode != KEY_ESCAPE;
872  if (GetMBWMenuKey() != bShowAccels)
873  {
874  SetMBWMenuKey(bShowAccels);
875  SetMBWHideAccel(!bShowAccels);
876  if (autoacc)
878  }
879 
880  return bDone;
881 }
882 
884 {
885  if (!m_pMenu)
886  return;
887 
888  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
889 
890  Size aOutputSize = GetOutputSizePixel();
891 
892  // no VCL paint if native menus
894  {
896  return;
897  }
898 
899  // Make sure that all actual rendering happens in one go to avoid flicker.
900  vcl::BufferDevice pBuffer(this, rRenderContext);
901 
903  {
904  MenubarValue aMenubarValue;
906 
907  if (!rStyleSettings.GetPersonaHeader().IsEmpty())
908  Erase(*pBuffer);
909  else
910  {
911  tools::Rectangle aCtrlRegion( Point(), aOutputSize );
912 
914  ControlState::ENABLED, aMenubarValue, OUString());
915  }
916 
917  ImplAddNWFSeparator(*pBuffer, aOutputSize, aMenubarValue);
918  }
919 
920  // shrink the area of the buttons
921  aOutputSize.AdjustWidth( -(m_aCloseBtn->GetSizePixel().Width()) );
922 
923  pBuffer->SetFillColor(rStyleSettings.GetMenuColor());
924  m_pMenu->ImplPaint(*pBuffer, aOutputSize, 0);
925 
929  HighlightItem(*pBuffer, m_nRolloveredItem);
930 
931  // in high contrast mode draw a separating line on the lower edge
933  rStyleSettings.GetHighContrastMode())
934  {
936  pBuffer->SetLineColor(COL_WHITE);
937  pBuffer->SetMapMode(MapMode(MapUnit::MapPixel));
938  Size aSize = GetSizePixel();
939  pBuffer->DrawLine(Point(0, aSize.Height() - 1),
940  Point(aSize.Width() - 1, aSize.Height() - 1));
941  pBuffer->Pop();
942  }
943 }
944 
946 {
947  Size aOutSz = GetOutputSizePixel();
948  tools::Long n = aOutSz.Height()-4;
949  tools::Long nX = aOutSz.Width()-3;
950  tools::Long nY = 2;
951 
952  if ( m_aCloseBtn->IsVisible() )
953  {
954  m_aCloseBtn->Hide();
956  Size aTbxSize( m_aCloseBtn->CalcWindowSizePixel() );
957  nX -= aTbxSize.Width();
958  tools::Long nTbxY = (aOutSz.Height() - aTbxSize.Height())/2;
959  m_aCloseBtn->setPosSizePixel(nX, nTbxY, aTbxSize.Width(), aTbxSize.Height());
960  nX -= 3;
961  m_aCloseBtn->Show();
962  }
963  if ( m_aFloatBtn->IsVisible() )
964  {
965  nX -= n;
966  m_aFloatBtn->setPosSizePixel( nX, nY, n, n );
967  }
968  if ( m_aHideBtn->IsVisible() )
969  {
970  nX -= n;
971  m_aHideBtn->setPosSizePixel( nX, nY, n, n );
972  }
973 
976 
977  Invalidate();
978 }
979 
980 sal_uInt16 MenuBarWindow::ImplFindEntry( const Point& rMousePos ) const
981 {
982  if( m_pMenu )
983  {
984  tools::Long nX = 0;
985  size_t nCount = m_pMenu->pItemList->size();
986  for ( size_t n = 0; n < nCount; n++ )
987  {
988  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
989  if ( m_pMenu->ImplIsVisible( n ) )
990  {
991  nX += pData->aSz.Width();
992  if ( nX > rMousePos.X() )
993  return static_cast<sal_uInt16>(n);
994  }
995  }
996  }
997  return ITEMPOS_INVALID;
998 }
999 
1001 {
1002  sal_uInt16 nId = m_nHighlightedItem;
1003  if ( rHEvt.GetMode() & HelpEventMode::CONTEXT )
1005 
1007  if( !ImplHandleHelpEvent( this, m_pMenu, nId, rHEvt, aHighlightRect ) )
1008  Window::RequestHelp( rHEvt );
1009 }
1010 
1012 {
1013  Window::StateChanged( nType );
1014 
1015  if (nType == StateChangedType::ControlForeground ||
1017  {
1018  ApplySettings(*this);
1019  Invalidate();
1020  }
1021  else if (nType == StateChangedType::Enable)
1022  {
1023  Invalidate();
1024  }
1025  else if(m_pMenu)
1026  {
1028  }
1029 }
1030 
1032 {
1033  if (!m_pMenu)
1034  return;
1035 
1036  ApplySettings(*this);
1037 
1038  // if the font was changed.
1039  tools::Long nHeight = m_pMenu->ImplCalcSize(this).Height();
1040 
1041  // depending on the native implementation or the displayable flag
1042  // the menubar windows is suppressed (ie, height=0)
1043  if (!static_cast<MenuBar*>(m_pMenu.get())->IsDisplayable() ||
1045  {
1046  nHeight = 0;
1047  }
1048  setPosSizePixel(0, 0, 0, nHeight, PosSizeFlags::Height);
1049  GetParent()->Resize();
1050  Invalidate();
1051  Resize();
1052 
1054 }
1055 
1057 {
1058  Window::ApplySettings(rRenderContext);
1059  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1060 
1061  SetPointFont(rRenderContext, rStyleSettings.GetMenuFont());
1062 
1064  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1065  if (pNativeMenu)
1066  pNativeMenu->ApplyPersona();
1067  if (!rPersonaBitmap.IsEmpty())
1068  {
1069  Wallpaper aWallpaper(rPersonaBitmap);
1070  aWallpaper.SetStyle(WallpaperStyle::TopRight);
1071  aWallpaper.SetColor(Application::GetSettings().GetStyleSettings().GetWorkspaceColor());
1072 
1073  rRenderContext.SetBackground(aWallpaper);
1074  SetPaintTransparent(false);
1076  }
1078  {
1079  rRenderContext.SetBackground(); // background will be drawn by NWF
1080  }
1081  else
1082  {
1083  Wallpaper aWallpaper;
1085  rRenderContext.SetBackground(aWallpaper);
1086  SetPaintTransparent(false);
1088  }
1089 
1090  rRenderContext.SetTextColor(rStyleSettings.GetMenuBarTextColor());
1091  rRenderContext.SetTextFillColor();
1092  rRenderContext.SetLineColor();
1093 }
1094 
1096 {
1099  return;
1100 
1101  AllSettings aSettings(GetSettings());
1102  ImplGetFrame()->UpdateSettings(aSettings); // to update persona
1103  StyleSettings aStyle(aSettings.GetStyleSettings());
1104  Color aHighlightTextColor = ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor;
1105  if (aHighlightTextColor != COL_TRANSPARENT)
1106  {
1107  aStyle.SetMenuHighlightTextColor(aHighlightTextColor);
1108  }
1109  aSettings.SetStyleSettings(aStyle);
1110  OutputDevice::SetSettings(aSettings);
1111 }
1112 
1114 {
1115  Window::DataChanged( rDCEvt );
1116 
1117  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1119  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1120  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1121  {
1122  ApplySettings(*this);
1124  LayoutChanged();
1125  }
1126 }
1127 
1129 {
1130  if ( !HasChildPathFocus( true ) )
1131  ChangeHighlightItem( ITEMPOS_INVALID, false, false );
1132 }
1133 
1135 {
1136  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1137  if (pNativeMenu && pNativeMenu->TakeFocus())
1138  return;
1139 
1141  {
1142  mbAutoPopup = false; // do not open menu when activated by focus handling like taskpane cycling
1143  ChangeHighlightItem( 0, false );
1144  }
1145 }
1146 
1147 css::uno::Reference<css::accessibility::XAccessible> MenuBarWindow::CreateAccessible()
1148 {
1149  css::uno::Reference<css::accessibility::XAccessible> xAcc;
1150 
1151  if (m_pMenu)
1152  xAcc = m_pMenu->GetAccessible();
1153 
1154  return xAcc;
1155 }
1156 
1157 sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link<MenuBar::MenuBarButtonCallbackArg&,bool>& i_rLink, const OUString& i_rToolTip )
1158 {
1159  // find first free button id
1160  sal_uInt16 nId = IID_DOCUMENTCLOSE;
1161  std::map< sal_uInt16, AddButtonEntry >::const_iterator it;
1162  do
1163  {
1164  nId++;
1165  it = m_aAddButtons.find( nId );
1166  } while( it != m_aAddButtons.end() && nId < 128 );
1167  SAL_WARN_IF( nId >= 128, "vcl", "too many addbuttons in menubar" );
1168  AddButtonEntry& rNewEntry = m_aAddButtons[nId];
1169  rNewEntry.m_aSelectLink = i_rLink;
1170  m_aCloseBtn->InsertItem(nId, i_rImage, ToolBoxItemBits::NONE, 0);
1173  LayoutChanged();
1174 
1175  if( m_pMenu->mpSalMenu )
1176  m_pMenu->mpSalMenu->AddMenuBarButton( SalMenuButtonItem( nId, i_rImage, i_rToolTip ) );
1177 
1178  return nId;
1179 }
1180 
1182 {
1183  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( nId );
1184  if( it != m_aAddButtons.end() )
1185  it->second.m_aHighlightLink = rLink;
1186 }
1187 
1189 {
1190  tools::Rectangle aRect;
1191  if( m_aAddButtons.find( nId ) != m_aAddButtons.end() )
1192  {
1193  if( m_pMenu->mpSalMenu )
1194  {
1195  aRect = m_pMenu->mpSalMenu->GetMenuBarButtonRectPixel( nId, ImplGetWindowImpl()->mpFrame );
1196  if( aRect == tools::Rectangle( Point( -1, -1 ), Size( 1, 1 ) ) )
1197  {
1198  // system menu button is somewhere but location cannot be determined
1199  return tools::Rectangle();
1200  }
1201  }
1202 
1203  if( aRect.IsEmpty() )
1204  {
1205  aRect = m_aCloseBtn->GetItemRect(nId);
1207  aRect.Move( aOffset.X(), aOffset.Y() );
1208  }
1209  }
1210  return aRect;
1211 }
1212 
1214 {
1215  ToolBox::ImplToolItems::size_type nPos = m_aCloseBtn->GetItemPos(nId);
1216  m_aCloseBtn->RemoveItem(nPos);
1217  m_aAddButtons.erase( nId );
1219  LayoutChanged();
1220 
1221  if( m_pMenu->mpSalMenu )
1222  m_pMenu->mpSalMenu->RemoveMenuBarButton( nId );
1223 }
1224 
1225 bool MenuBarWindow::HandleMenuButtonEvent( sal_uInt16 i_nButtonId )
1226 {
1227  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( i_nButtonId );
1228  if( it != m_aAddButtons.end() )
1229  {
1231  aArg.nId = it->first;
1232  aArg.bHighlight = true;
1233  return it->second.m_aSelectLink.Call( aArg );
1234  }
1235  return false;
1236 }
1237 
1239 {
1240  /* #i83908# do not use the menubar if it is native or invisible
1241  this relies on MenuBar::ImplCreate setting the height of the menubar
1242  to 0 in this case
1243  */
1244  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1245  if (pNativeMenu && pNativeMenu->VisibleMenuBar())
1246  return pNativeMenu->CanGetFocus();
1247  return GetSizePixel().Height() > 0;
1248 }
1249 
1250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void calcMinSize()
VclPtr< Menu > pSubMenu
Size GetSizePixel() const
Definition: Image.cxx:86
tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId)
void Deactivate()
Definition: menu.cxx:276
PopupMenu * GetPopupMenu(sal_uInt16 nItemId) const
Definition: menu.cxx:761
tools::Long lastSize
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
Definition: toolbox2.cxx:1340
virtual void DrawMenuBar()=0
void SetAlpha(sal_uInt8 nAlpha)
VclPtr< vcl::Window > mpFocusWin
Definition: svdata.hxx:248
bool mbNoSaveFocus
Definition: svdata.hxx:264
css::uno::Reference< css::accessibility::XAccessible > GetAccessible()
Definition: menu.cxx:1289
SAL_DLLPRIVATE void ImplKillLayoutData() const
Definition: menu.cxx:2214
const Color & GetMenuBarRolloverColor() const
const Color & GetMenuBarTextColor() const
Image GetItemImage(sal_uInt16 nItemId) const
Definition: toolbox2.cxx:1031
const vcl::Font & GetMenuFont() const
std::unique_ptr< ContentProperties > pData
SAL_DLLPRIVATE bool ImplCurrentlyHiddenOnGUI(sal_uInt16 nPos) const
Definition: menu.cxx:1180
bool HasCloseButton() const
Definition: menu.hxx:448
MenuItemData * SearchItem(sal_Unicode cSelectChar, vcl::KeyCode aKeyCode, size_t &rPos, size_t &nDuplicates, size_t nCurrentPos) const
vcl::KeyCode aAccelKey
VclPtr< DecoToolBox > m_aCloseBtn
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
Definition: button.hxx:32
void SetStyleSettings(const StyleSettings &rSet)
void SetHelpId(sal_uInt16 nItemId, const OString &rHelpId)
Definition: menu.cxx:1131
void PopupClosed(Menu const *pMenu)
Point BottomLeft() const
bool mbNoDeactivate
Definition: svdata.hxx:263
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
OUString aHelpText
sal_uIntPtr sal_uLong
long Long
bool HasFloatButton() const
Definition: menu.hxx:449
void disposeAndClear()
Definition: vclptr.hxx:200
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:724
void SetHeight(tools::Long nHeight)
BitmapEx const & GetPersonaHeader() const
ImplSVNWFData maNWFData
Definition: svdata.hxx:397
sal_Int64 n
virtual Size GetSizePixel() const
Definition: window.cxx:2400
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:901
void SetColor(const Color &rColor)
Definition: wall.cxx:188
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:563
static bool ImplHandleHelpEvent(vcl::Window *pMenuWindow, Menu const *pMenu, sal_uInt16 nHighlightedItem, const HelpEvent &rHEvt, const tools::Rectangle &rHighlightRect)
Show the appropriate help tooltip.
Definition: menuwindow.cxx:40
Color GetSeparatorColor() const
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
SAL_DLLPRIVATE void ImplCallEventListeners(VclEventId nEvent, sal_uInt16 nPos)
Definition: menu.cxx:372
void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus=true, bool bDefaultToDocument=true)
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Post a user event to the default window.
Definition: svapp.cxx:1016
void ShowButtons(bool bClose, bool bFloat, bool bHide)
void SetTextFillColor()
Definition: text.cxx:697
sal_uInt16 GetCode() const
Definition: keycod.hxx:51
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
void ShowItem(sal_uInt16 nItemId, bool bVisible=true)
Shows or hides items.
Definition: toolbox2.cxx:1270
DataChangedEventType GetType() const
Definition: event.hxx:356
void IntersectClipRegion(const tools::Rectangle &rRect)
The invalidated area is updated immediately.
virtual void SetSettings(const AllSettings &rSettings)
Definition: outdev.cxx:210
constexpr sal_uInt16 KEY_F6
Definition: keycodes.hxx:88
VclPtr< Menu > m_pMenu
constexpr sal_uInt16 KEY_MENU
Definition: keycodes.hxx:147
const Color & GetMenuHighlightColor() const
void SetHelpText(sal_uInt16 nItemId, const OUString &rString)
Definition: menu.cxx:1077
void SetType(WindowType nType)
Definition: window2.cxx:968
void KillActivePopup()
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1226
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3006
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
void SetMapMode()
Definition: map.cxx:546
HelpEventMode GetMode() const
Definition: event.hxx:205
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
bool CanGetFocus() const
SAL_DLLPRIVATE Size ImplCalcSize(vcl::Window *pWin)
Definition: menu.cxx:1413
constexpr sal_uInt16 KEY_END
Definition: keycodes.hxx:115
bool IsEmpty() const
sal_uInt16 m_nRolloveredItem
StateChangedType
Definition: window.hxx:317
WinBits const WB_NOPOINTERFOCUS
bool GetMBWHideAccel() const
Size CalcWindowSizePixel()
Definition: toolbox.hxx:520
A construction helper for ScopedVclPtr.
Definition: vclptr.hxx:407
sal_uInt16 sal_Unicode
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
void SetBackground()
OUString aCommandStr
void SetSymbol(SymbolType eSymbol)
Definition: button.cxx:1513
Buffers drawing on a vcl::RenderContext using a VirtualDevice.
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
bool IsEnterWindow() const
Definition: event.hxx:135
Toolbox that holds the close button (right hand side of the menubar).
virtual bool TakeFocus()
Definition: salmenu.hxx:85
int nCount
ImplToolItems::size_type GetItemPos(sal_uInt16 nItemId) const
Definition: toolbox2.cxx:714
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
Definition: menu.cxx:1040
void Hide()
Definition: window.hxx:948
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All) override
Definition: dockwin.cxx:824
AllSettingsFlags GetFlags() const
Definition: event.hxx:357
void SetImages(tools::Long nMaxHeight, bool bForce=false)
bool GetHighContrastMode() const
void SetMBWMenuKey(bool val)
Link< MenuBar::MenuBarButtonCallbackArg &, bool > m_aSelectLink
virtual void InsertItem(const OUString &rCommand, const css::uno::Reference< css::frame::XFrame > &rFrame, ToolBoxItemBits nBits, const Size &rRequestedSize, ImplToolItems::size_type nPos=APPEND)
Insert a command (like '.uno:Save').
Definition: toolbox2.cxx:432
SAL_DLLPRIVATE SalMenu * ImplGetSalMenu()
Definition: menu.hxx:187
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:88
sal_uInt16 nCode
void GetFocus() override
bool mbAutoAccel
Definition: svdata.hxx:333
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
const Color & GetMenuColor() const
tools::Rectangle GetItemRect(sal_uInt16 nItemId)
Definition: toolbox2.cxx:830
void SetPopupMenu(sal_uInt16 nItemId, PopupMenu *pMenu)
Definition: menu.cxx:724
VclPtr< PopupMenu > mpParentPopup
Class that implements the actual window of the menu bar.
OString aHelpId
constexpr sal_uInt16 KEY_DOWN
Definition: keycodes.hxx:110
void SetMBWHideAccel(bool val)
Point BottomRight() const
bool IsEmpty() const
Definition: BitmapEx.cxx:198
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:73
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
void SetLineColor()
void clear()
Definition: vclptr.hxx:190
void RemoveItem(ImplToolItems::size_type nPos)
Definition: toolbox2.cxx:529
sal_uInt16 nId
bool IsLeaveWindow() const
Definition: event.hxx:137
std::unique_ptr< MenuItemList > pItemList
Definition: menu.hxx:132
int i
bool bInCallback
In Activate/Deactivate.
Definition: menu.hxx:158
bool IsSystemWindow() const
Definition: window2.cxx:997
void SetMenu(MenuBar *pMenu)
virtual bool CanGetFocus() const
Definition: salmenu.hxx:84
void HighlightItem(vcl::RenderContext &rRenderContext, sal_uInt16 nPos)
void DataChanged(const DataChangedEvent &rDCEvt) override
constexpr sal_uInt16 KEY_HOME
Definition: keycodes.hxx:114
void LoseFocus() override
void SetStyle(WallpaperStyle eStyle)
Definition: wall.cxx:202
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId)
sal_uInt16 GetItemId(sal_uInt16 nPos) const
Definition: menu.cxx:634
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1164
MenuItemType eType
virtual void ApplyPersona()
Definition: salvtables.cxx:191
void SetFillColor()
tools::Long Width() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
void SetTextColor(const Color &rColor)
Definition: text.cxx:662
void AddPopupModeWindow(vcl::Window *pWindow)
Definition: floatwin.cxx:955
virtual void RequestHelp(const HelpEvent &rHEvt) override
WinBits const WB_SMALLSTYLE
WinBits const WB_RECTSTYLE
virtual void Resize()
Definition: window.cxx:1834
void GrabFocusToDocument()
Definition: window.cxx:2988
std::map< sal_uInt16, AddButtonEntry > m_aAddButtons
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
virtual void UpdateSettings(AllSettings &rSettings)=0
const AllSettings & GetSettings() const
Definition: outdev.hxx:418
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1026
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
SAL_DLLPRIVATE bool ImplIsVisible(sal_uInt16 nPos) const
Definition: menu.cxx:1194
MenuItemList * GetItemList() const
Definition: menu.hxx:351
void DataChanged(const DataChangedEvent &rDCEvt) override
void SetSelectHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox.hxx:454
void GrabFocus()
Definition: window.cxx:2978
vcl::Window * GetParent() const
Definition: window2.cxx:1097
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
SAL_DLLPRIVATE vcl::Window * ImplGetWindow() const
Definition: menu.hxx:214
void ImplInitStyleSettings()
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
VclPtr< PopupMenu > m_pActivePopup
virtual void SetFrame(const SalFrame *pFrame)=0
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1039
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
void SetPointFont(vcl::RenderContext &rRenderContext, const vcl::Font &rFont)
Definition: window.cxx:2172
void ImplCreatePopup(bool bPreSelectFirst)
MenuBarWindow(vcl::Window *pParent)
OUString aHelpCommandStr
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2664
bool IsItemVisible(sal_uInt16 nItemId) const
Definition: toolbox2.cxx:1296
void RemoveMenuBarButton(sal_uInt16 nId)
void AddEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:300
void InsertItem(sal_uInt16 nItemId, const OUString &rStr, MenuItemBits nItemBits=MenuItemBits::NONE, const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
Definition: menu.cxx:421
SalFrame * ImplGetFrame() const
Definition: window2.cxx:848
Size GetSizePixel() const override
Definition: dockwin.cxx:866
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:54
MenuItemData * GetDataFromPos(size_t nPos) const
Definition: menu.hxx:121
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
void Erase()
Definition: wallpaper.cxx:103
void SetHelpCommand(sal_uInt16 nItemId, const OUString &rString)
Definition: menu.cxx:1059
bool IsShift() const
Definition: keycod.hxx:56
OString sIdent
VclPtr< PushButton > m_aFloatBtn
sal_uInt16 ImplFindEntry(const Point &rMousePos) const
void StateChanged(StateChangedType nType) override
tools::Rectangle ImplGetItemRect(sal_uInt16 nPos)
bool IsSynthetic() const
Definition: event.hxx:139
void Activate()
Definition: menu.cxx:245
#define SAL_WARN_IF(condition, area, stream)
constexpr sal_uInt16 KEY_ESCAPE
Definition: keycodes.hxx:120
sal_uInt16 AddMenuBarButton(const Image &, const Link< MenuBar::MenuBarButtonCallbackArg &, bool > &, const OUString &)
Add an arbitrary button to the menubar that will appear next to the close button. ...
void SetItemImage(sal_uInt16 nItemId, const Image &rImage)
Definition: toolbox2.cxx:940
bool IsVisible() const
Definition: window2.cxx:1102
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
VclPtr< vcl::Window > m_xSaveFocusId
bool HandleKeyEvent(const KeyEvent &rKeyEvent)
sal_Unicode GetCharCode() const
Definition: event.hxx:53
const Size & getMinSize() const
sal_uInt16 GetItemCount() const
Definition: menu.cxx:588
tools::Long AdjustWidth(tools::Long n)
Definition: image.hxx:39
bool IsMod1() const
Definition: keycod.hxx:58
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
virtual void KeyInput(const KeyEvent &rKEvent) override
MenuItemData * GetData(sal_uInt16 nSVId, size_t &rPos) const
virtual void Resize() override
DecoToolBox(vcl::Window *pParent)
void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link< MenuBar::MenuBarButtonCallbackArg &, bool > &)
tools::Long Height() const
virtual void MouseMove(const MouseEvent &rMEvt) override
void SetAccelKey(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: menu.cxx:771
const Point & GetPosPixel() const
Definition: event.hxx:120
SAL_DLLPRIVATE MenuFloatingWindow * ImplGetFloatingWindow() const
Definition: menu.cxx:2712
BitmapEx GetBitmapEx() const
Definition: Image.cxx:94
bool HasHideButton() const
Definition: menu.hxx:450
std::unique_ptr< SalMenu > mpSalMenu
Definition: menu.hxx:163
WindowType GetType() const
Definition: window2.cxx:974
sal_uInt16 GetItemId(ImplToolItems::size_type nPos) const
Definition: toolbox2.cxx:738
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
SAL_DLLPRIVATE void ImplCallHighlight(sal_uInt16 nHighlightItem)
Definition: menu.cxx:2110
void RemoveEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:305
OUString aText
OUString VclResId(const char *pId)
Definition: svdata.cxx:257
TaskPaneList * GetTaskPaneList()
Definition: syswin.cxx:244
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2801
SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext &rRenderContext, Size const &rSize, sal_uInt16 nBorder, tools::Long nOffY=0, MenuItemData const *pThisDataOnly=nullptr, bool bHighlighted=false, bool bLayout=false, bool bRollover=false) const
Definition: menu.cxx:1717
VclPtr< PushButton > m_aHideBtn
SAL_DLLPRIVATE ImplFrameData * ImplGetFrameData()
Definition: window2.cxx:843
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:59
SAL_DLLPRIVATE sal_uInt16 ImplExecute(const VclPtr< vcl::Window > &pW, const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags, Menu *pSFrom, bool bPreSelectFirst)
Definition: menu.cxx:2836
virtual ~MenuBarWindow() override
sal_Int32 nState
::Color maMenuBarHighlightTextColor
Definition: svdata.hxx:314
bool isDisposed() const
ImplToolItems::size_type GetItemCount() const
Definition: toolbox2.cxx:704
virtual bool VisibleMenuBar()=0
virtual void SetMenu(SalMenu *pSalMenu)=0
sal_uInt16 nPos
bool GetMBWMenuKey() const
sal_uInt16 m_nHighlightedItem
ImplSVWinData * mpWinData
Definition: svdata.hxx:394
bool IsMod2() const
Definition: keycod.hxx:60
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2186
Size const & MinCloseButtonSize()
bool HandleKeyEvent(const KeyEvent &rKEvent, bool bFromMenu=true)
MenuItemBits nBits