|
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 Function-Map's button class, CCalcCommandButton |
|
15 * Derived from CEikCommandButtonBase |
|
16 * The CCalcCommandButton is flat button. |
|
17 * In making disable, it calls SetDimmed() function. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <gulicon.h> |
|
24 #include <calcsoft.rsg> |
|
25 #include <aknutils.h> |
|
26 |
|
27 #include "CalcFunc.h" |
|
28 #include "CalcCmdBtn.h" |
|
29 #include "CalcDrawingConst.laf" |
|
30 #include <AppLayout.cdl.h> |
|
31 #include <AknIconUtils.h> |
|
32 #include "fbs.h" |
|
33 |
|
34 // skin support |
|
35 #include <AknsDrawUtils.h> |
|
36 #include <AknLayoutScalable_Avkon.cdl.h> |
|
37 #include <aknlayoutscalable_avkon.cdl.common.h> |
|
38 #include <AknLayout2ScalableDef.h> |
|
39 |
|
40 #include <aknsconstants.h> |
|
41 #include <AknLayoutScalable_Apps.cdl.h> |
|
42 |
|
43 // skin support |
|
44 #include <AknsDrawUtils.h> |
|
45 |
|
46 |
|
47 // LOCAL CONSTANTS AND MACROS |
|
48 |
|
49 // ================= MEMBER FUNCTIONS ======================= |
|
50 |
|
51 // Two-phased constructor. |
|
52 CCalcCommandButton* CCalcCommandButton::NewL( |
|
53 CCalcFuncmapSubPane* aFuncmapSubPane, |
|
54 const CGulIcon* aUnpressedBmp, |
|
55 const CGulIcon* aPressedBmp, |
|
56 const CGulIcon* aInactiveBmp) |
|
57 { |
|
58 CCalcCommandButton* self = new (ELeave) CCalcCommandButton(); |
|
59 CleanupStack::PushL(self); |
|
60 self->ConstructL(aFuncmapSubPane, aUnpressedBmp, |
|
61 aPressedBmp, aInactiveBmp); |
|
62 CleanupStack::Pop(self); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // Destructor |
|
67 CCalcCommandButton::~CCalcCommandButton() |
|
68 { |
|
69 } |
|
70 |
|
71 |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // CCalcCommandButton::SetStateAndRedraw |
|
75 // Button state is set and re-draw. |
|
76 // (other items were commented in a header). |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 void CCalcCommandButton::SetStateAndRedraw |
|
80 (const TState& aState) |
|
81 { |
|
82 iState = aState; |
|
83 DrawNow(); |
|
84 } |
|
85 |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // CCalcCommandButton::SetIsSelectedAndRedraw |
|
89 // Set flag which button is selected or not, and redraw. |
|
90 // (other items were commented in a header). |
|
91 // --------------------------------------------------------- |
|
92 // |
|
93 void CCalcCommandButton::SetIsSelectedAndRedraw(TBool aIsSelected) |
|
94 { |
|
95 iIsSelected = aIsSelected; |
|
96 DrawNow(); |
|
97 } |
|
98 |
|
99 |
|
100 // --------------------------------------------------------- |
|
101 // CCalcCommandButton::State |
|
102 // Button state is returned. |
|
103 // (other items were commented in a header). |
|
104 // --------------------------------------------------------- |
|
105 // |
|
106 CCalcCommandButton::TState CCalcCommandButton::State() const |
|
107 { |
|
108 return iState; |
|
109 } |
|
110 |
|
111 |
|
112 |
|
113 // C++ default constructor can NOT contain any code, that |
|
114 // might leave. |
|
115 // |
|
116 CCalcCommandButton::CCalcCommandButton() |
|
117 : iState(ENormal), |
|
118 iIsSelected(EFalse) |
|
119 { |
|
120 } |
|
121 |
|
122 // Second-phase constructor |
|
123 void CCalcCommandButton::ConstructL |
|
124 (CCalcFuncmapSubPane* aFuncmapSubPane, |
|
125 const CGulIcon* aUnpressedButtonIcon, |
|
126 const CGulIcon* aPressedButtonIcon, |
|
127 const CGulIcon* aInactiveButtonIcon) |
|
128 { |
|
129 iUnpressedButton = aUnpressedButtonIcon; |
|
130 iPressedButton = aPressedButtonIcon; |
|
131 iInactiveButton = aInactiveButtonIcon; |
|
132 SetContainerWindowL(*aFuncmapSubPane); |
|
133 } |
|
134 |
|
135 |
|
136 // --------------------------------------------------------- |
|
137 // CCalcCommandButton::SizeChanged |
|
138 // Data of control is set. |
|
139 // (other items were commented in a header). |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 void CCalcCommandButton::SizeChanged() |
|
143 { |
|
144 TRect buttonRect(Rect()); |
|
145 TRect aParentRect; |
|
146 TAknWindowLineLayout area; |
|
147 TAknWindowLineLayout cursor_color; |
|
148 |
|
149 if (AknLayoutUtils::ScalableLayoutInterfaceAvailable()) |
|
150 { |
|
151 |
|
152 area = AknLayoutScalable_Apps::cell_calc_pane_g1().LayoutLine(); |
|
153 |
|
154 // For drawing cursor color. |
|
155 cursor_color = AknLayoutScalable_Apps::grid_highlight_pane_cp02().LayoutLine(); |
|
156 |
|
157 |
|
158 } |
|
159 |
|
160 else |
|
161 { |
|
162 |
|
163 area = AppLayout::Cell_pane_elements__calc__Line_1(); |
|
164 // For drawing cursor color. |
|
165 cursor_color = AppLayout::Cell_pane_highlight_elements__various__Line_1(aParentRect); |
|
166 |
|
167 } |
|
168 |
|
169 area.iC = cursor_color.iC; |
|
170 iLayoutRect.LayoutRect(buttonRect,area); |
|
171 |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------- |
|
175 // CCalcCommandButton::Draw |
|
176 // Draw a button |
|
177 // (other items were commented in a header). |
|
178 // --------------------------------------------------------- |
|
179 // |
|
180 void CCalcCommandButton::Draw |
|
181 (const TRect& /* aRect */) const |
|
182 { |
|
183 const CGulIcon* drawButton = iUnpressedButton; |
|
184 |
|
185 switch (iState) |
|
186 { |
|
187 case EPressed: |
|
188 { |
|
189 drawButton = iPressedButton; |
|
190 break; |
|
191 } |
|
192 case EDimmed: |
|
193 { |
|
194 drawButton = iInactiveButton; |
|
195 break; |
|
196 } |
|
197 default: |
|
198 { |
|
199 break; |
|
200 } |
|
201 } |
|
202 CWindowGc& gc = SystemGc(); |
|
203 |
|
204 // Clear with skin background |
|
205 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
206 AknsDrawUtils::Background( skin, AknsDrawUtils::ControlContext(this), this, gc, Rect()); |
|
207 |
|
208 if (AknLayoutUtils::ScalableLayoutInterfaceAvailable()) |
|
209 { |
|
210 TAknWindowLineLayout layout = AknLayoutScalable_Apps::grid_highlight_pane_cp02().LayoutLine(); |
|
211 TAknWindowLineLayout area = AknLayoutScalable_Apps::cell_calc_pane_g1().LayoutLine(); |
|
212 |
|
213 TAknLayoutRect topLeft; |
|
214 topLeft.LayoutRect(Rect(), area); |
|
215 |
|
216 TAknLayoutRect bottomRight; |
|
217 bottomRight.LayoutRect(Rect(),area); |
|
218 |
|
219 TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); |
|
220 TRect innerRect = outerRect; |
|
221 innerRect.Shrink(TSize(5,5)); |
|
222 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
223 if (iIsSelected) |
|
224 TBool highlightDrawn = AknsDrawUtils::DrawFrame(skin, gc, outerRect, innerRect, |
|
225 KAknsIIDQsnFrGrid, KAknsIIDNone); |
|
226 } |
|
227 else |
|
228 { |
|
229 if (iIsSelected) |
|
230 { |
|
231 iLayoutRect.DrawOutLineRect(gc); |
|
232 } |
|
233 |
|
234 } |
|
235 |
|
236 |
|
237 |
|
238 //Set the size of the bitmap. SVG-T upgrade. |
|
239 TRect rect(Rect()); |
|
240 AknIconUtils::SetSize(drawButton->Bitmap(),rect.Size()); |
|
241 AknIconUtils::SetSize(drawButton->Mask(), rect.Size()); |
|
242 iLayoutRect.DrawImage(gc, drawButton->Bitmap(), drawButton->Mask()); |
|
243 |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------- |
|
247 // CCalcCommandButton::SetBitmapIcons |
|
248 // Sets the button bitmap Icons when the skin changes. |
|
249 // --------------------------------------------------------- |
|
250 // |
|
251 void CCalcCommandButton::SetBitmapIcons(CGulIcon* aUnpressedBmp, |
|
252 CGulIcon* aPressedBmp, |
|
253 CGulIcon* aInactiveBmp) |
|
254 { |
|
255 iUnpressedButton = aUnpressedBmp; |
|
256 iPressedButton = aPressedBmp; |
|
257 iInactiveButton = aInactiveBmp; |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------- |
|
261 // CCalcCommandButton::ButtonLayout |
|
262 // Gets the button layout. Used for pen input. |
|
263 // --------------------------------------------------------- |
|
264 // |
|
265 TRect CCalcCommandButton::ButtonLayout() |
|
266 { |
|
267 TRect buttonRect(Rect()); |
|
268 return buttonRect; |
|
269 } |
|
270 // End of File |