|
1 /* |
|
2 * Copyright (c) 2003 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMIDTEXTFIELDITEM_H |
|
20 #define CMIDTEXTFIELDITEM_H |
|
21 |
|
22 // for MEikEdwinObserver and MEikEdwinSizeObserver interfaces in class declaration |
|
23 #include <eikedwob.h> // for MEikEdwinSizeObserver |
|
24 // CMIDControl item inheritance in class declaration |
|
25 #include "CMIDControlItem.h" |
|
26 #include "lcdui.h" |
|
27 |
|
28 class CMIDEdwin; |
|
29 class CAknEdwinDrawingModifier; |
|
30 |
|
31 NONSHARABLE_CLASS(CMIDTextFieldItem) : public CMIDControlItem, public MMIDTextField, |
|
32 public MEikEdwinSizeObserver, public MEikEdwinObserver |
|
33 { |
|
34 public: |
|
35 |
|
36 /** |
|
37 * Double ctor |
|
38 * @param aLabel Label |
|
39 * @return MMIDTextField instance |
|
40 * |
|
41 * @since s60 |
|
42 */ |
|
43 static MMIDTextField* NewL( |
|
44 const TDesC& aLabel, const TDesC& aText, |
|
45 TInt aConstraints, TInt aMaxSize, CMIDUIManager* aUIManager); |
|
46 |
|
47 ~CMIDTextFieldItem(); |
|
48 // |
|
49 // From MMIDTextField |
|
50 // |
|
51 void DeleteTextL(TInt aOffset,TInt aLength); |
|
52 void SetTextL(const TDesC& aText); |
|
53 void InsertTextL(const TDesC& aText,TInt aPosition); |
|
54 void SetConstraintsL(TUint aConstraints); |
|
55 TInt SetMaxSizeL(TInt aMaxSize); |
|
56 TInt GetMaxSize(); |
|
57 TInt Size(); |
|
58 TInt GetCaretPosition(); |
|
59 HBufC* GetTextL(); |
|
60 void SetInitialInputModeL(const TDesC& aCharacterSubset); |
|
61 // |
|
62 // From MMIDItem |
|
63 // |
|
64 void SetLabelL(const TDesC& aLabel); |
|
65 void SetLayoutL(TLayout aLayout); |
|
66 TSize ResetPreferredSize() const; |
|
67 void SetPreferredSizeL(const TSize& aSize); |
|
68 TSize PreferredSize() const; |
|
69 TSize MinimumSize() const; |
|
70 void AddCommandL(MMIDCommand* aCommand); |
|
71 void RemoveCommand(MMIDCommand* aCommand); |
|
72 void SetDefaultCommand(MMIDCommand* aCommand); |
|
73 // |
|
74 // From MMIDComponent |
|
75 // |
|
76 void Dispose(); |
|
77 // |
|
78 // From CCoeControl |
|
79 // |
|
80 TSize MinimumSize(); |
|
81 TInt CountComponentControls() const; |
|
82 CCoeControl* ComponentControl(TInt aIndex) const; |
|
83 void Draw(const TRect& aRect) const; |
|
84 void SizeChanged(); |
|
85 void SetContainerWindowL(const CCoeControl& aContainer); |
|
86 void FocusChanged(TDrawNow /*DrawNow*/); |
|
87 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
88 TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
89 TCoeInputCapabilities InputCapabilities() const; |
|
90 #ifdef RD_SCALABLE_UI_V2 |
|
91 void HandlePointerEventL(const TPointerEvent &aPointerEvent); |
|
92 #endif // RD_SCALABLE_UI_V2 |
|
93 void MakeVisible(TBool aVisible); |
|
94 |
|
95 // |
|
96 // From CMIDItem |
|
97 // |
|
98 TInt ItemPreferredHeightWithoutLabel(); |
|
99 TRect FocusableRect(); |
|
100 void HandleCurrentL(TBool aCurrent); |
|
101 |
|
102 // |
|
103 // From CMIDControlItem |
|
104 // |
|
105 void ResolutionChange(TInt aType); |
|
106 void PostFocusTransferEvent(TBool aFocus, CMIDForm::TDirection aDirection); |
|
107 void RestoreInnerFocus(); |
|
108 // |
|
109 // From MEikEdwinSizeObserver |
|
110 // |
|
111 TBool HandleEdwinSizeEventL(CEikEdwin* /*aEdwin*/, |
|
112 TEdwinSizeEvent /*aEventType*/, TSize aDesirableEdwinSize); |
|
113 // |
|
114 // From MEikEdwinObserver |
|
115 // |
|
116 void HandleEdwinEventL(CEikEdwin* /*aEdwin*/,TEdwinEvent /*aEventType*/); |
|
117 // |
|
118 // TextField implements MCoeControlObserver and calls our HandleControlEventL on EEventStateChanged |
|
119 // |
|
120 void HandleControlEventL(CCoeControl* aSource, MCoeControlObserver::TCoeEvent aEventType); |
|
121 // |
|
122 void DoHandleEdwinEventL(); |
|
123 // returns ETrue if successful, sets aPoint the xy coordinates of the cursor |
|
124 TBool GetCursorPosL(TPoint& aPoint); |
|
125 |
|
126 private: |
|
127 void CreateTextFieldL(const TDesC& aText, TUint aConstraints, TInt aMaxSize); |
|
128 |
|
129 /** |
|
130 * Update the layout for the Edwin control relative to the rect where |
|
131 * the Edwin will be laid out, and the top margin, and the height |
|
132 * |
|
133 * @note Updates <code>iEdwinMarginTop</code>, |
|
134 * <code>iEdwinMinHeight</code>, |
|
135 */ |
|
136 void UpdateLayout(); |
|
137 |
|
138 /** |
|
139 * Ctor |
|
140 * @param aUIManager UI manager |
|
141 * |
|
142 * @since s60 |
|
143 */ |
|
144 CMIDTextFieldItem(CMIDUIManager* aUIManager); |
|
145 |
|
146 void ConstructL(const TDesC& aLabel,const TDesC& aText,TInt aConstraints,TInt aMaxSize); |
|
147 CMIDEdwin* TextComponent() const; |
|
148 |
|
149 public: |
|
150 /** |
|
151 * Sets the cursor visiblity for the text field (=edwin) when this item is focused. |
|
152 * If the item is not focused, this method does nothing. |
|
153 * |
|
154 * @param aVisible Defines the visibility of the cursor. |
|
155 * @since S60 5.0 |
|
156 */ |
|
157 void SetCursorVisibility(TBool aVisible); |
|
158 private: |
|
159 CMIDEdwin* iTextField; |
|
160 HBufC* iText; |
|
161 CAknEdwinDrawingModifier* iDrawingModifier; |
|
162 TUint8 iEdwinMarginTop; |
|
163 TUint8 iEdwinMinHeight; |
|
164 |
|
165 }; |
|
166 |
|
167 #endif // CMIDTEXTFIELDITEM_H |
|
168 |
|
169 |
|
170 |