|
1 /* |
|
2 * Copyright (c) 2006-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: Implementation for latchable button |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "peninputlayoutlatchbutton.h" |
|
20 |
|
21 // ============================ MEMBER FUNCTIONS =============================== |
|
22 // --------------------------------------------------------------------------- |
|
23 // CFepLayoutLatchButton::NewL |
|
24 // factory function |
|
25 // (other items were commented in a header). |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 EXPORT_C CFepLayoutLatchButton* CFepLayoutLatchButton::NewL(const TRect& aRect, |
|
29 CFepUiLayout* aUiLayout,TInt aCtrlId) |
|
30 { |
|
31 CFepLayoutLatchButton* btn=new (ELeave)CFepLayoutLatchButton(aRect, |
|
32 aUiLayout,aCtrlId); |
|
33 CleanupStack::PushL(btn); |
|
34 btn->BaseConstructL(); |
|
35 CleanupStack::Pop(btn); |
|
36 return btn; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CFepLayoutLatchButton::CFepLayoutLatchButton |
|
41 // C++ default constructor |
|
42 // (other items were commented in a header). |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CFepLayoutLatchButton::CFepLayoutLatchButton(const TRect& aRect, |
|
46 CFepUiLayout* aUiLayout,TInt aCtrlId) |
|
47 :CButtonBase(aRect,aUiLayout,aCtrlId), |
|
48 iLatched(EFalse) |
|
49 { |
|
50 //do nothing right now. |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CFepLayoutLatchButton::~CFepLayoutLatchButton |
|
55 // Destructor |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CFepLayoutLatchButton::~CFepLayoutLatchButton() |
|
59 { |
|
60 delete iLatchedBmp; |
|
61 delete iLatchedMaskBmp; |
|
62 delete iUnLatchedBmp; |
|
63 delete iUnLatchedMaskBmp; |
|
64 |
|
65 iActiveBmp = NULL; |
|
66 iActiveBmpPressed= NULL; |
|
67 iNonActiveBkBmp= NULL; |
|
68 iNonActiveBkBmpPressed= NULL; |
|
69 |
|
70 |
|
71 iActiveMaskBmp= NULL; |
|
72 iActiveMaskBmpPressed= NULL; |
|
73 iNonActiveBkMaskBmp= NULL; |
|
74 iNonActiveBkMaskBmpPressed= NULL; |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CFepLayoutLatchButton::SetLatchedBitmapL |
|
80 // Set lathed bitmap |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 EXPORT_C void CFepLayoutLatchButton::SetLatchedBitmap(CFbsBitmap* aBmp, |
|
84 CFbsBitmap* aMaskBmp) |
|
85 { |
|
86 iLatchedBmp = aBmp; |
|
87 iLatchedMaskBmp = aMaskBmp; |
|
88 if(iLatched) |
|
89 { |
|
90 SetBackgroundBmp(iLatchedBmp); |
|
91 SetBackgroundMaskBmp(iLatchedMaskBmp); |
|
92 } |
|
93 //set active pressed and non active pressed bitmap to latched bitmap |
|
94 iActiveBmpPressed = aBmp; |
|
95 iNonActiveBkBmpPressed = aBmp; |
|
96 iActiveMaskBmpPressed = aMaskBmp; |
|
97 iNonActiveBkMaskBmpPressed = aMaskBmp; |
|
98 |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CFepLayoutLatchButton::SetUnLatchedBitmapL |
|
103 // Set unlathed bitmap |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C void CFepLayoutLatchButton::SetUnLatchedBitmap(CFbsBitmap* aBmp, |
|
107 CFbsBitmap* aMaskBmp) |
|
108 { |
|
109 iUnLatchedBmp = aBmp; |
|
110 iUnLatchedMaskBmp = aMaskBmp; |
|
111 if(!iLatched) |
|
112 { |
|
113 SetBackgroundBmp(iUnLatchedBmp); |
|
114 SetBackgroundMaskBmp(iUnLatchedMaskBmp); |
|
115 } |
|
116 //set active and non active bitmap to latched bitmap |
|
117 iActiveBmp = aBmp; |
|
118 iNonActiveBkBmp = aBmp; |
|
119 iActiveMaskBmp = aMaskBmp; |
|
120 iNonActiveBkMaskBmp = aMaskBmp; |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // CFepLayoutLatchButton::HandlePointerDownEventL |
|
125 // Handle latch button down event |
|
126 // (other items were commented in a header). |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C CFepUiBaseCtrl* CFepLayoutLatchButton::HandlePointerDownEventL( |
|
130 const TPoint& aPt) |
|
131 { |
|
132 |
|
133 if(IsDimmed()) |
|
134 return NULL; |
|
135 CFepUiBaseCtrl::HandlePointerDownEventL(aPt); |
|
136 ChangeState(); |
|
137 ReportEvent(EEventButtonDown); |
|
138 return this; |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CFepLayoutLatchButton::HandlePointerUpEentL |
|
143 // Handle latch button up event |
|
144 // (other items were commented in a header). |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C CFepUiBaseCtrl* CFepLayoutLatchButton::HandlePointerUpEventL( |
|
148 const TPoint& aPt) |
|
149 { |
|
150 //do nothing special |
|
151 CFepUiBaseCtrl::HandlePointerUpEventL(aPt); |
|
152 ReportEvent(EEventButtonUp); |
|
153 return this; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CFepLayoutLatchButton::HandlePointerEnter |
|
158 // Handle pointer enter event |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C void CFepLayoutLatchButton::HandlePointerEnter(const TPoint& /*aPt*/) |
|
162 { |
|
163 if(IsDimmed()) |
|
164 return; |
|
165 ChangeState(); |
|
166 ReportEvent(EEventPointerEnterControl); |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CFepLayoutLatchButton::HandlePointerLeave |
|
171 // Handle pointer leave event |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 EXPORT_C void CFepLayoutLatchButton::HandlePointerLeave(const TPoint& /*aPt*/) |
|
175 { |
|
176 if(IsDimmed()) |
|
177 return; |
|
178 ChangeState(); |
|
179 ReportEvent(EEventPointerLeftControl); |
|
180 } |
|
181 |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CFepLayoutLatchButton::ChangeState |
|
185 // Change latch state when button down/up |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 void CFepLayoutLatchButton::ChangeState() |
|
189 { |
|
190 iLatched = !iLatched; //change state |
|
191 Draw(); |
|
192 UpdateArea(Rect(),EFalse); |
|
193 } |
|
194 |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // CFepLayoutLatchButton::Draw |
|
198 // Draw the control |
|
199 // (other items were commented in a header). |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 EXPORT_C void CFepLayoutLatchButton::Draw() |
|
203 { |
|
204 //change backgroud according to latch state |
|
205 if(iLatched) |
|
206 { |
|
207 SetBackgroundBmp(iLatchedBmp); |
|
208 SetBackgroundMaskBmp(iLatchedMaskBmp); |
|
209 } |
|
210 else |
|
211 { |
|
212 SetBackgroundBmp(iUnLatchedBmp); |
|
213 SetBackgroundMaskBmp(iUnLatchedMaskBmp); |
|
214 } |
|
215 CButtonBase::Draw(); |
|
216 } |
|
217 |
|
218 //end of file |