|
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 CMIDSTRINGITEM_H |
|
20 #define CMIDSTRINGITEM_H |
|
21 |
|
22 #include "CMIDControlItem.h" |
|
23 #include "lcdui.h" |
|
24 // using CAknButton API when appearance is MMIDItem::EButton |
|
25 #include <aknbutton.h> |
|
26 |
|
27 #ifdef RD_TACTILE_FEEDBACK |
|
28 #include <touchfeedback.h> |
|
29 #endif |
|
30 |
|
31 |
|
32 class CMIDStringButton; |
|
33 |
|
34 /** |
|
35 * A form string item as defined in MMIDStringItem. Contains a CMIDItemLabel |
|
36 * inherited from CMIDControlItem (the label) and a second CMIDItemLabel |
|
37 * to display the content of the string item. |
|
38 */ |
|
39 NONSHARABLE_CLASS(CMIDStringItem) : public CMIDControlItem, public MMIDStringItem |
|
40 { |
|
41 public: |
|
42 /** |
|
43 * Double ctor |
|
44 * @param aLabel Label |
|
45 * @return MMIDStringItem instance |
|
46 * |
|
47 * @since s60 |
|
48 */ |
|
49 static MMIDStringItem* NewL( |
|
50 const TDesC& aLabel, const TDesC& aText, TAppearance aAppearance, CMIDUIManager* aUIManager); |
|
51 |
|
52 const TDesC& Text() const; |
|
53 MMIDFont* Font() const; |
|
54 // |
|
55 // From CMIDItem |
|
56 // |
|
57 TBool IsSelectable() const; |
|
58 TPtrC Label() const; |
|
59 // |
|
60 // From MMIDStringItem |
|
61 // |
|
62 void SetTextL(const TDesC& aText); |
|
63 void SetFontL(MMIDFont* aFont); |
|
64 // |
|
65 // From MMIDItem |
|
66 // |
|
67 void SetLabelL(const TDesC& aLabel); |
|
68 void SetLayoutL(TLayout aLayout); |
|
69 void SetPreferredSizeL(const TSize& aSize); |
|
70 |
|
71 TSize MinimumSize() const; |
|
72 TSize PreferredSize() const; |
|
73 MMIDItem::TAppearance Appearance() const; |
|
74 |
|
75 void AddCommandL(MMIDCommand* aCommand); |
|
76 void RemoveCommand(MMIDCommand* aCommand); |
|
77 void SetDefaultCommand(MMIDCommand* aCommand); |
|
78 // |
|
79 // From MMIDComponent |
|
80 // |
|
81 void Dispose(); |
|
82 // |
|
83 // From CCoeControl |
|
84 // |
|
85 TSize MinimumSize(); |
|
86 TInt CountComponentControls() const; |
|
87 CCoeControl* ComponentControl(TInt aIndex) const; |
|
88 void Draw(const TRect& aRect) const; |
|
89 void SizeChanged(); |
|
90 void ResolutionChange(TInt aType); |
|
91 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
92 void SetContainerWindowL(const CCoeControl& aContainer); |
|
93 #ifdef RD_SCALABLE_UI_V2 |
|
94 void HandlePointerEventL(const TPointerEvent &aPointerEvent); |
|
95 #endif // RD_SCALABLE_UI_V2 |
|
96 |
|
97 // |
|
98 // From CMIDItem |
|
99 // |
|
100 TInt ItemPreferredHeightWithoutLabel(); |
|
101 // |
|
102 // From CMIDControlItem |
|
103 // |
|
104 void FocusChanged(TDrawNow aDrawNow); |
|
105 TRect FocusableRect(); |
|
106 // |
|
107 // |
|
108 CMIDItemLabel* StringContentControl() const; |
|
109 TBool IsUnconstrainedStringItem(); |
|
110 TBool WidthOrHeightSpecified() const; |
|
111 TBool WidthSpecified() const; |
|
112 TBool HeightSpecified() const; |
|
113 TSize ResetPreferredSize() const; |
|
114 void AdjustToNewWidthL(TInt aWidth); |
|
115 TInt NumNewlinesBefore(); |
|
116 TInt NumNewlinesAfter(); |
|
117 TSize PreferredSize(); |
|
118 void AdjustToSizeL(const TSize& aSize); |
|
119 |
|
120 /** |
|
121 * Gives appearance after taking into account whether the item has commands or not. |
|
122 * Focusable items (e.g hyperlinks) are rendered as plain if there are no commands. |
|
123 * NOTE: EPlain is dealed as a EHyperlink if it contains command(s) |
|
124 * @return Appearance mode |
|
125 */ |
|
126 TAppearance RenderedAppearance() const; |
|
127 |
|
128 /** |
|
129 * Returns area that is sensitive to tapping actions |
|
130 */ |
|
131 TRect TappingActionRect(); |
|
132 |
|
133 /** |
|
134 * Returns ETrue if CMIDStringItem was didided to several CMIDLabelContainerItem |
|
135 * objects due to concatenation. |
|
136 * Returns EFalse if CMIDStringItem was added to Form as default item |
|
137 */ |
|
138 TBool IsDivided(); |
|
139 /** |
|
140 * Sets flag iIsDivided to ETrue if CMIDStringItem was didided to several CMIDLabelContainerItem |
|
141 * objects due to concatenation. |
|
142 * Sets flag iIsDivided to EFalse if CMIDStringItem was added to Form as default item. |
|
143 */ |
|
144 void SetIsDivided(TBool aIsDivided); |
|
145 |
|
146 private: |
|
147 |
|
148 /** |
|
149 * Ctor |
|
150 * @param aAppearance Appearance |
|
151 * @param aUIManager UI manager |
|
152 * |
|
153 * @since s60 |
|
154 */ |
|
155 CMIDStringItem(TAppearance aAppearance, CMIDUIManager* aUIManager); |
|
156 |
|
157 void ConstructL(const TDesC& aLabel,const TDesC& aText); |
|
158 ~CMIDStringItem(); |
|
159 // |
|
160 void CountNewlinesBeforeAndAfter(const TDesC& aText); |
|
161 |
|
162 /** |
|
163 * Sets label and content colors according to the appearance mode and focus info |
|
164 * NOTE: focusable items (e.g hyperlinks) are rendered as plain if there are no commands. |
|
165 * PLAIN: |
|
166 * label & content = EAknsCIQsnTextColorsCG6 (text #6 main area, main area texts #215) |
|
167 * HYPERLINK - FOCUSED: |
|
168 * label & content = EAknsCIQsnTextColorsCG10 (text #10 list highlight, list texts #215) |
|
169 * HYPERLINK - NON FOCUSED: |
|
170 * label & content = EAknsCIQsnHighlightColorsCG3 (highlight #3 link indication, link text and underline indication #210) |
|
171 */ |
|
172 void SetColorL(); |
|
173 |
|
174 TRgb BorderColor() const; |
|
175 |
|
176 /** |
|
177 * Update button size. If buttonSize was not set before (height or width == 0) then first size defaults to minimumSize |
|
178 * @param aNewWidth a new width |
|
179 */ |
|
180 void CMIDStringItem::SetButtonWidth(TInt aNewWidth); |
|
181 |
|
182 /** |
|
183 * Calculates the minimum button size with ellipsis used as text |
|
184 */ |
|
185 void CalculateButtonEllipsedSizeL(); |
|
186 |
|
187 #ifdef RD_TACTILE_FEEDBACK |
|
188 private: |
|
189 MTouchFeedback* iFeedback; |
|
190 #endif |
|
191 |
|
192 private: |
|
193 TBool iHyperLinkActivated; |
|
194 HBufC* iText; |
|
195 TAppearance iAppearance; |
|
196 MMIDFont* iFont; |
|
197 CMIDItemLabel* iContentControl; |
|
198 TInt iNumNewlinesBefore; |
|
199 TInt iNumNewlinesAfter; |
|
200 TGulBorder::TColors iBorderColors; |
|
201 CAknButton* iButton; // used when appearance is MMIDItem::EButton |
|
202 TSize iSavedButtonSize; // the latest set button size is kept separately in the variable |
|
203 TSize iEllipsedButtonSize; // minimum button size if ellipsis is used instead of text |
|
204 #ifdef RD_SCALABLE_UI_V2 |
|
205 TBool iPointerDownOnContentArea; // ETrue, if EButton1Down happened on item content area |
|
206 #endif //RD_SCALABLE_UI_V2 |
|
207 // flag detects if string item was divided to label container items |
|
208 // due to concatenation of contents contained in adjacent string items |
|
209 TBool iIsDivided; |
|
210 |
|
211 }; |
|
212 |
|
213 #endif // CMIDSTRINGITEM_H |