25
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2010 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: Declares window owning control for editor lines.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <AknsDrawUtils.h>
|
|
21 |
#include <eikenv.h>
|
|
22 |
|
|
23 |
#include "UssdEditorLines.h"
|
|
24 |
#include "UssdLayout.h"
|
|
25 |
|
|
26 |
// CONSTANTS
|
|
27 |
|
|
28 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
29 |
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
// CUssdEditorLines::CUssdEditorLines
|
|
32 |
// C++ default constructor can NOT contain any code, that
|
|
33 |
// might leave.
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
CUssdEditorLines::CUssdEditorLines()
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
// CUssdEditorLines::ConstructL
|
|
43 |
// Symbian 2nd phase constructor can leave.
|
|
44 |
//
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
void CUssdEditorLines::ConstructL( const CCoeControl* aParent )
|
|
48 |
{
|
|
49 |
// Create an own window
|
|
50 |
CreateWindowL( aParent );
|
|
51 |
|
|
52 |
// This window draws editor row lines, so enable window
|
|
53 |
// transparency to display the editor window content as background
|
|
54 |
// for this line-window.
|
|
55 |
EnableWindowTransparency();
|
|
56 |
|
|
57 |
// enabled drag event to editor for highlighting the text.
|
|
58 |
EnableDragEvents();
|
|
59 |
|
|
60 |
// Create region buffer.
|
|
61 |
iRegBuf = new ( ELeave ) RRegionBuf< KUssdMaxNumberOfEditorLines >;
|
|
62 |
|
|
63 |
// Create rects
|
|
64 |
|
|
65 |
iRects = new ( ELeave ) CArrayPtrFlat<TAknLayoutRect>( KUssdMaxNumberOfEditorLines );
|
|
66 |
iRects->SetReserveL( KUssdMaxNumberOfEditorLines );
|
|
67 |
|
|
68 |
TAknLayoutRect* rect = NULL;
|
|
69 |
for ( TInt i = 0 ; i < KUssdMaxNumberOfEditorLines ; i++ )
|
|
70 |
{
|
|
71 |
rect = new ( ELeave ) TAknLayoutRect;
|
|
72 |
iRects->InsertL( i , rect ); // Can't leave
|
|
73 |
}
|
|
74 |
|
|
75 |
SetRect( aParent->Rect() );
|
|
76 |
SetFocus( ETrue );
|
|
77 |
|
|
78 |
// activate control
|
|
79 |
ActivateL();
|
|
80 |
}
|
|
81 |
|
|
82 |
|
|
83 |
// Destructor
|
|
84 |
CUssdEditorLines::~CUssdEditorLines()
|
|
85 |
{
|
|
86 |
if ( iRects )
|
|
87 |
{
|
|
88 |
iRects->ResetAndDestroy() ;
|
|
89 |
delete iRects;
|
|
90 |
}
|
|
91 |
|
|
92 |
if ( iRegBuf )
|
|
93 |
{
|
|
94 |
iRegBuf->Close() ;
|
|
95 |
delete iRegBuf;
|
|
96 |
}
|
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
// -----------------------------------------------------------------------------
|
|
101 |
// CUssdEditorLines::SizeChanged
|
|
102 |
// Called by framework when the view size is changed
|
|
103 |
//
|
|
104 |
// -----------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CUssdEditorLines::SizeChanged()
|
|
107 |
{
|
|
108 |
// Move rectangles to right position
|
|
109 |
|
|
110 |
for ( TInt i = 0;
|
|
111 |
iRects && i < iRects->Count() && i < UssdLayout::NumberOfEditorLines();
|
|
112 |
i++ )
|
|
113 |
{
|
|
114 |
iRects->At( i )->LayoutRect( Rect() ,
|
|
115 |
UssdLayout::MessageWritingLayoutElements6( i+1 ) );
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
// CUssdEditorLines::Draw
|
|
122 |
//
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
void CUssdEditorLines::Draw( const TRect& /*aRect*/ ) const
|
|
126 |
{
|
|
127 |
// Take the colour from some ramdom line.
|
|
128 |
// Here it is taken from the first line.
|
|
129 |
|
|
130 |
TRgb lineColour( KRgbWhite );
|
|
131 |
|
|
132 |
if ( iRects->Count() )
|
|
133 |
{
|
|
134 |
lineColour = iRects->At( 0 )->Color();
|
|
135 |
}
|
|
136 |
|
|
137 |
// Get skin colour if set.
|
|
138 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
139 |
TRgb skinColor;
|
|
140 |
TInt error =
|
|
141 |
AknsUtils::GetCachedColor(
|
|
142 |
skin,
|
|
143 |
skinColor,
|
|
144 |
KAknsIIDQsnLineColors,
|
|
145 |
EAknsCIQsnLineColorsCG6 );
|
|
146 |
|
|
147 |
if ( error == KErrNone )
|
|
148 |
{
|
|
149 |
lineColour = skinColor;
|
|
150 |
}
|
|
151 |
CWindowGc& gc = SystemGc();
|
|
152 |
gc.SetBrushColor( lineColour );
|
|
153 |
|
|
154 |
// Draw row lines by clearing rectangles corresponding to row locations.
|
|
155 |
TInt count( iRects->Count() );
|
|
156 |
TInt lines( UssdLayout::NumberOfEditorLines() );
|
|
157 |
for ( TInt i = 0; iRects && i < count && i < lines; i++ )
|
|
158 |
{
|
|
159 |
gc.Clear( iRects->At( i )->Rect() );
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
// -----------------------------------------------------------------------------
|
|
164 |
// CUssdEditorLines::HandlePointerEventL
|
|
165 |
//
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void CUssdEditorLines::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
169 |
{
|
|
170 |
// Temporary variant for text editor.
|
|
171 |
CCoeControl *editor( Parent() ? Parent()->ComponentControl( 0 ) : NULL );
|
|
172 |
// Redirect pointer event to CEikEdwin, so as that CEikEdwin can popup
|
|
173 |
// virtual keyboard when user gives a click input.
|
|
174 |
if ( editor )
|
|
175 |
{
|
|
176 |
editor->HandlePointerEventL( aPointerEvent );
|
|
177 |
}
|
|
178 |
}
|
|
179 |
// End of File
|