64
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Parent class for specific fields owned by fieldcontainer
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#ifndef CESMRFIELD_H
|
|
18 |
#define CESMRFIELD_H
|
|
19 |
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <fbs.h>
|
|
22 |
//<cmail>
|
|
23 |
#include "esmrdef.h"
|
|
24 |
#include "esmrcommands.h"
|
|
25 |
//</cmail>
|
|
26 |
|
|
27 |
#include "mesmrcalentry.h"
|
|
28 |
#include "mesmrtitlepaneobserver.h"
|
|
29 |
#include "mesmrfieldeventobserver.h"
|
|
30 |
#include "mesmrfieldeventnotifier.h"
|
|
31 |
|
|
32 |
#include <coecntrl.h>
|
|
33 |
#include <esmrgui.mbg>
|
|
34 |
|
|
35 |
class MESMRListObserver;
|
|
36 |
class MESMRCalEntry;
|
|
37 |
class CMRBackground;
|
|
38 |
class MTouchFeedback;
|
|
39 |
class MESMRFieldValidator;
|
|
40 |
class CEikMenuPane;
|
|
41 |
class MTouchFeedback;
|
|
42 |
class CMRRecordingGc;
|
|
43 |
|
|
44 |
// Enumeration for border type
|
|
45 |
enum TESMRFieldFocusType
|
|
46 |
{
|
|
47 |
EESMRNoFocus = 0,
|
|
48 |
EESMRBorderFocus,
|
|
49 |
EESMRHighlightFocus
|
|
50 |
};
|
|
51 |
|
|
52 |
/**
|
|
53 |
* CESMRField defines a list item.
|
|
54 |
* This is the base class for all fields.
|
|
55 |
*
|
|
56 |
* @lib esmrgui.lib
|
|
57 |
*/
|
|
58 |
class CESMRField : public CCoeControl,
|
|
59 |
public MESMRFieldEventObserver,
|
|
60 |
public MESMRFieldEventNotifier
|
|
61 |
{
|
|
62 |
public:
|
|
63 |
/**
|
|
64 |
* Destructor.
|
|
65 |
*/
|
|
66 |
IMPORT_C virtual ~CESMRField();
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Construct field with the given component. Given component
|
|
70 |
* will have outline focus when focused.
|
|
71 |
*
|
|
72 |
* @param aControl Field control, ownership transferred
|
|
73 |
*/
|
|
74 |
IMPORT_C void ConstructL(
|
|
75 |
CCoeControl* aControl );
|
|
76 |
|
|
77 |
/**
|
|
78 |
* Observer interface is used to notify the list component when
|
|
79 |
* component is added, removed or needs resizing.
|
|
80 |
*
|
|
81 |
* @param aObserver List component observer
|
|
82 |
*/
|
|
83 |
IMPORT_C virtual void SetListObserver( MESMRListObserver* aObserver );
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Set identifier for this field.
|
|
87 |
*
|
|
88 |
* @param aFieldId Id for this field
|
|
89 |
*/
|
|
90 |
IMPORT_C virtual void SetFieldId( TESMREntryFieldId aFieldId );
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Set identifier for preceding item index.
|
|
94 |
*
|
|
95 |
* @param PreItemIndex Index for pre item in the list
|
|
96 |
*/
|
|
97 |
IMPORT_C void SetPreItemIndex( TInt aPreItemIndex );
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Set identifier for current item index.
|
|
101 |
*
|
|
102 |
* @param aCurrentItemIndex Index for current item in the list
|
|
103 |
*/
|
|
104 |
IMPORT_C void SetCurrentItemIndex( TInt aCurrentItemIndex );
|
|
105 |
|
|
106 |
public:
|
|
107 |
/**
|
|
108 |
* Layout this field relative to given TRect. Implementation MUST
|
|
109 |
* update the height of this field to given TRect so the calling
|
|
110 |
* list component knows where to place the next field.
|
|
111 |
*
|
|
112 |
* @param aRect Contains the rect for this field. The height must be updated.
|
|
113 |
* @deprecated Use InitializeL() and ExpandableHeight() instead.
|
|
114 |
*/
|
|
115 |
IMPORT_C void DoLayout( TRect& aRect );
|
|
116 |
|
|
117 |
/**
|
|
118 |
* Called in the constuct phase. Font and colors are typically set here
|
|
119 |
*/
|
|
120 |
IMPORT_C virtual void InitializeL();
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Called if the Font needs to be updated from CESMRLayoutManager
|
|
124 |
*
|
|
125 |
* @see InitializeL()
|
|
126 |
*/
|
|
127 |
IMPORT_C virtual void FontChangedL();
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Identifier for this field.
|
|
131 |
*
|
|
132 |
* @return TESMRField
|
|
133 |
*/
|
|
134 |
IMPORT_C virtual TESMREntryFieldId FieldId() const;
|
|
135 |
|
|
136 |
/**
|
|
137 |
* Identifier for preceding item index.
|
|
138 |
*
|
|
139 |
* @return The pre item index in the listpane
|
|
140 |
*/
|
|
141 |
IMPORT_C TInt PreItemIndex() const;
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Identifier for preceding item index.
|
|
145 |
*
|
|
146 |
* @return The current item index in the listpane
|
|
147 |
*/
|
|
148 |
IMPORT_C TInt CurrentItemIndex() const;
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Called by the list component. Implementations should update the
|
|
152 |
* the field according to MESMRCalEntry argument. Default implementation
|
|
153 |
* does nothing.
|
|
154 |
*
|
|
155 |
* @param aEntry Current calendar entry
|
|
156 |
*/
|
|
157 |
IMPORT_C virtual void InternalizeL( MESMRCalEntry& aEntry );
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Called by the list component. Implementations should update the
|
|
161 |
* the given calendar entry with its data.
|
|
162 |
*
|
|
163 |
* @param aEntry Current calendar entry
|
|
164 |
*/
|
|
165 |
IMPORT_C virtual void ExternalizeL( MESMRCalEntry& aEntry );
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Set this fields focus.
|
|
169 |
* @param aFocus
|
|
170 |
*/
|
|
171 |
IMPORT_C virtual void SetOutlineFocusL( TBool aFocus );
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Subclasses should overwrite this method when any validity
|
|
175 |
* checks are needed.
|
|
176 |
*
|
|
177 |
* @return ETrue if data is valid, EFalse if not (focus not changed)
|
|
178 |
*/
|
|
179 |
IMPORT_C virtual TBool OkToLoseFocusL( TESMREntryFieldId aNextItem );
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Return minimun vertical area that should be shown when
|
|
183 |
* scrolling the list.
|
|
184 |
* @param aUpper, the upper vertical coordinate
|
|
185 |
* @param aLower, the lower vertical coordinate
|
|
186 |
*/
|
|
187 |
IMPORT_C virtual void GetMinimumVisibleVerticalArea(TInt& aUpper, TInt& aLower);
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Get current cursor line virtical position, it's relative to current field
|
|
191 |
* If no internal cursor in this field, default return whole field rect size.
|
|
192 |
* @param aUpper, the upper vertical coordinate
|
|
193 |
* @param aLower, the lower vertical coordinate
|
|
194 |
*/
|
|
195 |
IMPORT_C virtual void GetCursorLineVerticalPos(TInt& aUpper, TInt& aLower);
|
|
196 |
|
|
197 |
/**
|
|
198 |
* Trigger for notifying when the list observer is set
|
|
199 |
*/
|
|
200 |
IMPORT_C virtual void ListObserverSet();
|
|
201 |
|
|
202 |
/**
|
|
203 |
* Executes generic command if needed by the field.
|
|
204 |
*
|
|
205 |
* @param aCommand, commandId to handle specific command
|
|
206 |
* @return ETrue if the command is used, EFalse otherwise
|
|
207 |
*/
|
|
208 |
IMPORT_C virtual TBool ExecuteGenericCommandL( TInt aCommand );
|
|
209 |
|
|
210 |
/**
|
|
211 |
* Notifies long tap event to field.
|
|
212 |
* Calls virtual CESMRField::HandleLongtapEventL for
|
|
213 |
* field specific event handling.
|
|
214 |
*
|
|
215 |
* @param aPosition position of the long tap event.
|
|
216 |
* @see HandleLongtapEventL
|
|
217 |
*/
|
|
218 |
IMPORT_C void LongtapDetectedL( const TPoint& aPosition );
|
|
219 |
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Set titlepane observer to see title pane subject events
|
|
223 |
* @param aObserver title pane observer to be set
|
|
224 |
*/
|
|
225 |
IMPORT_C virtual void SetTitlePaneObserver( MESMRTitlePaneObserver* aObserver );
|
|
226 |
|
|
227 |
/**
|
|
228 |
* From MESMRFieldEventNotifier
|
|
229 |
* Sets field event queue.
|
|
230 |
* @param aObserver observer to receive field events.
|
|
231 |
*/
|
|
232 |
IMPORT_C void SetEventQueueL( MESMRFieldEventQueue* aEventQueue );
|
|
233 |
|
|
234 |
/**
|
|
235 |
* Getter for retrieving outline focus state.
|
|
236 |
* @return ETrue if field is focused EFalse otherwise.
|
|
237 |
*/
|
|
238 |
IMPORT_C TBool HasOutlineFocus() const;
|
|
239 |
|
|
240 |
/**
|
|
241 |
* Getter for focus rect. CMRBackground uses this to get rectangle
|
|
242 |
* it draws background focus to.
|
|
243 |
* Returned rectangle should be relative to Field's rect.
|
|
244 |
* @return focus rectangle.
|
|
245 |
*/
|
|
246 |
IMPORT_C TRect GetFocusRect() const;
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Setter for background focus area. Every field should set
|
|
250 |
* this in their SizeChanged methods.
|
|
251 |
* Given rectangle should be relative to Field's rect.
|
|
252 |
* @param aFocusRect rectangle for focus.
|
|
253 |
*/
|
|
254 |
IMPORT_C void SetFocusRect( const TRect& aFocusRect );
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Getter for background focus type. CMRBackground uses this
|
|
258 |
* method to determine how to draw focus.
|
|
259 |
* @return focus type.
|
|
260 |
*/
|
|
261 |
IMPORT_C TESMRFieldFocusType GetFocusType() const;
|
|
262 |
|
|
263 |
/**
|
|
264 |
* Setter for focus type. Every field should set this in e.g. their
|
|
265 |
* ConstructL.
|
|
266 |
* @param aFocusType focus type.
|
|
267 |
*/
|
|
268 |
IMPORT_C void SetFocusType( TESMRFieldFocusType aFocusType );
|
|
269 |
|
|
270 |
/**
|
|
271 |
* Setter for field mode. Field is either in viewer or editor mode.
|
|
272 |
* @param aModeOfField Mode of the field
|
|
273 |
*/
|
|
274 |
IMPORT_C void SetFieldMode( TESMRFieldMode aMode );
|
|
275 |
|
|
276 |
/**
|
|
277 |
* Getter for the field mode.
|
|
278 |
* @return Field mode
|
|
279 |
*/
|
|
280 |
IMPORT_C TESMRFieldMode FieldMode() const;
|
|
281 |
|
|
282 |
/**
|
|
283 |
* Set middle softkey command and name
|
|
284 |
* @param aCommandId, command to execute on MSK press
|
|
285 |
* @param aResourceId, resource string to display on MSK
|
|
286 |
*/
|
|
287 |
IMPORT_C void ChangeMiddleSoftKeyL( TInt aCommandId, TInt aResourceId);
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Sets validator for field.
|
|
291 |
*
|
|
292 |
* @param aValidator validator to use.
|
|
293 |
*/
|
|
294 |
IMPORT_C virtual void SetValidatorL( MESMRFieldValidator* aValidator );
|
|
295 |
|
|
296 |
/**
|
|
297 |
* Tests if field control has been activated.
|
|
298 |
*/
|
|
299 |
IMPORT_C TBool IsFieldActivated() const;
|
|
300 |
|
|
301 |
/**
|
|
302 |
* Provides possibility for field to dynamically
|
|
303 |
* intialize context menu.
|
|
304 |
*
|
|
305 |
* @param aResourceId Context menu resource ID
|
|
306 |
* @param aMenuPane Pointer to menu pane
|
|
307 |
*/
|
|
308 |
IMPORT_C virtual void DynInitMenuPaneL(
|
|
309 |
TInt aResourceId,
|
|
310 |
CEikMenuPane* aMenuPane );
|
|
311 |
|
|
312 |
/**
|
|
313 |
* Setter for field view mode. Enumeration TESMRFieldType
|
|
314 |
* lists possible view modes.
|
|
315 |
* @param aViewMode View mode of the field
|
|
316 |
*/
|
|
317 |
IMPORT_C void SetFieldViewMode( TESMRFieldType aViewMode );
|
|
318 |
|
|
319 |
/**
|
|
320 |
* Getter for the field view mode.
|
|
321 |
* @return Field view mode
|
|
322 |
*/
|
|
323 |
IMPORT_C TESMRFieldType FieldViewMode() const;
|
|
324 |
|
|
325 |
/**
|
|
326 |
* Updates field extension control and takes ownership
|
|
327 |
* @param aControl Pointer to extension control.
|
|
328 |
*/
|
|
329 |
IMPORT_C void UpdateExtControlL(
|
|
330 |
CCoeControl* aControl );
|
|
331 |
|
|
332 |
/**
|
|
333 |
* Set field as locked field(can't be deleted or edited)
|
|
334 |
*/
|
|
335 |
IMPORT_C void virtual LockL();
|
|
336 |
|
|
337 |
/**
|
|
338 |
* Get lock status of the field
|
|
339 |
* @return ETrue shows field locked EFalse shows field not locked
|
|
340 |
*/
|
|
341 |
IMPORT_C TBool IsLocked();
|
|
342 |
|
|
343 |
/**
|
|
344 |
* Finds out if field supports longtap functionality or not
|
|
345 |
* @param aPointerEvent, where the event actually occured
|
|
346 |
* @return ETrue if field supports longtap functionality
|
|
347 |
*/
|
|
348 |
IMPORT_C virtual TBool SupportsLongTapFunctionalityL(
|
|
349 |
const TPointerEvent &aPointerEvent );
|
|
350 |
|
|
351 |
/**
|
|
352 |
* Moves field to and away from screen
|
|
353 |
* @param aVisible if ETrue, field is moved to screen
|
|
354 |
*/
|
|
355 |
IMPORT_C void MoveToScreen( TBool aVisible );
|
|
356 |
|
|
357 |
/**
|
|
358 |
* Records field drawing commands to custom graphics context
|
|
359 |
*/
|
|
360 |
IMPORT_C void RecordField();
|
|
361 |
|
|
362 |
protected:
|
|
363 |
|
|
364 |
/**
|
|
365 |
* Sends event to the event queue.
|
|
366 |
* @param aEvent event to send.
|
|
367 |
*/
|
|
368 |
IMPORT_C void NotifyEventL( const MESMRFieldEvent& aEvent );
|
|
369 |
|
|
370 |
/**
|
|
371 |
* Sends command event to the event queue.
|
|
372 |
* @param aCommand command to send
|
|
373 |
*/
|
|
374 |
IMPORT_C void NotifyEventL( TInt aCommand );
|
|
375 |
|
|
376 |
/**
|
|
377 |
* Sends event to the event queue asynchronously.
|
|
378 |
* Ownership of the event is transferred to the event queue.
|
|
379 |
* @param aEvent event to send.
|
|
380 |
*/
|
|
381 |
IMPORT_C void NotifyEventAsyncL( MESMRFieldEvent* aEvent );
|
|
382 |
|
|
383 |
/**
|
|
384 |
* Sends command event to the event queue asynchronously.
|
|
385 |
* Ownership of the event is transferred to the event queue.
|
|
386 |
* @param aEvent event to send.
|
|
387 |
*/
|
|
388 |
IMPORT_C void NotifyEventAsyncL( TInt aCommand );
|
|
389 |
|
|
390 |
/**
|
|
391 |
* Set middle softkey command
|
|
392 |
* @param aResourceId, MSK CBA_BUTTON resource id
|
|
393 |
*/
|
|
394 |
IMPORT_C void ChangeMiddleSoftKeyL( TInt aResourceId );
|
|
395 |
|
|
396 |
/**
|
|
397 |
* Requests dialog to restore middle softkey to the default one.
|
|
398 |
*/
|
|
399 |
IMPORT_C void RestoreMiddleSoftKeyL();
|
|
400 |
|
|
401 |
/**
|
|
402 |
* Sets middle softkey visible in field.
|
|
403 |
* @param aVisible if ETrue sets middle softkey visible.
|
|
404 |
*/
|
|
405 |
IMPORT_C void SetMiddleSoftKeyVisible( TBool aVisible );
|
|
406 |
|
|
407 |
/**
|
|
408 |
* Long tap event handler for field. Subclasses should execute their
|
|
409 |
* specific long tap action when this event handler is called.
|
|
410 |
*
|
|
411 |
* @param aPosition position of long tap event
|
|
412 |
*/
|
|
413 |
IMPORT_C virtual void HandleLongtapEventL( const TPoint& aPosition );
|
|
414 |
|
|
415 |
/**
|
|
416 |
* Single tap event handler for field. Subclasses should execute their
|
|
417 |
* specific single tap action when this event handler is called.
|
|
418 |
* @param aPosition position of single tap event
|
|
419 |
* @return ETrue if field handles single tap event.
|
|
420 |
*/
|
|
421 |
IMPORT_C virtual TBool HandleSingletapEventL( const TPoint& aPosition );
|
|
422 |
/**
|
|
423 |
* Pointer event handler for field. This is being called if the received
|
|
424 |
* pointer event has not been handled by single tap or long tap handler.
|
|
425 |
* @param aPointerEvent the pointer event
|
|
426 |
* @return ETrue if pointer event was consumed
|
|
427 |
*/
|
|
428 |
IMPORT_C virtual TBool HandleRawPointerEventL( const TPointerEvent& aPointerEvent );
|
|
429 |
|
|
430 |
public: // From base class CCoeControl
|
|
431 |
IMPORT_C void SetContainerWindowL(const CCoeControl& aContainer);
|
|
432 |
IMPORT_C virtual TKeyResponse OfferKeyEventL( const TKeyEvent& aEvent, TEventCode aType );
|
|
433 |
IMPORT_C virtual void SizeChanged();
|
|
434 |
IMPORT_C virtual TInt CountComponentControls() const;
|
|
435 |
IMPORT_C virtual CCoeControl* ComponentControl( TInt aInd ) const;
|
|
436 |
IMPORT_C virtual TSize MinimumSize();
|
|
437 |
IMPORT_C void Draw( const TRect& aRect ) const;
|
|
438 |
|
|
439 |
protected: // From base class CCoeControl
|
|
440 |
|
|
441 |
/**
|
|
442 |
* Implements pointer event handling for fields.
|
|
443 |
* Subclasses must not override this but implement the field specific
|
|
444 |
* actions using the template methods.
|
|
445 |
*
|
|
446 |
* @param aPointerEvent the pointer event to handle
|
|
447 |
* @see HandleSingletapEventL
|
|
448 |
* @see HandleRawPointerEventL
|
|
449 |
*/
|
|
450 |
IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
|
|
451 |
|
|
452 |
protected:
|
|
453 |
|
|
454 |
IMPORT_C CESMRField();
|
|
455 |
|
|
456 |
// From MESMRFieldEventObserver
|
|
457 |
/**
|
|
458 |
* Handles an event from other field.
|
|
459 |
* Default implementation delegates command events to
|
|
460 |
* <c>ExecuteGenericCommandL()</c>
|
|
461 |
* @param aEvent event to handle
|
|
462 |
*/
|
|
463 |
IMPORT_C void HandleFieldEventL( const MESMRFieldEvent& aEvent );
|
|
464 |
|
|
465 |
// From MESMRFieldEventNotifier
|
|
466 |
/**
|
|
467 |
* Returns the event observer interface
|
|
468 |
*/
|
|
469 |
IMPORT_C MESMRFieldEventObserver* EventObserver() const;
|
|
470 |
|
|
471 |
/**
|
|
472 |
* Initiates tactile feedback when called
|
|
473 |
*/
|
|
474 |
IMPORT_C void HandleTactileFeedbackL();
|
|
475 |
|
|
476 |
|
|
477 |
private:
|
|
478 |
void AquireTactileFeedback();
|
|
479 |
void DrawControl( CCoeControl* aControl ) const;
|
|
480 |
|
|
481 |
protected: // data
|
|
482 |
/// Own: control which is surrounded by border
|
|
483 |
CCoeControl* iExtControl;
|
|
484 |
/// Ref: Observer for notifying field container
|
|
485 |
MESMRListObserver* iObserver;
|
|
486 |
/// Ref: Id for this field.
|
|
487 |
TESMREntryFieldId iFieldId;
|
|
488 |
/// Ref: Id for preceding item index.
|
|
489 |
TInt iPreItemIndex;
|
|
490 |
/// Ref: Id for current item index.
|
|
491 |
TInt iCurrentItemIndex;
|
|
492 |
/// Field event queue.
|
|
493 |
MESMRFieldEventQueue* iEventQueue;
|
|
494 |
/// Custom MSK flag
|
|
495 |
TBool iCustomMsk;
|
|
496 |
/// Redraw flag
|
|
497 |
TBool iDisableRedraw;
|
|
498 |
/// Field default value for MSK visibility
|
|
499 |
TBool iDefaultMskVisible;
|
|
500 |
/// Msk disable/enable flag
|
|
501 |
TBool iMskVisible;
|
|
502 |
/// Own: Background/focus layer
|
|
503 |
CMRBackground* iBackground;
|
|
504 |
/// Boolean whether field has outline focus
|
|
505 |
TBool iOutlineFocus;
|
|
506 |
/// Background focus rect
|
|
507 |
TRect iFocusRect;
|
|
508 |
/// Background focus type
|
|
509 |
TESMRFieldFocusType iFocusType;
|
|
510 |
/// Field mode (editor or viewer)
|
|
511 |
TESMRFieldMode iFieldMode;
|
|
512 |
/// Field view mode. Required for disabling a field
|
|
513 |
TESMRFieldType iFieldViewMode;
|
|
514 |
/// Ref: Reference to tactile feedback
|
|
515 |
MTouchFeedback* iTactileFeedback;
|
|
516 |
/// Ref: Validator
|
|
517 |
MESMRFieldValidator* iValidator;
|
|
518 |
/// Own: lock status
|
|
519 |
TBool iLocked;
|
|
520 |
/// Own: Cache for drawing commands
|
|
521 |
CMRRecordingGc* iRecordingGc;
|
|
522 |
};
|
|
523 |
|
|
524 |
#endif // CESMRFIELD_H
|