|
1 /* |
|
2 * Copyright (c) 1997-1999 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 <eikmnbut.h> |
|
20 #include <eikmenup.h> |
|
21 #include <barsread.h> |
|
22 #include <coeaui.h> |
|
23 #include <eikenv.h> |
|
24 #include <eikappui.h> |
|
25 #include "lafmnbut.h" |
|
26 |
|
27 #include <AknTasHook.h> // for testability hooks |
|
28 EXPORT_C CEikMenuButton::CEikMenuButton() |
|
29 { |
|
30 if (LafMenuButton::IsReportingOnButtonDown()) |
|
31 SetReportOnPointerDown(); |
|
32 AKNTASHOOK_ADD( this, "CEikMenuButton" ); |
|
33 } |
|
34 |
|
35 EXPORT_C CEikMenuButton::~CEikMenuButton() |
|
36 { |
|
37 AKNTASHOOK_REMOVE(); |
|
38 if (iMenuPopup) |
|
39 { |
|
40 iEikonEnv->EikAppUi()->RemoveFromStack(iMenuPopup); |
|
41 delete iMenuPopup; |
|
42 } |
|
43 } |
|
44 |
|
45 EXPORT_C void CEikMenuButton::SetMenuPaneId(TInt aMenuPaneId) |
|
46 { |
|
47 iMenuPaneId=aMenuPaneId; |
|
48 } |
|
49 |
|
50 EXPORT_C void CEikMenuButton::ConstructFromResourceL(TResourceReader& aReader) |
|
51 { |
|
52 iMenuPaneId=aReader.ReadInt32(); |
|
53 CEikCommandButton::ConstructFromResourceL(aReader); |
|
54 } |
|
55 |
|
56 EXPORT_C void CEikMenuButton::Animate() |
|
57 { |
|
58 iButFlags|=0x10; // same as KButtonPressedMask - avoid magic number !!! |
|
59 StateChanged(); |
|
60 DrawNow(); |
|
61 iCoeEnv->WsSession().Flush(); |
|
62 } |
|
63 |
|
64 EXPORT_C void CEikMenuButton::ProcessCommandL(TInt aCommandId) |
|
65 { |
|
66 if (iMenuPopup) |
|
67 ClosePopupMenu(); |
|
68 iMenuObserver->ProcessCommandL(aCommandId); |
|
69 } |
|
70 |
|
71 EXPORT_C void CEikMenuButton::LaunchPopupMenuL(MEikMenuObserver* aObserver) |
|
72 { |
|
73 iMenuObserver=aObserver; |
|
74 iMenuPopup=new(ELeave) CEikMenuPane(this); |
|
75 TRAPD(err,DoLaunchPopupMenuL()); |
|
76 if (err) |
|
77 { |
|
78 ClosePopupMenu(); |
|
79 User::Leave(err); |
|
80 } |
|
81 } |
|
82 |
|
83 /** |
|
84 * Writes the internal state of the control and its components to aStream. |
|
85 * Does nothing in release mode. |
|
86 * Designed to be overidden and base called by subclasses. |
|
87 * |
|
88 * @internal |
|
89 * @since App-Framework_6.1 |
|
90 */ |
|
91 #ifndef _DEBUG |
|
92 EXPORT_C void CEikMenuButton::WriteInternalStateL(RWriteStream&) const |
|
93 {} |
|
94 #else |
|
95 EXPORT_C void CEikMenuButton::WriteInternalStateL(RWriteStream& aWriteStream) const |
|
96 { |
|
97 _LIT(KLitEikMenuButCtlStart, "<CEikMenuButton>"); |
|
98 _LIT(KLitEikMenuButCtlEnd, "<\\CEikMenuButton>"); |
|
99 _LIT(KLitEikMenuButPnId,"<iMenuPaneId>"); |
|
100 _LIT(KLitEikMenuButPnIdEnd,"<\\iMenuPaneId>"); |
|
101 |
|
102 aWriteStream << KLitEikMenuButCtlStart; |
|
103 aWriteStream << KLitEikMenuButPnId; |
|
104 aWriteStream.WriteInt32L(iMenuPaneId); |
|
105 aWriteStream << KLitEikMenuButPnIdEnd; |
|
106 CEikCommandButton::WriteInternalStateL(aWriteStream); |
|
107 aWriteStream << KLitEikMenuButCtlEnd; |
|
108 } |
|
109 #endif |
|
110 |
|
111 void CEikMenuButton::DoLaunchPopupMenuL() |
|
112 { |
|
113 iMenuPopup->ConstructL(NULL); |
|
114 iMenuObserver->RestoreMenuL(iMenuPopup,iMenuPaneId,MEikMenuObserver::EMenuPane); |
|
115 iMenuPopup->SetPointerCapture(ETrue); |
|
116 iEikonEnv->EikAppUi()->AddToStackL(iMenuPopup,ECoeStackPriorityDialog); |
|
117 TPoint pos(0,0); |
|
118 TRect screenRect(PositionRelativeToScreen(),Size()); |
|
119 LafMenuButton::GetMenuPosition(pos, screenRect, iMenuPopup->CalculateSizeAndPosition().Size(), iEikonEnv->ScreenDevice()->SizeInPixels()); |
|
120 iMenuPopup->StartDisplayingMenuPane(NULL,pos,NULL,0/*,EPopupTargetTopRight*/); |
|
121 if (iCoeEnv->LastEvent().Type()==EEventPointer) |
|
122 { |
|
123 SetIgnoreNextPointerUp(); |
|
124 iMenuPopup->ClaimPointerGrab(); |
|
125 } |
|
126 iMenuPopup->SetLaunchingButton(this); |
|
127 } |
|
128 |
|
129 EXPORT_C void CEikMenuButton::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
130 { |
|
131 CEikCommandButton::HandlePointerEventL(aPointerEvent); |
|
132 } |
|
133 |
|
134 EXPORT_C void* CEikMenuButton::ExtensionInterface( TUid /*aInterface*/ ) |
|
135 { |
|
136 return NULL; |
|
137 } |
|
138 |
|
139 void CEikMenuButton::ClosePopupMenu() |
|
140 { |
|
141 if (!iMenuPopup) |
|
142 return; |
|
143 iEikonEnv->EikAppUi()->RemoveFromStack(iMenuPopup); |
|
144 delete iMenuPopup; |
|
145 iMenuPopup=NULL; |
|
146 } |
|
147 |
|
148 EXPORT_C void CEikMenuButton::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/) |
|
149 { // !! what should go here |
|
150 } |
|
151 |