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  }
77 
78  aTbx.disposeAndClear();
79 }
80 
81 void DecoToolBox::SetImages( long nMaxHeight, bool bForce )
82 {
83  long border = getMinSize().Height() - maImage.GetSizePixel().Height();
84 
85  if( !nMaxHeight && lastSize != -1 )
86  nMaxHeight = lastSize + border; // don't change anything if called with 0
87 
88  if( nMaxHeight < getMinSize().Height() )
89  nMaxHeight = getMinSize().Height();
90 
91  if( (lastSize == nMaxHeight - border) && !bForce )
92  return;
93 
94  lastSize = nMaxHeight - border;
95 
96  Color aEraseColor( 255, 255, 255, 255 );
97  BitmapEx aBmpExDst( maImage.GetBitmapEx() );
98  BitmapEx aBmpExSrc( aBmpExDst );
99 
100  aEraseColor.SetTransparency( 255 );
101  aBmpExDst.Erase( aEraseColor );
102  aBmpExDst.Scale( Size( lastSize, lastSize ) );
103 
104  tools::Rectangle aSrcRect( Point(0,0), maImage.GetSizePixel() );
106  (lastSize - maImage.GetSizePixel().Height())/2 ),
107  maImage.GetSizePixel() );
108 
109  aBmpExDst.CopyPixel( aDestRect, aSrcRect, &aBmpExSrc );
110  SetItemImage( IID_DOCUMENTCLOSE, Image( aBmpExDst ) );
111 
112 }
113 
115  Window( pParent, 0 ),
116  m_aCloseBtn(VclPtr<DecoToolBox>::Create(this)),
119 {
120  SetType(WindowType::MENUBARWINDOW);
121  m_pMenu = nullptr;
122  m_pActivePopup = nullptr;
125  mbAutoPopup = true;
126  m_bIgnoreFirstMove = true;
127  SetMBWHideAccel(true);
128  SetMBWMenuKey(false);
129 
130  m_aCloseBtn->maImage = Image(StockImage::Yes, SV_RESID_BITMAP_CLOSEDOC);
131 
136 
138  m_aCloseBtn->SetSelectHdl(LINK(this, MenuBarWindow, CloseHdl));
139  m_aCloseBtn->AddEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
140  m_aCloseBtn->SetQuickHelpText(IID_DOCUMENTCLOSE, VclResId(SV_HELPTEXT_CLOSEDOCUMENT));
141 
143  m_aFloatBtn->SetQuickHelpText(VclResId(SV_HELPTEXT_RESTORE));
144 
146  m_aHideBtn->SetQuickHelpText(VclResId(SV_HELPTEXT_MINIMIZE));
147 
149 
150  AddEventListener(LINK(this, MenuBarWindow, ShowHideListener));
151 }
152 
154 {
155  disposeOnce();
156 }
157 
159 {
160  m_aCloseBtn->RemoveEventListener(LINK(this, MenuBarWindow, ToolboxEventHdl));
161  RemoveEventListener(LINK(this, MenuBarWindow, ShowHideListener));
162 
167  m_pMenu.clear();
170 
171  Window::dispose();
172 }
173 
175 {
176  m_pMenu = pMen;
177  KillActivePopup();
179  if (pMen)
180  {
182  m_aCloseBtn->Show(pMen->HasCloseButton() || !m_aAddButtons.empty());
183  m_aFloatBtn->Show(pMen->HasFloatButton());
184  m_aHideBtn->Show(pMen->HasHideButton());
185  }
186  Invalidate();
187 
188  // show and connect native menubar
189  if( m_pMenu && m_pMenu->ImplGetSalMenu() )
190  {
193 
195  }
196 }
197 
198 void MenuBarWindow::SetHeight(long nHeight)
199 {
200  setPosSizePixel(0, 0, 0, nHeight, PosSizeFlags::Height);
201 }
202 
203 void MenuBarWindow::ShowButtons( bool bClose, bool bFloat, bool bHide )
204 {
206  m_aCloseBtn->Show(bClose || !m_aAddButtons.empty());
207  if (m_pMenu->mpSalMenu)
208  m_pMenu->mpSalMenu->ShowCloseButton(bClose);
209  m_aFloatBtn->Show( bFloat );
210  m_aHideBtn->Show( bHide );
211  Resize();
212 }
213 
215 {
216  return m_aCloseBtn->getMinSize();
217 }
218 
220 {
221  if( ! m_pMenu )
222  return;
223 
224  if( m_aCloseBtn->GetCurItemId() == IID_DOCUMENTCLOSE )
225  {
226  // #i106052# call close hdl asynchronously to ease handler implementation
227  // this avoids still being in the handler while the DecoToolBox already
228  // gets destroyed
229  Application::PostUserEvent(static_cast<MenuBar*>(m_pMenu.get())->GetCloseButtonClickHdl());
230  }
231  else
232  {
233  std::map<sal_uInt16,AddButtonEntry>::iterator it = m_aAddButtons.find(m_aCloseBtn->GetCurItemId());
234  if( it != m_aAddButtons.end() )
235  {
237  aArg.nId = it->first;
238  aArg.bHighlight = (m_aCloseBtn->GetHighlightItemId() == it->first);
239  it->second.m_aSelectLink.Call( aArg );
240  }
241  }
242 }
243 
244 IMPL_LINK( MenuBarWindow, ToolboxEventHdl, VclWindowEvent&, rEvent, void )
245 {
246  if( ! m_pMenu )
247  return;
248 
250  aArg.nId = 0xffff;
251  aArg.bHighlight = (rEvent.GetId() == VclEventId::ToolboxHighlight);
252  if( rEvent.GetId() == VclEventId::ToolboxHighlight )
253  aArg.nId = m_aCloseBtn->GetHighlightItemId();
254  else if( rEvent.GetId() == VclEventId::ToolboxHighlightOff )
255  {
256  auto nPos = static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rEvent.GetData()));
257  aArg.nId = m_aCloseBtn->GetItemId(nPos);
258  }
259  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( aArg.nId );
260  if( it != m_aAddButtons.end() )
261  {
262  it->second.m_aHighlightLink.Call( aArg );
263  }
264 }
265 
266 IMPL_LINK( MenuBarWindow, ShowHideListener, VclWindowEvent&, rEvent, void )
267 {
268  if( ! m_pMenu )
269  return;
270 
271  if( rEvent.GetId() == VclEventId::WindowShow )
272  m_pMenu->ImplCallEventListeners( VclEventId::MenuShow, ITEMPOS_INVALID );
273  else if( rEvent.GetId() == VclEventId::WindowHide )
274  m_pMenu->ImplCallEventListeners( VclEventId::MenuHide, ITEMPOS_INVALID );
275 }
276 
277 void MenuBarWindow::ImplCreatePopup( bool bPreSelectFirst )
278 {
280  if ( pItemData )
281  {
282  m_bIgnoreFirstMove = true;
283  if ( m_pActivePopup && ( m_pActivePopup != pItemData->pSubMenu ) )
284  {
285  KillActivePopup();
286  }
287  if ( pItemData->bEnabled && pItemData->pSubMenu && ( m_nHighlightedItem != ITEMPOS_INVALID ) &&
288  ( pItemData->pSubMenu != m_pActivePopup ) )
289  {
290  m_pActivePopup = static_cast<PopupMenu*>(pItemData->pSubMenu.get());
291  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  }
346 }
347 
349 {
350  if ( m_pActivePopup )
351  {
352  if( m_pActivePopup->pWindow )
353  if( static_cast<FloatingWindow *>(m_pActivePopup->pWindow.get())->IsInCleanUp() )
354  return; // kill it later
355 
356  if ( m_pActivePopup->bInCallback )
357  m_pActivePopup->bCanceled = true;
358 
359  m_pActivePopup->bInCallback = true;
361  m_pActivePopup->bInCallback = false;
362  // check for pActivePopup, if stopped by deactivate...
363  if ( m_pActivePopup->ImplGetWindow() )
364  {
365  if (mpParentPopup)
366  {
367  for (sal_uInt16 i = 0; i < mpParentPopup->GetItemCount(); ++i)
368  {
369  sal_uInt16 nId = mpParentPopup->GetItemId(i);
370  MenuItemData* pParentItemData = mpParentPopup->GetItemList()->GetData(nId);
371  assert(pParentItemData);
372  pParentItemData->pSubMenu = nullptr;
373  }
374  }
377  m_pActivePopup->pWindow->SetParentToDefaultWindow();
378  m_pActivePopup->pWindow.disposeAndClear();
379  }
380  m_pActivePopup = nullptr;
381  }
382 }
383 
384 void MenuBarWindow::PopupClosed( Menu const * pPopup )
385 {
386  if ( pPopup == m_pActivePopup )
387  {
388  KillActivePopup();
389  ChangeHighlightItem( ITEMPOS_INVALID, false, ImplGetFrameWindow()->ImplGetFrameData()->mbHasFocus, false );
390  }
391 }
392 
394 {
395  mbAutoPopup = true;
396  SetMBWMenuKey(false);
397  sal_uInt16 nEntry = ImplFindEntry( rMEvt.GetPosPixel() );
398  if ( ( nEntry != ITEMPOS_INVALID ) && !m_pActivePopup )
399  {
400  ChangeHighlightItem( nEntry, false );
401  }
402  else
403  {
404  KillActivePopup();
406  }
407 }
408 
410 {
411 }
412 
414 {
415  if ( rMEvt.IsSynthetic() || rMEvt.IsEnterWindow() )
416  return;
417 
418  if ( rMEvt.IsLeaveWindow() )
419  {
421  {
422  // there is a spurious MouseMove generated after a menu is launched from the keyboard, hence this...
424  {
425  bool hide = GetMBWHideAccel();
426  SetMBWHideAccel(true);
427  Invalidate(); //HighlightItem( nRolloveredItem, false );
428  SetMBWHideAccel(hide);
429  }
430  else
431  Invalidate(); //HighlightItem( nRolloveredItem, false );
432  }
433 
435  return;
436  }
437 
438  sal_uInt16 nEntry = ImplFindEntry( rMEvt.GetPosPixel() );
440  {
441  if ( m_nRolloveredItem != nEntry )
442  {
444  Invalidate(); //HighlightItem( nRolloveredItem, false );
445 
446  m_nRolloveredItem = nEntry;
447  Invalidate(); //HighlightItem( nRolloveredItem, true );
448  }
449  return;
450  }
451  m_nRolloveredItem = nEntry;
452 
453  if( m_bIgnoreFirstMove )
454  {
455  m_bIgnoreFirstMove = false;
456  return;
457  }
458 
459  if ( ( nEntry != ITEMPOS_INVALID )
460  && ( nEntry != m_nHighlightedItem ) )
461  ChangeHighlightItem( nEntry, false );
462 }
463 
464 void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool bAllowRestoreFocus, bool bDefaultToDocument)
465 {
466  if( ! m_pMenu )
467  return;
468 
469  // always hide accelerators when updating the menu bar...
470  SetMBWHideAccel(true);
471 
472  // #57934# close active popup if applicable, as TH's background storage works.
473  MenuItemData* pNextData = m_pMenu->pItemList->GetDataFromPos( n );
474  if ( m_pActivePopup && m_pActivePopup->ImplGetWindow() && ( !pNextData || ( m_pActivePopup != pNextData->pSubMenu ) ) )
475  KillActivePopup(); // pActivePopup when applicable without pWin, if Rescheduled in Activate()
476 
477  // activate menubar only ones per cycle...
478  bool bJustActivated = false;
479  if ( ( m_nHighlightedItem == ITEMPOS_INVALID ) && ( n != ITEMPOS_INVALID ) )
480  {
482  // #105406# avoid saving the focus when we already have the focus
483  bool bNoSaveFocus = (this == ImplGetSVData()->maWinData.mpFocusWin.get() );
484 
485  if( m_xSaveFocusId != nullptr )
486  {
488  {
489  m_xSaveFocusId = nullptr;
490  if( !bNoSaveFocus )
491  m_xSaveFocusId = Window::SaveFocus(); // only save focus when initially activated
492  }
493  else {
494  ; // do nothing: we 're activated again from taskpanelist, focus was already saved
495  }
496  }
497  else
498  {
499  if( !bNoSaveFocus )
500  m_xSaveFocusId = Window::SaveFocus(); // only save focus when initially activated
501  }
502  m_pMenu->bInCallback = true; // set here if Activate overridden
503  m_pMenu->Activate();
504  m_pMenu->bInCallback = false;
505  bJustActivated = true;
506  }
507  else if ( ( m_nHighlightedItem != ITEMPOS_INVALID ) && ( n == ITEMPOS_INVALID ) )
508  {
509  m_pMenu->bInCallback = true;
510  m_pMenu->Deactivate();
511  m_pMenu->bInCallback = false;
513  if( !ImplGetSVData()->maWinData.mbNoSaveFocus )
514  {
515  VclPtr<vcl::Window> xTempFocusId;
517  xTempFocusId = m_xSaveFocusId;
518  m_xSaveFocusId = nullptr;
519 
520  if (bAllowRestoreFocus)
521  {
522  // tdf#115227 the popup is already killed, so temporarily set us as the
523  // focus window, so we could avoid sending superfluous activate events
524  // to top window listeners.
525  if (xTempFocusId || bDefaultToDocument)
527 
528  // #105406# restore focus to document if we could not save focus before
529  if (!xTempFocusId && bDefaultToDocument)
531  else
532  Window::EndSaveFocus(xTempFocusId);
533  }
534  }
535  }
536 
538  {
540  Invalidate(); //HighlightItem( nHighlightedItem, false );
541 
543  }
544 
545  m_nHighlightedItem = n;
546  SAL_WARN_IF( ( m_nHighlightedItem != ITEMPOS_INVALID ) && !m_pMenu->ImplIsVisible( m_nHighlightedItem ), "vcl", "ChangeHighlightItem: Not visible!" );
548  Invalidate(); //HighlightItem( nHighlightedItem, true );
549  else if ( m_nRolloveredItem != ITEMPOS_INVALID )
550  Invalidate(); //HighlightItem( nRolloveredItem, true );
552 
553  if( mbAutoPopup )
554  ImplCreatePopup( bSelectEntry );
555 
556  // #58935# #73659# Focus, if no popup underneath...
557  if ( bJustActivated && !m_pActivePopup )
558  GrabFocus();
559 }
560 
561 static int ImplGetTopDockingAreaHeight( vcl::Window const *pWindow )
562 {
563  // find docking area that is top aligned and return its height
564  // note: dockingareas are direct children of the SystemWindow
565  if( pWindow->ImplGetFrameWindow() )
566  {
567  vcl::Window *pWin = pWindow->ImplGetFrameWindow()->GetWindow( GetWindowType::FirstChild ); //mpWindowImpl->mpFirstChild;
568  while( pWin )
569  {
570  if( pWin->IsSystemWindow() )
571  {
572  vcl::Window *pChildWin = pWin->GetWindow( GetWindowType::FirstChild ); //mpWindowImpl->mpFirstChild;
573  while( pChildWin )
574  {
575  DockingAreaWindow *pDockingArea = nullptr;
576  if ( pChildWin->GetType() == WindowType::DOCKINGAREA )
577  pDockingArea = static_cast< DockingAreaWindow* >( pChildWin );
578 
579  if( pDockingArea && pDockingArea->GetAlign() == WindowAlign::Top &&
580  pDockingArea->IsVisible() && pDockingArea->GetOutputSizePixel().Height() != 0 )
581  {
582  return pDockingArea->GetOutputSizePixel().Height();
583  }
584 
585  pChildWin = pChildWin->GetWindow( GetWindowType::Next ); //mpWindowImpl->mpNext;
586  }
587 
588  }
589 
590  pWin = pWin->GetWindow( GetWindowType::Next ); //mpWindowImpl->mpNext;
591  }
592  }
593  return 0;
594 }
595 
596 static void ImplAddNWFSeparator(vcl::RenderContext& rRenderContext, const Size& rSize, const MenubarValue& rMenubarValue)
597 {
598  // add a separator if
599  // - we have an adjacent docking area
600  // - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx)
601  if (rMenubarValue.maTopDockingAreaHeight
602  && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB
603  && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames)
604  {
605  // note: the menubar only provides the upper (dark) half of it, the rest (bright part) is drawn by the docking area
606 
607  rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor());
608  tools::Rectangle aRect(Point(), rSize);
609  rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
610  }
611 }
612 
613 void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos)
614 {
615  if (!m_pMenu)
616  return;
617 
618  long nX = 0;
619  size_t nCount = m_pMenu->pItemList->size();
620 
621  Size aOutputSize = GetOutputSizePixel();
622  aOutputSize.AdjustWidth( -(m_aCloseBtn->GetSizePixel().Width()) );
623 
624  for (size_t n = 0; n < nCount; n++)
625  {
626  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
627  if (n == nPos)
628  {
629  if (pData->eType != MenuItemType::SEPARATOR)
630  {
631  // #107747# give menuitems the height of the menubar
632  tools::Rectangle aRect(Point(nX, 1), Size(pData->aSz.Width(), aOutputSize.Height() - 2));
633  rRenderContext.Push(PushFlags::CLIPREGION);
634  rRenderContext.IntersectClipRegion(aRect);
635  bool bRollover, bHighlight;
636  if (!ImplGetSVData()->maNWFData.mbRolloverMenubar)
637  {
638  bHighlight = true;
639  bRollover = nPos != m_nHighlightedItem;
640  }
641  else
642  {
643  bRollover = nPos == m_nRolloveredItem;
644  bHighlight = nPos == m_nHighlightedItem;
645  }
648  {
649  // draw background (transparency)
650  MenubarValue aControlValue;
651  aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
652 
653  if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
654  Erase(rRenderContext);
655  else
656  {
657  tools::Rectangle aBgRegion(Point(), aOutputSize);
659  ControlState::ENABLED, aControlValue, OUString());
660  }
661 
662  ImplAddNWFSeparator(rRenderContext, aOutputSize, aControlValue);
663 
664  // draw selected item
666  if (bRollover)
667  nState |= ControlState::ROLLOVER;
668  else
669  nState |= ControlState::SELECTED;
671  aRect, nState, aControlValue, OUString() );
672  }
673  else
674  {
675  if (bRollover)
676  rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuBarRolloverColor());
677  else
678  rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
679  rRenderContext.SetLineColor();
680  rRenderContext.DrawRect(aRect);
681  }
682  rRenderContext.Pop();
683 
684  m_pMenu->ImplPaint(rRenderContext, aOutputSize, 0, 0, pData, bHighlight, false, bRollover);
685  }
686  return;
687  }
688 
689  nX += pData->aSz.Width();
690  }
691 }
692 
694 {
695  tools::Rectangle aRect;
696  if( m_pMenu )
697  {
698  long nX = 0;
699  size_t nCount = m_pMenu->pItemList->size();
700  for ( size_t n = 0; n < nCount; n++ )
701  {
702  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
703  if ( n == nPos )
704  {
705  if ( pData->eType != MenuItemType::SEPARATOR )
706  // #107747# give menuitems the height of the menubar
707  aRect = tools::Rectangle( Point( nX, 1 ), Size( pData->aSz.Width(), GetOutputSizePixel().Height()-2 ) );
708  break;
709  }
710 
711  nX += pData->aSz.Width();
712  }
713  }
714  return aRect;
715 }
716 
717 void MenuBarWindow::KeyInput( const KeyEvent& rKEvent )
718 {
719  if ( !HandleKeyEvent( rKEvent ) )
720  Window::KeyInput( rKEvent );
721 }
722 
723 bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
724 {
725  if (!m_pMenu)
726  return false;
727 
728  if (m_pMenu->bInCallback)
729  return true; // swallow
730 
731  bool bDone = false;
732  sal_uInt16 nCode = rKEvent.GetKeyCode().GetCode();
733 
734  if( GetParent() )
735  {
737  {
738  SystemWindow *pSysWin = static_cast<SystemWindow*>(GetParent()->GetWindow( GetWindowType::Client ));
739  if( pSysWin->GetTaskPaneList() )
740  if( pSysWin->GetTaskPaneList()->HandleKeyEvent( rKEvent ) )
741  return true;
742  }
743  }
744 
745  // no key events if native menus
747  {
748  return false;
749  }
750 
751  if ( nCode == KEY_MENU && !rKEvent.GetKeyCode().IsShift() ) // only F10, not Shift-F10
752  {
753  mbAutoPopup = false;
755  {
756  ChangeHighlightItem( 0, false );
757  GrabFocus();
758  }
759  else
760  {
762  m_xSaveFocusId = nullptr;
763  }
764  bDone = true;
765  }
766  else if ( bFromMenu )
767  {
768  if ( ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) ||
769  ( nCode == KEY_HOME ) || ( nCode == KEY_END ) )
770  {
771  sal_uInt16 n = m_nHighlightedItem;
772  if ( n == ITEMPOS_INVALID )
773  {
774  if ( nCode == KEY_LEFT)
775  n = 0;
776  else
777  n = m_pMenu->GetItemCount()-1;
778  }
779 
780  sal_uInt16 nLoop = n;
781 
782  if( nCode == KEY_HOME )
783  { n = sal_uInt16(-1); nLoop = n+1; }
784  if( nCode == KEY_END )
785  { n = m_pMenu->GetItemCount(); nLoop = n-1; }
786 
787  do
788  {
789  if ( nCode == KEY_LEFT || nCode == KEY_END )
790  {
791  if ( n )
792  n--;
793  else
794  n = m_pMenu->GetItemCount()-1;
795  }
796  if ( nCode == KEY_RIGHT || nCode == KEY_HOME )
797  {
798  n++;
799  if ( n >= m_pMenu->GetItemCount() )
800  n = 0;
801  }
802 
804  if (pData->eType != MenuItemType::SEPARATOR &&
805  m_pMenu->ImplIsVisible(n) &&
807  {
808  ChangeHighlightItem( n, true );
809  break;
810  }
811  } while ( n != nLoop );
812  bDone = true;
813  }
814  else if ( nCode == KEY_RETURN )
815  {
817  else
818  if ( !mbAutoPopup )
819  {
820  ImplCreatePopup( true );
821  mbAutoPopup = true;
822  }
823  bDone = true;
824  }
825  else if ( ( nCode == KEY_UP ) || ( nCode == KEY_DOWN ) )
826  {
827  if ( !mbAutoPopup )
828  {
829  ImplCreatePopup( true );
830  mbAutoPopup = true;
831  }
832  bDone = true;
833  }
834  else if ( nCode == KEY_ESCAPE || ( nCode == KEY_F6 && rKEvent.GetKeyCode().IsMod1() ) )
835  {
836  if( m_pActivePopup )
837  {
838  // hide the menu and remove the focus...
839  mbAutoPopup = false;
840  KillActivePopup();
841  }
842 
844 
845  if( nCode == KEY_F6 && rKEvent.GetKeyCode().IsMod1() )
846  {
847  // put focus into document
849  }
850 
851  bDone = true;
852  }
853  }
854 
855  bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel;
856 
857  if ( !bDone && ( bFromMenu || rKEvent.GetKeyCode().IsMod2() ) )
858  {
859  sal_Unicode nCharCode = rKEvent.GetCharCode();
860  if ( nCharCode )
861  {
862  size_t nEntry, nDuplicates;
863  MenuItemData* pData = m_pMenu->GetItemList()->SearchItem( nCharCode, rKEvent.GetKeyCode(), nEntry, nDuplicates, m_nHighlightedItem );
864  if ( pData && (nEntry != ITEMPOS_INVALID) )
865  {
866  mbAutoPopup = true;
867  ChangeHighlightItem( nEntry, true );
868  bDone = true;
869  }
870  }
871  }
872 
873  const bool bShowAccels = nCode != KEY_ESCAPE;
874  if (GetMBWMenuKey() != bShowAccels)
875  {
876  SetMBWMenuKey(bShowAccels);
877  SetMBWHideAccel(!bShowAccels);
878  if (autoacc)
880  }
881 
882  return bDone;
883 }
884 
886 {
887  if (!m_pMenu)
888  return;
889 
890  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
891 
892  Size aOutputSize = GetOutputSizePixel();
893 
894  // no VCL paint if native menus
896  {
898  return;
899  }
900 
901  // Make sure that all actual rendering happens in one go to avoid flicker.
902  vcl::BufferDevice pBuffer(this, rRenderContext);
903 
905  {
906  MenubarValue aMenubarValue;
908 
909  if (!rStyleSettings.GetPersonaHeader().IsEmpty())
910  Erase(*pBuffer);
911  else
912  {
913  tools::Rectangle aCtrlRegion( Point(), aOutputSize );
914 
916  ControlState::ENABLED, aMenubarValue, OUString());
917  }
918 
919  ImplAddNWFSeparator(*pBuffer, aOutputSize, aMenubarValue);
920  }
921 
922  // shrink the area of the buttons
923  aOutputSize.AdjustWidth( -(m_aCloseBtn->GetSizePixel().Width()) );
924 
925  pBuffer->SetFillColor(rStyleSettings.GetMenuColor());
926  m_pMenu->ImplPaint(*pBuffer, aOutputSize, 0);
927 
931  HighlightItem(*pBuffer, m_nRolloveredItem);
932 
933  // in high contrast mode draw a separating line on the lower edge
935  rStyleSettings.GetHighContrastMode())
936  {
938  pBuffer->SetLineColor(COL_WHITE);
939  pBuffer->SetMapMode(MapMode(MapUnit::MapPixel));
940  Size aSize = GetSizePixel();
941  pBuffer->DrawLine(Point(0, aSize.Height() - 1),
942  Point(aSize.Width() - 1, aSize.Height() - 1));
943  pBuffer->Pop();
944  }
945 }
946 
948 {
949  Size aOutSz = GetOutputSizePixel();
950  long n = aOutSz.Height()-4;
951  long nX = aOutSz.Width()-3;
952  long nY = 2;
953 
954  if ( m_aCloseBtn->IsVisible() )
955  {
956  m_aCloseBtn->Hide();
958  Size aTbxSize( m_aCloseBtn->CalcWindowSizePixel() );
959  nX -= aTbxSize.Width();
960  long nTbxY = (aOutSz.Height() - aTbxSize.Height())/2;
961  m_aCloseBtn->setPosSizePixel(nX, nTbxY, aTbxSize.Width(), aTbxSize.Height());
962  nX -= 3;
963  m_aCloseBtn->Show();
964  }
965  if ( m_aFloatBtn->IsVisible() )
966  {
967  nX -= n;
968  m_aFloatBtn->setPosSizePixel( nX, nY, n, n );
969  }
970  if ( m_aHideBtn->IsVisible() )
971  {
972  nX -= n;
973  m_aHideBtn->setPosSizePixel( nX, nY, n, n );
974  }
975 
978 
979  Invalidate();
980 }
981 
982 sal_uInt16 MenuBarWindow::ImplFindEntry( const Point& rMousePos ) const
983 {
984  if( m_pMenu )
985  {
986  long nX = 0;
987  size_t nCount = m_pMenu->pItemList->size();
988  for ( size_t n = 0; n < nCount; n++ )
989  {
990  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
991  if ( m_pMenu->ImplIsVisible( n ) )
992  {
993  nX += pData->aSz.Width();
994  if ( nX > rMousePos.X() )
995  return static_cast<sal_uInt16>(n);
996  }
997  }
998  }
999  return ITEMPOS_INVALID;
1000 }
1001 
1003 {
1004  sal_uInt16 nId = m_nHighlightedItem;
1005  if ( rHEvt.GetMode() & HelpEventMode::CONTEXT )
1007 
1009  if( !ImplHandleHelpEvent( this, m_pMenu, nId, rHEvt, aHighlightRect ) )
1010  Window::RequestHelp( rHEvt );
1011 }
1012 
1014 {
1015  Window::StateChanged( nType );
1016 
1017  if (nType == StateChangedType::ControlForeground ||
1019  {
1020  ApplySettings(*this);
1021  Invalidate();
1022  }
1023  else if (nType == StateChangedType::Enable)
1024  {
1025  Invalidate();
1026  }
1027  else if(m_pMenu)
1028  {
1030  }
1031 }
1032 
1034 {
1035  if (!m_pMenu)
1036  return;
1037 
1038  ApplySettings(*this);
1039 
1040  // if the font was changed.
1041  long nHeight = m_pMenu->ImplCalcSize(this).Height();
1042 
1043  // depending on the native implementation or the displayable flag
1044  // the menubar windows is suppressed (ie, height=0)
1045  if (!static_cast<MenuBar*>(m_pMenu.get())->IsDisplayable() ||
1047  {
1048  nHeight = 0;
1049  }
1050  setPosSizePixel(0, 0, 0, nHeight, PosSizeFlags::Height);
1051  GetParent()->Resize();
1052  Invalidate();
1053  Resize();
1054 
1056 }
1057 
1059 {
1060  Window::ApplySettings(rRenderContext);
1061  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1062 
1063  SetPointFont(rRenderContext, rStyleSettings.GetMenuFont());
1064 
1066  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1067  if (pNativeMenu)
1068  pNativeMenu->ApplyPersona();
1069  if (!rPersonaBitmap.IsEmpty())
1070  {
1071  Wallpaper aWallpaper(rPersonaBitmap);
1072  aWallpaper.SetStyle(WallpaperStyle::TopRight);
1073  aWallpaper.SetColor(Application::GetSettings().GetStyleSettings().GetWorkspaceColor());
1074 
1075  rRenderContext.SetBackground(aWallpaper);
1076  SetPaintTransparent(false);
1078  }
1080  {
1081  rRenderContext.SetBackground(); // background will be drawn by NWF
1082  }
1083  else
1084  {
1085  Wallpaper aWallpaper;
1087  rRenderContext.SetBackground(aWallpaper);
1088  SetPaintTransparent(false);
1090  }
1091 
1092  rRenderContext.SetTextColor(rStyleSettings.GetMenuBarTextColor());
1093  rRenderContext.SetTextFillColor();
1094  rRenderContext.SetLineColor();
1095 }
1096 
1098 {
1101  {
1102  AllSettings aSettings(GetSettings());
1103  ImplGetFrame()->UpdateSettings(aSettings); // to update persona
1104  StyleSettings aStyle(aSettings.GetStyleSettings());
1105  Color aHighlightTextColor = ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor;
1106  if (aHighlightTextColor != COL_TRANSPARENT)
1107  {
1108  aStyle.SetMenuHighlightTextColor(aHighlightTextColor);
1109  }
1110  aSettings.SetStyleSettings(aStyle);
1111  OutputDevice::SetSettings(aSettings);
1112  }
1113 }
1114 
1116 {
1117  Window::DataChanged( rDCEvt );
1118 
1119  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1121  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1122  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1123  {
1124  ApplySettings(*this);
1126  LayoutChanged();
1127  }
1128 }
1129 
1131 {
1132  if ( !HasChildPathFocus( true ) )
1133  ChangeHighlightItem( ITEMPOS_INVALID, false, false );
1134 }
1135 
1137 {
1138  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1139  if (pNativeMenu && pNativeMenu->TakeFocus())
1140  return;
1141 
1143  {
1144  mbAutoPopup = false; // do not open menu when activated by focus handling like taskpane cycling
1145  ChangeHighlightItem( 0, false );
1146  }
1147 }
1148 
1149 css::uno::Reference<css::accessibility::XAccessible> MenuBarWindow::CreateAccessible()
1150 {
1151  css::uno::Reference<css::accessibility::XAccessible> xAcc;
1152 
1153  if (m_pMenu)
1154  xAcc = m_pMenu->GetAccessible();
1155 
1156  return xAcc;
1157 }
1158 
1159 sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link<MenuBar::MenuBarButtonCallbackArg&,bool>& i_rLink, const OUString& i_rToolTip )
1160 {
1161  // find first free button id
1162  sal_uInt16 nId = IID_DOCUMENTCLOSE;
1163  std::map< sal_uInt16, AddButtonEntry >::const_iterator it;
1164  do
1165  {
1166  nId++;
1167  it = m_aAddButtons.find( nId );
1168  } while( it != m_aAddButtons.end() && nId < 128 );
1169  SAL_WARN_IF( nId >= 128, "vcl", "too many addbuttons in menubar" );
1170  AddButtonEntry& rNewEntry = m_aAddButtons[nId];
1171  rNewEntry.m_aSelectLink = i_rLink;
1172  m_aCloseBtn->InsertItem(nId, i_rImage, ToolBoxItemBits::NONE, 0);
1175  LayoutChanged();
1176 
1177  if( m_pMenu->mpSalMenu )
1178  m_pMenu->mpSalMenu->AddMenuBarButton( SalMenuButtonItem( nId, i_rImage, i_rToolTip ) );
1179 
1180  return nId;
1181 }
1182 
1184 {
1185  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( nId );
1186  if( it != m_aAddButtons.end() )
1187  it->second.m_aHighlightLink = rLink;
1188 }
1189 
1191 {
1192  tools::Rectangle aRect;
1193  if( m_aAddButtons.find( nId ) != m_aAddButtons.end() )
1194  {
1195  if( m_pMenu->mpSalMenu )
1196  {
1197  aRect = m_pMenu->mpSalMenu->GetMenuBarButtonRectPixel( nId, ImplGetWindowImpl()->mpFrame );
1198  if( aRect == tools::Rectangle( Point( -1, -1 ), Size( 1, 1 ) ) )
1199  {
1200  // system menu button is somewhere but location cannot be determined
1201  return tools::Rectangle();
1202  }
1203  }
1204 
1205  if( aRect.IsEmpty() )
1206  {
1207  aRect = m_aCloseBtn->GetItemRect(nId);
1209  aRect.Move( aOffset.X(), aOffset.Y() );
1210  }
1211  }
1212  return aRect;
1213 }
1214 
1216 {
1217  ToolBox::ImplToolItems::size_type nPos = m_aCloseBtn->GetItemPos(nId);
1218  m_aCloseBtn->RemoveItem(nPos);
1219  m_aAddButtons.erase( nId );
1221  LayoutChanged();
1222 
1223  if( m_pMenu->mpSalMenu )
1224  m_pMenu->mpSalMenu->RemoveMenuBarButton( nId );
1225 }
1226 
1227 bool MenuBarWindow::HandleMenuButtonEvent( sal_uInt16 i_nButtonId )
1228 {
1229  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( i_nButtonId );
1230  if( it != m_aAddButtons.end() )
1231  {
1233  aArg.nId = it->first;
1234  aArg.bHighlight = true;
1235  return it->second.m_aSelectLink.Call( aArg );
1236  }
1237  return false;
1238 }
1239 
1241 {
1242  /* #i83908# do not use the menubar if it is native or invisible
1243  this relies on MenuBar::ImplCreate setting the height of the menubar
1244  to 0 in this case
1245  */
1246  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1247  if (pNativeMenu && pNativeMenu->VisibleMenuBar())
1248  return pNativeMenu->CanGetFocus();
1249  return GetSizePixel().Height() > 0;
1250 }
1251 
1252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void calcMinSize()
long Width() const
VclPtr< Menu > pSubMenu
Size GetSizePixel() const
Definition: Image.cxx:86
tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId)
void Deactivate()
Definition: menu.cxx:275
PopupMenu * GetPopupMenu(sal_uInt16 nItemId) const
Definition: menu.cxx:759
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
Definition: toolbox2.cxx:1356
virtual void DrawMenuBar()=0
VclPtr< vcl::Window > mpFocusWin
Definition: svdata.hxx:200
bool mbNoSaveFocus
Definition: svdata.hxx:217
css::uno::Reference< css::accessibility::XAccessible > GetAccessible()
Definition: menu.cxx:1284
void SetTransparency(sal_uInt8 nTransparency)
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption)
Request rendering of a particular control and/or part.
SAL_DLLPRIVATE void ImplKillLayoutData() const
Definition: menu.cxx:2209
const Color & GetMenuBarRolloverColor() const
const Color & GetMenuBarTextColor() const
long AdjustWidth(long n)
long AdjustX(long nHorzMove)
Image GetItemImage(sal_uInt16 nItemId) const
Definition: toolbox2.cxx:1031
const vcl::Font & GetMenuFont() const
SAL_DLLPRIVATE bool ImplCurrentlyHiddenOnGUI(sal_uInt16 nPos) const
Definition: menu.cxx:1175
bool HasCloseButton() const
Definition: menu.hxx:433
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:1126
long Height() const
void PopupClosed(Menu const *pMenu)
Point BottomLeft() const
bool mbNoDeactivate
Definition: svdata.hxx:216
OUString aHelpText
sal_uIntPtr sal_uLong
bool HasFloatButton() const
Definition: menu.hxx:434
void disposeAndClear()
Definition: vclptr.hxx:200
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:704
BitmapEx const & GetPersonaHeader() const
ImplSVNWFData maNWFData
Definition: svdata.hxx:352
virtual Size GetSizePixel() const
Definition: window.cxx:2364
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:890
void SetColor(const Color &rColor)
Definition: wall.cxx:195
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:554
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:371
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:996
void ShowButtons(bool bClose, bool bFloat, bool bHide)
void SetTextFillColor()
Definition: text.cxx:698
sal_uInt16 GetCode() const
Definition: keycod.hxx:53
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
void ShowItem(sal_uInt16 nItemId, bool bVisible=true)
Shows or hides items.
Definition: toolbox2.cxx:1286
DataChangedEventType GetType() const
Definition: event.hxx:348
void IntersectClipRegion(const tools::Rectangle &rRect)
virtual void SetSettings(const AllSettings &rSettings)
Definition: outdev.cxx:213
#define TOOLBOX_STYLE_FLAT
Definition: toolbox.hxx:45
VclPtr< Menu > m_pMenu
const Color & GetMenuHighlightColor() const
void SetHelpText(sal_uInt16 nItemId, const OUString &rString)
Definition: menu.cxx:1075
void SetType(WindowType nType)
Definition: window2.cxx:957
void KillActivePopup()
#define KEY_LEFT
Definition: keycodes.hxx:112
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1215
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3008
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
void SetMapMode()
Definition: map.cxx:655
HelpEventMode GetMode() const
Definition: event.hxx:192
bool CanGetFocus() const
void Move(long nHorzMoveDelta, long nVertMoveDelta)
SAL_DLLPRIVATE Size ImplCalcSize(vcl::Window *pWin)
Definition: menu.cxx:1408
bool IsEmpty() const
sal_uInt16 m_nRolloveredItem
StateChangedType
Definition: window.hxx:311
WinBits const WB_NOPOINTERFOCUS
bool GetMBWHideAccel() const
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2685
Size CalcWindowSizePixel()
Definition: toolbox.hxx:528
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:1509
Buffers drawing on a vcl::RenderContext using a VirtualDevice.
bool IsEnterWindow() const
Definition: event.hxx:122
Toolbox that holds the close button (right hand side of the menubar).
virtual bool TakeFocus()
Definition: salmenu.hxx:85
ImplToolItems::size_type GetItemPos(sal_uInt16 nItemId) const
Definition: toolbox2.cxx:702
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
Definition: menu.cxx:1038
void Hide()
Definition: window.hxx:932
AllSettingsFlags GetFlags() const
Definition: event.hxx:349
bool GetHighContrastMode() const
void SetMBWMenuKey(bool val)
Link< MenuBar::MenuBarButtonCallbackArg &, bool > m_aSelectLink
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags=PosSizeFlags::All) override
Definition: dockwin.cxx:820
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
SAL_DLLPRIVATE SalMenu * ImplGetSalMenu()
Definition: menu.hxx:185
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:88
void GetFocus() override
bool mbAutoAccel
Definition: svdata.hxx:288
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:32
const Color & GetMenuColor() const
tools::Rectangle GetItemRect(sal_uInt16 nItemId)
Definition: toolbox2.cxx:818
void SetPopupMenu(sal_uInt16 nItemId, PopupMenu *pMenu)
Definition: menu.cxx:722
VclPtr< PopupMenu > mpParentPopup
Class that implements the actual window of the menu bar.
OString aHelpId
void SetMBWHideAccel(bool val)
Point BottomRight() const
bool IsEmpty() const
Definition: bitmapex.cxx:203
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:67
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:517
sal_uInt16 nId
bool IsLeaveWindow() const
Definition: event.hxx:124
std::unique_ptr< MenuItemList > pItemList
Definition: menu.hxx:132
long AdjustY(long nVertMove)
bool bInCallback
In Activate/Deactivate.
Definition: menu.hxx:156
bool IsSystemWindow() const
Definition: window2.cxx:986
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
void LoseFocus() override
void SetStyle(WallpaperStyle eStyle)
Definition: wall.cxx:209
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId)
int i
#define KEY_ESCAPE
Definition: keycodes.hxx:120
sal_uInt16 GetItemId(sal_uInt16 nPos) const
Definition: menu.cxx:632
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1156
MenuItemType eType
virtual void ApplyPersona()
Definition: salvtables.cxx:228
void SetFillColor()
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
void SetTextColor(const Color &rColor)
Definition: text.cxx:663
void AddPopupModeWindow(vcl::Window *pWindow)
Definition: floatwin.cxx:891
virtual void RequestHelp(const HelpEvent &rHEvt) override
WinBits const WB_SMALLSTYLE
WinBits const WB_RECTSTYLE
virtual void Resize()
Definition: window.cxx:1798
void GrabFocusToDocument()
Definition: window.cxx:2990
std::map< sal_uInt16, AddButtonEntry > m_aAddButtons
virtual void UpdateSettings(AllSettings &rSettings)=0
const AllSettings & GetSettings() const
Definition: outdev.hxx:420
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1018
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
SAL_DLLPRIVATE bool ImplIsVisible(sal_uInt16 nPos) const
Definition: menu.cxx:1189
MenuItemList * GetItemList() const
Definition: menu.hxx:350
void DataChanged(const DataChangedEvent &rDCEvt) override
void SetSelectHdl(const Link< ToolBox *, void > &rLink)
Definition: toolbox.hxx:460
void GrabFocus()
Definition: window.cxx:2980
vcl::Window * GetParent() const
Definition: window2.cxx:1086
long X() const
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
#define KEY_END
Definition: keycodes.hxx:115
SAL_DLLPRIVATE vcl::Window * ImplGetWindow() const
Definition: menu.hxx:213
void ImplInitStyleSettings()
VclPtr< PopupMenu > m_pActivePopup
virtual void SetFrame(const SalFrame *pFrame)=0
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1035
SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext &rRenderContext, Size const &rSize, sal_uInt16 nBorder, long nOffY=0, MenuItemData const *pThisDataOnly=nullptr, bool bHighlighted=false, bool bLayout=false, bool bRollover=false) const
Definition: menu.cxx:1712
void SetPointFont(vcl::RenderContext &rRenderContext, const vcl::Font &rFont)
Definition: window.cxx:2136
void ImplCreatePopup(bool bPreSelectFirst)
MenuBarWindow(vcl::Window *pParent)
OUString aHelpCommandStr
bool IsItemVisible(sal_uInt16 nItemId) const
Definition: toolbox2.cxx:1312
ImplSVWinData maWinData
Definition: svdata.hxx:349
#define KEY_RETURN
Definition: keycodes.hxx:119
void RemoveMenuBarButton(sal_uInt16 nId)
void AddEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:302
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
SalFrame * ImplGetFrame() const
Definition: window2.cxx:848
Size GetSizePixel() const override
Definition: dockwin.cxx:862
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:53
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:1057
bool IsShift() const
Definition: keycod.hxx:58
#define KEY_DOWN
Definition: keycodes.hxx:110
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:126
void Activate()
Definition: menu.cxx:244
#define SAL_WARN_IF(condition, area, stream)
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:918
bool IsVisible() const
Definition: window2.cxx:1091
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
VclPtr< vcl::Window > m_xSaveFocusId
bool HandleKeyEvent(const KeyEvent &rKeyEvent)
sal_Unicode GetCharCode() const
Definition: event.hxx:52
const Size & getMinSize() const
sal_uInt16 GetItemCount() const
Definition: menu.cxx:586
Definition: image.hxx:40
bool IsMod1() const
Definition: keycod.hxx:60
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 > &)
virtual void MouseMove(const MouseEvent &rMEvt) override
void SetAccelKey(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: menu.cxx:769
WindowAlign GetAlign() const
const Point & GetPosPixel() const
Definition: event.hxx:117
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
void SetOutStyle(sal_uInt16 nNewStyle)
Definition: toolbox2.cxx:1395
SAL_DLLPRIVATE MenuFloatingWindow * ImplGetFloatingWindow() const
Definition: menu.cxx:2682
BitmapEx GetBitmapEx() const
Definition: Image.cxx:94
void SetHeight(long nHeight)
bool HasHideButton() const
Definition: menu.hxx:435
std::unique_ptr< SalMenu > mpSalMenu
Definition: menu.hxx:161
#define KEY_F6
Definition: keycodes.hxx:88
WindowType GetType() const
Definition: window2.cxx:963
sal_uInt16 GetItemId(ImplToolItems::size_type nPos) const
Definition: toolbox2.cxx:726
#define KEY_HOME
Definition: keycodes.hxx:114
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
SAL_DLLPRIVATE void ImplCallHighlight(sal_uInt16 nHighlightItem)
Definition: menu.cxx:2105
void RemoveEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:307
OUString aText
OUString VclResId(const char *pId)
Definition: svdata.cxx:258
TaskPaneList * GetTaskPaneList()
Definition: syswin.cxx:242
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2818
VclPtr< PushButton > m_aHideBtn
SAL_DLLPRIVATE ImplFrameData * ImplGetFrameData()
Definition: window2.cxx:843
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:60
SAL_DLLPRIVATE sal_uInt16 ImplExecute(const VclPtr< vcl::Window > &pW, const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags, Menu *pSFrom, bool bPreSelectFirst)
Definition: menu.cxx:2810
sal_Int32 nPos
void SetImages(long nMaxHeight, bool bForce=false)
virtual ~MenuBarWindow() override
::Color maMenuBarHighlightTextColor
Definition: svdata.hxx:269
bool isDisposed() const
ImplToolItems::size_type GetItemCount() const
Definition: toolbox2.cxx:692
#define KEY_RIGHT
Definition: keycodes.hxx:113
virtual bool VisibleMenuBar()=0
virtual void SetMenu(SalMenu *pSalMenu)=0
long Y() const
bool GetMBWMenuKey() const
sal_uInt16 m_nHighlightedItem
#define KEY_MENU
Definition: keycodes.hxx:147
#define KEY_UP
Definition: keycodes.hxx:111
bool IsMod2() const
Definition: keycod.hxx:62
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2150
Size const & MinCloseButtonSize()
bool HandleKeyEvent(const KeyEvent &rKEvent, bool bFromMenu=true)
MenuItemBits nBits