|
1 /* |
|
2 * Copyright (c) 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 the License "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: The Toolbar class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <AknUtils.h> |
|
21 #include <StringLoader.h> |
|
22 #include <AknsConstants.h> |
|
23 #include <AknsUtils.h> |
|
24 #include <AknsItemID.h> |
|
25 #include <bautils.h> |
|
26 #include <data_caging_path_literals.hrh> |
|
27 #include <eikbtgpc.h> |
|
28 |
|
29 #include <webkitutils.rsg> |
|
30 #include <webkitutilsicons.mbg> |
|
31 |
|
32 #include "ToolBar.h" |
|
33 #include "ToolBarButton.h" |
|
34 #include "BrCtlDefs.h" |
|
35 |
|
36 #include "eikon.hrh" |
|
37 |
|
38 |
|
39 // EXTERNAL DATA STRUCTURES |
|
40 |
|
41 // EXTERNAL FUNCTION PROTOTYPES |
|
42 |
|
43 // CONSTANTS |
|
44 _LIT( KToolBarSvgFile, "webkitutilsicons.mif" ); |
|
45 _LIT( KToolBarBitmapsFile, "webkitutils.mbm" ); |
|
46 |
|
47 const TInt KMargin = 5; |
|
48 const TInt KMaxBorderAlpha = 128; // how dark is the shadow around tooltip |
|
49 const TInt KButtonCount = 7; |
|
50 const TInt KAnimDeltaX = 25; |
|
51 const TInt KAnimDeltaY = 12; |
|
52 const TInt KShadow = 4; |
|
53 const TInt KToolTipDelay = 1500000; |
|
54 |
|
55 // MACROS |
|
56 |
|
57 // LOCAL CONSTANTS AND MACROS |
|
58 |
|
59 // MODULE DATA STRUCTURES |
|
60 |
|
61 // LOCAL FUNCTION PROTOTYPES |
|
62 |
|
63 // FORWARD DECLARATIONS |
|
64 |
|
65 // ============================= LOCAL FUNCTIONS =============================== |
|
66 |
|
67 //------------------------------------------------------------------------------- |
|
68 // DoToolTipCb |
|
69 // C-style TCallback function |
|
70 //------------------------------------------------------------------------------- |
|
71 TInt DoToolTipCb( |
|
72 TAny* aPtr ) |
|
73 { |
|
74 CToolBar* t = static_cast<CToolBar*>(aPtr); |
|
75 t->MakeToolTipVisible(); |
|
76 return EFalse; |
|
77 } |
|
78 |
|
79 //------------------------------------------------------------------------------- |
|
80 // Animate |
|
81 // C-style TCallback function |
|
82 //------------------------------------------------------------------------------- |
|
83 TBool Animate( |
|
84 TAny* aAny ) |
|
85 { |
|
86 CToolBar* toolBar = static_cast<CToolBar*> (aAny); |
|
87 TBool result = toolBar->ToolBarAnimation(); |
|
88 return result; |
|
89 } |
|
90 |
|
91 // ============================ MEMBER FUNCTIONS =============================== |
|
92 //------------------------------------------------------------------------------- |
|
93 // CToolBar* CToolBar::NewL(MToolBarCallBack& aToolBarCallBack) |
|
94 // Two phase construction |
|
95 //------------------------------------------------------------------------------- |
|
96 EXPORT_C CToolBar* CToolBar::NewL( |
|
97 MToolBarCallback& aToolBarCallback) |
|
98 { |
|
99 CToolBar *self = new CToolBar(aToolBarCallback); |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL(); |
|
102 CleanupStack::Pop(); |
|
103 return self; |
|
104 } |
|
105 |
|
106 //------------------------------------------------------------------------------- |
|
107 // CToolBar::CToolBar(MToolBarCallBack& aToolBarCallBack) |
|
108 // Two phase construction |
|
109 //------------------------------------------------------------------------------- |
|
110 CToolBar::CToolBar(MToolBarCallback& aToolBarCallback) |
|
111 : iToolBarCallback(&aToolBarCallback), |
|
112 iOrigCursorPos(iToolBarCallback->CursorPosition()), |
|
113 iCba(NULL) |
|
114 { |
|
115 } |
|
116 |
|
117 //------------------------------------------------------------------------------- |
|
118 // CToolBar::ConstructL() |
|
119 // Two phase construction |
|
120 //------------------------------------------------------------------------------- |
|
121 void CToolBar::ConstructL() |
|
122 { |
|
123 // move cursor off screen to hide it |
|
124 iToolBarCallback->SetAndUpdateCursorPosition(TPoint(-20,-20)); |
|
125 |
|
126 LoadResourceFileL(); |
|
127 CreateCbaL(); |
|
128 |
|
129 iMbmFile = GetCannedImageDirL(); |
|
130 iMbmFile->Des().Append( KToolBarBitmapsFile ); |
|
131 iSvgMbmFile = GetCannedImageDirL(); |
|
132 iSvgMbmFile->Des().Append( KToolBarSvgFile ); |
|
133 |
|
134 iButtonArray = new (ELeave) CArrayPtrFlat<CToolBarButton>(KButtonCount); |
|
135 |
|
136 iButtonConfigArray = new (ELeave) CArrayFixFlat<TUint>(KButtonCount); |
|
137 |
|
138 InitToolbarL(); |
|
139 |
|
140 iOffScreenBitmap = new (ELeave) CFbsBitmap(); |
|
141 User::LeaveIfError( iOffScreenBitmap->Create( iToolBarSize, EColor16MA) ); |
|
142 iBitmapDevice = CFbsBitmapDevice::NewL(iOffScreenBitmap); |
|
143 User::LeaveIfError(iBitmapDevice->CreateContext(iBitmapGc)); |
|
144 |
|
145 iMaskBitmap = new (ELeave) CFbsBitmap(); |
|
146 User::LeaveIfError( iMaskBitmap->Create( iToolBarSize, EColor256) ); |
|
147 iMaskBitmapDevice = CFbsBitmapDevice::NewL(iMaskBitmap); |
|
148 User::LeaveIfError(iMaskBitmapDevice->CreateContext(iMaskBitmapGc)); |
|
149 |
|
150 DrawToolbarToBitmap(); |
|
151 DrawButtonsToBitmap(); |
|
152 |
|
153 TInt x = iOrigCursorPos.iX; |
|
154 TInt y = iOrigCursorPos.iY; |
|
155 CCoeControl& view = iToolBarCallback->View(); |
|
156 TRect r(TPoint(0,0),view.Size()); |
|
157 |
|
158 TInt dx = Min(x , r.iBr.iX - x); |
|
159 TInt dy = Min(y , r.iBr.iY - y); |
|
160 iAnimDirX = dx >= dy ? 0: (r.iBr.iX - x > x) ? 1 : -1; |
|
161 iAnimDirY = dy > dx ? 0: (r.iBr.iY - y > y) ? 1 : -1; |
|
162 |
|
163 TInt count = iButtonArray->Count(); |
|
164 if (count <= 0) |
|
165 User::Leave(KErrUnderflow); |
|
166 |
|
167 iPosition.iX = iAnimDirX == 0 ? Min(x - iToolBarSize.iWidth/(2*count), r.iBr.iX - iToolBarSize.iWidth) |
|
168 : iAnimDirX == 1 ? - iToolBarSize.iWidth : r.iBr.iX; |
|
169 iPosition.iY = iAnimDirY == 0 ? Min(y - iToolBarSize.iHeight/2, r.iBr.iY - iToolBarSize.iHeight) |
|
170 : iAnimDirY == 1 ? - iToolBarSize.iHeight : r.iBr.iY; |
|
171 |
|
172 |
|
173 iAnimationTimer = CIdle::NewL( CActive::EPriorityHigh ); |
|
174 iAnimationTimer->Start(TCallBack(&Animate,this)); |
|
175 |
|
176 iToolTipTimer = CPeriodic::NewL( CActive::EPriorityLow ); |
|
177 ConstructSprite(); |
|
178 UpdateCursorPosition(); |
|
179 } |
|
180 |
|
181 // ---------------------------------------------------------------------------- |
|
182 // void CToolBar::InitToolbarL() |
|
183 // Method to init and layout toolbar buttons |
|
184 // ---------------------------------------------------------------------------- |
|
185 void CToolBar::InitToolbarL() |
|
186 { |
|
187 TInt x = KMargin + KShadow; |
|
188 TInt y = KMargin; |
|
189 TInt h = 0; |
|
190 |
|
191 for (TUint i= TBrCtlDefs::ESettingsToolbarButton1Cmd ; i<= TBrCtlDefs::ESettingsToolbarButton7Cmd ; i++ ) |
|
192 { |
|
193 TUint buttonsettingval = iToolBarCallback->GetBrowserSettingL( i ); |
|
194 TInt buttoncmd = ToolbarCommandDecodeMatrix[buttonsettingval][KToolbarCommandDecodeMatrixCmdVal]; |
|
195 TInt buttonstring = ToolbarCommandDecodeMatrix[buttonsettingval][KToolbarCommandDecodeMatrixStringId]; |
|
196 |
|
197 switch (buttoncmd) |
|
198 { |
|
199 case EToolBarNone: |
|
200 { |
|
201 break; |
|
202 } |
|
203 |
|
204 case EToolBarRecenUrls: |
|
205 { |
|
206 HBufC* visitedToolTip = StringLoader::LoadLC(buttonstring); |
|
207 CVisitedButton*visitedButton = CVisitedButton::NewL(*this, buttoncmd,*visitedToolTip); |
|
208 CleanupStack::PopAndDestroy(); |
|
209 visitedButton->SetPosition(TPoint(x,y)); |
|
210 x += visitedButton->Size().iWidth + KMargin; |
|
211 h = Max(h,visitedButton->Size().iHeight); |
|
212 iButtonArray->AppendL(visitedButton); |
|
213 iButtonConfigArray->AppendL(buttoncmd); |
|
214 break; |
|
215 } |
|
216 |
|
217 case EToolBarListBookmarks: |
|
218 { |
|
219 HBufC* BookmarksToolTip = StringLoader::LoadLC(buttonstring); |
|
220 CBookmarksButton*bookmarksButton = CBookmarksButton::NewL(*this, buttoncmd,*BookmarksToolTip); |
|
221 CleanupStack::PopAndDestroy(); |
|
222 bookmarksButton->SetPosition(TPoint(x,y)); |
|
223 x += bookmarksButton->Size().iWidth + KMargin; |
|
224 h = Max(h,bookmarksButton->Size().iHeight); |
|
225 iButtonArray->AppendL(bookmarksButton); |
|
226 iButtonConfigArray->AppendL(buttoncmd); |
|
227 break; |
|
228 } |
|
229 |
|
230 case EToolBarSubscribeToFeeds: |
|
231 { |
|
232 const RPointerArray<TBrCtlSubscribeTo>& feedsArray = iToolBarCallback->SubscribeToMenuItemsL(); |
|
233 HBufC* feedsToolTip = StringLoader::LoadLC(buttonstring); |
|
234 CRssButton* rssButton = CRssButton::NewL(*this, buttoncmd,*feedsToolTip,feedsArray); |
|
235 CleanupStack::PopAndDestroy(); |
|
236 rssButton->SetPosition(TPoint(x,y)); |
|
237 x += rssButton->Size().iWidth + KMargin; |
|
238 h = Max(h,rssButton->Size().iHeight); |
|
239 iButtonArray->AppendL(rssButton); |
|
240 iButtonConfigArray->AppendL(buttoncmd); |
|
241 break; |
|
242 } |
|
243 |
|
244 case EToolBarMiniatureShow: |
|
245 case EToolBarReload: |
|
246 case EToolBarFindKeyword: |
|
247 case EToolBarSettings: |
|
248 case EToolBarGoToWebAddress: |
|
249 case EToolBarManageBookmarks: |
|
250 case EToolBarSaveAsBookmark: |
|
251 case EToolBarPreviousPage: |
|
252 case EToolBarVisualHistory: |
|
253 case EToolBarGoToHompage: |
|
254 case EToolBarZoomIn: |
|
255 case EToolBarZoomOut: |
|
256 case EToolBarRotateScreen: |
|
257 case EToolBarViewImages: |
|
258 case EToolBarSavePage: |
|
259 case EToolBarSwitchWindow: |
|
260 case EToolBarShowKeymap: |
|
261 case EToolBarShowHelp: |
|
262 case EToolBarFullScreen: |
|
263 { |
|
264 HBufC* str = StringLoader::LoadLC(buttonstring); |
|
265 CToolBarButton* b = CToolBarButton::NewL(*this, buttoncmd, *str); |
|
266 CleanupStack::PopAndDestroy(); |
|
267 b->SetPosition(TPoint(x,y)); |
|
268 x += b->Size().iWidth + KMargin; |
|
269 h = Max(h,b->Size().iHeight); |
|
270 iButtonArray->AppendL(b); |
|
271 iButtonConfigArray->AppendL(buttoncmd); |
|
272 break; |
|
273 } |
|
274 |
|
275 /* Zoom Mode not currently in use |
|
276 case EToolBarZoomMode: |
|
277 { |
|
278 if ( !iToolBarCallback->wmlMode() ) |
|
279 { |
|
280 HBufC* str = StringLoader::LoadLC(buttonstring); |
|
281 CToolBarButton* b = CToolBarButton::NewL(*this, buttoncmd, *str); |
|
282 CleanupStack::PopAndDestroy(); |
|
283 b->SetPosition(TPoint(x,y)); |
|
284 x += b->Size().iWidth + KMargin; |
|
285 h = Max(h,b->Size().iHeight); |
|
286 iButtonArray->AppendL(b); |
|
287 iButtonConfigArray->AppendL(buttoncmd); |
|
288 } |
|
289 break; |
|
290 } |
|
291 */ |
|
292 |
|
293 default: |
|
294 break; // shouldn't get here |
|
295 } |
|
296 |
|
297 } // for loop end |
|
298 |
|
299 iToolBarSize = TSize(x + KShadow,h + 2*KMargin + KShadow); |
|
300 } |
|
301 |
|
302 // ---------------------------------------------------------------------------- |
|
303 // CToolBar::DrawToolbarToBitmap() |
|
304 // Method to draw the empty toolbar to the offscreen bitmap |
|
305 // ---------------------------------------------------------------------------- |
|
306 void CToolBar::DrawToolbarToBitmap() |
|
307 { |
|
308 iMaskBitmapGc->SetPenStyle( CGraphicsContext::ESolidPen ); |
|
309 iMaskBitmapGc->SetPenColor( TRgb( 0, 0, 0 ) ); |
|
310 iMaskBitmapGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
311 iMaskBitmapGc->SetBrushColor( TRgb( 0, 0, 0 ) ); |
|
312 iMaskBitmapGc->DrawRect( TRect( TPoint( 0, 0 ), iToolBarSize ) ); |
|
313 |
|
314 TRect r1(iPosition,iToolBarSize); |
|
315 iMaskBitmapGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
316 iMaskBitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
317 // wider shadow to bottom, no shadow to top |
|
318 TInt bw = KShadow; |
|
319 for (TInt n=1;n<=2*bw-1;n++) |
|
320 { |
|
321 TInt grade = 85*n/(2*bw); |
|
322 //iMaskBitmapGc->SetPenColor(TRgb(0,0,0,n*n*KMaxBorderAlpha/(2*2*bw*bw))); |
|
323 iMaskBitmapGc->SetPenColor(TRgb(255-grade, 255-grade, 255-grade)); |
|
324 iMaskBitmapGc->DrawRect(r1); |
|
325 r1.iTl.iX += n%2; |
|
326 r1.iBr.iX -= n%2; |
|
327 r1.iBr.iY -= 1; |
|
328 } |
|
329 |
|
330 iBitmapGc->SetPenStyle( CGraphicsContext::ESolidPen ); |
|
331 iBitmapGc->SetPenColor( TRgb( 242, 244, 242 ) ); |
|
332 iBitmapGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
333 iBitmapGc->SetBrushColor( TRgb( 242, 244, 242 ) ); |
|
334 iBitmapGc->DrawRect( TRect( TPoint( 0, 0 ), iToolBarSize ) ); |
|
335 |
|
336 TRect r(iPosition,iToolBarSize); |
|
337 iBitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
338 iBitmapGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
339 iBitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
340 // wider shadow to bottom, no shadow to top |
|
341 for (TInt n=1;n<=2*bw-1;n++) |
|
342 { |
|
343 iBitmapGc->SetPenColor(TRgb(0,0,0,n*n*KMaxBorderAlpha/(2*2*bw*bw))); |
|
344 iBitmapGc->DrawRect(r); |
|
345 r.iTl.iX += n%2; |
|
346 r.iBr.iX -= n%2; |
|
347 r.iBr.iY -= 1; |
|
348 } |
|
349 } |
|
350 |
|
351 // ---------------------------------------------------------------------------- |
|
352 // CToolBar::DrawButtonsToBitmap() |
|
353 // Method to draw the toolbar buttons to the offscreen bitmap |
|
354 // ---------------------------------------------------------------------------- |
|
355 void CToolBar::DrawButtonsToBitmap() |
|
356 { |
|
357 |
|
358 iBitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
359 for (TInt i = 0; i < iButtonArray->Count() ;i++) |
|
360 { |
|
361 CToolBarButton * b = (*iButtonArray)[i]; |
|
362 TRect bmpPieceRect(b->Position(),b->Size()); |
|
363 CFbsBitmap& bmp = b->ButtonImage(); |
|
364 CFbsBitmap& mask = b->ButtonMaskImage(); |
|
365 if (i == iFocusedButtonIndex) |
|
366 { |
|
367 iBitmapGc->SetPenStyle( CGraphicsContext::ESolidPen ); |
|
368 iBitmapGc->SetPenColor( TRgb( 194, 195, 194 ) ); |
|
369 iBitmapGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
370 iBitmapGc->SetBrushColor( TRgb( 194, 195, 194 ) ); |
|
371 iBitmapGc->DrawRect( bmpPieceRect ); |
|
372 } |
|
373 else |
|
374 { |
|
375 iBitmapGc->SetPenStyle( CGraphicsContext::ESolidPen ); |
|
376 iBitmapGc->SetPenColor( TRgb( 242, 244, 242 ) ); |
|
377 iBitmapGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
378 iBitmapGc->SetBrushColor( TRgb( 242, 244, 242 ) ); |
|
379 iBitmapGc->DrawRect( bmpPieceRect ); |
|
380 } |
|
381 |
|
382 iBitmapGc->BitBltMasked(b->Position(),&bmp, TRect(TPoint(0,0),b->Size()),&mask, ETrue); |
|
383 } |
|
384 |
|
385 } |
|
386 |
|
387 // ---------------------------------------------------------------------------- |
|
388 // CToolBar::UpdateCursorPosition() |
|
389 // Method to update cursor position |
|
390 // ---------------------------------------------------------------------------- |
|
391 void CToolBar::UpdateCursorPosition() |
|
392 { |
|
393 if (iButtonArray->Length() > 0 && iButtonArray->Length() >= iFocusedButtonIndex) { |
|
394 CToolBarButton* b = iButtonArray->At(iFocusedButtonIndex); |
|
395 if (b) { |
|
396 TPoint pt = iPosition + b->Position() + TPoint(b->Size().iWidth/2,b->Size().iHeight/2); |
|
397 iCursorPosition = pt; |
|
398 SelectableItemHighlighted(CanActivateButton()); |
|
399 } |
|
400 } |
|
401 } |
|
402 |
|
403 // ---------------------------------------------------------------------------- |
|
404 // CToolBar::MakeToolTipVisible() |
|
405 // Method called by the timer to make the tooltip visible |
|
406 // ---------------------------------------------------------------------------- |
|
407 void CToolBar::MakeToolTipVisible(TBool aVisible) |
|
408 { |
|
409 iToolTipTimer->Cancel(); |
|
410 //Show tooltip only if the animation is not running |
|
411 if ( !iAnimationTimer->IsActive() ) |
|
412 { |
|
413 CToolBarButton* b = (*iButtonArray)[iFocusedButtonIndex]; |
|
414 b->ShowToolTip(aVisible); |
|
415 } |
|
416 } |
|
417 |
|
418 // ---------------------------------------------------------------------------- |
|
419 // CToolBar::StartToolTipTimer() |
|
420 // Method to start the tooltip timer |
|
421 // ---------------------------------------------------------------------------- |
|
422 void CToolBar::StartToolTipTimer() |
|
423 { |
|
424 iToolTipTimer->Cancel(); |
|
425 iToolTipTimer->Start( KToolTipDelay, 0, TCallBack( &DoToolTipCb, this ) ); |
|
426 } |
|
427 |
|
428 // ---------------------------------------------------------------------------- |
|
429 // CToolBar::ToolBarAnimation() |
|
430 // Method to do toolbar animation |
|
431 // ---------------------------------------------------------------------------- |
|
432 TBool CToolBar::ToolBarAnimation() |
|
433 { |
|
434 TPoint cp = iOrigCursorPos; |
|
435 TInt dir = iCanCloseToolBar ? -1 : 1; |
|
436 iPosition += TPoint(dir*iAnimDirX*KAnimDeltaX,dir*iAnimDirY*KAnimDeltaY); |
|
437 |
|
438 CCoeControl& view = iToolBarCallback->View(); |
|
439 |
|
440 TBool ret = ETrue; |
|
441 if (iCanCloseToolBar) |
|
442 { |
|
443 TRect r(TPoint(0,0),view.Size()); |
|
444 TRect tbRect = TRect(iPosition,iToolBarSize); |
|
445 ret = r.Intersects(tbRect); |
|
446 if (ret) |
|
447 { |
|
448 iSprite.SetPosition( iPosition ); |
|
449 } |
|
450 else |
|
451 { |
|
452 if (iActivateButton) |
|
453 { |
|
454 //Now handle the toolbar activation |
|
455 HandleButtonActivation(); |
|
456 } |
|
457 else{ |
|
458 iSprite.Close(); |
|
459 TRAP_IGNORE(iToolBarCallback->CloseToolBarL()); |
|
460 } |
|
461 } |
|
462 } |
|
463 else |
|
464 { |
|
465 TPoint p = iPosition; |
|
466 if (iAnimDirY == 0) |
|
467 { |
|
468 TInt count = iButtonArray->Count(); |
|
469 TInt dx = count != 0 ? iToolBarSize.iWidth/(2*count) : 0; |
|
470 p.iX = iAnimDirX == 1 ? Min(p.iX,Max(0,cp.iX - dx)) |
|
471 : Max(p.iX,Min(cp.iX + dx,view.Size().iWidth - iToolBarSize.iWidth)); |
|
472 ret = p.iX == iPosition.iX; |
|
473 } |
|
474 else |
|
475 { |
|
476 p.iY= iAnimDirY == 1 ? Min(p.iY,Max(0,cp.iY - iToolBarSize.iHeight/2)) |
|
477 : Max(p.iY,Min(cp.iY - iToolBarSize.iHeight/2,view.Size().iHeight - iToolBarSize.iHeight)); |
|
478 ret = p.iY == iPosition.iY; |
|
479 } |
|
480 |
|
481 if (!ret) |
|
482 { |
|
483 if (((cp.iX + iToolBarSize.iWidth) > view.Size().iWidth) && |
|
484 (iAnimDirX == 1)) |
|
485 { |
|
486 p.iX = view.Size().iWidth - iToolBarSize.iWidth; |
|
487 } |
|
488 iPosition = p; |
|
489 iSprite.SetPosition( iPosition ); |
|
490 UpdateCursorPosition(); |
|
491 CToolBarButton * b = (*iButtonArray)[iFocusedButtonIndex]; |
|
492 b->SetFocus(ETrue); |
|
493 StartToolTipTimer(); |
|
494 view.DrawNow(); |
|
495 } |
|
496 else |
|
497 { |
|
498 iSprite.SetPosition( iPosition ); |
|
499 } |
|
500 } |
|
501 |
|
502 return ret; |
|
503 } |
|
504 |
|
505 // ---------------------------------------------------------------------------- |
|
506 // CToolBar::AnimateToolBarClosing() |
|
507 // Method to do toolbar animation when closing it |
|
508 // ---------------------------------------------------------------------------- |
|
509 EXPORT_C void CToolBar::AnimateToolBarClosing( |
|
510 TBool aActivateButton ) |
|
511 { |
|
512 iAnimationTimer->Cancel(); |
|
513 CToolBarButton* b = (*iButtonArray)[iFocusedButtonIndex]; |
|
514 b->SetFocus(EFalse); |
|
515 iCanCloseToolBar = ETrue; |
|
516 iActivateButton = aActivateButton; |
|
517 iAnimationTimer->Start(TCallBack(&Animate,this)); |
|
518 } |
|
519 |
|
520 // ---------------------------------------------------------------------------- |
|
521 // CToolBar::CToolBar() |
|
522 // Destructor |
|
523 // ---------------------------------------------------------------------------- |
|
524 CToolBar::~CToolBar() |
|
525 { |
|
526 iToolBarCallback->SetAndUpdateCursorPosition(iOrigCursorPos); |
|
527 if (iButtonArray != NULL) |
|
528 { |
|
529 iButtonArray->ResetAndDestroy(); |
|
530 } |
|
531 delete iButtonArray; |
|
532 |
|
533 delete iButtonConfigArray; |
|
534 |
|
535 delete iBitmapGc; |
|
536 delete iBitmapDevice; |
|
537 delete iOffScreenBitmap; |
|
538 |
|
539 delete iMaskBitmapGc; |
|
540 delete iMaskBitmapDevice; |
|
541 delete iMaskBitmap; |
|
542 |
|
543 if (iAnimationTimer) |
|
544 { |
|
545 iAnimationTimer->Cancel(); |
|
546 } |
|
547 delete iAnimationTimer; |
|
548 |
|
549 if ( iToolTipTimer ) |
|
550 { |
|
551 iToolTipTimer->Cancel(); |
|
552 } |
|
553 delete iToolTipTimer; |
|
554 |
|
555 iSprite.Close(); |
|
556 // remove resource file |
|
557 CCoeEnv::Static()->DeleteResourceFile( iResourceFile ); |
|
558 |
|
559 if (iCba) |
|
560 { |
|
561 CCoeEnv::Static()->AppUi()->RemoveFromStack(iCba->ButtonGroup()->AsControl()); |
|
562 } |
|
563 delete iCba; |
|
564 } |
|
565 |
|
566 void CToolBar::ConstructSprite() |
|
567 { |
|
568 CCoeControl& view = iToolBarCallback->View(); |
|
569 iSprite = RWsSprite(view.ControlEnv()->WsSession()); |
|
570 RWindowTreeNode *window = (RDrawableWindow* )iToolBarCallback->CCoeControlParent().DrawableWindow(); |
|
571 iSprite.Construct(*window,iPosition,ESpriteNoChildClip); |
|
572 |
|
573 TSpriteMember spriteMem; |
|
574 spriteMem.iBitmap = iOffScreenBitmap; |
|
575 spriteMem.iMaskBitmap = iMaskBitmap; |
|
576 spriteMem.iInvertMask = ETrue; |
|
577 |
|
578 iSprite.AppendMember(spriteMem); |
|
579 iSprite.Activate(); |
|
580 } |
|
581 |
|
582 // ---------------------------------------------------------------------------- |
|
583 // CToolBar::Draw() |
|
584 // Method to draw the toolbar |
|
585 // ---------------------------------------------------------------------------- |
|
586 //EXPORT_C void CToolBar::Draw( |
|
587 // CWindowGc& aGc ) const |
|
588 EXPORT_C void CToolBar::Draw() const |
|
589 { |
|
590 for (TInt i = 0; i < iButtonArray->Count() ;i++) |
|
591 { |
|
592 CToolBarButton* b = (*iButtonArray)[i]; |
|
593 if ( b ) |
|
594 { |
|
595 b->Draw(); |
|
596 } |
|
597 } |
|
598 } |
|
599 |
|
600 // ---------------------------------------------------------------------------- |
|
601 // CToolBar::HandleCursorMovement() |
|
602 // Method to handle cursor movement |
|
603 // ---------------------------------------------------------------------------- |
|
604 void CToolBar::HandleCursorMovement( |
|
605 TInt aLr, |
|
606 TInt aTb ) |
|
607 { |
|
608 TInt count = iButtonArray->Count(); |
|
609 TInt oldIndex = iFocusedButtonIndex; |
|
610 if ( aTb == 0) |
|
611 { |
|
612 iFocusedButtonIndex = aLr == 1 ? iFocusedButtonIndex == count - 1 ? 0 : ++iFocusedButtonIndex |
|
613 : iFocusedButtonIndex == 0 ? count - 1 : --iFocusedButtonIndex; |
|
614 } |
|
615 |
|
616 if ( oldIndex != iFocusedButtonIndex ) |
|
617 { |
|
618 // button hover |
|
619 CToolBarButton* oldB = iButtonArray->At( oldIndex ); |
|
620 CToolBarButton* newB = iButtonArray->At( iFocusedButtonIndex ); |
|
621 if ( oldB ) |
|
622 { |
|
623 oldB->SetFocus( EFalse ); |
|
624 } |
|
625 if ( newB ) |
|
626 { |
|
627 newB->SetFocus( ETrue ); |
|
628 } |
|
629 UpdateCursorPosition(); |
|
630 DrawButtonsToBitmap(); |
|
631 |
|
632 StartToolTipTimer(); |
|
633 iToolBarCallback->View().DrawNow(); |
|
634 } |
|
635 } |
|
636 |
|
637 // ---------------------------------------------------------------------------- |
|
638 // CToolBar::CanActivateButton() |
|
639 // Method to test if a button can be activated |
|
640 // |
|
641 // ---------------------------------------------------------------------------- |
|
642 TBool CToolBar::CanActivateButton() |
|
643 { |
|
644 switch( iButtonConfigArray->At(iFocusedButtonIndex) ) |
|
645 { |
|
646 case EToolBarRecenUrls: |
|
647 case EToolBarSubscribeToFeeds: |
|
648 case EToolBarListBookmarks: |
|
649 { |
|
650 return EFalse; |
|
651 } |
|
652 |
|
653 case EToolBarMiniatureShow: |
|
654 case EToolBarReload: |
|
655 case EToolBarFindKeyword: |
|
656 case EToolBarGoToWebAddress: |
|
657 case EToolBarManageBookmarks: |
|
658 case EToolBarSaveAsBookmark: |
|
659 case EToolBarSettings: |
|
660 case EToolBarPreviousPage: |
|
661 case EToolBarVisualHistory: |
|
662 case EToolBarGoToHompage: |
|
663 case EToolBarZoomIn: |
|
664 case EToolBarZoomOut: |
|
665 // case EToolBarZoomMode: |
|
666 case EToolBarRotateScreen: |
|
667 case EToolBarViewImages: |
|
668 case EToolBarSavePage: |
|
669 case EToolBarSwitchWindow: |
|
670 case EToolBarShowKeymap: |
|
671 case EToolBarShowHelp: |
|
672 case EToolBarFullScreen: |
|
673 { |
|
674 return ETrue; |
|
675 } |
|
676 |
|
677 |
|
678 default: |
|
679 { |
|
680 break; |
|
681 } |
|
682 } |
|
683 return EFalse; |
|
684 } |
|
685 |
|
686 // ---------------------------------------------------------------------------- |
|
687 // CToolBar::HandleButtonActivation() |
|
688 // Method to handle toolbar activation. |
|
689 // This method contains the behaviour of each button |
|
690 // ---------------------------------------------------------------------------- |
|
691 void CToolBar::HandleButtonActivation() |
|
692 { |
|
693 CArrayFixFlat<TPtrC>* attrNames = 0; |
|
694 CArrayFixFlat<TPtrC>* attrValues = 0; |
|
695 |
|
696 MakeToolTipVisible(EFalse); |
|
697 switch( iButtonConfigArray->At(iFocusedButtonIndex) ) |
|
698 { |
|
699 case EToolBarRecenUrls: |
|
700 { |
|
701 break; |
|
702 } |
|
703 |
|
704 case EToolBarMiniatureShow: |
|
705 { |
|
706 TRAP_IGNORE(iToolBarCallback->OpenPageViewL()); |
|
707 break; |
|
708 } |
|
709 |
|
710 case EToolBarReload: |
|
711 { |
|
712 TRAP_IGNORE(iToolBarCallback->HandleHistoryCommandL(TBrCtlDefs::ECommandReload)); |
|
713 break; |
|
714 } |
|
715 |
|
716 case EToolBarPreviousPage: |
|
717 { |
|
718 TRAP_IGNORE(iToolBarCallback->HandleHistoryCommandL(TBrCtlDefs::ECommandOneStepBack)); |
|
719 break; |
|
720 } |
|
721 |
|
722 case EToolBarVisualHistory: |
|
723 { |
|
724 TRAP_IGNORE(iToolBarCallback->HandleHistoryCommandL(TBrCtlDefs::ECommandShowHistory)); |
|
725 break; |
|
726 } |
|
727 |
|
728 case EToolBarViewImages: |
|
729 { |
|
730 TRAP_IGNORE(iToolBarCallback->ViewImagesL()); |
|
731 break; |
|
732 } |
|
733 |
|
734 case EToolBarFindKeyword: |
|
735 { |
|
736 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandLaunchFindKeyword,*attrNames,*attrValues); |
|
737 break; |
|
738 } |
|
739 |
|
740 case EToolBarListBookmarks: |
|
741 { |
|
742 break; |
|
743 } |
|
744 |
|
745 case EToolBarSubscribeToFeeds: |
|
746 { |
|
747 break; |
|
748 } |
|
749 |
|
750 case EToolBarSettings: |
|
751 { |
|
752 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandToolbarSettings,*attrNames,*attrValues); |
|
753 break; |
|
754 } |
|
755 |
|
756 case EToolBarShowKeymap: |
|
757 { |
|
758 // may seem roundabout to go to ui and then back to client but |
|
759 // this prevents problem with CBAs and keeps things cleaner |
|
760 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandToolbarShowKeymap,*attrNames,*attrValues); |
|
761 break; |
|
762 } |
|
763 |
|
764 case EToolBarGoToWebAddress: |
|
765 { |
|
766 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandGotoWebAddress,*attrNames,*attrValues); |
|
767 break; |
|
768 } |
|
769 |
|
770 case EToolBarManageBookmarks: |
|
771 { |
|
772 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandManageBookmarks,*attrNames,*attrValues); |
|
773 break; |
|
774 } |
|
775 |
|
776 case EToolBarSaveAsBookmark: |
|
777 { |
|
778 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandSaveAsBookmark,*attrNames,*attrValues); |
|
779 break; |
|
780 } |
|
781 |
|
782 /* Zoom Mode not currently used |
|
783 case EToolBarZoomMode: |
|
784 { |
|
785 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandZoomMode,*attrNames,*attrValues); |
|
786 break; |
|
787 } |
|
788 */ |
|
789 |
|
790 case EToolBarZoomIn: |
|
791 { |
|
792 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandZoomIn,*attrNames,*attrValues); |
|
793 break; |
|
794 } |
|
795 |
|
796 case EToolBarZoomOut: |
|
797 { |
|
798 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandZoomOut,*attrNames,*attrValues); |
|
799 break; |
|
800 } |
|
801 |
|
802 case EToolBarGoToHompage: |
|
803 { |
|
804 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandGoToHompage,*attrNames,*attrValues); |
|
805 break; |
|
806 } |
|
807 |
|
808 case EToolBarRotateScreen: |
|
809 { |
|
810 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandRotateScreen,*attrNames,*attrValues); |
|
811 break; |
|
812 } |
|
813 |
|
814 case EToolBarSavePage: |
|
815 { |
|
816 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandSavePage,*attrNames,*attrValues); |
|
817 break; |
|
818 } |
|
819 |
|
820 case EToolBarSwitchWindow: |
|
821 { |
|
822 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandSwitchWindow,*attrNames,*attrValues); |
|
823 break; |
|
824 } |
|
825 |
|
826 case EToolBarShowHelp: |
|
827 { |
|
828 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandShowHelp,*attrNames,*attrValues); |
|
829 break; |
|
830 } |
|
831 |
|
832 case EToolBarFullScreen: |
|
833 { |
|
834 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandFullScreen,*attrNames,*attrValues); |
|
835 break; |
|
836 } |
|
837 |
|
838 default: |
|
839 { |
|
840 break; |
|
841 } |
|
842 } |
|
843 } |
|
844 |
|
845 // ---------------------------------------------------------------------------- |
|
846 // CToolBar::HandleOfferKeyEventL() |
|
847 // Method to handle toolbar key events |
|
848 // This method is the control point for left/right up/down and enter key |
|
849 // ---------------------------------------------------------------------------- |
|
850 EXPORT_C TKeyResponse CToolBar::HandleOfferKeyEventL( |
|
851 const TKeyEvent& aKeyEvent, |
|
852 TEventCode aEventCode ) |
|
853 { |
|
854 |
|
855 CToolBarButton* b = iButtonArray->At( iFocusedButtonIndex ); |
|
856 |
|
857 if ( b && b->HandleOfferKeyEventL( aKeyEvent, aEventCode ) == EKeyWasConsumed ) |
|
858 { |
|
859 return EKeyWasConsumed; |
|
860 } |
|
861 |
|
862 switch( aEventCode ) |
|
863 { |
|
864 case EEventKeyDown: |
|
865 { |
|
866 break; |
|
867 } |
|
868 case EEventKey: |
|
869 { |
|
870 iLastEventKey = aKeyEvent; |
|
871 break; |
|
872 } |
|
873 case EEventKeyUp: |
|
874 { |
|
875 |
|
876 switch( iLastEventKey.iCode ) |
|
877 { |
|
878 // The arrow key events: |
|
879 case EKeyRightUpArrow: // Northeast |
|
880 case EStdKeyDevice11: // : Extra KeyEvent supports diagonal event simulator wedge |
|
881 case EKeyRightArrow: // East |
|
882 case EKeyRightDownArrow: // Southeast |
|
883 case EStdKeyDevice12: // : Extra KeyEvent supports diagonal event simulator wedge |
|
884 { |
|
885 if ( !iAnimationTimer->IsActive() ) //Do navigation only when the animation timer is not running |
|
886 HandleCursorMovement(+1,0); |
|
887 } |
|
888 break; |
|
889 |
|
890 case EKeyLeftUpArrow: // Northwest |
|
891 case EStdKeyDevice10: // : Extra KeyEvent supports diagonal event simulator wedge |
|
892 case EKeyLeftArrow: // West |
|
893 case EKeyLeftDownArrow: // Southwest |
|
894 case EStdKeyDevice13: // : Extra KeyEvent supports diagonal event simulator wedge |
|
895 { |
|
896 if ( !iAnimationTimer->IsActive() ) |
|
897 HandleCursorMovement(-1,0); |
|
898 } |
|
899 break; |
|
900 |
|
901 // The enter key events. aka activate key |
|
902 case EKeyDevice3: |
|
903 { |
|
904 if ( iAnimationTimer->IsActive() ) |
|
905 { |
|
906 AnimateToolBarClosing(EFalse); |
|
907 break; |
|
908 } |
|
909 if ( CanActivateButton() ) |
|
910 { |
|
911 AnimateToolBarClosing(ETrue); |
|
912 break; |
|
913 } |
|
914 break; |
|
915 } |
|
916 |
|
917 default: |
|
918 { |
|
919 break; |
|
920 } |
|
921 |
|
922 } |
|
923 iLastEventKey.iCode = EKeyNull; // Reset |
|
924 } |
|
925 |
|
926 default: |
|
927 break; |
|
928 } |
|
929 |
|
930 return EKeyWasConsumed; |
|
931 } |
|
932 |
|
933 // ---------------------------------------------------------------------------- |
|
934 // CToolBar::HandlePointerEventL |
|
935 // Method to handle toolbar pointer events |
|
936 // ---------------------------------------------------------------------------- |
|
937 EXPORT_C void CToolBar::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
938 { |
|
939 TPointerEvent::TType pEventType = aPointerEvent.iType; |
|
940 switch (pEventType) |
|
941 { |
|
942 case TPointerEvent::EButton1Down: |
|
943 { |
|
944 |
|
945 TRect tbRect = TRect(iPosition,iToolBarSize); |
|
946 if (tbRect.Contains(aPointerEvent.iPosition)) |
|
947 { |
|
948 ButtonOnPointerEvent(aPointerEvent); |
|
949 } |
|
950 break; |
|
951 } |
|
952 |
|
953 case TPointerEvent::EButton1Up: |
|
954 { |
|
955 |
|
956 TRect tbRect = TRect(iPosition,iToolBarSize); |
|
957 if (tbRect.Contains(aPointerEvent.iPosition)) |
|
958 { |
|
959 ButtonOnPointerEvent(aPointerEvent); |
|
960 HandleButtonActivation(); |
|
961 } |
|
962 else |
|
963 { |
|
964 CToolBarButton* b = iButtonArray->At(0); |
|
965 CToolBarButton* fb = iButtonArray->At(KButtonCount-1); |
|
966 |
|
967 if (iFocusedButtonIndex == 0) |
|
968 { |
|
969 b = iButtonArray->At(0); |
|
970 } |
|
971 else if (CRssButton* rssb = dynamic_cast<CRssButton*>(fb)) |
|
972 { |
|
973 b = iButtonArray->At(KButtonCount-1); |
|
974 } |
|
975 if (b->HandlePointerEventL(aPointerEvent)) |
|
976 { |
|
977 TRAP_IGNORE(iToolBarCallback->CloseToolBarL()); |
|
978 } |
|
979 } |
|
980 break; |
|
981 } |
|
982 |
|
983 case TPointerEvent::EDrag: |
|
984 { |
|
985 break; |
|
986 } |
|
987 |
|
988 case TPointerEvent::EMove: |
|
989 { |
|
990 break; |
|
991 } |
|
992 |
|
993 default: |
|
994 break; |
|
995 } |
|
996 |
|
997 } |
|
998 |
|
999 // ---------------------------------------------------------------------------- |
|
1000 // CToolBar::ButtonOnPointerEvent(const TPointerEvent& aPointerEvent) |
|
1001 // Method to activate the toolbar button on pointer events |
|
1002 // ---------------------------------------------------------------------------- |
|
1003 void CToolBar::ButtonOnPointerEvent(const TPointerEvent& aPointerEvent) |
|
1004 { |
|
1005 CToolBarButton* b = (*iButtonArray)[iFocusedButtonIndex]; |
|
1006 b->SetFocus(EFalse); |
|
1007 iToolBarCallback->View().DrawNow(); |
|
1008 |
|
1009 //find the button to be activated |
|
1010 for (TInt i = 0; i < iButtonArray->Count() ;i++) |
|
1011 { |
|
1012 CToolBarButton* b = (*iButtonArray)[i]; |
|
1013 TRect bTect(iPosition + b->Position(), b->Size()); |
|
1014 if (bTect.Contains(aPointerEvent.iPosition)) |
|
1015 { |
|
1016 b->SetFocus(ETrue); |
|
1017 iFocusedButtonIndex = i; |
|
1018 UpdateCursorPosition(); |
|
1019 MakeToolTipVisible(); |
|
1020 } |
|
1021 } |
|
1022 } |
|
1023 |
|
1024 // ----------------------------------------------------------------------------- |
|
1025 // CCannedImages::GetImage |
|
1026 // Gets the button image |
|
1027 // ----------------------------------------------------------------------------- |
|
1028 // |
|
1029 void CToolBar::GetButtonImage( |
|
1030 TInt aImageId, |
|
1031 CFbsBitmap*& aImage , |
|
1032 CFbsBitmap*& aImageMask) |
|
1033 { |
|
1034 switch (aImageId) |
|
1035 { |
|
1036 case EToolBarRecenUrls: |
|
1037 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_urls, |
|
1038 KAknsIIDQgnIndiBrowserTbUrls, |
|
1039 *iSvgMbmFile, aImage, aImageMask ); |
|
1040 break; |
|
1041 |
|
1042 case EToolBarMiniatureShow: |
|
1043 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_page, |
|
1044 KAknsIIDQgnIndiBrowserTbPage, |
|
1045 *iSvgMbmFile, aImage, aImageMask ); |
|
1046 break; |
|
1047 |
|
1048 case EToolBarReload: |
|
1049 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_reload, |
|
1050 KAknsIIDQgnIndiBrowserTbReload, |
|
1051 *iSvgMbmFile, aImage, aImageMask ); |
|
1052 break; |
|
1053 |
|
1054 case EToolBarFindKeyword: |
|
1055 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_find_kw, |
|
1056 KAknsIIDQgnIndiBrowserTbFindKw, |
|
1057 *iSvgMbmFile, aImage, aImageMask ); |
|
1058 break; |
|
1059 |
|
1060 case EToolBarSubscribeToFeeds: |
|
1061 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_rss, |
|
1062 KAknsIIDQgnIndiBrowserTbRss, |
|
1063 *iSvgMbmFile, aImage, aImageMask ); |
|
1064 break; |
|
1065 |
|
1066 case EToolBarListBookmarks: |
|
1067 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_bm, |
|
1068 KAknsIIDQgnIndiBrowserTbBm, |
|
1069 *iSvgMbmFile, aImage, aImageMask ); |
|
1070 break; |
|
1071 |
|
1072 case EToolBarSettings: |
|
1073 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_settings, |
|
1074 KAknsIIDQgnIndiBrowserTbSettings, |
|
1075 *iSvgMbmFile, aImage, aImageMask ); |
|
1076 break; |
|
1077 |
|
1078 case EToolBarGoToWebAddress: |
|
1079 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_goto, |
|
1080 KAknsIIDQgnIndiBrowserTbGoto, |
|
1081 *iSvgMbmFile, aImage, aImageMask ); |
|
1082 break; |
|
1083 |
|
1084 case EToolBarManageBookmarks: |
|
1085 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_bm, |
|
1086 KAknsIIDQgnIndiBrowserTbBm, |
|
1087 *iSvgMbmFile, aImage, aImageMask ); |
|
1088 break; |
|
1089 |
|
1090 case EToolBarSaveAsBookmark: |
|
1091 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_save_bm, |
|
1092 KAknsIIDQgnIndiBrowserTbSaveBm, |
|
1093 *iSvgMbmFile, aImage, aImageMask ); |
|
1094 break; |
|
1095 |
|
1096 case EToolBarPreviousPage: |
|
1097 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_back, |
|
1098 KAknsIIDQgnIndiBrowserTbBack, |
|
1099 *iSvgMbmFile, aImage, aImageMask ); |
|
1100 break; |
|
1101 |
|
1102 case EToolBarVisualHistory: |
|
1103 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_view_pages, |
|
1104 KAknsIIDQgnIndiBrowserTbViewPages, |
|
1105 *iSvgMbmFile, aImage, aImageMask ); |
|
1106 break; |
|
1107 |
|
1108 case EToolBarGoToHompage: |
|
1109 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_home, |
|
1110 KAknsIIDQgnIndiBrowserTbHome, |
|
1111 *iSvgMbmFile, aImage, aImageMask ); |
|
1112 break; |
|
1113 |
|
1114 /* Zoom Mode not currently used |
|
1115 case EToolBarZoomMode: |
|
1116 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_zoom_in, |
|
1117 KAknsIIDQgnIndiBrowserTbZoomIn, |
|
1118 *iSvgMbmFile, aImage, aImageMask ); |
|
1119 break; |
|
1120 */ |
|
1121 |
|
1122 case EToolBarZoomIn: |
|
1123 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_zoom_in, |
|
1124 KAknsIIDQgnIndiBrowserTbZoomIn, |
|
1125 *iSvgMbmFile, aImage, aImageMask ); |
|
1126 break; |
|
1127 |
|
1128 case EToolBarZoomOut: |
|
1129 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_zoom_out, |
|
1130 KAknsIIDQgnIndiBrowserTbZoomOut, |
|
1131 *iSvgMbmFile, aImage, aImageMask ); |
|
1132 break; |
|
1133 |
|
1134 case EToolBarRotateScreen: |
|
1135 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_rotate, |
|
1136 KAknsIIDQgnIndiBrowserTbRotate, |
|
1137 *iSvgMbmFile, aImage, aImageMask ); |
|
1138 break; |
|
1139 |
|
1140 case EToolBarViewImages: |
|
1141 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_view_images, |
|
1142 KAknsIIDQgnIndiBrowserTbViewImages, |
|
1143 *iSvgMbmFile, aImage, aImageMask ); |
|
1144 break; |
|
1145 |
|
1146 case EToolBarSavePage: |
|
1147 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_save_page, |
|
1148 KAknsIIDQgnIndiBrowserTbSavePage, |
|
1149 *iSvgMbmFile, aImage, aImageMask ); |
|
1150 break; |
|
1151 |
|
1152 case EToolBarSwitchWindow: |
|
1153 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_switch_win, |
|
1154 KAknsIIDQgnIndiBrowserTbSwitchWin, |
|
1155 *iSvgMbmFile, aImage, aImageMask ); |
|
1156 break; |
|
1157 |
|
1158 case EToolBarShowKeymap: |
|
1159 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_key_map, |
|
1160 KAknsIIDQgnIndiBrowserTbKeyMap, |
|
1161 *iSvgMbmFile, aImage, aImageMask ); |
|
1162 break; |
|
1163 |
|
1164 case EToolBarShowHelp: |
|
1165 LoadSvg( EMbmWebkitutilsiconsQgn_indi_browser_tb_help, |
|
1166 KAknsIIDQgnIndiBrowserTbHelp, |
|
1167 *iSvgMbmFile, aImage, aImageMask ); |
|
1168 break; |
|
1169 |
|
1170 case EToolBarFullScreen: |
|
1171 LoadSvg( EMbmWebkitutilsiconsQgn_indi_button_exit_fs, |
|
1172 KAknsIIDQgnIndiBrowserTbFull, |
|
1173 *iSvgMbmFile, aImage, aImageMask ); |
|
1174 break; |
|
1175 |
|
1176 default: |
|
1177 break; |
|
1178 |
|
1179 } // end of switch |
|
1180 } |
|
1181 |
|
1182 |
|
1183 |
|
1184 // ----------------------------------------------------------------------------- |
|
1185 // CToolBar::LoadSvg |
|
1186 // Loads the canned image |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // |
|
1189 void CToolBar::LoadSvg( |
|
1190 TInt aImageId, |
|
1191 TAknsItemID aAknsId, |
|
1192 const TDesC& aFileName, |
|
1193 CFbsBitmap*& aImage , |
|
1194 CFbsBitmap*& aImageMask ) |
|
1195 { |
|
1196 // This stuff is copied from Kimono |
|
1197 |
|
1198 // Check the device resolution |
|
1199 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
1200 CWsScreenDevice& screenDev = *eikEnv->ScreenDevice(); |
|
1201 |
|
1202 TUint dpi = screenDev.VerticalTwipsToPixels(KTwipsPerInch); |
|
1203 |
|
1204 // Initialize size to be 12 pixels |
|
1205 TInt defaultPx = 15; |
|
1206 TInt px = 15; |
|
1207 |
|
1208 // Since web designers assume a 96 pixel per inch (ppi) display use that as the reference point. |
|
1209 // Thus the multiplier should be: |
|
1210 // ppi/96 |
|
1211 // Below is a list of the density of commercially available LCD displays. |
|
1212 // Density Multiplier: |
|
1213 // 400 ppi 4.2 |
|
1214 // 210 ppi 2.2 |
|
1215 // 200 ppi 2.1 |
|
1216 // 120 ppi 1.3 |
|
1217 // 100 ppi 1.0 |
|
1218 // 96 ppi 1.0 |
|
1219 if ((200 > dpi) && (dpi >= 120)) |
|
1220 { |
|
1221 defaultPx = (TInt)((float)defaultPx * 1.7); |
|
1222 } |
|
1223 else if ((210 > dpi) && (dpi >= 200)) |
|
1224 { |
|
1225 defaultPx = (TInt)((float)defaultPx * 2.1); |
|
1226 } |
|
1227 else if ((400 > dpi) && (dpi >= 210)) |
|
1228 { |
|
1229 defaultPx = (TInt)((float)defaultPx * 2.2); |
|
1230 } |
|
1231 else if (dpi >= 400) |
|
1232 { |
|
1233 defaultPx = (TInt)((float)defaultPx * 4.2); |
|
1234 } |
|
1235 |
|
1236 // Don't skin icons--at least for now. |
|
1237 TRAPD(error, AknIconUtils::CreateIconL( aImage, |
|
1238 aImageMask, |
|
1239 aFileName, |
|
1240 aImageId, |
|
1241 aImageId+1)); |
|
1242 |
|
1243 if (error!=KErrNone) |
|
1244 { |
|
1245 return; |
|
1246 } |
|
1247 |
|
1248 |
|
1249 // adjust the size |
|
1250 if (dpi < 200) |
|
1251 { |
|
1252 px = (TInt)((float)defaultPx * 1.1); |
|
1253 } |
|
1254 else |
|
1255 { |
|
1256 px = (TInt)((float)defaultPx * 1.3); |
|
1257 } |
|
1258 |
|
1259 AknIconUtils::SetSize(aImage,TSize(px,px)); //rect.Rect().Size()); |
|
1260 AknIconUtils::SetSize(aImageMask,TSize(px,px)); //rect.Rect().Size()); |
|
1261 } |
|
1262 |
|
1263 // ----------------------------------------------------------------------------- |
|
1264 // CToolBar::GetCannedImageDirL |
|
1265 // Gets the folder where the canned image is located |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 // |
|
1268 HBufC* CToolBar::GetCannedImageDirL( ) |
|
1269 { |
|
1270 TFileName mbmDrive; |
|
1271 HBufC* mbmFile = NULL; |
|
1272 TParse parse; |
|
1273 |
|
1274 // get the drive letter - MBM is on the same drive as this DLL |
|
1275 Dll::FileName( mbmDrive ); |
|
1276 parse.Set( mbmDrive, NULL, NULL ); |
|
1277 mbmDrive = parse.Drive(); |
|
1278 |
|
1279 // allocate memory for MBM file name |
|
1280 mbmFile = HBufC::NewL( KMaxFileName ); |
|
1281 |
|
1282 // assemble the MBM file name |
|
1283 TPtr ptr( mbmFile->Des() ); |
|
1284 ptr.SetLength( 0 ); |
|
1285 ptr.Append( mbmDrive ); |
|
1286 ptr.Append( KDC_APP_BITMAP_DIR ); |
|
1287 return mbmFile; |
|
1288 } |
|
1289 |
|
1290 //------------------------------------------------------------------------------- |
|
1291 // CToolBar::LoadResourceFileL |
|
1292 // add webkit resource file to the coe environment |
|
1293 // |
|
1294 //------------------------------------------------------------------------------- |
|
1295 void CToolBar::LoadResourceFileL() |
|
1296 { |
|
1297 // add webkit resource file to the coe environment |
|
1298 // load resource file |
|
1299 TFileName drive; |
|
1300 TFileName resourceFileName; |
|
1301 TParse parse; |
|
1302 Dll::FileName( drive ); |
|
1303 parse.Set( drive, NULL, NULL ); |
|
1304 |
|
1305 resourceFileName += parse.Drive(); |
|
1306 resourceFileName += KDC_RESOURCE_FILES_DIR; |
|
1307 resourceFileName += _L("WebKitUtils.RSC"); |
|
1308 |
|
1309 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
1310 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFileName ); |
|
1311 iResourceFile = coeEnv->AddResourceFileL( resourceFileName ); |
|
1312 } |
|
1313 |
|
1314 // --------------------------------------------------------- |
|
1315 // CNTAIDialogWindowControl::ProcessCommandL |
|
1316 // Softkey event handling |
|
1317 // --------------------------------------------------------- |
|
1318 // |
|
1319 void CToolBar::ProcessCommandL(TInt aCommand) |
|
1320 { |
|
1321 switch ( aCommand ) |
|
1322 { |
|
1323 case EAknSoftkeyCancel: |
|
1324 { |
|
1325 AnimateToolBarClosing(EFalse); |
|
1326 break; |
|
1327 } |
|
1328 case EAknSoftkeySelect: |
|
1329 { |
|
1330 // down and up key events are already handled |
|
1331 // here we need to fake the EventKey |
|
1332 TKeyEvent keyEvent; |
|
1333 keyEvent.iModifiers = 0; |
|
1334 keyEvent.iRepeats = 0; |
|
1335 keyEvent.iCode = EKeyDevice3; |
|
1336 keyEvent.iScanCode = 0; |
|
1337 HandleOfferKeyEventL(keyEvent, EEventKey); |
|
1338 break; |
|
1339 } |
|
1340 |
|
1341 case EAknSoftkeyChange: |
|
1342 { |
|
1343 CArrayFixFlat<TPtrC>* attrNames = 0; |
|
1344 CArrayFixFlat<TPtrC>* attrValues = 0; |
|
1345 |
|
1346 // close toolbar first |
|
1347 AnimateToolBarClosing(EFalse); |
|
1348 // Go to Toolbar group Settings directly |
|
1349 iToolBarCallback->SendCommandsToClient(TBrCtlDefs::EClientCommandToolbarConfigure,*attrNames,*attrValues); |
|
1350 break; |
|
1351 } |
|
1352 default: |
|
1353 break; |
|
1354 } |
|
1355 } |
|
1356 |
|
1357 // --------------------------------------------------------- |
|
1358 // CToolBar::SetEmphasis |
|
1359 // --------------------------------------------------------- |
|
1360 // |
|
1361 void CToolBar::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/) |
|
1362 { |
|
1363 } |
|
1364 |
|
1365 // --------------------------------------------------------- |
|
1366 // CToolBar::DynInitMenuPaneL |
|
1367 // --------------------------------------------------------- |
|
1368 // |
|
1369 void CToolBar::DynInitMenuPaneL( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ ) |
|
1370 { |
|
1371 } |
|
1372 |
|
1373 // --------------------------------------------------------- |
|
1374 // CToolBar::DynInitMenuPaneL |
|
1375 // --------------------------------------------------------- |
|
1376 // |
|
1377 void CToolBar::SelectableItemHighlighted( TBool aSelectable ) |
|
1378 { |
|
1379 if (aSelectable) |
|
1380 { |
|
1381 SetCba(R_TOOLBAR_SELECTABLE_BUTTON); |
|
1382 } |
|
1383 else |
|
1384 { |
|
1385 SetCba(R_TOOLBAR_NONSELECTABLE_BUTTON); |
|
1386 } |
|
1387 } |
|
1388 |
|
1389 // --------------------------------------------------------- |
|
1390 // CToolBar::CreateCbaL |
|
1391 // Softkey construction |
|
1392 // --------------------------------------------------------- |
|
1393 // |
|
1394 void CToolBar::CreateCbaL() |
|
1395 { |
|
1396 ASSERT(!iCba); |
|
1397 const TSize screenSize=CCoeEnv::Static()->ScreenDevice()->SizeInPixels(); |
|
1398 iCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, |
|
1399 CEikButtonGroupContainer::EHorizontal, |
|
1400 this, R_TOOLBAR_SELECTABLE_BUTTON); |
|
1401 |
|
1402 iCba->SetBoundingRect(TRect(screenSize)); |
|
1403 |
|
1404 CCoeEnv::Static()->AppUi()->AddToStackL(iCba->ButtonGroup()->AsControl(), |
|
1405 ECoeStackPriorityCba, |
|
1406 ECoeStackFlagRefusesFocus); |
|
1407 iCba->DrawableWindow()->SetOrdinalPosition(0); |
|
1408 |
|
1409 ((CEikCba*)iCba->ButtonGroup())->SetSkinBackgroundId(KAknsIIDQsnBgAreaControlIdle); |
|
1410 |
|
1411 iCba->MakeVisible(ETrue); |
|
1412 } |
|
1413 |
|
1414 // --------------------------------------------------------- |
|
1415 // CToolBar::SetCba |
|
1416 // --------------------------------------------------------- |
|
1417 // |
|
1418 void CToolBar::SetCba(TInt aResourceId) |
|
1419 { |
|
1420 TRAP_IGNORE(iCba->SetCommandSetL(aResourceId)); |
|
1421 iCba->DrawDeferred(); |
|
1422 } |
|
1423 |
|
1424 // End of File |