1 /* |
|
2 * Copyright (c) 2005-2006 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 Configuration UI server application class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <aknlists.h> |
|
19 |
|
20 #include "simpsyuiappui.h" |
|
21 #include "simpsyuicontainer.h" |
|
22 #include "simpsyuilbmodel.h" |
|
23 |
|
24 // --------------------------------------------------------- |
|
25 // void CSimPsyUiContainer::ConstructL |
|
26 // --------------------------------------------------------- |
|
27 // |
|
28 void CSimPsyUiContainer::ConstructL( const TRect& aRect, |
|
29 CSimPsyUiAppUi* aAppUi ) |
|
30 { |
|
31 if( !aAppUi ) |
|
32 { |
|
33 User::Leave( KErrArgument ); |
|
34 } |
|
35 iAppUi = aAppUi; |
|
36 CreateWindowL(); |
|
37 CreateListboxL(); |
|
38 SetRect(aRect); |
|
39 ActivateL(); |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------- |
|
43 // CSimPsyUiContainer::~CSimPsyUiContainer |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 CSimPsyUiContainer::~CSimPsyUiContainer() |
|
47 { |
|
48 delete iListBox; |
|
49 iListBox = NULL; |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------- |
|
53 // TKeyResponse CSimPsyUiContainer::OfferKeyEventL |
|
54 // --------------------------------------------------------- |
|
55 // |
|
56 TKeyResponse CSimPsyUiContainer::OfferKeyEventL |
|
57 ( const TKeyEvent& /*aKeyEvent*/, |
|
58 TEventCode /*aType*/ ) |
|
59 { |
|
60 return TKeyResponse( EKeyWasConsumed ) ; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // void CSimPsyUiContainer::UpdateListBox |
|
65 // --------------------------------------------------------- |
|
66 // |
|
67 void CSimPsyUiContainer::UpdateListBox() |
|
68 { |
|
69 if ( iListBox ) |
|
70 { |
|
71 iListBox->DrawDeferred(); |
|
72 } |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // void CSimPsyUiContainer::CreateListboxL |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 void CSimPsyUiContainer::CreateListboxL() |
|
80 { |
|
81 |
|
82 delete iListBox; |
|
83 iListBox = NULL; |
|
84 |
|
85 iListBox = new( ELeave ) CAknDoubleStyleListBox; |
|
86 iListBox->SetContainerWindowL( *this ); |
|
87 iListBox->ConstructL( this, EAknGenericListBoxFlags); |
|
88 |
|
89 CSimPsyUiLBModel* lLBModel = CSimPsyUiLBModel::NewLC(); |
|
90 |
|
91 iListBox->Model()->SetItemTextArray( lLBModel ); |
|
92 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
93 CleanupStack::Pop(lLBModel); // model |
|
94 |
|
95 iListBox->DrawNow(); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CSimPsyUiContainer::SizeChanged() |
|
100 // Called by framework when the view size is changed |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 void CSimPsyUiContainer::SizeChanged() |
|
104 { |
|
105 if ( iListBox ) |
|
106 { |
|
107 iListBox->SetRect( Rect() ); |
|
108 } |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CSimPsyUiContainer::CountComponentControls() const |
|
113 // --------------------------------------------------------- |
|
114 // |
|
115 TInt CSimPsyUiContainer::CountComponentControls() const |
|
116 { |
|
117 if( iListBox ) |
|
118 { |
|
119 return 1; |
|
120 } |
|
121 else |
|
122 { |
|
123 return 0; |
|
124 } |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // CSimPsyUiContainer::ComponentControl |
|
129 // --------------------------------------------------------- |
|
130 // |
|
131 CCoeControl* CSimPsyUiContainer::ComponentControl( TInt /*aIndex*/ ) const |
|
132 { |
|
133 if( iListBox ) |
|
134 { |
|
135 return iListBox; |
|
136 } |
|
137 else |
|
138 { |
|
139 return NULL; |
|
140 } |
|
141 } |
|
142 // --------------------------------------------------------- |
|
143 // CSimPsyUiContainer::FocusChanged |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void CSimPsyUiContainer::FocusChanged(TDrawNow aDrawNow) |
|
147 { |
|
148 if( iListBox ) |
|
149 { |
|
150 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
151 } |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CLocMainContainer::HandleResourceChange |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CSimPsyUiContainer::HandleResourceChange(TInt aType) |
|
159 { |
|
160 CCoeControl::HandleResourceChange(aType); |
|
161 switch( aType ) |
|
162 { |
|
163 case KEikDynamicLayoutVariantSwitch: |
|
164 { |
|
165 if( iAppUi ) |
|
166 { |
|
167 SetRect(iAppUi->ClientRect()); |
|
168 DrawDeferred(); |
|
169 } |
|
170 break; |
|
171 } |
|
172 default: |
|
173 { |
|
174 break; |
|
175 } |
|
176 } |
|
177 } |
|