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 
192  }
193 }
194 
196 {
197  setPosSizePixel(0, 0, 0, nHeight, PosSizeFlags::Height);
198 }
199 
200 void MenuBarWindow::ShowButtons( bool bClose, bool bFloat, bool bHide )
201 {
203  m_aCloseBtn->Show(bClose || !m_aAddButtons.empty());
204  if (m_pMenu->mpSalMenu)
205  m_pMenu->mpSalMenu->ShowCloseButton(bClose);
206  m_aFloatBtn->Show( bFloat );
207  m_aHideBtn->Show( bHide );
208  Resize();
209 }
210 
212 {
213  return m_aCloseBtn->getMinSize();
214 }
215 
217 {
218  if( ! m_pMenu )
219  return;
220 
221  if( m_aCloseBtn->GetCurItemId() == ToolBoxItemId(IID_DOCUMENTCLOSE) )
222  {
223  // #i106052# call close hdl asynchronously to ease handler implementation
224  // this avoids still being in the handler while the DecoToolBox already
225  // gets destroyed
226  Application::PostUserEvent(static_cast<MenuBar*>(m_pMenu.get())->GetCloseButtonClickHdl());
227  }
228  else
229  {
230  std::map<sal_uInt16,AddButtonEntry>::iterator it = m_aAddButtons.find(sal_uInt16(m_aCloseBtn->GetCurItemId()));
231  if( it != m_aAddButtons.end() )
232  {
234  aArg.nId = it->first;
235  aArg.bHighlight = (sal_uInt16(m_aCloseBtn->GetHighlightItemId()) == it->first);
236  it->second.m_aSelectLink.Call( aArg );
237  }
238  }
239 }
240 
241 IMPL_LINK( MenuBarWindow, ToolboxEventHdl, VclWindowEvent&, rEvent, void )
242 {
243  if( ! m_pMenu )
244  return;
245 
247  aArg.nId = 0xffff;
248  aArg.bHighlight = (rEvent.GetId() == VclEventId::ToolboxHighlight);
249  if( rEvent.GetId() == VclEventId::ToolboxHighlight )
250  aArg.nId =sal_uInt16(m_aCloseBtn->GetHighlightItemId());
251  else if( rEvent.GetId() == VclEventId::ToolboxHighlightOff )
252  {
253  auto nPos = static_cast<ToolBox::ImplToolItems::size_type>(reinterpret_cast<sal_IntPtr>(rEvent.GetData()));
254  aArg.nId = sal_uInt16(m_aCloseBtn->GetItemId(nPos));
255  }
256  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( aArg.nId );
257  if( it != m_aAddButtons.end() )
258  {
259  it->second.m_aHighlightLink.Call( aArg );
260  }
261 }
262 
263 IMPL_LINK( MenuBarWindow, ShowHideListener, VclWindowEvent&, rEvent, void )
264 {
265  if( ! m_pMenu )
266  return;
267 
268  if( rEvent.GetId() == VclEventId::WindowShow )
269  m_pMenu->ImplCallEventListeners( VclEventId::MenuShow, ITEMPOS_INVALID );
270  else if( rEvent.GetId() == VclEventId::WindowHide )
271  m_pMenu->ImplCallEventListeners( VclEventId::MenuHide, ITEMPOS_INVALID );
272 }
273 
274 void MenuBarWindow::ImplCreatePopup( bool bPreSelectFirst )
275 {
277  if ( !pItemData )
278  return;
279 
280  m_bIgnoreFirstMove = true;
281  if ( m_pActivePopup && ( m_pActivePopup != pItemData->pSubMenu ) )
282  {
283  KillActivePopup();
284  }
285  if ( !(pItemData->bEnabled && pItemData->pSubMenu && ( m_nHighlightedItem != ITEMPOS_INVALID ) &&
286  ( pItemData->pSubMenu != m_pActivePopup )) )
287  return;
288 
289  m_pActivePopup = static_cast<PopupMenu*>(pItemData->pSubMenu.get());
290  tools::Long nX = 0;
291  MenuItemData* pData = nullptr;
292  for ( sal_uLong n = 0; n < m_nHighlightedItem; n++ )
293  {
294  pData = m_pMenu->GetItemList()->GetDataFromPos( n );
295  nX += pData->aSz.Width();
296  }
297  pData = m_pMenu->pItemList->GetDataFromPos( m_nHighlightedItem );
298  Point aItemTopLeft( nX, 0 );
299  Point aItemBottomRight( aItemTopLeft );
300  aItemBottomRight.AdjustX(pData->aSz.Width() );
301 
302  if (pData->bHiddenOnGUI)
303  {
307 
308  for (sal_uInt16 i = m_nHighlightedItem; i < m_pMenu->GetItemCount(); ++i)
309  {
310  sal_uInt16 nId = m_pMenu->GetItemId(i);
311 
312  MenuItemData* pParentItemData = m_pMenu->GetItemList()->GetData(nId);
313  assert(pParentItemData);
314  mpParentPopup->InsertItem(nId, pParentItemData->aText, pParentItemData->nBits, pParentItemData->sIdent);
315  mpParentPopup->SetHelpId(nId, pParentItemData->aHelpId);
316  mpParentPopup->SetHelpText(nId, pParentItemData->aHelpText);
317  mpParentPopup->SetAccelKey(nId, pParentItemData->aAccelKey);
318  mpParentPopup->SetItemCommand(nId, pParentItemData->aCommandStr);
319  mpParentPopup->SetHelpCommand(nId, pParentItemData->aHelpCommandStr);
320 
321  PopupMenu* pPopup = m_pMenu->GetPopupMenu(nId);
322  mpParentPopup->SetPopupMenu(nId, pPopup);
323  }
324  }
325  // the menu bar could have height 0 in fullscreen mode:
326  // so do not use always WindowHeight, as ItemHeight < WindowHeight.
327  if ( GetSizePixel().Height() )
328  {
329  // #107747# give menuitems the height of the menubar
330  aItemBottomRight.AdjustY(GetOutputSizePixel().Height()-1 );
331  }
332 
333  // ImplExecute is not modal...
334  // #99071# do not grab the focus, otherwise it will be restored to the menubar
335  // when the frame is reactivated later
336  //GrabFocus();
337  m_pActivePopup->ImplExecute( this, tools::Rectangle( aItemTopLeft, aItemBottomRight ), FloatWinPopupFlags::Down | FloatWinPopupFlags::NoHorzPlacement, m_pMenu, bPreSelectFirst );
338  // does not have a window, if aborted before or if there are no entries
341  else
342  m_pActivePopup = nullptr;
343 }
344 
346 {
347  if ( !m_pActivePopup )
348  return;
349 
350  if( m_pActivePopup->pWindow )
351  if( static_cast<FloatingWindow *>(m_pActivePopup->pWindow.get())->IsInCleanUp() )
352  return; // kill it later
353 
354  if ( m_pActivePopup->bInCallback )
355  m_pActivePopup->bCanceled = true;
356 
357  m_pActivePopup->bInCallback = true;
359  m_pActivePopup->bInCallback = false;
360  // check for pActivePopup, if stopped by deactivate...
361  if ( m_pActivePopup->ImplGetWindow() )
362  {
363  if (mpParentPopup)
364  {
365  for (sal_uInt16 i = 0; i < mpParentPopup->GetItemCount(); ++i)
366  {
367  sal_uInt16 nId = mpParentPopup->GetItemId(i);
368  MenuItemData* pParentItemData = mpParentPopup->GetItemList()->GetData(nId);
369  assert(pParentItemData);
370  pParentItemData->pSubMenu = nullptr;
371  }
372  }
375  m_pActivePopup->pWindow.disposeAndClear();
376  }
377  m_pActivePopup = nullptr;
378 }
379 
380 void MenuBarWindow::PopupClosed( Menu const * pPopup )
381 {
382  if ( pPopup == m_pActivePopup )
383  {
384  KillActivePopup();
385  ChangeHighlightItem( ITEMPOS_INVALID, false, ImplGetFrameWindow()->ImplGetFrameData()->mbHasFocus, false );
386  }
387 }
388 
390 {
391  mbAutoPopup = true;
392  sal_uInt16 nEntry = ImplFindEntry( rMEvt.GetPosPixel() );
393  if ( ( nEntry != ITEMPOS_INVALID ) && !m_pActivePopup )
394  {
395  ChangeHighlightItem( nEntry, false );
396  }
397  else
398  {
399  KillActivePopup();
401  }
402 }
403 
405 {
406 }
407 
409 {
410  if ( rMEvt.IsSynthetic() || rMEvt.IsEnterWindow() )
411  return;
412 
413  if ( rMEvt.IsLeaveWindow() )
414  {
416  Invalidate(); //HighlightItem( nRolloveredItem, false );
417 
419  return;
420  }
421 
422  sal_uInt16 nEntry = ImplFindEntry( rMEvt.GetPosPixel() );
424  {
425  if ( m_nRolloveredItem != nEntry )
426  {
428  Invalidate(); //HighlightItem( nRolloveredItem, false );
429 
430  m_nRolloveredItem = nEntry;
431  Invalidate(); //HighlightItem( nRolloveredItem, true );
432  }
433  return;
434  }
435  m_nRolloveredItem = nEntry;
436 
437  if( m_bIgnoreFirstMove )
438  {
439  m_bIgnoreFirstMove = false;
440  return;
441  }
442 
443  if ( ( nEntry != ITEMPOS_INVALID )
444  && ( nEntry != m_nHighlightedItem ) )
445  ChangeHighlightItem( nEntry, false );
446 }
447 
448 void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool bAllowRestoreFocus, bool bDefaultToDocument)
449 {
450  if( ! m_pMenu )
451  return;
452 
453  // #57934# close active popup if applicable, as TH's background storage works.
454  MenuItemData* pNextData = m_pMenu->pItemList->GetDataFromPos( n );
455  if ( m_pActivePopup && m_pActivePopup->ImplGetWindow() && ( !pNextData || ( m_pActivePopup != pNextData->pSubMenu ) ) )
456  KillActivePopup(); // pActivePopup when applicable without pWin, if Rescheduled in Activate()
457 
458  // activate menubar only ones per cycle...
459  bool bJustActivated = false;
460  if ( ( m_nHighlightedItem == ITEMPOS_INVALID ) && ( n != ITEMPOS_INVALID ) )
461  {
463  // #105406# avoid saving the focus when we already have the focus
464  bool bNoSaveFocus = (this == ImplGetSVData()->mpWinData->mpFocusWin.get());
465 
466  if( m_xSaveFocusId != nullptr )
467  {
469  {
470  m_xSaveFocusId = nullptr;
471  if( !bNoSaveFocus )
472  m_xSaveFocusId = Window::SaveFocus(); // only save focus when initially activated
473  }
474  else {
475  ; // do nothing: we 're activated again from taskpanelist, focus was already saved
476  }
477  }
478  else
479  {
480  if( !bNoSaveFocus )
481  m_xSaveFocusId = Window::SaveFocus(); // only save focus when initially activated
482  }
483  m_pMenu->bInCallback = true; // set here if Activate overridden
484  m_pMenu->Activate();
485  m_pMenu->bInCallback = false;
486  bJustActivated = true;
487  }
488  else if ( ( m_nHighlightedItem != ITEMPOS_INVALID ) && ( n == ITEMPOS_INVALID ) )
489  {
490  m_pMenu->bInCallback = true;
491  m_pMenu->Deactivate();
492  m_pMenu->bInCallback = false;
494  if (!ImplGetSVData()->mpWinData->mbNoSaveFocus)
495  {
496  VclPtr<vcl::Window> xTempFocusId;
498  xTempFocusId = m_xSaveFocusId;
499  m_xSaveFocusId = nullptr;
500 
501  if (bAllowRestoreFocus)
502  {
503  // tdf#115227 the popup is already killed, so temporarily set us as the
504  // focus window, so we could avoid sending superfluous activate events
505  // to top window listeners.
506  if (xTempFocusId || bDefaultToDocument)
508 
509  // #105406# restore focus to document if we could not save focus before
510  if (!xTempFocusId && bDefaultToDocument)
512  else
513  Window::EndSaveFocus(xTempFocusId);
514  }
515  }
516  }
517 
519  {
521  Invalidate(); //HighlightItem( nHighlightedItem, false );
522 
524  }
525 
526  m_nHighlightedItem = n;
527  SAL_WARN_IF( ( m_nHighlightedItem != ITEMPOS_INVALID ) && !m_pMenu->ImplIsVisible( m_nHighlightedItem ), "vcl", "ChangeHighlightItem: Not visible!" );
529  Invalidate(); //HighlightItem( nHighlightedItem, true );
530  else if ( m_nRolloveredItem != ITEMPOS_INVALID )
531  Invalidate(); //HighlightItem( nRolloveredItem, true );
533 
534  if( mbAutoPopup )
535  ImplCreatePopup( bSelectEntry );
536 
537  // #58935# #73659# Focus, if no popup underneath...
538  if ( bJustActivated && !m_pActivePopup )
539  GrabFocus();
540 }
541 
542 static int ImplGetTopDockingAreaHeight( vcl::Window const *pWindow )
543 {
544  // find docking area that is top aligned and return its height
545  // note: dockingareas are direct children of the SystemWindow
546  if( pWindow->ImplGetFrameWindow() )
547  {
548  vcl::Window *pWin = pWindow->ImplGetFrameWindow()->GetWindow( GetWindowType::FirstChild ); //mpWindowImpl->mpFirstChild;
549  while( pWin )
550  {
551  if( pWin->IsSystemWindow() )
552  {
553  vcl::Window *pChildWin = pWin->GetWindow( GetWindowType::FirstChild ); //mpWindowImpl->mpFirstChild;
554  while( pChildWin )
555  {
556  DockingAreaWindow *pDockingArea = nullptr;
557  if ( pChildWin->GetType() == WindowType::DOCKINGAREA )
558  pDockingArea = static_cast< DockingAreaWindow* >( pChildWin );
559 
560  if( pDockingArea && pDockingArea->GetAlign() == WindowAlign::Top &&
561  pDockingArea->IsVisible() && pDockingArea->GetOutputSizePixel().Height() != 0 )
562  {
563  return pDockingArea->GetOutputSizePixel().Height();
564  }
565 
566  pChildWin = pChildWin->GetWindow( GetWindowType::Next ); //mpWindowImpl->mpNext;
567  }
568 
569  }
570 
571  pWin = pWin->GetWindow( GetWindowType::Next ); //mpWindowImpl->mpNext;
572  }
573  }
574  return 0;
575 }
576 
577 static void ImplAddNWFSeparator(vcl::RenderContext& rRenderContext, const Size& rSize, const MenubarValue& rMenubarValue)
578 {
579  // add a separator if
580  // - we have an adjacent docking area
581  // - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx)
582  if (rMenubarValue.maTopDockingAreaHeight
583  && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB
584  && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames)
585  {
586  // note: the menubar only provides the upper (dark) half of it, the rest (bright part) is drawn by the docking area
587 
588  rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor());
589  tools::Rectangle aRect(Point(), rSize);
590  rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
591  }
592 }
593 
594 void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos)
595 {
596  if (!m_pMenu)
597  return;
598 
599  tools::Long nX = 0;
600  size_t nCount = m_pMenu->pItemList->size();
601 
602  Size aOutputSize = GetOutputSizePixel();
603  aOutputSize.AdjustWidth( -(m_aCloseBtn->GetSizePixel().Width()) );
604 
605  for (size_t n = 0; n < nCount; n++)
606  {
607  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
608  if (n == nPos)
609  {
610  if (pData->eType != MenuItemType::SEPARATOR)
611  {
612  // #107747# give menuitems the height of the menubar
613  tools::Rectangle aRect(Point(nX, 1), Size(pData->aSz.Width(), aOutputSize.Height() - 2));
614  rRenderContext.Push(vcl::PushFlags::CLIPREGION);
615  rRenderContext.IntersectClipRegion(aRect);
616  bool bRollover, bHighlight;
617  if (!ImplGetSVData()->maNWFData.mbRolloverMenubar)
618  {
619  bHighlight = true;
620  bRollover = nPos != m_nHighlightedItem;
621  }
622  else
623  {
624  bRollover = nPos == m_nRolloveredItem;
625  bHighlight = nPos == m_nHighlightedItem;
626  }
629  {
630  // draw background (transparency)
631  MenubarValue aControlValue;
632  aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
633 
634  if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
635  Erase(rRenderContext);
636  else
637  {
638  tools::Rectangle aBgRegion(Point(), aOutputSize);
640  ControlState::ENABLED, aControlValue, OUString());
641  }
642 
643  ImplAddNWFSeparator(rRenderContext, aOutputSize, aControlValue);
644 
645  // draw selected item
647  if (bRollover)
648  nState |= ControlState::ROLLOVER;
649  else
650  nState |= ControlState::SELECTED;
652  aRect, nState, aControlValue, OUString() );
653  }
654  else
655  {
656  if (bRollover)
657  rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuBarRolloverColor());
658  else
659  rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
660  rRenderContext.SetLineColor();
661  rRenderContext.DrawRect(aRect);
662  }
663  rRenderContext.Pop();
664 
665  m_pMenu->ImplPaint(rRenderContext, aOutputSize, 0, 0, pData, bHighlight, false, bRollover);
666  }
667  return;
668  }
669 
670  nX += pData->aSz.Width();
671  }
672 }
673 
675 {
676  tools::Rectangle aRect;
677  if( m_pMenu )
678  {
679  tools::Long nX = 0;
680  size_t nCount = m_pMenu->pItemList->size();
681  for ( size_t n = 0; n < nCount; n++ )
682  {
683  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
684  if ( n == nPos )
685  {
686  if ( pData->eType != MenuItemType::SEPARATOR )
687  // #107747# give menuitems the height of the menubar
688  aRect = tools::Rectangle( Point( nX, 1 ), Size( pData->aSz.Width(), GetOutputSizePixel().Height()-2 ) );
689  break;
690  }
691 
692  nX += pData->aSz.Width();
693  }
694  }
695  return aRect;
696 }
697 
698 void MenuBarWindow::KeyInput( const KeyEvent& rKEvent )
699 {
700  if ( !HandleKeyEvent( rKEvent ) )
701  Window::KeyInput( rKEvent );
702 }
703 
704 bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu )
705 {
706  if (!m_pMenu)
707  return false;
708 
709  if (m_pMenu->bInCallback)
710  return true; // swallow
711 
712  bool bDone = false;
713  sal_uInt16 nCode = rKEvent.GetKeyCode().GetCode();
714 
715  if( GetParent() )
716  {
718  {
719  SystemWindow *pSysWin = static_cast<SystemWindow*>(GetParent()->GetWindow( GetWindowType::Client ));
720  if( pSysWin->GetTaskPaneList() )
721  if( pSysWin->GetTaskPaneList()->HandleKeyEvent( rKEvent ) )
722  return true;
723  }
724  }
725 
726  // no key events if native menus
728  {
729  return false;
730  }
731 
732  if ( nCode == KEY_MENU && !rKEvent.GetKeyCode().IsShift() ) // only F10, not Shift-F10
733  {
734  mbAutoPopup = false;
736  {
737  ChangeHighlightItem( 0, false );
738  GrabFocus();
739  }
740  else
741  {
743  m_xSaveFocusId = nullptr;
744  }
745  bDone = true;
746  }
747  else if ( bFromMenu )
748  {
749  if ( ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) ||
750  ( nCode == KEY_HOME ) || ( nCode == KEY_END ) )
751  {
752  sal_uInt16 n = m_nHighlightedItem;
753  if ( n == ITEMPOS_INVALID )
754  {
755  if ( nCode == KEY_LEFT)
756  n = 0;
757  else
758  n = m_pMenu->GetItemCount()-1;
759  }
760 
761  sal_uInt16 nLoop = n;
762 
763  if( nCode == KEY_HOME )
764  { n = sal_uInt16(-1); nLoop = n+1; }
765  if( nCode == KEY_END )
766  { n = m_pMenu->GetItemCount(); nLoop = n-1; }
767 
768  do
769  {
770  if ( nCode == KEY_LEFT || nCode == KEY_END )
771  {
772  if ( n )
773  n--;
774  else
775  n = m_pMenu->GetItemCount()-1;
776  }
777  if ( nCode == KEY_RIGHT || nCode == KEY_HOME )
778  {
779  n++;
780  if ( n >= m_pMenu->GetItemCount() )
781  n = 0;
782  }
783 
785  if (pData->eType != MenuItemType::SEPARATOR &&
786  m_pMenu->ImplIsVisible(n) &&
788  {
789  ChangeHighlightItem( n, true );
790  break;
791  }
792  } while ( n != nLoop );
793  bDone = true;
794  }
795  else if ( nCode == KEY_RETURN )
796  {
798  else
799  if ( !mbAutoPopup )
800  {
801  ImplCreatePopup( true );
802  mbAutoPopup = true;
803  }
804  bDone = true;
805  }
806  else if ( ( nCode == KEY_UP ) || ( nCode == KEY_DOWN ) )
807  {
808  if ( !mbAutoPopup )
809  {
810  ImplCreatePopup( true );
811  mbAutoPopup = true;
812  }
813  bDone = true;
814  }
815  else if ( nCode == KEY_ESCAPE || ( nCode == KEY_F6 && rKEvent.GetKeyCode().IsMod1() ) )
816  {
817  if( m_pActivePopup )
818  {
819  // hide the menu and remove the focus...
820  mbAutoPopup = false;
821  KillActivePopup();
822  }
823 
825 
826  if( nCode == KEY_F6 && rKEvent.GetKeyCode().IsMod1() )
827  {
828  // put focus into document
830  }
831 
832  bDone = true;
833  }
834  }
835 
836  if ( !bDone && ( bFromMenu || rKEvent.GetKeyCode().IsMod2() ) )
837  {
838  sal_Unicode nCharCode = rKEvent.GetCharCode();
839  if ( nCharCode )
840  {
841  size_t nEntry, nDuplicates;
842  MenuItemData* pData = m_pMenu->GetItemList()->SearchItem( nCharCode, rKEvent.GetKeyCode(), nEntry, nDuplicates, m_nHighlightedItem );
843  if ( pData && (nEntry != ITEMPOS_INVALID) )
844  {
845  mbAutoPopup = true;
846  ChangeHighlightItem( nEntry, true );
847  bDone = true;
848  }
849  }
850  }
851 
852  return bDone;
853 }
854 
856 {
857  if (!m_pMenu)
858  return;
859 
860  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
861 
862  Size aOutputSize = GetOutputSizePixel();
863 
864  // no VCL paint if native menus
866  {
868  return;
869  }
870 
871  // Make sure that all actual rendering happens in one go to avoid flicker.
872  vcl::BufferDevice pBuffer(this, rRenderContext);
873 
875  {
876  MenubarValue aMenubarValue;
878 
879  if (!rStyleSettings.GetPersonaHeader().IsEmpty())
880  Erase(*pBuffer);
881  else
882  {
883  tools::Rectangle aCtrlRegion( Point(), aOutputSize );
884 
886  ControlState::ENABLED, aMenubarValue, OUString());
887  }
888 
889  ImplAddNWFSeparator(*pBuffer, aOutputSize, aMenubarValue);
890  }
891 
892  // shrink the area of the buttons
893  aOutputSize.AdjustWidth( -(m_aCloseBtn->GetSizePixel().Width()) );
894 
895  pBuffer->SetFillColor(rStyleSettings.GetMenuColor());
896  m_pMenu->ImplPaint(*pBuffer, aOutputSize, 0);
897 
901  HighlightItem(*pBuffer, m_nRolloveredItem);
902 
903  // in high contrast mode draw a separating line on the lower edge
905  rStyleSettings.GetHighContrastMode())
906  {
908  pBuffer->SetLineColor(COL_WHITE);
909  pBuffer->SetMapMode(MapMode(MapUnit::MapPixel));
910  Size aSize = GetSizePixel();
911  pBuffer->DrawLine(Point(0, aSize.Height() - 1),
912  Point(aSize.Width() - 1, aSize.Height() - 1));
913  pBuffer->Pop();
914  }
915 }
916 
918 {
919  Size aOutSz = GetOutputSizePixel();
920  tools::Long n = aOutSz.Height()-4;
921  tools::Long nX = aOutSz.Width()-3;
922  tools::Long nY = 2;
923 
924  if ( m_aCloseBtn->IsVisible() )
925  {
926  m_aCloseBtn->Hide();
928  Size aTbxSize( m_aCloseBtn->CalcWindowSizePixel() );
929  nX -= aTbxSize.Width();
930  tools::Long nTbxY = (aOutSz.Height() - aTbxSize.Height())/2;
931  m_aCloseBtn->setPosSizePixel(nX, nTbxY, aTbxSize.Width(), aTbxSize.Height());
932  nX -= 3;
933  m_aCloseBtn->Show();
934  }
935  if ( m_aFloatBtn->IsVisible() )
936  {
937  nX -= n;
938  m_aFloatBtn->setPosSizePixel( nX, nY, n, n );
939  }
940  if ( m_aHideBtn->IsVisible() )
941  {
942  nX -= n;
943  m_aHideBtn->setPosSizePixel( nX, nY, n, n );
944  }
945 
948 
949  Invalidate();
950 }
951 
952 sal_uInt16 MenuBarWindow::ImplFindEntry( const Point& rMousePos ) const
953 {
954  if( m_pMenu )
955  {
956  tools::Long nX = 0;
957  size_t nCount = m_pMenu->pItemList->size();
958  for ( size_t n = 0; n < nCount; n++ )
959  {
960  MenuItemData* pData = m_pMenu->pItemList->GetDataFromPos( n );
961  if ( m_pMenu->ImplIsVisible( n ) )
962  {
963  nX += pData->aSz.Width();
964  if ( nX > rMousePos.X() )
965  return static_cast<sal_uInt16>(n);
966  }
967  }
968  }
969  return ITEMPOS_INVALID;
970 }
971 
973 {
974  sal_uInt16 nId = m_nHighlightedItem;
975  if ( rHEvt.GetMode() & HelpEventMode::CONTEXT )
977 
979  if( !ImplHandleHelpEvent( this, m_pMenu, nId, rHEvt, aHighlightRect ) )
980  Window::RequestHelp( rHEvt );
981 }
982 
984 {
985  Window::StateChanged( nType );
986 
989  {
991  Invalidate();
992  }
993  else if (nType == StateChangedType::Enable)
994  {
995  Invalidate();
996  }
997  else if(m_pMenu)
998  {
1000  }
1001 }
1002 
1004 {
1005  if (!m_pMenu)
1006  return;
1007 
1009 
1010  // if the font was changed.
1011  tools::Long nHeight = m_pMenu->ImplCalcSize(this).Height();
1012 
1013  // depending on the native implementation or the displayable flag
1014  // the menubar windows is suppressed (ie, height=0)
1015  if (!static_cast<MenuBar*>(m_pMenu.get())->IsDisplayable() ||
1017  {
1018  nHeight = 0;
1019  }
1020  setPosSizePixel(0, 0, 0, nHeight, PosSizeFlags::Height);
1021  GetParent()->Resize();
1022  Invalidate();
1023  Resize();
1024 
1026 }
1027 
1029 {
1030  Window::ApplySettings(rRenderContext);
1031  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1032 
1033  SetPointFont(rRenderContext, rStyleSettings.GetMenuFont());
1034 
1036  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1037  if (pNativeMenu)
1038  pNativeMenu->ApplyPersona();
1039  if (!rPersonaBitmap.IsEmpty())
1040  {
1041  Wallpaper aWallpaper(rPersonaBitmap);
1042  aWallpaper.SetStyle(WallpaperStyle::TopRight);
1043  aWallpaper.SetColor(Application::GetSettings().GetStyleSettings().GetWorkspaceColor());
1044 
1045  rRenderContext.SetBackground(aWallpaper);
1046  SetPaintTransparent(false);
1048  }
1050  {
1051  rRenderContext.SetBackground(); // background will be drawn by NWF
1052  }
1053  else
1054  {
1055  Wallpaper aWallpaper;
1057  rRenderContext.SetBackground(aWallpaper);
1058  SetPaintTransparent(false);
1060  }
1061 
1062  rRenderContext.SetTextColor(rStyleSettings.GetMenuBarTextColor());
1063  rRenderContext.SetTextFillColor();
1064  rRenderContext.SetLineColor();
1065 }
1066 
1068 {
1071  return;
1072 
1073  AllSettings aSettings(GetSettings());
1074  ImplGetFrame()->UpdateSettings(aSettings); // to update persona
1075  StyleSettings aStyle(aSettings.GetStyleSettings());
1076  Color aHighlightTextColor = ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor;
1077  if (aHighlightTextColor != COL_TRANSPARENT)
1078  {
1079  aStyle.SetMenuHighlightTextColor(aHighlightTextColor);
1080  }
1081  aSettings.SetStyleSettings(aStyle);
1082  GetOutDev()->SetSettings(aSettings);
1083 }
1084 
1086 {
1087  Window::DataChanged( rDCEvt );
1088 
1089  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1091  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1092  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1093  {
1096  LayoutChanged();
1097  }
1098 }
1099 
1101 {
1102  if ( !HasChildPathFocus( true ) )
1103  ChangeHighlightItem( ITEMPOS_INVALID, false, false );
1104 }
1105 
1107 {
1108  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1109  if (pNativeMenu && pNativeMenu->TakeFocus())
1110  return;
1111 
1113  {
1114  mbAutoPopup = false; // do not open menu when activated by focus handling like taskpane cycling
1115  ChangeHighlightItem( 0, false );
1116  }
1117 }
1118 
1119 css::uno::Reference<css::accessibility::XAccessible> MenuBarWindow::CreateAccessible()
1120 {
1121  css::uno::Reference<css::accessibility::XAccessible> xAcc;
1122 
1123  if (m_pMenu)
1124  xAcc = m_pMenu->GetAccessible();
1125 
1126  return xAcc;
1127 }
1128 
1129 sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link<MenuBarButtonCallbackArg&,bool>& i_rLink, const OUString& i_rToolTip )
1130 {
1131  // find first free button id
1132  sal_uInt16 nId = IID_DOCUMENTCLOSE;
1133  std::map< sal_uInt16, AddButtonEntry >::const_iterator it;
1134  do
1135  {
1136  nId++;
1137  it = m_aAddButtons.find( nId );
1138  } while( it != m_aAddButtons.end() && nId < 128 );
1139  SAL_WARN_IF( nId >= 128, "vcl", "too many addbuttons in menubar" );
1140  AddButtonEntry& rNewEntry = m_aAddButtons[nId];
1141  rNewEntry.m_aSelectLink = i_rLink;
1145  LayoutChanged();
1146 
1147  if( m_pMenu->mpSalMenu )
1148  m_pMenu->mpSalMenu->AddMenuBarButton( SalMenuButtonItem( nId, i_rImage, i_rToolTip ) );
1149 
1150  return nId;
1151 }
1152 
1154 {
1155  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( nId );
1156  if( it != m_aAddButtons.end() )
1157  it->second.m_aHighlightLink = rLink;
1158 }
1159 
1161 {
1162  tools::Rectangle aRect;
1163  if( m_aAddButtons.find( nId ) != m_aAddButtons.end() )
1164  {
1165  if( m_pMenu->mpSalMenu )
1166  {
1167  aRect = m_pMenu->mpSalMenu->GetMenuBarButtonRectPixel( nId, ImplGetWindowImpl()->mpFrame );
1168  if( aRect == tools::Rectangle( Point( -1, -1 ), Size( 1, 1 ) ) )
1169  {
1170  // system menu button is somewhere but location cannot be determined
1171  return tools::Rectangle();
1172  }
1173  }
1174 
1175  if( aRect.IsEmpty() )
1176  {
1177  aRect = m_aCloseBtn->GetItemRect(ToolBoxItemId(nId));
1179  aRect.Move( aOffset.X(), aOffset.Y() );
1180  }
1181  }
1182  return aRect;
1183 }
1184 
1186 {
1187  ToolBox::ImplToolItems::size_type nPos = m_aCloseBtn->GetItemPos(ToolBoxItemId(nId));
1188  m_aCloseBtn->RemoveItem(nPos);
1189  m_aAddButtons.erase( nId );
1191  LayoutChanged();
1192 
1193  if( m_pMenu->mpSalMenu )
1194  m_pMenu->mpSalMenu->RemoveMenuBarButton( nId );
1195 }
1196 
1197 bool MenuBarWindow::HandleMenuButtonEvent( sal_uInt16 i_nButtonId )
1198 {
1199  std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( i_nButtonId );
1200  if( it != m_aAddButtons.end() )
1201  {
1203  aArg.nId = it->first;
1204  aArg.bHighlight = true;
1205  return it->second.m_aSelectLink.Call( aArg );
1206  }
1207  return false;
1208 }
1209 
1211 {
1212  /* #i83908# do not use the menubar if it is native or invisible
1213  this relies on MenuBar::ImplCreate setting the height of the menubar
1214  to 0 in this case
1215  */
1216  SalMenu *pNativeMenu = m_pMenu ? m_pMenu->ImplGetSalMenu() : nullptr;
1217  if (pNativeMenu && pNativeMenu->VisibleMenuBar())
1218  return pNativeMenu->CanGetFocus();
1219  return GetSizePixel().Height() > 0;
1220 }
1221 
1222 /* 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:750
tools::Long lastSize
virtual void DrawMenuBar()=0
void SetAlpha(sal_uInt8 nAlpha)
VclPtr< vcl::Window > mpFocusWin
Definition: svdata.hxx:255
bool mbNoSaveFocus
Definition: svdata.hxx:271
css::uno::Reference< css::accessibility::XAccessible > GetAccessible()
Definition: menu.cxx:1279
SAL_DLLPRIVATE void ImplKillLayoutData() const
Definition: menu.cxx:2187
const Color & GetMenuBarRolloverColor() const
const Color & GetMenuBarTextColor() const
const vcl::Font & GetMenuFont() const
SAL_DLLPRIVATE bool ImplCurrentlyHiddenOnGUI(sal_uInt16 nPos) const
Definition: menu.cxx:1169
bool HasCloseButton() const
Definition: menu.hxx:443
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:1120
void PopupClosed(Menu const *pMenu)
std::unique_ptr< sal_Int32[]> pData
bool mbNoDeactivate
Definition: svdata.hxx:270
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
OUString aHelpText
void Erase(vcl::RenderContext &rRenderContext)
Definition: paint.cxx:1596
sal_uIntPtr sal_uLong
long Long
bool HasFloatButton() const
Definition: menu.hxx:444
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:760
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:33
void SetHeight(tools::Long nHeight)
BitmapEx const & GetPersonaHeader() const
ImplSVNWFData maNWFData
Definition: svdata.hxx:404
sal_Int64 n
virtual Size GetSizePixel() const
Definition: window.cxx:2405
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:924
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:1120
void ShowButtons(bool bClose, bool bFloat, bool bHide)
void SetTextFillColor()
Definition: text.cxx:732
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:217
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:1066
void SetType(WindowType nType)
Definition: window2.cxx:991
tools::Rectangle ImplGetItemRect(sal_uInt16 nPos) const
void KillActivePopup()
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1249
bool HasChildPathFocus(bool bSystemWindow=false) const
Definition: window.cxx:3010
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:649
HelpEventMode GetMode() const
Definition: event.hxx:208
constexpr sal_uInt16 KEY_UP
Definition: keycodes.hxx:111
sal_uInt16 AddMenuBarButton(const Image &, const Link< MenuBarButtonCallbackArg &, bool > &, const OUString &)
Add an arbitrary button to the menubar that will appear next to the close button. ...
bool CanGetFocus() const
SAL_DLLPRIVATE Size ImplCalcSize(vcl::Window *pWin)
Definition: menu.cxx:1403
constexpr sal_uInt16 KEY_END
Definition: keycodes.hxx:115
void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link< MenuBarButtonCallbackArg &, bool > &)
sal_uInt16 m_nRolloveredItem
StateChangedType
Definition: window.hxx:289
constexpr tools::Long Width() const
WinBits const WB_NOPOINTERFOCUS
o3tl::strong_int< sal_uInt16, struct ToolBoxItemIdTag > ToolBoxItemId
Definition: toolboxid.hxx:14
Size const & MinCloseButtonSize() const
Size CalcWindowSizePixel()
Definition: toolbox.hxx:525
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:1611
Buffers drawing on a vcl::RenderContext using a VirtualDevice.
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:83
constexpr Point BottomLeft() const
int nCount
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
Definition: menu.cxx:1029
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:822
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
void SetImages(tools::Long nMaxHeight, bool bForce=false)
bool GetHighContrastMode() const
void Pop()
Definition: stack.cxx:92
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:181
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:259
void SetPopupMenu(sal_uInt16 nItemId, PopupMenu *pMenu)
Definition: menu.cxx:713
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:76
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:126
int i
bool bInCallback
In Activate/Deactivate.
Definition: menu.hxx:152
bool IsSystemWindow() const
Definition: window2.cxx:1020
void SetMenu(MenuBar *pMenu)
void SetQuickHelpText(ToolBoxItemId nItemId, const OUString &rText)
Definition: toolbox2.cxx:1345
virtual bool CanGetFocus() const
Definition: salmenu.hxx:82
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:75
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:623
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
MenuItemType eType
virtual void ApplyPersona()
Definition: salvtables.cxx:214
void SetFillColor()
Definition: fill.cxx:29
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:175
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void SetTextColor(const Color &rColor)
Definition: text.cxx:714
void AddPopupModeWindow(vcl::Window *pWindow)
Definition: floatwin.cxx:954
virtual void RequestHelp(const HelpEvent &rHEvt) override
WinBits const WB_SMALLSTYLE
WinBits const WB_RECTSTYLE
virtual void Resize()
Definition: window.cxx:1838
void GrabFocusToDocument()
Definition: window.cxx:2992
Link< MenuBarButtonCallbackArg &, bool > m_aSelectLink
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:295
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1025
SAL_DLLPRIVATE bool ImplIsVisible(sal_uInt16 nPos) const
Definition: menu.cxx:1183
ColorTransparency
MenuItemList * GetItemList() const
Definition: menu.hxx:343
virtual void ShowMenuBar(bool)
Definition: salmenu.hxx:64
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:459
void GrabFocus()
Definition: window.cxx:2982
vcl::Window * GetParent() const
Definition: window2.cxx:1120
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
SAL_DLLPRIVATE vcl::Window * ImplGetWindow() const
Definition: menu.hxx:208
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:2176
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:2669
void RemoveMenuBarButton(sal_uInt16 nId)
void AddEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:303
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:866
Size GetSizePixel() const override
Definition: dockwin.cxx:864
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
MenuItemData * GetDataFromPos(size_t nPos) const
Definition: menu.hxx:115
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:1048
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
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
bool IsVisible() const
Definition: window2.cxx:1125
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:568
sal_Unicode GetCharCode() const
Definition: event.hxx:56
const Size & getMinSize() const
sal_uInt16 GetItemCount() const
Definition: menu.cxx:577
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)
virtual void MouseMove(const MouseEvent &rMEvt) override
void SetAccelKey(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: menu.cxx:760
const Point & GetPosPixel() const
Definition: event.hxx:123
SAL_DLLPRIVATE MenuFloatingWindow * ImplGetFloatingWindow() const
Definition: menu.cxx:2658
BitmapEx GetBitmapEx() const
Definition: Image.cxx:94
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool HasHideButton() const
Definition: menu.hxx:445
constexpr Point BottomRight() const
std::unique_ptr< SalMenu > mpSalMenu
Definition: menu.hxx:157
WindowType GetType() const
Definition: window2.cxx:997
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:2083
void RemoveEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:308
OUString aText
TaskPaneList * GetTaskPaneList()
Definition: syswin.cxx:240
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:2809
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:1700
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:861
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:2781
virtual ~MenuBarWindow() override
sal_Int32 nState
::Color maMenuBarHighlightTextColor
Definition: svdata.hxx:321
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:401
bool IsMod2() const
Definition: keycod.hxx:58
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2190
bool HandleKeyEvent(const KeyEvent &rKEvent, bool bFromMenu=true)
MenuItemBits nBits