|
1 /* |
|
2 * Copyright (c) 2002 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 of paper lines of Notepad/Template Editor. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <AknUtils.h> |
|
21 #include <barsread.h> |
|
22 #include <applayout.cdl.h> |
|
23 #include <eikrted.h> // for CRichTextEditor |
|
24 #include <aknlayoutscalable_apps.cdl.h> |
|
25 #include <aknappui.h> |
|
26 #include <eikdialg.h> |
|
27 #include <AknsFrameBackgroundControlContext.h> |
|
28 #include <skinlayout.cdl.h> |
|
29 |
|
30 #include "NpdEdwinLines.h" |
|
31 #include "NpdEdwin.h" |
|
32 #include "NpdLibPanic.h" |
|
33 |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CNotepadEdwinLines::CNotepadEdwinLines |
|
39 // public Constructor |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CNotepadEdwinLines::CNotepadEdwinLines(CEikDialog* aParent) |
|
43 : CCoeControl(),iParent(aParent),iBgContext(NULL) |
|
44 { |
|
45 |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CNotepadEdwinLines::~CNotepadEdwinLines |
|
50 // Destructor |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CNotepadEdwinLines::~CNotepadEdwinLines() |
|
54 { |
|
55 iRects.Close(); |
|
56 if(iBgContext != NULL) |
|
57 { |
|
58 delete iBgContext; |
|
59 iBgContext = NULL; |
|
60 } |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CNotepadEdwinLines::AddRectsAndLayout |
|
65 // from CNotepadEdwinLines (called from SizeChanged) |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CNotepadEdwinLines::AddRectsAndLayout(RRegion& aRegion) |
|
69 { |
|
70 TAknLayoutRect mainNotesPane; |
|
71 TAknLayoutRect lineLayout; |
|
72 TAknLayoutRect line; |
|
73 TAknLayoutScalableParameterLimits textLimits ; |
|
74 |
|
75 TRect tempMainPane; |
|
76 TRect statusPane; |
|
77 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,tempMainPane); |
|
78 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,statusPane); |
|
79 TRect mainPane(TPoint(0, 0), tempMainPane.Size()); |
|
80 mainNotesPane.LayoutRect(mainPane, AknLayoutScalable_Apps::main_notes_pane().LayoutLine()); |
|
81 lineLayout.LayoutRect(mainNotesPane.Rect(),AknLayoutScalable_Apps::list_notes_pane().LayoutLine()); |
|
82 textLimits = AknLayoutScalable_Apps::list_notes_text_pane_ParamLimits(); |
|
83 |
|
84 TInt lineCount = textLimits.LastRow() - textLimits.FirstRow() + 1; |
|
85 |
|
86 // The array iRects should be reset, when there is a change |
|
87 // in the no of lines after a layout switch |
|
88 |
|
89 if ( iRects.Count() != lineCount ) |
|
90 { |
|
91 iRects.Reset(); |
|
92 for (TInt j(textLimits.FirstRow()); j <= textLimits.LastRow(); j++) |
|
93 { |
|
94 iRects.Append( TAknLayoutRect() ); |
|
95 } |
|
96 } |
|
97 |
|
98 for ( TInt i(textLimits.FirstRow()); i <= textLimits.LastRow(); i++ ) |
|
99 { |
|
100 line.LayoutRect(lineLayout.Rect(),AknLayoutScalable_Apps::list_notes_text_pane(i).LayoutLine()); |
|
101 iRects[i].LayoutRect(line.Rect() ,AknLayoutScalable_Apps::list_notes_text_pane_g1().LayoutLine()); |
|
102 aRegion.AddRect(iRects[i].Rect()); |
|
103 } |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CNotepadEdwinLines::ConstructFromResourceL |
|
108 // from CCoeControl |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CNotepadEdwinLines::ConstructFromResourceL(TResourceReader& /*aReader*/) |
|
112 { |
|
113 TAknLayoutScalableParameterLimits textLimits ; |
|
114 |
|
115 TInt ignor; |
|
116 TRAP(ignor, |
|
117 iBgContext = CAknsFrameBackgroundControlContext::NewL( |
|
118 KAknsIIDQsnFrNotepad, |
|
119 TRect(0,0,0,0), |
|
120 TRect(0,0,0,0), |
|
121 EFalse ); |
|
122 ); |
|
123 ignor = KErrNone; |
|
124 textLimits = AknLayoutScalable_Apps::list_notes_text_pane_ParamLimits(); |
|
125 for (TInt i(textLimits.FirstRow()); i <= textLimits.LastRow(); i++) |
|
126 { |
|
127 User::LeaveIfError(iRects.Append(TAknLayoutRect())); |
|
128 } |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CNotepadEdwinLines::Draw |
|
133 // from CCoeControl |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CNotepadEdwinLines::Draw(const TRect& /*aRect*/) const |
|
137 { |
|
138 CWindowGc& gc = SystemGc(); |
|
139 for(TInt i(iRects.Count() - 1); i >= 0; i--) |
|
140 { |
|
141 iRects[i].DrawRect(gc); |
|
142 } |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------- |
|
146 // CNotepadEdwinLines::MopSupplyObject(TTypeUid aId) |
|
147 // Handles a change to the control's resources. |
|
148 // --------------------------------------------------------- |
|
149 // |
|
150 TTypeUid::Ptr CNotepadEdwinLines::MopSupplyObject(TTypeUid aId) |
|
151 { |
|
152 if((aId.iUid == MAknsControlContext::ETypeId) && (iBgContext != NULL)) |
|
153 { |
|
154 return MAknsControlContext::SupplyMopObject(aId, iBgContext); |
|
155 } |
|
156 return CCoeControl::MopSupplyObject(aId); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------- |
|
160 // CNotepadEdwinLines::HandleResourceChange(TInt aType) |
|
161 // Handles a change to the control's resources. |
|
162 // --------------------------------------------------------- |
|
163 // |
|
164 void CNotepadEdwinLines::HandleResourceChange(TInt aType) |
|
165 { |
|
166 if(aType == KAknsMessageSkinChange) |
|
167 { |
|
168 if(iBgContext) |
|
169 { |
|
170 delete iBgContext; |
|
171 iBgContext = NULL; |
|
172 } |
|
173 |
|
174 TInt ignor; |
|
175 TRAP(ignor, |
|
176 iBgContext = CAknsFrameBackgroundControlContext::NewL( |
|
177 KAknsIIDQsnFrNotepad, |
|
178 TRect(0,0,0,0), |
|
179 TRect(0,0,0,0), |
|
180 EFalse ); |
|
181 ); |
|
182 ignor = KErrNone; |
|
183 SizeChanged(); |
|
184 DrawDeferred(); |
|
185 } |
|
186 } |
|
187 |
|
188 void CNotepadEdwinLines::SizeChanged() |
|
189 { |
|
190 TRect rect( iParent->Rect() ); |
|
191 RRegion region; |
|
192 AddRectsAndLayout(region); |
|
193 Window().SetShape(region); |
|
194 region.Close(); |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CNotepadEdwinLines::SetContainerWindowL |
|
199 // cf. CEikEdwin::SetContainerWindowL. |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void CNotepadEdwinLines::SetContainerWindowL(const CCoeControl& aContainer) |
|
203 { |
|
204 if ( !OwnsWindow() ) |
|
205 { |
|
206 CreateWindowL(&aContainer); // include SetMopParent |
|
207 } |
|
208 else |
|
209 { |
|
210 CCoeControl::SetContainerWindowL(aContainer); |
|
211 } |
|
212 } |
|
213 // End of File |