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