64
|
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: MR grid impl.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cmrgrid.h"
|
|
19 |
|
|
20 |
#include "nmrbitmapmanager.h"
|
|
21 |
#include "nmrlayoutmanager.h"
|
|
22 |
#include "esmrhelper.h"
|
|
23 |
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <AknIconArray.h>
|
|
26 |
#include <AknGrid.h>
|
|
27 |
#include <AknGridM.h>
|
|
28 |
#include <aknlists.h>
|
|
29 |
#include <AknUtils.h>
|
|
30 |
#include <aknPopup.h>
|
|
31 |
#include <avkon.hrh>
|
|
32 |
#include <e32base.h>
|
|
33 |
#include <gulicon.h>
|
|
34 |
#include <AknLayout2ScalableDef.h>
|
|
35 |
#include <esmrgui.mbg>
|
|
36 |
#include <esmrgui.rsg>
|
|
37 |
#include <data_caging_path_literals.hrh>
|
|
38 |
|
|
39 |
// DEBUG
|
|
40 |
#include "emailtrace.h"
|
|
41 |
|
|
42 |
namespace { // codescanner::namespace
|
|
43 |
|
|
44 |
//CONSTANTS
|
|
45 |
const TInt KColumns( 3 );
|
|
46 |
const TInt KRows( 2 );
|
|
47 |
|
|
48 |
} // namespace
|
|
49 |
|
|
50 |
// ======== MEMBER FUNCTIONS ========
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// CMRGrid::CMRGrid()
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CMRGrid::CMRGrid()
|
|
57 |
{
|
|
58 |
FUNC_LOG;
|
|
59 |
}
|
|
60 |
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
// CMRGrid::NewL
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
TBool CMRGrid::ExecuteL( TInt& aSelectedOption )
|
|
66 |
{
|
|
67 |
FUNC_LOG;
|
|
68 |
|
|
69 |
CMRGrid* self = new( ELeave )CMRGrid();
|
|
70 |
CleanupStack::PushL ( self );
|
|
71 |
TBool ret = self->ShowGridL( aSelectedOption );
|
|
72 |
CleanupStack::PopAndDestroy( self );
|
|
73 |
|
|
74 |
return ret;
|
|
75 |
}
|
|
76 |
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
// CMRGrid::~CMRGrid
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
CMRGrid::~CMRGrid( )
|
|
82 |
{
|
|
83 |
FUNC_LOG;
|
|
84 |
delete iGrid;
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// CMRGrid::AddGridIconsL
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
void CMRGrid::AddGridIconsL()
|
|
92 |
{
|
|
93 |
FUNC_LOG;
|
|
94 |
|
|
95 |
CArrayPtr<CGulIcon>* iconArray = new( ELeave ) CAknIconArray( 1 );
|
|
96 |
CleanupStack::PushL( iconArray );
|
|
97 |
|
|
98 |
/*
|
|
99 |
* 1. Item: Image
|
|
100 |
*/
|
|
101 |
CFbsBitmap* imageBitmap = NULL;
|
|
102 |
CFbsBitmap* imageBitmapMask = NULL;
|
|
103 |
GetSkinBasedBitmapLC( NMRBitmapManager::EMRBitmapAttachmentTypeImage,
|
|
104 |
imageBitmap,
|
|
105 |
imageBitmapMask,
|
|
106 |
TSize( 100, 100 ) );
|
|
107 |
|
|
108 |
CGulIcon* imageIcon = CGulIcon::NewL( imageBitmap, imageBitmapMask );
|
|
109 |
CleanupStack::Pop( 2 ); // imageBitmap, imageBitmapMask
|
|
110 |
CleanupStack::PushL( imageIcon );
|
|
111 |
iconArray->AppendL( imageIcon );
|
|
112 |
CleanupStack::Pop( imageIcon );
|
|
113 |
|
|
114 |
/*
|
|
115 |
* 2. Item: Video clip
|
|
116 |
*/
|
|
117 |
CFbsBitmap* videoClipBitmap = NULL;
|
|
118 |
CFbsBitmap* videoClipBitmapMask = NULL;
|
|
119 |
GetSkinBasedBitmapLC( NMRBitmapManager::EMRBitmapAttachmentTypeVideo,
|
|
120 |
videoClipBitmap,
|
|
121 |
videoClipBitmapMask,
|
|
122 |
TSize( 100, 100 ) );
|
|
123 |
|
|
124 |
CGulIcon* videoClipIcon = CGulIcon::NewL( videoClipBitmap, videoClipBitmapMask );
|
|
125 |
CleanupStack::Pop( 2 ); // videoClipBitmap, videoClipBitmapMask
|
|
126 |
CleanupStack::PushL( videoClipIcon );
|
|
127 |
iconArray->AppendL( videoClipIcon );
|
|
128 |
CleanupStack::Pop( videoClipIcon );
|
|
129 |
|
|
130 |
/*
|
|
131 |
* 3. Item: Sound clip
|
|
132 |
*/
|
|
133 |
CFbsBitmap* soundClipBitmap = NULL;
|
|
134 |
CFbsBitmap* soundClipBitmapMask = NULL;
|
|
135 |
GetSkinBasedBitmapLC( NMRBitmapManager::EMRBitmapAttachmentTypeMusic,
|
|
136 |
soundClipBitmap,
|
|
137 |
soundClipBitmapMask,
|
|
138 |
TSize( 100, 100 ) );
|
|
139 |
|
|
140 |
CGulIcon* soundClipIcon = CGulIcon::NewL( soundClipBitmap, soundClipBitmapMask );
|
|
141 |
CleanupStack::Pop( 2 ); // soundClipBitmap, soundClipBitmapMask
|
|
142 |
CleanupStack::PushL( soundClipIcon );
|
|
143 |
iconArray->AppendL( soundClipIcon );
|
|
144 |
CleanupStack::Pop( soundClipIcon );
|
|
145 |
|
|
146 |
/*
|
|
147 |
* 4. Item: Note
|
|
148 |
*/
|
|
149 |
CFbsBitmap* noteBitmap = NULL;
|
|
150 |
CFbsBitmap* noteBitmapMask = NULL;
|
|
151 |
GetSkinBasedBitmapLC( NMRBitmapManager::EMRBitmapAttachmentTypeNote,
|
|
152 |
noteBitmap,
|
|
153 |
noteBitmapMask,
|
|
154 |
TSize( 100, 100 ) );
|
|
155 |
|
|
156 |
CGulIcon* noteIcon = CGulIcon::NewL( noteBitmap, noteBitmapMask );
|
|
157 |
CleanupStack::Pop( 2 ); // noteBitmap, noteBitmapMask
|
|
158 |
CleanupStack::PushL( noteIcon );
|
|
159 |
iconArray->AppendL( noteIcon );
|
|
160 |
CleanupStack::Pop( noteIcon );
|
|
161 |
|
|
162 |
/*
|
|
163 |
* 5. Item: Other
|
|
164 |
*/
|
|
165 |
CFbsBitmap* otherBitmap = NULL;
|
|
166 |
CFbsBitmap* otherBitmapMask = NULL;
|
|
167 |
GetSkinBasedBitmapLC( NMRBitmapManager::EMRBitmapAttachmentTypeOther,
|
|
168 |
otherBitmap,
|
|
169 |
otherBitmapMask,
|
|
170 |
TSize( 100, 100 ) );
|
|
171 |
|
|
172 |
CGulIcon* otherIcon = CGulIcon::NewL( otherBitmap, otherBitmapMask );
|
|
173 |
CleanupStack::Pop( 2 ); // otherBitmap, otherBitmapMask
|
|
174 |
CleanupStack::PushL( otherIcon );
|
|
175 |
iconArray->AppendL( otherIcon );
|
|
176 |
CleanupStack::Pop( otherIcon );
|
|
177 |
|
|
178 |
iGrid->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
|
|
179 |
|
|
180 |
CleanupStack::Pop( iconArray );
|
|
181 |
iGrid->HandleItemAdditionL();
|
|
182 |
}
|
|
183 |
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
// CMRGrid::ShowGridL
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
TBool CMRGrid::ShowGridL( TInt& aSelectedOption )
|
|
189 |
{
|
|
190 |
FUNC_LOG;
|
|
191 |
TRect mainPaneRect( 0, 0, 0, 0 );
|
|
192 |
AknLayoutUtils::LayoutMetricsRect(
|
|
193 |
AknLayoutUtils::EMainPane, mainPaneRect );
|
|
194 |
|
|
195 |
TAknLayoutRect gridLayoutRect =
|
|
196 |
NMRLayoutManager::GetLayoutRect(
|
|
197 |
mainPaneRect,
|
|
198 |
NMRLayoutManager::EMRLayoutAttachmentSelectionGrid );
|
|
199 |
|
|
200 |
TRect gridRect( gridLayoutRect.Rect() );
|
|
201 |
|
|
202 |
TAknLayoutRect cellLayoutRect =
|
|
203 |
NMRLayoutManager::GetLayoutRect(
|
|
204 |
gridRect,
|
|
205 |
NMRLayoutManager::EMRLayoutAttachmentSelectionGridCell );
|
|
206 |
|
|
207 |
TRect cellRect( cellLayoutRect.Rect() );
|
|
208 |
cellRect.Move( -gridRect.iTl);
|
|
209 |
|
|
210 |
iGrid = new( ELeave ) CAknGrid;
|
|
211 |
CAknPopupList* gridList = CAknPopupList::NewL(
|
|
212 |
iGrid, R_AVKON_SOFTKEYS_SELECT_BACK );
|
|
213 |
CleanupStack::PushL( gridList );
|
|
214 |
|
|
215 |
// Load query heading
|
|
216 |
HBufC* buf( StringLoader::LoadLC(
|
|
217 |
R_QTN_MEET_REQ_QUERY_HEADING_SELECT_ATTACHMENT_TYPE ) );
|
|
218 |
gridList->SetTitleL( *buf );
|
|
219 |
CleanupStack::PopAndDestroy( buf );
|
|
220 |
|
|
221 |
iGrid->ConstructL( gridList, EAknListBoxMenuGrid );
|
|
222 |
iGrid->SetLayoutL(
|
|
223 |
EFalse, ETrue, ETrue, KColumns, KRows, cellRect.Size() );
|
|
224 |
iGrid->SetPrimaryScrollingType(
|
|
225 |
CAknGridView::EScrollIncrementLineAndLoops );
|
|
226 |
iGrid->SetSecondaryScrollingType(
|
|
227 |
CAknGridView::EScrollIncrementLineAndLoops );
|
|
228 |
|
|
229 |
iGrid->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
230 |
CEikScrollBarFrame::EOff,
|
|
231 |
CEikScrollBarFrame::EOff );
|
|
232 |
|
|
233 |
CDesCArray *gridItemArray = static_cast<CDesCArray*>(
|
|
234 |
iGrid->Model()->ItemTextArray() );
|
|
235 |
|
|
236 |
// The order of the items should be in line with
|
|
237 |
// CMRAttachmentUi::ResolveAttachmentTypeL switch case items.
|
|
238 |
HBufC* textImage = StringLoader::LoadLC(
|
|
239 |
R_QTN_MEET_REQ_ATTACHMENT_TYPE_IMAGE );
|
|
240 |
gridItemArray->AppendL( _L("0\tImage") /*textImage*/ );
|
|
241 |
CleanupStack::PopAndDestroy( textImage );
|
|
242 |
|
|
243 |
HBufC* textVideo = StringLoader::LoadLC(
|
|
244 |
R_QTN_MEET_REQ_ATTACHMENT_TYPE_VIDEO );
|
|
245 |
gridItemArray->AppendL( _L("1\tVideo clip") /*textVideo*/ );
|
|
246 |
CleanupStack::PopAndDestroy( textVideo );
|
|
247 |
|
|
248 |
HBufC* textSound = StringLoader::LoadLC(
|
|
249 |
R_QTN_MEET_REQ_ATTACHMENT_TYPE_SOUNDCLIP );
|
|
250 |
gridItemArray->AppendL( _L("2\tSound clip") /*textSound*/ );
|
|
251 |
CleanupStack::PopAndDestroy( textSound );
|
|
252 |
|
|
253 |
HBufC* textNote = StringLoader::LoadLC(
|
|
254 |
R_QTN_MEET_REQ_ATTACHMENT_TYPE_NOTE );
|
|
255 |
gridItemArray->AppendL( _L("3\tNote") /*textNote*/ );
|
|
256 |
CleanupStack::PopAndDestroy( textNote );
|
|
257 |
|
|
258 |
HBufC* textOther = StringLoader::LoadLC(
|
|
259 |
R_QTN_MEET_REQ_ATTACHMENT_TYPE_NOTE );
|
|
260 |
gridItemArray->AppendL( _L("4\tOther") /*textOther*/ );
|
|
261 |
CleanupStack::PopAndDestroy( textOther );
|
|
262 |
|
|
263 |
iGrid->HandleItemAdditionL();
|
|
264 |
|
|
265 |
AddGridIconsL();
|
|
266 |
|
|
267 |
TAknLayoutRect graphicLayoutRect =
|
|
268 |
NMRLayoutManager::GetLayoutRect(
|
|
269 |
cellRect,
|
|
270 |
NMRLayoutManager::
|
|
271 |
EMRLayoutAttachmentSelectionGridCellGraphic );
|
|
272 |
|
|
273 |
TRect graphicRect( graphicLayoutRect.Rect() );
|
|
274 |
|
|
275 |
// Setup grid graphics
|
|
276 |
AknListBoxLayouts::SetupFormGfxCell(
|
|
277 |
*iGrid, iGrid->ItemDrawer(),
|
|
278 |
0 /*Column index*/,
|
|
279 |
graphicRect.iTl.iX /*Left pos*/,
|
|
280 |
graphicRect.iTl.iY /*Top pos*/,
|
|
281 |
0 /*unused*/,
|
|
282 |
0 /*unused*/,
|
|
283 |
graphicRect.Width() /*Icon width*/,
|
|
284 |
graphicRect.Height() /*Icon height*/,
|
|
285 |
graphicRect.iTl /*Start pos*/,
|
|
286 |
graphicRect.iBr /*End pos*/ );
|
|
287 |
|
|
288 |
TAknLayoutText gridTextLayout(
|
|
289 |
NMRLayoutManager::GetLayoutText(
|
|
290 |
cellRect,
|
|
291 |
NMRLayoutManager::
|
|
292 |
EMRTextLayoutAttachmentSelectionGridCellText ) );
|
|
293 |
|
|
294 |
TRect textRect( gridTextLayout.TextRect() );
|
|
295 |
|
|
296 |
// Calculate the text baseline
|
|
297 |
TInt baseLine( cellRect.iBr.iY - ( cellRect.iBr.iY - textRect.iBr.iY ) );
|
|
298 |
// Reduce font's descent -> Baseline calculated
|
|
299 |
baseLine -= gridTextLayout.Font()->DescentInPixels();
|
|
300 |
|
|
301 |
// Setup grid texts
|
|
302 |
AknListBoxLayouts::SetupFormTextCell(
|
|
303 |
*iGrid, iGrid->ItemDrawer(),
|
|
304 |
1 /*Column index*/,
|
|
305 |
gridTextLayout.Font() /*Font type*/,
|
|
306 |
gridTextLayout.Color().Value() /*color*/,
|
|
307 |
0 /*Left margin*/,
|
|
308 |
0 /*unused*/,
|
|
309 |
baseLine/*Baseline*/,
|
|
310 |
0 /*Text width*/,
|
|
311 |
gridTextLayout.Align() /*Text alignment*/,
|
|
312 |
textRect.iTl /*Start pos*/,
|
|
313 |
textRect.iBr /*End pos*/);
|
|
314 |
|
|
315 |
TBool popupOk = gridList->ExecuteLD();
|
|
316 |
aSelectedOption = iGrid->CurrentDataIndex();
|
|
317 |
CleanupStack::Pop( gridList );
|
|
318 |
|
|
319 |
return popupOk;
|
|
320 |
}
|
|
321 |
|
|
322 |
//EOF
|