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  {
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  // handling gtk like (aka mbOpenMenuOnF10)
781  // do not highlight an item when opening a sub menu
782  // unless there already was a highlighted sub menu item
783  bool bWasHighlight = false;
784  if( m_pActivePopup )
785  {
786  MenuFloatingWindow* pSubWindow = dynamic_cast<MenuFloatingWindow*>(m_pActivePopup->ImplGetWindow());
787  if( pSubWindow )
788  bWasHighlight = (pSubWindow->GetHighlightedItem() != ITEMPOS_INVALID);
789  }
790 
791  sal_uInt16 nLoop = n;
792 
793  if( nCode == KEY_HOME )
794  { n = sal_uInt16(-1); nLoop = n+1; }
795  if( nCode == KEY_END )
796  { n = m_pMenu->GetItemCount(); nLoop = n-1; }
797 
798  do
799  {
800  if ( nCode == KEY_LEFT || nCode == KEY_END )
801  {
802  if ( n )
803  n--;
804  else
805  n = m_pMenu->GetItemCount()-1;
806  }
807  if ( nCode == KEY_RIGHT || nCode == KEY_HOME )
808  {
809  n++;
810  if ( n >= m_pMenu->GetItemCount() )
811  n = 0;
812  }
813 
815  if (pData->eType != MenuItemType::SEPARATOR &&
816  m_pMenu->ImplIsVisible(n) &&
818  {
819  bool bDoSelect = true;
821  bDoSelect = bWasHighlight;
822  ChangeHighlightItem( n, bDoSelect );
823  break;
824  }
825  } while ( n != nLoop );
826  bDone = true;
827  }
828  else if ( nCode == KEY_RETURN )
829  {
831  else
832  if ( !mbAutoPopup )
833  {
834  ImplCreatePopup( true );
835  mbAutoPopup = true;
836  }
837  bDone = true;
838  }
839  else if ( ( nCode == KEY_UP ) || ( nCode == KEY_DOWN ) )
840  {
841  if ( !mbAutoPopup )
842  {
843  ImplCreatePopup( true );
844  mbAutoPopup = true;
845  }
846  bDone = true;
847  }
848  else if ( nCode == KEY_ESCAPE || ( nCode == KEY_F6 && rKEvent.GetKeyCode().IsMod1() ) )
849  {
850  if( m_pActivePopup )
851  {
852  // hide the menu and remove the focus...
853  mbAutoPopup = false;
854  KillActivePopup();
855  }
856 
858 
859  if( nCode == KEY_F6 && rKEvent.GetKeyCode().IsMod1() )
860  {
861  // put focus into document
863  }
864 
865  bDone = true;
866  }
867  }
868 
869  bool accel = ImplGetSVData()->maNWFData.mbEnableAccel;
870  bool autoacc = ImplGetSVData()->maNWFData.mbAutoAccel;
871 
872  if ( !bDone && ( bFromMenu || (rKEvent.GetKeyCode().IsMod2() && accel) ) )
873  {
874  sal_Unicode nCharCode = rKEvent.GetCharCode();
875  if ( nCharCode )
876  {
877  size_t nEntry, nDuplicates;
878  MenuItemData* pData = m_pMenu->GetItemList()->SearchItem( nCharCode, rKEvent.GetKeyCode(), nEntry, nDuplicates, m_nHighlightedItem );
879  if ( pData && (nEntry != ITEMPOS_INVALID) )
880  {
881  mbAutoPopup = true;
882  ChangeHighlightItem( nEntry, true );
883  bDone = true;
884  }
885  }
886  }
887 
888  const bool bShowAccels = nCode != KEY_ESCAPE;
889  if (GetMBWMenuKey() != bShowAccels)
890  {
891  SetMBWMenuKey(bShowAccels);
892  SetMBWHideAccel(!bShowAccels);
893  if (accel && autoacc)
895  }
896 
897  return bDone;
898 }
899 
901 {
902  if (!m_pMenu)
903  return;
904 
905  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
906 
907  Size aOutputSize = GetOutputSizePixel();
908 
909  // no VCL paint if native menus
911  {
913  return;
914  }
915 
916  // Make sure that all actual rendering happens in one go to avoid flicker.
917  vcl::BufferDevice pBuffer(this, rRenderContext);
918 
920  {
921  MenubarValue aMenubarValue;
923 
924  if (!rStyleSettings.GetPersonaHeader().IsEmpty())
925  Erase(*pBuffer);
926  else
927  {
928  tools::Rectangle aCtrlRegion( Point(), aOutputSize );
929 
931  ControlState::ENABLED, aMenubarValue, OUString());
932  }
933 
934  ImplAddNWFSeparator(*pBuffer, aOutputSize, aMenubarValue);
935  }
936 
937  // shrink the area of the buttons
938  aOutputSize.AdjustWidth( -(m_aCloseBtn->GetSizePixel().Width()) );
939 
940  pBuffer->SetFillColor(rStyleSettings.GetMenuColor());
941  m_pMenu->ImplPaint(*pBuffer, aOutputSize, 0);
942 
946  HighlightItem(*pBuffer, m_nRolloveredItem);
947 
948  // in high contrast mode draw a separating line on the lower edge
950  rStyleSettings.GetHighContrastMode())
951  {
953  pBuffer->SetLineColor(COL_WHITE);
954  pBuffer->SetMapMode(MapMode(MapUnit::MapPixel));
955  Size aSize = GetSizePixel();
956  pBuffer->DrawLine(Point(0, aSize.Height() - 1),
957  Point(aSize.Width() - 1, aSize.Height() - 1));
958  pBuffer->Pop();
959  }
960 }
961 
963 {
964  Size aOutSz = GetOutputSizePixel();
965  long n = aOutSz.Height()-4;
966  long nX = aOutSz.Width()-3;
967  long nY = 2;
968 
969  if ( m_aCloseBtn->IsVisible() )
970  {
971  m_aCloseBtn->Hide();
973  Size aTbxSize( m_aCloseBtn->CalcWindowSizePixel() );
974  nX -= aTbxSize.Width();
975  long nTbxY = (aOutSz.Height() - aTbxSize.Height())/2;
976  m_aCloseBtn->setPosSizePixel(nX, nTbxY, aTbxSize.Width(), aTbxSize.Height());
977  nX -= 3;
978  m_aCloseBtn->Show();
979  }
980  if ( m_aFloatBtn->IsVisible() )
981  {
982  nX -= n;
983  m_aFloatBtn->setPosSizePixel( nX, nY, n, n );
984  }
985  if ( m_aHideBtn->IsVisible() )
986  {
987  nX -= n;
988  m_aHideBtn->setPosSizePixel( nX, nY, n, n );
989  }
990 
993 
994  Invalidate();
995 }
996 
997 sal_uInt16 MenuBarWindow::ImplFindEntry( const Point& rMousePos ) const
998 {
999  if( m_pMenu )
1000  {
1001  long nX = 0;
1002  size_t nCount = m_pMenu->pItemList->size();
1003  for ( size_t n = 0; n < nCount; n++ )
1004  {
1005  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
1006  if ( m_pMenu->ImplIsVisible( n ) )
1007  {
1008  nX += pData->aSz.Width();
1009  if ( nX > rMousePos.X() )
1010  return static_cast<sal_uInt16>(n);
1011  }
1012  }
1013  }
1014  return ITEMPOS_INVALID;
1015 }
1016 
1018 {
1019  sal_uInt16 nId = m_nHighlightedItem;
1020  if ( rHEvt.GetMode() & HelpEventMode::CONTEXT )
1022 
1024  if( !ImplHandleHelpEvent( this, m_pMenu, nId, rHEvt, aHighlightRect ) )
1025  Window::RequestHelp( rHEvt );
1026 }
1027 
1029 {
1030  Window::StateChanged( nType );
1031 
1032  if (nType == StateChangedType::ControlForeground ||
1034  {
1035  ApplySettings(*this);
1036  Invalidate();
1037  }
1038  else if (nType == StateChangedType::Enable)
1039  {
1040  Invalidate();
1041  }
1042  else if(m_pMenu)
1043  {
1045  }
1046 }
1047 
1049 {
1050  if (!m_pMenu)
1051  return;
1052 
1053  ApplySettings(*this);
1054 
1055  // if the font was changed.
1056  long nHeight = m_pMenu->ImplCalcSize(this).Height();
1057 
1058  // depending on the native implementation or the displayable flag
1059  // the menubar windows is suppressed (ie, height=0)
1060  if (!static_cast<MenuBar*>(m_pMenu.get())->IsDisplayable() ||
1062  {
1063  nHeight = 0;
1064  }
1065  setPosSizePixel(0, 0, 0, nHeight, PosSizeFlags::Height);
1066  GetParent()->Resize();
1067  Invalidate();
1068  Resize();
1069 
1071 }
1072 
1074 {
1075  Window::ApplySettings(rRenderContext);
1076  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1077 
1078  SetPointFont(rRenderContext, rStyleSettings.GetMenuFont());
1079 
1081  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1082  if (pNativeMenu)
1083  pNativeMenu->ApplyPersona();
1084  if (!rPersonaBitmap.IsEmpty())
1085  {
1086  Wallpaper aWallpaper(rPersonaBitmap);
1087  aWallpaper.SetStyle(WallpaperStyle::TopRight);
1088  aWallpaper.SetColor(Application::GetSettings().GetStyleSettings().GetWorkspaceColor());
1089 
1090  rRenderContext.SetBackground(aWallpaper);
1091  SetPaintTransparent(false);
1093  }
1095  {
1096  rRenderContext.SetBackground(); // background will be drawn by NWF
1097  }
1098  else
1099  {
1100  Wallpaper aWallpaper;
1102  rRenderContext.SetBackground(aWallpaper);
1103  SetPaintTransparent(false);
1105  }
1106 
1107  rRenderContext.SetTextColor(rStyleSettings.GetMenuBarTextColor());
1108  rRenderContext.SetTextFillColor();
1109  rRenderContext.SetLineColor();
1110 }
1111 
1113 {
1116  {
1117  AllSettings aSettings(GetSettings());
1118  ImplGetFrame()->UpdateSettings(aSettings); // to update persona
1119  StyleSettings aStyle(aSettings.GetStyleSettings());
1120  Color aHighlightTextColor = ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor;
1121  if (aHighlightTextColor != COL_TRANSPARENT)
1122  {
1123  aStyle.SetMenuHighlightTextColor(aHighlightTextColor);
1124  }
1125  aSettings.SetStyleSettings(aStyle);
1126  OutputDevice::SetSettings(aSettings);
1127  }
1128 }
1129 
1131 {
1132  Window::DataChanged( rDCEvt );
1133 
1134  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1136  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1137  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1138  {
1139  ApplySettings(*this);
1141  LayoutChanged();
1142  }
1143 }
1144 
1146 {
1147  if ( !HasChildPathFocus( true ) )
1148  ChangeHighlightItem( ITEMPOS_INVALID, false, false );
1149 }
1150 
1152 {
1153  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1154  if (pNativeMenu && pNativeMenu->TakeFocus())
1155  return;
1156 
1158  {
1159  mbAutoPopup = false; // do not open menu when activated by focus handling like taskpane cycling
1160  ChangeHighlightItem( 0, false );
1161  }
1162 }
1163 
1164 css::uno::Reference<css::accessibility::XAccessible> MenuBarWindow::CreateAccessible()
1165 {
1166  css::uno::Reference<css::accessibility::XAccessible> xAcc;
1167 
1168  if (m_pMenu)
1169  xAcc = m_pMenu->GetAccessible();
1170 
1171  return xAcc;
1172 }
1173 
1174 sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link<MenuBar::MenuBarButtonCallbackArg&,bool>& i_rLink, const OUString& i_rToolTip )
1175 {
1176  // find first free button id
1177  sal_uInt16 nId = IID_DOCUMENTCLOSE;
1178  std::map< sal_uInt16, AddButtonEntry >::const_iterator it;
1179  do
1180  {
1181  nId++;
1182  it = m_aAddButtons.find( nId );
1183  } while( it != m_aAddButtons.end() && nId < 128 );
1184  SAL_WARN_IF( nId >= 128, "vcl", "too many addbuttons in menubar" );
1185  AddButtonEntry& rNewEntry = m_aAddButtons[nId];
1186  rNewEntry.m_aSelectLink = i_rLink;
1187  m_aCloseBtn->InsertItem(nId, i_rImage, ToolBoxItemBits::NONE, 0);
1190  LayoutChanged();
1191 
1192  if( m_pMenu->mpSalMenu )
1193  m_pMenu->mpSalMenu->AddMenuBarButton( SalMenuButtonItem( nId, i_rImage, i_rToolTip ) );
1194 
1195  return nId;
1196 }
1197 
1199 {
1200  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( nId );
1201  if( it != m_aAddButtons.end() )
1202  it->second.m_aHighlightLink = rLink;
1203 }
1204 
1206 {
1207  tools::Rectangle aRect;
1208  if( m_aAddButtons.find( nId ) != m_aAddButtons.end() )
1209  {
1210  if( m_pMenu->mpSalMenu )
1211  {
1212  aRect = m_pMenu->mpSalMenu->GetMenuBarButtonRectPixel( nId, ImplGetWindowImpl()->mpFrame );
1213  if( aRect == tools::Rectangle( Point( -1, -1 ), Size( 1, 1 ) ) )
1214  {
1215  // system menu button is somewhere but location cannot be determined
1216  return tools::Rectangle();
1217  }
1218  }
1219 
1220  if( aRect.IsEmpty() )
1221  {
1222  aRect = m_aCloseBtn->GetItemRect(nId);
1224  aRect.Move( aOffset.X(), aOffset.Y() );
1225  }
1226  }
1227  return aRect;
1228 }
1229 
1231 {
1232  ToolBox::ImplToolItems::size_type nPos = m_aCloseBtn->GetItemPos(nId);
1233  m_aCloseBtn->RemoveItem(nPos);
1234  m_aAddButtons.erase( nId );
1236  LayoutChanged();
1237 
1238  if( m_pMenu->mpSalMenu )
1239  m_pMenu->mpSalMenu->RemoveMenuBarButton( nId );
1240 }
1241 
1242 bool MenuBarWindow::HandleMenuButtonEvent( sal_uInt16 i_nButtonId )
1243 {
1244  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( i_nButtonId );
1245  if( it != m_aAddButtons.end() )
1246  {
1248  aArg.nId = it->first;
1249  aArg.bHighlight = true;
1250  return it->second.m_aSelectLink.Call( aArg );
1251  }
1252  return false;
1253 }
1254 
1256 {
1257  /* #i83908# do not use the menubar if it is native or invisible
1258  this relies on MenuBar::ImplCreate setting the height of the menubar
1259  to 0 in this case
1260  */
1261  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1262  if (pNativeMenu && pNativeMenu->VisibleMenuBar())
1263  return pNativeMenu->CanGetFocus();
1264  return GetSizePixel().Height() > 0;
1265 }
1266 
1267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void calcMinSize()
long Width() const
VclPtr< Menu > pSubMenu
Size GetSizePixel() const
Definition: Image.cxx:75
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:1357
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:2213
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:1030
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:705
BitmapEx const & GetPersonaHeader() const
ImplSVNWFData maNWFData
Definition: svdata.hxx:357
virtual Size GetSizePixel() const
Definition: window.cxx:2364
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:895
void SetColor(const Color &rColor)
Definition: wall.cxx:194
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:552
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:997
void ShowButtons(bool bClose, bool bFloat, bool bHide)
void SetTextFillColor()
Definition: text.cxx:697
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:1287
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:962
void KillActivePopup()
#define KEY_LEFT
Definition: keycodes.hxx:112
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1220
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3000
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:309
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:536
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:1526
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
Class that implements the actual window of the floating menu.
ImplToolItems::size_type GetItemPos(sal_uInt16 nItemId) const
Definition: toolbox2.cxx:701
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
Definition: menu.cxx:1038
void Hide()
Definition: window.hxx:930
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:420
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:293
sal_uInt16 GetHighlightedItem() const
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:32
const Color & GetMenuColor() const
tools::Rectangle GetItemRect(sal_uInt16 nItemId)
Definition: toolbox2.cxx:817
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
bool mbEnableAccel
Definition: svdata.hxx:292
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:516
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:991
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:208
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:1153
MenuItemType eType
virtual void ApplyPersona()
Definition: salvtables.cxx:223
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:662
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:1015
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:470
void GrabFocus()
Definition: window.cxx:2980
vcl::Window * GetParent() const
Definition: window2.cxx:1091
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:1713
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:1313
ImplSVWinData maWinData
Definition: svdata.hxx:354
#define KEY_RETURN
Definition: keycodes.hxx:119
void RemoveMenuBarButton(sal_uInt16 nId)
void AddEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:292
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:853
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:917
bool IsVisible() const
Definition: window2.cxx:1096
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:51
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:1396
SAL_DLLPRIVATE MenuFloatingWindow * ImplGetFloatingWindow() const
Definition: menu.cxx:2686
BitmapEx GetBitmapEx() const
Definition: Image.cxx:83
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:968
sal_uInt16 GetItemId(ImplToolItems::size_type nPos) const
Definition: toolbox2.cxx:725
#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:2109
void RemoveEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:297
OUString aText
OUString VclResId(const char *pId)
Definition: svdata.cxx:258
TaskPaneList * GetTaskPaneList()
Definition: syswin.cxx:240
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:848
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:2814
sal_Int32 nPos
void SetImages(long nMaxHeight, bool bForce=false)
virtual ~MenuBarWindow() override
bool mbOpenMenuOnF10
Definition: svdata.hxx:279
::Color maMenuBarHighlightTextColor
Definition: svdata.hxx:270
bool isDisposed() const
ImplToolItems::size_type GetItemCount() const
Definition: toolbox2.cxx:691
#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