|
1 /* |
|
2 * Copyright (c) 2002 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 #include <aknnotecontrol.h> |
|
20 #include <AknUtils.h> |
|
21 #include <aknappui.h> |
|
22 #include <aknborders.h> |
|
23 #include <eikcapc.h> |
|
24 #include <eikimage.h> |
|
25 #include <aknconsts.h> |
|
26 #include <aknstaticnotedialog.h> |
|
27 |
|
28 #include <avkon.mbg> |
|
29 #include <AknUtils.h> |
|
30 #include <AknsUtils.h> |
|
31 #include <AknsDrawUtils.h> |
|
32 |
|
33 #include <AknTasHook.h> // for testability hooks |
|
34 class CAknStackIndicatorAttributes: public CBase |
|
35 { |
|
36 public: |
|
37 TSize iTwoNotesInStackBitmapSize; |
|
38 TSize iManyNotesInStackBitmapSize; |
|
39 TInt iStackDepth; |
|
40 }; |
|
41 |
|
42 ////////////////////////////////////////////////////////////////////// |
|
43 // Construction/Destruction |
|
44 ////////////////////////////////////////////////////////////////////// |
|
45 |
|
46 |
|
47 // class CAknStaticNoteStackIndicator |
|
48 |
|
49 CAknStaticNoteStackIndicator::~CAknStaticNoteStackIndicator() |
|
50 { |
|
51 delete iAttributes; |
|
52 } |
|
53 |
|
54 void CAknStaticNoteStackIndicator::DoSetExtent() |
|
55 { |
|
56 |
|
57 TSize size = TSize(0,0); |
|
58 TPoint pos = iParentNote->Position(); |
|
59 |
|
60 if ( iAttributes->iStackDepth == 1 ) |
|
61 { |
|
62 pos -= TPoint(0,iAttributes->iTwoNotesInStackBitmapSize.iHeight); |
|
63 size = iAttributes->iTwoNotesInStackBitmapSize; |
|
64 } |
|
65 else if ( iAttributes->iStackDepth > 1 ) |
|
66 { |
|
67 pos -= TPoint(0,iAttributes->iManyNotesInStackBitmapSize.iHeight); |
|
68 size = iAttributes->iManyNotesInStackBitmapSize; |
|
69 } |
|
70 |
|
71 // We want to avoid unnecessary SizeChanged Events |
|
72 if ( pos != Position() || size != Size() ) |
|
73 { |
|
74 SetExtent(pos, size); |
|
75 } |
|
76 } |
|
77 |
|
78 EXPORT_C void CAknStaticNoteStackIndicator::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
79 { |
|
80 CAknControl::HandlePointerEventL(aPointerEvent); |
|
81 } |
|
82 |
|
83 EXPORT_C void* CAknStaticNoteStackIndicator::ExtensionInterface( TUid /*aInterface*/ ) |
|
84 { |
|
85 return NULL; |
|
86 } |
|
87 |
|
88 void CAknStaticNoteStackIndicator::ConstructL(CCoeControl* aParentNote, TInt aStackDepth) |
|
89 { |
|
90 iAttributes = new (ELeave) CAknStackIndicatorAttributes(); |
|
91 iAttributes->iStackDepth = aStackDepth; |
|
92 |
|
93 iParentNote = aParentNote; |
|
94 |
|
95 HandleResourceChange(KAknsMessageSkinChange); |
|
96 |
|
97 CreateWindowL(); |
|
98 |
|
99 DoSetExtent(); |
|
100 |
|
101 ActivateL(); |
|
102 } |
|
103 |
|
104 void CAknStaticNoteStackIndicator::UpdateDepth(TInt aDepth) |
|
105 { |
|
106 iAttributes->iStackDepth = aDepth; |
|
107 DoSetExtent(); |
|
108 if ( aDepth >= 1 ) |
|
109 DrawDeferred(); |
|
110 } |
|
111 |
|
112 void CAknStaticNoteStackIndicator::Draw(const TRect& /*aRect*/) const |
|
113 { |
|
114 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
115 |
|
116 TAknsItemID id; |
|
117 id.Set(0,0); |
|
118 |
|
119 if ( iAttributes->iStackDepth == 1 ) |
|
120 { |
|
121 id = KAknsIIDQgnGrafSnoteAdd1; |
|
122 } |
|
123 else if ( iAttributes->iStackDepth > 1 ) |
|
124 { |
|
125 id = KAknsIIDQgnGrafSnoteAdd2; |
|
126 } |
|
127 |
|
128 // if following method fails, we draw nothing, no big deal |
|
129 AknsDrawUtils::DrawCachedImage( skin, SystemGc(), Rect(), id); |
|
130 } |
|
131 |
|
132 EXPORT_C void CAknStaticNoteStackIndicator::HandleResourceChange(TInt aType) |
|
133 { |
|
134 if ( !iAttributes ) |
|
135 return; |
|
136 |
|
137 if( aType == KAknsMessageSkinChange ) |
|
138 { |
|
139 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
140 TAknLayoutRect rect; |
|
141 rect.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_Notification_pop_up_window_elements__text__Line_1 ); |
|
142 |
|
143 CFbsBitmap* bitmap = NULL; |
|
144 |
|
145 bitmap = AknsUtils::GetCachedBitmap( skin, KAknsIIDQgnGrafSnoteAdd1 ); |
|
146 if (bitmap) |
|
147 { |
|
148 AknIconUtils::SetSize( bitmap, rect.Rect().Size() ); |
|
149 iAttributes->iTwoNotesInStackBitmapSize = bitmap->SizeInPixels(); |
|
150 bitmap = NULL; |
|
151 } |
|
152 bitmap = AknsUtils::GetCachedBitmap( skin, KAknsIIDQgnGrafSnoteAdd2 ); |
|
153 if (bitmap) |
|
154 { |
|
155 AknIconUtils::SetSize( bitmap, rect.Rect().Size() ); |
|
156 iAttributes->iManyNotesInStackBitmapSize = bitmap->SizeInPixels(); |
|
157 } |
|
158 |
|
159 } |
|
160 } |
|
161 |
|
162 |
|
163 /** |
|
164 * Default constructor |
|
165 * |
|
166 * Just call CAknNoteDialog constructor |
|
167 */ |
|
168 EXPORT_C CAknStaticNoteDialog::CAknStaticNoteDialog() : CAknNoteDialog() |
|
169 { |
|
170 AKNTASHOOK_ADD( this, "CAknStaticNoteDialog" ); |
|
171 } |
|
172 |
|
173 /** |
|
174 * Another class constructor |
|
175 * |
|
176 * Accept self pointer to CEikDialog* in order to NULL |
|
177 * client pointer when a non modal note is dismissed. |
|
178 * |
|
179 * @param aSelfPtr Address of the dialog pointer |
|
180 */ |
|
181 EXPORT_C CAknStaticNoteDialog::CAknStaticNoteDialog(CEikDialog** aSelfPtr) : CAknNoteDialog(aSelfPtr) |
|
182 { |
|
183 AKNTASHOOK_ADD( this, "CAknStaticNoteDialog" ); |
|
184 } |
|
185 |
|
186 /** |
|
187 * Class destructor |
|
188 * |
|
189 * Delete the stack indicator |
|
190 */ |
|
191 EXPORT_C CAknStaticNoteDialog::~CAknStaticNoteDialog() |
|
192 { |
|
193 AKNTASHOOK_REMOVE(); |
|
194 delete iStackIndicator; |
|
195 } |
|
196 |
|
197 /** |
|
198 * Set the number of borders |
|
199 * |
|
200 * Update the stack indicator depth to the specified number of borders. |
|
201 * |
|
202 * @param aNumber The number of borders |
|
203 */ |
|
204 EXPORT_C void CAknStaticNoteDialog::SetNumberOfBorders(TInt aNumber) |
|
205 { |
|
206 iStackDepth = aNumber - 1; |
|
207 if (iStackIndicator) |
|
208 iStackIndicator->UpdateDepth(iStackDepth); |
|
209 }; |
|
210 |
|
211 EXPORT_C void CAknStaticNoteDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
212 { |
|
213 CAknNoteDialog::HandlePointerEventL(aPointerEvent); |
|
214 } |
|
215 |
|
216 EXPORT_C void* CAknStaticNoteDialog::ExtensionInterface( TUid /*aInterface*/ ) |
|
217 { |
|
218 return NULL; |
|
219 } |
|
220 |
|
221 /** |
|
222 * Part of dialog framework, called after layout has been performed |
|
223 * |
|
224 * Call PostLayoutDynInitL as implemented in the base, CAknNoteDialog |
|
225 * and create a stack indicator |
|
226 * |
|
227 */ |
|
228 EXPORT_C void CAknStaticNoteDialog::PostLayoutDynInitL() |
|
229 { |
|
230 CAknNoteDialog::PostLayoutDynInitL(); |
|
231 if (!iStackIndicator) |
|
232 { |
|
233 iStackIndicator = new(ELeave)CAknStaticNoteStackIndicator(); |
|
234 iStackIndicator->ConstructL(this, iStackDepth); |
|
235 } |
|
236 } |
|
237 |
|
238 /** |
|
239 * Part of the dialog framework, process a key event. |
|
240 * |
|
241 * Call the implementation of OfferKeyEventL provided by |
|
242 * CEikDialog, bypassing the direct base, CAknNoteDialog. |
|
243 */ |
|
244 |
|
245 EXPORT_C TKeyResponse CAknStaticNoteDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
246 { |
|
247 return CEikDialog::OfferKeyEventL(aKeyEvent,aType); |
|
248 } |
|
249 |
|
250 EXPORT_C void CAknStaticNoteDialog::CEikDialog_Reserved_1() |
|
251 { |
|
252 } |
|
253 |
|
254 EXPORT_C void CAknStaticNoteDialog::CEikDialog_Reserved_2() |
|
255 { |
|
256 } |
|
257 |
|
258 EXPORT_C void CAknStaticNoteDialog::CAknNoteDialog_Reserved() |
|
259 { |
|
260 } |
|
261 |
|
262 EXPORT_C void CAknStaticNoteDialog::CAknStaticNoteDialog_Reserved() |
|
263 { |
|
264 } |
|
265 |
|
266 |
|
267 // End of File |