1 /* |
|
2 * Copyright (c) 2005 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: BLID Satellite Info dialog definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknlists.h> |
|
21 #include <aknPopup.h> |
|
22 #include <AknQueryDialog.h> |
|
23 #include <SatInfo.rsg> |
|
24 #include <avkon.rsg> |
|
25 #include <aknlayoutscalable_apps.cdl.h> // For LAF |
|
26 #include <lbssatellite.h> |
|
27 #include <aknborders.h> |
|
28 #include <AknsFrameBackgroundControlContext.h> |
|
29 #include <aknappui.h> |
|
30 #include <skinlayout.cdl.h> |
|
31 using namespace SkinLayout; |
|
32 |
|
33 #include "Debug.h" |
|
34 #include "MSatelliteEng.h" |
|
35 #include "CSatelliteDialog.h" |
|
36 #include "satellite.hrh" |
|
37 #include "satellitecontrol.h" |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS ============================== |
|
40 // ---------------------------------------------------------------------------- |
|
41 // CSatelliteDialog::NewL |
|
42 // Two-phased constructor. |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 CSatelliteDialog* CSatelliteDialog::NewL( MSatelliteEng& aEngine ) |
|
46 { |
|
47 CSatelliteDialog* self = new( ELeave ) CSatelliteDialog(aEngine); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL( ); |
|
50 CleanupStack::Pop(); // self |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CSatelliteDialog::CSatelliteDialog |
|
57 // C++ default constructor can NOT contain any code, that |
|
58 // might leave. |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 CSatelliteDialog::CSatelliteDialog(MSatelliteEng& aEngine): iEngine(aEngine) |
|
62 { |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // CSatelliteDialog::~CSatelliteDialog |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 CSatelliteDialog::~CSatelliteDialog() |
|
70 { |
|
71 delete iBgContext; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CSatelliteDialog::ConstructL |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 void CSatelliteDialog::ConstructL( ) |
|
79 { |
|
80 TRect windowRect = Rect(); |
|
81 |
|
82 TAknLayoutRect topLeft; |
|
83 topLeft.LayoutRect(windowRect, Popup_windows_skin_placing__frame_general__Line_2()); |
|
84 |
|
85 //Determine the outer and inner rects of the dialog for drawing the frames. |
|
86 TAknLayoutRect bottomRight; |
|
87 bottomRight.LayoutRect(windowRect, ELayoutEmpty, 169, ELayoutEmpty, ELayoutEmpty, 2, 7,7); |
|
88 bottomRight.LayoutRect(windowRect, Popup_windows_skin_placing__frame_general__Line_5()); |
|
89 |
|
90 TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); |
|
91 TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl); |
|
92 |
|
93 //Background context responsible for drawing the frame and the |
|
94 //background of the frame |
|
95 iBgContext = CAknsFrameBackgroundControlContext::NewL( |
|
96 KAknsIIDQsnFrPopup, outerRect, innerRect, ETrue ); |
|
97 |
|
98 //Create satellite control responsible for all the drawing on the dialog. |
|
99 iSatelliteControl = CSatelliteControl::NewL(iEngine); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // CSatelliteDialog::SetLaunchView |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 void CSatelliteDialog::SetLaunchView(TSatDialogView aView) |
|
107 { |
|
108 //Satellite controls is responsible for the initial launch |
|
109 //view of the dialog. Pass the initial launch view of the dialog |
|
110 //to the control |
|
111 iSatelliteControl->SetLaunchView(aView); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // CSatelliteDialog::OkToExitL |
|
116 // --------------------------------------------------------- |
|
117 // |
|
118 TBool CSatelliteDialog::OkToExitL(TInt aButtonId) |
|
119 { |
|
120 if(aButtonId == ESatelliteChangeView) |
|
121 { |
|
122 // Change view soft key pressed.Notify the control to change |
|
123 // the view and draw. |
|
124 iSatelliteControl->ChangeViewL(); |
|
125 DrawNow(); |
|
126 return EFalse; |
|
127 } |
|
128 else |
|
129 { |
|
130 return CAknDialog::OkToExitL(aButtonId); |
|
131 } |
|
132 } |
|
133 |
|
134 // ---------------------------------------------------------------------------- |
|
135 // CSatelliteDialog::CreateCustomControlL() |
|
136 // ---------------------------------------------------------------------------- |
|
137 // |
|
138 SEikControlInfo CSatelliteDialog::CreateCustomControlL(TInt aControlType) |
|
139 { |
|
140 // This function is invoked by the dialog frame work when if |
|
141 // finds an unknow id in the dialog resouce.This function is |
|
142 // expected to return the control which is reponsible for all |
|
143 // the drawings that will happen in the dialog. |
|
144 SEikControlInfo controlInfo; |
|
145 controlInfo.iControl = NULL; |
|
146 controlInfo.iTrailerTextId = 0; |
|
147 controlInfo.iFlags = 0; |
|
148 |
|
149 switch(aControlType) |
|
150 { |
|
151 case ESatelliteControl: |
|
152 // This dialog takes ownerwhip of the control and |
|
153 // wil also delete the control once the dialog is |
|
154 // destroyed. |
|
155 controlInfo.iControl = iSatelliteControl; |
|
156 break; |
|
157 |
|
158 default: |
|
159 break; |
|
160 } |
|
161 return controlInfo; |
|
162 } |
|
163 |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CSatelliteDialog::SetSizeAndPosition |
|
167 // ---------------------------------------------------------------------------- |
|
168 // |
|
169 void CSatelliteDialog::SetSizeAndPosition(const TSize& /*aSize*/) |
|
170 { |
|
171 TRect rect = iSatelliteControl->CalculateDialogRect(); |
|
172 SetRect( rect ); |
|
173 } |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 // CSatelliteDialog::SizeChanged() |
|
177 // ---------------------------------------------------------------------------- |
|
178 // |
|
179 void CSatelliteDialog::SizeChanged() |
|
180 { |
|
181 CAknDialog::SizeChanged(); |
|
182 TRect windowRect = Rect(); |
|
183 |
|
184 TAknLayoutRect topLeft; |
|
185 topLeft.LayoutRect(windowRect, Popup_windows_skin_placing__frame_general__Line_2()); |
|
186 |
|
187 TAknLayoutRect bottomRight; |
|
188 bottomRight.LayoutRect(windowRect, Popup_windows_skin_placing__frame_general__Line_5()); |
|
189 |
|
190 TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); |
|
191 TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl); |
|
192 |
|
193 iBgContext->SetFrameRects( outerRect, innerRect ); |
|
194 iBgContext->SetParentPos( PositionRelativeToScreen() ); |
|
195 TRAP_IGNORE(UpdateL()); |
|
196 } |
|
197 |
|
198 // ---------------------------------------------------------------------------- |
|
199 // CSatelliteDialog::SupplyMopObject() |
|
200 // ---------------------------------------------------------------------------- |
|
201 // |
|
202 TTypeUid::Ptr CSatelliteDialog::MopSupplyObject(TTypeUid aId) |
|
203 { |
|
204 return MAknsControlContext::SupplyMopObject(aId, iBgContext ); |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // CSatelliteDialog::UpdateL |
|
209 // ---------------------------------------------------------------------------- |
|
210 // |
|
211 void CSatelliteDialog::UpdateL() |
|
212 { |
|
213 CEikButtonGroupContainer& buttonContainer = ButtonGroupContainer(); |
|
214 |
|
215 // Dim the "ChangeView" command when satellite data is not |
|
216 // available |
|
217 if(!iEngine.IsSatelliteDataAvailable()) |
|
218 { |
|
219 buttonContainer.SetCommandSetL(R_AVKON_SOFTKEYS_CLOSE); |
|
220 buttonContainer.DrawNow(); |
|
221 } |
|
222 else |
|
223 { |
|
224 buttonContainer.SetCommandSetL(R_SATELLITE_DIALOG_CBA); |
|
225 buttonContainer.DrawNow(); |
|
226 } |
|
227 DrawNow(); |
|
228 } |
|
229 |
|
230 // ---------------------------------------------------------------------------- |
|
231 // CSatelliteDialog::OfferKeyEventL |
|
232 // ---------------------------------------------------------------------------- |
|
233 // |
|
234 TKeyResponse CSatelliteDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
235 TEventCode aType) |
|
236 { |
|
237 if ( aType == EEventKey && aKeyEvent.iCode == EKeyEnter || |
|
238 aType == EEventKey && aKeyEvent.iScanCode == EStdKeyEnter ) |
|
239 { |
|
240 iSatelliteControl->ChangeViewL(); |
|
241 DrawNow(); |
|
242 return EKeyWasConsumed; |
|
243 } |
|
244 return CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
245 } |
|
246 // End of File |
|