25
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Navigation arrow (used to replace the navipane).
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cmrnaviarrow.h"
|
|
19 |
#include "nmrbitmapmanager.h"
|
|
20 |
#include "cesmrviewerdialog.h"
|
|
21 |
#include "esmricalvieweropcodes.hrh"
|
|
22 |
|
|
23 |
#include <aknbutton.h>
|
|
24 |
#include <gulicon.h>
|
|
25 |
#include <w32std.h>
|
|
26 |
|
|
27 |
#include "emailtrace.h"
|
|
28 |
|
|
29 |
namespace
|
|
30 |
{
|
|
31 |
// Value table for 70% Transparency
|
|
32 |
const TInt KTransparency[256] =
|
|
33 |
{
|
|
34 |
0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7,
|
|
35 |
8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 13, 13, 13,
|
|
36 |
14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19,
|
|
37 |
19, 19, 20, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 23, 24, 24,
|
|
38 |
24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29,
|
|
39 |
30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35,
|
|
40 |
35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 38, 39, 39, 39, 40, 40, 40,
|
|
41 |
41, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 46,
|
|
42 |
46, 46, 47, 47, 47, 47, 48, 48, 48, 49, 49, 49, 50, 50, 50, 50, 51, 51,
|
|
43 |
51, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 56,
|
|
44 |
57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62,
|
|
45 |
62, 62, 63, 63, 63, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67,
|
|
46 |
68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 71, 72, 72, 72, 73,
|
|
47 |
73, 73, 74, 74, 74, 74, 75, 75, 75, 76, 76, 76, 77, 77
|
|
48 |
};
|
|
49 |
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
// ======== MEMBER FUNCTIONS ========
|
|
54 |
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
// CMRNaviArrow::NewL()
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CMRNaviArrow* CMRNaviArrow::NewL( const CCoeControl* aParent,
|
|
60 |
TArrowType aType,
|
|
61 |
MESMRNaviArrowEventObserver* aObserver,
|
|
62 |
TSize aIconSize )
|
|
63 |
{
|
|
64 |
FUNC_LOG;
|
|
65 |
CMRNaviArrow* self = new (ELeave) CMRNaviArrow( aObserver, aType, aIconSize );
|
|
66 |
CleanupStack::PushL( self );
|
|
67 |
self->ConstructL( aParent);
|
|
68 |
CleanupStack::Pop( self );
|
|
69 |
return self;
|
|
70 |
}
|
|
71 |
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
// CMRNaviArrow::CMRNaviArrow()
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
CMRNaviArrow::CMRNaviArrow( MESMRNaviArrowEventObserver* aObserver, TArrowType aType, TSize aIconSize )
|
|
77 |
:iObserver(aObserver),
|
|
78 |
iArrowType(aType),
|
|
79 |
iIconSize( aIconSize )
|
|
80 |
{
|
|
81 |
FUNC_LOG;
|
|
82 |
// Do nothing
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// CMRNaviArrow::~CMRNaviArrow
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
CMRNaviArrow::~CMRNaviArrow()
|
|
90 |
{
|
|
91 |
FUNC_LOG;
|
|
92 |
delete iArrow;
|
|
93 |
}
|
|
94 |
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
// CMRNaviArrow::ConstructL()
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
void CMRNaviArrow::ConstructL( const CCoeControl* aParent )
|
|
100 |
{
|
|
101 |
FUNC_LOG;
|
|
102 |
CreateWindowL( aParent );
|
|
103 |
EnableWindowTransparency();
|
|
104 |
InitNaviArrowsL();
|
|
105 |
}
|
|
106 |
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
// CMRNaviArrow::InitNaviArrows()
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
void CMRNaviArrow::InitNaviArrowsL()
|
|
112 |
{
|
|
113 |
FUNC_LOG;
|
|
114 |
|
|
115 |
CFbsBitmap* bitMapL( NULL );
|
|
116 |
CFbsBitmap* bitMapMaskL( NULL );
|
|
117 |
NMRBitmapManager::TMRBitmapId bitmapId;
|
|
118 |
if ( EMRArrowLeft == iArrowType )
|
|
119 |
{
|
|
120 |
bitmapId = NMRBitmapManager::EMRBitmapMailPre;
|
|
121 |
}
|
|
122 |
else
|
|
123 |
{
|
|
124 |
bitmapId = NMRBitmapManager::EMRBitmapMailNext;
|
|
125 |
}
|
|
126 |
NMRBitmapManager::GetSkinBasedBitmapLC(
|
|
127 |
bitmapId, bitMapL, bitMapMaskL, iIconSize );
|
|
128 |
|
|
129 |
CGulIcon* transparentIconL = CreateSemiTransparentIconL( bitMapL, bitMapMaskL );
|
|
130 |
CleanupStack::Pop( 2 ); // bitMap, bitMapMask
|
|
131 |
CleanupStack::PushL( transparentIconL );
|
|
132 |
iArrow = CAknButton::NewL( transparentIconL, NULL, NULL, NULL, KNullDesC,
|
|
133 |
KNullDesC, KAknButtonNoFrame | KAknButtonPressedDownFrame, 0 );
|
|
134 |
CleanupStack::Pop( transparentIconL );
|
|
135 |
|
|
136 |
iArrow->SetParent( this );
|
|
137 |
iArrow->SetContainerWindowL(*this);
|
|
138 |
}
|
|
139 |
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
// CMRNaviArrow::SizeChanged
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CMRNaviArrow::SizeChanged()
|
|
145 |
{
|
|
146 |
FUNC_LOG;
|
|
147 |
iArrow->SetRect( Rect() );
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// CMRNaviArrow::CountComponentControls()
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
TInt CMRNaviArrow::CountComponentControls() const
|
|
155 |
{
|
|
156 |
FUNC_LOG;
|
|
157 |
TInt count(0);
|
|
158 |
if( iArrow )
|
|
159 |
{
|
|
160 |
count++;
|
|
161 |
}
|
|
162 |
return count;
|
|
163 |
}
|
|
164 |
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
// CMRNaviArrow::ComponentControl()
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
CCoeControl* CMRNaviArrow::ComponentControl( TInt aInd ) const
|
|
170 |
{
|
|
171 |
FUNC_LOG;
|
|
172 |
CCoeControl* control = NULL;
|
|
173 |
switch ( aInd )
|
|
174 |
{
|
|
175 |
case 0:
|
|
176 |
control = iArrow;
|
|
177 |
break;
|
|
178 |
default:
|
|
179 |
break;
|
|
180 |
}
|
|
181 |
|
|
182 |
return control;
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
// CMRNaviArrow::HandlePointerEventL()
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void CMRNaviArrow::HandlePointerEventL( const TPointerEvent &aPointerEvent )
|
|
190 |
{
|
|
191 |
FUNC_LOG;
|
|
192 |
CCoeControl::HandlePointerEventL(aPointerEvent);
|
|
193 |
TESMRIcalViewerOperationType operationType;
|
|
194 |
if ( EMRArrowLeft == iArrowType )
|
|
195 |
{
|
|
196 |
operationType = EESMRCmdMailPreviousMessage;
|
|
197 |
}
|
|
198 |
else
|
|
199 |
{
|
|
200 |
operationType = EESMRCmdMailNextMessage;
|
|
201 |
}
|
|
202 |
if( aPointerEvent.iType == TPointerEvent::EButton1Up )
|
|
203 |
{
|
|
204 |
if ( iArrow->Rect().Contains( aPointerEvent.iPosition ) )
|
|
205 |
{
|
|
206 |
iObserver->HandleNaviArrowEventL( operationType );
|
|
207 |
}
|
|
208 |
else
|
|
209 |
{
|
|
210 |
Parent()->HandlePointerEventL(aPointerEvent);
|
|
211 |
}
|
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
// CMRNaviArrow::SetNaviArrowStatus()
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
void CMRNaviArrow::SetNaviArrowStatus( TBool aVisible )
|
|
220 |
{
|
|
221 |
FUNC_LOG;
|
|
222 |
iArrow->MakeVisible( aVisible );
|
|
223 |
DrawDeferred();
|
|
224 |
}
|
|
225 |
|
|
226 |
// ---------------------------------------------------------------------------
|
|
227 |
// CMRNaviArrow::Draw()
|
|
228 |
// ---------------------------------------------------------------------------
|
|
229 |
//
|
|
230 |
void CMRNaviArrow::Draw(const TRect& /*aRect*/) const
|
|
231 |
{
|
|
232 |
FUNC_LOG;
|
|
233 |
}
|
|
234 |
|
|
235 |
// ---------------------------------------------------------------------------
|
|
236 |
// CMRNaviArrow::CreateSemiTransparentIconL()
|
|
237 |
// ---------------------------------------------------------------------------
|
|
238 |
//
|
|
239 |
CGulIcon* CMRNaviArrow::CreateSemiTransparentIconL( CFbsBitmap* aBitMap,
|
|
240 |
CFbsBitmap* aBitMapMask )
|
|
241 |
{
|
|
242 |
CGulIcon* newIcon(NULL);
|
|
243 |
|
|
244 |
if ( aBitMap && aBitMapMask )
|
|
245 |
{
|
|
246 |
newIcon = CGulIcon::NewLC();
|
|
247 |
newIcon->SetBitmap( aBitMap );
|
|
248 |
|
|
249 |
CFbsBitmap* newMask = new ( ELeave ) CFbsBitmap;
|
|
250 |
CleanupStack::PushL( newMask );
|
|
251 |
|
|
252 |
User::LeaveIfError( newMask->Create(
|
|
253 |
newIcon->Bitmap()->SizeInPixels(), EGray256 ) );
|
|
254 |
|
|
255 |
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL( newMask );
|
|
256 |
CleanupStack::PushL( bitmapDevice );
|
|
257 |
|
|
258 |
CFbsBitGc* bitGc( NULL );
|
|
259 |
User::LeaveIfError( bitmapDevice->CreateContext( bitGc ) );
|
|
260 |
CleanupStack::PushL( bitGc );
|
|
261 |
|
|
262 |
bitGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
263 |
bitGc->BitBlt( TPoint( 0, 0 ), aBitMapMask );
|
|
264 |
|
|
265 |
newMask->LockHeap();
|
|
266 |
TInt w = aBitMapMask->SizeInPixels().iWidth;
|
|
267 |
TInt h = aBitMapMask->SizeInPixels().iHeight;
|
|
268 |
TInt dataStride = aBitMapMask->DataStride() - w;
|
|
269 |
unsigned char* address = (unsigned char *)newMask->DataAddress();
|
|
270 |
|
|
271 |
for ( TInt i = 0; i < h; ++i )
|
|
272 |
{
|
|
273 |
for ( TInt j = 0; j < w; ++j )
|
|
274 |
{
|
|
275 |
*address = KTransparency[*address];
|
|
276 |
++address;
|
|
277 |
}
|
|
278 |
address += dataStride;
|
|
279 |
}
|
|
280 |
|
|
281 |
newMask->UnlockHeap();
|
|
282 |
newIcon->SetMask( newMask );
|
|
283 |
|
|
284 |
CleanupStack::PopAndDestroy( 2 ); // bitmapDevice, bitGc
|
|
285 |
CleanupStack::Pop( 2 ); // newIcon, newMask
|
|
286 |
}
|
|
287 |
|
|
288 |
return newIcon;
|
|
289 |
}
|
|
290 |
|
|
291 |
// End of file
|