|
1 /* |
|
2 * Copyright (c) 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: Simulation PSY file selector dialog. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <AknIconArray.h> // Icon Array |
|
21 #include <eikclbd.h> // Column Listbox |
|
22 #include <aknlists.h> // CAknPopupList |
|
23 #include <aknconsts.h> |
|
24 #include <AknIconArray.h> |
|
25 #include <AknsUtils.h> |
|
26 #include <AknsConstants.h> |
|
27 #include <avkon.mbg> |
|
28 #include <gulicon.h> |
|
29 #include <fbs.h> |
|
30 |
|
31 // USER INCLUDES |
|
32 #include "simpsyfileselector.h" |
|
33 #include "simpsyfileselectormodel.h" |
|
34 |
|
35 // ========================= MEMBER FUNCTIONS ================================ |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CSimPsyFileSelector::CSimPsyFileSelector |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CSimPsyFileSelector::CSimPsyFileSelector() |
|
42 { |
|
43 // C++ Default constructor. No allocations or functions which can Leave |
|
44 // should be called from here. |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CSimPsyFileSelector::~CSimPsyFileSelector |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CSimPsyFileSelector::~CSimPsyFileSelector() |
|
52 { |
|
53 // C++ Destructor. Free all resources associated with this class. |
|
54 |
|
55 // Delete the List box model. |
|
56 delete iListBoxModel; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // void CSimPsyFileSelector::ConstructL |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CSimPsyFileSelector::ConstructL( CCoeControl* aParent ) |
|
64 { |
|
65 // Create the list box model |
|
66 iListBoxModel = CSimPsyFileSelectorModel::NewL(); |
|
67 |
|
68 CAknSingleGraphicPopupMenuStyleListBox::ConstructL( aParent, EAknListBoxMenuList ); |
|
69 |
|
70 CreateScrollBarFrameL( ETrue ); |
|
71 ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
72 CEikScrollBarFrame::EAuto ); |
|
73 |
|
74 UpdateIconsL(); |
|
75 |
|
76 Model()->SetItemTextArray( iListBoxModel ); |
|
77 Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
78 |
|
79 ActivateL(); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // void CSimPsyFileSelector::UpdateIconsL |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CSimPsyFileSelector::UpdateIconsL() |
|
87 { |
|
88 // Add icons to listbox |
|
89 CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 1 ); |
|
90 CleanupStack::PushL( iconArray ); |
|
91 |
|
92 CFbsBitmap* bitmap = NULL; |
|
93 CFbsBitmap* mask = NULL; |
|
94 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
|
95 KAknsIIDQgnPropNrtypNote, |
|
96 bitmap, |
|
97 mask, |
|
98 KAvkonBitmapFile, |
|
99 EMbmAvkonQgn_prop_nrtyp_note, |
|
100 EMbmAvkonQgn_prop_nrtyp_note_mask ); |
|
101 CleanupStack::PushL( bitmap ); |
|
102 CleanupStack::PushL( mask ); |
|
103 |
|
104 // Ownership is transferred to CGulIcon |
|
105 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
106 CleanupStack::Pop( 2 ); // mask, bitmap |
|
107 CleanupStack::PushL( icon ); |
|
108 iconArray->AppendL( icon ); // Ownership is transferred to CAknIconArray |
|
109 CleanupStack::Pop( icon ); // icon |
|
110 |
|
111 // Get old icons and delete those. This is done because SetIconArray will |
|
112 // not do it. |
|
113 CAknIconArray* oldIcons = |
|
114 static_cast<CAknIconArray*>( ItemDrawer()->ColumnData()->IconArray()); |
|
115 |
|
116 delete oldIcons; |
|
117 |
|
118 //Set New Icons to array |
|
119 ItemDrawer()->ColumnData()->SetIconArray( iconArray ); |
|
120 CleanupStack::Pop( iconArray ); |
|
121 |
|
122 // Enable Marquee scrolling |
|
123 ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); |
|
124 |
|
125 DrawDeferred(); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 //TPtrC CSimPsyFileSelector::SimulationFileNameL |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 TPtrC CSimPsyFileSelector::SimulationFileNameL() |
|
133 { |
|
134 return iListBoxModel->SimulationFileNameL( CurrentItemIndex()); |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // void CSimPsyFileSelector::HandleResourceChange |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CSimPsyFileSelector::HandleResourceChange( TInt aType ) |
|
142 { |
|
143 // Pass the event to the base class |
|
144 CCoeControl::HandleResourceChange( aType ); |
|
145 switch( aType ) |
|
146 { |
|
147 // Dynamic Layout switch and Skin Change |
|
148 case KEikDynamicLayoutVariantSwitch: |
|
149 { |
|
150 SetRect( Rect()); |
|
151 break; |
|
152 } |
|
153 case KAknsMessageSkinChange: |
|
154 { |
|
155 TRAP_IGNORE( UpdateIconsL()); |
|
156 break; |
|
157 } |
|
158 default: |
|
159 { |
|
160 break; |
|
161 } |
|
162 } |
|
163 DrawDeferred(); |
|
164 } |