LibreOffice Module vcl (master) 1
menu.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
21#include <sal/log.hxx>
22
23#include <comphelper/lok.hxx>
24#include <vcl/dialoghelper.hxx>
25#include <vcl/svapp.hxx>
26#include <vcl/mnemonic.hxx>
27#include <vcl/image.hxx>
28#include <vcl/event.hxx>
29#include <vcl/help.hxx>
31#include <vcl/decoview.hxx>
32#include <vcl/menu.hxx>
33#include <vcl/taskpanelist.hxx>
34#include <vcl/settings.hxx>
36
37#include <salinst.hxx>
38#include <svdata.hxx>
39#include <strings.hrc>
40#include <window.h>
41#include <salmenu.hxx>
42#include <salframe.hxx>
43
44#include "menubarwindow.hxx"
46#include "menuitemlist.hxx"
47
48#include <com/sun/star/uno/Reference.h>
49#include <com/sun/star/lang/XComponent.hpp>
50#include <com/sun/star/accessibility/XAccessible.hpp>
52#include <rtl/ustrbuf.hxx>
53
54#include <configsettings.hxx>
55
56#include <map>
57#include <string_view>
58#include <vector>
59
60namespace vcl
61{
62
64{
65 std::vector< sal_uInt16 > m_aLineItemIds;
66 std::map< sal_uInt16, tools::Rectangle > m_aVisibleItemBoundRects;
67};
68
69}
70
71using namespace vcl;
72
73#define EXTRAITEMHEIGHT 4
74#define SPACE_AROUND_TITLE 4
75
76static bool ImplAccelDisabled()
77{
78 // display of accelerator strings may be suppressed via configuration
79 static int nAccelDisabled = -1;
80
81 if( nAccelDisabled == -1 )
82 {
83 OUString aStr =
85 getValue( "Menu", "SuppressAccelerators" );
86 nAccelDisabled = aStr.equalsIgnoreAsciiCase("true") ? 1 : 0;
87 }
88 return nAccelDisabled == 1;
89}
90
91static void ImplSetMenuItemData( MenuItemData* pData )
92{
93 // convert data
94 if ( !pData->aImage )
96 else if ( pData->aText.isEmpty() )
98 else
100}
101
102namespace {
103
104void ImplClosePopupToolBox( const VclPtr<vcl::Window>& pWin )
105{
106 if ( pWin->GetType() == WindowType::TOOLBOX && ImplGetDockingManager()->IsInPopupMode( pWin ) )
107 {
108 SystemWindow* pFloatingWindow = ImplGetDockingManager()->GetFloatingWindow(pWin);
109 if (pFloatingWindow)
110 static_cast<FloatingWindow*>(pFloatingWindow)->EndPopupMode( FloatWinPopupEndFlags::CloseAll );
111 }
112}
113
114// TODO: Move to common code with the same function in toolbox
115// Draw the ">>" - more indicator at the coordinates
116void lclDrawMoreIndicator(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
117{
118 rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
119 rRenderContext.SetLineColor();
120
121 if (rRenderContext.GetSettings().GetStyleSettings().GetFaceColor().IsDark())
122 rRenderContext.SetFillColor(COL_WHITE);
123 else
124 rRenderContext.SetFillColor(COL_BLACK);
125 float fScaleFactor = rRenderContext.GetDPIScaleFactor();
126
127 int linewidth = 1 * fScaleFactor;
128 int space = 4 * fScaleFactor;
129
130 tools::Long width = 8 * fScaleFactor;
131 tools::Long height = 5 * fScaleFactor;
132
133 //Keep odd b/c drawing code works better
134 if ( height % 2 == 0 )
135 height--;
136
137 tools::Long heightOrig = height;
138
139 tools::Long x = rRect.Left() + (rRect.getOpenWidth() - width)/2 + 1;
140 tools::Long y = rRect.Top() + (rRect.getOpenHeight() - height)/2 + 1;
141 while( height >= 1)
142 {
143 rRenderContext.DrawRect( tools::Rectangle( x, y, x + linewidth, y ) );
144 x += space;
145 rRenderContext.DrawRect( tools::Rectangle( x, y, x + linewidth, y ) );
146 x -= space;
147 y++;
148 if( height <= heightOrig / 2 + 1) x--;
149 else x++;
150 height--;
151 }
152 rRenderContext.Pop();
153}
154
155} // end anonymous namespace
156
157
159 : mpFirstDel(nullptr),
160 pItemList(new MenuItemList),
161 pStartedFrom(nullptr),
162 pWindow(nullptr),
163 nTitleHeight(0),
164 nEventId(nullptr),
165 mnHighlightedItemPos(ITEMPOS_INVALID),
166 nMenuFlags(MenuFlags::NONE),
167 nSelectedId(0),
168 nImgOrChkPos(0),
169 nTextPos(0),
170 bCanceled(false),
171 bInCallback(false),
172 bKilled(false)
173{
174}
175
177{
178 disposeOnce();
179}
180
182{
184
185 // at the window free the reference to the accessible component
186 // and make sure the MenuFloatingWindow knows about our destruction
187 if ( pWindow )
188 {
189 MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get());
190 if( pFloat->pMenu.get() == this )
191 pFloat->pMenu.clear();
192 pWindow->SetAccessible( css::uno::Reference< css::accessibility::XAccessible >() );
193 }
194
195 // dispose accessible components
196 if ( mxAccessible.is() )
197 {
198 css::uno::Reference< css::lang::XComponent> xComponent( mxAccessible, css::uno::UNO_QUERY );
199 if ( xComponent.is() )
200 xComponent->dispose();
201 }
202
203 if ( nEventId )
205
206 // Notify deletion of this menu
207 ImplMenuDelData* pDelData = mpFirstDel;
208 while ( pDelData )
209 {
210 pDelData->mpMenu = nullptr;
211 pDelData = pDelData->mpNext;
212 }
213
214 bKilled = true;
215
216 // tdf#140225 when clearing pItemList, keep SalMenu in sync with
217 // their removal during menu teardown
218 for (size_t n = pItemList->size(); n;)
219 {
220 --n;
221 if (mpSalMenu)
222 mpSalMenu->RemoveItem(n);
223 pItemList->Remove(n);
224 }
225
226 assert(!pItemList->size());
227
228 mpLayoutData.reset();
229
230 // Native-support: destroy SalMenu
231 mpSalMenu.reset();
232
234 pWindow.clear();
236}
237
239{
240 MnemonicGenerator aMnemonicGenerator;
241 size_t n;
242 for ( n = 0; n < pItemList->size(); n++ )
243 {
244 MenuItemData* pData = pItemList->GetDataFromPos( n );
245 if ( ! (pData->nBits & MenuItemBits::NOSELECT ) )
246 aMnemonicGenerator.RegisterMnemonic( pData->aText );
247 }
248 for ( n = 0; n < pItemList->size(); n++ )
249 {
250 MenuItemData* pData = pItemList->GetDataFromPos( n );
251 if ( ! (pData->nBits & MenuItemBits::NOSELECT ) )
252 pData->aText = aMnemonicGenerator.CreateMnemonic( pData->aText );
253 }
254}
255
257{
258 bInCallback = true;
259
260 ImplMenuDelData aDelData( this );
261
263
264 if( !aDelData.isDeleted() )
265 {
266 if ( !aActivateHdl.Call( this ) )
267 {
268 if( !aDelData.isDeleted() )
269 {
270 Menu* pStartMenu = ImplGetStartMenu();
271 if ( pStartMenu && ( pStartMenu != this ) )
272 {
273 pStartMenu->bInCallback = true;
274 // MT 11/01: Call EventListener here? I don't know...
275 pStartMenu->aActivateHdl.Call( this );
276 pStartMenu->bInCallback = false;
277 }
278 }
279 }
280 bInCallback = false;
281 }
282
283 if (!aDelData.isDeleted() && !(nMenuFlags & MenuFlags::NoAutoMnemonics))
285}
286
288{
289 for ( size_t n = pItemList->size(); n; )
290 {
291 MenuItemData* pData = pItemList->GetDataFromPos( --n );
292 if ( pData->bIsTemporary )
293 {
294 if ( ImplGetSalMenu() )
296
297 pItemList->Remove( n );
298 }
299 }
300
301 bInCallback = true;
302
303 ImplMenuDelData aDelData( this );
304
305 Menu* pStartMenu = ImplGetStartMenu();
307
308 if( !aDelData.isDeleted() )
309 {
310 if ( !aDeactivateHdl.Call( this ) )
311 {
312 if( !aDelData.isDeleted() )
313 {
314 if ( pStartMenu && ( pStartMenu != this ) )
315 {
316 pStartMenu->bInCallback = true;
317 pStartMenu->aDeactivateHdl.Call( this );
318 pStartMenu->bInCallback = false;
319 }
320 }
321 }
322 }
323
324 if( !aDelData.isDeleted() )
325 {
326 bInCallback = false;
327 }
328}
329
331{
333 if ( pData && (pData->nBits & MenuItemBits::AUTOCHECK) )
334 {
335 bool bChecked = IsItemChecked( nSelectedId );
336 if ( pData->nBits & MenuItemBits::RADIOCHECK )
337 {
338 if ( !bChecked )
340 }
341 else
342 CheckItem( nSelectedId, !bChecked );
343 }
344
345 // call select
346 ImplSVData* pSVData = ImplGetSVData();
347 pSVData->maAppData.mpActivePopupMenu = nullptr; // if new execute in select()
348 nEventId = Application::PostUserEvent( LINK( this, Menu, ImplCallSelect ) );
349}
350
352{
353 ImplMenuDelData aDelData( this );
354
356 if (aDelData.isDeleted())
357 return;
358 if (aSelectHdl.Call(this))
359 return;
360 if (aDelData.isDeleted())
361 return;
362 Menu* pStartMenu = ImplGetStartMenu();
363 if (!pStartMenu || (pStartMenu == this))
364 return;
365 pStartMenu->nSelectedId = nSelectedId;
366 pStartMenu->sSelectedIdent = sSelectedIdent;
367 pStartMenu->aSelectHdl.Call( this );
368}
369
370#if defined(MACOSX)
371void Menu::ImplSelectWithStart( Menu* pSMenu )
372{
373 auto pOldStartedFrom = pStartedFrom;
374 pStartedFrom = pSMenu;
375 auto pOldStartedStarted = pOldStartedFrom ? pOldStartedFrom->pStartedFrom : VclPtr<Menu>();
376 Select();
377 if( pOldStartedFrom )
378 pOldStartedFrom->pStartedFrom = pOldStartedStarted;
379 pStartedFrom = pOldStartedFrom;
380}
381#endif
382
383void Menu::ImplCallEventListeners( VclEventId nEvent, sal_uInt16 nPos )
384{
385 ImplMenuDelData aDelData( this );
386
387 VclMenuEvent aEvent( this, nEvent, nPos );
388
389 // This is needed by atk accessibility bridge
390 if ( nEvent == VclEventId::MenuHighlight )
391 {
393 }
394
395 if ( !aDelData.isDeleted() )
396 {
397 // Copy the list, because this can be destroyed when calling a Link...
398 std::list<Link<VclMenuEvent&,void>> aCopy( maEventListeners );
399 for ( const auto& rLink : aCopy )
400 {
401 if( std::find(maEventListeners.begin(), maEventListeners.end(), rLink) != maEventListeners.end() )
402 rLink.Call( aEvent );
403 }
404 }
405}
406
408{
409 maEventListeners.push_back( rEventListener );
410}
411
413{
414 maEventListeners.remove( rEventListener );
415}
416
418 const OUString& rStr, Menu* pMenu,
419 size_t nPos, const OUString &rIdent)
420{
421 // put Item in MenuItemList
423 nBits, rStr, pMenu, nPos, rIdent);
424
425 // update native menu
426 if (ImplGetSalMenu() && pData->pSalMenuItem)
427 ImplGetSalMenu()->InsertItem(pData->pSalMenuItem.get(), nPos);
428
429 return pData;
430}
431
432void Menu::InsertItem(sal_uInt16 nItemId, const OUString& rStr, MenuItemBits nItemBits,
433 const OUString &rIdent, sal_uInt16 nPos)
434{
435 SAL_WARN_IF( !nItemId, "vcl", "Menu::InsertItem(): ItemId == 0" );
436 SAL_WARN_IF( GetItemPos( nItemId ) != MENU_ITEM_NOTFOUND, "vcl",
437 "Menu::InsertItem(): ItemId already exists" );
438
439 // if Position > ItemCount, append
440 if ( nPos >= pItemList->size() )
442
443 // put Item in MenuItemList
444 NbcInsertItem(nItemId, nItemBits, rStr, this, nPos, rIdent);
445
446 vcl::Window* pWin = ImplGetWindow();
447 mpLayoutData.reset();
448 if ( pWin )
449 {
450 ImplCalcSize( pWin );
451 if ( pWin->IsVisible() )
452 pWin->Invalidate();
453 }
455}
456
457void Menu::InsertItem(sal_uInt16 nItemId, const Image& rImage,
458 MenuItemBits nItemBits, const OUString &rIdent, sal_uInt16 nPos)
459{
460 InsertItem(nItemId, OUString(), nItemBits, rIdent, nPos);
461 SetItemImage( nItemId, rImage );
462}
463
464void Menu::InsertItem(sal_uInt16 nItemId, const OUString& rStr,
465 const Image& rImage, MenuItemBits nItemBits,
466 const OUString &rIdent, sal_uInt16 nPos)
467{
468 InsertItem(nItemId, rStr, nItemBits, rIdent, nPos);
469 SetItemImage( nItemId, rImage );
470}
471
472void Menu::InsertSeparator(const OUString &rIdent, sal_uInt16 nPos)
473{
474 // do nothing if it's a menu bar
475 if (IsMenuBar())
476 return;
477
478 // if position > ItemCount, append
479 if ( nPos >= pItemList->size() )
481
482 // put separator in item list
483 pItemList->InsertSeparator(rIdent, nPos);
484
485 // update native menu
486 size_t itemPos = ( nPos != MENU_APPEND ) ? nPos : pItemList->size() - 1;
487 MenuItemData *pData = pItemList->GetDataFromPos( itemPos );
488 if( ImplGetSalMenu() && pData && pData->pSalMenuItem )
489 ImplGetSalMenu()->InsertItem( pData->pSalMenuItem.get(), nPos );
490
491 mpLayoutData.reset();
492
494}
495
496void Menu::RemoveItem( sal_uInt16 nPos )
497{
498 bool bRemove = false;
499
500 if ( nPos < GetItemCount() )
501 {
502 // update native menu
503 if( ImplGetSalMenu() )
505
506 pItemList->Remove( nPos );
507 bRemove = true;
508 }
509
510 vcl::Window* pWin = ImplGetWindow();
511 if ( pWin )
512 {
513 ImplCalcSize( pWin );
514 if ( pWin->IsVisible() )
515 pWin->Invalidate();
516 }
517 mpLayoutData.reset();
518
519 if ( bRemove )
521}
522
523static void ImplCopyItem( Menu* pThis, const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 nNewPos )
524{
526
528 return;
529
531 pThis->InsertSeparator( {}, nNewPos );
532 else
533 {
534 sal_uInt16 nId = rMenu.GetItemId( nPos );
535
536 SAL_WARN_IF( pThis->GetItemPos( nId ) != MENU_ITEM_NOTFOUND, "vcl",
537 "Menu::CopyItem(): ItemId already exists" );
538
540
541 if (!pData)
542 return;
543
545 pThis->InsertItem( nId, pData->aText, pData->aImage, pData->nBits, pData->sIdent, nNewPos );
546 else if ( eType == MenuItemType::STRING )
547 pThis->InsertItem( nId, pData->aText, pData->nBits, pData->sIdent, nNewPos );
548 else
549 pThis->InsertItem( nId, pData->aImage, pData->nBits, pData->sIdent, nNewPos );
550
551 if ( rMenu.IsItemChecked( nId ) )
552 pThis->CheckItem( nId );
553 if ( !rMenu.IsItemEnabled( nId ) )
554 pThis->EnableItem( nId, false );
555 pThis->SetHelpId( nId, pData->aHelpId );
556 pThis->SetHelpText( nId, pData->aHelpText );
557 pThis->SetAccelKey( nId, pData->aAccelKey );
558 pThis->SetItemCommand( nId, pData->aCommandStr );
559 pThis->SetHelpCommand( nId, pData->aHelpCommandStr );
560
561 PopupMenu* pSubMenu = rMenu.GetPopupMenu( nId );
562 if ( pSubMenu )
563 {
564 // create auto-copy
565 VclPtr<PopupMenu> pNewMenu = VclPtr<PopupMenu>::Create( *pSubMenu );
566 pThis->SetPopupMenu( nId, pNewMenu );
567 }
568 }
569}
570
572{
573 for ( sal_uInt16 i = GetItemCount(); i; i-- )
574 RemoveItem( 0 );
575}
576
577sal_uInt16 Menu::GetItemCount() const
578{
579 return static_cast<sal_uInt16>(pItemList->size());
580}
581
583{
584 sal_uInt16 nItems = 0;
585 for ( size_t n = pItemList->size(); n; )
586 {
587 if ( ImplIsVisible( --n ) )
588 nItems++;
589 }
590 return nItems;
591}
592
594{
595 for ( size_t n = 0; n < pItemList->size(); n++ )
596 {
597 if ( ImplIsVisible( n ) )
598 return n;
599 }
600 return ITEMPOS_INVALID;
601}
602
603sal_uInt16 Menu::ImplGetPrevVisible( sal_uInt16 nPos ) const
604{
605 for ( size_t n = nPos; n; )
606 {
607 if (ImplIsVisible(--n))
608 return n;
609 }
610 return ITEMPOS_INVALID;
611}
612
613sal_uInt16 Menu::ImplGetNextVisible( sal_uInt16 nPos ) const
614{
615 for ( size_t n = nPos+1; n < pItemList->size(); n++ )
616 {
617 if ( ImplIsVisible( n ) )
618 return n;
619 }
620 return ITEMPOS_INVALID;
621}
622
623sal_uInt16 Menu::GetItemId(sal_uInt16 nPos) const
624{
625 MenuItemData* pData = pItemList->GetDataFromPos( nPos );
626
627 if ( pData )
628 return pData->nId;
629 else
630 return 0;
631}
632
633sal_uInt16 Menu::GetItemId(std::u16string_view rIdent) const
634{
635 for (size_t n = 0; n < pItemList->size(); ++n)
636 {
637 MenuItemData* pData = pItemList->GetDataFromPos(n);
638 if (pData && pData->sIdent == rIdent)
639 return pData->nId;
640 }
641 return MENU_ITEM_NOTFOUND;
642}
643
644sal_uInt16 Menu::GetItemPos( sal_uInt16 nItemId ) const
645{
646 size_t nPos;
647 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
648
649 if ( pData )
650 return static_cast<sal_uInt16>(nPos);
651 else
652 return MENU_ITEM_NOTFOUND;
653}
654
655MenuItemType Menu::GetItemType( sal_uInt16 nPos ) const
656{
657 MenuItemData* pData = pItemList->GetDataFromPos( nPos );
658
659 if ( pData )
660 return pData->eType;
661 else
663}
664
665OUString Menu::GetItemIdent(sal_uInt16 nId) const
666{
667 const MenuItemData* pData = pItemList->GetData(nId);
668 return pData ? pData->sIdent : OUString();
669}
670
671void Menu::SetItemBits( sal_uInt16 nItemId, MenuItemBits nBits )
672{
673 size_t nPos;
674 MenuItemData* pData = pItemList->GetData(nItemId, nPos);
675
676 if (pData && (pData->nBits != nBits))
677 {
678 pData->nBits = nBits;
679
680 // update native menu
681 if (ImplGetSalMenu())
683 }
684}
685
686MenuItemBits Menu::GetItemBits( sal_uInt16 nItemId ) const
687{
689 MenuItemData* pData = pItemList->GetData( nItemId );
690 if ( pData )
691 nBits = pData->nBits;
692 return nBits;
693}
694
695void Menu::SetUserValue(sal_uInt16 nItemId, void* nUserValue, MenuUserDataReleaseFunction aFunc)
696{
697 MenuItemData* pData = pItemList->GetData(nItemId);
698 if (pData)
699 {
700 if (pData->aUserValueReleaseFunc)
701 pData->aUserValueReleaseFunc(pData->nUserValue);
702 pData->aUserValueReleaseFunc = aFunc;
703 pData->nUserValue = nUserValue;
704 }
705}
706
707void* Menu::GetUserValue( sal_uInt16 nItemId ) const
708{
709 MenuItemData* pData = pItemList->GetData( nItemId );
710 return pData ? pData->nUserValue : nullptr;
711}
712
713void Menu::SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu )
714{
715 size_t nPos;
716 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
717
718 // Item does not exist -> return NULL
719 if ( !pData )
720 return;
721
722 // same menu, nothing to do
723 if ( static_cast<PopupMenu*>(pData->pSubMenu.get()) == pMenu )
724 return;
725
726 // remove old menu
727 auto oldSubMenu = pData->pSubMenu;
728
729 // data exchange
730 pData->pSubMenu = pMenu;
731
732 // #112023# Make sure pStartedFrom does not point to invalid (old) data
733 if ( pData->pSubMenu )
734 pData->pSubMenu->pStartedFrom = nullptr;
735
736 // set native submenu
737 if( ImplGetSalMenu() && pData->pSalMenuItem )
738 {
739 if( pMenu )
740 ImplGetSalMenu()->SetSubMenu( pData->pSalMenuItem.get(), pMenu->ImplGetSalMenu(), nPos );
741 else
742 ImplGetSalMenu()->SetSubMenu( pData->pSalMenuItem.get(), nullptr, nPos );
743 }
744
745 oldSubMenu.disposeAndClear();
746
748}
749
750PopupMenu* Menu::GetPopupMenu( sal_uInt16 nItemId ) const
751{
752 MenuItemData* pData = pItemList->GetData( nItemId );
753
754 if ( pData )
755 return static_cast<PopupMenu*>(pData->pSubMenu.get());
756 else
757 return nullptr;
758}
759
760void Menu::SetAccelKey( sal_uInt16 nItemId, const KeyCode& rKeyCode )
761{
762 size_t nPos;
763 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
764
765 if ( !pData )
766 return;
767
768 if ( pData->aAccelKey == rKeyCode )
769 return;
770
771 pData->aAccelKey = rKeyCode;
772
773 // update native menu
774 if( ImplGetSalMenu() && pData->pSalMenuItem )
775 ImplGetSalMenu()->SetAccelerator( nPos, pData->pSalMenuItem.get(), rKeyCode, rKeyCode.GetName() );
776}
777
778KeyCode Menu::GetAccelKey( sal_uInt16 nItemId ) const
779{
780 MenuItemData* pData = pItemList->GetData( nItemId );
781
782 if ( pData )
783 return pData->aAccelKey;
784 else
785 return KeyCode();
786}
787
788KeyEvent Menu::GetActivationKey( sal_uInt16 nItemId ) const
789{
790 KeyEvent aRet;
791 MenuItemData* pData = pItemList->GetData( nItemId );
792 if( pData )
793 {
794 sal_Int32 nPos = pData->aText.indexOf( '~' );
795 if( nPos != -1 && nPos < pData->aText.getLength()-1 )
796 {
797 sal_uInt16 nCode = 0;
798 sal_Unicode cAccel = pData->aText[nPos+1];
799 if( cAccel >= 'a' && cAccel <= 'z' )
800 nCode = KEY_A + (cAccel-'a');
801 else if( cAccel >= 'A' && cAccel <= 'Z' )
802 nCode = KEY_A + (cAccel-'A');
803 else if( cAccel >= '0' && cAccel <= '9' )
804 nCode = KEY_0 + (cAccel-'0');
805
806 aRet = KeyEvent( cAccel, KeyCode( nCode, KEY_MOD2 ) );
807 }
808
809 }
810 return aRet;
811}
812
813void Menu::CheckItem( sal_uInt16 nItemId, bool bCheck )
814{
815 size_t nPos;
816 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
817
818 if ( !pData || pData->bChecked == bCheck )
819 return;
820
821 // if radio-check, then uncheck previous
822 if ( bCheck && (pData->nBits & MenuItemBits::AUTOCHECK) &&
824 {
825 MenuItemData* pGroupData;
826 sal_uInt16 nGroupPos;
827 sal_uInt16 nItemCount = GetItemCount();
828 bool bFound = false;
829
830 nGroupPos = nPos;
831 while ( nGroupPos )
832 {
833 pGroupData = pItemList->GetDataFromPos( nGroupPos-1 );
834 if ( pGroupData->nBits & MenuItemBits::RADIOCHECK )
835 {
836 if ( IsItemChecked( pGroupData->nId ) )
837 {
838 CheckItem( pGroupData->nId, false );
839 bFound = true;
840 break;
841 }
842 }
843 else
844 break;
845 nGroupPos--;
846 }
847
848 if ( !bFound )
849 {
850 nGroupPos = nPos+1;
851 while ( nGroupPos < nItemCount )
852 {
853 pGroupData = pItemList->GetDataFromPos( nGroupPos );
854 if ( pGroupData->nBits & MenuItemBits::RADIOCHECK )
855 {
856 if ( IsItemChecked( pGroupData->nId ) )
857 {
858 CheckItem( pGroupData->nId, false );
859 break;
860 }
861 }
862 else
863 break;
864 nGroupPos++;
865 }
866 }
867 }
868
869 pData->bChecked = bCheck;
870
871 // update native menu
872 if( ImplGetSalMenu() )
873 ImplGetSalMenu()->CheckItem( nPos, bCheck );
874
876}
877
878void Menu::CheckItem( std::u16string_view rIdent , bool bCheck )
879{
880 CheckItem( GetItemId( rIdent ), bCheck );
881}
882
883bool Menu::IsItemChecked( sal_uInt16 nItemId ) const
884{
885 size_t nPos;
886 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
887
888 if ( !pData )
889 return false;
890
891 return pData->bChecked;
892}
893
894void Menu::EnableItem( sal_uInt16 nItemId, bool bEnable )
895{
896 size_t nPos;
897 MenuItemData* pItemData = pItemList->GetData( nItemId, nPos );
898
899 if ( !(pItemData && ( pItemData->bEnabled != bEnable )) )
900 return;
901
902 pItemData->bEnabled = bEnable;
903
904 vcl::Window* pWin = ImplGetWindow();
905 if ( pWin && pWin->IsVisible() )
906 {
907 SAL_WARN_IF(!IsMenuBar(), "vcl", "Menu::EnableItem - Popup visible!" );
908 tools::Long nX = 0;
909 size_t nCount = pItemList->size();
910 for ( size_t n = 0; n < nCount; n++ )
911 {
912 MenuItemData* pData = pItemList->GetDataFromPos( n );
913 if ( n == nPos )
914 {
915 pWin->Invalidate( tools::Rectangle( Point( nX, 0 ), Size( pData->aSz.Width(), pData->aSz.Height() ) ) );
916 break;
917 }
918 nX += pData->aSz.Width();
919 }
920 }
921 // update native menu
922 if( ImplGetSalMenu() )
923 ImplGetSalMenu()->EnableItem( nPos, bEnable );
924
926}
927
928bool Menu::IsItemEnabled( sal_uInt16 nItemId ) const
929{
930 size_t nPos;
931 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
932
933 if ( !pData )
934 return false;
935
936 return pData->bEnabled;
937}
938
939void Menu::ShowItem( sal_uInt16 nItemId, bool bVisible )
940{
941 size_t nPos;
942 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
943
944 SAL_WARN_IF(IsMenuBar() && !bVisible , "vcl", "Menu::ShowItem - ignored for menu bar entries!");
945 if (IsMenuBar() || !pData || (pData->bVisible == bVisible))
946 return;
947
948 vcl::Window* pWin = ImplGetWindow();
949 if ( pWin && pWin->IsVisible() )
950 {
951 SAL_WARN( "vcl", "Menu::ShowItem - ignored for visible popups!" );
952 return;
953 }
954 pData->bVisible = bVisible;
955
956 // update native menu
957 if( ImplGetSalMenu() )
959}
960
961void Menu::SetItemText( sal_uInt16 nItemId, const OUString& rStr )
962{
963 size_t nPos;
964 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
965
966 if ( !pData )
967 return;
968
969 if ( rStr == pData->aText )
970 return;
971
972 pData->aText = rStr;
973 // Clear layout for aText.
974 pData->aTextGlyphs.Invalidate();
976 // update native menu
977 if( ImplGetSalMenu() && pData->pSalMenuItem )
978 ImplGetSalMenu()->SetItemText( nPos, pData->pSalMenuItem.get(), rStr );
979
980 vcl::Window* pWin = ImplGetWindow();
981 mpLayoutData.reset();
982 if (pWin && IsMenuBar())
983 {
984 ImplCalcSize( pWin );
985 if ( pWin->IsVisible() )
986 pWin->Invalidate();
987 }
988
990}
991
992OUString Menu::GetItemText( sal_uInt16 nItemId ) const
993{
994 size_t nPos;
995 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
996
997 if ( pData )
998 return pData->aText;
999
1000 return OUString();
1001}
1002
1003void Menu::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
1004{
1005 size_t nPos;
1006 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
1007
1008 if ( !pData )
1009 return;
1010
1011 pData->aImage = rImage;
1013
1014 // update native menu
1015 if( ImplGetSalMenu() && pData->pSalMenuItem )
1016 ImplGetSalMenu()->SetItemImage( nPos, pData->pSalMenuItem.get(), rImage );
1017}
1018
1019Image Menu::GetItemImage( sal_uInt16 nItemId ) const
1020{
1021 MenuItemData* pData = pItemList->GetData( nItemId );
1022
1023 if ( pData )
1024 return pData->aImage;
1025 else
1026 return Image();
1027}
1028
1029void Menu::SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand )
1030{
1031 size_t nPos;
1032 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
1033
1034 if ( pData )
1035 pData->aCommandStr = rCommand;
1036}
1037
1038OUString Menu::GetItemCommand( sal_uInt16 nItemId ) const
1039{
1040 MenuItemData* pData = pItemList->GetData( nItemId );
1041
1042 if (pData)
1043 return pData->aCommandStr;
1044
1045 return OUString();
1046}
1047
1048void Menu::SetHelpCommand( sal_uInt16 nItemId, const OUString& rStr )
1049{
1050 MenuItemData* pData = pItemList->GetData( nItemId );
1051
1052 if ( pData )
1053 pData->aHelpCommandStr = rStr;
1054}
1055
1056OUString Menu::GetHelpCommand( sal_uInt16 nItemId ) const
1057{
1058 MenuItemData* pData = pItemList->GetData( nItemId );
1059
1060 if ( pData )
1061 return pData->aHelpCommandStr;
1062
1063 return OUString();
1064}
1065
1066void Menu::SetHelpText( sal_uInt16 nItemId, const OUString& rStr )
1067{
1068 MenuItemData* pData = pItemList->GetData( nItemId );
1069
1070 if ( pData )
1071 pData->aHelpText = rStr;
1072}
1073
1074OUString Menu::ImplGetHelpText( sal_uInt16 nItemId ) const
1075{
1076 MenuItemData* pData = pItemList->GetData( nItemId );
1077
1078 if (!pData)
1079 return OUString();
1080
1081 if ( pData->aHelpText.isEmpty() &&
1082 (( !pData->aHelpId.isEmpty() ) || ( !pData->aCommandStr.isEmpty() )))
1083 {
1084 Help* pHelp = Application::GetHelp();
1085 if ( pHelp )
1086 {
1087 if (!pData->aCommandStr.isEmpty())
1088 pData->aHelpText = pHelp->GetHelpText( pData->aCommandStr, static_cast<weld::Widget*>(nullptr) );
1089 if (pData->aHelpText.isEmpty() && !pData->aHelpId.isEmpty())
1090 pData->aHelpText = pHelp->GetHelpText( pData->aHelpId, static_cast<weld::Widget*>(nullptr) );
1091 }
1092 }
1093
1094 //Fallback to Menu::GetAccessibleDescription without reentry to GetHelpText()
1095 if (pData->aHelpText.isEmpty())
1096 return pData->aAccessibleDescription;
1097 return pData->aHelpText;
1098}
1099
1100OUString Menu::GetHelpText( sal_uInt16 nItemId ) const
1101{
1102 return ImplGetHelpText( nItemId );
1103}
1104
1105void Menu::SetTipHelpText( sal_uInt16 nItemId, const OUString& rStr )
1106{
1107 MenuItemData* pData = pItemList->GetData( nItemId );
1108
1109 if ( pData )
1110 pData->aTipHelpText = rStr;
1111}
1112
1113OUString Menu::GetTipHelpText( sal_uInt16 nItemId ) const
1114{
1115 MenuItemData* pData = pItemList->GetData( nItemId );
1116
1117 if ( pData )
1118 return pData->aTipHelpText;
1119
1120 return OUString();
1121}
1122
1123void Menu::SetHelpId( sal_uInt16 nItemId, const OUString& rHelpId )
1124{
1125 MenuItemData* pData = pItemList->GetData( nItemId );
1126
1127 if ( pData )
1128 pData->aHelpId = rHelpId;
1129}
1130
1131OUString Menu::GetHelpId( sal_uInt16 nItemId ) const
1132{
1133 OUString aRet;
1134
1135 MenuItemData* pData = pItemList->GetData( nItemId );
1136
1137 if ( pData )
1138 {
1139 if ( !pData->aHelpId.isEmpty() )
1140 aRet = pData->aHelpId;
1141 else
1142 aRet = pData->aCommandStr;
1143 }
1144
1145 return aRet;
1146}
1147
1148Menu& Menu::operator=( const Menu& rMenu )
1149{
1150 if(this == &rMenu)
1151 return *this;
1152
1153 // clean up
1154 Clear();
1155
1156 // copy items
1157 sal_uInt16 nCount = rMenu.GetItemCount();
1158 for ( sal_uInt16 i = 0; i < nCount; i++ )
1159 ImplCopyItem( this, rMenu, i, MENU_APPEND );
1160
1161 aActivateHdl = rMenu.aActivateHdl;
1163 aSelectHdl = rMenu.aSelectHdl;
1164 aTitleText = rMenu.aTitleText;
1165 nTitleHeight = rMenu.nTitleHeight;
1166
1167 return *this;
1168}
1169
1170// Returns true if the item is completely hidden on the GUI and shouldn't
1171// be possible to interact with
1172bool Menu::ImplCurrentlyHiddenOnGUI(sal_uInt16 nPos) const
1173{
1174 MenuItemData* pData = pItemList->GetDataFromPos(nPos);
1175 if (pData)
1176 {
1177 MenuItemData* pPreviousData = pItemList->GetDataFromPos( nPos - 1 );
1178 if (pPreviousData && pPreviousData->bHiddenOnGUI)
1179 {
1180 return true;
1181 }
1182 }
1183 return false;
1184}
1185
1186bool Menu::ImplIsVisible( sal_uInt16 nPos ) const
1187{
1188 bool bVisible = true;
1189
1190 MenuItemData* pData = pItemList->GetDataFromPos( nPos );
1191 // check general visibility first
1192 if( pData && !pData->bVisible )
1193 bVisible = false;
1194
1195 if ( bVisible && pData && pData->eType == MenuItemType::SEPARATOR )
1196 {
1197 if( nPos == 0 ) // no separator should be shown at the very beginning
1198 bVisible = false;
1199 else
1200 {
1201 // always avoid adjacent separators
1202 size_t nCount = pItemList->size();
1203 size_t n;
1204 MenuItemData* pNextData = nullptr;
1205 // search next visible item
1206 for( n = nPos + 1; n < nCount; n++ )
1207 {
1208 pNextData = pItemList->GetDataFromPos( n );
1209 if( pNextData && pNextData->bVisible )
1210 {
1211 if( pNextData->eType == MenuItemType::SEPARATOR || ImplIsVisible(n) )
1212 break;
1213 }
1214 }
1215 if( n == nCount ) // no next visible item
1216 bVisible = false;
1217 // check for separator
1218 if( pNextData && pNextData->bVisible && pNextData->eType == MenuItemType::SEPARATOR )
1219 bVisible = false;
1220
1221 if( bVisible )
1222 {
1223 for( n = nPos; n > 0; n-- )
1224 {
1225 pNextData = pItemList->GetDataFromPos( n-1 );
1226 if( pNextData && pNextData->bVisible )
1227 {
1228 if( pNextData->eType != MenuItemType::SEPARATOR && ImplIsVisible(n-1) )
1229 break;
1230 }
1231 }
1232 if( n == 0 ) // no previous visible item
1233 bVisible = false;
1234 }
1235 }
1236 }
1237
1238 // not allowed for menubar, as I do not know
1239 // whether a menu-entry will disappear or will appear
1242 {
1243 if( !pData ) // e.g. nPos == ITEMPOS_INVALID
1244 bVisible = false;
1245 else if ( pData->eType != MenuItemType::SEPARATOR ) // separators handled above
1246 {
1247 // tdf#86850 Always display clipboard functions
1248 if ( pData->aCommandStr == ".uno:Cut" || pData->aCommandStr == ".uno:Copy" || pData->aCommandStr == ".uno:Paste" ||
1249 pData->sIdent == ".uno:Cut" || pData->sIdent == ".uno:Copy" || pData->sIdent == ".uno:Paste" )
1250 bVisible = true;
1251 else
1252 // bVisible = pData->bEnabled && ( !pData->pSubMenu || pData->pSubMenu->HasValidEntries( true ) );
1253 bVisible = pData->bEnabled; // do not check submenus as they might be filled at Activate().
1254 }
1255 }
1256
1257 return bVisible;
1258}
1259
1260bool Menu::IsItemPosVisible( sal_uInt16 nItemPos ) const
1261{
1262 return IsMenuVisible() && ImplIsVisible( nItemPos );
1263}
1264
1266{
1267 return pWindow && pWindow->IsReallyVisible();
1268}
1269
1270bool Menu::ImplIsSelectable( sal_uInt16 nPos ) const
1271{
1272 bool bSelectable = true;
1273
1274 MenuItemData* pData = pItemList->GetDataFromPos( nPos );
1275 // check general visibility first
1276 if ( pData && ( pData->nBits & MenuItemBits::NOSELECT ) )
1277 bSelectable = false;
1278
1279 return bSelectable;
1280}
1281
1282css::uno::Reference<css::accessibility::XAccessible> Menu::GetAccessible()
1283{
1284 // Since PopupMenu are sometimes shared by different instances of MenuBar, the mxAccessible member gets
1285 // overwritten and may contain a disposed object when the initial menubar gets set again. So use the
1286 // mxAccessible member only for sub menus.
1287 if (pStartedFrom && pStartedFrom != this)
1288 {
1289 for ( sal_uInt16 i = 0, nCount = pStartedFrom->GetItemCount(); i < nCount; ++i )
1290 {
1291 sal_uInt16 nItemId = pStartedFrom->GetItemId( i );
1292 if ( static_cast< Menu* >( pStartedFrom->GetPopupMenu( nItemId ) ) == this )
1293 {
1294 css::uno::Reference<css::accessibility::XAccessible> xParent = pStartedFrom->GetAccessible();
1295 if ( xParent.is() )
1296 {
1297 css::uno::Reference<css::accessibility::XAccessibleContext> xParentContext( xParent->getAccessibleContext() );
1298 if (xParentContext.is())
1299 return xParentContext->getAccessibleChild( i );
1300 }
1301 }
1302 }
1303 }
1304 else if ( !mxAccessible.is() )
1305 {
1307 if ( pWrapper )
1308 mxAccessible = pWrapper->CreateAccessible(this, IsMenuBar());
1309 }
1310
1311 return mxAccessible;
1312}
1313
1314void Menu::SetAccessible(const css::uno::Reference<css::accessibility::XAccessible>& rxAccessible )
1315{
1316 mxAccessible = rxAccessible;
1317}
1318
1319Size Menu::ImplGetNativeCheckAndRadioSize(vcl::RenderContext const & rRenderContext, tools::Long& rCheckHeight, tools::Long& rRadioHeight ) const
1320{
1321 tools::Long nCheckWidth = 0, nRadioWidth = 0;
1322 rCheckHeight = rRadioHeight = 0;
1323
1324 if (!IsMenuBar())
1325 {
1326 ImplControlValue aVal;
1327 tools::Rectangle aNativeBounds;
1328 tools::Rectangle aNativeContent;
1329
1330 tools::Rectangle aCtrlRegion(tools::Rectangle(Point(), Size(100, 15)));
1332 {
1334 aCtrlRegion, ControlState::ENABLED, aVal,
1335 aNativeBounds, aNativeContent))
1336 {
1337 rCheckHeight = aNativeBounds.GetHeight() - 1;
1338 nCheckWidth = aNativeContent.GetWidth() - 1;
1339 }
1340 }
1342 {
1344 aCtrlRegion, ControlState::ENABLED, aVal,
1345 aNativeBounds, aNativeContent))
1346 {
1347 rRadioHeight = aNativeBounds.GetHeight() - 1;
1348 nRadioWidth = aNativeContent.GetWidth() - 1;
1349 }
1350 }
1351 }
1352 return Size(std::max(nCheckWidth, nRadioWidth), std::max(rCheckHeight, rRadioHeight));
1353}
1354
1355bool Menu::ImplGetNativeSubmenuArrowSize(vcl::RenderContext const & rRenderContext, Size& rArrowSize, tools::Long& rArrowSpacing)
1356{
1357 ImplControlValue aVal;
1358 tools::Rectangle aCtrlRegion(tools::Rectangle(Point(), Size(100, 15)));
1360 {
1361 tools::Rectangle aNativeContent;
1362 tools::Rectangle aNativeBounds;
1364 aCtrlRegion, ControlState::ENABLED,
1365 aVal, aNativeBounds, aNativeContent))
1366 {
1367 Size aSize(aNativeContent.GetWidth(), aNativeContent.GetHeight());
1368 rArrowSize = aSize;
1369 rArrowSpacing = aNativeBounds.GetWidth() - aNativeContent.GetWidth();
1370 return true;
1371 }
1372 }
1373 return false;
1374}
1375
1377{
1378 SAL_WARN_IF( rDel.mpMenu, "vcl", "Menu::ImplAddDel(): cannot add ImplMenuDelData twice !" );
1379 if( !rDel.mpMenu )
1380 {
1381 rDel.mpMenu = this;
1382 rDel.mpNext = mpFirstDel;
1383 mpFirstDel = &rDel;
1384 }
1385}
1386
1388{
1389 rDel.mpMenu = nullptr;
1390 if ( mpFirstDel == &rDel )
1391 {
1392 mpFirstDel = rDel.mpNext;
1393 }
1394 else
1395 {
1397 while ( pData && (pData->mpNext != &rDel) )
1398 pData = pData->mpNext;
1399
1400 SAL_WARN_IF( !pData, "vcl", "Menu::ImplRemoveDel(): ImplMenuDelData not registered !" );
1401 if( pData )
1402 pData->mpNext = rDel.mpNext;
1403 }
1404}
1405
1407{
1408 // | Check/Radio/Image| Text| Accel/Popup|
1409
1410 // for symbols: nFontHeight x nFontHeight
1411 tools::Long nFontHeight = pWin->GetTextHeight();
1412 tools::Long nExtra = nFontHeight/4;
1413
1414 tools::Long nMinMenuItemHeight = nFontHeight;
1415 tools::Long nCheckHeight = 0, nRadioHeight = 0;
1416 Size aMarkSize = ImplGetNativeCheckAndRadioSize(*pWin->GetOutDev(), nCheckHeight, nRadioHeight);
1417 if( aMarkSize.Height() > nMinMenuItemHeight )
1418 nMinMenuItemHeight = aMarkSize.Height();
1419
1420 tools::Long aMaxImgWidth = 0;
1421
1422 const StyleSettings& rSettings = pWin->GetSettings().GetStyleSettings();
1423 if ( rSettings.GetUseImagesInMenus() )
1424 {
1425 if ( 16 > nMinMenuItemHeight )
1426 nMinMenuItemHeight = 16;
1427 for ( size_t i = pItemList->size(); i; )
1428 {
1429 MenuItemData* pData = pItemList->GetDataFromPos( --i );
1430 if ( ImplIsVisible( i )
1431 && ( ( pData->eType == MenuItemType::IMAGE )
1432 || ( pData->eType == MenuItemType::STRINGIMAGE )
1433 )
1434 )
1435 {
1436 Size aImgSz = pData->aImage.GetSizePixel();
1437 if ( aImgSz.Width() > aMaxImgWidth )
1438 aMaxImgWidth = aImgSz.Width();
1439 if ( aImgSz.Height() > nMinMenuItemHeight )
1440 nMinMenuItemHeight = aImgSz.Height();
1441 break;
1442 }
1443 }
1444 }
1445
1446 Size aSz;
1447 tools::Long nMaxWidth = 0;
1448
1449 for ( size_t n = pItemList->size(); n; )
1450 {
1451 MenuItemData* pData = pItemList->GetDataFromPos( --n );
1452
1453 pData->aSz.setHeight( 0 );
1454 pData->aSz.setWidth( 0 );
1455
1456 if ( ImplIsVisible( n ) )
1457 {
1458 tools::Long nWidth = 0;
1459
1460 // Separator
1461 if (!IsMenuBar()&& (pData->eType == MenuItemType::SEPARATOR))
1462 {
1463 pData->aSz.setHeight( 4 );
1464 }
1465
1466 // Image:
1467 if (!IsMenuBar() && ((pData->eType == MenuItemType::IMAGE) || (pData->eType == MenuItemType::STRINGIMAGE)))
1468 {
1469 tools::Long aImgHeight = pData->aImage.GetSizePixel().Height();
1470
1471 aImgHeight += 4; // add a border for native marks
1472 if (aImgHeight > pData->aSz.Height())
1473 pData->aSz.setHeight(aImgHeight);
1474 }
1475
1476 // Check Buttons:
1477 if (!IsMenuBar() && pData->HasCheck())
1478 {
1479 // checks / images take the same place
1480 if( ( pData->eType != MenuItemType::IMAGE ) && ( pData->eType != MenuItemType::STRINGIMAGE ) )
1481 {
1482 nWidth += aMarkSize.Width() + nExtra * 2;
1483 if (aMarkSize.Height() > pData->aSz.Height())
1484 pData->aSz.setHeight(aMarkSize.Height());
1485 }
1486 }
1487
1488 // Text:
1489 if ( (pData->eType == MenuItemType::STRING) || (pData->eType == MenuItemType::STRINGIMAGE) )
1490 {
1491 const SalLayoutGlyphs* pGlyphs = pData->GetTextGlyphs(pWin->GetOutDev());
1492 tools::Long nTextWidth = pWin->GetOutDev()->GetCtrlTextWidth(pData->aText, pGlyphs);
1493 tools::Long nTextHeight = pWin->GetTextHeight() + EXTRAITEMHEIGHT;
1494
1495 if (IsMenuBar())
1496 {
1497 if ( nTextHeight > pData->aSz.Height() )
1498 pData->aSz.setHeight( nTextHeight );
1499
1500 pData->aSz.setWidth( nTextWidth + 4*nExtra );
1501 aSz.AdjustWidth(pData->aSz.Width() );
1502 }
1503 else
1504 pData->aSz.setHeight( std::max( std::max( nTextHeight, pData->aSz.Height() ), nMinMenuItemHeight ) );
1505
1506 nWidth += nTextWidth;
1507 }
1508
1509 // Accel
1510 if (!IsMenuBar()&& pData->aAccelKey.GetCode() && !ImplAccelDisabled())
1511 {
1512 OUString aName = pData->aAccelKey.GetName();
1513 tools::Long nAccWidth = pWin->GetTextWidth( aName );
1514 nAccWidth += nExtra;
1515 nWidth += nAccWidth;
1516 }
1517
1518 // SubMenu?
1519 if (!IsMenuBar() && pData->pSubMenu)
1520 {
1521 if ( nFontHeight > nWidth )
1522 nWidth += nFontHeight;
1523
1524 pData->aSz.setHeight( std::max( std::max( nFontHeight, pData->aSz.Height() ), nMinMenuItemHeight ) );
1525 }
1526
1527 if (!IsMenuBar())
1528 aSz.AdjustHeight(pData->aSz.Height() );
1529
1530 if ( nWidth > nMaxWidth )
1531 nMaxWidth = nWidth;
1532
1533 }
1534 }
1535
1536 // Additional space for title
1537 nTitleHeight = 0;
1538 if (!IsMenuBar() && aTitleText.getLength() > 0) {
1539 // Set expected font
1540 pWin->GetOutDev()->Push(PushFlags::FONT);
1541 vcl::Font aFont = pWin->GetFont();
1542 aFont.SetWeight(WEIGHT_BOLD);
1543 pWin->SetFont(aFont);
1544
1545 // Compute text bounding box
1546 tools::Rectangle aTextBoundRect;
1547 pWin->GetOutDev()->GetTextBoundRect(aTextBoundRect, aTitleText);
1548
1549 // Vertically, one height of char + extra space for decoration
1550 nTitleHeight = aTextBoundRect.GetSize().Height() + 4 * SPACE_AROUND_TITLE ;
1552
1553 tools::Long nWidth = aTextBoundRect.GetSize().Width() + 4 * SPACE_AROUND_TITLE;
1554 pWin->GetOutDev()->Pop();
1555 if ( nWidth > nMaxWidth )
1556 nMaxWidth = nWidth;
1557 }
1558
1559 if (!IsMenuBar())
1560 {
1561 // popup menus should not be wider than half the screen
1562 // except on rather small screens
1563 // TODO: move GetScreenNumber from SystemWindow to Window ?
1564 // currently we rely on internal privileges
1565 unsigned int nDisplayScreen = pWin->ImplGetWindowImpl()->mpFrame->maGeometry.screen();
1566 tools::Rectangle aDispRect( Application::GetScreenPosSizePixel( nDisplayScreen ) );
1567 tools::Long nScreenWidth = aDispRect.GetWidth() >= 800 ? aDispRect.GetWidth() : 800;
1568 if( nMaxWidth > nScreenWidth/2 )
1569 nMaxWidth = nScreenWidth/2;
1570
1571 sal_uInt16 gfxExtra = static_cast<sal_uInt16>(std::max( nExtra, tools::Long(7) )); // #107710# increase space between checkmarks/images/text
1572 nImgOrChkPos = static_cast<sal_uInt16>(nExtra);
1573 tools::Long nImgOrChkWidth = 0;
1574 if( aMarkSize.Height() > 0 ) // NWF case
1575 nImgOrChkWidth = aMarkSize.Height() + nExtra;
1576 else // non NWF case
1577 nImgOrChkWidth = nFontHeight/2 + gfxExtra;
1578 nImgOrChkWidth = std::max( nImgOrChkWidth, aMaxImgWidth + gfxExtra );
1579 nTextPos = static_cast<sal_uInt16>(nImgOrChkPos + nImgOrChkWidth);
1580 nTextPos = nTextPos + gfxExtra;
1581
1582 aSz.setWidth( nTextPos + nMaxWidth + nExtra );
1583 aSz.AdjustWidth(4*nExtra ); // a _little_ more ...
1584
1587 }
1588 else
1589 {
1590 nTextPos = static_cast<sal_uInt16>(2*nExtra);
1591 aSz.setHeight( nFontHeight+6 );
1592
1593 // get menubar height from native methods if supported
1595 {
1596 ImplControlValue aVal;
1597 tools::Rectangle aNativeBounds;
1598 tools::Rectangle aNativeContent;
1599 Point tmp( 0, 0 );
1600 tools::Rectangle aCtrlRegion( tmp, Size( 100, 15 ) );
1603 aCtrlRegion,
1605 aVal,
1606 aNativeBounds,
1607 aNativeContent )
1608 )
1609 {
1610 int nNativeHeight = aNativeBounds.GetHeight();
1611 if( nNativeHeight > aSz.Height() )
1612 aSz.setHeight( nNativeHeight );
1613 }
1614 }
1615
1616 // account for the size of the close button, which actually is a toolbox
1617 // due to NWF this is variable
1618 tools::Long nCloseButtonHeight = static_cast<MenuBarWindow*>(pWindow.get())->MinCloseButtonSize().Height();
1619 if (aSz.Height() < nCloseButtonHeight)
1620 aSz.setHeight( nCloseButtonHeight );
1621 }
1622
1623 return aSz;
1624}
1625
1626static void ImplPaintCheckBackground(vcl::RenderContext & rRenderContext, vcl::Window const & rWindow, const tools::Rectangle& i_rRect, bool i_bHighlight)
1627{
1628 bool bNativeOk = false;
1630 {
1631 ImplControlValue aControlValue;
1632 aControlValue.setTristateVal(ButtonValue::On);
1633 tools::Rectangle r = i_rRect;
1634 r.AdjustBottom(1);
1635
1637 r,
1639 aControlValue,
1640 OUString());
1641 }
1642
1643 if (!bNativeOk)
1644 {
1645 const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
1646 Color aColor( i_bHighlight ? rSettings.GetMenuHighlightTextColor() : rSettings.GetHighlightColor() );
1647 RenderTools::DrawSelectionBackground(rRenderContext, rWindow, i_rRect, 0, i_bHighlight, true, false, nullptr, 2, &aColor);
1648 }
1649}
1650
1651static OUString getShortenedString( const OUString& i_rLong, vcl::RenderContext const & rRenderContext, tools::Long i_nMaxWidth )
1652{
1653 sal_Int32 nPos = -1;
1654 OUString aNonMnem(removeMnemonicFromString(i_rLong, nPos));
1655 aNonMnem = rRenderContext.GetEllipsisString( aNonMnem, i_nMaxWidth, DrawTextFlags::CenterEllipsis);
1656 // re-insert mnemonic
1657 if (nPos != -1)
1658 {
1659 if (nPos < aNonMnem.getLength() && i_rLong[nPos+1] == aNonMnem[nPos])
1660 {
1661 OUString aTmp = OUString::Concat(aNonMnem.subView(0, nPos)) + "~" + aNonMnem.subView(nPos);
1662 aNonMnem = aTmp;
1663 }
1664 }
1665 return aNonMnem;
1666}
1667
1668void Menu::ImplPaintMenuTitle(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) const
1669{
1670 // Save previous graphical settings, set new one
1671 rRenderContext.Push(PushFlags::FONT | PushFlags::FILLCOLOR);
1672 Wallpaper aOldBackground = rRenderContext.GetBackground();
1673
1674 Color aBackgroundColor = rRenderContext.GetSettings().GetStyleSettings().GetMenuBarColor();
1675 rRenderContext.SetBackground(Wallpaper(aBackgroundColor));
1676 rRenderContext.SetFillColor(aBackgroundColor);
1677 vcl::Font aFont = rRenderContext.GetFont();
1678 aFont.SetWeight(WEIGHT_BOLD);
1679 rRenderContext.SetFont(aFont);
1680
1681 // Draw background rectangle
1682 tools::Rectangle aBgRect(rRect);
1683 int nOuterSpaceX = ImplGetSVData()->maNWFData.mnMenuFormatBorderX;
1685 aBgRect.setWidth(aBgRect.getOpenWidth() - 2 * SPACE_AROUND_TITLE - 2 * nOuterSpaceX);
1687 rRenderContext.DrawRect(aBgRect);
1688
1689 // Draw the text centered
1690 Point aTextTopLeft(aBgRect.TopLeft());
1691 tools::Rectangle aTextBoundRect;
1692 rRenderContext.GetTextBoundRect( aTextBoundRect, aTitleText );
1693 aTextTopLeft.AdjustX((aBgRect.getOpenWidth() - aTextBoundRect.GetSize().Width()) / 2 );
1694 aTextTopLeft.AdjustY((aBgRect.GetHeight() - aTextBoundRect.GetSize().Height()) / 2
1695 - aTextBoundRect.Top() );
1696 rRenderContext.DrawText(aTextTopLeft, aTitleText, 0, aTitleText.getLength());
1697
1698 // Restore
1699 rRenderContext.Pop();
1700 rRenderContext.SetBackground(aOldBackground);
1701}
1702
1703void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
1704 sal_uInt16 nBorder, tools::Long nStartY, MenuItemData const * pThisItemOnly,
1705 bool bHighlighted, bool bLayout, bool bRollover) const
1706{
1707 // for symbols: nFontHeight x nFontHeight
1708 tools::Long nFontHeight = rRenderContext.GetTextHeight();
1709 tools::Long nExtra = nFontHeight / 4;
1710
1711 tools::Long nCheckHeight = 0, nRadioHeight = 0;
1712 ImplGetNativeCheckAndRadioSize(rRenderContext, nCheckHeight, nRadioHeight);
1713
1714 DecorationView aDecoView(&rRenderContext);
1715 const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
1716
1717 Point aTopLeft, aTmpPos;
1718
1719 int nOuterSpaceX = 0;
1720 if (!IsMenuBar())
1721 {
1723 aTopLeft.AdjustX(nOuterSpaceX );
1724 aTopLeft.AdjustY(ImplGetSVData()->maNWFData.mnMenuFormatBorderY );
1725 }
1726
1727 // for the computations, use size of the underlying window, not of RenderContext
1728 Size aOutSz(rSize);
1729
1730 size_t nCount = pItemList->size();
1731 if (bLayout)
1732 mpLayoutData->m_aVisibleItemBoundRects.clear();
1733
1734 // Paint title
1735 if (!pThisItemOnly && !IsMenuBar() && nTitleHeight > 0)
1736 ImplPaintMenuTitle(rRenderContext, tools::Rectangle(aTopLeft, aOutSz));
1737
1738 bool bHiddenItems = false; // are any items on the GUI hidden
1739
1740 for (size_t n = 0; n < nCount; n++)
1741 {
1742 MenuItemData* pData = pItemList->GetDataFromPos( n );
1743 if (ImplIsVisible(n) && (!pThisItemOnly || (pData == pThisItemOnly)))
1744 {
1745 if (pThisItemOnly)
1746 {
1747 if (IsMenuBar())
1748 {
1749 if (!ImplGetSVData()->maNWFData.mbRolloverMenubar)
1750 {
1751 if (bRollover)
1752 rRenderContext.SetTextColor(rSettings.GetMenuBarRolloverTextColor());
1753 else if (bHighlighted)
1754 rRenderContext.SetTextColor(rSettings.GetMenuBarHighlightTextColor());
1755 }
1756 else
1757 {
1758 if (bHighlighted)
1759 rRenderContext.SetTextColor(rSettings.GetMenuBarHighlightTextColor());
1760 else if (bRollover)
1761 rRenderContext.SetTextColor(rSettings.GetMenuBarRolloverTextColor());
1762 }
1763 if (!bRollover && !bHighlighted)
1764 rRenderContext.SetTextColor(rSettings.GetMenuBarTextColor());
1765 }
1766 else if (bHighlighted)
1767 rRenderContext.SetTextColor(rSettings.GetMenuHighlightTextColor());
1768 }
1769
1770 Point aPos(aTopLeft);
1771 aPos.AdjustY(nBorder );
1772 aPos.AdjustY(nStartY );
1773
1774 if (aPos.Y() >= 0)
1775 {
1776 tools::Long nTextOffsetY = (pData->aSz.Height() - nFontHeight) / 2;
1777 if (IsMenuBar())
1778 nTextOffsetY += (aOutSz.Height()-pData->aSz.Height()) / 2;
1782
1783 // submenus without items are not disabled when no items are
1784 // contained. The application itself should check for this!
1785 // Otherwise it could happen entries are disabled due to
1786 // asynchronous loading
1787 if (!pData->bEnabled || !pWindow->IsEnabled())
1788 {
1789 nTextStyle |= DrawTextFlags::Disable;
1790 nSymbolStyle |= DrawSymbolFlags::Disable;
1791 nImageStyle |= DrawImageFlags::Disable;
1792 }
1793
1794 // Separator
1795 if (!bLayout && !IsMenuBar() && (pData->eType == MenuItemType::SEPARATOR))
1796 {
1797 bool bNativeOk = false;
1799 {
1801 if (pData->bEnabled && pWindow->IsEnabled())
1803 if (bHighlighted)
1805 Size aSz(pData->aSz);
1806 aSz.setWidth( aOutSz.Width() - 2*nOuterSpaceX );
1807 tools::Rectangle aItemRect(aPos, aSz);
1808 MenupopupValue aVal(nTextPos - GUTTERBORDER, aItemRect);
1810 aItemRect, nState, aVal, OUString());
1811 }
1812 if (!bNativeOk)
1813 {
1814 aTmpPos.setY( aPos.Y() + ((pData->aSz.Height() - 2) / 2) );
1815 aTmpPos.setX( aPos.X() + 2 + nOuterSpaceX );
1816 rRenderContext.SetLineColor(rSettings.GetShadowColor());
1817 rRenderContext.DrawLine(aTmpPos, Point(aOutSz.Width() - 3 - 2 * nOuterSpaceX, aTmpPos.Y()));
1818 aTmpPos.AdjustY( 1 );
1819 rRenderContext.SetLineColor(rSettings.GetLightColor());
1820 rRenderContext.DrawLine(aTmpPos, Point(aOutSz.Width() - 3 - 2 * nOuterSpaceX, aTmpPos.Y()));
1821 rRenderContext.SetLineColor();
1822 }
1823 }
1824
1825 tools::Rectangle aOuterCheckRect(Point(aPos.X()+nImgOrChkPos, aPos.Y()),
1826 Size(pData->aSz.Height(), pData->aSz.Height()));
1827
1828 // CheckMark
1829 if (!bLayout && !IsMenuBar() && pData->HasCheck())
1830 {
1831 // draw selection transparent marker if checked
1832 // onto that either a checkmark or the item image
1833 // will be painted
1834 // however do not do this if native checks will be painted since
1835 // the selection color too often does not fit the theme's check and/or radio
1836
1837 if( (pData->eType != MenuItemType::IMAGE) && (pData->eType != MenuItemType::STRINGIMAGE))
1838 {
1843 {
1844 ControlPart nPart = ((pData->nBits & MenuItemBits::RADIOCHECK)
1847
1849
1850 if (pData->bChecked)
1852
1853 if (pData->bEnabled && pWindow->IsEnabled())
1855
1856 if (bHighlighted)
1858
1859 tools::Long nCtrlHeight = (pData->nBits & MenuItemBits::RADIOCHECK) ? nCheckHeight : nRadioHeight;
1860 aTmpPos.setX( aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - nCtrlHeight) / 2 );
1861 aTmpPos.setY( aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - nCtrlHeight) / 2 );
1862
1863 tools::Rectangle aCheckRect(aTmpPos, Size(nCtrlHeight, nCtrlHeight));
1864 Size aSz(pData->aSz);
1865 aSz.setWidth( aOutSz.Width() - 2 * nOuterSpaceX );
1866 tools::Rectangle aItemRect(aPos, aSz);
1867 MenupopupValue aVal(nTextPos - GUTTERBORDER, aItemRect);
1868 rRenderContext.DrawNativeControl(ControlType::MenuPopup, nPart, aCheckRect,
1869 nState, aVal, OUString());
1870 }
1871 else if (pData->bChecked) // by default do nothing for unchecked items
1872 {
1873 ImplPaintCheckBackground(rRenderContext, *pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted);
1874
1876 Size aSymbolSize;
1877 if (pData->nBits & MenuItemBits::RADIOCHECK)
1878 {
1880 aSymbolSize = Size(nFontHeight / 2, nFontHeight / 2);
1881 }
1882 else
1883 {
1885 aSymbolSize = Size((nFontHeight * 25) / 40, nFontHeight / 2);
1886 }
1887 aTmpPos.setX( aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - aSymbolSize.Width()) / 2 );
1888 aTmpPos.setY( aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - aSymbolSize.Height()) / 2 );
1889 tools::Rectangle aRect(aTmpPos, aSymbolSize);
1890 aDecoView.DrawSymbol(aRect, eSymbol, rRenderContext.GetTextColor(), nSymbolStyle);
1891 }
1892 }
1893 }
1894
1895 // Image:
1896 if (!bLayout && !IsMenuBar() && ((pData->eType == MenuItemType::IMAGE) || (pData->eType == MenuItemType::STRINGIMAGE)))
1897 {
1898 // Don't render an image for a check thing
1899 if (pData->bChecked)
1900 ImplPaintCheckBackground(rRenderContext, *pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted);
1901
1902 Image aImage = pData->aImage;
1903
1904 aTmpPos = aOuterCheckRect.TopLeft();
1905 aTmpPos.AdjustX((aOuterCheckRect.GetWidth() - aImage.GetSizePixel().Width()) / 2 );
1906 aTmpPos.AdjustY((aOuterCheckRect.GetHeight() - aImage.GetSizePixel().Height()) / 2 );
1907 rRenderContext.DrawImage(aTmpPos, aImage, nImageStyle);
1908 }
1909
1910 // Text:
1911 if ((pData->eType == MenuItemType::STRING ) || (pData->eType == MenuItemType::STRINGIMAGE))
1912 {
1913 aTmpPos.setX( aPos.X() + nTextPos );
1914 aTmpPos.setY( aPos.Y() );
1915 aTmpPos.AdjustY(nTextOffsetY );
1916 DrawTextFlags nStyle = nTextStyle | DrawTextFlags::Mnemonic;
1917
1918 if (pData->bIsTemporary)
1919 nStyle |= DrawTextFlags::Disable;
1920 std::vector< tools::Rectangle >* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : nullptr;
1921 OUString* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : nullptr;
1922 if (bLayout)
1923 {
1924 mpLayoutData->m_aLineIndices.push_back(mpLayoutData->m_aDisplayText.getLength());
1925 mpLayoutData->m_aLineItemIds.push_back(pData->nId);
1926 }
1927 // #i47946# with NWF painted menus the background is transparent
1928 // since DrawCtrlText can depend on the background (e.g. for
1929 // DrawTextFlags::Disable), temporarily set a background which
1930 // hopefully matches the NWF background since it is read
1931 // from the system style settings
1932 bool bSetTmpBackground = !rRenderContext.IsBackground()
1934 if (bSetTmpBackground)
1935 {
1936 Color aBg = IsMenuBar() ? rRenderContext.GetSettings().GetStyleSettings().GetMenuBarColor()
1937 : rRenderContext.GetSettings().GetStyleSettings().GetMenuColor();
1938 rRenderContext.SetBackground(Wallpaper(aBg));
1939 }
1940 // how much space is there for the text?
1941 tools::Long nMaxItemTextWidth = aOutSz.Width() - aTmpPos.X() - nExtra - nOuterSpaceX;
1942 if (!IsMenuBar() && pData->aAccelKey.GetCode() && !ImplAccelDisabled())
1943 {
1944 OUString aAccText = pData->aAccelKey.GetName();
1945 nMaxItemTextWidth -= rRenderContext.GetTextWidth(aAccText) + 3 * nExtra;
1946 }
1947 if (!IsMenuBar() && pData->pSubMenu)
1948 {
1949 nMaxItemTextWidth -= nFontHeight - nExtra;
1950 }
1951
1952 OUString aItemText(pData->aText);
1953 pData->bHiddenOnGUI = false;
1954
1955 if (IsMenuBar()) // In case of menubar if we are out of bounds we shouldn't paint the item
1956 {
1957 if (nMaxItemTextWidth < rRenderContext.GetTextWidth(aItemText))
1958 {
1959 aItemText = "";
1960 pData->bHiddenOnGUI = true;
1961 bHiddenItems = true;
1962 }
1963 }
1964 else
1965 {
1966 aItemText = getShortenedString(aItemText, rRenderContext, nMaxItemTextWidth);
1967 pData->bHiddenOnGUI = false;
1968 }
1969
1970 const SalLayoutGlyphs* pGlyphs = pData->GetTextGlyphs(&rRenderContext);
1971 if (aItemText != pData->aText)
1972 // Can't use pre-computed glyphs, item text was
1973 // changed.
1974 pGlyphs = nullptr;
1975 rRenderContext.DrawCtrlText(aTmpPos, aItemText, 0, aItemText.getLength(),
1976 nStyle, pVector, pDisplayText, pGlyphs);
1977 if (bSetTmpBackground)
1978 rRenderContext.SetBackground();
1979 }
1980
1981 // Accel
1982 if (!bLayout && !IsMenuBar() && pData->aAccelKey.GetCode() && !ImplAccelDisabled())
1983 {
1984 OUString aAccText = pData->aAccelKey.GetName();
1985 aTmpPos.setX( aOutSz.Width() - rRenderContext.GetTextWidth(aAccText) );
1986 aTmpPos.AdjustX( -(4 * nExtra) );
1987
1988 aTmpPos.AdjustX( -nOuterSpaceX );
1989 aTmpPos.setY( aPos.Y() );
1990 aTmpPos.AdjustY(nTextOffsetY );
1991 rRenderContext.DrawCtrlText(aTmpPos, aAccText, 0, aAccText.getLength(), nTextStyle);
1992 }
1993
1994 // SubMenu?
1995 if (!bLayout && !IsMenuBar() && pData->pSubMenu)
1996 {
1997 bool bNativeOk = false;
1999 {
2001 Size aTmpSz(0, 0);
2002 tools::Long aSpacing = 0;
2003
2004 if (!ImplGetNativeSubmenuArrowSize(rRenderContext, aTmpSz, aSpacing))
2005 {
2006 aTmpSz = Size(nFontHeight, nFontHeight);
2007 aSpacing = nOuterSpaceX;
2008 }
2009
2010 if (pData->bEnabled && pWindow->IsEnabled())
2012 if (bHighlighted)
2014
2015 aTmpPos.setX( aOutSz.Width() - aTmpSz.Width() - aSpacing - nOuterSpaceX );
2016 aTmpPos.setY( aPos.Y() + ( pData->aSz.Height() - aTmpSz.Height() ) / 2 );
2017 aTmpPos.AdjustY(nExtra / 2 );
2018
2019 tools::Rectangle aItemRect(aTmpPos, aTmpSz);
2020 MenupopupValue aVal(nTextPos - GUTTERBORDER, aItemRect);
2022 aItemRect, nState, aVal, OUString());
2023 }
2024 if (!bNativeOk)
2025 {
2026 aTmpPos.setX( aOutSz.Width() - nFontHeight + nExtra - nOuterSpaceX );
2027 aTmpPos.setY( aPos.Y() );
2028 aTmpPos.AdjustY(nExtra/2 );
2029 aTmpPos.AdjustY((pData->aSz.Height() / 2) - (nFontHeight / 4) );
2030 if (pData->nBits & MenuItemBits::POPUPSELECT)
2031 {
2032 rRenderContext.SetTextColor(rSettings.GetMenuTextColor());
2033 Point aTmpPos2(aPos);
2034 aTmpPos2.setX( aOutSz.Width() - nFontHeight - nFontHeight/4 );
2035 aDecoView.DrawFrame(tools::Rectangle(aTmpPos2, Size(nFontHeight + nFontHeight / 4,
2036 pData->aSz.Height())),
2038 }
2039 aDecoView.DrawSymbol(tools::Rectangle(aTmpPos, Size(nFontHeight / 2, nFontHeight / 2)),
2040 SymbolType::SPIN_RIGHT, rRenderContext.GetTextColor(), nSymbolStyle);
2041 }
2042 }
2043
2044 if (pThisItemOnly && bHighlighted)
2045 {
2046 // This restores the normal menu or menu bar text
2047 // color for when it is no longer highlighted.
2048 if (IsMenuBar())
2049 rRenderContext.SetTextColor(rSettings.GetMenuBarTextColor());
2050 else
2051 rRenderContext.SetTextColor(rSettings.GetMenuTextColor());
2052 }
2053 }
2054 if( bLayout )
2055 {
2056 if (!IsMenuBar())
2057 mpLayoutData->m_aVisibleItemBoundRects[ n ] = tools::Rectangle(aTopLeft, Size(aOutSz.Width(), pData->aSz.Height()));
2058 else
2059 mpLayoutData->m_aVisibleItemBoundRects[ n ] = tools::Rectangle(aTopLeft, pData->aSz);
2060 }
2061 }
2062
2063 if (!IsMenuBar())
2064 aTopLeft.AdjustY(pData->aSz.Height() );
2065 else
2066 aTopLeft.AdjustX(pData->aSz.Width() );
2067 }
2068
2069 // draw "more" (">>") indicator if some items have been hidden as they go out of visible area
2070 if (bHiddenItems)
2071 {
2072 sal_Int32 nSize = nFontHeight;
2073 tools::Rectangle aRectangle(Point(aOutSz.Width() - nSize, (aOutSz.Height() / 2) - (nSize / 2)), Size(nSize, nSize));
2074 lclDrawMoreIndicator(rRenderContext, aRectangle);
2075 }
2076}
2077
2079{
2080 Menu* pStart = this;
2081 while ( pStart && pStart->pStartedFrom && ( pStart->pStartedFrom != pStart ) )
2082 pStart = pStart->pStartedFrom;
2083 return pStart;
2084}
2085
2086void Menu::ImplCallHighlight(sal_uInt16 nItem)
2087{
2088 ImplMenuDelData aDelData( this );
2089
2090 nSelectedId = 0;
2091 sSelectedIdent.clear();
2092 MenuItemData* pData = pItemList->GetDataFromPos(nItem);
2093 if (pData)
2094 {
2095 nSelectedId = pData->nId;
2096 sSelectedIdent = pData->sIdent;
2097 }
2099
2100 if( !aDelData.isDeleted() )
2101 {
2102 nSelectedId = 0;
2103 sSelectedIdent.clear();
2104 }
2105}
2106
2107IMPL_LINK_NOARG(Menu, ImplCallSelect, void*, void)
2108{
2109 nEventId = nullptr;
2110 Select();
2111}
2112
2114{
2115 Menu* pSelMenu = nEventId ? this : nullptr;
2116
2117 for ( size_t n = GetItemList()->size(); n && !pSelMenu; )
2118 {
2120
2121 if ( pData->pSubMenu )
2122 pSelMenu = pData->pSubMenu->ImplFindSelectMenu();
2123 }
2124
2125 return pSelMenu;
2126}
2127
2128Menu* Menu::ImplFindMenu( sal_uInt16 nItemId )
2129{
2130 Menu* pSelMenu = nullptr;
2131
2132 for ( size_t n = GetItemList()->size(); n && !pSelMenu; )
2133 {
2135
2136 if( pData->nId == nItemId )
2137 pSelMenu = this;
2138 else if ( pData->pSubMenu )
2139 pSelMenu = pData->pSubMenu->ImplFindMenu( nItemId );
2140 }
2141
2142 return pSelMenu;
2143}
2144
2145void Menu::RemoveDisabledEntries( bool bRemoveEmptyPopups )
2146{
2147 for ( sal_uInt16 n = 0; n < GetItemCount(); n++ )
2148 {
2149 bool bRemove = false;
2150 MenuItemData* pItem = pItemList->GetDataFromPos( n );
2151 if ( pItem->eType == MenuItemType::SEPARATOR )
2152 {
2153 if ( !n || ( GetItemType( n-1 ) == MenuItemType::SEPARATOR ) )
2154 bRemove = true;
2155 }
2156 else
2157 bRemove = !pItem->bEnabled;
2158
2159 if ( pItem->pSubMenu )
2160 {
2162 if ( bRemoveEmptyPopups && !pItem->pSubMenu->GetItemCount() )
2163 bRemove = true;
2164 }
2165
2166 if ( bRemove )
2167 RemoveItem( n-- );
2168 }
2169
2170 if ( GetItemCount() )
2171 {
2172 sal_uInt16 nLast = GetItemCount() - 1;
2173 MenuItemData* pItem = pItemList->GetDataFromPos( nLast );
2174 if ( pItem->eType == MenuItemType::SEPARATOR )
2175 RemoveItem( nLast );
2176 }
2177 mpLayoutData.reset();
2178}
2179
2181{
2182 if ( ImplGetSalMenu() )
2184}
2185
2187{
2188}
2189
2191{
2192 mpLayoutData.reset();
2193}
2194
2196{
2197 if (!(pWindow && pWindow->IsReallyVisible()))
2198 return;
2199
2200 mpLayoutData.reset(new MenuLayoutData);
2201 if (IsMenuBar())
2202 {
2203 ImplPaint(*pWindow->GetOutDev(), pWindow->GetOutputSizePixel(), 0, 0, nullptr, false, true); // FIXME
2204 }
2205 else
2206 {
2207 MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get());
2209 nullptr, false, true); //FIXME
2210 }
2211}
2212
2213tools::Rectangle Menu::GetCharacterBounds( sal_uInt16 nItemID, tools::Long nIndex ) const
2214{
2215 tools::Long nItemIndex = -1;
2216 if( ! mpLayoutData )
2218 if( mpLayoutData )
2219 {
2220 for( size_t i = 0; i < mpLayoutData->m_aLineItemIds.size(); i++ )
2221 {
2222 if( mpLayoutData->m_aLineItemIds[i] == nItemID )
2223 {
2224 nItemIndex = mpLayoutData->m_aLineIndices[i];
2225 break;
2226 }
2227 }
2228 }
2229 return (mpLayoutData && nItemIndex != -1) ? mpLayoutData->GetCharacterBounds( nItemIndex+nIndex ) : tools::Rectangle();
2230}
2231
2232tools::Long Menu::GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const
2233{
2234 tools::Long nIndex = -1;
2235 rItemID = 0;
2236 if( ! mpLayoutData )
2238 if( mpLayoutData )
2239 {
2240 nIndex = mpLayoutData->GetIndexForPoint( rPoint );
2241 for( size_t i = 0; i < mpLayoutData->m_aLineIndices.size(); i++ )
2242 {
2243 if( mpLayoutData->m_aLineIndices[i] <= nIndex &&
2244 (i == mpLayoutData->m_aLineIndices.size()-1 || mpLayoutData->m_aLineIndices[i+1] > nIndex) )
2245 {
2246 // make index relative to item
2247 nIndex -= mpLayoutData->m_aLineIndices[i];
2248 rItemID = mpLayoutData->m_aLineItemIds[i];
2249 break;
2250 }
2251 }
2252 }
2253 return nIndex;
2254}
2255
2257{
2258 tools::Rectangle aRet;
2259
2260 if (!mpLayoutData )
2262 if (mpLayoutData)
2263 {
2264 std::map< sal_uInt16, tools::Rectangle >::const_iterator it = mpLayoutData->m_aVisibleItemBoundRects.find( nPos );
2265 if( it != mpLayoutData->m_aVisibleItemBoundRects.end() )
2266 aRet = it->second;
2267 }
2268 return aRet;
2269}
2270
2271void Menu::SetAccessibleName( sal_uInt16 nItemId, const OUString& rStr )
2272{
2273 size_t nPos;
2274 MenuItemData* pData = pItemList->GetData( nItemId, nPos );
2275
2276 if (pData && !rStr.equals(pData->aAccessibleName))
2277 {
2278 pData->aAccessibleName = rStr;
2280 }
2281}
2282
2283OUString Menu::GetAccessibleName( sal_uInt16 nItemId ) const
2284{
2285 MenuItemData* pData = pItemList->GetData( nItemId );
2286
2287 if ( pData )
2288 return pData->aAccessibleName;
2289
2290 return OUString();
2291}
2292
2293void Menu::SetAccessibleDescription( sal_uInt16 nItemId, const OUString& rStr )
2294{
2295 MenuItemData* pData = pItemList->GetData( nItemId );
2296
2297 if ( pData )
2298 pData->aAccessibleDescription = rStr;
2299}
2300
2301OUString Menu::GetAccessibleDescription( sal_uInt16 nItemId ) const
2302{
2303 MenuItemData* pData = pItemList->GetData( nItemId );
2304
2305 if (pData && !pData->aAccessibleDescription.isEmpty())
2306 return pData->aAccessibleDescription;
2307
2308 return GetHelpText(nItemId);
2309}
2310
2312{
2313 Menu* pMenu = const_cast<Menu*>(this);
2314 if( pData && pMenu->ImplGetSalMenu() )
2315 {
2317 }
2318}
2319
2320bool Menu::IsHighlighted( sal_uInt16 nItemPos ) const
2321{
2322 bool bRet = false;
2323
2324 if( pWindow )
2325 {
2326 if (IsMenuBar())
2327 bRet = ( nItemPos == static_cast< MenuBarWindow * > (pWindow.get())->GetHighlightedItem() );
2328 else
2329 bRet = ( nItemPos == static_cast< MenuFloatingWindow * > (pWindow.get())->GetHighlightedItem() );
2330 }
2331
2332 return bRet;
2333}
2334
2335void Menu::HighlightItem( sal_uInt16 nItemPos )
2336{
2337 if ( !pWindow )
2338 return;
2339
2340 if (IsMenuBar())
2341 {
2342 MenuBarWindow* pMenuWin = static_cast< MenuBarWindow* >( pWindow.get() );
2343 pMenuWin->SetAutoPopup( false );
2344 pMenuWin->ChangeHighlightItem( nItemPos, false );
2345 }
2346 else
2347 {
2348 static_cast< MenuFloatingWindow* >( pWindow.get() )->ChangeHighlightItem( nItemPos, false );
2349 }
2350}
2351
2353{
2354 // so far just a dynamic_cast, hopefully to be turned into something saner
2355 // at some stage
2356 MenuBarWindow *pWin = dynamic_cast<MenuBarWindow*>(pWindow.get());
2357 //either there is no window (fdo#87663) or it is a MenuBarWindow
2358 assert(!pWindow || pWin);
2359 return pWin;
2360}
2361
2363 : mbCloseBtnVisible(false),
2364 mbFloatBtnVisible(false),
2365 mbHideBtnVisible(false),
2366 mbDisplayable(true)
2367{
2368 mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(true, this);
2369}
2370
2372 : mbCloseBtnVisible(false),
2373 mbFloatBtnVisible(false),
2374 mbHideBtnVisible(false),
2375 mbDisplayable(true)
2376{
2377 mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(true, this);
2378 *this = rMenu;
2379}
2380
2382{
2383 disposeOnce();
2384}
2385
2387{
2388 ImplDestroy( this, true );
2389 Menu::dispose();
2390}
2391
2393{
2394 MenuBarWindow* pMenuWin = getMenuBarWindow();
2395 if (!pMenuWin)
2396 return;
2397 pMenuWin->PopupClosed(pMenu);
2398}
2399
2401{
2402 pWindow->KeyInput(rEvent);
2403}
2404
2406{
2408}
2409
2410void MenuBar::ShowButtons( bool bClose, bool bFloat, bool bHide )
2411{
2412 if ((bClose != mbCloseBtnVisible) ||
2413 (bFloat != mbFloatBtnVisible) ||
2414 (bHide != mbHideBtnVisible))
2415 {
2416 mbCloseBtnVisible = bClose;
2417 mbFloatBtnVisible = bFloat;
2418 mbHideBtnVisible = bHide;
2419 MenuBarWindow* pMenuWin = getMenuBarWindow();
2420 if (pMenuWin)
2421 pMenuWin->ShowButtons(bClose, bFloat, bHide);
2422 }
2423}
2424
2426{
2427 MenuBarWindow* pMenuWin = getMenuBarWindow();
2428 if (pMenuWin)
2429 pMenuWin->LayoutChanged();
2430}
2431
2432void MenuBar::SetDisplayable( bool bDisplayable )
2433{
2434 if( bDisplayable != mbDisplayable )
2435 {
2436 if ( ImplGetSalMenu() )
2437 ImplGetSalMenu()->ShowMenuBar( bDisplayable );
2438
2439 mbDisplayable = bDisplayable;
2440 LayoutChanged();
2441 }
2442}
2443
2445{
2446 VclPtr<MenuBarWindow> pMenuBarWindow = dynamic_cast<MenuBarWindow*>(pWindow);
2447 if (!pMenuBarWindow)
2448 {
2449 pWindow = pMenuBarWindow = VclPtr<MenuBarWindow>::Create( pParent );
2450 }
2451
2452 pMenu->pStartedFrom = nullptr;
2453 pMenu->pWindow = pWindow;
2454 pMenuBarWindow->SetMenu(pMenu);
2455 tools::Long nHeight = pWindow ? pMenu->ImplCalcSize(pWindow).Height() : 0;
2456
2457 // depending on the native implementation or the displayable flag
2458 // the menubar windows is suppressed (ie, height=0)
2459 if (!pMenu->IsDisplayable() || (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar()))
2460 {
2461 nHeight = 0;
2462 }
2463
2464 pMenuBarWindow->SetHeight(nHeight);
2465 return pWindow;
2466}
2467
2468void MenuBar::ImplDestroy( MenuBar* pMenu, bool bDelete )
2469{
2470 vcl::Window *pWindow = pMenu->ImplGetWindow();
2471 if (pWindow && bDelete)
2472 {
2473 MenuBarWindow* pMenuWin = pMenu->getMenuBarWindow();
2474 if (pMenuWin)
2475 pMenuWin->KillActivePopup();
2477 }
2478 pMenu->pWindow = nullptr;
2479 if (pMenu->mpSalMenu) {
2480 pMenu->mpSalMenu->ShowMenuBar(false);
2481 }
2482}
2483
2485{
2486 // No keyboard processing when our menubar is invisible
2487 if (!IsDisplayable())
2488 return false;
2489
2490 // No keyboard processing when system handles the menu.
2491 SalMenu *pNativeMenu = ImplGetSalMenu();
2492 if (pNativeMenu && pNativeMenu->VisibleMenuBar())
2493 {
2494 // Except when the event is the F6 cycle pane event and we can put our
2495 // focus into it (i.e. the gtk3 menubar case but not the mac/unity case
2496 // where it's not part of the application window)
2497 if (!TaskPaneList::IsCycleKey(rKEvent.GetKeyCode()))
2498 return false;
2499 if (!pNativeMenu->CanGetFocus())
2500 return false;
2501 }
2502
2503 bool bDone = false;
2504 // check for enabled, if this method is called from another window...
2505 vcl::Window* pWin = ImplGetWindow();
2506 if (pWin && pWin->IsEnabled() && pWin->IsInputEnabled() && !pWin->IsInModalMode())
2507 {
2508 MenuBarWindow* pMenuWin = getMenuBarWindow();
2509 bDone = pMenuWin && pMenuWin->HandleKeyEvent(rKEvent, false/*bFromMenu*/);
2510 }
2511 return bDone;
2512}
2513
2514void MenuBar::SelectItem(sal_uInt16 nId)
2515{
2516 if (!pWindow)
2517 return;
2518
2519 pWindow->GrabFocus();
2520 nId = GetItemPos( nId );
2521
2522 MenuBarWindow* pMenuWin = getMenuBarWindow();
2523 if (pMenuWin)
2524 {
2525 // #99705# popup the selected menu
2526 pMenuWin->SetAutoPopup( true );
2527 if (ITEMPOS_INVALID != pMenuWin->GetHighlightedItem())
2528 {
2529 pMenuWin->KillActivePopup();
2530 pMenuWin->ChangeHighlightItem( ITEMPOS_INVALID, false );
2531 }
2532 if (nId != ITEMPOS_INVALID)
2533 pMenuWin->ChangeHighlightItem( nId, false );
2534 }
2535}
2536
2537// handler for native menu selection and command events
2539{
2540 if( pMenu )
2541 {
2542 ImplMenuDelData aDelData( this );
2543
2544 pMenu->pStartedFrom = const_cast<Menu*>(this);
2545 pMenu->bInCallback = true;
2546 pMenu->Activate();
2547
2548 if( !aDelData.isDeleted() )
2549 pMenu->bInCallback = false;
2550 }
2551 return true;
2552}
2553
2555{
2556 if( pMenu )
2557 {
2558 ImplMenuDelData aDelData( this );
2559
2560 pMenu->pStartedFrom = const_cast<Menu*>(this);
2561 pMenu->bInCallback = true;
2562 pMenu->Deactivate();
2563 if( !aDelData.isDeleted() )
2564 pMenu->bInCallback = false;
2565 }
2566 return true;
2567}
2568
2569bool MenuBar::HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nHighlightEventId ) const
2570{
2571 if( !pMenu )
2572 pMenu = const_cast<MenuBar*>(this)->ImplFindMenu(nHighlightEventId);
2573 if( pMenu )
2574 {
2575 ImplMenuDelData aDelData( pMenu );
2576
2579
2580 if( !aDelData.isDeleted() )
2581 {
2582 pMenu->mnHighlightedItemPos = pMenu->GetItemPos( nHighlightEventId );
2583 pMenu->nSelectedId = nHighlightEventId;
2584 pMenu->sSelectedIdent = pMenu->GetItemIdent( nHighlightEventId );
2585 pMenu->pStartedFrom = const_cast<MenuBar*>(this);
2586 pMenu->ImplCallHighlight( pMenu->mnHighlightedItemPos );
2587 }
2588 return true;
2589 }
2590 else
2591 return false;
2592}
2593
2594bool Menu::HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nCommandEventId ) const
2595{
2596 if( !pMenu )
2597 pMenu = const_cast<Menu*>(this)->ImplFindMenu(nCommandEventId);
2598 if( pMenu )
2599 {
2600 pMenu->nSelectedId = nCommandEventId;
2601 pMenu->sSelectedIdent = pMenu->GetItemIdent(nCommandEventId);
2602 pMenu->pStartedFrom = const_cast<Menu*>(this);
2603 pMenu->ImplSelect();
2604 return true;
2605 }
2606 else
2607 return false;
2608}
2609
2610sal_uInt16 MenuBar::AddMenuBarButton( const Image& i_rImage, const Link<MenuBarButtonCallbackArg&,bool>& i_rLink, const OUString& i_rToolTip )
2611{
2612 MenuBarWindow* pMenuWin = getMenuBarWindow();
2613 return pMenuWin ? pMenuWin->AddMenuBarButton(i_rImage, i_rLink, i_rToolTip) : 0;
2614}
2615
2617{
2618 MenuBarWindow* pMenuWin = getMenuBarWindow();
2619 if (!pMenuWin)
2620 return;
2621 pMenuWin->SetMenuBarButtonHighlightHdl(nId, rLink);
2622}
2623
2624void MenuBar::RemoveMenuBarButton( sal_uInt16 nId )
2625{
2626 MenuBarWindow* pMenuWin = getMenuBarWindow();
2627 if (!pMenuWin)
2628 return;
2629 pMenuWin->RemoveMenuBarButton(nId);
2630}
2631
2633{
2634 MenuBarWindow* pMenuWin = getMenuBarWindow();
2635 return pMenuWin ? pMenuWin->GetMenuBarButtonRectPixel(nId) : tools::Rectangle();
2636}
2637
2638bool MenuBar::HandleMenuButtonEvent( sal_uInt16 i_nButtonId )
2639{
2640 MenuBarWindow* pMenuWin = getMenuBarWindow();
2641 return pMenuWin && pMenuWin->HandleMenuButtonEvent(i_nButtonId);
2642}
2643
2645{
2646 MenuBar* pMenuBar = const_cast<MenuBar*>(this);
2647 const SalMenu *pNativeMenu = pMenuBar->ImplGetSalMenu();
2648 int nMenubarHeight;
2649 if (pNativeMenu)
2650 nMenubarHeight = pNativeMenu->GetMenuBarHeight();
2651 else
2652 {
2653 vcl::Window* pMenubarWin = GetWindow();
2654 nMenubarHeight = pMenubarWin ? pMenubarWin->GetOutputSizePixel().Height() : 0;
2655 }
2656 return nMenubarHeight;
2657}
2658
2659// bool PopupMenu::bAnyPopupInExecute = false;
2660
2662 return static_cast<MenuFloatingWindow *>(Menu::ImplGetWindow());
2663}
2664
2666{
2667 mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this);
2668}
2669
2671{
2672 mpSalMenu = ImplGetSVData()->mpDefInst->CreateMenu(false, this);
2673 *this = rMenu;
2674}
2675
2677{
2678 disposeOnce();
2679}
2680
2682{
2684 PopupMenu *pPopup = dynamic_cast<PopupMenu*>(pMenu);
2685 if (p && pPopup)
2686 p->KillActivePopup(pPopup);
2687}
2688
2689namespace vcl
2690{
2692 {
2693 return PopupMenu::GetActivePopupMenu() != nullptr;
2694 }
2695}
2696
2698{
2699 ImplSVData* pSVData = ImplGetSVData();
2700 return pSVData->maAppData.mpActivePopupMenu;
2701}
2702
2704{
2705 if ( ImplGetWindow() )
2707}
2708
2709void PopupMenu::SelectItem(sal_uInt16 nId)
2710{
2711 if ( !ImplGetWindow() )
2712 return;
2713
2714 if( nId != ITEMPOS_INVALID )
2715 {
2716 size_t nPos = 0;
2718 if (pData && pData->pSubMenu)
2720 else
2722 }
2723 else
2724 {
2726 pFloat->GrabFocus();
2727
2728 for( size_t nPos = 0; nPos < GetItemList()->size(); nPos++ )
2729 {
2731 if( pData->pSubMenu )
2732 {
2733 pFloat->KillActivePopup();
2734 }
2735 }
2736 pFloat->ChangeHighlightItem( ITEMPOS_INVALID, false );
2737 }
2738}
2739
2740void PopupMenu::SetSelectedEntry( sal_uInt16 nId )
2741{
2742 nSelectedId = nId;
2744}
2745
2746sal_uInt16 PopupMenu::Execute( vcl::Window* pExecWindow, const Point& rPopupPos )
2747{
2748 return Execute( pExecWindow, tools::Rectangle( rPopupPos, rPopupPos ), PopupMenuFlags::ExecuteDown );
2749}
2750
2752{
2754 if ( nFlags & PopupMenuFlags::ExecuteDown )
2755 nPopupModeFlags = FloatWinPopupFlags::Down;
2756 else if ( nFlags & PopupMenuFlags::ExecuteUp )
2757 nPopupModeFlags = FloatWinPopupFlags::Up;
2758 else if ( nFlags & PopupMenuFlags::ExecuteRight )
2759 nPopupModeFlags = FloatWinPopupFlags::Right;
2760 else
2761 nPopupModeFlags = FloatWinPopupFlags::Down;
2762
2763 if (nFlags & PopupMenuFlags::NoMouseUpClose ) // allow popup menus to stay open on mouse button up
2764 nPopupModeFlags |= FloatWinPopupFlags::NoMouseUpClose; // useful if the menu was opened on mousebutton down (eg toolbox configuration)
2765
2766 return nPopupModeFlags;
2767}
2768
2769sal_uInt16 PopupMenu::Execute( vcl::Window* pExecWindow, const tools::Rectangle& rRect, PopupMenuFlags nFlags )
2770{
2771 ENSURE_OR_RETURN( pExecWindow, "PopupMenu::Execute: need a non-NULL window!", 0 );
2772 return ImplExecute( pExecWindow, rRect, lcl_TranslateFlags(nFlags), nullptr, false );
2773}
2774
2776{
2777 // is there still Select?
2778 Menu* pSelect = ImplFindSelectMenu();
2779 if (pSelect)
2780 {
2781 // Select should be called prior to leaving execute in a popup menu!
2783 pSelect->nEventId = nullptr;
2784 pSelect->Select();
2785 }
2786}
2787
2789 FloatWinPopupFlags& nPopupModeFlags, Menu* pSFrom,
2790 bool& bRealExecute, VclPtr<MenuFloatingWindow>& pWin)
2791{
2792 bRealExecute = false;
2793 const sal_uInt16 nItemCount = GetItemCount();
2794 if (!pSFrom && (vcl::IsInPopupMenuExecute() || !nItemCount))
2795 return false;
2796
2797 mpLayoutData.reset();
2798
2799 ImplSVData* pSVData = ImplGetSVData();
2800
2801 pStartedFrom = pSFrom;
2802 nSelectedId = 0;
2803 sSelectedIdent.clear();
2804 bCanceled = false;
2805
2806 VclPtr<vcl::Window> xFocusId;
2807 if ( !pStartedFrom )
2808 {
2809 pSVData->mpWinData->mbNoDeactivate = true;
2810 xFocusId = Window::SaveFocus();
2811 bRealExecute = true;
2812 }
2813 else
2814 {
2815 // assure that only one menu is open at a time
2816 if (pStartedFrom->IsMenuBar() && pSVData->mpWinData->mpFirstFloat)
2819 }
2820
2821 SAL_WARN_IF( ImplGetWindow(), "vcl", "Win?!" );
2822 rRect.SetPos(pParentWin->OutputToScreenPixel(rRect.TopLeft()));
2823
2825 if (bRealExecute)
2826 nPopupModeFlags |= FloatWinPopupFlags::NewLevel;
2827
2828 bInCallback = true; // set it here, if Activate overridden
2829 Activate();
2830 bInCallback = false;
2831
2832 if (pParentWin->isDisposed())
2833 return false;
2834
2835 if ( bCanceled || bKilled )
2836 return false;
2837
2838 if (!nItemCount)
2839 return false;
2840
2841 // The flag MenuFlags::HideDisabledEntries is inherited.
2842 if ( pSFrom )
2843 {
2846 else
2848 }
2849 else
2850 // #102790# context menus shall never show disabled entries
2852
2853 sal_uInt16 nVisibleEntries = ImplGetVisibleItemCount();
2854 if ( !nVisibleEntries )
2855 {
2856 OUString aTmpEntryText(VclResId(SV_RESID_STRING_NOSELECTIONPOSSIBLE));
2857
2858 MenuItemData* pData = NbcInsertItem(0xFFFF, MenuItemBits::NONE, aTmpEntryText, nullptr, 0xFFFF, {});
2859 size_t nPos = 0;
2860 pData = pItemList->GetData( pData->nId, nPos );
2861 assert(pData);
2862 if (pData)
2863 {
2864 pData->bIsTemporary = true;
2865 }
2867 }
2868
2870 if (comphelper::LibreOfficeKit::isActive() && get_id() == "editviewspellmenu")
2871 {
2872 VclPtr<vcl::Window> xNotifierParent = pParentWin->GetParentWithLOKNotifier();
2873 assert(xNotifierParent && xNotifierParent->GetLOKNotifier() && "editview menu without LOKNotifier");
2874 pWin->SetLOKNotifier(xNotifierParent->GetLOKNotifier());
2875 }
2876
2877 if( pSVData->maNWFData.mbFlatMenu )
2878 pWin->SetBorderStyle( WindowBorderStyle::NOBORDER );
2879 else
2880 pWin->SetBorderStyle( pWin->GetBorderStyle() | WindowBorderStyle::MENU );
2881 pWindow = pWin;
2882
2883 Size aSz = ImplCalcSize( pWin );
2884
2885 tools::Rectangle aDesktopRect(pWin->GetDesktopRectPixel());
2887 {
2889 if( ! pDeskW )
2890 pDeskW = pWindow;
2891 Point aDesktopTL(pDeskW->OutputToAbsoluteScreenPixel(rRect.TopLeft()));
2894 }
2895
2896 tools::Long nMaxHeight = aDesktopRect.GetHeight();
2897
2898 //rhbz#1021915. If a menu won't fit in the desired location the default
2899 //mode is to place it somewhere it will fit. e.g. above, left, right. For
2900 //some cases, e.g. menubars, it's desirable to limit the options to
2901 //above/below and force the menu to scroll if it won't fit
2902 if (nPopupModeFlags & FloatWinPopupFlags::NoHorzPlacement)
2903 {
2904 vcl::Window* pRef = pWin;
2905 if ( pRef->GetParent() )
2906 pRef = pRef->GetParent();
2907
2910
2911 tools::Long nHeightAbove = devRect.Top() - aDesktopRect.Top();
2912 tools::Long nHeightBelow = aDesktopRect.Bottom() - devRect.Bottom();
2913 nMaxHeight = std::min(nMaxHeight, std::max(nHeightAbove, nHeightBelow));
2914 }
2915
2916 // In certain cases this might be misdetected with a height of 0, leading to menus not being displayed.
2917 // So assume that the available screen size matches at least the system requirements
2918 SAL_WARN_IF(nMaxHeight < 768, "vcl",
2919 "Available height misdetected as " << nMaxHeight
2920 << "px. Setting to 768px instead.");
2921 nMaxHeight = std::max(nMaxHeight, tools::Long(768));
2922
2924 nMaxHeight -= pParentWin->GetSizePixel().Height();
2925 sal_Int32 nLeft, nTop, nRight, nBottom;
2926 pWindow->GetBorder( nLeft, nTop, nRight, nBottom );
2927 nMaxHeight -= nTop+nBottom;
2928 if ( aSz.Height() > nMaxHeight )
2929 {
2930 pWin->EnableScrollMenu( true );
2931 sal_uInt16 nStart = ImplGetFirstVisible();
2932 sal_uInt16 nEntries = ImplCalcVisEntries( nMaxHeight, nStart );
2933 aSz.setHeight( ImplCalcHeight( nEntries ) );
2934 }
2935
2936 pWin->SetFocusId( xFocusId );
2937 pWin->SetOutputSizePixel( aSz );
2938 return true;
2939}
2940
2941bool PopupMenu::Run(const VclPtr<MenuFloatingWindow>& pWin, const bool bRealExecute, const bool bPreSelectFirst,
2942 const FloatWinPopupFlags nPopupModeFlags, Menu* pSFrom, const tools::Rectangle& rRect)
2943{
2944 SalMenu* pMenu = ImplGetSalMenu();
2945 if (pMenu && bRealExecute && pMenu->ShowNativePopupMenu(pWin, rRect, nPopupModeFlags))
2946 return true;
2947
2948 pWin->StartPopupMode(rRect, nPopupModeFlags);
2949 if (pSFrom)
2950 {
2951 sal_uInt16 aPos;
2952 if (pSFrom->IsMenuBar())
2953 aPos = static_cast<MenuBarWindow *>(pSFrom->pWindow.get())->GetHighlightedItem();
2954 else
2955 aPos = static_cast<MenuFloatingWindow *>(pSFrom->pWindow.get())->GetHighlightedItem();
2956
2957 pWin->SetPosInParent(aPos); // store position to be sent in SUBMENUDEACTIVATE
2959 }
2960
2961 if ( bPreSelectFirst )
2962 {
2963 for (size_t n = 0; n < static_cast<size_t>(GetItemCount()); n++)
2964 {
2965 MenuItemData* pData = pItemList->GetDataFromPos( n );
2966 if ( ( pData->bEnabled
2968 )
2969 && ( pData->eType != MenuItemType::SEPARATOR )
2970 && ImplIsVisible( n )
2971 && ImplIsSelectable( n )
2972 )
2973 {
2974 pWin->ChangeHighlightItem(n, false);
2975 break;
2976 }
2977 }
2978 }
2979
2980 if (bRealExecute)
2981 pWin->Execute();
2982
2983 return false;
2984}
2985
2986void PopupMenu::FinishRun(const VclPtr<MenuFloatingWindow>& pWin, const VclPtr<vcl::Window>& pParentWin, const bool bRealExecute, const bool bIsNativeMenu)
2987{
2988 if (!bRealExecute || pWin->isDisposed())
2989 return;
2990
2991 if (!bIsNativeMenu)
2992 {
2993 VclPtr<vcl::Window> xFocusId = pWin->GetFocusId();
2994 assert(xFocusId == nullptr && "Focus should already be restored by MenuFloatingWindow::End");
2995 pWin->ImplEndPopupMode(FloatWinPopupEndFlags::NONE, xFocusId);
2996
2997 if (nSelectedId) // then clean up .. ( otherwise done by TH )
2998 {
2999 PopupMenu* pSub = pWin->GetActivePopup();
3000 while ( pSub )
3001 {
3003 pSub = pSub->ImplGetFloatingWindow()->GetActivePopup();
3004 }
3005 }
3006 }
3007 else
3008 pWin->StopExecute();
3009
3010 pWin->doShutdown();
3012 ImplClosePopupToolBox(pParentWin);
3014}
3015
3016sal_uInt16 PopupMenu::ImplExecute(const VclPtr<vcl::Window>& pParentWin, const tools::Rectangle& rRect,
3017 FloatWinPopupFlags nPopupModeFlags, Menu* pSFrom, bool bPreSelectFirst)
3018{
3019 // tdf#126054 hold this until after function completes
3020 VclPtr<PopupMenu> xThis(this);
3021 bool bRealExecute = false;
3022 tools::Rectangle aRect(rRect);
3024 if (!PrepareRun(pParentWin, aRect, nPopupModeFlags, pSFrom, bRealExecute, pWin))
3025 return 0;
3026 const bool bNative = Run(pWin, bRealExecute, bPreSelectFirst, nPopupModeFlags, pSFrom, aRect);
3027 FinishRun(pWin, pParentWin, bRealExecute, bNative);
3028 return nSelectedId;
3029}
3030
3031sal_uInt16 PopupMenu::ImplCalcVisEntries( tools::Long nMaxHeight, sal_uInt16 nStartEntry, sal_uInt16* pLastVisible ) const
3032{
3033 nMaxHeight -= 2 * ImplGetFloatingWindow()->GetScrollerHeight();
3034
3035 tools::Long nHeight = 0;
3036 size_t nEntries = pItemList->size();
3037 sal_uInt16 nVisEntries = 0;
3038
3039 if ( pLastVisible )
3040 *pLastVisible = 0;
3041
3042 for ( size_t n = nStartEntry; n < nEntries; n++ )
3043 {
3044 if ( ImplIsVisible( n ) )
3045 {
3046 MenuItemData* pData = pItemList->GetDataFromPos( n );
3047 nHeight += pData->aSz.Height();
3048 if ( nHeight > nMaxHeight )
3049 break;
3050
3051 if ( pLastVisible )
3052 *pLastVisible = n;
3053 nVisEntries++;
3054 }
3055 }
3056 return nVisEntries;
3057}
3058
3059tools::Long PopupMenu::ImplCalcHeight( sal_uInt16 nEntries ) const
3060{
3061 tools::Long nHeight = 0;
3062
3063 sal_uInt16 nFound = 0;
3064 for ( size_t n = 0; ( nFound < nEntries ) && ( n < pItemList->size() ); n++ )
3065 {
3066 if ( ImplIsVisible( static_cast<sal_uInt16>(n) ) )
3067 {
3068 MenuItemData* pData = pItemList->GetDataFromPos( n );
3069 nHeight += pData->aSz.Height();
3070 nFound++;
3071 }
3072 }
3073
3074 nHeight += 2*ImplGetFloatingWindow()->GetScrollerHeight();
3075
3076 return nHeight;
3077}
3078
3079css::uno::Reference<css::awt::XPopupMenu> PopupMenu::CreateMenuInterface()
3080{
3082 if ( pWrapper )
3083 return pWrapper->CreateMenuInterface(this);
3084 return nullptr;
3085}
3086
3088: mpNext( nullptr )
3089, mpMenu( nullptr )
3090{
3091 if( pMenu )
3092 const_cast< Menu* >( pMenu )->ImplAddDel( *this );
3093}
3094
3096{
3097 if( mpMenu )
3098 const_cast< Menu* >( mpMenu.get() )->ImplRemoveDel( *this );
3099}
3100
3101/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawImageFlags
DrawTextFlags
AnyEventRef aEvent
EdgeEntry * mpNext
const StyleSettings & GetStyleSettings() const
static void ImplCallEventListeners(VclSimpleEvent &rEvent)
Send event to all VCL application event listeners.
Definition: svapp.cxx:709
static SAL_DLLPRIVATE unsigned int GetBestScreen(const tools::Rectangle &)
Get the "best" screen.
Definition: svapp.cxx:1303
static unsigned int GetScreenCount()
Get the number of screens available for the display.
Definition: svapp.cxx:1236
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:655
static bool IsUnifiedDisplay()
Determines if the screens that make up a display are separate or form one large display area.
Definition: svapp.cxx:1242
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Post a user event to the default window.
Definition: svapp.cxx:1016
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
Remove user event based on event ID.
Definition: svapp.cxx:1040
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1378
static tools::Rectangle GetScreenPosSizePixel(unsigned int nScreen)
Get a screen's rectangular area.
Definition: svapp.cxx:1277
bool IsDark() const
void DrawSymbol(const tools::Rectangle &rRect, SymbolType eType, const Color &rColor, DrawSymbolFlags nStyle=DrawSymbolFlags::NONE)
Definition: decoview.cxx:768
void DrawFrame(const tools::Rectangle &rRect, const Color &rLeftTopColor, const Color &rRightBottomColor)
Definition: decoview.cxx:811
SystemWindow * GetFloatingWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:371
void EndPopupMode(FloatWinPopupEndFlags nFlags=FloatWinPopupEndFlags::NONE)
Definition: floatwin.cxx:964
Definition: help.hxx:61
virtual OUString GetHelpText(const OUString &aHelpURL, const weld::Widget *pWidget)
Definition: help.cxx:72
Definition: image.hxx:40
Size GetSizePixel() const
Definition: Image.cxx:88
void setTristateVal(ButtonValue nTristate)
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
Class that implements the actual window of the menu bar.
void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus=true, bool bDefaultToDocument=true)
void RemoveMenuBarButton(sal_uInt16 nId)
void PopupClosed(Menu const *pMenu)
sal_uInt16 GetHighlightedItem() const
bool HandleMenuButtonEvent(sal_uInt16 i_nButtonId)
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.
void ShowButtons(bool bClose, bool bFloat, bool bHide)
void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link< MenuBarButtonCallbackArg &, bool > &)
tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId)
void KillActivePopup()
bool HandleKeyEvent(const KeyEvent &rKEvent, bool bFromMenu=true)
void SetAutoPopup(bool bAuto)
bool mbDisplayable
Definition: menu.hxx:411
virtual ~MenuBar() override
Definition: menu.cxx:2381
sal_uInt16 AddMenuBarButton(const Image &, const Link< MenuBarButtonCallbackArg &, bool > &, const OUString &)
Definition: menu.cxx:2610
void LayoutChanged()
Definition: menu.cxx:2425
void ShowButtons(bool bClose, bool bFloat, bool bHide)
Definition: menu.cxx:2410
virtual void ClosePopup(Menu *pMenu) override
Close the 'pStartedFrom' menu window.
Definition: menu.cxx:2392
bool HandleMenuButtonEvent(sal_uInt16 nEventId)
Definition: menu.cxx:2638
SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent &rKEvent)
Definition: menu.cxx:2484
tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId)
Definition: menu.cxx:2632
int GetMenuBarHeight() const
Definition: menu.cxx:2644
bool mbFloatBtnVisible
Definition: menu.hxx:409
bool mbHideBtnVisible
Definition: menu.hxx:410
void SetDisplayable(bool bDisplayable)
Definition: menu.cxx:2432
MenuBarWindow * getMenuBarWindow()
Return the MenuBarWindow.
Definition: menu.cxx:2352
MenuBar()
Definition: menu.cxx:2362
virtual void MenuBarKeyInput(const KeyEvent &rEvent) override
Forward the KeyInput call to the MenuBar.
Definition: menu.cxx:2400
bool IsDisplayable() const
Definition: menu.hxx:460
void SetMenuBarButtonHighlightHdl(sal_uInt16 nId, const Link< MenuBarButtonCallbackArg &, bool > &)
Definition: menu.cxx:2616
virtual void dispose() override
Definition: menu.cxx:2386
virtual void SelectItem(sal_uInt16 nId) override
Definition: menu.cxx:2514
static SAL_DLLPRIVATE VclPtr< vcl::Window > ImplCreate(vcl::Window *pParent, vcl::Window *pWindow, MenuBar *pMenu)
Definition: menu.cxx:2444
bool HandleMenuHighlightEvent(Menu *pMenu, sal_uInt16 nEventId) const
Definition: menu.cxx:2569
void ShowCloseButton(bool bShow)
Definition: menu.cxx:2405
bool mbCloseBtnVisible
Definition: menu.hxx:408
static SAL_DLLPRIVATE void ImplDestroy(MenuBar *pMenu, bool bDelete)
Definition: menu.cxx:2468
void RemoveMenuBarButton(sal_uInt16 nId)
Definition: menu.cxx:2624
Class that implements the actual window of the floating menu.
PopupMenu * GetActivePopup() const
sal_uInt16 GetScrollerHeight() const
void ChangeHighlightItem(sal_uInt16 n, bool bStartPopupTimer)
void KillActivePopup(PopupMenu *pThisOnly=nullptr)
tools::Long ImplGetStartY() const
Get a negative pixel offset for an offset menu.
size_t size() const
MenuItemData * GetData(sal_uInt16 nSVId, size_t &rPos) const
MenuItemData * GetDataFromPos(size_t nPos) const
Definition: menu.hxx:116
bool IsHighlighted(sal_uInt16 nItemPos) const
Definition: menu.cxx:2320
SAL_DLLPRIVATE Menu * ImplFindSelectMenu()
Definition: menu.cxx:2113
Menu & operator=(const Menu &rMenu)
Definition: menu.cxx:1148
SAL_DLLPRIVATE void ImplCallEventListeners(VclEventId nEvent, sal_uInt16 nPos)
Definition: menu.cxx:383
bool IsItemChecked(sal_uInt16 nItemId) const
Definition: menu.cxx:883
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &rxAccessible)
Definition: menu.cxx:1314
void SetItemImage(sal_uInt16 nItemId, const Image &rImage)
Definition: menu.cxx:1003
virtual void MenuBarKeyInput(const KeyEvent &rEvent)
Forward the KeyInput call to the MenuBar.
Definition: menu.cxx:2186
bool bKilled
Killed.
Definition: menu.hxx:153
SAL_DLLPRIVATE SalMenu * ImplGetSalMenu()
Definition: menu.hxx:181
void Activate()
Definition: menu.cxx:256
void ShowItem(sal_uInt16 nItemId, bool bVisible=true)
Definition: menu.cxx:939
css::uno::Reference< css::accessibility::XAccessible > mxAccessible
Definition: menu.hxx:155
const OUString & get_id() const
Get the ID of the window.
Definition: menu.hxx:396
sal_uInt16 nImgOrChkPos
Definition: menu.hxx:148
SAL_DLLPRIVATE OUString ImplGetHelpText(sal_uInt16 nItemId) const
Definition: menu.cxx:1074
bool HandleMenuActivateEvent(Menu *pMenu) const
Definition: menu.cxx:2538
Link< Menu *, bool > aActivateHdl
Definition: menu.hxx:130
void AddEventListener(const Link< VclMenuEvent &, void > &rEventListener)
Definition: menu.cxx:407
std::unique_ptr< SalMenu > mpSalMenu
Definition: menu.hxx:157
void InsertSeparator(const OUString &rIdent={}, sal_uInt16 nPos=MENU_APPEND)
Definition: menu.cxx:472
void SetItemText(sal_uInt16 nItemId, const OUString &rStr)
Definition: menu.cxx:961
OUString GetItemText(sal_uInt16 nItemId) const
Definition: menu.cxx:992
SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const
Definition: menu.cxx:593
sal_uInt16 nTextPos
Definition: menu.hxx:149
virtual bool IsMenuBar() const =0
MenuItemBits GetItemBits(sal_uInt16 nItemId) const
Definition: menu.cxx:686
MenuItemType GetItemType(sal_uInt16 nPos) const
Definition: menu.cxx:655
SAL_DLLPRIVATE Menu * ImplFindMenu(sal_uInt16 nId)
Definition: menu.cxx:2128
SAL_DLLPRIVATE bool ImplCurrentlyHiddenOnGUI(sal_uInt16 nPos) const
Definition: menu.cxx:1172
css::uno::Reference< css::accessibility::XAccessible > GetAccessible()
Definition: menu.cxx:1282
void HighlightItem(sal_uInt16 nItemPos)
Definition: menu.cxx:2335
void Select()
Definition: menu.cxx:351
VclPtr< Menu > pStartedFrom
Definition: menu.hxx:127
SAL_DLLPRIVATE void ImplAddDel(ImplMenuDelData &rDel)
Definition: menu.cxx:1376
bool HandleMenuDeActivateEvent(Menu *pMenu) const
Definition: menu.cxx:2554
OUString GetItemCommand(sal_uInt16 nItemId) const
Definition: menu.cxx:1038
sal_uInt16 GetCurItemId() const
Definition: menu.hxx:258
void SetHelpId(sal_uInt16 nItemId, const OUString &rHelpId)
Definition: menu.cxx:1123
SAL_DLLPRIVATE void ImplPaintMenuTitle(vcl::RenderContext &, const tools::Rectangle &rRect) const
Definition: menu.cxx:1668
OUString GetAccessibleName(sal_uInt16 nItemId) const
Definition: menu.cxx:2283
OUString sSelectedIdent
Definition: menu.hxx:145
OUString aTitleText
Definition: menu.hxx:138
bool bCanceled
Terminated during a callback.
Definition: menu.hxx:151
tools::Long GetIndexForPoint(const Point &rPoint, sal_uInt16 &rItemID) const
Definition: menu.cxx:2232
SAL_DLLPRIVATE Menu * ImplGetStartMenu()
Definition: menu.cxx:2078
void SetAccessibleName(sal_uInt16 nItemId, const OUString &rStr)
Definition: menu.cxx:2271
bool IsItemPosVisible(sal_uInt16 nItemPos) const
Definition: menu.cxx:1260
OUString GetAccessibleDescription(sal_uInt16 nItemId) const
Definition: menu.cxx:2301
ImplSVEvent * nEventId
Definition: menu.hxx:141
KeyEvent GetActivationKey(sal_uInt16 nItemId) const
Definition: menu.cxx:788
SAL_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const
Definition: menu.cxx:582
void Clear()
Definition: menu.cxx:571
void RemoveEventListener(const Link< VclMenuEvent &, void > &rEventListener)
Definition: menu.cxx:412
vcl::KeyCode GetAccelKey(sal_uInt16 nItemId) const
Definition: menu.cxx:778
void RemoveDisabledEntries(bool bRemoveEmptyPopups=false)
Definition: menu.cxx:2145
SAL_DLLPRIVATE void ImplFillLayoutData() const
Definition: menu.cxx:2195
SAL_DLLPRIVATE void ImplKillLayoutData() const
Definition: menu.cxx:2190
SAL_DLLPRIVATE Size ImplCalcSize(vcl::Window *pWin)
Definition: menu.cxx:1406
void CheckItem(sal_uInt16 nItemId, bool bCheck=true)
Definition: menu.cxx:813
static SAL_DLLPRIVATE bool ImplGetNativeSubmenuArrowSize(vcl::RenderContext const &rRenderContext, Size &rArrowSize, tools::Long &rArrowSpacing)
Definition: menu.cxx:1355
OUString GetHelpId(sal_uInt16 nItemId) const
Definition: menu.cxx:1131
SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize(vcl::RenderContext const &rRenderContext, tools::Long &rCheckHeight, tools::Long &rRadioHeight) const
Definition: menu.cxx:1319
void UpdateNativeMenu()
Definition: menu.cxx:2180
sal_uInt16 GetItemId(sal_uInt16 nPos) const
Definition: menu.cxx:623
vcl::Window * GetWindow() const
Definition: menu.hxx:370
void SetAccessibleDescription(sal_uInt16 nItemId, const OUString &rStr)
Definition: menu.cxx:2293
void SetUserValue(sal_uInt16 nItemId, void *nUserValue, MenuUserDataReleaseFunction aFunc=nullptr)
Definition: menu.cxx:695
void SetAccelKey(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: menu.cxx:760
SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible(sal_uInt16 nPos) const
Definition: menu.cxx:613
tools::Rectangle GetCharacterBounds(sal_uInt16 nItemId, tools::Long nIndex) const
Definition: menu.cxx:2213
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:1703
SAL_DLLPRIVATE bool ImplIsSelectable(sal_uInt16 nPos) const
Definition: menu.cxx:1270
SAL_DLLPRIVATE MenuItemData * NbcInsertItem(sal_uInt16 nId, MenuItemBits nBits, const OUString &rStr, Menu *pMenu, size_t nPos, const OUString &rIdent)
Definition: menu.cxx:417
bool IsMenuVisible() const
Definition: menu.cxx:1265
void Deactivate()
Definition: menu.cxx:287
Link< Menu *, bool > aDeactivateHdl
Definition: menu.hxx:131
Image GetItemImage(sal_uInt16 nItemId) const
Definition: menu.cxx:1019
void SetTipHelpText(sal_uInt16 nItemId, const OUString &rString)
Definition: menu.cxx:1105
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
Definition: menu.cxx:1029
bool HandleMenuCommandEvent(Menu *pMenu, sal_uInt16 nEventId) const
Definition: menu.cxx:2594
PopupMenu * GetPopupMenu(sal_uInt16 nItemId) const
Definition: menu.cxx:750
tools::Rectangle GetBoundingRectangle(sal_uInt16 nItemPos) const
Definition: menu.cxx:2256
void GetSystemMenuData(SystemMenuData *pData) const
Definition: menu.cxx:2311
bool IsItemEnabled(sal_uInt16 nItemId) const
Definition: menu.cxx:928
SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible(sal_uInt16 nPos) const
Definition: menu.cxx:603
OUString GetItemIdent(sal_uInt16 nItemId) const
Definition: menu.cxx:665
SAL_DLLPRIVATE bool ImplIsVisible(sal_uInt16 nPos) const
Definition: menu.cxx:1186
VclPtr< vcl::Window > pWindow
Definition: menu.hxx:128
virtual ~Menu() override
Definition: menu.cxx:176
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
Definition: menu.cxx:894
SAL_DLLPRIVATE void ImplCallHighlight(sal_uInt16 nHighlightItem)
Definition: menu.cxx:2086
MenuFlags nMenuFlags
Definition: menu.hxx:143
sal_uInt16 nTitleHeight
Definition: menu.hxx:139
SAL_DLLPRIVATE void ImplRemoveDel(ImplMenuDelData &rDel)
Definition: menu.cxx:1387
void RemoveItem(sal_uInt16 nPos)
Definition: menu.cxx:496
void SetPopupMenu(sal_uInt16 nItemId, PopupMenu *pMenu)
Definition: menu.cxx:713
Menu()
The Menu constructor is protected.
Definition: menu.cxx:158
void * GetUserValue(sal_uInt16 nItemId) const
Definition: menu.cxx:707
void SetItemBits(sal_uInt16 nItemId, MenuItemBits nBits)
Definition: menu.cxx:671
sal_uInt16 nSelectedId
Definition: menu.hxx:144
void SetHelpCommand(sal_uInt16 nItemId, const OUString &rString)
Definition: menu.cxx:1048
void SetHelpText(sal_uInt16 nItemId, const OUString &rString)
Definition: menu.cxx:1066
void CreateAutoMnemonics()
Definition: menu.cxx:238
bool bInCallback
In Activate/Deactivate.
Definition: menu.hxx:152
SAL_DLLPRIVATE void ImplSelect()
Definition: menu.cxx:330
ImplMenuDelData * mpFirstDel
Definition: menu.hxx:125
void InsertItem(sal_uInt16 nItemId, const OUString &rStr, MenuItemBits nItemBits=MenuItemBits::NONE, const OUString &rIdent={}, sal_uInt16 nPos=MENU_APPEND)
Definition: menu.cxx:432
std::unique_ptr< vcl::MenuLayoutData > mpLayoutData
Definition: menu.hxx:156
Link< Menu *, bool > aSelectHdl
Definition: menu.hxx:132
OUString GetHelpText(sal_uInt16 nItemId) const
Definition: menu.cxx:1100
MenuItemList * GetItemList() const
Definition: menu.hxx:343
OUString GetTipHelpText(sal_uInt16 nItemId) const
Definition: menu.cxx:1113
OUString GetHelpCommand(sal_uInt16 nItemId) const
Definition: menu.cxx:1056
sal_uInt16 GetItemPos(sal_uInt16 nItemId) const
Definition: menu.cxx:644
sal_uInt16 GetItemCount() const
Definition: menu.cxx:577
SAL_DLLPRIVATE vcl::Window * ImplGetWindow() const
Definition: menu.hxx:208
std::unique_ptr< MenuItemList > pItemList
Definition: menu.hxx:126
sal_uInt16 mnHighlightedItemPos
Definition: menu.hxx:142
virtual void dispose() override
Definition: menu.cxx:181
std::list< Link< VclMenuEvent &, void > > maEventListeners
Definition: menu.hxx:134
void RegisterMnemonic(const OUString &rKey)
OUString CreateMnemonic(const OUString &rKey)
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
tools::Long GetCtrlTextWidth(const OUString &rStr, const SalLayoutGlyphs *pLayoutCache=nullptr) const
Definition: text.cxx:2306
void DrawCtrlText(const Point &rPos, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, DrawTextFlags nStyle=DrawTextFlags::Mnemonic, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr)
Definition: text.cxx:2162
const vcl::Font & GetFont() const
Definition: outdev.hxx:529
float GetDPIScaleFactor() const
Definition: outdev.hxx:396
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:50
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:161
const Wallpaper & GetBackground() const
Definition: outdev.hxx:523
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
Return the exact bounding rectangle of rStr.
Definition: text.cxx:2323
void SetLineColor()
Definition: line.cxx:37
OUString GetEllipsisString(const OUString &rStr, tools::Long nMaxWidth, DrawTextFlags nStyle=DrawTextFlags::EndEllipsis) const
Definition: text.cxx:2030
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: text.cxx:886
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void SetFillColor()
Definition: fill.cxx:29
const Color & GetTextColor() const
Definition: outdev.hxx:1003
bool IsBackground() const
Definition: outdev.hxx:526
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:32
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:897
void SetBackground()
Definition: background.cxx:27
void Pop()
Definition: stack.cxx:91
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
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.
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:797
const AllSettings & GetSettings() const
Definition: outdev.hxx:288
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
SAL_DLLPRIVATE sal_uInt16 ImplExecute(const VclPtr< vcl::Window > &pParentWin, const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags, Menu *pSFrom, bool bPreSelectFirst)
Definition: menu.cxx:3016
void SetSelectedEntry(sal_uInt16 nId)
Definition: menu.cxx:2740
virtual void SelectItem(sal_uInt16 nId) override
Definition: menu.cxx:2709
virtual ~PopupMenu() override
Definition: menu.cxx:2676
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
Definition: menu.cxx:2746
css::uno::Reference< css::awt::XPopupMenu > CreateMenuInterface()
Definition: menu.cxx:3079
SAL_DLLPRIVATE sal_uInt16 ImplCalcVisEntries(tools::Long nMaxHeight, sal_uInt16 nStartEntry, sal_uInt16 *pLastVisible=nullptr) const
Definition: menu.cxx:3031
static PopupMenu * GetActivePopupMenu()
Definition: menu.cxx:2697
PopupMenu()
Definition: menu.cxx:2665
virtual void ClosePopup(Menu *pMenu) override
Close the 'pStartedFrom' menu window.
Definition: menu.cxx:2681
void EndExecute()
Definition: menu.cxx:2703
SAL_DLLPRIVATE void FinishRun(const VclPtr< MenuFloatingWindow > &, const VclPtr< vcl::Window > &pParentWin, bool bRealExecute, bool bIsNativeMenu)
Definition: menu.cxx:2986
SAL_DLLPRIVATE void ImplFlushPendingSelect()
Definition: menu.cxx:2775
SAL_DLLPRIVATE MenuFloatingWindow * ImplGetFloatingWindow() const
Definition: menu.cxx:2661
SAL_DLLPRIVATE bool Run(const VclPtr< MenuFloatingWindow > &, bool bRealExecute, bool bPreSelectFirst, FloatWinPopupFlags nPopupModeFlags, Menu *pSFrom, const tools::Rectangle &rRect)
Definition: menu.cxx:2941
SAL_DLLPRIVATE tools::Long ImplCalcHeight(sal_uInt16 nEntries) const
Definition: menu.cxx:3059
SAL_DLLPRIVATE bool PrepareRun(const VclPtr< vcl::Window > &pParentWin, tools::Rectangle &rRect, FloatWinPopupFlags &nPopupModeFlags, Menu *pSFrom, bool &bRealExecute, VclPtr< MenuFloatingWindow > &)
Definition: menu.cxx:2788
unsigned int screen() const
Definition: salgeom.hxx:65
SalFrameGeometry maGeometry
absolute, unmirrored values
Definition: salframe.hxx:127
virtual std::unique_ptr< SalMenu > CreateMenu(bool bMenuBar, Menu *pMenu)
Definition: salvtables.cxx:158
virtual void SetAccelerator(unsigned nPos, SalMenuItem *pSalMenuItem, const vcl::KeyCode &rKeyCode, const OUString &rKeyName)=0
virtual void GetSystemMenuData(SystemMenuData *pData)=0
virtual int GetMenuBarHeight() const
Definition: salvtables.cxx:235
virtual void SetSubMenu(SalMenuItem *pSalMenuItem, SalMenu *pSubMenu, unsigned nPos)=0
virtual void SetItemBits(unsigned, MenuItemBits)
Definition: salmenu.hxx:70
virtual bool CanGetFocus() const
Definition: salmenu.hxx:83
virtual bool ShowNativePopupMenu(FloatingWindow *pWin, const tools::Rectangle &rRect, FloatWinPopupFlags nFlags)
Definition: salvtables.cxx:219
virtual void ShowMenuBar(bool)
Definition: salmenu.hxx:65
virtual void EnableItem(unsigned nPos, bool bEnable)=0
virtual void RemoveItem(unsigned nPos)=0
virtual void ShowItem(unsigned nPos, bool bShow)
Definition: salmenu.hxx:87
virtual void InsertItem(SalMenuItem *pSalMenuItem, unsigned nPos)=0
virtual void Update()
Definition: salmenu.hxx:81
virtual void SetItemText(unsigned nPos, SalMenuItem *pSalMenuItem, const OUString &rText)=0
virtual void SetItemImage(unsigned nPos, SalMenuItem *pSalMenuItem, const Image &rImage)=0
virtual void CheckItem(unsigned nPos, bool bCheck)=0
virtual bool VisibleMenuBar()=0
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetMenuHighlightTextColor() const
const Color & GetShadowColor() const
const Color & GetMenuColor() const
const Color & GetMenuBarTextColor() const
const Color & GetMenuBarRolloverTextColor() const
const Color & GetLightColor() const
bool GetSkipDisabledInMenus() const
const Color & GetMenuBarColor() const
bool GetUseImagesInMenus() const
const Color & GetHighlightColor() const
const Color & GetFaceColor() const
const Color & GetMenuBarHighlightTextColor() const
const Color & GetMenuTextColor() const
static bool IsCycleKey(const vcl::KeyCode &rKeyCode)
virtual css::uno::Reference< css::awt::XPopupMenu > CreateMenuInterface(PopupMenu *pPopupMenu)=0
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible(Menu *pMenu, bool bIsMenuBar)=0
static UnoWrapperBase * GetUnoWrapper(bool bCreateIfNotExists=true)
Get the application's UNO wrapper object.
Definition: svapp.cxx:1499
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:277
void disposeAndClear()
Definition: vclptr.hxx:200
void clear()
Definition: vclptr.hxx:190
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
bool isDisposed() const
virtual void dispose()
SalFrame * mpFrame
Definition: window.h:229
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
constexpr Point TopLeft() const
tools::Long getOpenHeight() const
void SetPos(const Point &rPoint)
void setWidth(tools::Long n)
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr Point BottomRight() const
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
void setHeight(tools::Long n)
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
void SetWeight(FontWeight)
Definition: font/font.cxx:236
OUString GetName() const
Definition: keycod.cxx:66
static SettingsConfigItem * get()
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2809
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: window3.cxx:66
void SetFont(const vcl::Font &rNewFont)
Definition: window3.cxx:59
bool IsReallyVisible() const
Definition: window2.cxx:1143
vcl::Window * GetParent() const
Definition: window2.cxx:1133
bool IsInputEnabled() const
Definition: window2.cxx:1163
WindowType GetType() const
Definition: window2.cxx:1010
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: window.cxx:2427
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1036
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
void GrabFocus()
Definition: window.cxx:2982
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
Definition: window3.cxx:79
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: window3.cxx:65
const AllSettings & GetSettings() const
Definition: window3.cxx:129
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1808
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
Definition: window3.cxx:74
VclPtr< vcl::Window > GetParentWithLOKNotifier()
Find the nearest parent with LOK Notifier; can be itself if this Window has LOK notifier set.
Definition: window.cxx:3262
::OutputDevice const * GetOutDev() const
Definition: window.cxx:567
const vcl::Font & GetFont() const
Definition: window3.cxx:58
const vcl::ILibreOfficeKitNotifier * GetLOKNotifier() const
Definition: window.cxx:3252
bool IsInModalMode() const
A window is in modal mode if one of its children or subchildren is a running modal window (a modal di...
Definition: window.cxx:3603
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:528
virtual Size GetSizePixel() const
Definition: window.cxx:2405
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsVisible() const
Definition: window2.cxx:1138
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
Definition: window.cxx:2858
bool IsEnabled() const
Definition: window2.cxx:1158
int nCount
DrawSymbolFlags
Definition: decoview.hxx:35
#define ENSURE_OR_RETURN(c, m, r)
ItemID nItemID
float y
float x
sal_Int32 nState
DocumentType eType
WEIGHT_BOLD
sal_Int32 nIndex
OUString aName
void * p
sal_Int64 n
constexpr sal_uInt16 KEY_0
Definition: keycodes.hxx:45
constexpr sal_uInt16 KEY_MOD2
Definition: keycodes.hxx:32
constexpr sal_uInt16 KEY_A
Definition: keycodes.hxx:56
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
static void ImplSetMenuItemData(MenuItemData *pData)
Definition: menu.cxx:91
#define EXTRAITEMHEIGHT
Definition: menu.cxx:73
IMPL_LINK_NOARG(Menu, ImplCallSelect, void *, void)
Definition: menu.cxx:2107
static FloatWinPopupFlags lcl_TranslateFlags(PopupMenuFlags nFlags)
Definition: menu.cxx:2751
static bool ImplAccelDisabled()
Definition: menu.cxx:76
static void ImplCopyItem(Menu *pThis, const Menu &rMenu, sal_uInt16 nPos, sal_uInt16 nNewPos)
Definition: menu.cxx:523
static OUString getShortenedString(const OUString &i_rLong, vcl::RenderContext const &rRenderContext, tools::Long i_nMaxWidth)
Definition: menu.cxx:1651
static void ImplPaintCheckBackground(vcl::RenderContext &rRenderContext, vcl::Window const &rWindow, const tools::Rectangle &i_rRect, bool i_bHighlight)
Definition: menu.cxx:1626
#define SPACE_AROUND_TITLE
Definition: menu.cxx:74
MenuFlags
Definition: menu.hxx:86
@ HideDisabledEntries
@ AlwaysShowDisabledEntries
constexpr auto ITEMPOS_INVALID
Invalid menu item id.
Definition: menu.hxx:100
PopupMenuFlags
Definition: menu.hxx:72
void(* MenuUserDataReleaseFunction)(void *)
Definition: menu.hxx:113
constexpr sal_uInt16 MENU_APPEND
Definition: menu.hxx:67
constexpr sal_uInt16 MENU_ITEM_NOTFOUND
Definition: menu.hxx:68
#define GUTTERBORDER
aStr
std::unique_ptr< sal_Int32[]> pData
sal_uInt16 nCode
NONE
tools::Long const nBorder
size
int i
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
@ eSymbol
Definition: ppdparser.hxx:44
long Long
bool IsInPopupMenuExecute()
Definition: menu.cxx:2691
sal_Int16 nId
VclPtr< const Menu > mpMenu
Definition: menu.hxx:105
ImplMenuDelData(const Menu *)
Definition: menu.cxx:3087
ImplMenuDelData * mpNext
Definition: menu.hxx:104
bool isDeleted() const
Definition: menu.hxx:110
VclPtr< PopupMenu > mpActivePopupMenu
Definition: svdata.hxx:156
SalInstance * mpDefInst
Definition: svdata.hxx:391
ImplSVNWFData maNWFData
Definition: svdata.hxx:405
ImplSVWinData * mpWinData
Definition: svdata.hxx:402
ImplSVAppData maAppData
Definition: svdata.hxx:399
bool mbFlatMenu
Definition: svdata.hxx:326
int mnMenuFormatBorderY
Definition: svdata.hxx:319
int mnMenuFormatBorderX
Definition: svdata.hxx:318
VclPtr< FloatingWindow > mpFirstFloat
Definition: svdata.hxx:256
bool mbNoDeactivate
Definition: svdata.hxx:268
VclPtr< Menu > pSubMenu
sal_uInt16 nId
MenuItemBits nBits
MenuItemType eType
std::vector< sal_uInt16 > m_aLineItemIds
Definition: menu.cxx:65
std::map< sal_uInt16, tools::Rectangle > m_aVisibleItemBoundRects
Definition: menu.cxx:66
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:77
DockingManager * ImplGetDockingManager()
Definition: svdata.cxx:316
OUString VclResId(TranslateId aId)
Definition: svdata.cxx:261
OUString removeMnemonicFromString(OUString const &rStr)
bool bVisible
sal_uInt16 sal_Unicode
MenuItemType
Definition: vclenum.hxx:30
MenuItemBits
Definition: vclenum.hxx:33
SymbolType
Definition: vclenum.hxx:74
FloatWinPopupFlags
Definition: vclenum.hxx:318
VclEventId
Definition: vclevent.hxx:38
@ MenuSubmenuChanged
@ MenuItemTextChanged
@ MenuAccessibleNameChanged
@ MenuSubmenuActivate
WinBits const WB_SYSTEMWINDOW
Definition: wintypes.hxx:126
WinBits const WB_BORDER
Definition: wintypes.hxx:115