1 /* |
|
2 * Copyright (c) 2007-2008 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: Class for rendering text based indicators on top of viewfinder |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "camtextitem.h" |
|
20 #include "AknLayout2ScalableDef.h" |
|
21 #include "AknLayoutFont.h" |
|
22 #include "CamUtility.h" |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CCamTextItem::CCamTextItem() |
|
29 { |
|
30 // No implementation required |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CCamTextItem::~CCamTextItem() |
|
38 { |
|
39 delete iText; |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CCamTextItem* CCamTextItem::NewL() |
|
47 { |
|
48 CCamTextItem* self = new ( ELeave ) CCamTextItem(); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CCamTextItem::ConstructL() |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CCamTextItem::SetLayoutL( |
|
68 const TRect& aParentRect, |
|
69 const TAknTextComponentLayout& aLayout ) |
|
70 { |
|
71 const CFont* layoutFont = AknLayoutUtils::FontFromId(aLayout.LayoutLine().FontId(), 0); |
|
72 layoutFont->FontSpecInTwips().iFontStyle.SetEffects(FontEffect::EOutline,ETrue); |
|
73 layoutFont->FontSpecInTwips().iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
|
74 iLayout.LayoutText( aParentRect, aLayout.LayoutLine(), layoutFont ); |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CCamTextItem::SetTextL( const TDesC& aText ) |
|
82 { |
|
83 if ( !iText || aText.Compare( *iText ) ) |
|
84 { |
|
85 delete iText; |
|
86 iText = NULL; |
|
87 iText = aText.AllocL(); |
|
88 TPtr textPtr = iText->Des(); |
|
89 AknTextUtils::LanguageSpecificNumberConversion( textPtr ); |
|
90 } |
|
91 } |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void CCamTextItem::Draw( CBitmapContext& aBitmapContext ) const |
|
97 { |
|
98 if ( iText ) |
|
99 { |
|
100 aBitmapContext.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
101 aBitmapContext.SetBrushColor( KRgbWhite ); |
|
102 iLayout.DrawText( |
|
103 aBitmapContext, |
|
104 *iText, |
|
105 ETrue, |
|
106 KRgbBlack); |
|
107 } |
|
108 } |
|
109 |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 TRect CCamTextItem::Rect() |
|
116 { |
|
117 return iLayout.TextRect(); |
|
118 } |
|
119 |
|