34
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Item activator
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
|
|
20 |
// User includes
|
|
21 |
#include "xnappuiadapter.h"
|
|
22 |
#include "xnuiengine.h"
|
|
23 |
#include "xneditor.h"
|
|
24 |
#include "xndomstringpool.h"
|
|
25 |
#include "xndomdocument.h"
|
|
26 |
#include "xnproperty.h"
|
|
27 |
#include "xnnodeimpl.h"
|
|
28 |
#include "xnnode.h"
|
|
29 |
#include "xntype.h"
|
|
30 |
#include "xnodt.h"
|
|
31 |
|
|
32 |
#include "xnitemactivator.h"
|
|
33 |
|
|
34 |
// Constants
|
|
35 |
_LIT8( KMenuItem, "menuitem" );
|
|
36 |
_LIT8( KDynMenuItem, "dynmenuitem" );
|
|
37 |
_LIT8( KWidgetMenuItem, "widgetmenuitem" );
|
|
38 |
|
|
39 |
// ============================ LOCAL FUNCTIONS ================================
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
// BuildActivateTriggerNodeL
|
|
42 |
//
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
static CXnNode* BuildActivateTriggerNodeL( CXnUiEngine& aUiEngine )
|
|
46 |
{
|
|
47 |
CXnNode* node = CXnNode::NewL();
|
|
48 |
CleanupStack::PushL( node );
|
|
49 |
CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger );
|
|
50 |
CleanupStack::PushL( type );
|
|
51 |
CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
|
|
52 |
CleanupStack::Pop( type );
|
|
53 |
node->SetImpl( impl );
|
|
54 |
node->SetUiEngine( aUiEngine );
|
|
55 |
CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
|
|
56 |
aUiEngine.ODT()->DomDocument().StringPool() );
|
|
57 |
CleanupStack::PushL( nameValue );
|
|
58 |
nameValue->SetStringValueL( CXnDomPropertyValue::EString,
|
|
59 |
XnPropertyNames::action::trigger::name::KActivate );
|
|
60 |
CXnProperty* name = CXnProperty::NewL(
|
|
61 |
XnPropertyNames::action::trigger::KName,
|
|
62 |
nameValue,
|
|
63 |
*aUiEngine.ODT()->DomDocument().StringPool() );
|
|
64 |
CleanupStack::Pop( nameValue );
|
|
65 |
CleanupStack::PushL( name );
|
|
66 |
node->SetPropertyL( name );
|
|
67 |
CleanupStack::Pop( name );
|
|
68 |
CleanupStack::Pop( node );
|
|
69 |
return node;
|
|
70 |
}
|
|
71 |
|
|
72 |
// -----------------------------------------------------------------------------
|
|
73 |
// IsMenuItem
|
|
74 |
//
|
|
75 |
// -----------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
static TBool IsMenuItem( CXnNode& aItem )
|
|
78 |
{
|
|
79 |
const TDesC8& type( aItem.Type()->Type() );
|
|
80 |
|
|
81 |
return ( type == KMenuItem ||
|
|
82 |
type == KDynMenuItem ||
|
|
83 |
type == KWidgetMenuItem );
|
|
84 |
}
|
|
85 |
|
|
86 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
// CXnItemActivator::NewL()
|
|
89 |
// Two-phased constructor.
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
CXnItemActivator* CXnItemActivator::NewL( CXnAppUiAdapter& aAppUiAdapter )
|
|
93 |
{
|
|
94 |
CXnItemActivator* self = CXnItemActivator::NewLC( aAppUiAdapter );
|
|
95 |
CleanupStack::Pop( self );
|
|
96 |
return self;
|
|
97 |
}
|
|
98 |
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
// CXnItemActivator::NewLC()
|
|
101 |
// Two-phased constructor.
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
CXnItemActivator* CXnItemActivator::NewLC( CXnAppUiAdapter& aAppUiAdapter )
|
|
105 |
{
|
|
106 |
CXnItemActivator* self = new ( ELeave ) CXnItemActivator( aAppUiAdapter );
|
|
107 |
CleanupStack::PushL( self );
|
|
108 |
self->ConstructL();
|
|
109 |
return self;
|
|
110 |
}
|
|
111 |
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
// CXnItemActivator::~CXnItemActivator()
|
|
114 |
// C++ default destructor.
|
|
115 |
// -----------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
CXnItemActivator::~CXnItemActivator()
|
|
118 |
{
|
|
119 |
Cancel();
|
|
120 |
|
|
121 |
delete iTrigger;
|
|
122 |
}
|
|
123 |
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
// CXnItemActivator::CXnItemActivator()
|
|
126 |
// C++ default constructor.
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
CXnItemActivator::CXnItemActivator( CXnAppUiAdapter& aAppUiAdapter )
|
|
130 |
: CTimer( CActive::EPriorityUserInput + 1 ), iAppUiAdapter( aAppUiAdapter )
|
|
131 |
{
|
|
132 |
CActiveScheduler::Add( this );
|
|
133 |
}
|
|
134 |
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
// CXnItemActivator::ConstructL()
|
|
137 |
// 2nd phase constructor.
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void CXnItemActivator::ConstructL()
|
|
141 |
{
|
|
142 |
CTimer::ConstructL();
|
|
143 |
|
|
144 |
iTrigger = BuildActivateTriggerNodeL( iAppUiAdapter.UiEngine() );
|
|
145 |
}
|
|
146 |
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
// CXnItemActivator::RunL()
|
|
149 |
//
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
void CXnItemActivator::RunL()
|
|
153 |
{
|
|
154 |
CXnNode* item( iItemToActivate );
|
|
155 |
|
|
156 |
iItemToActivate = NULL;
|
|
157 |
|
|
158 |
if ( item && iAppUiAdapter.IsForeground() )
|
|
159 |
{
|
|
160 |
iAppUiAdapter.UiEngine().DisableRenderUiLC();
|
|
161 |
|
|
162 |
item->ReportXuikonEventL( *iTrigger );
|
|
163 |
|
|
164 |
CleanupStack::PopAndDestroy(); // DisableRenderUiLC
|
|
165 |
}
|
|
166 |
}
|
|
167 |
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
// CXnItemActivator::RunError()
|
|
170 |
//
|
|
171 |
// -----------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
TInt CXnItemActivator::RunError( TInt aError )
|
|
174 |
{
|
|
175 |
return aError;
|
|
176 |
}
|
|
177 |
|
|
178 |
// -----------------------------------------------------------------------------
|
|
179 |
// CXnItemActivator::DoCancel()
|
|
180 |
//
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
void CXnItemActivator::DoCancel()
|
|
184 |
{
|
|
185 |
iItemToActivate = NULL;
|
|
186 |
}
|
|
187 |
|
|
188 |
// -----------------------------------------------------------------------------
|
|
189 |
// CXnItemActivator::ActivateL()
|
|
190 |
//
|
|
191 |
// -----------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
void CXnItemActivator::ActivateL( CXnNode* aItemToActivate )
|
|
194 |
{
|
|
195 |
if ( aItemToActivate )
|
|
196 |
{
|
|
197 |
Cancel();
|
|
198 |
|
|
199 |
iItemToActivate = aItemToActivate;
|
|
200 |
|
|
201 |
if ( IsMenuItem( *aItemToActivate ) )
|
|
202 |
{
|
|
203 |
RunL();
|
|
204 |
}
|
|
205 |
else
|
|
206 |
{
|
|
207 |
After( 0 );
|
|
208 |
}
|
|
209 |
}
|
|
210 |
}
|
|
211 |
|
|
212 |
// End of file
|