|
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: The OutputSheet sub-pane class, CCalcOutputSheet. |
|
15 * Derived from CCoeControl. |
|
16 * The CCalcOutputSheet displays histroy data. |
|
17 * History data is scroll up and down. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <AknUtils.h> |
|
25 #include <Calcsoft.rsg> |
|
26 #include <applayout.cdl.h> |
|
27 #include <AknsDrawUtils.h> |
|
28 #include <layoutmetadata.cdl.h> |
|
29 #include "CalcEnv.h" |
|
30 #include "CalcCont.h" |
|
31 #include "CalcOutSheet.h" |
|
32 #include "CalcDoc.h" |
|
33 #include "CalcEditline.h" |
|
34 #include "CalcAppUi.h" |
|
35 #include "CalcHistory.h" |
|
36 #include "CalcDrawingConst.laf" |
|
37 #include "fbs.h" |
|
38 #include <AknIconUtils.h> |
|
39 #include <aknlayoutscalable_apps.cdl.h> |
|
40 #include <AknsBasicBackgroundControlContext.h> |
|
41 #include <AknFepInternalCRKeys.h> |
|
42 |
|
43 |
|
44 #include <eiksbfrm.h> |
|
45 #include <eikscrlb.h> |
|
46 |
|
47 // LOCAL CONSTANTS AND MACROS |
|
48 |
|
49 // ================= MEMBER FUNCTIONS ======================= |
|
50 |
|
51 // Two-phased constructor. |
|
52 CCalcOutputSheet* CCalcOutputSheet::NewL( |
|
53 CCalcContainer* aContainer) |
|
54 { |
|
55 CCalcOutputSheet* self = new (ELeave) CCalcOutputSheet(); |
|
56 CleanupStack::PushL(self); |
|
57 self->ConstructL(aContainer); |
|
58 CleanupStack::Pop(self); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // Destructor |
|
63 CCalcOutputSheet::~CCalcOutputSheet() |
|
64 { |
|
65 delete iOpSheetContext; |
|
66 if(iOperatorLayout) |
|
67 { |
|
68 iOperatorLayout->Reset(); |
|
69 delete iOperatorLayout; |
|
70 } |
|
71 if(iOperandLayout) |
|
72 { |
|
73 iOperandLayout->Reset(); |
|
74 delete iOperandLayout; |
|
75 } |
|
76 if(iEqualLineLayout) |
|
77 { |
|
78 iEqualLineLayout->Reset(); |
|
79 delete iEqualLineLayout; |
|
80 } |
|
81 if(iResultsLineLayout) |
|
82 { |
|
83 iResultsLineLayout->Reset(); |
|
84 delete iResultsLineLayout; |
|
85 } |
|
86 if (iCRKey) |
|
87 { |
|
88 delete iCRKey; |
|
89 iCRKey = NULL; |
|
90 } |
|
91 |
|
92 //Delete the scrollbar frame |
|
93 if(iSBFrame) |
|
94 { |
|
95 delete iSBFrame; |
|
96 iSBFrame = NULL; |
|
97 } |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------- |
|
101 // CCalcOutputSheet::ScrollToBottomL |
|
102 // Scroll to bottom line. |
|
103 // (other items were commented in a header). |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 void CCalcOutputSheet::ScrollToBottomL() |
|
107 { |
|
108 iScrollOffset = 0; |
|
109 |
|
110 //If scrollbar is present, update the scrollbar as well |
|
111 if( AknLayoutUtils::PenEnabled() ) |
|
112 { |
|
113 UpdateScrollIndicatorL(); |
|
114 } |
|
115 DrawNow(); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------- |
|
119 // CCalcOutputSheet::NotifyClearHistory |
|
120 // Called after clearing calculation history. |
|
121 // (other items were commented in a header). |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 void CCalcOutputSheet::NotifyClearHistoryL() |
|
125 { |
|
126 iScrollOffset = 0; |
|
127 if( AknLayoutUtils::PenEnabled() ) |
|
128 { |
|
129 UpdateScrollIndicatorL(); |
|
130 } |
|
131 DrawNow(); |
|
132 } |
|
133 |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // CCalcOutputSheet::CanUp |
|
137 // Check whether scroll-up can be done or not. |
|
138 // (other items were commented in a header). |
|
139 // --------------------------------------------------------- |
|
140 // |
|
141 TBool CCalcOutputSheet::CanUp() const |
|
142 { |
|
143 // The number of lines of the history which a document has is got. |
|
144 TInt historyLine(iCalcHistory->Count()); |
|
145 if ( (iCalcOutputSheetLines + iScrollOffset) < historyLine ) |
|
146 { |
|
147 return ETrue; |
|
148 } |
|
149 return EFalse; |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CCalcOutputSheet::CanDown |
|
154 // Check whether scroll-down can be done or not. |
|
155 // (other items were commented in a header). |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 TBool CCalcOutputSheet::CanDown() const |
|
159 { |
|
160 // The number of lines of the history which a document has is got. |
|
161 return (iScrollOffset != 0); |
|
162 } |
|
163 |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CCalcOutputSheet::ScrollUp |
|
167 // history is scrolled up. |
|
168 // (other items were commented in a header). |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 void CCalcOutputSheet::ScrollUp() |
|
172 { |
|
173 |
|
174 if (CanUp()) |
|
175 { |
|
176 iScrollOffset++; |
|
177 DrawNow(); |
|
178 } |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------- |
|
182 // CCalcOutputSheet::ScrollDown |
|
183 // history is scrolled down. |
|
184 // (other items were commented in a header). |
|
185 // --------------------------------------------------------- |
|
186 // |
|
187 void CCalcOutputSheet::ScrollDown() |
|
188 { |
|
189 |
|
190 if (CanDown()) |
|
191 { |
|
192 iScrollOffset--; |
|
193 DrawNow(); |
|
194 } |
|
195 } |
|
196 |
|
197 // C++ default constructor can NOT contain any code, that |
|
198 // might leave. |
|
199 // |
|
200 CCalcOutputSheet::CCalcOutputSheet() |
|
201 { |
|
202 } |
|
203 |
|
204 // default constructor can leave. |
|
205 void CCalcOutputSheet::ConstructL |
|
206 (CCalcContainer* aContainer) |
|
207 |
|
208 { |
|
209 SetContainerWindowL(*aContainer); |
|
210 |
|
211 iCalcContainer = aContainer; |
|
212 |
|
213 iCalcAppEnv = CCalcAppEnv::Static(); |
|
214 iCalcPaper = iCalcAppEnv->PaperBitmap(); |
|
215 iCalcAppEnv->ScalablePaperBitmaps(iCalcScalablePaper); |
|
216 #ifdef __SCALABLE_ICONS |
|
217 iCalcResultsLine = iCalcAppEnv->ResultsLineBitmap(); |
|
218 #endif |
|
219 |
|
220 CCalcAppUi* appui = iCalcAppEnv->AppUi(); |
|
221 CCalcDocument* calcDocument = |
|
222 STATIC_CAST(CCalcDocument*, appui->Document()); |
|
223 iCalcHistory = calcDocument->History(); |
|
224 TAknLayoutScalableParameterLimits listLimits; |
|
225 listLimits = AknLayoutScalable_Apps::list_calc_item_pane_ParamLimits(); |
|
226 iCalcOutputSheetLines = (listLimits.LastRow()-listLimits.FirstRow()) + 1; |
|
227 iOpSheetContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnFrCalcPaper , TRect(0,0,0,0), EFalse); |
|
228 iOperatorLayout = new(ELeave)CArrayFixFlat<TAknLayoutText>(iCalcOutputSheetLines); |
|
229 iOperandLayout = new(ELeave)CArrayFixFlat<TAknLayoutText>(iCalcOutputSheetLines); |
|
230 iResultsLineLayout = new(ELeave)CArrayFixFlat<TAknLayoutRect>(iCalcOutputSheetLines-1); |
|
231 iEqualLineLayout = new(ELeave)CArrayFixFlat<TAknLayoutRect>(iCalcOutputSheetLines-1); |
|
232 iUiLanguage = User::Language(); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------- |
|
236 // CCalcOutputSheet::SizeChanged |
|
237 // Set size of control. |
|
238 // (other items were commented in a header). |
|
239 // --------------------------------------------------------- |
|
240 // |
|
241 void CCalcOutputSheet::SizeChanged() |
|
242 { |
|
243 TRAP_IGNORE( SizeChangedOutSheetL() ); |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------- |
|
247 // CCalcOutputSheet::SizeChanged |
|
248 // Set size of control. |
|
249 // (other items were commented in a header). |
|
250 // --------------------------------------------------------- |
|
251 // |
|
252 void CCalcOutputSheet::SizeChangedOutSheetL() |
|
253 { |
|
254 TRect parentRect(iCalcContainer->Rect()); |
|
255 |
|
256 TAknLayoutScalableParameterLimits listLimits; |
|
257 if(AknLayoutUtils::PenEnabled()) |
|
258 { |
|
259 listLimits = AknLayoutScalable_Apps::list_calc_item_pane_ParamLimits(enTouch_enabled); |
|
260 } |
|
261 else |
|
262 { |
|
263 listLimits = AknLayoutScalable_Apps::list_calc_item_pane_ParamLimits(enTouch_disabled); |
|
264 } |
|
265 iCalcOutputSheetLines = (listLimits.LastRow()-listLimits.FirstRow()) + 1; |
|
266 iOperatorLayout->ResizeL(iCalcOutputSheetLines); |
|
267 iOperandLayout->ResizeL(iCalcOutputSheetLines); |
|
268 iResultsLineLayout->ResizeL(iCalcOutputSheetLines-1); |
|
269 iEqualLineLayout->ResizeL(iCalcOutputSheetLines-1); |
|
270 |
|
271 iOperatorLayout->Reset(); |
|
272 iOperandLayout->Reset(); |
|
273 iResultsLineLayout->Reset(); |
|
274 iEqualLineLayout->Reset(); |
|
275 |
|
276 TAknLayoutRect rectParent; |
|
277 TAknWindowLineLayout layoutOfParentResultsLine; |
|
278 TAknLayoutRect rectListCalcPane; |
|
279 |
|
280 |
|
281 |
|
282 if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
283 { |
|
284 TAknWindowLineLayout calcPaperPane; |
|
285 |
|
286 //For Touch UI Layouts, different configuration |
|
287 if( AknLayoutUtils::PenEnabled() ) |
|
288 { |
|
289 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
290 { |
|
291 calcPaperPane = AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_lsc).LayoutLine(); |
|
292 } |
|
293 else |
|
294 { |
|
295 calcPaperPane = AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_prt).LayoutLine(); |
|
296 } |
|
297 } |
|
298 else |
|
299 { |
|
300 calcPaperPane = AknLayoutScalable_Apps::calc_paper_pane(enTouch_disabled).LayoutLine(); |
|
301 } |
|
302 TAknLayoutRect rectcalcPaperPane; |
|
303 rectcalcPaperPane.LayoutRect(parentRect,calcPaperPane); |
|
304 TAknWindowLineLayout layoutListCalcPane; |
|
305 if( AknLayoutUtils::PenEnabled() ) |
|
306 { |
|
307 layoutListCalcPane = AknLayoutScalable_Apps::list_calc_pane(enTouch_enabled).LayoutLine(); |
|
308 } |
|
309 else |
|
310 { |
|
311 layoutListCalcPane = AknLayoutScalable_Apps::list_calc_pane(enTouch_disabled).LayoutLine(); |
|
312 } |
|
313 |
|
314 rectListCalcPane.LayoutRect(rectcalcPaperPane.Rect(),layoutListCalcPane); |
|
315 } |
|
316 |
|
317 TInt nTimes=(iCalcOutputSheetLines-1); |
|
318 for (TInt cnt(0); cnt < iCalcOutputSheetLines; cnt++) |
|
319 { |
|
320 if (AknLayoutUtils::ScalableLayoutInterfaceAvailable()) |
|
321 { |
|
322 if(AknLayoutUtils::PenEnabled()) |
|
323 { |
|
324 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
325 { |
|
326 layoutOfParentResultsLine = AknLayoutScalable_Apps::list_calc_item_pane(nTimes,enTouch_enabled).LayoutLine(); |
|
327 } |
|
328 else |
|
329 { |
|
330 layoutOfParentResultsLine = AknLayoutScalable_Apps::list_calc_item_pane(nTimes,enTouch_enabled).LayoutLine(); |
|
331 } |
|
332 |
|
333 } |
|
334 else |
|
335 { |
|
336 layoutOfParentResultsLine = AknLayoutScalable_Apps::list_calc_item_pane(nTimes,enTouch_disabled).LayoutLine(); |
|
337 } |
|
338 |
|
339 |
|
340 rectParent.LayoutRect(rectListCalcPane.Rect(),layoutOfParentResultsLine) ; |
|
341 |
|
342 TAknLayoutText operatorLayout; |
|
343 TAknLayoutText operendLayout; |
|
344 if(AknLayoutUtils::PenEnabled()) |
|
345 { |
|
346 operatorLayout.LayoutText(rectParent.Rect(),AknLayoutScalable_Apps::list_calc_item_pane_t2(enTouch_with_prt).LayoutLine(),iCalcAppEnv->OutSheetOperatorFont()); |
|
347 iOperatorLayout->AppendL(operatorLayout); |
|
348 |
|
349 operendLayout.LayoutText(rectParent.Rect(),AknLayoutScalable_Apps::list_calc_item_pane_t1(enTouch_with_lsc).LayoutLine(),iCalcAppEnv->OutSheetOperatorFont()); |
|
350 iOperandLayout->AppendL(operendLayout); |
|
351 } |
|
352 else |
|
353 { |
|
354 operatorLayout.LayoutText(rectParent.Rect(),AknLayoutScalable_Apps::list_calc_item_pane_t2(enTouch_disabled).LayoutLine(),iCalcAppEnv->OutSheetOperatorFont()); |
|
355 iOperatorLayout->AppendL(operatorLayout); |
|
356 |
|
357 operendLayout.LayoutText(rectParent.Rect(),AknLayoutScalable_Apps::list_calc_item_pane_t1(enTouch_disabled).LayoutLine(),iCalcAppEnv->OutSheetOperatorFont()); |
|
358 iOperandLayout->AppendL(operendLayout); |
|
359 } |
|
360 |
|
361 // aCustomFont |
|
362 --nTimes; |
|
363 |
|
364 } |
|
365 |
|
366 else |
|
367 { |
|
368 |
|
369 |
|
370 //Scalable UI. |
|
371 |
|
372 TAknLayoutText operatorLayout; |
|
373 TAknLayoutText operendLayout; |
|
374 operatorLayout.LayoutText(parentRect,AppLayout::Calculator_texts_Line_8(nTimes),iCalcAppEnv->OutSheetOperatorFont()); // aCustomFont |
|
375 iOperatorLayout->AppendL(operatorLayout); |
|
376 |
|
377 operendLayout.LayoutText(parentRect,AppLayout::Calculator_texts_Line_7(nTimes), NULL); |
|
378 iOperandLayout->AppendL(operendLayout); |
|
379 --nTimes; |
|
380 } |
|
381 } |
|
382 |
|
383 //Scalable UI. |
|
384 nTimes = iCalcOutputSheetLines - 2; |
|
385 for (TInt ii(0); ii < (iCalcOutputSheetLines - 1); ii++) |
|
386 { |
|
387 |
|
388 |
|
389 if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
390 { |
|
391 #ifdef __SCALABLE_ICONS |
|
392 layoutOfParentResultsLine = AknLayoutScalable_Apps::list_calc_item_pane(nTimes).LayoutLine(); |
|
393 |
|
394 rectParent.LayoutRect(rectListCalcPane.Rect(),layoutOfParentResultsLine) ; |
|
395 TAknWindowLineLayout layoutOfResultsLine = AknLayoutScalable_Apps::list_calc_item_pane_g1().LayoutLine(); |
|
396 TAknLayoutRect lineLayout; |
|
397 lineLayout.LayoutRect(rectParent.Rect(),layoutOfResultsLine); |
|
398 iResultsLineLayout->AppendL(lineLayout); |
|
399 #else |
|
400 TAknLayoutRect lineLayout; |
|
401 lineLayout.LayoutRect(parentRect,AppLayout::Calculator_elements_Line_3(nTimes)); |
|
402 iEqualLineLayout->AppendL(lineLayout); |
|
403 #endif |
|
404 } |
|
405 else |
|
406 { |
|
407 TAknLayoutRect lineLayout; |
|
408 lineLayout.LayoutRect(parentRect,AppLayout::Calculator_elements_Line_3(nTimes)); |
|
409 iEqualLineLayout->AppendL(lineLayout); |
|
410 } |
|
411 |
|
412 --nTimes; |
|
413 } |
|
414 |
|
415 TAknLayoutRect paperRect; |
|
416 if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
417 { |
|
418 TAknLayoutRect rectCalcPaperPane; |
|
419 TAknLayoutRect rectbgCalcPaperPane; |
|
420 //Different configuration for Touch Layouts |
|
421 if( AknLayoutUtils::PenEnabled() ) |
|
422 { |
|
423 //In landscape mode different configuration is needed |
|
424 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
425 { |
|
426 rectCalcPaperPane.LayoutRect(parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_lsc).LayoutLine()); |
|
427 } |
|
428 else |
|
429 { |
|
430 rectCalcPaperPane.LayoutRect(parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_prt).LayoutLine()); |
|
431 } |
|
432 rectbgCalcPaperPane.LayoutRect(rectCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane(enTouch_enabled).LayoutLine()); |
|
433 } |
|
434 else |
|
435 { |
|
436 rectCalcPaperPane.LayoutRect(parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_disabled).LayoutLine()); |
|
437 rectbgCalcPaperPane.LayoutRect(rectCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane().LayoutLine()); |
|
438 } |
|
439 |
|
440 iPaperPaneRect = rectCalcPaperPane; |
|
441 |
|
442 |
|
443 iCalcPaperLayout[0].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g1().LayoutLine()); |
|
444 iCalcPaperLayout[1].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g2().LayoutLine()); |
|
445 iCalcPaperLayout[2].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g3().LayoutLine()); |
|
446 iCalcPaperLayout[3].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g4().LayoutLine()); |
|
447 iCalcPaperLayout[4].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g5().LayoutLine()); |
|
448 iCalcPaperLayout[5].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g6().LayoutLine()); |
|
449 iCalcPaperLayout[6].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g7().LayoutLine()); |
|
450 iCalcPaperLayout[7].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g8().LayoutLine()); |
|
451 iCalcPaperLayout[8].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::calc_bg_paper_pane_g9().LayoutLine()); |
|
452 } |
|
453 |
|
454 iOpSheetContext->SetRect(Rect()); |
|
455 |
|
456 //Only for touch UI, scrollbars are present |
|
457 if( AknLayoutUtils::PenEnabled() ) |
|
458 { |
|
459 UpdateScrollIndicatorL(); |
|
460 } |
|
461 else |
|
462 { |
|
463 if(iSBFrame) |
|
464 { |
|
465 delete(iSBFrame); |
|
466 iSBFrame = NULL; |
|
467 } |
|
468 |
|
469 } |
|
470 |
|
471 } |
|
472 |
|
473 |
|
474 // --------------------------------------------------------- |
|
475 // CCalcOutputSheet::UpdateScrollIndicatorL |
|
476 // Creates and updates the scrollbar |
|
477 // (other items were commented in a header). |
|
478 // --------------------------------------------------------- |
|
479 void CCalcOutputSheet::UpdateScrollIndicatorL() |
|
480 { |
|
481 |
|
482 if( !AknLayoutUtils::PenEnabled() ) |
|
483 { |
|
484 return; |
|
485 } |
|
486 |
|
487 TAknLayoutRect rectCalcScrollPane; |
|
488 |
|
489 //Get the layout information for the scrollbar |
|
490 if( AknLayoutUtils::PenEnabled() ) |
|
491 { |
|
492 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
493 { |
|
494 rectCalcScrollPane.LayoutRect(iPaperPaneRect.Rect(),AknLayoutScalable_Apps::scroll_pane_cp024().LayoutLine()); |
|
495 } |
|
496 else |
|
497 { |
|
498 rectCalcScrollPane.LayoutRect(iPaperPaneRect.Rect(),AknLayoutScalable_Apps::scroll_pane_cp024().LayoutLine()); |
|
499 } |
|
500 |
|
501 } |
|
502 //Create scrollbar if not created already |
|
503 if ( !iSBFrame ) |
|
504 { |
|
505 //Make this class as the observer class as well |
|
506 iSBFrame = new( ELeave ) CEikScrollBarFrame( this,this, ETrue ); |
|
507 |
|
508 // Decide which type of scrollbar is to be shown |
|
509 CAknAppUi* appUi = iAvkonAppUi; |
|
510 if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan) |
|
511 { |
|
512 // For EDoubleSpan type scrollbar |
|
513 iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse); // non-window owning scrollbar |
|
514 iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan); |
|
515 } |
|
516 else |
|
517 { |
|
518 // For EArrowHead type scrollbar |
|
519 iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EArrowHead); |
|
520 } |
|
521 iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
522 } |
|
523 |
|
524 TEikScrollBarModel hSbarModel; |
|
525 TEikScrollBarModel vSbarModel; |
|
526 |
|
527 //By default span is one if only one page is present |
|
528 if(iCalcHistory->Count() < iCalcOutputSheetLines) |
|
529 { |
|
530 vSbarModel.iScrollSpan = 1; |
|
531 vSbarModel.iThumbPosition = 0; |
|
532 |
|
533 } |
|
534 else |
|
535 { |
|
536 //span calculator if no of lines exceeds one page |
|
537 vSbarModel.iScrollSpan = 1 + iCalcHistory->Count() - iCalcOutputSheetLines; |
|
538 } |
|
539 |
|
540 iPrevThumbPosition = vSbarModel.iThumbPosition = vSbarModel.iScrollSpan - 1; |
|
541 vSbarModel.iThumbSpan = 1; |
|
542 |
|
543 TRect clientRect( iAvkonAppUi->ClientRect() ); |
|
544 TRect rec(rectCalcScrollPane.Rect()); |
|
545 |
|
546 TEikScrollBarFrameLayout layout; |
|
547 layout.iTilingMode = TEikScrollBarFrameLayout::EInclusiveRectConstant; |
|
548 |
|
549 if (iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan) |
|
550 { |
|
551 // For EDoubleSpan type scrollbar |
|
552 if (vSbarModel.iThumbPosition + vSbarModel.iThumbSpan > vSbarModel.iScrollSpan) |
|
553 { |
|
554 // Not let scrollbar values overflow |
|
555 vSbarModel.iThumbPosition = vSbarModel.iScrollSpan - vSbarModel.iThumbSpan; |
|
556 } |
|
557 |
|
558 TAknDoubleSpanScrollBarModel hDsSbarModel(hSbarModel); |
|
559 TAknDoubleSpanScrollBarModel vDsSbarModel(vSbarModel); |
|
560 |
|
561 iSBFrame->TileL(&hDsSbarModel, &vDsSbarModel, clientRect, rec, layout); |
|
562 iSBFrame->SetVFocusPosToThumbPos(vDsSbarModel.FocusPosition()); |
|
563 } |
|
564 else |
|
565 { |
|
566 iSBFrame->TileL( &hSbarModel, &vSbarModel, clientRect, rec, layout ); |
|
567 iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition ); |
|
568 } |
|
569 } |
|
570 |
|
571 |
|
572 // --------------------------------------------------------- |
|
573 // CCalcOutputSheet::Draw |
|
574 // Drawing frame and history. |
|
575 // (other items were commented in a header). |
|
576 // --------------------------------------------------------- |
|
577 // |
|
578 void CCalcOutputSheet::Draw |
|
579 (const TRect& aRect) const |
|
580 { |
|
581 |
|
582 CWindowGc& gc = SystemGc(); |
|
583 gc.Clear(aRect); |
|
584 gc.SetClippingRect(aRect); |
|
585 TRect rect(Rect()); |
|
586 |
|
587 |
|
588 |
|
589 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
590 |
|
591 AknsDrawUtils::Background( AknsUtils:: SkinInstance(), AknsDrawUtils::ControlContext(this), this, gc, rect ); |
|
592 |
|
593 |
|
594 gc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
595 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
596 //set the size of the bitmap. SVG-T upgrade. |
|
597 CAknsItemData* idata = NULL; |
|
598 if (skin) |
|
599 { |
|
600 idata = skin->GetCachedItemData( KAknsIIDQsnFrCalcPaper); |
|
601 } |
|
602 |
|
603 if ( idata && idata->Type() == EAknsITImageTable ) |
|
604 { |
|
605 if ( AknLayoutUtils::PenEnabled() ) |
|
606 {//when touch input,the paper become bigger,so it needs only one paper |
|
607 AknIconUtils::SetSize(iCalcScalablePaper[0]->Bitmap(),iCalcPaperLayout[0].Rect().Size(),EAspectRatioNotPreserved); |
|
608 AknIconUtils::SetSize(iCalcScalablePaper[0]->Mask(),iCalcPaperLayout[0].Rect().Size(),EAspectRatioNotPreserved); |
|
609 iCalcPaperLayout[0].DrawImage(gc, iCalcScalablePaper[0]->Bitmap(),iCalcScalablePaper[0]->Mask()); |
|
610 } |
|
611 else |
|
612 { |
|
613 for(TInt Cnt=0;Cnt < 9; Cnt++) |
|
614 { |
|
615 AknIconUtils::SetSize(iCalcScalablePaper[Cnt]->Bitmap(),iCalcPaperLayout[Cnt].Rect().Size(),EAspectRatioNotPreserved); |
|
616 AknIconUtils::SetSize(iCalcScalablePaper[Cnt]->Mask(),iCalcPaperLayout[Cnt].Rect().Size(),EAspectRatioNotPreserved); |
|
617 iCalcPaperLayout[Cnt].DrawImage(gc, iCalcScalablePaper[Cnt]->Bitmap(),iCalcScalablePaper[Cnt]->Mask()); |
|
618 } |
|
619 } |
|
620 } |
|
621 else |
|
622 { |
|
623 // Make outsheet displayed in Jingmask is the same size as in other themes |
|
624 // when there is a scrollbar on outsheet. |
|
625 if ( AknLayoutUtils::PenEnabled() ) |
|
626 { |
|
627 AknsDrawUtils::Background( AknsUtils:: SkinInstance(), iOpSheetContext, this, gc, iCalcPaperLayout[0].Rect() ); |
|
628 } |
|
629 else |
|
630 { |
|
631 AknsDrawUtils::Background( AknsUtils:: SkinInstance(), iOpSheetContext, this, gc, rect ); |
|
632 } |
|
633 } |
|
634 |
|
635 |
|
636 for (TInt loop(iCalcOutputSheetLines - 1); loop >= 0; loop--) |
|
637 { |
|
638 const TCalcEditLine& history = (*iCalcHistory)[loop + iScrollOffset]; |
|
639 TCalcEditLine::TCalcOperatorType operatorType( |
|
640 history.Operator()); |
|
641 |
|
642 if (loop < iCalcOutputSheetLines - 1) |
|
643 { |
|
644 // When an operator is Equal, a line is drawn at an upper end. |
|
645 if (TCalcEditLine::ECalcEqual == operatorType) |
|
646 { |
|
647 TRgb ResultsLineolor; |
|
648 TInt error1 = AknsUtils::GetCachedColor( skin, ResultsLineolor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG29); |
|
649 if(error1 == KErrNone) |
|
650 { |
|
651 AknIconUtils::SetIconColor(iCalcResultsLine->Bitmap(),ResultsLineolor); |
|
652 } |
|
653 if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
654 { |
|
655 #ifdef __SCALABLE_ICONS |
|
656 TAknLayoutRect& lineLayout = iResultsLineLayout->At(loop); |
|
657 AknIconUtils::SetSize(iCalcResultsLine->Bitmap(),lineLayout.Rect().Size(),EAspectRatioNotPreserved); |
|
658 AknIconUtils::SetSize(iCalcResultsLine->Mask(),lineLayout.Rect().Size(),EAspectRatioNotPreserved); |
|
659 lineLayout.DrawImage(gc, iCalcResultsLine->Bitmap(),iCalcResultsLine->Mask()); |
|
660 #else |
|
661 TAknLayoutRect& equalLineLayout= iEqualLineLayout->At(loop); |
|
662 TRect rectLine = equalLineLayout.Rect(); |
|
663 equalLineLayout.DrawRect(gc); |
|
664 #endif |
|
665 } |
|
666 else |
|
667 { |
|
668 TAknLayoutRect& equalLineLayout= iEqualLineLayout->At(loop); |
|
669 TRect rectLine = equalLineLayout.Rect(); |
|
670 equalLineLayout.DrawRect(gc); |
|
671 } |
|
672 } |
|
673 } |
|
674 TRgb color; |
|
675 TInt error = AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG29); |
|
676 if(error == KErrNone) |
|
677 { |
|
678 gc.SetPenColor(color); |
|
679 } |
|
680 |
|
681 //change TBuf<10> to TBuf<KCalcMaxNumberWidth> |
|
682 TBuf<KCalcMaxNumberWidth> keyvalue; |
|
683 |
|
684 keyvalue.Append(history.NumberString()); |
|
685 AknTextUtils::LanguageSpecificNumberConversion (keyvalue); |
|
686 // An operand's drawing |
|
687 TAknLayoutText& operendLayout = iOperandLayout->At(loop); |
|
688 |
|
689 if ( iUiLanguage == ELangFarsi || iUiLanguage == ELangHindi || |
|
690 iUiLanguage == ELangUrdu || iUiLanguage == ELangArabic ) |
|
691 { |
|
692 if( iUiLanguage == ELangUrdu || iUiLanguage == ELangArabic ) |
|
693 { |
|
694 TInt len = keyvalue.Length(); |
|
695 TInt pos = KErrNotFound; |
|
696 TBuf<1> ch; |
|
697 ch.Append(iCalcAppEnv->MinusIndicator()); |
|
698 if( (pos = keyvalue.Locate(iCalcAppEnv->MinusIndicator())) != KErrNotFound && |
|
699 pos == keyvalue.LocateReverse(iCalcAppEnv->MinusIndicator())) |
|
700 { |
|
701 keyvalue.Delete( pos, 1 ); |
|
702 keyvalue.Insert( 0, ch ); |
|
703 } |
|
704 } |
|
705 operendLayout.DrawText(gc,keyvalue,EFalse,color); |
|
706 } |
|
707 else |
|
708 { |
|
709 operendLayout.DrawText(gc,history.NumberString(),EFalse,color); |
|
710 } |
|
711 // An operator's drawing |
|
712 TPtrC operatorString( |
|
713 iCalcAppEnv->OutSheetOperator(operatorType)); |
|
714 TAknLayoutText& operatorLayout = iOperatorLayout->At(loop); |
|
715 operatorLayout.DrawText(gc, operatorString , EFalse, color); |
|
716 } |
|
717 |
|
718 |
|
719 } |
|
720 |
|
721 // --------------------------------------------------------- |
|
722 // CCalcOutputSheet::HandleScrollEventL |
|
723 // Handles the events from the scrollbar |
|
724 // (other items were commented in a header). |
|
725 // --------------------------------------------------------- |
|
726 // |
|
727 void CCalcOutputSheet::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
728 { |
|
729 //Only on page up/down,scroll up/down and drag events |
|
730 if((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) || |
|
731 (aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) || |
|
732 (aEventType == EEikScrollDown)) |
|
733 |
|
734 { |
|
735 //Get the current position from the scroll bar |
|
736 |
|
737 if(iPrevThumbPosition >aScrollBar->ThumbPosition() ) |
|
738 { |
|
739 //Move the scroll bar n times up |
|
740 while(iPrevThumbPosition != aScrollBar->ThumbPosition()) |
|
741 { |
|
742 ScrollUp(); |
|
743 iPrevThumbPosition--; |
|
744 } |
|
745 } |
|
746 else |
|
747 { |
|
748 //Move the scroll bar n times down |
|
749 while( iPrevThumbPosition != aScrollBar->ThumbPosition() ) |
|
750 { |
|
751 ScrollDown(); |
|
752 iPrevThumbPosition++; |
|
753 } |
|
754 } |
|
755 |
|
756 DrawNow(); |
|
757 } |
|
758 } |
|
759 |
|
760 // --------------------------------------------------------- |
|
761 // CCalcOutputSheet::HandleResourceChange |
|
762 // Handles the events that needs to be taken care after resource change |
|
763 // (other items were commented in a header). |
|
764 // --------------------------------------------------------- |
|
765 // |
|
766 void CCalcOutputSheet::HandleResourceChange(TInt aType) |
|
767 { |
|
768 TRAP_IGNORE(HandleResourceChangeOutSheetL(aType) ); |
|
769 } |
|
770 |
|
771 // --------------------------------------------------------- |
|
772 // CCalcOutputSheet::HandleResourceChangeOutSheetL |
|
773 // Handles the events that needs to be taken care after resource change |
|
774 // (other items were commented in a header). |
|
775 // --------------------------------------------------------- |
|
776 // |
|
777 void CCalcOutputSheet::HandleResourceChangeOutSheetL(TInt aType) |
|
778 |
|
779 { |
|
780 |
|
781 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
782 { |
|
783 if ( AknLayoutUtils::PenEnabled() ) |
|
784 { |
|
785 ScrollToBottomL(); |
|
786 } |
|
787 } |
|
788 if(aType == KAknsMessageSkinChange) |
|
789 { |
|
790 if( AknLayoutUtils::PenEnabled() ) |
|
791 { |
|
792 delete(iSBFrame); |
|
793 iSBFrame = NULL; |
|
794 |
|
795 UpdateScrollIndicatorL(); |
|
796 } |
|
797 } |
|
798 } |
|
799 // End of File |