|
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 #ifndef __TOOLBAR |
|
20 #define __TOOLBAR |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <bitstd.h> |
|
25 #include <W32STD.H> |
|
26 #include <COEDEF.H> |
|
27 #include <AknsConstants.h> |
|
28 #include <AknsItemID.h> |
|
29 #include <AknsConstants.h> |
|
30 #include "BrCtlDefs.h" |
|
31 #include <eikmobs.h> |
|
32 #include <webkitutils.rsg> |
|
33 // CONSTANTS |
|
34 |
|
35 // MACROS |
|
36 |
|
37 // DATA TYPES |
|
38 |
|
39 // FUNCTION PROTOTYPES |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class CToolBarButton; |
|
43 class CPeriodic; |
|
44 class CWindowGc; |
|
45 class CCoeControl; |
|
46 class CFbsBitmapDevice; |
|
47 class TBrCtlSubscribeTo; |
|
48 class CGulIcon; |
|
49 class CEikButtonGroupContainer; |
|
50 |
|
51 // CLASS DECLARATION |
|
52 |
|
53 /** |
|
54 * |
|
55 * |
|
56 * @lib webkit.dll |
|
57 * @since 3.1 |
|
58 */ |
|
59 class MToolBarCallback |
|
60 { |
|
61 public: |
|
62 /** |
|
63 * |
|
64 * @since 3.1 |
|
65 * @param |
|
66 * @return |
|
67 */ |
|
68 virtual TPoint CursorPosition() = 0; |
|
69 |
|
70 /** |
|
71 * |
|
72 * @since 3.1 |
|
73 * @param |
|
74 * @return |
|
75 */ |
|
76 virtual void SetAndUpdateCursorPosition(const TPoint& aPoint) = 0; |
|
77 |
|
78 /** |
|
79 * |
|
80 * @since 3.1 |
|
81 * @param |
|
82 * @return |
|
83 */ |
|
84 virtual const RPointerArray<TBrCtlSubscribeTo>& SubscribeToMenuItemsL() = 0; |
|
85 |
|
86 /** |
|
87 * |
|
88 * @since 3.1 |
|
89 * @param |
|
90 * @return |
|
91 */ |
|
92 virtual CCoeControl& View() = 0; |
|
93 |
|
94 /** |
|
95 * |
|
96 * @since 3.1 |
|
97 * @param |
|
98 * @return |
|
99 */ |
|
100 virtual CCoeControl& CCoeControlParent() = 0; |
|
101 |
|
102 /** |
|
103 * |
|
104 * @since 3.1 |
|
105 * @param |
|
106 * @return |
|
107 */ |
|
108 virtual void CloseToolBarL() = 0; |
|
109 |
|
110 /** |
|
111 * |
|
112 * @since 3.1 |
|
113 * @param |
|
114 * @return |
|
115 */ |
|
116 virtual CGulIcon* GetFaviconL(const TDesC& aUrl) = 0; |
|
117 |
|
118 /** |
|
119 * |
|
120 * @since 3.1 |
|
121 * @param |
|
122 * @return |
|
123 */ |
|
124 virtual void SendCommandsToClient(TBrCtlDefs::TBrCtlClientCommands aCommand, |
|
125 const CArrayFix<TPtrC>& aAttributesNames, |
|
126 const CArrayFix<TPtrC>& aAttributeValues) = 0; |
|
127 |
|
128 /** |
|
129 * |
|
130 * @since 3.1 |
|
131 * @param |
|
132 * @return |
|
133 */ |
|
134 virtual void LoadUrlL( const TDesC& aUrl, TBrCtlDefs::TBrCtlCacheMode aCacheMode ) = 0; |
|
135 |
|
136 /** |
|
137 * |
|
138 * @since 3.1 |
|
139 * @param |
|
140 * @return |
|
141 */ |
|
142 virtual HBufC* ResolveUrlL( const TDesC& aUrl) = 0; |
|
143 |
|
144 /** |
|
145 * |
|
146 * @since 3.1 |
|
147 * @param |
|
148 * @return |
|
149 */ |
|
150 virtual void OpenPageViewL() = 0; |
|
151 |
|
152 |
|
153 /** |
|
154 * |
|
155 * @since 3.2 |
|
156 * @param |
|
157 * @return |
|
158 */ |
|
159 virtual TUint GetBrowserSettingL(TUint aSetting) = 0; |
|
160 |
|
161 /** |
|
162 * |
|
163 * @since 3.1 |
|
164 * @param |
|
165 * @return |
|
166 */ |
|
167 virtual void HandleHistoryCommandL(TBrCtlDefs::TBrCtlCommands aCommand) = 0; |
|
168 |
|
169 /** |
|
170 * |
|
171 * @since 5.0 |
|
172 * @param |
|
173 * @return |
|
174 */ |
|
175 virtual void ViewImagesL() = 0; |
|
176 |
|
177 /** |
|
178 * |
|
179 * @since 5.0 |
|
180 * @param |
|
181 * @return |
|
182 */ |
|
183 virtual TBool wmlMode() = 0; |
|
184 }; |
|
185 |
|
186 /** |
|
187 * This is the toolbar class |
|
188 * @since 3.1 |
|
189 */ |
|
190 class CToolBar: public CBase, MEikMenuObserver |
|
191 { |
|
192 public: // Constructors and destructor |
|
193 |
|
194 /** |
|
195 * Two-phased constructor. |
|
196 */ |
|
197 IMPORT_C static CToolBar* NewL( MToolBarCallback& aToolBarCallBack ); |
|
198 |
|
199 /** |
|
200 * Destructor. |
|
201 */ |
|
202 virtual ~CToolBar(); |
|
203 |
|
204 public: //from MEikMenuObserver |
|
205 |
|
206 void ProcessCommandL(TInt aCommand); |
|
207 void SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/); |
|
208 void DynInitMenuPaneL( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ ); |
|
209 |
|
210 |
|
211 public: // New functions |
|
212 |
|
213 /** |
|
214 * Draw |
|
215 * Draws the toolbar |
|
216 * @since 3.1 |
|
217 * @param CWindowGc& aGc |
|
218 * @return void |
|
219 */ |
|
220 // IMPORT_C void Draw( CWindowGc& aGc ) const; |
|
221 IMPORT_C void Draw( ) const; |
|
222 |
|
223 /** |
|
224 * HandleOfferKeyEventL |
|
225 * Handles key events |
|
226 * @since 3.1 |
|
227 * @param aKeyEvent |
|
228 * @param param |
|
229 * @return if key response has been consumed or not |
|
230 */ |
|
231 IMPORT_C TKeyResponse HandleOfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode param ); |
|
232 |
|
233 /** |
|
234 * AnimateToolBarClosing |
|
235 * Starts the tooltip timer |
|
236 * @since 3.1 |
|
237 * @return void |
|
238 */ |
|
239 IMPORT_C void AnimateToolBarClosing(TBool aActivateButton); |
|
240 |
|
241 /** |
|
242 * HandlePointerEventL |
|
243 * Handles pointer events |
|
244 * @since 3.1 |
|
245 * @param aPointerEvent |
|
246 * @return void |
|
247 */ |
|
248 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
249 |
|
250 /** |
|
251 * Draw |
|
252 * Animates the toolbar position |
|
253 * @since 3.1 |
|
254 * @return EFalse if animation is done or ETrue if animation is not complete |
|
255 */ |
|
256 TBool ToolBarAnimation(); |
|
257 |
|
258 /** |
|
259 * MakeToolTipVisible |
|
260 * Makes the tooltip visible, tooltip is displayed after a delay |
|
261 * This method is called by the tooltip timer |
|
262 * Also called by the toolbar button drop down list to hide the tool tip |
|
263 * @since 3.1 |
|
264 * @param aVisible show or hide tooltip - default is to show tooltip |
|
265 * @return void |
|
266 */ |
|
267 void MakeToolTipVisible(TBool aVisible = ETrue); |
|
268 |
|
269 /** |
|
270 * StartToolTipTimer |
|
271 * Starts the tooltip timer |
|
272 * @since 3.1 |
|
273 * @return void |
|
274 */ |
|
275 void StartToolTipTimer(); |
|
276 |
|
277 /** |
|
278 * Parent |
|
279 * |
|
280 * @since 3.1 |
|
281 * @return void |
|
282 */ |
|
283 MToolBarCallback& ToolBarCallback() const { return *iToolBarCallback; } |
|
284 |
|
285 /** |
|
286 * Size |
|
287 * |
|
288 * @since 3.1 |
|
289 * @return void |
|
290 */ |
|
291 TSize Size() const { return iToolBarSize; } |
|
292 |
|
293 /** |
|
294 * Position |
|
295 * |
|
296 * @since 3.1 |
|
297 * @return void |
|
298 */ |
|
299 TPoint Position() const { return iPosition; } |
|
300 |
|
301 /** |
|
302 * UpdateCursorPosition |
|
303 * Updates the cursor position based on the focused index |
|
304 * @since 3.1 |
|
305 */ |
|
306 void UpdateCursorPosition(); |
|
307 |
|
308 /** |
|
309 * Cursor Position |
|
310 * |
|
311 * @since 3.2 |
|
312 * @return void |
|
313 */ |
|
314 TPoint CursorPosition() const { return iCursorPosition; } |
|
315 |
|
316 /** |
|
317 * HandleButtonActivation |
|
318 * Handles navigation inside the toolbar |
|
319 * @since 3.1 |
|
320 * @param ETrue if events was consumer EFalse if the event was not consumed |
|
321 */ |
|
322 void HandleButtonActivation(); |
|
323 |
|
324 /** |
|
325 * HandleButtonActivation |
|
326 * Handles navigation inside the toolbar |
|
327 * @since 3.1 |
|
328 * @param ETrue if events was consumer EFalse if the event was not consumed |
|
329 */ |
|
330 void GetButtonImage( TInt aImageId, CFbsBitmap*& aImage ,CFbsBitmap*& aImageMask); |
|
331 |
|
332 /** |
|
333 * SelectableItemHighlighted |
|
334 * cursor is highlighting something |
|
335 * @since 3.2 |
|
336 * @param ETrue if highlighted element is selectable. default is true |
|
337 */ |
|
338 void SelectableItemHighlighted( TBool aSelectable = ETrue ); |
|
339 |
|
340 //Enums used to represent button commands |
|
341 enum TToolBarButtonType |
|
342 { |
|
343 EToolBarNone, |
|
344 EToolBarRecenUrls, |
|
345 EToolBarMiniatureShow, |
|
346 EToolBarReload, |
|
347 EToolBarFindKeyword, |
|
348 EToolBarGoToWebAddress, |
|
349 EToolBarManageBookmarks, |
|
350 EToolBarListBookmarks, |
|
351 EToolBarSaveAsBookmark, |
|
352 EToolBarSettings, |
|
353 EToolBarPreviousPage, |
|
354 EToolBarVisualHistory, |
|
355 EToolBarGoToHompage, |
|
356 EToolBarZoomIn, |
|
357 EToolBarZoomOut, |
|
358 EToolBarZoomMode, |
|
359 EToolBarRotateScreen, |
|
360 EToolBarViewImages, |
|
361 EToolBarSavePage, |
|
362 EToolBarSwitchWindow, |
|
363 EToolBarSubscribeToFeeds, |
|
364 EToolBarShowKeymap, |
|
365 EToolBarShowHelp, |
|
366 EToolBarFullScreen |
|
367 }; |
|
368 |
|
369 protected: |
|
370 |
|
371 /** |
|
372 * Constructor |
|
373 * |
|
374 */ |
|
375 CToolBar(MToolBarCallback& aToolBarCallback); |
|
376 |
|
377 /** |
|
378 * Two-phase construction |
|
379 */ |
|
380 void ConstructL(); |
|
381 |
|
382 private: |
|
383 /** |
|
384 * ConstructSprite |
|
385 * Construct Sprite for toolbar bitmap |
|
386 * @since 3.1 |
|
387 */ |
|
388 void ConstructSprite(); |
|
389 |
|
390 /** |
|
391 * HandleCursorMovement |
|
392 * Handles navigation inside the toolbar |
|
393 * @since 3.1 |
|
394 * @param lr = 1 Right lr = -1 Left tb = 1 Down tb = -1 Up |
|
395 */ |
|
396 void HandleCursorMovement(TInt lr,TInt tb); |
|
397 |
|
398 /** |
|
399 * InitToolbarL |
|
400 * Initializes the toolbar |
|
401 * @since 3.1 |
|
402 */ |
|
403 void InitToolbarL(); |
|
404 |
|
405 /** |
|
406 * DrawToolbarToBitmap |
|
407 * Draws the empty toolbar to the bitmap |
|
408 * @since 3.1 |
|
409 */ |
|
410 void DrawToolbarToBitmap(); |
|
411 |
|
412 /** |
|
413 * DrawButtonsToBitmap |
|
414 * Draws the buttons to the bitmap |
|
415 * @since 3.1 |
|
416 */ |
|
417 void DrawButtonsToBitmap(); |
|
418 |
|
419 /** |
|
420 * LoadSvg |
|
421 * Draws the buttons to the bitmap |
|
422 * @since 3.1 |
|
423 */ |
|
424 void LoadSvg( TInt aImageId, TAknsItemID aAknsId, const TDesC& aFileName, CFbsBitmap*& aImage, CFbsBitmap*& aImageMask ); |
|
425 |
|
426 /** |
|
427 * GetCannedImageDirL |
|
428 * Draws the buttons to the bitmap |
|
429 * @since 3.1 |
|
430 */ |
|
431 HBufC* GetCannedImageDirL(); |
|
432 |
|
433 /** |
|
434 * GetCannedImageDirL |
|
435 * Draws the buttons to the bitmap |
|
436 * @since 3.1 |
|
437 */ |
|
438 void LoadResourceFileL(); |
|
439 |
|
440 /** |
|
441 * GetCannedImageDirL |
|
442 * Draws the buttons to the bitmap |
|
443 * @since 3.1 |
|
444 */ |
|
445 TBool CanActivateButton(); |
|
446 |
|
447 /** |
|
448 * ButtonOnPointerEvent(const TPointerEvent& aPointerEvent) |
|
449 * Activates the Button on pointer events |
|
450 * @since 3.1 |
|
451 * @return void |
|
452 */ |
|
453 void ButtonOnPointerEvent(const TPointerEvent& aPointerEvent); |
|
454 |
|
455 void CreateCbaL(); |
|
456 void SetCba(TInt aResourceId); |
|
457 |
|
458 private: |
|
459 |
|
460 //A pointer to the view |
|
461 MToolBarCallback* iToolBarCallback; |
|
462 |
|
463 //Tool bar bitmap |
|
464 CFbsBitmap* iOffScreenBitmap; |
|
465 CFbsBitmapDevice* iBitmapDevice; |
|
466 CFbsBitGc* iBitmapGc; |
|
467 |
|
468 //Tool bar mask bitmap |
|
469 CFbsBitmap* iMaskBitmap; |
|
470 CFbsBitmapDevice* iMaskBitmapDevice; |
|
471 CFbsBitGc* iMaskBitmapGc; |
|
472 |
|
473 //Array of toolbar buttons |
|
474 CArrayPtrFlat<CToolBarButton> *iButtonArray; |
|
475 |
|
476 //Position and Size of toolbar |
|
477 TSize iToolBarSize; |
|
478 TPoint iPosition; |
|
479 TPoint iCursorPosition; |
|
480 |
|
481 //Current focussed button index |
|
482 TInt iFocusedButtonIndex; |
|
483 //Saved cursor position |
|
484 TPoint iOrigCursorPos; |
|
485 |
|
486 //Direction of toolbar animation |
|
487 TInt iAnimDirX; // 1 From Left -1 From Right |
|
488 TInt iAnimDirY; // 1 From top -1 from Bottom |
|
489 |
|
490 //AO for the toolbar animationm |
|
491 CIdle *iAnimationTimer; |
|
492 |
|
493 //Timer for showing the tooltip |
|
494 CPeriodic* iToolTipTimer; |
|
495 |
|
496 TBool iCanCloseToolBar; |
|
497 |
|
498 TBool iActivateButton; |
|
499 |
|
500 TKeyEvent iLastEventKey; |
|
501 |
|
502 HBufC* iMbmFile; |
|
503 |
|
504 HBufC* iSvgMbmFile; |
|
505 |
|
506 TInt iResourceFile; |
|
507 |
|
508 RWsSprite iSprite; |
|
509 |
|
510 CEikButtonGroupContainer* iCba; |
|
511 |
|
512 //Button Configuration Array - stores which buttons are on by button index |
|
513 CArrayFixFlat<TUint> *iButtonConfigArray; |
|
514 }; |
|
515 |
|
516 // Toolbar button translation matrix |
|
517 // |
|
518 // translates cenrep value to button tooltip string resource id |
|
519 // for each toolbar button |
|
520 // |
|
521 // NOTE: THIS MUST STAY IN SYNC WITH SAME DEFINITION IN browserpreferences.h in UI. |
|
522 // |
|
523 typedef const TInt TToolbarCommandDecodeEntry[2]; |
|
524 |
|
525 #define KToolbarCommandDecodeMatrixCount 23 |
|
526 #define KToolbarCommandDecodeMatrixCmdVal 0 // First entry is the Command Value |
|
527 #define KToolbarCommandDecodeMatrixStringId 1 // Second entry is the Setting String Id |
|
528 |
|
529 static const TToolbarCommandDecodeEntry ToolbarCommandDecodeMatrix[] = |
|
530 { |
|
531 // Index # Value Tooltip String Id |
|
532 // = cenrep value |
|
533 /* 0 */ { CToolBar::EToolBarNone, 0 /* N/A */ }, |
|
534 /* 1 */ { CToolBar::EToolBarShowHelp, R_BROWSER_TOOLTIP_SHOW_HELP }, |
|
535 /* 2 */ { CToolBar::EToolBarSwitchWindow, R_BROWSER_TOOLTIP_SWITCH_WINDOW }, |
|
536 /* 3 */ { CToolBar::EToolBarSavePage, R_BROWSER_TOOLTIP_SAVE_PAGE }, |
|
537 /* 4 */ { CToolBar::EToolBarViewImages, R_BROWSER_TOOLTIP_VIEW_IMAGES }, |
|
538 /* 5 */ { CToolBar::EToolBarVisualHistory, R_BROWSER_TOOLTIP_VISUAL_HISTORY }, |
|
539 /* 6 */ { CToolBar::EToolBarManageBookmarks, R_BROWSER_TOOLTIP_MANAGE_BOOKMARKS }, |
|
540 /* 7 */ { CToolBar::EToolBarSubscribeToFeeds, R_BROWSER_TOOLTIP_SUBSCRIBE_TO_FEEDS }, |
|
541 /* 8 */ { CToolBar::EToolBarRotateScreen, R_BROWSER_TOOLTIP_ROTATE_SCREEN }, |
|
542 /* 9 */ { CToolBar::EToolBarSettings, R_BROWSER_TOOLTIP_SETTINGS }, |
|
543 /* 10 */ { CToolBar::EToolBarZoomOut, R_BROWSER_TOOLTIP_ZOOM_OUT }, |
|
544 /* 11 */ { CToolBar::EToolBarZoomIn, R_BROWSER_TOOLTIP_ZOOM_IN }, |
|
545 /* 12 */ { CToolBar::EToolBarGoToHompage, R_BROWSER_TOOLTIP_GO_TO_HOMPAGE }, |
|
546 /* 13 */ { CToolBar::EToolBarPreviousPage, R_BROWSER_TOOLTIP_PREVIOUS_PAGE }, |
|
547 /* 14 */ { CToolBar::EToolBarMiniatureShow, R_BROWSER_TOOLTIP_MINIATURE_SHOW }, |
|
548 /* 15 */ { CToolBar::EToolBarReload, R_BROWSER_TOOLTIP_RELOAD }, |
|
549 /* 16 */ { CToolBar::EToolBarFindKeyword, R_BROWSER_TOOLTIP_FIND_KEYWORD }, |
|
550 /* 17 */ { CToolBar::EToolBarRecenUrls, R_BROWSER_TOOLTIP_RECENT_URLS }, |
|
551 /* 18 */ { CToolBar::EToolBarSaveAsBookmark, R_BROWSER_TOOLTIP_SAVE_AS_BOOKMARK }, |
|
552 /* 19 */ { CToolBar::EToolBarListBookmarks, R_BROWSER_TOOLTIP_LIST_BOOKMARKS }, |
|
553 /* 20 */ { CToolBar::EToolBarGoToWebAddress, R_BROWSER_TOOLTIP_GO_TO_WEB_ADDRESS }, |
|
554 /* 21 */ { CToolBar::EToolBarShowKeymap, R_BROWSER_TOOLTIP_SHOW_KEYMAP }, |
|
555 /* 22 */ { CToolBar::EToolBarFullScreen, R_BROWSER_TOOLTIP_FULL_SCREEN }, |
|
556 }; |
|
557 |
|
558 #endif |