23
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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 the License "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: Container class for Main view.*
|
|
15 |
*/
|
|
16 |
|
|
17 |
|
|
18 |
// Version : %version: 10 %
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
// INCLUDE FILES
|
|
24 |
#include <barsread.h>
|
|
25 |
#include <MediaSettings.rsg>
|
|
26 |
#include <aknlists.h>
|
|
27 |
#include <AknIconArray.h>
|
|
28 |
#include <AknsUtils.h>
|
|
29 |
#include <gulicon.h>
|
|
30 |
#include <calslbs.h>
|
|
31 |
#include <eikclbd.h>
|
|
32 |
#include <StringLoader.h>
|
|
33 |
#include <mediasettings.mbg>
|
|
34 |
#include <featmgr.h>
|
|
35 |
#include <aknnotewrappers.h>
|
|
36 |
#include <textresolver.h>
|
|
37 |
#include <AknCommonDialogs.h>
|
|
38 |
#include <csxhelp/iptv.hlp.hrh>
|
|
39 |
|
|
40 |
#include "MPSettingsApp.h"
|
|
41 |
#include "MPSettingsMainContainer.h"
|
|
42 |
#include "MPSettingsConstants.h"
|
|
43 |
#include "mpxlog.h"
|
|
44 |
|
|
45 |
// CONSTANTS
|
|
46 |
const TInt KIconArrayGranularity = 2;
|
|
47 |
|
|
48 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
// CMPSettingsMainContainer::CMPSettingsMainContainer
|
|
52 |
// C++ default constructor can NOT contain any code, that
|
|
53 |
// might leave.
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CMPSettingsMainContainer::CMPSettingsMainContainer()
|
|
57 |
{
|
|
58 |
MPX_DEBUG1(_L("#MS# CMPSettingsMainContainer::CMPSettingsMainContainer()"));
|
|
59 |
}
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// CMPSettingsMainContainer::~CMPSettingsMainContainer
|
|
63 |
// Destructor
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CMPSettingsMainContainer::~CMPSettingsMainContainer()
|
|
67 |
{
|
|
68 |
MPX_DEBUG1(_L("#MS# CMPSettingsMainContainer::~CMPSettingsMainContainer()"));
|
|
69 |
if (iListBox)
|
|
70 |
{
|
|
71 |
delete iListBox;
|
|
72 |
}
|
|
73 |
}
|
|
74 |
|
|
75 |
// ---------------------------------------------------------
|
|
76 |
// CMPSettingsMainContainer::ConstructComponentControlsL
|
|
77 |
// ---------------------------------------------------------
|
|
78 |
//
|
|
79 |
void CMPSettingsMainContainer::ConstructComponentControlsL()
|
|
80 |
{
|
|
81 |
MPX_DEBUG1(_L("#MS# CMPSettingsMainContainer::ConstructComponentControlsL()"));
|
|
82 |
// * Create listbox *
|
|
83 |
|
|
84 |
iListBox = new(ELeave) CAknSingleLargeStyleListBox;
|
|
85 |
|
|
86 |
// Set's iListBox to be contained in this container
|
|
87 |
iListBox->SetContainerWindowL(*this);
|
|
88 |
|
|
89 |
// Construct from resource
|
|
90 |
TResourceReader rReader;
|
|
91 |
iCoeEnv->Static()->CreateResourceReaderLC(rReader,
|
|
92 |
R_MPSETT_MAIN_LBX_RESOURCE);
|
|
93 |
|
|
94 |
// Construct's iListBox from resource file
|
|
95 |
iListBox->ConstructFromResourceL(rReader);
|
|
96 |
CleanupStack::PopAndDestroy(); // rReader
|
|
97 |
|
|
98 |
iListBox->CreateScrollBarFrameL(ETrue);
|
|
99 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
100 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
101 |
|
|
102 |
MakeIconArrayL();
|
|
103 |
|
|
104 |
iComponentControl = iListBox;
|
|
105 |
}
|
|
106 |
|
|
107 |
// ---------------------------------------------------------
|
|
108 |
// CMPSettingsMainContainer::HandleResourceChange
|
|
109 |
// ---------------------------------------------------------
|
|
110 |
//
|
|
111 |
void CMPSettingsMainContainer::HandleResourceChange( TInt aType )
|
|
112 |
{
|
|
113 |
MPX_DEBUG2(_L("#MS# CMPSettingsMainContainer::HandleResourceChange(0x%X)"),aType);
|
|
114 |
CCoeControl::HandleResourceChange( aType );
|
|
115 |
|
|
116 |
if( aType == KAknsMessageSkinChange )
|
|
117 |
{
|
|
118 |
TRAPD(err,MakeIconArrayL());
|
|
119 |
|
|
120 |
if( err )
|
|
121 |
{
|
|
122 |
TRAP_IGNORE( HandleResourceChangeErrorL( err ) );
|
|
123 |
}
|
|
124 |
}
|
|
125 |
else if ( aType == KEikDynamicLayoutVariantSwitch ) //Handle change in layout orientation
|
|
126 |
{
|
|
127 |
TRect mainPaneRect;
|
|
128 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
|
|
129 |
SetRect( mainPaneRect );
|
|
130 |
DrawNow();
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
// ---------------------------------------------------------
|
|
135 |
// CMPSettingsMainContainer::HandleResourceChangeErrorL
|
|
136 |
// ---------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CMPSettingsMainContainer::HandleResourceChangeErrorL( TInt aError )
|
|
139 |
{
|
|
140 |
CTextResolver* textresolver = NULL;
|
|
141 |
|
|
142 |
// TextResolver instance for error resolving.
|
|
143 |
textresolver = CTextResolver::NewL();
|
|
144 |
|
|
145 |
if ( textresolver )
|
|
146 |
{
|
|
147 |
// Resolve the error text
|
|
148 |
TPtrC text;
|
|
149 |
text.Set(textresolver->ResolveErrorString( aError ));
|
|
150 |
|
|
151 |
CAknErrorNote* dlg = new (ELeave) CAknErrorNote(ETrue);
|
|
152 |
dlg->ExecuteLD(text);
|
|
153 |
|
|
154 |
delete textresolver;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------
|
|
159 |
// CMPSettingsMainContainer::TitleResourceId
|
|
160 |
// ---------------------------------------------------------
|
|
161 |
//
|
|
162 |
TInt CMPSettingsMainContainer::TitleResourceId()
|
|
163 |
{
|
|
164 |
return R_MPSETT_MAIN_VIEW_TITLE;
|
|
165 |
}
|
|
166 |
|
|
167 |
// ---------------------------------------------------------
|
|
168 |
// CMPSettingsMainContainer::GetHelpContext
|
|
169 |
// ---------------------------------------------------------
|
|
170 |
//
|
|
171 |
void CMPSettingsMainContainer::GetHelpContext(TCoeHelpContext& aContext) const
|
|
172 |
{
|
|
173 |
MPX_DEBUG1(_L("#MS# CMPSettingsMainContainer::GetHelpContext()"));
|
|
174 |
aContext.iMajor = KIptvHelpContextUid;
|
|
175 |
aContext.iContext = KIPTV_HLP_SETTINGS;
|
|
176 |
}
|
|
177 |
|
|
178 |
// ---------------------------------------------------------
|
|
179 |
// CMPSettingsMainContainer::MakeIconArrayL
|
|
180 |
// ---------------------------------------------------------
|
|
181 |
//
|
|
182 |
void CMPSettingsMainContainer::MakeIconArrayL()
|
|
183 |
{
|
|
184 |
MPX_DEBUG1(_L("#MS# CMPSettingsMainContainer::MakeIconArrayL()"));
|
|
185 |
|
|
186 |
TFileName fileName;
|
|
187 |
|
|
188 |
// Construct CAknIconArray for iListBox
|
|
189 |
CEikColumnListBox* listbox =
|
|
190 |
static_cast<CEikColumnListBox*>( iListBox );
|
|
191 |
|
|
192 |
delete listbox->ItemDrawer()->ColumnData()->IconArray();
|
|
193 |
listbox->ItemDrawer()->ColumnData()->SetIconArray( NULL );
|
|
194 |
|
|
195 |
HBufC* mbmpath = StringLoader::LoadLC( R_MPSETT_ICON_MBM_FILE );
|
|
196 |
|
|
197 |
// This is done to ensure upgraded file is used first.
|
|
198 |
// If no upgraded file is found, default file in Z: drive will be used.
|
|
199 |
TFindFile find( CCoeEnv::Static()->FsSession() );
|
|
200 |
TInt err = find.FindByDir( *mbmpath, KNullDesC );
|
|
201 |
|
|
202 |
if ( err )
|
|
203 |
{
|
|
204 |
fileName.Append( *mbmpath );
|
|
205 |
}
|
|
206 |
else
|
|
207 |
{
|
|
208 |
fileName.Append( find.File() );
|
|
209 |
}
|
|
210 |
|
|
211 |
CAknIconArray* icons =
|
|
212 |
new ( ELeave ) CAknIconArray( KIconArrayGranularity );
|
|
213 |
CleanupStack::PushL( icons );
|
|
214 |
|
|
215 |
AppendIconToArrayL(
|
|
216 |
icons,
|
|
217 |
KAknsIIDQgnPropSetMpVideoSub,
|
|
218 |
fileName,
|
|
219 |
EMbmMediasettingsQgn_prop_set_mp_video_sub,
|
|
220 |
EMbmMediasettingsQgn_prop_set_mp_video_sub_mask );
|
|
221 |
|
|
222 |
AppendIconToArrayL(
|
|
223 |
icons,
|
|
224 |
KAknsIIDQgnPropSetMpStreamSub,
|
|
225 |
fileName,
|
|
226 |
EMbmMediasettingsQgn_prop_set_mp_stream_sub,
|
|
227 |
EMbmMediasettingsQgn_prop_set_mp_stream_sub_mask );
|
|
228 |
|
|
229 |
|
|
230 |
CleanupStack::Pop(); // icons
|
|
231 |
CleanupStack::PopAndDestroy(); // mbmpath
|
|
232 |
|
|
233 |
listbox->ItemDrawer()->ColumnData()->SetIconArray( icons );
|
|
234 |
|
|
235 |
}
|
|
236 |
|
|
237 |
// ---------------------------------------------------------
|
|
238 |
// CMPSettingsMainContainer::AppendIconToArrayL
|
|
239 |
// ---------------------------------------------------------
|
|
240 |
//
|
|
241 |
void CMPSettingsMainContainer::AppendIconToArrayL(
|
|
242 |
CAknIconArray* aArray,
|
|
243 |
const TAknsItemID& aID,
|
|
244 |
const TDesC& aMbmFile,
|
|
245 |
TInt aBitmapId,
|
|
246 |
TInt aMaskId )
|
|
247 |
{
|
|
248 |
|
|
249 |
MPX_DEBUG1(_L("#MS# CMPSettingsMainContainer::AppendIconToArrayL()"));
|
|
250 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
251 |
|
|
252 |
CFbsBitmap* bitmap = NULL;
|
|
253 |
CFbsBitmap* mask = NULL;
|
|
254 |
|
|
255 |
AknsUtils::CreateIconLC( skin, aID,
|
|
256 |
bitmap, mask, aMbmFile, aBitmapId, aMaskId );
|
|
257 |
|
|
258 |
CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
|
|
259 |
icon->SetBitmapsOwnedExternally( EFalse );
|
|
260 |
|
|
261 |
// icon now owns the bitmaps, no need to keep on cleanup stack.
|
|
262 |
CleanupStack::Pop(2); // mask, bitmap
|
|
263 |
bitmap = NULL;
|
|
264 |
mask = NULL;
|
|
265 |
|
|
266 |
CleanupStack::PushL( icon );
|
|
267 |
aArray->AppendL( icon );
|
|
268 |
|
|
269 |
// aArray now owns the icon, no need to delete.
|
|
270 |
CleanupStack::Pop();
|
|
271 |
}
|
|
272 |
|
|
273 |
// ---------------------------------------------------------
|
|
274 |
// CMPSettingsMainContainer::FocusChanged
|
|
275 |
// ---------------------------------------------------------
|
|
276 |
//
|
|
277 |
void CMPSettingsMainContainer::FocusChanged(TDrawNow /*aDrawNow*/)
|
|
278 |
{
|
|
279 |
if( iListBox)
|
|
280 |
{
|
|
281 |
iListBox->SetFocus( IsFocused() );
|
|
282 |
}
|
|
283 |
}
|
|
284 |
|
|
285 |
// End of File
|