|
1 /* |
|
2 * Copyright (c) 2002-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: 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 // Create region buffer. |
|
58 iRegBuf = new ( ELeave ) RRegionBuf< KUssdMaxNumberOfEditorLines >; |
|
59 |
|
60 // Create rects |
|
61 |
|
62 iRects = new ( ELeave ) CArrayPtrFlat<TAknLayoutRect>( KUssdMaxNumberOfEditorLines ); |
|
63 iRects->SetReserveL( KUssdMaxNumberOfEditorLines ); |
|
64 |
|
65 TAknLayoutRect* rect = NULL; |
|
66 for ( TInt i = 0 ; i < KUssdMaxNumberOfEditorLines ; i++ ) |
|
67 { |
|
68 rect = new ( ELeave ) TAknLayoutRect; |
|
69 iRects->InsertL( i , rect ); // Can't leave |
|
70 } |
|
71 |
|
72 SetRect( aParent->Rect() ); |
|
73 SetFocus( ETrue ); |
|
74 |
|
75 // activate control |
|
76 ActivateL(); |
|
77 } |
|
78 |
|
79 |
|
80 // Destructor |
|
81 CUssdEditorLines::~CUssdEditorLines() |
|
82 { |
|
83 if ( iRects ) |
|
84 { |
|
85 iRects->ResetAndDestroy() ; |
|
86 delete iRects; |
|
87 } |
|
88 |
|
89 if ( iRegBuf ) |
|
90 { |
|
91 iRegBuf->Close() ; |
|
92 delete iRegBuf; |
|
93 } |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CUssdEditorLines::SizeChanged |
|
99 // Called by framework when the view size is changed |
|
100 // |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CUssdEditorLines::SizeChanged() |
|
104 { |
|
105 // Move rectangles to right position |
|
106 |
|
107 for ( TInt i = 0; |
|
108 iRects && i < iRects->Count() && i < UssdLayout::NumberOfEditorLines(); |
|
109 i++ ) |
|
110 { |
|
111 iRects->At( i )->LayoutRect( Rect() , |
|
112 UssdLayout::MessageWritingLayoutElements6( i+1 ) ); |
|
113 } |
|
114 } |
|
115 |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CUssdEditorLines::Draw |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CUssdEditorLines::Draw( const TRect& aRect ) const |
|
123 { |
|
124 // Take the colour from some ramdom line. |
|
125 // Here it is takem from the first line. |
|
126 |
|
127 TRgb lineColour( KRgbWhite ); |
|
128 |
|
129 if ( iRects->Count() ) |
|
130 { |
|
131 lineColour = iRects->At( 0 )->Color(); |
|
132 } |
|
133 |
|
134 // Get skin colour if set. |
|
135 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
136 TRgb skinColor; |
|
137 TInt error = |
|
138 AknsUtils::GetCachedColor( |
|
139 skin, |
|
140 skinColor, |
|
141 KAknsIIDQsnLineColors, |
|
142 EAknsCIQsnLineColorsCG6 ); |
|
143 |
|
144 if ( error == KErrNone ) |
|
145 { |
|
146 lineColour = skinColor; |
|
147 } |
|
148 CWindowGc& gc = SystemGc(); |
|
149 gc.SetBrushColor( lineColour ); |
|
150 |
|
151 // Draw row lines by clearing rectangles corresponding to row locations. |
|
152 TInt count( iRects->Count() ); |
|
153 TInt lines( UssdLayout::NumberOfEditorLines() ); |
|
154 for ( TInt i = 0; iRects && i < count && i < lines; i++ ) |
|
155 { |
|
156 gc.Clear( iRects->At( i )->Rect() ); |
|
157 } |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CUssdEditorLines::HandlePointerEventL |
|
162 // |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CUssdEditorLines::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
166 { |
|
167 // Temporary variant for text editor. |
|
168 CCoeControl *editor( Parent() ? Parent()->ComponentControl( 0 ) : NULL ); |
|
169 // Redirect pointer event to CEikEdwin, so as that CEikEdwin can popup |
|
170 // virtual keyboard when user gives a click input. |
|
171 if ( editor ) |
|
172 { |
|
173 editor->HandlePointerEventL( aPointerEvent ); |
|
174 } |
|
175 } |
|
176 // End of File |