|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * Defines CSatUiViewContainer class |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <eiktxlbx.h> |
|
23 #include <eiklbx.h> //for CEikListBox |
|
24 #include <barsread.h> |
|
25 #include <eikenv.h> |
|
26 #include <aknlists.h> |
|
27 |
|
28 #include <SatUi.rsg> |
|
29 |
|
30 #include <AknIconArray.h> |
|
31 #include <eikclbd.h> |
|
32 #include <AknDef.h> // New Akn header |
|
33 #include <csxhelp/sat.hlp.hrh> // For help |
|
34 |
|
35 #include "CSatUiApplication.h" |
|
36 #include "CSatUiViewContainer.h" |
|
37 #include "CSatUiView.h" |
|
38 #include "tflogger.h" |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 // C++ default constructor can NOT contain any code, that |
|
43 // might leave. |
|
44 // |
|
45 CSatUiViewContainer::CSatUiViewContainer( CSatUiView* aView ) : |
|
46 iView( aView ) |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // CSatUiViewContainer::ConstructL |
|
52 // Symbian OS default constructor can leave. |
|
53 // (other items were commented in a header). |
|
54 // ---------------------------------------------------------. |
|
55 void CSatUiViewContainer::ConstructL( TBool aIconOn ) |
|
56 { |
|
57 TFLOGSTRING( "CSatUiViewContainer::ConstructL called" ) |
|
58 CreateWindowL(); |
|
59 iIconOn = aIconOn; |
|
60 |
|
61 TResourceReader resourceReader; |
|
62 |
|
63 iCoeEnv->CreateResourceReaderLC( resourceReader , |
|
64 R_SATUI_LISTBOX ); |
|
65 |
|
66 //different listbox depends on item icon |
|
67 if ( iIconOn ) |
|
68 { |
|
69 TFLOGSTRING( "CSatUiViewContainer::ConstructL iIconOn true" ) |
|
70 iListBox = new (ELeave) |
|
71 CAknSingleGraphicStyleListBox; |
|
72 } |
|
73 else |
|
74 { |
|
75 TFLOGSTRING( "CSatUiViewContainer::ConstructL iIconOn false" ) |
|
76 iListBox = new (ELeave) CAknSingleStyleListBox; |
|
77 } |
|
78 |
|
79 iListBox->SetContainerWindowL( *this ); |
|
80 |
|
81 iListBox->ConstructFromResourceL( resourceReader ); |
|
82 |
|
83 iListBox->CreateScrollBarFrameL( ETrue ); |
|
84 |
|
85 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
86 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
87 |
|
88 iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); |
|
89 |
|
90 // resourceReader. Cannot add this as a parameter since |
|
91 // TResourceReader is not derived from CBase |
|
92 CleanupStack::PopAndDestroy(); |
|
93 TFLOGSTRING( "CSatUiViewContainer::ConstructL exit" ) |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CSatUiViewContainer::NewL |
|
98 // Two-phased constructor. |
|
99 // (other items were commented in a header). |
|
100 // ---------------------------------------------------------. |
|
101 CSatUiViewContainer* CSatUiViewContainer::NewL( TBool aIconOn, |
|
102 CSatUiView* aView ) |
|
103 { |
|
104 TFLOGSTRING( "CSatUiViewContainer::NewL called-exit" ) |
|
105 CSatUiViewContainer* self = |
|
106 new (ELeave) CSatUiViewContainer( aView ); |
|
107 |
|
108 CleanupStack::PushL( self ); |
|
109 self->ConstructL( aIconOn ); |
|
110 CleanupStack::Pop( self ); |
|
111 |
|
112 return self; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // CSatUiViewContainer::~CSatUiViewContainer |
|
117 // Destructor. |
|
118 // (other items were commented in a header). |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 CSatUiViewContainer::~CSatUiViewContainer() |
|
122 { |
|
123 TFLOGSTRING( "CSatUiViewContainer::~CSatUiViewContainer called" ) |
|
124 //need to reset first if contains icons |
|
125 if ( iListBox->ItemDrawer()->ColumnData()->IconArray() ) |
|
126 { |
|
127 iListBox->ItemDrawer()->ColumnData()->IconArray()->Reset(); |
|
128 } |
|
129 delete iListBox; |
|
130 TFLOGSTRING( "CSatUiViewContainer::~CSatUiViewContainer exit" ) |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------- |
|
134 // CSatUiViewContainer::ListBox |
|
135 // Returns a pointer to a listbox object. |
|
136 // (other items were commented in a header). |
|
137 // --------------------------------------------------------- |
|
138 // |
|
139 CAknColumnListBox* CSatUiViewContainer::ListBox() |
|
140 { |
|
141 TFLOGSTRING( "CSatUiViewContainer::ListBox called-exit" ) |
|
142 return iListBox; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------- |
|
146 // CSatUiViewContainer::CountComponentControls |
|
147 // The only control is a listbox. |
|
148 // (other items were commented in a header). |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 TInt CSatUiViewContainer::CountComponentControls() const |
|
152 { |
|
153 TFLOGSTRING( "CSatUiViewContainer::CountComponentControls called-exit" ) |
|
154 return 1; |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------- |
|
158 // CSatUiViewContainer::ComponentControl |
|
159 // The only control is a listbox. |
|
160 // (other items were commented in a header). |
|
161 // --------------------------------------------------------- |
|
162 // |
|
163 CCoeControl* CSatUiViewContainer::ComponentControl( |
|
164 TInt /* aIndex */) const |
|
165 { |
|
166 TFLOGSTRING( "CSatUiViewContainer::ComponentControl called-exit" ) |
|
167 return iListBox; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------- |
|
171 // CSatUiViewContainer::SizeChanged |
|
172 // Sets the available size. |
|
173 // (other items were commented in a header). |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 void CSatUiViewContainer::SizeChanged() |
|
177 { |
|
178 TFLOGSTRING( "CSatUiViewContainer::SizeChanged called" ) |
|
179 TRect parentRect( Rect() ); |
|
180 if ( iListBox ) |
|
181 { |
|
182 iListBox->SetRect( parentRect ); |
|
183 } |
|
184 TFLOGSTRING( "CSatUiViewContainer::SizeChanged exit" ) |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // CSatUiViewContainer::OfferKeyEventL |
|
189 // Listbox takes all event even if it doesn't use them. |
|
190 // (other items were commented in a header). |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 TKeyResponse CSatUiViewContainer::OfferKeyEventL( |
|
194 const TKeyEvent& aKeyEvent, |
|
195 TEventCode aType ) |
|
196 { |
|
197 TFLOGSTRING( "CSatUiViewContainer::OfferKeyEventL called" ) |
|
198 TKeyResponse response( EKeyWasNotConsumed ); |
|
199 |
|
200 if ( ( EKeyLeftArrow != aKeyEvent.iCode ) && |
|
201 ( EKeyRightArrow != aKeyEvent.iCode ) ) |
|
202 { |
|
203 response = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
204 } |
|
205 |
|
206 if ( ( EKeyUpArrow == aKeyEvent.iCode ) || |
|
207 ( EKeyDownArrow == aKeyEvent.iCode ) ) |
|
208 { |
|
209 iView->UpdateMskL( iListBox->CurrentItemIndex(), EFalse ); |
|
210 } |
|
211 TFLOGSTRING2( "CSatUiViewContainer::OfferKeyEventL exit, return: %d", \ |
|
212 response ) |
|
213 return response; |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------- |
|
217 // CSatUiViewContainer::GetHelpContext |
|
218 // Returns SatUi help context. |
|
219 // (other items were commented in a header). |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 void CSatUiViewContainer::GetHelpContext( |
|
223 TCoeHelpContext& aContext ) const |
|
224 { |
|
225 TFLOGSTRING( "CSatUiViewContainer::GetHelpContext called" ) |
|
226 aContext.iMajor = KUidSATUI; |
|
227 aContext.iContext = KSAT_HLP_APP; |
|
228 TFLOGSTRING( "CSatUiViewContainer::GetHelpContext exit" ) |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------- |
|
232 // CSatUiViewContainer::HandleResourceChange |
|
233 // Handles control's layout change. |
|
234 // (other items were commented in a header). |
|
235 // --------------------------------------------------------- |
|
236 // |
|
237 void CSatUiViewContainer::HandleResourceChange( TInt aType ) |
|
238 { |
|
239 TFLOGSTRING2( "CSatUiViewContainer::HandleResourceChange called, \ |
|
240 aType: %d", aType ) |
|
241 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
242 { |
|
243 TRect mainPaneRect; |
|
244 AknLayoutUtils::LayoutMetricsRect( |
|
245 AknLayoutUtils::EMainPane, mainPaneRect ); |
|
246 SetRect( mainPaneRect ); |
|
247 DrawDeferred(); |
|
248 } |
|
249 |
|
250 CCoeControl::HandleResourceChange( aType ); |
|
251 TFLOGSTRING( "CSatUiViewContainer::HandleResourceChange exit" ) |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------- |
|
255 // CSatUiViewContainer::FocusChanged |
|
256 // Indicate the requirements for control redrawing. |
|
257 // (other items were commented in a header). |
|
258 // --------------------------------------------------------- |
|
259 // |
|
260 void CSatUiViewContainer::FocusChanged( TDrawNow aDrawNow ) |
|
261 { |
|
262 TFLOGSTRING( "CSatUiViewContainer::FocusChanged called" ) |
|
263 CCoeControl::FocusChanged( aDrawNow ); |
|
264 if ( iListBox ) |
|
265 { |
|
266 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
267 } |
|
268 TFLOGSTRING( "CSatUiViewContainer::FocusChanged exit" ) |
|
269 } |
|
270 |
|
271 // End of File |