|
1 /* |
|
2 * Copyright (c) 2008 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: This file defines class CFSEmailUiShortcutBinding. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __FS_EMAIL_UI_SHORTCUT_BINDING_H |
|
20 #define __FS_EMAIL_UI_SHORTCUT_BINDING_H |
|
21 |
|
22 #include <PtiDefs.h> |
|
23 #include <e32property.h> |
|
24 #include "FreestyleEmailUi.hrh" |
|
25 |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CEikMenuPane; |
|
31 class CPtiEngine; |
|
32 class CPtiKeyMappings; |
|
33 |
|
34 |
|
35 // CLASS DECLARATION |
|
36 class CFSEmailUiShortcutBinding : public CBase |
|
37 { |
|
38 public: // types |
|
39 |
|
40 //! Defines a view where the shortcut is used |
|
41 enum TShortcutContext |
|
42 { |
|
43 EContextMailList, |
|
44 EContextSearchResults, |
|
45 EContextMailViewer, |
|
46 EContextHtmlViewer, |
|
47 EContextMailDetails, |
|
48 EContextFolderList, |
|
49 EContextAttachmentList, |
|
50 EContextDownloadManager, |
|
51 EContextMainGrid, |
|
52 EContextSettings, |
|
53 EContextSendAttachmentList |
|
54 }; |
|
55 |
|
56 //! @internal |
|
57 struct TShortcutBinding |
|
58 { |
|
59 TText iItutShortcut; //!< Shortcut character on ITU-T. 0 if N/A. |
|
60 |
|
61 TText iQwertyShortcut; //!< Shortcut character on QWERTY. 0 if N/A. |
|
62 TUint32 iQwertyModifiers; //!< Modifiers of type TEventModifier required for the QWERTY shortcut. 0 if none. |
|
63 |
|
64 TInt iCommandId; //!< The command for the shortcut. |
|
65 }; |
|
66 |
|
67 public: // construction & destruction |
|
68 |
|
69 static CFSEmailUiShortcutBinding* NewL(); |
|
70 |
|
71 ~CFSEmailUiShortcutBinding(); |
|
72 |
|
73 public: // methods |
|
74 |
|
75 /** |
|
76 * Gives a command ID for the given shortcut key. In the QWERTY mode, this |
|
77 * depends on the English key mappings of the used device. |
|
78 * @param aKey Key event for which the command is fetched |
|
79 * @param aContext The view where the shortcut is used |
|
80 * @return The command ID for the given key. |
|
81 * KErrNotFound if there is no command binded to the key in the given context. |
|
82 */ |
|
83 TInt CommandForShortcutKey( const TKeyEvent& aKey, TShortcutContext aContext ) const; |
|
84 |
|
85 /** |
|
86 * Gives a command ID for the given shortcut. As opposed to the function |
|
87 * CommandForShortcutKey(), this function does no mapping for the given |
|
88 * shortcut. |
|
89 * @param aShortcut The shortcut character for which the command is fetched. |
|
90 * @param aContext The view where the shortcut is used. |
|
91 * @param aModifier Modifiers (like ctrl) which are used when entering the shortcut. |
|
92 * @return The command ID for the given shortcut. |
|
93 * KErrNotFound if there is no command binded to the shortcut in the given context. |
|
94 */ |
|
95 static TInt CommandForShortcut( TText aShortcut, TShortcutContext aContext, TUint32 aModifiers=0 ); |
|
96 |
|
97 /** |
|
98 * Gives a shortcut character for the given command. This function supports only |
|
99 * one key shortcuts: if the shortcut is made up of a modifer (like ctrl) and the |
|
100 * base key, this function does not find it. |
|
101 * @param aCommandId The command for which a shortcut is fetched. |
|
102 * @param aContext The view where the shortcut should be available. |
|
103 * @param aQwertyMode Is the shortcut for QWERTY or ITU-T mode required. |
|
104 * ETrue means QWERTY mode. |
|
105 * @return The shortcut character for the given command. |
|
106 * 0 if no such command was found. |
|
107 */ |
|
108 static TText ShortcutForCommand( TInt aCommandId, TShortcutContext aContext, TBool aQwertyMode ); |
|
109 |
|
110 /** |
|
111 * Adds the shortcut hints to the given menu. If the device is currently in the QWERTY |
|
112 * mode, the QWERTY shortcuts are used. Otherwise, the ITU-T shortcuts are used. |
|
113 * Only one key shortcuts are hinted: if a QWERTY shortcut needs a modifier key (like ctrl), |
|
114 * no hint is added to the menu. |
|
115 * @param aMenuPane The menu where the shortcuts should be added. |
|
116 * @param aContext The view in which the menu is shown. |
|
117 */ |
|
118 void AppendShortcutHintsL( CEikMenuPane& aMenuPane, TShortcutContext aContext ) const; |
|
119 |
|
120 /** |
|
121 * Possible keyboard modes. Values match values stored to property key KAknKeyBoardLayout. |
|
122 */ |
|
123 enum TKeyBoardType |
|
124 { |
|
125 ENoKeyboard = 0, |
|
126 EItutKeyPad = 1, |
|
127 EQwerty4x12 = 2, |
|
128 EQwerty4x10 = 3, |
|
129 EQwerty3x11 = 4, |
|
130 EHalfQwerty = 5, |
|
131 ECustomQwerty = 6 |
|
132 }; |
|
133 |
|
134 /** |
|
135 * For checking current keyboard mode |
|
136 * @return Type of the currently active keyboard |
|
137 */ |
|
138 TKeyBoardType KeyBoardType() const; |
|
139 |
|
140 |
|
141 private: // construction |
|
142 |
|
143 CFSEmailUiShortcutBinding(); |
|
144 |
|
145 void ConstructL(); |
|
146 |
|
147 private: // methods |
|
148 |
|
149 //! Utility function for selecting the correct binding table for the given view. |
|
150 static void GetBindingsForContext( const TShortcutBinding*& aBindingArray, |
|
151 TInt& aBindingCount, |
|
152 TShortcutContext aContext ); |
|
153 |
|
154 //! Appends the given shortcut hint with decorations to the given descriptor. |
|
155 static void AppendHintToCaption( TDes& aCaption, TText aHint ); |
|
156 |
|
157 private: // data |
|
158 |
|
159 CPtiEngine* iPtiEngine; |
|
160 |
|
161 RProperty iKbLayoutProperty; |
|
162 |
|
163 CPtiKeyMappings* iQwertyMappings; // owned by iPtiEngine |
|
164 CPtiKeyMappings* iHalfQwertyMappings; // owned by iPtiEngine |
|
165 }; |
|
166 |
|
167 #endif // __FS_EMAIL_UI_SHORTCUT_BINDING_H |