|
1 /* |
|
2 * Copyright (c) 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: Class is responsible of showing the title for current "view" |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cesmrtitlepane.h" |
|
19 #include "nmrlayoutmanager.h" |
|
20 #include "cmrlabel.h" |
|
21 #include "cmrimage.h" |
|
22 //<cmail> |
|
23 #include "esmrdef.h" |
|
24 //</cmail> |
|
25 #include <AknIconUtils.h> |
|
26 #include <gulcolor.h> |
|
27 #include <AknUtils.h> |
|
28 #include <AknsConstants.h> |
|
29 #include <aknsconstants.hrh> |
|
30 #include <AknsUtils.h> |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <AknLayout2ScalableDef.h> |
|
33 |
|
34 #include "emailtrace.h" |
|
35 |
|
36 /// Unnamed namespace for local definitions |
|
37 namespace { // codescanner::namespace |
|
38 |
|
39 /** |
|
40 * KReplaceWhitespaceChars contains some characters that should be replaced by space |
|
41 * in Calendar popup, day view etc. |
|
42 * Following characters are replaced with space |
|
43 * \x0009 horizontal tab |
|
44 * \x000a new line |
|
45 * \x000b line tabulation (vertical |
|
46 * \x000c form feed |
|
47 * \x000d carriage return |
|
48 * \x2028 line separator |
|
49 * \x2029 paragraph separator |
|
50 */ |
|
51 _LIT( KReplaceWhitespaceChars, "\x0009\x000A\x000B\x000C\x000D\x2028\x2029" ); |
|
52 |
|
53 } // namespace |
|
54 |
|
55 // ======== MEMBER FUNCTIONS ======== |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CESMRTitlePane::NewL() |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CESMRTitlePane* CESMRTitlePane::NewL() |
|
62 { |
|
63 FUNC_LOG; |
|
64 CESMRTitlePane* self = CESMRTitlePane::NewLC(); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CESMRTitlePane::NewLC() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CESMRTitlePane* CESMRTitlePane::NewLC() |
|
74 { |
|
75 FUNC_LOG; |
|
76 CESMRTitlePane* self = new (ELeave) CESMRTitlePane(); |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 return self; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CESMRTitlePane::~CESMRTitlePane() |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CESMRTitlePane::~CESMRTitlePane() |
|
87 { |
|
88 FUNC_LOG; |
|
89 delete iTitle; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CESMRTitlePane::CESMRTitlePane() |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CESMRTitlePane::CESMRTitlePane() |
|
97 { |
|
98 FUNC_LOG; |
|
99 // Do nothing |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CESMRTitlePane::ConstructL() |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CESMRTitlePane::ConstructL() |
|
107 { |
|
108 FUNC_LOG; |
|
109 iEntryType = MESMRCalEntry::EESMRCalEntryNotSupported; |
|
110 |
|
111 iTitle = CMRLabel::NewL(); |
|
112 iTitle->SetParent( this ); |
|
113 iTitle->SetTextL( KNullDesC ); |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CESMRTitlePane::SizeChanged() |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void CESMRTitlePane::SizeChanged() |
|
121 { |
|
122 FUNC_LOG; |
|
123 TRect rect = Rect(); |
|
124 |
|
125 TAknTextComponentLayout labelLayout = |
|
126 NMRLayoutManager::GetTextComponentLayout( |
|
127 NMRLayoutManager::EMRLayoutCtrlBarTitle ); |
|
128 AknLayoutUtils::LayoutLabel( iTitle, rect, labelLayout ); |
|
129 |
|
130 TRgb color; |
|
131 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
132 color, |
|
133 KAknsIIDQsnTextColors, |
|
134 EAknsCIQsnTextColorsCG2 ); |
|
135 // If this leaves we'll have to use the default color |
|
136 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
137 *iTitle, |
|
138 EColorLabelText, |
|
139 color ) ); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CESMRTitlePane::CountComponentControls() |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CESMRTitlePane::CountComponentControls() const |
|
147 { |
|
148 FUNC_LOG; |
|
149 TInt count( 0 ); |
|
150 |
|
151 if ( iTitle ) |
|
152 ++count; |
|
153 |
|
154 return count; |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CESMRTitlePane::ComponentControl() |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 CCoeControl* CESMRTitlePane::ComponentControl( TInt aInd ) const |
|
162 { |
|
163 FUNC_LOG; |
|
164 switch( aInd ) |
|
165 { |
|
166 case 0: |
|
167 { |
|
168 return iTitle; |
|
169 } |
|
170 default: |
|
171 return NULL; |
|
172 } |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CESMRTitlePane::SetTextL() |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 void CESMRTitlePane::SetTextL( const TDesC& aText ) |
|
180 { |
|
181 FUNC_LOG; |
|
182 // Create new string buffer for trimming the text, |
|
183 // remove all linefeed/break etc. |
|
184 |
|
185 HBufC* titleForTrimming = aText.AllocLC(); |
|
186 TPtr ptr = titleForTrimming->Des(); |
|
187 AknTextUtils::ReplaceCharacters( ptr, |
|
188 KReplaceWhitespaceChars, |
|
189 TChar(' ') ); |
|
190 |
|
191 titleForTrimming->Des().TrimAll(); |
|
192 |
|
193 iTitle->SetTextL( *titleForTrimming ); |
|
194 |
|
195 CleanupStack::PopAndDestroy( titleForTrimming ); |
|
196 iTitle->CropText(); |
|
197 DrawDeferred(); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CESMRTitlePane::InternalizeL() |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CESMRTitlePane::InternalizeL( MESMRCalEntry& aEntry ) |
|
205 { |
|
206 FUNC_LOG; |
|
207 iEntryType = aEntry.Type(); |
|
208 } |
|
209 |
|
210 |
|
211 // EOF |