1 /* |
|
2 * Copyright (c) 2002 - 2006 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: |
|
15 * This class is an extension to the standard Eikon label. |
|
16 * It provides leave-safe SetText() and is able to |
|
17 * clear its background before drawing. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include <AknUtils.h> |
|
25 #include <AknsUtils.h> |
|
26 #include <AknBidiTextUtils.h> |
|
27 #include <AknsDrawUtils.h> |
|
28 |
|
29 #include "CVRLabel.h" |
|
30 #include "voicerecorder.hrh" |
|
31 |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================================== |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CVRLabel::NewLC |
|
37 // |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CVRLabel* CVRLabel::NewLC( const CCoeControl& aContainer ) |
|
41 { |
|
42 CVRLabel* self = new( ELeave ) CVRLabel; |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aContainer ); |
|
45 |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CVRLabel::~CVRLabel |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CVRLabel::~CVRLabel() |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CVRLabel::ConstructL |
|
62 // |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CVRLabel::ConstructL( const CCoeControl& aContainer ) |
|
66 { |
|
67 SetContainerWindowL( aContainer ); |
|
68 SetBufferReserveLengthL( VRLABELMAXLENGTH ); |
|
69 iSkin = AknsUtils::SkinInstance(); |
|
70 } |
|
71 |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CVRLabel::Draw |
|
75 // Clears the label area and then draws the text |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CVRLabel::Draw( const TRect& aRect ) const |
|
79 { |
|
80 // Acquire the control context through the MOP-chain |
|
81 MAknsControlContext* context = AknsDrawUtils::ControlContext( this ); |
|
82 |
|
83 // Draw the background using the control context |
|
84 // Note: if there is no skin, the background is just cleared |
|
85 // (which is OK for us) |
|
86 AknsDrawUtils::Background( iSkin, context, this, SystemGc(), Rect() ); |
|
87 |
|
88 // Draw the actual text |
|
89 CEikLabel::Draw( aRect ); |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CVRLabel::SetText |
|
95 // Non-leaving SetText variant. |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CVRLabel::SetText( const TDesC& aText ) |
|
99 { |
|
100 TBuf< VRLABELMAXLENGTH > clipped( aText ); |
|
101 // will Panic if clipped is longer than VRLABELMAXLENGTH |
|
102 // AknTextUtils::ClipToFit( clipped, *iFont, iSize.iWidth ); |
|
103 // AknBidiTextUtils::ConvertToVisualAndClipL(clipped,*iFont,iSize.iWidth, iSize.iWidth ); |
|
104 *iText = clipped; |
|
105 } |
|
106 |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CVRLabel::SetTextAndDraw |
|
110 // Updates the label if the given text is differentfrom the label's |
|
111 // current text. |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void CVRLabel::SetTextAndDraw( const TDesC& aText ) |
|
115 { |
|
116 if ( iText->Compare( aText ) ) |
|
117 { |
|
118 SetText( aText ); |
|
119 DrawNow(); |
|
120 } |
|
121 } |
|
122 |
|