|
1 /* |
|
2 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lafmnbut.h" |
|
20 |
|
21 /** |
|
22 * Returns ETrue if the menu button should report on a button down event. Otherwise the button |
|
23 * should report on a button up event. |
|
24 * |
|
25 * @since App-Framework_6.1 |
|
26 */ |
|
27 EXPORT_C TBool LafMenuButton::IsReportingOnButtonDown() |
|
28 { |
|
29 return ETrue; |
|
30 } |
|
31 |
|
32 /** |
|
33 * Gets the position, aMenuPosition, of the popup menu launched by the button using the rectangle |
|
34 * of the button aButtonRect, the size of the menu aMenuSize and the device screen size |
|
35 * aScreenSize for reference. |
|
36 * |
|
37 * @since App-Framework_6.1 |
|
38 */ |
|
39 EXPORT_C void LafMenuButton::GetMenuPosition(TPoint& aMenuPosition, const TRect& aButtonRect, |
|
40 const TSize& aMenuSize, const TSize& aScreenSize) |
|
41 { |
|
42 aMenuPosition=aButtonRect.iTl; |
|
43 // try to position popup to right of button, then below, then left and lastly above |
|
44 TSize buttonSize(aButtonRect.Size()); |
|
45 if (aMenuPosition.iX+buttonSize.iWidth+aMenuSize.iWidth<=aScreenSize.iWidth) |
|
46 aMenuPosition.iX+=buttonSize.iWidth; |
|
47 else if (aMenuPosition.iY+buttonSize.iHeight+aMenuSize.iHeight<=aScreenSize.iHeight) |
|
48 aMenuPosition.iY+=buttonSize.iHeight; |
|
49 else if (aMenuPosition.iX-aMenuSize.iWidth>=0) |
|
50 aMenuPosition.iX-=aMenuSize.iWidth; |
|
51 else if (aMenuPosition.iY-aMenuSize.iHeight>=0) |
|
52 aMenuPosition.iY-=aMenuSize.iHeight; |
|
53 else |
|
54 { |
|
55 aMenuPosition.iX+=buttonSize.iWidth; |
|
56 aMenuPosition.iY+=buttonSize.iHeight; |
|
57 } |
|
58 } |