66
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2006 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: Implementation class for TextBox
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <lafmain.h>
|
|
20 |
// LAF API use in GetLayout function
|
|
21 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
22 |
|
|
23 |
#include "CMIDEdwin.h"
|
|
24 |
#include "CMIDTextBoxEdwin.h"
|
|
25 |
// API for iCustomDraw
|
|
26 |
#include "CMIDTextBoxEdwinCustomDraw.h"
|
|
27 |
#include "CMIDDisplayable.h"
|
|
28 |
|
|
29 |
// class CMIDTextBoxEdwin
|
|
30 |
|
|
31 |
CMIDTextBoxEdwin* CMIDTextBoxEdwin::NewL(TInt aConstraints,
|
|
32 |
const TDesC& aText,
|
|
33 |
TInt aMaxSize,
|
|
34 |
MMIDDisplayable* aDisplayable)
|
|
35 |
{
|
|
36 |
CMIDTextBoxEdwin* textBox = new(ELeave)CMIDTextBoxEdwin(aConstraints, aDisplayable);
|
|
37 |
CleanupStack::PushL(textBox);
|
|
38 |
textBox->ConstructL(aText,aMaxSize);
|
|
39 |
CleanupStack::Pop(textBox);
|
|
40 |
return textBox;
|
|
41 |
}
|
|
42 |
|
|
43 |
void CMIDTextBoxEdwin::ConstructL(const TDesC& aText,TInt aMaxSize)
|
|
44 |
{
|
|
45 |
// just call superclass, for now
|
|
46 |
CMIDEdwin::ConstructL(aText, aMaxSize);
|
|
47 |
}
|
|
48 |
|
|
49 |
// ----------------------------------------------------------------------------
|
|
50 |
// CMIDTextBoxEdwin::GetLayout()
|
|
51 |
// ----------------------------------------------------------------------------
|
|
52 |
TAknMultiLineTextLayout CMIDTextBoxEdwin::GetLayout() const
|
|
53 |
{
|
|
54 |
TAknMultiLineTextLayout edwinLayout;
|
|
55 |
TAknTextComponentLayout textLayout;
|
|
56 |
RArray<TAknTextComponentLayout> edwinLayoutLines;
|
|
57 |
|
|
58 |
// TextBox case
|
|
59 |
TAknWindowComponentLayout rowPaneLayout; // row pane
|
|
60 |
TAknTextComponentLayout textRowLayout; // text within a row pane
|
|
61 |
|
|
62 |
textLayout = AknLayoutScalable_Avkon::list_single_midp_pane_t1();
|
|
63 |
|
|
64 |
// get the number of layout lines for panel rows
|
|
65 |
TAknLayoutScalableParameterLimits limits =
|
|
66 |
AknLayoutScalable_Avkon::list_single_midp_pane_ParamLimits();
|
|
67 |
TInt linesCount = limits.LastRow() + 1;
|
|
68 |
|
|
69 |
for (TInt i = 0; i < linesCount; i++)
|
|
70 |
{
|
|
71 |
// translate one row of text layout inside a row pane
|
|
72 |
textRowLayout = TAknWindowComponentLayout::ComposeText(
|
|
73 |
AknLayoutScalable_Avkon::list_single_midp_pane(i),
|
|
74 |
textLayout);
|
|
75 |
|
|
76 |
TRAP_IGNORE(edwinLayoutLines.AppendL(textRowLayout));
|
|
77 |
}
|
|
78 |
|
|
79 |
edwinLayout = TAknTextComponentLayout::Multiline(edwinLayoutLines);
|
|
80 |
edwinLayoutLines.Reset();
|
|
81 |
|
|
82 |
return edwinLayout;
|
|
83 |
}
|
|
84 |
|
|
85 |
|
|
86 |
CMIDTextBoxEdwin::CMIDTextBoxEdwin(TUint aConstraints, MMIDDisplayable* aDisplayable)
|
|
87 |
: CMIDEdwin(aConstraints, aDisplayable, NULL)
|
|
88 |
{
|
|
89 |
}
|
|
90 |
|
|
91 |
CMIDTextBoxEdwin::~CMIDTextBoxEdwin()
|
|
92 |
{
|
|
93 |
// just calls superclass destructor
|
|
94 |
}
|
|
95 |
|
|
96 |
CLafEdwinCustomDrawBase* CMIDTextBoxEdwin::CreateCustomDrawL()
|
|
97 |
{
|
|
98 |
// set custom drawing to the editor
|
|
99 |
const MFormCustomDraw* customDraw = CEikEdwin::CreateCustomDrawL(); // we will take ownership of the original custom draw
|
|
100 |
iCustomDraw = CMIDTextBoxEdwinCustomDraw::NewL(iEikonEnv->LafEnv(), customDraw, this);
|
|
101 |
return iCustomDraw;
|
|
102 |
}
|
|
103 |
|
|
104 |
void CMIDTextBoxEdwin::DoLayout(const TRect& aRect)
|
|
105 |
{
|
|
106 |
TAknMultiLineTextLayout layout;
|
|
107 |
|
|
108 |
/** The skin text color overrides the text color in LAF. */
|
|
109 |
TAknsQsnTextColorsIndex skinTextColor;
|
|
110 |
|
|
111 |
if (iConstraints & MMIDTextField::EUneditable)
|
|
112 |
{ // skinning colour groups for uneditable text
|
|
113 |
skinTextColor = EAknsCIQsnTextColorsCG52;
|
|
114 |
}
|
|
115 |
else
|
|
116 |
{ // skinning colour groups for editable text
|
|
117 |
skinTextColor = EAknsCIQsnTextColorsCG6;
|
|
118 |
}
|
|
119 |
|
|
120 |
// get layout
|
|
121 |
layout = GetLayout();
|
|
122 |
|
|
123 |
// layout the control
|
|
124 |
AknLayoutUtils::LayoutEdwin(this, aRect, layout, skinTextColor);
|
|
125 |
// layout the custom draw
|
|
126 |
if (iCustomDraw != NULL) // the custom draw is created by us, so if it is defined we have the right version
|
|
127 |
{
|
|
128 |
iCustomDraw->CalculateLayout(aRect);
|
|
129 |
}
|
|
130 |
}
|
|
131 |
|
|
132 |
|
|
133 |
#ifdef RD_SCALABLE_UI_V2
|
|
134 |
void CMIDTextBoxEdwin::HandlePointerEventL(const TPointerEvent &aPointerEvent)
|
|
135 |
{
|
|
136 |
if (AknLayoutUtils::PenEnabled())
|
|
137 |
{
|
|
138 |
TBool consumed = STATIC_CAST(CMIDDisplayable*, iDisplayable)->TryDetectLongTapL(aPointerEvent);
|
|
139 |
if (!consumed)
|
|
140 |
{
|
|
141 |
CEikEdwin::HandlePointerEventL(aPointerEvent);
|
|
142 |
}
|
|
143 |
}
|
|
144 |
|
|
145 |
}
|
|
146 |
#endif // RD_SCALABLE_UI_V2
|
|
147 |
|
|
148 |
|
|
149 |
TCoeInputCapabilities CMIDTextBoxEdwin::InputCapabilities() const
|
|
150 |
{
|
|
151 |
TCoeInputCapabilities inputCapabilities(TCoeInputCapabilities::ENone, NULL,
|
|
152 |
const_cast<CMIDTextBoxEdwin*>(this));
|
|
153 |
inputCapabilities.MergeWith(CMIDEdwin::InputCapabilities());
|
|
154 |
return inputCapabilities;
|
|
155 |
}
|
|
156 |
|
|
157 |
|
|
158 |
void CMIDTextBoxEdwin::GetCaptionForFep(TDes& aCaption) const
|
|
159 |
{
|
|
160 |
ASSERT(iDisplayable);
|
|
161 |
HBufC* title = static_cast<CMIDDisplayable*>(iDisplayable)->Title();
|
|
162 |
|
|
163 |
if (title)
|
|
164 |
{
|
|
165 |
const TInt maximumLength = aCaption.MaxLength();
|
|
166 |
if (title->Length() > maximumLength)
|
|
167 |
{
|
|
168 |
aCaption = title->Left(maximumLength);
|
|
169 |
}
|
|
170 |
else
|
|
171 |
{
|
|
172 |
aCaption = *title;
|
|
173 |
}
|
|
174 |
}
|
|
175 |
else
|
|
176 |
{
|
|
177 |
aCaption = KNullDesC;
|
|
178 |
}
|
|
179 |
}
|
|
180 |
|
|
181 |
|
|
182 |
void CMIDTextBoxEdwin::AddCommandToEdwinL(MMIDCommand& aCommand)
|
|
183 |
{
|
|
184 |
STATIC_CAST(CMIDDisplayable*, iDisplayable)->AddCommandL(&aCommand);
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------
|
|
188 |
// CMIDTextBoxEdwin::GetCustomDraw()
|
|
189 |
// ---------------------------------------------------------
|
|
190 |
//
|
|
191 |
CMIDTextBoxEdwinCustomDraw* CMIDTextBoxEdwin::GetCustomDraw() const
|
|
192 |
{
|
|
193 |
return iCustomDraw;
|
|
194 |
}
|
|
195 |
|