|
1 /* |
|
2 * Copyright (c) 2009 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "profiler_gui_maincontainer.h" |
|
22 #include "profiler_gui.hrh" |
|
23 #include "profiler_gui_document.h" |
|
24 #include "profiler_gui_appui.h" |
|
25 #include "profiler_gui_model.h" |
|
26 #include <piprofilerui_extraicons.mbg> |
|
27 |
|
28 #include <aknlists.h> |
|
29 #include <eikclb.h> |
|
30 #include <eikclbd.h> |
|
31 #include <aknconsts.h> |
|
32 #include <AknUtils.h> |
|
33 #include <aknnotewrappers.h> |
|
34 #include <AknIconArray.h> |
|
35 #include <f32file.h> |
|
36 #include <AknIconUtils.h> |
|
37 #include <AknDef.h> |
|
38 #include <akntitle.h> |
|
39 #include <eikspane.h> |
|
40 |
|
41 _LIT(KExtraIconsPath, "\\resource\\apps\\piprofilerui_extraicons.mif"); |
|
42 |
|
43 // ===================================== MEMBER FUNCTIONS ===================================== |
|
44 |
|
45 void CProfilerGuiMainContainer::ConstructL(const TRect& aRect) |
|
46 { |
|
47 iModel = static_cast<CProfilerGuiDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model(); |
|
48 iModel->SetMainContainer(this); |
|
49 |
|
50 CreateWindowL(); |
|
51 SetRect(aRect); |
|
52 SetBlank(); |
|
53 |
|
54 // init listbox |
|
55 iListBox = new(ELeave) CAknSingleGraphicStyleListBox; |
|
56 iListBox->SetContainerWindowL(*this); |
|
57 iListBox->ConstructL(this, EAknListBoxMarkableList); |
|
58 iListBox->View()->SetListEmptyTextL(_L("No plugins found yet")); |
|
59 |
|
60 // if description length longer than screen width, scroll the text |
|
61 iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); |
|
62 |
|
63 // create icon array and add marking indicator to it |
|
64 CAknIconArray* iconArray = new(ELeave) CAknIconArray(1); |
|
65 CleanupStack::PushL(iconArray); |
|
66 CFbsBitmap* markBitmap = NULL; |
|
67 CFbsBitmap* markBitmapMask = NULL; |
|
68 |
|
69 TRgb defaultColor; |
|
70 defaultColor = iEikonEnv->Color(EColorControlText); |
|
71 |
|
72 AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), |
|
73 KAknsIIDQgnIndiMarkedAdd, |
|
74 KAknsIIDQsnIconColors, |
|
75 EAknsCIQsnIconColorsCG13, |
|
76 markBitmap, |
|
77 markBitmapMask, |
|
78 AknIconUtils::AvkonIconFileName(), |
|
79 EMbmAvkonQgn_indi_marked_add, |
|
80 EMbmAvkonQgn_indi_marked_add_mask, |
|
81 defaultColor |
|
82 ); |
|
83 |
|
84 CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); |
|
85 iconArray->AppendL(markIcon); |
|
86 |
|
87 // append icons from profiler_gui_extraicons.mif |
|
88 TFileName extraIconsPath; |
|
89 extraIconsPath.Copy(KExtraIconsPath); |
|
90 TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName()); // get path where this app is installed |
|
91 extraIconsPath.Insert(0, parse.Drive()); // drive letter |
|
92 |
|
93 CFbsBitmap* redBitmap = NULL; |
|
94 CFbsBitmap* redBitmapMask = NULL; |
|
95 CFbsBitmap* greenBitmap = NULL; |
|
96 CFbsBitmap* greenBitmapMask = NULL; |
|
97 |
|
98 AknIconUtils::CreateIconL(redBitmap, redBitmapMask, extraIconsPath, EMbmPiprofilerui_extraiconsQgn_prob_piprofilerui_status_disabled, EMbmPiprofilerui_extraiconsQgn_prob_piprofilerui_status_disabled_mask); |
|
99 AknIconUtils::CreateIconL(greenBitmap, greenBitmapMask, extraIconsPath, EMbmPiprofilerui_extraiconsQgn_prob_piprofilerui_status_enabled, EMbmPiprofilerui_extraiconsQgn_prob_piprofilerui_status_enabled_mask); |
|
100 |
|
101 CGulIcon* redIcon = CGulIcon::NewL(redBitmap, redBitmapMask); |
|
102 iconArray->AppendL(redIcon); |
|
103 |
|
104 CGulIcon* greenIcon = CGulIcon::NewL(greenBitmap, greenBitmapMask); |
|
105 iconArray->AppendL(greenIcon); |
|
106 |
|
107 // set icon array |
|
108 CleanupStack::Pop(); // iconArray |
|
109 iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray); |
|
110 |
|
111 iListBox->CreateScrollBarFrameL(ETrue); |
|
112 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
113 iListBox->SetListBoxObserver(this); |
|
114 |
|
115 // set size of the listbox |
|
116 TSize outputRectSize; |
|
117 AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); |
|
118 TRect outputRect(outputRectSize); |
|
119 iListBox->SetRect(outputRect); |
|
120 |
|
121 iListBox->ActivateL(); |
|
122 |
|
123 ActivateL(); |
|
124 |
|
125 iInfoPopup = CAknInfoPopupNoteController::NewL(); |
|
126 iInfoPopup->SetTimePopupInView(5000); |
|
127 iInfoPopup->SetTimeDelayBeforeShow(500); |
|
128 iInfoPopup->SetTextL(_L("TIP: Check also sampler specific settings!")); |
|
129 iInfoPopup->ShowInfoPopupNote(); |
|
130 } |
|
131 |
|
132 // -------------------------------------------------------------------------------------------- |
|
133 |
|
134 CProfilerGuiMainContainer::~CProfilerGuiMainContainer() |
|
135 { |
|
136 delete iInfoPopup; |
|
137 |
|
138 if (iListBox) |
|
139 delete iListBox; |
|
140 } |
|
141 |
|
142 // -------------------------------------------------------------------------------------------- |
|
143 |
|
144 void CProfilerGuiMainContainer::SizeChanged() |
|
145 { |
|
146 TSize outputRectSize; |
|
147 AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); |
|
148 TRect outputRect(outputRectSize); |
|
149 |
|
150 if (iListBox) |
|
151 iListBox->SetRect(outputRect); |
|
152 } |
|
153 |
|
154 // -------------------------------------------------------------------------------------------- |
|
155 |
|
156 TInt CProfilerGuiMainContainer::CountComponentControls() const |
|
157 { |
|
158 if (iListBox) |
|
159 return 1; |
|
160 else |
|
161 return 0; |
|
162 } |
|
163 |
|
164 // -------------------------------------------------------------------------------------------- |
|
165 |
|
166 CCoeControl* CProfilerGuiMainContainer::ComponentControl(TInt /*aIndex*/) const |
|
167 { |
|
168 if (iListBox) |
|
169 return iListBox; |
|
170 else |
|
171 return NULL; |
|
172 } |
|
173 |
|
174 // -------------------------------------------------------------------------------------------- |
|
175 |
|
176 TInt CProfilerGuiMainContainer::CurrentListBoxItemIndex() |
|
177 { |
|
178 if (iListBox) |
|
179 { |
|
180 return iListBox->CurrentItemIndex(); |
|
181 } |
|
182 else |
|
183 return KErrNotFound; |
|
184 } |
|
185 |
|
186 // -------------------------------------------------------------------------------------------- |
|
187 |
|
188 void CProfilerGuiMainContainer::SetListBoxTextArrayL(CDesCArray* aTextArray) |
|
189 { |
|
190 if (iListBox) |
|
191 { |
|
192 iListBox->Model()->SetItemTextArray(aTextArray); |
|
193 iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray); |
|
194 iListBox->HandleItemAdditionL(); |
|
195 iListBox->UpdateScrollBarsL(); |
|
196 } |
|
197 } |
|
198 |
|
199 // -------------------------------------------------------------------------------------------- |
|
200 |
|
201 const CArrayFix<TInt>* CProfilerGuiMainContainer::ListBoxSelectionIndexes() |
|
202 { |
|
203 if (iListBox) |
|
204 { |
|
205 const CListBoxView::CSelectionIndexArray* indices = iListBox->SelectionIndexes(); |
|
206 return static_cast<const CArrayFix<TInt>*>(indices); |
|
207 } |
|
208 else |
|
209 return NULL; |
|
210 } |
|
211 |
|
212 // -------------------------------------------------------------------------------------------- |
|
213 |
|
214 TInt CProfilerGuiMainContainer::ListBoxSelectionIndexesCount() |
|
215 { |
|
216 if (iListBox) |
|
217 { |
|
218 return iListBox->SelectionIndexes()->Count(); |
|
219 } |
|
220 else |
|
221 return KErrNotFound; |
|
222 } |
|
223 |
|
224 // -------------------------------------------------------------------------------------------- |
|
225 |
|
226 void CProfilerGuiMainContainer::Draw(const TRect& aRect) const |
|
227 { |
|
228 CWindowGc& gc = SystemGc(); |
|
229 gc.Clear(aRect); |
|
230 } |
|
231 |
|
232 // -------------------------------------------------------------------------------------------- |
|
233 |
|
234 void CProfilerGuiMainContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) |
|
235 { |
|
236 } |
|
237 |
|
238 // -------------------------------------------------------------------------------------------- |
|
239 |
|
240 void CProfilerGuiMainContainer::SetDefaultTitlePaneTextL() |
|
241 { |
|
242 _LIT(KTitleText, "PIProfiler"); |
|
243 |
|
244 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
245 CAknTitlePane* tp = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
246 tp->SetTextL( KTitleText ); |
|
247 } |
|
248 |
|
249 // -------------------------------------------------------------------------------------------- |
|
250 |
|
251 TKeyResponse CProfilerGuiMainContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
252 { |
|
253 if(aType != EEventKey) |
|
254 return EKeyWasNotConsumed; |
|
255 |
|
256 if (iListBox && iListBox->Model()->NumberOfItems() > 0) |
|
257 { |
|
258 // handle OK/Enter keys |
|
259 if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) |
|
260 { |
|
261 // check if profiler state is idle |
|
262 if(iModel->iState == MProfilerStatusObserver::EIdle) |
|
263 { |
|
264 // show action menu only if state is idle |
|
265 iModel->ShowItemActionMenuL(); |
|
266 } |
|
267 } |
|
268 else |
|
269 { |
|
270 return iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
271 } |
|
272 } |
|
273 |
|
274 return EKeyWasNotConsumed; |
|
275 } |
|
276 |
|
277 // -------------------------------------------------------------------------------------------- |
|
278 |
|
279 void CProfilerGuiMainContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
280 { |
|
281 switch (aEventType) |
|
282 { |
|
283 case EEventEnterKeyPressed: |
|
284 case EEventItemDoubleClicked: |
|
285 { |
|
286 iModel->ShowItemActionMenuL(); |
|
287 } |
|
288 break; |
|
289 default: |
|
290 break; |
|
291 } |
|
292 } |
|
293 |
|
294 // -------------------------------------------------------------------------------------------- |
|
295 |
|
296 void CProfilerGuiMainContainer::HandleResourceChange(TInt aType) |
|
297 { |
|
298 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
299 { |
|
300 TRect mainPaneRect; |
|
301 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
302 SetRect(mainPaneRect); |
|
303 |
|
304 TSize outputRectSize; |
|
305 AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); |
|
306 TRect outputRect(outputRectSize); |
|
307 iListBox->SetRect(outputRect); |
|
308 } |
|
309 else |
|
310 { |
|
311 CCoeControl::HandleResourceChange(aType); |
|
312 } |
|
313 } |
|
314 |
|
315 // -------------------------------------------------------------------------------------------- |
|
316 |
|
317 void CProfilerGuiMainContainer::ShowWriterInfoPopupL(const TDesC& aNote) |
|
318 { |
|
319 if(!iInfoPopup) |
|
320 { |
|
321 iInfoPopup = CAknInfoPopupNoteController::NewL(); |
|
322 } |
|
323 // Hide the note. The last note may be visible when creating the second |
|
324 iInfoPopup->HideInfoPopupNote(); |
|
325 iInfoPopup->SetTimePopupInView(5000); |
|
326 iInfoPopup->SetTimeDelayBeforeShow(500); |
|
327 iInfoPopup->SetTextL(iModel->GetWriterInfoNoteL(aNote)); |
|
328 iInfoPopup->ShowInfoPopupNote(); |
|
329 } |
|
330 |
|
331 |
|
332 // End of File |