|
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: Base class for MediaSettings views.* |
|
15 */ |
|
16 |
|
17 |
|
18 // Version : %version: 4 % |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <aknViewAppUi.h> |
|
25 #include <akntitle.h> |
|
26 #include <barsread.h> |
|
27 #include <aknnavi.h> |
|
28 #include <aknnavide.h> |
|
29 #include <featmgr.h> |
|
30 #include <eikmenup.h> |
|
31 #include <MediaSettings.rsg> |
|
32 #include <StringLoader.h> |
|
33 #include "mediasettings.hrh" |
|
34 #include "MPSettingsAppUi.h" |
|
35 #include "MPSettingsBaseView.h" |
|
36 #include "MPSettingsBaseContainer.h" |
|
37 #include "MPSettingsNaviPaneController.h" |
|
38 #include "MPSettingsConstants.h" |
|
39 #include "mpxlog.h" |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CMPSettingsBaseView::CMPSettingsBaseView |
|
45 // C++ default constructor can NOT contain any code, that |
|
46 // might leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CMPSettingsBaseView::CMPSettingsBaseView() |
|
50 { |
|
51 MPX_DEBUG1(_L("#MS# CMPSettingsBaseView::CMPSettingsBaseView()")); |
|
52 iNaviCntrl = static_cast<CMPSettingsAppUi*>(AppUi()); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CMPSettingsBaseView::~CMPSettingsBaseView |
|
57 // Destructor |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 EXPORT_C CMPSettingsBaseView::~CMPSettingsBaseView() |
|
61 { |
|
62 MPX_DEBUG1(_L("#MS# CMPSettingsBaseView::~CMPSettingsBaseView()")); |
|
63 if (iContainer) |
|
64 { |
|
65 AppUi()->RemoveFromStack(iContainer); |
|
66 delete iContainer; |
|
67 } |
|
68 |
|
69 if (iNaviPaneContext && iNaviPaneContext != iNaviCntrl->MPTabGroup()) |
|
70 { |
|
71 delete iNaviPaneContext; |
|
72 } |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CMPSettingsBaseView::HandleClientRectChange |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C void CMPSettingsBaseView::HandleClientRectChange() |
|
80 { |
|
81 MPX_DEBUG1(_L("#MS# CMPSettingsBaseView::HandleClientRectChange()")); |
|
82 if (iContainer) |
|
83 { |
|
84 iContainer->SetRect(ClientRect()); |
|
85 } |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CMPSettingsBaseView::HandleClientRectChange |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C void CMPSettingsBaseView::SetCurrentItem(TInt aIndex) |
|
93 { |
|
94 MPX_DEBUG2(_L("#MS# CMPSettingsBaseView::SetCurrentItem(%d)"),aIndex); |
|
95 iCurrentItem = aIndex; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CMPSettingsBaseView::DoActivateL |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C void CMPSettingsBaseView::DoActivateL( |
|
103 const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, |
|
104 const TDesC8& /*aCustomMessage*/) |
|
105 { |
|
106 MPX_DEBUG1(_L("#MS# CMPSettingsBaseView::DoActivateL()")); |
|
107 // Set correct navi pane |
|
108 SetNaviPaneL(); |
|
109 |
|
110 // Create iContainer if one does not exist |
|
111 if (!iContainer) |
|
112 { |
|
113 iContainer = NewContainerL(); |
|
114 |
|
115 __ASSERT_DEBUG(iContainer, User::Panic(_L("DoActivateL"), EMPViewPanicNullPtr)); |
|
116 |
|
117 iContainer->SetMopParent(this); |
|
118 |
|
119 // Construction of component control could fail => delete iContainer in order |
|
120 // to quarantee that it is constructed again the next time it is used. |
|
121 TRAPD(error, iContainer->ConstructL(ClientRect())); |
|
122 if (error) |
|
123 { |
|
124 delete iContainer; |
|
125 iContainer = NULL; |
|
126 User::Leave(error); |
|
127 } |
|
128 |
|
129 AppUi()->AddToStackL(*this, iContainer); |
|
130 |
|
131 DynInitContainerL(); |
|
132 } |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // CMPSettingsBaseView::HandleCommandL |
|
137 // --------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C void CMPSettingsBaseView::DoDeactivate() |
|
140 { |
|
141 MPX_DEBUG1(_L("#MS# CMPSettingsBaseView::DoDeactivate()")); |
|
142 if (iContainer) |
|
143 { |
|
144 CEikTextListBox* listbox = iContainer->ListBox(); |
|
145 if (listbox) |
|
146 { |
|
147 iCurrentItem = listbox->CurrentItemIndex(); |
|
148 iTopItemIndex = listbox->TopItemIndex(); |
|
149 } |
|
150 |
|
151 AppUi()->RemoveFromStack(iContainer); |
|
152 delete iContainer; |
|
153 iContainer = NULL; |
|
154 } |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CMPSettingsBaseView::DynInitMenuPaneL |
|
159 // Before showing a options menu |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C void CMPSettingsBaseView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
163 { |
|
164 MPX_DEBUG2(_L("#MS# CMPSettingsBaseView::DynInitMenuPaneL(0x%X)"),aResourceId); |
|
165 if (aResourceId == R_MPSETT_APP_MENU) |
|
166 { |
|
167 // Help should be displayed only if the feature is supported according |
|
168 // to Feature Manager |
|
169 if (!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
170 { |
|
171 aMenuPane->SetItemDimmed(EMPSettCmdHelp, ETrue); |
|
172 } |
|
173 } |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // CMPSettingsBaseView::SetNaviPaneL |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C void CMPSettingsBaseView::SetNaviPaneL() |
|
181 { |
|
182 MPX_DEBUG1(_L("#MS# CMPSettingsBaseView::SetNaviPaneL()")); |
|
183 if (iNaviPaneContext) |
|
184 { |
|
185 iNaviCntrl->NaviContainer()->PushL(*iNaviPaneContext); |
|
186 if (iNaviPaneContext == iNaviCntrl->MPTabGroup()) |
|
187 { |
|
188 iNaviCntrl->UpdateTabIndex(); |
|
189 } |
|
190 } |
|
191 else |
|
192 { |
|
193 iNaviCntrl->NaviContainer()->PushDefaultL(); |
|
194 } |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CMPSettingsBaseView::DynInitContainerL |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C void CMPSettingsBaseView::DynInitContainerL() |
|
202 { |
|
203 MPX_DEBUG1(_L("#MS# CMPSettingsBaseView::DynInitContainerL()")); |
|
204 // Do nothing. |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CMPSettingsBaseView::SetMiddleSoftKeyLabelL |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 EXPORT_C void CMPSettingsBaseView::SetMiddleSoftKeyLabelL( const TInt aResourceId, const TInt aCommandId ) |
|
212 { |
|
213 MPX_DEBUG1(_L("#MS# CMPSettingsBaseView::SetMiddleSoftKeyLabelL()")); |
|
214 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
215 if ( cbaGroup ) |
|
216 { |
|
217 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
218 TPtr mskPtr = middleSKText->Des(); |
|
219 MPX_DEBUG2(_L("#MS# CMPSettingsBaseView::SetMiddleSoftKeyLabelL(%S)"),&mskPtr); |
|
220 cbaGroup->AddCommandToStackL( |
|
221 KMediaSettingsMSKControlID, |
|
222 aCommandId, |
|
223 mskPtr ); |
|
224 CleanupStack::PopAndDestroy( middleSKText ); |
|
225 } |
|
226 } |
|
227 |
|
228 // End of File |