|
1 /* |
|
2 * Copyright (c) 2002, 2003 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: Navi decorated control for eventview |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "calencustomnavilabel.h" |
|
19 #include "calendarui_debug.h" |
|
20 |
|
21 #include <aknlayoutscalable_apps.cdl.h> |
|
22 #include <eikapp.h> |
|
23 #include <eikappui.h> |
|
24 #include <AknUtils.h> |
|
25 #include <calendar.mbg> |
|
26 #include <AknIconUtils.h> |
|
27 #include <debug.h> |
|
28 #include <aknsutils.h> |
|
29 |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // CCustomNaviControl::NewL |
|
33 // First stage construction |
|
34 // ---------------------------------------------------------------------------- |
|
35 CCustomNaviControl* CCustomNaviControl::NewL(const TDesC& aName, const TRgb aColor) |
|
36 { |
|
37 TRACE_ENTRY_POINT; |
|
38 CCustomNaviControl* self = new(ELeave)CCustomNaviControl(); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL( aName, aColor ); |
|
41 CleanupStack::Pop(self); |
|
42 TRACE_EXIT_POINT; |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ---------------------------------------------------------------------------- |
|
47 // CCustomNaviControl::~CCustomNaviControl |
|
48 // Destructor |
|
49 // ---------------------------------------------------------------------------- |
|
50 CCustomNaviControl::~CCustomNaviControl() |
|
51 { |
|
52 TRACE_ENTRY_POINT; |
|
53 if(iBitmap) |
|
54 { |
|
55 delete iBitmap; |
|
56 iBitmap = NULL; |
|
57 } |
|
58 if(iMask) |
|
59 { |
|
60 delete iMask; |
|
61 iMask = NULL; |
|
62 } |
|
63 |
|
64 if(iCalendarName) |
|
65 { |
|
66 delete iCalendarName; |
|
67 } |
|
68 TRACE_EXIT_POINT; |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CCustomNaviControl::SetCalendarNameAndColor |
|
73 // Sets the Calendar name and Color. |
|
74 // ---------------------------------------------------------------------------- |
|
75 void CCustomNaviControl::SetCalendarNameAndColor(const TDesC& aName, const TRgb aColor) |
|
76 { |
|
77 TRACE_ENTRY_POINT; |
|
78 delete iCalendarName; |
|
79 iCalendarColor = aColor; |
|
80 iCalendarName = aName.AllocL(); |
|
81 TRACE_EXIT_POINT; |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // CCustomNaviControl::CCustomNaviControl |
|
86 // Constructor |
|
87 // ---------------------------------------------------------------------------- |
|
88 CCustomNaviControl::CCustomNaviControl() |
|
89 { |
|
90 TRACE_ENTRY_POINT; |
|
91 TRACE_EXIT_POINT; |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // CCustomNaviControl::ConstructL |
|
96 // Second stage construction |
|
97 // ---------------------------------------------------------------------------- |
|
98 void CCustomNaviControl::ConstructL(const TDesC& aName, const TRgb aColor) |
|
99 { |
|
100 TRACE_ENTRY_POINT; |
|
101 iCalendarColor = aColor; |
|
102 iCalendarName = aName.AllocL(); |
|
103 CreateWindowL(); |
|
104 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgNavipaneSolid, |
|
105 Rect(), |
|
106 ETrue ); |
|
107 // Create an icon |
|
108 TFileName IconFile; |
|
109 IconFile = ((CEikAppUi*)CCoeEnv::Static()->AppUi())->Application()->BitmapStoreName(); |
|
110 AknIconUtils::CreateIconL(iBitmap, iMask,IconFile, |
|
111 EMbmCalendarQgn_indi_navi_color, |
|
112 EMbmCalendarQgn_indi_navi_color_mask); |
|
113 TRect naviPane; |
|
114 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ENaviPane, naviPane ); |
|
115 SetRect(naviPane); |
|
116 ActivateL(); |
|
117 TRACE_EXIT_POINT; |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------------------------- |
|
121 // CCustomNaviControl::Draw |
|
122 // (other items were commented in a header). |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 void CCustomNaviControl::Draw(const TRect& /*aRect*/) const |
|
126 { |
|
127 TRACE_ENTRY_POINT; |
|
128 |
|
129 TSize navi_pane_size; |
|
130 AknLayoutUtils::LayoutMetricsSize (AknLayoutUtils::ENaviPane, navi_pane_size); |
|
131 TRect navi_pane(navi_pane_size); |
|
132 TAknLayoutRect navi_cale_icon_pane; |
|
133 navi_cale_icon_pane.LayoutRect(navi_pane, |
|
134 AknLayoutScalable_Apps::navi_pane_bcale_mc_g1().LayoutLine() ); |
|
135 TRect navi_cale_icon_ev2_pane = navi_cale_icon_pane.Rect(); |
|
136 |
|
137 CWindowGc& gc = SystemGc(); |
|
138 AknIconUtils::SetSize(iBitmap, navi_cale_icon_ev2_pane.Size()); |
|
139 AknIconUtils::SetIconColor(iBitmap,iCalendarColor); |
|
140 gc.BitBlt(navi_cale_icon_ev2_pane.iTl,iBitmap); |
|
141 TAknTextLineLayout navi_cale_text_pane_t1 = |
|
142 AknLayoutScalable_Apps::navi_pane_bcale_mc_t1(0).LayoutLine(); |
|
143 |
|
144 // Get heading layout properties |
|
145 // from field_cale_ev2_pane_t1 with list_cale_ev2_pane as parent |
|
146 TAknLayoutText headingTextLayout; |
|
147 headingTextLayout.LayoutText(navi_pane, navi_cale_text_pane_t1); |
|
148 |
|
149 const CFont* font = CCoeEnv::Static()->NormalFont(); |
|
150 gc.UseFont(font); |
|
151 // If you see bright red text, the skins api is broken! |
|
152 TRgb textColourFromSkin(255,0,0); |
|
153 // Does not transfer ownership. |
|
154 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
155 AknsUtils::GetCachedColor(skin, |
|
156 textColourFromSkin, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG2); |
|
157 TCharFormat charFormat; |
|
158 TCharFormatMask charFormatMask; |
|
159 // Set the text colour we found. |
|
160 charFormat.iFontPresentation.iTextColor = TLogicalRgb(textColourFromSkin); |
|
161 charFormatMask.SetAttrib(EAttColor); |
|
162 gc.SetPenColor(charFormat.iFontPresentation.iTextColor); |
|
163 gc.DrawText(*(iCalendarName),TPoint(headingTextLayout.TextRect().iTl.iX, |
|
164 headingTextLayout.TextRect().iBr.iY)); |
|
165 gc.DiscardFont(); |
|
166 TRACE_EXIT_POINT; |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CCustomNaviControl::Sizechanged |
|
171 // Child control was resized. |
|
172 // (other items were commented in a header) |
|
173 // ---------------------------------------------------------------------------- |
|
174 // |
|
175 void CCustomNaviControl::SizeChanged() |
|
176 { |
|
177 TRACE_ENTRY_POINT; |
|
178 TRACE_EXIT_POINT; |
|
179 } |
|
180 |
|
181 // ---------------------------------------------------------------------------- |
|
182 // CCustomNaviControl::CountComponentControls |
|
183 // Return child control count. |
|
184 // (other items were commented in a header). |
|
185 // ---------------------------------------------------------------------------- |
|
186 // |
|
187 TInt CCustomNaviControl::CountComponentControls() const |
|
188 { |
|
189 TRACE_ENTRY_POINT; |
|
190 TRACE_EXIT_POINT; |
|
191 |
|
192 return 0; |
|
193 } |
|
194 |
|
195 // ---------------------------------------------------------------------------- |
|
196 // CCustomNaviControl::ComponentControl |
|
197 // Return child control pointer. |
|
198 // (other items were commented in a header). |
|
199 // ---------------------------------------------------------------------------- |
|
200 // |
|
201 CCoeControl* CCustomNaviControl::ComponentControl(TInt /*aIndex*/) const |
|
202 { |
|
203 TRACE_ENTRY_POINT; |
|
204 TRACE_EXIT_POINT; |
|
205 |
|
206 return NULL; |
|
207 } |
|
208 |
|
209 // end of file |