Kaydet (Commit) 355267ba authored tarafından Jan Holesovsky's avatar Jan Holesovsky

vcl: Move MenuFloatingWindow to an own file + adapt code.

The needed changes included:

* Move MenuItemList and MenuItemData to an own file
* Introduce MenuWindow class for pieces shared between MenuFloatingWindow and
  MenuBarWindow.

Change-Id: I129b6ddba6efb8f0cb60018a2d8abafed42552c8
üst 047d2f95
......@@ -81,6 +81,9 @@ namespace vcl { struct MenuLayoutData; }
// overrides default hiding of disabled entries in popup menus
#define MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES 0x0004
/// Invalid menu item id
#define ITEMPOS_INVALID 0xFFFF
struct ImplMenuDelData
{
ImplMenuDelData* mpNext;
......@@ -184,6 +187,16 @@ protected:
SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel );
SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel );
/// Close the 'pStartedFrom' menu window.
SAL_DLLPRIVATE void CloseStartedFrom();
/// Deactivate the MenuBarWindow.
SAL_DLLPRIVATE sal_uLong DeactivateMenuBar(sal_uLong nFocusId);
/// Forward the KeyInput call to the MenuBar.
SAL_DLLPRIVATE void MenuBarKeyInput(const KeyEvent& rEvent);
public:
SAL_DLLPRIVATE void ImplKillLayoutData() const;
SAL_DLLPRIVATE Menu* ImplGetStartedFrom() const { return pStartedFrom; }
......
......@@ -138,6 +138,9 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/window/keyevent \
vcl/source/window/layout \
vcl/source/window/menu \
vcl/source/window/menufloatingwindow \
vcl/source/window/menuitemlist \
vcl/source/window/menuwindow \
vcl/source/window/mnemonic \
vcl/source/window/mnemonicengine \
vcl/source/window/mouse \
......
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_VCL_SOURCE_WINDOW_MENUFLOATINGWINDOW_HXX
#define INCLUDED_VCL_SOURCE_WINDOW_MENUFLOATINGWINDOW_HXX
#include "menuwindow.hxx"
#include <vcl/floatwin.hxx>
#include <vcl/menu.hxx>
#define EXTRASPACEY 2
#define GUTTERBORDER 8
/** Class that implements the actual window of the floating menu.
*/
class MenuFloatingWindow : public MenuWindow, public FloatingWindow
{
friend void Menu::ImplFillLayoutData() const;
friend Menu::~Menu();
private:
Menu* pMenu;
PopupMenu* pActivePopup;
Timer aHighlightChangedTimer;
Timer aSubmenuCloseTimer;
Timer aScrollTimer;
sal_uLong nSaveFocusId;
sal_uInt16 nHighlightedItem; // highlighted/selected Item
sal_uInt16 nMBDownPos;
sal_uInt16 nScrollerHeight;
sal_uInt16 nFirstEntry;
sal_uInt16 nBorder;
sal_uInt16 nPosInParent;
bool bInExecute;
bool bScrollMenu;
bool bScrollUp;
bool bScrollDown;
bool bIgnoreFirstMove;
bool bKeyInput;
DECL_LINK(PopupEnd, void *);
DECL_LINK( HighlightChanged, Timer* );
DECL_LINK(SubmenuClose, void *);
DECL_LINK(AutoScroll, void *);
DECL_LINK( ShowHideListener, VclWindowEvent* );
virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
void InitMenuClipRegion();
protected:
Region ImplCalcClipRegion( bool bIncludeLogo = true ) const;
void ImplDrawScroller( bool bUp );
using Window::ImplScroll;
void ImplScroll( const Point& rMousePos );
void ImplScroll( bool bUp );
void ImplCursorUpDown( bool bUp, bool bHomeEnd = false );
void ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDown );
long ImplGetStartY() const;
Rectangle ImplGetItemRect( sal_uInt16 nPos );
public:
MenuFloatingWindow( Menu* pMenu, Window* pParent, WinBits nStyle );
virtual ~MenuFloatingWindow();
void doShutdown();
virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void KeyInput( const KeyEvent& rKEvent ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
virtual void Resize() SAL_OVERRIDE;
void SetFocusId( sal_uLong nId ) { nSaveFocusId = nId; }
sal_uLong GetFocusId() const { return nSaveFocusId; }
void EnableScrollMenu( bool b );
bool IsScrollMenu() const { return bScrollMenu; }
sal_uInt16 GetScrollerHeight() const { return nScrollerHeight; }
void Execute();
void StopExecute( sal_uLong nFocusId = 0 );
void EndExecute();
void EndExecute( sal_uInt16 nSelectId );
PopupMenu* GetActivePopup() const { return pActivePopup; }
void KillActivePopup( PopupMenu* pThisOnly = NULL );
void HighlightItem( sal_uInt16 nPos, bool bHighlight );
void ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTimer );
sal_uInt16 GetHighlightedItem() const { return nHighlightedItem; }
void SetPosInParent( sal_uInt16 nPos ) { nPosInParent = nPos; }
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
};
#endif // INCLUDED_VCL_SOURCE_WINDOW_MENUFLOATINGWINDOW_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "menuitemlist.hxx"
#include <salframe.hxx>
#include <salinst.hxx>
#include <salmenu.hxx>
#include <svdata.hxx>
#include <vcl/i18nhelp.hxx>
#include <vcl/settings.hxx>
#include <vcl/window.hxx>
using namespace css;
using namespace vcl;
MenuItemData::~MenuItemData()
{
if( pAutoSubMenu )
{
((PopupMenu*)pAutoSubMenu)->pRefAutoSubMenu = NULL;
delete pAutoSubMenu;
pAutoSubMenu = NULL;
}
if( pSalMenuItem )
ImplGetSVData()->mpDefInst->DestroyMenuItem( pSalMenuItem );
}
MenuItemList::~MenuItemList()
{
for( size_t i = 0, n = maItemList.size(); i < n; ++i )
delete maItemList[ i ];
}
MenuItemData* MenuItemList::Insert(
sal_uInt16 nId,
MenuItemType eType,
MenuItemBits nBits,
const OUString& rStr,
const Image& rImage,
Menu* pMenu,
size_t nPos,
const OString &rIdent
)
{
MenuItemData* pData = new MenuItemData( rStr, rImage );
pData->nId = nId;
pData->sIdent = rIdent;
pData->eType = eType;
pData->nBits = nBits;
pData->pSubMenu = NULL;
pData->pAutoSubMenu = NULL;
pData->nUserValue = 0;
pData->bChecked = false;
pData->bEnabled = true;
pData->bVisible = true;
pData->bIsTemporary = false;
pData->bMirrorMode = false;
pData->nItemImageAngle = 0;
SalItemParams aSalMIData;
aSalMIData.nId = nId;
aSalMIData.eType = eType;
aSalMIData.nBits = nBits;
aSalMIData.pMenu = pMenu;
aSalMIData.aText = rStr;
aSalMIData.aImage = rImage;
// Native-support: returns NULL if not supported
pData->pSalMenuItem = ImplGetSVData()->mpDefInst->CreateMenuItem( &aSalMIData );
if( nPos < maItemList.size() ) {
maItemList.insert( maItemList.begin() + nPos, pData );
} else {
maItemList.push_back( pData );
}
return pData;
}
void MenuItemList::InsertSeparator(const OString &rIdent, size_t nPos)
{
MenuItemData* pData = new MenuItemData;
pData->nId = 0;
pData->sIdent = rIdent;
pData->eType = MENUITEM_SEPARATOR;
pData->nBits = 0;
pData->pSubMenu = NULL;
pData->pAutoSubMenu = NULL;
pData->nUserValue = 0;
pData->bChecked = false;
pData->bEnabled = true;
pData->bVisible = true;
pData->bIsTemporary = false;
pData->bMirrorMode = false;
pData->nItemImageAngle = 0;
SalItemParams aSalMIData;
aSalMIData.nId = 0;
aSalMIData.eType = MENUITEM_SEPARATOR;
aSalMIData.nBits = 0;
aSalMIData.pMenu = NULL;
aSalMIData.aText = OUString();
aSalMIData.aImage = Image();
// Native-support: returns NULL if not supported
pData->pSalMenuItem = ImplGetSVData()->mpDefInst->CreateMenuItem( &aSalMIData );
if( nPos < maItemList.size() ) {
maItemList.insert( maItemList.begin() + nPos, pData );
} else {
maItemList.push_back( pData );
}
}
void MenuItemList::Remove( size_t nPos )
{
if( nPos < maItemList.size() )
{
delete maItemList[ nPos ];
maItemList.erase( maItemList.begin() + nPos );
}
}
MenuItemData* MenuItemList::GetData( sal_uInt16 nSVId, size_t& rPos ) const
{
for( size_t i = 0, n = maItemList.size(); i < n; ++i )
{
if ( maItemList[ i ]->nId == nSVId )
{
rPos = i;
return maItemList[ i ];
}
}
return NULL;
}
MenuItemData* MenuItemList::SearchItem(
sal_Unicode cSelectChar,
KeyCode aKeyCode,
sal_uInt16& rPos,
sal_uInt16& nDuplicates,
sal_uInt16 nCurrentPos
) const
{
const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
size_t nListCount = maItemList.size();
// try character code first
nDuplicates = GetItemCount( cSelectChar ); // return number of duplicates
if( nDuplicates )
{
for ( rPos = 0; rPos < nListCount; rPos++)
{
MenuItemData* pData = maItemList[ rPos ];
if ( pData->bEnabled && rI18nHelper.MatchMnemonic( pData->aText, cSelectChar ) )
{
if( nDuplicates > 1 && rPos == nCurrentPos )
continue; // select next entry with the same mnemonic
else
return pData;
}
}
}
// nothing found, try keycode instead
nDuplicates = GetItemCount( aKeyCode ); // return number of duplicates
if( nDuplicates )
{
char ascii = 0;
if( aKeyCode.GetCode() >= KEY_A && aKeyCode.GetCode() <= KEY_Z )
ascii = sal::static_int_cast<char>('A' + (aKeyCode.GetCode() - KEY_A));
for ( rPos = 0; rPos < nListCount; rPos++)
{
MenuItemData* pData = maItemList[ rPos ];
if ( pData->bEnabled )
{
sal_Int32 n = pData->aText.indexOf('~');
if ( n != -1 )
{
KeyCode mnKeyCode;
sal_Unicode mnUnicode = pData->aText[n+1];
Window* pDefWindow = ImplGetDefaultWindow();
if( ( pDefWindow
&& pDefWindow->ImplGetFrame()->MapUnicodeToKeyCode( mnUnicode,
Application::GetSettings().GetUILanguageTag().getLanguageType(), mnKeyCode )
&& aKeyCode.GetCode() == mnKeyCode.GetCode()
)
|| ( ascii
&& rI18nHelper.MatchMnemonic( pData->aText, ascii )
)
)
{
if( nDuplicates > 1 && rPos == nCurrentPos )
continue; // select next entry with the same mnemonic
else
return pData;
}
}
}
}
}
return NULL;
}
size_t MenuItemList::GetItemCount( sal_Unicode cSelectChar ) const
{
// returns number of entries with same mnemonic
const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
size_t nItems = 0;
for ( size_t nPos = maItemList.size(); nPos; )
{
MenuItemData* pData = maItemList[ --nPos ];
if ( pData->bEnabled && rI18nHelper.MatchMnemonic( pData->aText, cSelectChar ) )
nItems++;
}
return nItems;
}
size_t MenuItemList::GetItemCount( KeyCode aKeyCode ) const
{
// returns number of entries with same mnemonic
// uses key codes instead of character codes
const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
char ascii = 0;
if( aKeyCode.GetCode() >= KEY_A && aKeyCode.GetCode() <= KEY_Z )
ascii = sal::static_int_cast<char>('A' + (aKeyCode.GetCode() - KEY_A));
size_t nItems = 0;
for ( size_t nPos = maItemList.size(); nPos; )
{
MenuItemData* pData = maItemList[ --nPos ];
if ( pData->bEnabled )
{
sal_Int32 n = pData->aText.indexOf('~');
if (n != -1)
{
KeyCode mnKeyCode;
// if MapUnicodeToKeyCode fails or is unsupported we try the pure ascii mapping of the keycodes
// so we have working shortcuts when ascii mnemonics are used
Window* pDefWindow = ImplGetDefaultWindow();
if( ( pDefWindow
&& pDefWindow->ImplGetFrame()->MapUnicodeToKeyCode( pData->aText[n+1],
Application::GetSettings().GetUILanguageTag().getLanguageType(), mnKeyCode )
&& aKeyCode.GetCode() == mnKeyCode.GetCode()
)
|| ( ascii
&& rI18nHelper.MatchMnemonic( pData->aText, ascii )
)
)
nItems++;
}
}
}
return nItems;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <rsc/rsc-vcl-shared-types.hxx>
#include <vcl/image.hxx>
#include <vcl/keycod.hxx>
#include <vcl/menu.hxx>
#include <com/sun/star/i18n/XCharacterClassification.hpp>
#include <vector>
class SalMenuItem;
struct MenuItemData
{
sal_uInt16 nId; // SV Id
MenuItemType eType; // MenuItem-Type
MenuItemBits nBits; // MenuItem-Bits
Menu* pSubMenu; // Pointer to SubMenu
Menu* pAutoSubMenu; // Pointer to SubMenu from Resource
OUString aText; // Menu-Text
OUString aHelpText; // Help-String
OUString aTipHelpText; // TipHelp-String (eg, expanded filenames)
OUString aCommandStr; // CommandString
OUString aHelpCommandStr; // Help command string (to reference external help)
OString sIdent;
OString aHelpId; // Help-Id
sal_uLong nUserValue; // User value
Image aImage; // Image
vcl::KeyCode aAccelKey; // Accelerator-Key
bool bChecked; // Checked
bool bEnabled; // Enabled
bool bVisible; // Visible (note: this flag will not override MENU_FLAG_HIDEDISABLEDENTRIES when true)
bool bIsTemporary; // Temporary inserted ('No selection possible')
bool bMirrorMode;
long nItemImageAngle;
Size aSz; // only temporarily valid
OUString aAccessibleName; // accessible name
OUString aAccessibleDescription; // accessible description
SalMenuItem* pSalMenuItem; // access to native menu
MenuItemData()
: nId(0)
, eType(MENUITEM_DONTKNOW)
, nBits(0)
, pSubMenu(NULL)
, pAutoSubMenu(NULL)
, nUserValue(0)
, bChecked(false)
, bEnabled(false)
, bVisible(false)
, bIsTemporary(false)
, bMirrorMode(false)
, nItemImageAngle(0)
, pSalMenuItem(NULL)
{
}
MenuItemData( const OUString& rStr, const Image& rImage )
: nId(0)
, eType(MENUITEM_DONTKNOW)
, nBits(0)
, pSubMenu(NULL)
, pAutoSubMenu(NULL)
, aText(rStr)
, nUserValue(0)
, aImage(rImage)
, bChecked(false)
, bEnabled(false)
, bVisible(false)
, bIsTemporary(false)
, bMirrorMode(false)
, nItemImageAngle(0)
, pSalMenuItem(NULL)
{
}
~MenuItemData();
bool HasCheck() const
{
return bChecked || ( nBits & ( MIB_RADIOCHECK | MIB_CHECKABLE | MIB_AUTOCHECK ) );
}
};
class MenuItemList
{
private:
typedef ::std::vector< MenuItemData* > MenuItemDataList_impl;
MenuItemDataList_impl maItemList;
css::uno::Reference< css::i18n::XCharacterClassification > xCharClass;
public:
MenuItemList() {}
~MenuItemList();
MenuItemData* Insert(
sal_uInt16 nId,
MenuItemType eType,
MenuItemBits nBits,
const OUString& rStr,
const Image& rImage,
Menu* pMenu,
size_t nPos,
const OString &rIdent
);
void InsertSeparator(const OString &rIdent, size_t nPos);
void Remove( size_t nPos );
MenuItemData* GetData( sal_uInt16 nSVId, size_t& rPos ) const;
MenuItemData* GetData( sal_uInt16 nSVId ) const
{
size_t nTemp;
return GetData( nSVId, nTemp );
}
MenuItemData* GetDataFromPos( size_t nPos ) const
{
return ( nPos < maItemList.size() ) ? maItemList[ nPos ] : NULL;
}
MenuItemData* SearchItem(
sal_Unicode cSelectChar,
vcl::KeyCode aKeyCode,
sal_uInt16& rPos,
sal_uInt16& nDuplicates,
sal_uInt16 nCurrentPos
) const;
size_t GetItemCount( sal_Unicode cSelectChar ) const;
size_t GetItemCount( vcl::KeyCode aKeyCode ) const;
size_t size()
{
return maItemList.size();
}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "menuwindow.hxx"
#include "menuitemlist.hxx"
#include <vcl/help.hxx>
#include <vcl/menu.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
void MenuWindow::ImplInitMenuWindow(Window* pWin, bool bFont, bool bMenuBar)
{
const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings();
if ( bFont )
pWin->SetPointFont( rStyleSettings.GetMenuFont() );
if( bMenuBar )
{
const BitmapEx& rPersonaBitmap = Application::GetSettings().GetStyleSettings().GetPersonaHeader();
if ( !rPersonaBitmap.IsEmpty() )
{
Wallpaper aWallpaper( rPersonaBitmap );
aWallpaper.SetStyle( WALLPAPER_TOPRIGHT );
aWallpaper.SetColor( Application::GetSettings().GetStyleSettings().GetWorkspaceColor() );
pWin->SetBackground( aWallpaper );
pWin->SetPaintTransparent( false );
pWin->SetParentClipMode( 0 );
}
else if ( pWin->IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) )
{
pWin->SetBackground(); // background will be drawn by NWF
}
else
{
Wallpaper aWallpaper;
aWallpaper.SetStyle( WALLPAPER_APPLICATIONGRADIENT );
pWin->SetBackground( aWallpaper );
pWin->SetPaintTransparent( false );
pWin->SetParentClipMode( 0 );
}
}
else
{
if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) )
{
pWin->SetBackground(); // background will be drawn by NWF
}
else
pWin->SetBackground( Wallpaper( rStyleSettings.GetMenuColor() ) );
}
if ( bMenuBar )
pWin->SetTextColor( rStyleSettings.GetMenuBarTextColor() );
else
pWin->SetTextColor( rStyleSettings.GetMenuTextColor() );
pWin->SetTextFillColor();
pWin->SetLineColor();
}
static sal_uLong ImplChangeTipTimeout( sal_uLong nTimeout, Window *pWindow )
{
AllSettings aAllSettings( pWindow->GetSettings() );
HelpSettings aHelpSettings( aAllSettings.GetHelpSettings() );
sal_uLong nRet = aHelpSettings.GetTipTimeout();
aHelpSettings.SetTipTimeout( nTimeout );
aAllSettings.SetHelpSettings( aHelpSettings );
pWindow->SetSettings( aAllSettings );
return nRet;
}
bool MenuWindow::ImplHandleHelpEvent(Window* pMenuWindow, Menu* pMenu, sal_uInt16 nHighlightedItem,
const HelpEvent& rHEvt, const Rectangle &rHighlightRect)
{
if( ! pMenu )
return false;
bool bDone = false;
sal_uInt16 nId = 0;
if ( nHighlightedItem != ITEMPOS_INVALID )
{
MenuItemData* pItemData = pMenu->GetItemList()->GetDataFromPos( nHighlightedItem );
if ( pItemData )
nId = pItemData->nId;
}
if ( ( rHEvt.GetMode() & HELPMODE_BALLOON ) && pMenuWindow )
{
Point aPos;
if( rHEvt.KeyboardActivated() )
aPos = rHighlightRect.Center();
else
aPos = rHEvt.GetMousePosPixel();
Rectangle aRect( aPos, Size() );
if (!pMenu->GetHelpText(nId).isEmpty())
Help::ShowBalloon( pMenuWindow, aPos, pMenu->GetHelpText( nId ) );
else
{
// give user a chance to read the full filename
sal_uLong oldTimeout=ImplChangeTipTimeout( 60000, pMenuWindow );
// call always, even when strlen==0 to correctly remove tip
Help::ShowQuickHelp( pMenuWindow, aRect, pMenu->GetTipHelpText( nId ) );
ImplChangeTipTimeout( oldTimeout, pMenuWindow );
}
bDone = true;
}
else if ( ( rHEvt.GetMode() & HELPMODE_QUICK ) && pMenuWindow )
{
Point aPos = rHEvt.GetMousePosPixel();
Rectangle aRect( aPos, Size() );
// give user a chance to read the full filename
sal_uLong oldTimeout=ImplChangeTipTimeout( 60000, pMenuWindow );
// call always, even when strlen==0 to correctly remove tip
Help::ShowQuickHelp( pMenuWindow, aRect, pMenu->GetTipHelpText( nId ) );
ImplChangeTipTimeout( oldTimeout, pMenuWindow );
bDone = true;
}
else if ( rHEvt.GetMode() & (HELPMODE_CONTEXT | HELPMODE_EXTENDED) )
{
// is help in the application selected
Help* pHelp = Application::GetHelp();
if ( pHelp )
{
// is an id available, then call help with the id, otherwise
// use help-index
OUString aCommand = pMenu->GetItemCommand( nId );
OString aHelpId( pMenu->GetHelpId( nId ) );
if( aHelpId.isEmpty() )
aHelpId = OOO_HELP_INDEX;
if ( !aCommand.isEmpty() )
pHelp->Start( aCommand, NULL );
else
pHelp->Start( OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), NULL );
}
bDone = true;
}
return bDone;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_VCL_SOURCE_WINDOW_MENUWINDOW_HXX
#define INCLUDED_VCL_SOURCE_WINDOW_MENUWINDOW_HXX
#include <sal/types.h>
class HelpEvent;
class Menu;
class Rectangle;
class Window;
/** Common ancestor for MenuFloatingWindow and MenuBarWindow.
The menu can be a floating window, or a menu bar. Even though this has
'Window' in the name, it is not derived from the VCL's Window class, as the
MenuFloatingWindow's or MenuBarWindow's already are VCL Windows.
*/
class MenuWindow
{
public:
/// Sets up some visual properties of the underlying window.
void ImplInitMenuWindow(Window* pWin, bool bFont, bool bMenuBar);
/// Show the appropriate help tooltip.
bool ImplHandleHelpEvent(Window* pMenuWindow, Menu* pMenu, sal_uInt16 nHighlightedItem,
const HelpEvent& rHEvt, const Rectangle &rHighlightRect);
};
#endif // INCLUDED_VCL_SOURCE_WINDOW_MENUWINDOW_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment