|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // system includes |
|
19 #include <peninputlayout.h> |
|
20 #include <AknIconUtils.h> |
|
21 #include <coemain.h> |
|
22 #include <AknsUtils.h> |
|
23 #include <AknsDrawUtils.h> |
|
24 // user includes |
|
25 #include "peninputcommonbgctrl.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS ============================= |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CAknFepCtrlCommonBgCtrl::NewL |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CAknFepCtrlCommonBgCtrl* CAknFepCtrlCommonBgCtrl::NewL(CFepUiLayout* aUiLayout, |
|
34 TInt aControlId, |
|
35 TAknsItemID aFrameID, |
|
36 TAknsItemID aCenterID) |
|
37 { |
|
38 CAknFepCtrlCommonBgCtrl* self = NewLC(aUiLayout, |
|
39 aControlId, |
|
40 aFrameID, |
|
41 aCenterID); |
|
42 CleanupStack::Pop(self); |
|
43 |
|
44 return self; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CAknFepCtrlCommonBgCtrl::NewLC |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CAknFepCtrlCommonBgCtrl* CAknFepCtrlCommonBgCtrl::NewLC(CFepUiLayout* aUiLayout, |
|
52 TInt aControlId, |
|
53 TAknsItemID aFrameID, |
|
54 TAknsItemID aCenterID) |
|
55 { |
|
56 CAknFepCtrlCommonBgCtrl* self = new (ELeave) CAknFepCtrlCommonBgCtrl(aUiLayout, |
|
57 aControlId, |
|
58 aFrameID, |
|
59 aCenterID); |
|
60 CleanupStack::PushL(self); |
|
61 self->BaseConstructL(); |
|
62 self->SetOrdinalPos(CFepUiBaseCtrl::EOrderBackground); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CAknFepCtrlCommonBgCtrl::SizeChanged |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void CAknFepCtrlCommonBgCtrl::SizeChanged(const TRect& aRect) |
|
71 { |
|
72 if (aRect.Size().iWidth == 0 || aRect.Size().iHeight == 0) |
|
73 { |
|
74 return; |
|
75 } |
|
76 |
|
77 SetRect( aRect ); |
|
78 |
|
79 Draw(); |
|
80 UpdateArea(Rect(), EFalse); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CAknFepCtrlCommonBgCtrl::Contains |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 TBool CAknFepCtrlCommonBgCtrl::Contains(const TPoint& /*aPt*/) |
|
88 { |
|
89 return EFalse; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CAknFepCtrlCommonBgCtrl::CAknFepCtrlCommonBgCtrl |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CAknFepCtrlCommonBgCtrl::CAknFepCtrlCommonBgCtrl(CFepUiLayout* aUiLayout, |
|
97 TInt aControlId, |
|
98 TAknsItemID aFrameID, |
|
99 TAknsItemID aCenterID) |
|
100 : CFepUiBaseCtrl(TRect(), aUiLayout, aControlId), |
|
101 iFrameID(aFrameID), iCenterID(aCenterID) |
|
102 { |
|
103 SetControlType( ECtrlBackgroundCtrl ); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CAknFepCtrlCommonBgCtrl::~CAknFepCtrlCommonBgCtrl |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CAknFepCtrlCommonBgCtrl::~CAknFepCtrlCommonBgCtrl() |
|
111 { |
|
112 iSubItems.Reset(); |
|
113 iSubItems.Close(); |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CAknFepCtrlCommonBgCtrl::SetFrameID |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void CAknFepCtrlCommonBgCtrl::SetFrameID( TAknsItemID aFrameID, TAknsItemID aCenterID ) |
|
121 { |
|
122 iFrameID = aFrameID; |
|
123 iCenterID = aCenterID; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CAknFepCtrlCommonBgCtrl::Draw |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CAknFepCtrlCommonBgCtrl::Draw() |
|
131 { |
|
132 if(Hiden() || !Ready() || Rect().Size() == TSize(0,0)) |
|
133 { |
|
134 return; |
|
135 } |
|
136 |
|
137 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
138 |
|
139 //mask bitmaps |
|
140 DrawOpaqueMaskBackground(); |
|
141 TRect rect = Rect(); |
|
142 // ----- draw frame ----- |
|
143 gc->Activate( BitmapDevice() ); |
|
144 gc->Clear(rect); |
|
145 DrawFrame( gc, rect, iFrameID, iCenterID); |
|
146 |
|
147 for( TInt i = 0; i < iSubItems.Count(); i++ ) |
|
148 { |
|
149 if( iSubItems[i].iIsShow ) |
|
150 { |
|
151 DrawFrame( gc, |
|
152 iSubItems[i].iRect, |
|
153 iSubItems[i].iFrameID, |
|
154 iSubItems[i].iCenterID ); |
|
155 } |
|
156 } |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CAknFepCtrlCommonBgCtrl::ReDrawRect |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CAknFepCtrlCommonBgCtrl::ReDrawRect(const TRect& aRect) |
|
164 { |
|
165 if(Hiden() || !Ready() || Rect().Size() == TSize(0,0)) |
|
166 { |
|
167 return; |
|
168 } |
|
169 |
|
170 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
171 DrawOpaqueMaskBackground(); |
|
172 gc->Activate( BitmapDevice() ); |
|
173 gc->Clear(aRect); |
|
174 |
|
175 gc->SetClippingRect( aRect ); |
|
176 TRect rect = Rect(); |
|
177 |
|
178 DrawFrame( gc, rect, iFrameID, iCenterID); |
|
179 |
|
180 for( TInt i = 0; i < iSubItems.Count(); i++ ) |
|
181 { |
|
182 if( iSubItems[i].iIsShow ) |
|
183 { |
|
184 DrawFrame( gc, |
|
185 iSubItems[i].iRect, |
|
186 iSubItems[i].iFrameID, |
|
187 iSubItems[i].iCenterID ); |
|
188 } |
|
189 } |
|
190 gc->CancelClippingRect(); |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CAknFepCtrlCommonBgCtrl::AddSubBgItemL |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 void CAknFepCtrlCommonBgCtrl::AddSubBgItemL( const TCommonBgCtrlSubItem& aSubItem ) |
|
198 { |
|
199 iSubItems.AppendL( aSubItem ); |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // CAknFepCtrlCommonBgCtrl::ShowSubBgItem |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 void CAknFepCtrlCommonBgCtrl::ShowSubBgItem( TInt aIndex, TBool aShow ) |
|
207 { |
|
208 iSubItems[aIndex].iIsShow = aShow; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // CAknFepCtrlCommonBgCtrl::DrawFrame |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 void CAknFepCtrlCommonBgCtrl::DrawFrame( CFbsBitGc* aGc, |
|
216 const TRect& aRect, |
|
217 TAknsItemID aFrameID, |
|
218 TAknsItemID aCenterID ) |
|
219 { |
|
220 MAknsSkinInstance* skin = UiLayout()->SkinInstance(); |
|
221 TRect innerRect = aRect; |
|
222 innerRect.Shrink( 4, 4 ); |
|
223 |
|
224 AknsDrawUtils::DrawFrame( |
|
225 skin, *aGc, |
|
226 aRect, innerRect, |
|
227 aFrameID, aCenterID); |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // CAknFepCtrlCommonBgCtrl::GetSubBgItem |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 TCommonBgCtrlSubItem& CAknFepCtrlCommonBgCtrl::GetSubBgItem( TInt aIndex ) |
|
235 { |
|
236 return iSubItems[aIndex]; |
|
237 } |
|
238 |
|
239 // End Of File |