|
1 /* |
|
2 * Copyright (c) 2007 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: Toolbar extension component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CAKNTOOLBAREXTENSION_H |
|
20 #define CAKNTOOLBAREXTENSION_H |
|
21 |
|
22 #include <aknbutton.h> |
|
23 |
|
24 class CAknToolbarItem; |
|
25 class CAknToolbarExtensionView; |
|
26 class CAknToolbar; |
|
27 |
|
28 |
|
29 /** |
|
30 * Toolbar extension. |
|
31 * |
|
32 * Toolbar extension component. Opens an extension view when this extension |
|
33 * is pressed. |
|
34 * |
|
35 * @lib eikcoctl |
|
36 * @since S60 v5.0 |
|
37 */ |
|
38 NONSHARABLE_CLASS( CAknToolbarExtension ) : public CAknButton, |
|
39 public MCoeControlObserver |
|
40 { |
|
41 |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Creates toolbar extension |
|
46 * |
|
47 * @return extension |
|
48 */ |
|
49 static CAknToolbarExtension* NewL( ); |
|
50 |
|
51 |
|
52 /** |
|
53 * Creates toolbar extension |
|
54 * |
|
55 * @param aResourceid The ID for this component's resource |
|
56 * @return extension |
|
57 */ |
|
58 IMPORT_C static CAknToolbarExtension* NewL( TInt aResourceId ); |
|
59 |
|
60 |
|
61 /** |
|
62 * Creates toolbar extension |
|
63 * |
|
64 * @param aResourceid The ID for this component's resource |
|
65 * @return extension |
|
66 */ |
|
67 IMPORT_C static CAknToolbarExtension* NewLC( TInt aResourceId ); |
|
68 |
|
69 /** |
|
70 * Destructor |
|
71 */ |
|
72 ~CAknToolbarExtension(); |
|
73 |
|
74 // from base class CCoeControl |
|
75 |
|
76 /** |
|
77 * From CAknButton |
|
78 * constructs the extension from resource |
|
79 * |
|
80 * @param aReader resource reader |
|
81 */ |
|
82 void ConstructFromResourceL( TResourceReader& aReader ); |
|
83 |
|
84 /** |
|
85 * From CCoeControl |
|
86 * |
|
87 * @param aKeyEvent information about the key event |
|
88 * @param aType type of the key event |
|
89 * @return boolean indicating if key event was consumed or not |
|
90 */ |
|
91 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
92 |
|
93 /** |
|
94 * From CCoeControl |
|
95 * Handles resource changes |
|
96 * |
|
97 * @param aType the type of the resource change |
|
98 */ |
|
99 void HandleResourceChange( TInt aType ); |
|
100 |
|
101 /** |
|
102 * From CCoeControl. |
|
103 * Makes extension and extension view visible or hides them |
|
104 * |
|
105 * @param aVisible boolean to tell if showing or hiding |
|
106 */ |
|
107 void MakeVisible( TBool aVisible ); |
|
108 |
|
109 |
|
110 // from base class MCoeControlObserver |
|
111 |
|
112 /** |
|
113 * From MCoeControlObserver. |
|
114 * Here the events from the extension itself and extension view components |
|
115 * are handled |
|
116 * |
|
117 * @param aControl control that sent this event |
|
118 * @param aEventType type of the event |
|
119 */ |
|
120 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); |
|
121 |
|
122 |
|
123 // new functions |
|
124 |
|
125 /** |
|
126 * Using this the extension view can get extension position in fixed toolbar |
|
127 * |
|
128 * @return index of the position |
|
129 */ |
|
130 TInt ExtensionPosition(); |
|
131 |
|
132 /** |
|
133 * Creates idle if it does not exist yet and calls it by giving |
|
134 * a callback for notifying when ready to draw extension view. |
|
135 */ |
|
136 void ShowViewViaIdle(); |
|
137 |
|
138 /** |
|
139 * Callback to get notified when ready to show extension view again |
|
140 * @param aThis pointer to this object |
|
141 * @return error code |
|
142 */ |
|
143 static TInt ShowView( TAny* aThis ); |
|
144 |
|
145 /** |
|
146 * Extension view tells extension to change state using this method. This is |
|
147 * used when tapping outside extension view. |
|
148 */ |
|
149 void ViewClosed(); |
|
150 |
|
151 /** |
|
152 * Gets a pointer to the specified control. |
|
153 * |
|
154 * @param aControlId The ID of the control for which a pointer is required. |
|
155 * @return Pointer to the control with the specified ID. |
|
156 */ |
|
157 IMPORT_C CCoeControl* ControlOrNull( TInt aCommandId ) const; |
|
158 |
|
159 /** |
|
160 * Adds one item to the specified place. Takes ownership. Leaves with |
|
161 * value KErrNotSupported, if called when extension view is shown and |
|
162 * with KErrArgument if aItem does not exist or aIndex is out of bound. |
|
163 * |
|
164 * @param aItem The control. |
|
165 * @param aType The type of the new toolbar item. |
|
166 * @param aCommandId The command ID for this item. |
|
167 * @param aFlags The flags. |
|
168 * @param aIndex The index in array at which item should be added. |
|
169 */ |
|
170 IMPORT_C void AddItemL( CCoeControl* aItem, |
|
171 TInt aType, |
|
172 TInt aCommandId, |
|
173 TInt aFlags, |
|
174 TInt aIndex ); |
|
175 |
|
176 |
|
177 /** |
|
178 * Removes one item from the extension view. Leaves with value |
|
179 * KErrNotSupported if called when extension view is shown. |
|
180 * |
|
181 * @param aCommandId The ID of the item which should be removed. |
|
182 */ |
|
183 IMPORT_C void RemoveItemL( TInt aCommandId ); |
|
184 |
|
185 /** |
|
186 * Gets extension flags |
|
187 * |
|
188 * @return extension flags |
|
189 */ |
|
190 TInt ExtensionFlags(); |
|
191 |
|
192 /** |
|
193 * Returns boolean indicating if extension view is shown. |
|
194 * |
|
195 * @return ETrue if shown, EFalse if not |
|
196 */ |
|
197 IMPORT_C TBool IsShown() const; |
|
198 |
|
199 /** |
|
200 * Shows or hides extension view. |
|
201 * |
|
202 * @param aShown to show or to hide |
|
203 */ |
|
204 IMPORT_C void SetShown( TBool aShown ); |
|
205 |
|
206 /** |
|
207 * Returns pointer to extension view |
|
208 * |
|
209 * @return pointer to extension view |
|
210 */ |
|
211 CCoeControl* ExtensionView(); |
|
212 |
|
213 /** |
|
214 * Sets item dimmed or undimmed |
|
215 * |
|
216 * @param aCommandId command id of the item to be dimmed/undimmed |
|
217 * @param aDimmed to dim or undim |
|
218 */ |
|
219 IMPORT_C void SetItemDimmed( TInt aCommandId, TBool aDimmed ); |
|
220 |
|
221 /** |
|
222 * Hides or unhides item. Leaves with value KErrNotSupported if called |
|
223 * when extension view is shown. |
|
224 * |
|
225 * @param aCommandId command id of the item to be hidden/unhidden |
|
226 * @param aHide to hide or unhide |
|
227 */ |
|
228 IMPORT_C void HideItemL( TInt aCommandId, TBool aHide ); |
|
229 |
|
230 private: |
|
231 |
|
232 /** |
|
233 * Constructor |
|
234 */ |
|
235 CAknToolbarExtension(); |
|
236 |
|
237 /** |
|
238 * Constructs the extension button by adding button states with icons |
|
239 */ |
|
240 void BaseConstructL(); |
|
241 |
|
242 /** |
|
243 * Constructs a control from resource |
|
244 * |
|
245 * @param aResourceId The id for this component's resource. |
|
246 */ |
|
247 void ConstructFromResourceL( const TInt aResourceId ); |
|
248 |
|
249 private: // data |
|
250 |
|
251 /** |
|
252 * Pointer to extension view. |
|
253 * Own. |
|
254 */ |
|
255 CAknToolbarExtensionView* iView; |
|
256 |
|
257 /** |
|
258 * Pointer to toolbar, so that extension can notify toolbar about |
|
259 * extension events |
|
260 * Not own. |
|
261 */ |
|
262 CAknToolbar* iToolbar; |
|
263 |
|
264 /** |
|
265 * idle to show extension again on top of other components when |
|
266 * extension is shown when coming back to view. |
|
267 * Own. |
|
268 */ |
|
269 CIdle* iIdle; |
|
270 |
|
271 /** |
|
272 * Extension flags |
|
273 */ |
|
274 TInt iFlags; |
|
275 }; |
|
276 |
|
277 #endif // CAKNTOOLBAREXTENSION_H |