54
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2010 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: A list box that displays settings items with radio buttons*
|
|
15 |
*/
|
|
16 |
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include "CamCaptureSetupListBox.h"
|
|
20 |
#include "CamCaptureSetupListBoxModel.h"
|
|
21 |
#include "CamCaptureSetupListItemDrawer.h"
|
|
22 |
#include "CamSettingValueObserver.h"
|
|
23 |
#include <uikon.hrh>
|
|
24 |
|
|
25 |
#include "CamUtility.h"
|
|
26 |
|
|
27 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
28 |
|
|
29 |
// ================= MEMBER FUNCTIONS =======================
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// CCamCaptureSetupListBox::CCamCaptureSetupListBox
|
|
33 |
// C++ constructor
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
CCamCaptureSetupListBox::CCamCaptureSetupListBox( MCamSettingValueObserver* aObserver
|
|
37 |
#ifndef CAMERAAPP_PLUGIN_BUILD
|
|
38 |
,CCamAppController& aController
|
|
39 |
#else
|
|
40 |
,MCamAppController& aController
|
|
41 |
#endif //CAMERAAPP_PLUGIN_BUILD
|
|
42 |
,TBool aSkinnedBackGround
|
|
43 |
)
|
|
44 |
: iSettingObserver( aObserver ), iController( aController ), iSkinnedBackGround( aSkinnedBackGround )
|
|
45 |
{
|
|
46 |
iBorder = TGulBorder::ENone;
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// CCamCaptureSetupListBox::ConstructL
|
|
51 |
// 2nd phase construction
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
void CCamCaptureSetupListBox::ConstructL( const CCoeControl* aParent,
|
|
55 |
TInt aArrayResourceId,
|
|
56 |
TInt aSettingItem,
|
|
57 |
TInt aFlags,
|
|
58 |
TBool aShootingModeListBox,
|
|
59 |
TBool aLocationSettingListBox
|
|
60 |
)
|
|
61 |
{
|
|
62 |
|
|
63 |
//Constructing model
|
|
64 |
CCamCaptureSetupListBoxModel* model =
|
|
65 |
CCamCaptureSetupListBoxModel::NewLC( iController,
|
|
66 |
aArrayResourceId,
|
|
67 |
aSettingItem,
|
|
68 |
aShootingModeListBox,
|
|
69 |
aLocationSettingListBox,
|
|
70 |
Rect()
|
|
71 |
);
|
|
72 |
CCamCaptureSetupListItemDrawer* itemDrawer =
|
|
73 |
CCamCaptureSetupListItemDrawer::NewL( *model, iSkinnedBackGround || aLocationSettingListBox );
|
|
74 |
|
|
75 |
itemDrawer->SetParentControl( aParent );
|
|
76 |
// CEikListBox takes ownership before anything can leave.
|
|
77 |
// Do not need the model or drawer on the stack when call ConstructL,
|
|
78 |
// because CEikListBox assigns objects as member variables before
|
|
79 |
// ConstructL calls any leaving functions.
|
|
80 |
CleanupStack::Pop( model );
|
|
81 |
CEikListBox::ConstructL( model, itemDrawer, aParent, aFlags );
|
|
82 |
// The number of items is fixed after the list box has been constructed
|
|
83 |
const TInt KMaxListItems = 5; // This value should come from the LAF
|
|
84 |
// Find the number of items to be displayed in the list box
|
|
85 |
iRequiredHeightInNumOfItems = Min( Model()->NumberOfItems(), KMaxListItems );
|
|
86 |
SetItemHeightL( iItemDrawer->MinimumCellSize().iHeight );
|
|
87 |
}
|
|
88 |
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
// CCamCaptureSetupListBox destructor
|
|
91 |
//
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
CCamCaptureSetupListBox::~CCamCaptureSetupListBox()
|
|
95 |
{
|
|
96 |
PRINT( _L("Camera => ~CCamCaptureSetupListBox") );
|
|
97 |
PRINT( _L("Camera <= ~CCamCaptureSetupListBox") );
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// CCamCaptureSetupListBox::InitializeL
|
|
102 |
// Initialize the current and selected item in the view
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
void CCamCaptureSetupListBox::InitializeL( TInt aCurrentValueId )
|
|
106 |
{
|
|
107 |
TInt selectedItemIndex =
|
|
108 |
static_cast<MCamListboxModel*>( iModel )->ValueIndex( aCurrentValueId );
|
|
109 |
|
|
110 |
// if the item does not exist select the topmost item
|
|
111 |
selectedItemIndex = Max( selectedItemIndex, 0 );
|
|
112 |
if ( selectedItemIndex < iModel->NumberOfItems() )
|
|
113 |
{
|
|
114 |
iView->SetCurrentItemIndex( selectedItemIndex );
|
|
115 |
iView->SetDisableRedraw( ETrue );
|
|
116 |
iView->SelectItemL( selectedItemIndex );
|
|
117 |
iView->SetDisableRedraw( EFalse );
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
// CCamCaptureSetupListBox::OfferKeyEventL
|
|
123 |
// Handle key presses
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
TKeyResponse CCamCaptureSetupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType )
|
|
127 |
{
|
|
128 |
PRINT( _L("Camera => CCamCaptureSetupListBox::OfferKeyEventL" ))
|
|
129 |
|
|
130 |
if ( !IsHighlightEnabled() &&
|
|
131 |
aKeyEvent.iCode != EKeyUpArrow &&
|
|
132 |
aKeyEvent.iCode != EKeyDownArrow )
|
|
133 |
{
|
|
134 |
PRINT( _L("Camera <= CCamCaptureSetupListBox::OfferKeyEventL highlight not visible" ))
|
|
135 |
return EKeyWasNotConsumed;
|
|
136 |
}
|
|
137 |
|
|
138 |
TInt oldCurrentItem = CurrentItemIndex();
|
|
139 |
TKeyResponse response = CEikListBox::OfferKeyEventL( aKeyEvent, aType );
|
|
140 |
TInt newCurrentItem = CurrentItemIndex();
|
|
141 |
|
|
142 |
if ( newCurrentItem != oldCurrentItem )
|
|
143 |
{
|
|
144 |
PRINT( _L("Camera <> CCamCaptureSetupListBox::OfferKeyEventL set obs" ))
|
|
145 |
MCamListboxModel* model = static_cast<MCamListboxModel*>( iModel );
|
|
146 |
iSettingObserver->HandleSettingValueUpdateL( model->ItemValue( newCurrentItem ) );
|
|
147 |
}
|
|
148 |
else
|
|
149 |
{
|
|
150 |
PRINT( _L("Camera <= CCamCaptureSetupListBox::OfferKeyEventL EKeyWasConsumed" ))
|
|
151 |
response = EKeyWasNotConsumed;
|
|
152 |
}
|
|
153 |
|
|
154 |
PRINT( _L("Camera <= CCamCaptureSetupListBox::OfferKeyEventL" ))
|
|
155 |
return response;
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
// CCamCaptureSetupListBox::HandlePointerEventL
|
|
160 |
// Handle pointer events
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
void CCamCaptureSetupListBox::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
164 |
{
|
|
165 |
/*TInt oldCurrentItem = CurrentItemIndex();
|
|
166 |
TInt newCurrentItem = CurrentItemIndex();
|
|
167 |
|
|
168 |
// listbox does default handling
|
|
169 |
CEikListBox::HandlePointerEventL(aPointerEvent);
|
|
170 |
|
|
171 |
newCurrentItem = CurrentItemIndex();
|
|
172 |
|
|
173 |
// handle settings update when focus changes
|
|
174 |
if ( newCurrentItem != oldCurrentItem )
|
|
175 |
{
|
|
176 |
MCamListboxModel* model = static_cast<MCamListboxModel*>( iModel );
|
|
177 |
iSettingObserver->HandleSettingValueUpdateL( model->ItemValue( newCurrentItem ) );
|
|
178 |
|
|
179 |
}*/
|
|
180 |
iController.StartIdleTimer(); // standby
|
|
181 |
CEikListBox::HandlePointerEventL(aPointerEvent);
|
|
182 |
}
|
|
183 |
|
|
184 |
|
|
185 |
//End of file
|
|
186 |
|