/src/libreoffice/vcl/source/window/menuwindow.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #include "menuwindow.hxx" |
21 | | #include "menuitemlist.hxx" |
22 | | |
23 | | #include <vcl/help.hxx> |
24 | | #include <vcl/menu.hxx> |
25 | | #include <vcl/settings.hxx> |
26 | | #include <vcl/svapp.hxx> |
27 | | #include <vcl/window.hxx> |
28 | | |
29 | | static sal_uLong ImplChangeTipTimeout( sal_uLong nTimeout, vcl::Window *pWindow ) |
30 | 0 | { |
31 | 0 | AllSettings aAllSettings( pWindow->GetSettings() ); |
32 | 0 | HelpSettings aHelpSettings( aAllSettings.GetHelpSettings() ); |
33 | 0 | sal_uLong nRet = aHelpSettings.GetTipTimeout(); |
34 | 0 | aHelpSettings.SetTipTimeout( nTimeout ); |
35 | 0 | aAllSettings.SetHelpSettings( aHelpSettings ); |
36 | 0 | pWindow->GetOutDev()->SetSettings( aAllSettings ); |
37 | 0 | return nRet; |
38 | 0 | } |
39 | | |
40 | | bool MenuWindow::ImplHandleHelpEvent(vcl::Window* pMenuWindow, Menu const * pMenu, sal_uInt16 nHighlightedItem, |
41 | | const HelpEvent& rHEvt, const tools::Rectangle &rHighlightRect) |
42 | 0 | { |
43 | 0 | if( ! pMenu ) |
44 | 0 | return false; |
45 | | |
46 | 0 | bool bDone = false; |
47 | 0 | sal_uInt16 nId = 0; |
48 | |
|
49 | 0 | if ( nHighlightedItem != ITEMPOS_INVALID ) |
50 | 0 | { |
51 | 0 | MenuItemData* pItemData = pMenu->GetItemList()->GetDataFromPos( nHighlightedItem ); |
52 | 0 | if ( pItemData ) |
53 | 0 | nId = pItemData->nId; |
54 | 0 | } |
55 | |
|
56 | 0 | if ( ( rHEvt.GetMode() & HelpEventMode::BALLOON ) && pMenuWindow ) |
57 | 0 | { |
58 | 0 | Point aPos; |
59 | 0 | if( rHEvt.KeyboardActivated() ) |
60 | 0 | aPos = rHighlightRect.Center(); |
61 | 0 | else |
62 | 0 | aPos = rHEvt.GetMousePosPixel(); |
63 | |
|
64 | 0 | tools::Rectangle aRect( aPos, Size() ); |
65 | 0 | if (!pMenu->GetHelpText(nId).isEmpty()) |
66 | 0 | Help::ShowBalloon( pMenuWindow, aPos, aRect, pMenu->GetHelpText( nId ) ); |
67 | 0 | else |
68 | 0 | { |
69 | | // give user a chance to read the full filename |
70 | 0 | sal_uLong oldTimeout=ImplChangeTipTimeout( 60000, pMenuWindow ); |
71 | | // call always, even when strlen==0 to correctly remove tip |
72 | 0 | Help::ShowQuickHelp( pMenuWindow, aRect, pMenu->GetTipHelpText( nId ) ); |
73 | 0 | ImplChangeTipTimeout( oldTimeout, pMenuWindow ); |
74 | 0 | } |
75 | 0 | bDone = true; |
76 | 0 | } |
77 | 0 | else if ( ( rHEvt.GetMode() &HelpEventMode::QUICK ) && pMenuWindow ) |
78 | 0 | { |
79 | 0 | Point aPos = rHEvt.GetMousePosPixel(); |
80 | 0 | tools::Rectangle aRect( aPos, Size() ); |
81 | | // give user a chance to read the full filename |
82 | 0 | sal_uLong oldTimeout=ImplChangeTipTimeout( 60000, pMenuWindow ); |
83 | | // call always, even when strlen==0 to correctly remove tip |
84 | 0 | Help::ShowQuickHelp( pMenuWindow, aRect, pMenu->GetTipHelpText( nId ) ); |
85 | 0 | ImplChangeTipTimeout( oldTimeout, pMenuWindow ); |
86 | 0 | bDone = true; |
87 | 0 | } |
88 | 0 | else if ( rHEvt.GetMode() & HelpEventMode::CONTEXT ) |
89 | 0 | { |
90 | | // is help in the application selected |
91 | 0 | Help* pHelp = Application::GetHelp(); |
92 | 0 | if ( pHelp ) |
93 | 0 | { |
94 | | // Check if there is a Help ID available, or else use |
95 | | // the command URL |
96 | 0 | OUString aCommand = pMenu->GetItemCommand( nId ); |
97 | 0 | OUString aHelpId; |
98 | | |
99 | | // If no entry is selected, use the general menu Help ID |
100 | 0 | if (nId <= 0) |
101 | 0 | aHelpId = pMenu->GetHelpId(); |
102 | 0 | else |
103 | 0 | aHelpId = pMenu->GetHelpId(nId); |
104 | |
|
105 | 0 | if( aHelpId.isEmpty() ) |
106 | 0 | aHelpId = OOO_HELP_INDEX; |
107 | |
|
108 | 0 | if ( !aHelpId.isEmpty() ) |
109 | 0 | pHelp->Start(aHelpId); |
110 | 0 | else |
111 | 0 | pHelp->Start(aCommand); |
112 | 0 | } |
113 | 0 | bDone = true; |
114 | 0 | } |
115 | 0 | return bDone; |
116 | 0 | } |
117 | | |
118 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |