34
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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 |
* Version : %version: MM_66 % << Don't touch! Updated by Synergy at check-out.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#include <aknlists.h>
|
|
21 |
#include <barsread.h>
|
|
22 |
|
|
23 |
#include <eikclb.h>
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <AknsLayeredBackgroundControlContext.h>
|
|
26 |
#include <AknsListBoxBackgroundControlContext.h>
|
|
27 |
|
|
28 |
#include "mmlistbox.h"
|
|
29 |
#include "mmlistboxmodel.h"
|
|
30 |
#include "mmmarqueeadapter.h"
|
|
31 |
#include "hnsuitemodel.h"
|
|
32 |
#include "mmlistboxcontainer.h"
|
|
33 |
#include "mmlistboxitemdrawer.h"
|
|
34 |
#include "mmwidgetsconstants.h"
|
|
35 |
#include "mmtemplatelibrary.h"
|
|
36 |
#include "mmpostevaluationprocessor.h"
|
|
37 |
#include "mmdraweranimator.h"
|
|
38 |
|
|
39 |
|
|
40 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// CListboxNumberContainer::CListboxNumberContainer()
|
|
44 |
// C++ default constructor
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CMmListBoxContainer* CMmListBoxContainer::NewLC( const TRect& aRect,
|
|
48 |
MObjectProvider* aObjectProvider, CMmTemplateLibrary* aTemplateLibrary )
|
|
49 |
{
|
|
50 |
CMmListBoxContainer* self = new( ELeave ) CMmListBoxContainer();
|
|
51 |
CleanupStack::PushL( self );
|
|
52 |
self->ConstructL( aRect, aObjectProvider, aTemplateLibrary );
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
// CListboxNumberContainer::CListboxNumberContainer()
|
|
58 |
// C++ default constructor
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CMmListBoxContainer* CMmListBoxContainer::NewL( const TRect& aRect,
|
|
62 |
MObjectProvider* aObjectProvider, CMmTemplateLibrary* aTemplateLibrary )
|
|
63 |
{
|
|
64 |
CMmListBoxContainer* self = NewLC( aRect, aObjectProvider, aTemplateLibrary );
|
|
65 |
CleanupStack::Pop( self );
|
|
66 |
return self;
|
|
67 |
}
|
|
68 |
|
|
69 |
// -----------------------------------------------------------------------------
|
|
70 |
// CListboxNumberContainer::CListboxNumberContainer()
|
|
71 |
// C++ default constructor
|
|
72 |
// -----------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
CMmListBoxContainer::CMmListBoxContainer()
|
|
75 |
{
|
|
76 |
}
|
|
77 |
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
// CListboxNumberContainer::~CListboxNumberContainer()
|
|
80 |
// Destructor
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
CMmListBoxContainer::~CMmListBoxContainer()
|
|
84 |
{
|
|
85 |
delete iListBox;
|
|
86 |
delete iMarqueeAdapter;
|
|
87 |
}
|
|
88 |
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// CMmListBoxContainer::ConstructL()
|
|
91 |
// 2nd phase constructor
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
void CMmListBoxContainer::ConstructL( const TRect& aRect,
|
|
95 |
MObjectProvider* aObjectProvider, CMmTemplateLibrary* aTemplateLibrary )
|
|
96 |
{
|
|
97 |
CMmWidgetContainer::ConstructL();
|
|
98 |
|
|
99 |
SetMopParent( aObjectProvider );
|
|
100 |
CreateWindowL(); // Creates window.
|
|
101 |
iWidget = CreateListboxL( aTemplateLibrary );
|
|
102 |
iWidget->SetListBoxObserver( this );
|
|
103 |
SetRect( aRect ); // Sets rectangle of frame.
|
|
104 |
ActivateL(); // Activates window. ( Ready to draw )
|
|
105 |
SetupDrawer();
|
|
106 |
// SetHighlightVisibilityL( ETrue );
|
|
107 |
iMarqueeAdapter = CMmMarqueeAdapter::NewL();
|
|
108 |
iDrawer->SetMarqueeAdapter( iMarqueeAdapter );
|
|
109 |
iListBox->SetMarqueeAdapter( iMarqueeAdapter );
|
|
110 |
iPostProcessor = CMmPostEvaluationProcessor::NewL( *iDrawer );
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
void CMmListBoxContainer::DrawView()
|
|
118 |
{
|
|
119 |
iListBox->DrawView();
|
|
120 |
}
|
|
121 |
|
|
122 |
// -----------------------------------------------------------------------------
|
|
123 |
// CMmListBoxContainer::CreateListboxL()
|
|
124 |
// Constructs listbox from resource, creates scroll bar and sets empty
|
|
125 |
// list background text.
|
|
126 |
// -----------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
CMmListBox* CMmListBoxContainer::CreateListboxL(
|
|
129 |
CMmTemplateLibrary* aTemplateLibrary )
|
|
130 |
{
|
|
131 |
iListBox = CMmListBox::NewL( this, EAknListBoxSelectionList
|
|
132 |
| EAknListBoxLoopScrolling, aTemplateLibrary );
|
|
133 |
iListBox->SetContainerWindowL( *this );
|
|
134 |
iListBox->CreateScrollBarFrameL( ETrue );
|
|
135 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
136 |
CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto );
|
|
137 |
iListBox->ScrollBarFrame()->DrawBackground( EFalse, EFalse );
|
|
138 |
return iListBox;
|
|
139 |
}
|
|
140 |
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
THnSuiteWidgetType CMmListBoxContainer::WidgetType()
|
|
146 |
{
|
|
147 |
return EListWidget;
|
|
148 |
}
|
|
149 |
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
EXPORT_C void CMmListBoxContainer::SetDefaultHighlightL( TBool aRedraw )
|
|
155 |
{
|
|
156 |
TInt defaultHighlight = Widget()->TopItemIndex();
|
|
157 |
if ( !ItemIsFullyVisible( defaultHighlight )
|
|
158 |
&& defaultHighlight < NumberOfItems() - 1 )
|
|
159 |
{
|
|
160 |
defaultHighlight++;
|
|
161 |
}
|
|
162 |
|
|
163 |
if (defaultHighlight >= 0 )
|
|
164 |
{
|
|
165 |
SetManualHighlightL( defaultHighlight, aRedraw );
|
|
166 |
}
|
|
167 |
}
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
//
|
|
171 |
// -----------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
EXPORT_C void CMmListBoxContainer::SetEmptyTextL(const TDesC& aText)
|
|
174 |
{
|
|
175 |
iListBox->View()->SetListEmptyTextL( aText );
|
|
176 |
}
|
|
177 |
|
|
178 |
// -----------------------------------------------------------------------------
|
|
179 |
//
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
void CMmListBoxContainer::SetEditModeL( TBool aIsEditMode )
|
|
183 |
{
|
|
184 |
if (aIsEditMode && !AknLayoutUtils::PenEnabled() )
|
|
185 |
{
|
|
186 |
iListBox->ClearListFlag( EAknListBoxLoopScrolling );
|
|
187 |
}
|
|
188 |
else
|
|
189 |
{
|
|
190 |
iListBox->SetListFlag( EAknListBoxLoopScrolling );
|
|
191 |
}
|
|
192 |
CMmWidgetContainer::SetEditModeL( aIsEditMode );
|
|
193 |
}
|
|
194 |
|
|
195 |
// -----------------------------------------------------------------------------
|
|
196 |
//
|
|
197 |
// -----------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
CMmListBoxModel* CMmListBoxContainer::GetMmModel()
|
|
200 |
{
|
|
201 |
return iListBox->MmModel();
|
|
202 |
}
|
|
203 |
|
|
204 |
// -----------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
// -----------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
void CMmListBoxContainer::SetupWidgetLayoutL()
|
|
209 |
{
|
|
210 |
}
|
|
211 |
|
|
212 |
// -----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
// -----------------------------------------------------------------------------
|
|
215 |
//
|
|
216 |
void CMmListBoxContainer::SetItemDrawerAndViewBgContext(
|
|
217 |
CAknsBasicBackgroundControlContext * aBgContext )
|
|
218 |
{
|
|
219 |
iListBox->SetItemDrawerAndViewBgContext (aBgContext);
|
|
220 |
}
|
|
221 |
|
|
222 |
// -----------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
// -----------------------------------------------------------------------------
|
|
225 |
//
|
|
226 |
void CMmListBoxContainer::SetSuiteModelL( CHnSuiteModel* aModel )
|
|
227 |
{
|
|
228 |
CMmWidgetContainer::SetSuiteModelL( aModel );
|
|
229 |
iMarqueeAdapter->StopMarqueeDrawing();
|
|
230 |
}
|
|
231 |
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
void CMmListBoxContainer::SetHighlightVisibilityL( TBool aVisible )
|
|
237 |
{
|
|
238 |
CMmWidgetContainer::SetHighlightVisibilityL( aVisible );
|
|
239 |
}
|
|
240 |
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
//
|
|
245 |
TBool CMmListBoxContainer::PointInItemReorderAreaL(
|
|
246 |
TInt aItemIndex, TPoint aPoint )
|
|
247 |
{
|
|
248 |
TRect itemRect = GetItemRectL( aItemIndex );
|
|
249 |
itemRect.Shrink( 0, MmEffects::KShiftRatio * itemRect.Height() );
|
|
250 |
return itemRect.Contains( aPoint );
|
|
251 |
}
|
|
252 |
|
|
253 |
// ---------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CMmListBoxContainer::HandleItemAdditionL()
|
|
258 |
{
|
|
259 |
iListBox->HandleItemAdditionL();
|
|
260 |
}
|
|
261 |
|
|
262 |
|
|
263 |
// ---------------------------------------------------------------------------
|
|
264 |
//
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
//
|
|
267 |
void CMmListBoxContainer::HandleItemRemovalL()
|
|
268 |
{
|
|
269 |
GetMmModel()->HandleSuiteEventL( ESuiteItemsRemoved, GetMmModel()->GetSuiteModel() );
|
|
270 |
iCurrentHighlight = GetSuiteModelL()->GetSuiteHighlight();
|
|
271 |
ValidateWidgetCurrentItemIndex();
|
|
272 |
|
|
273 |
iDrawer->RemoveFloatingItems();
|
|
274 |
if( IsEditMode() )
|
|
275 |
{
|
|
276 |
iDrawer->GetAnimator()->SetNextRedrawToWholeScreen();
|
|
277 |
}
|
|
278 |
|
|
279 |
iListBox->HandleItemRemovalL();
|
|
280 |
|
|
281 |
CHnSuiteModel* suiteModel = GetSuiteModelL();
|
|
282 |
suiteModel->SetSuiteHighlightL( iCurrentHighlight );
|
|
283 |
static_cast<CMmListBoxItemDrawer*>( iListBox->ItemDrawer() )->TrimCacheSize(
|
|
284 |
GetMmModel()->NumberOfItems() );
|
|
285 |
}
|
|
286 |
|
|
287 |
// ---------------------------------------------------------------------------
|
|
288 |
//
|
|
289 |
// ---------------------------------------------------------------------------
|
|
290 |
//
|
|
291 |
TInt CMmListBoxContainer::ColumnsInCurrentView()
|
|
292 |
{
|
|
293 |
return 1;
|
|
294 |
}
|
|
295 |
// ---------------------------------------------------------------------------
|
|
296 |
//
|
|
297 |
// ---------------------------------------------------------------------------
|
|
298 |
//
|
|
299 |
TInt CMmListBoxContainer::RowsInCurrentView()
|
|
300 |
{
|
|
301 |
return iListBox->View()->NumberOfItemsThatFitInRect(
|
|
302 |
iListBox->View()->ViewRect());
|
|
303 |
}
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
//
|
|
306 |
// -----------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
void CMmListBoxContainer::SetVerticalItemOffset( TInt aOffset )
|
|
309 |
{
|
|
310 |
iListBox->SetVerticalItemOffset( aOffset );
|
|
311 |
}
|
|
312 |
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
// -----------------------------------------------------------------------------
|
|
316 |
//
|
|
317 |
TInt CMmListBoxContainer::VerticalItemOffset() const
|
|
318 |
{
|
|
319 |
return iListBox->VerticalItemOffset();
|
|
320 |
}
|
|
321 |
|
|
322 |
//----------------------------------------------------------------------------
|
|
323 |
//
|
|
324 |
// ---------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
void CMmListBoxContainer::UpdateViewScrollBarThumbs()
|
|
327 |
{
|
|
328 |
iListBox->UpdateScrollBarThumbs();
|
|
329 |
}
|
|
330 |
// End of File
|