|
1 /* |
|
2 * Copyright (c) 2005-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: Screen saver view's container. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <aknlists.h> |
|
22 #include <eikclbd.h> |
|
23 |
|
24 // Help context. |
|
25 #include <csxhelp/skins.hlp.hrh> |
|
26 |
|
27 // Psln specific. |
|
28 #include <psln.rsg> |
|
29 #include "PslnModel.h" |
|
30 #include "PslnScreenSaverContainer.h" |
|
31 #include "PslnDebug.h" |
|
32 #include "PslnConst.h" |
|
33 |
|
34 // Framework |
|
35 #include <pslnfwiconhelper.h> |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 // ----------------------------------------------------------------------------- |
|
39 // C++ default constructor can NOT contain any code, that might leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CPslnScreenSaverContainer::CPslnScreenSaverContainer() |
|
43 { |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CPslnScreenSaverContainer::ConstructL( const TRect& aRect ) |
|
51 { |
|
52 iListBox = new (ELeave) CAknSingleGraphicStyleListBox; |
|
53 |
|
54 BaseConstructL( aRect, 0 ); |
|
55 } |
|
56 |
|
57 // Destructor |
|
58 CPslnScreenSaverContainer::~CPslnScreenSaverContainer() |
|
59 { |
|
60 // iListBox is deleted in class CPslnBaseContainer. |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Updates listbox. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CPslnScreenSaverContainer::UpdateListBoxL() |
|
68 { |
|
69 CPslnBaseContainer::UpdateListBoxL(); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // Creates listbox. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CPslnScreenSaverContainer::ConstructListBoxL( TInt /*aResLbxId*/ ) |
|
77 { |
|
78 CreateListBoxItemsL(); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // Creates items for listbox. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CPslnScreenSaverContainer::CreateListBoxItemsL() |
|
86 { |
|
87 PSLN_TRACE_DEBUG("CPslnScreenSaverContainer::CreateListBoxItemsL BEGIN"); |
|
88 __ASSERT_DEBUG( iModel, User::Panic( _L("Psln"), 1 ) ); |
|
89 iItemArray->Reset(); |
|
90 // Find all the screensavers available |
|
91 TInt selectedItem = iModel->CurrentPropertyIndexL( KPslnScreenSettingId ); |
|
92 if ( selectedItem < 0 ) |
|
93 { |
|
94 selectedItem = 0; |
|
95 } |
|
96 |
|
97 const MDesC16Array& ssNames = iModel->ScreensaverNames(); |
|
98 for( TInt i = 0; i < ssNames.MdcaCount(); i++ ) |
|
99 { |
|
100 HBufC* itemBuf = ssNames.MdcaPoint( i ).AllocL(); |
|
101 if ( itemBuf ) |
|
102 { |
|
103 PSLN_TRACE_DEBUG("CPslnScreenSaverContainer::CreateListBoxItemsL 2"); |
|
104 itemBuf = itemBuf->ReAllocL( itemBuf->Length() + KPslnIconSize ); |
|
105 TPtr ptr = itemBuf->Des(); |
|
106 if ( selectedItem == i ) |
|
107 { |
|
108 ptr.Insert( 0, KPslnFWActiveListItemFormat ); |
|
109 } |
|
110 else |
|
111 { |
|
112 ptr.Insert( 0, KPslnFWNonActiveListItemFormat ); |
|
113 } |
|
114 if ( iModel->IsScreenSaverOnMemoryCard( i ) ) |
|
115 { |
|
116 ptr.Append( KPslnFWListItemFormatMMCSuffix ); |
|
117 } |
|
118 else if ( iModel->IsScreenSaverOnMassDrive( i ) ) |
|
119 { |
|
120 ptr.Append( KPslnFWListItemFormatMassDriveSuffix ); |
|
121 } |
|
122 iItemArray->InsertL( i, ptr ); |
|
123 delete itemBuf; |
|
124 } |
|
125 } |
|
126 |
|
127 // Create pre- and post-text icons. |
|
128 CPslnFWIconHelper* iconHelper = CPslnFWIconHelper::NewL(); |
|
129 CleanupStack::PushL( iconHelper ); |
|
130 iconHelper->AddIconsToSettingItemsL( |
|
131 ETrue, |
|
132 KErrNotFound, |
|
133 iListBox ); |
|
134 CleanupStack::PopAndDestroy( iconHelper ); |
|
135 DrawDeferred(); |
|
136 PSLN_TRACE_DEBUG("CPslnScreenSaverContainer::CreateListBoxItemsL END"); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // Gets help context for Help application. |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CPslnScreenSaverContainer::GetHelpContext( |
|
144 TCoeHelpContext& aContext ) const |
|
145 { |
|
146 aContext.iMajor = KUidPsln; |
|
147 aContext.iContext = KSKINS_HLP_SCREENS_SETTINGS; |
|
148 } |
|
149 |
|
150 // End of File |