|
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 CAknFepCtrlCommonBgCtrl* CAknFepCtrlCommonBgCtrl::NewL(CFepUiLayout* aUiLayout, |
|
30 TInt aControlId, |
|
31 TAknsItemID aFrameID, |
|
32 TAknsItemID aCenterID) |
|
33 { |
|
34 CAknFepCtrlCommonBgCtrl* self = NewLC(aUiLayout, |
|
35 aControlId, |
|
36 aFrameID, |
|
37 aCenterID); |
|
38 CleanupStack::Pop(self); |
|
39 |
|
40 return self; |
|
41 } |
|
42 |
|
43 CAknFepCtrlCommonBgCtrl* CAknFepCtrlCommonBgCtrl::NewLC(CFepUiLayout* aUiLayout, |
|
44 TInt aControlId, |
|
45 TAknsItemID aFrameID, |
|
46 TAknsItemID aCenterID) |
|
47 { |
|
48 CAknFepCtrlCommonBgCtrl* self = new (ELeave) CAknFepCtrlCommonBgCtrl(aUiLayout, |
|
49 aControlId, |
|
50 aFrameID, |
|
51 aCenterID); |
|
52 CleanupStack::PushL(self); |
|
53 self->BaseConstructL(); |
|
54 self->SetOrdinalPos(CFepUiBaseCtrl::EOrderBackground); |
|
55 return self; |
|
56 } |
|
57 |
|
58 void CAknFepCtrlCommonBgCtrl::SizeChanged(const TRect& aRect) |
|
59 { |
|
60 if (aRect.Size().iWidth == 0 || aRect.Size().iHeight == 0) |
|
61 { |
|
62 return; |
|
63 } |
|
64 |
|
65 SetRect( aRect ); |
|
66 |
|
67 Draw(); |
|
68 UpdateArea(Rect(), EFalse); |
|
69 } |
|
70 |
|
71 TBool CAknFepCtrlCommonBgCtrl::Contains(const TPoint& /*aPt*/) |
|
72 { |
|
73 return EFalse; |
|
74 } |
|
75 |
|
76 CAknFepCtrlCommonBgCtrl::CAknFepCtrlCommonBgCtrl(CFepUiLayout* aUiLayout, |
|
77 TInt aControlId, |
|
78 TAknsItemID aFrameID, |
|
79 TAknsItemID aCenterID) |
|
80 : CFepUiBaseCtrl(TRect(), aUiLayout, aControlId), |
|
81 iFrameID(aFrameID), iCenterID(aCenterID) |
|
82 { |
|
83 SetControlType( ECtrlBackgroundCtrl ); |
|
84 } |
|
85 |
|
86 CAknFepCtrlCommonBgCtrl::~CAknFepCtrlCommonBgCtrl() |
|
87 { |
|
88 iSubItems.Reset(); |
|
89 iSubItems.Close(); |
|
90 } |
|
91 |
|
92 void CAknFepCtrlCommonBgCtrl::SetFrameID( TAknsItemID aFrameID, TAknsItemID aCenterID ) |
|
93 { |
|
94 iFrameID = aFrameID; |
|
95 iCenterID = aCenterID; |
|
96 } |
|
97 |
|
98 void CAknFepCtrlCommonBgCtrl::Draw() |
|
99 { |
|
100 if(Hiden() || !Ready() || Rect().Size() == TSize(0,0)) |
|
101 { |
|
102 return; |
|
103 } |
|
104 |
|
105 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
106 |
|
107 //mask bitmaps |
|
108 DrawOpaqueMaskBackground(); |
|
109 TRect rect = Rect(); |
|
110 // ----- draw frame ----- |
|
111 gc->Activate( BitmapDevice() ); |
|
112 gc->Clear(rect); |
|
113 DrawFrame( gc, rect, iFrameID, iCenterID); |
|
114 |
|
115 for( TInt i = 0; i < iSubItems.Count(); i++ ) |
|
116 { |
|
117 if( iSubItems[i].iIsShow ) |
|
118 { |
|
119 DrawFrame( gc, |
|
120 iSubItems[i].iRect, |
|
121 iSubItems[i].iFrameID, |
|
122 iSubItems[i].iCenterID ); |
|
123 } |
|
124 } |
|
125 } |
|
126 |
|
127 void CAknFepCtrlCommonBgCtrl::ReDrawRect(const TRect& aRect) |
|
128 { |
|
129 if(Hiden() || !Ready() || Rect().Size() == TSize(0,0)) |
|
130 { |
|
131 return; |
|
132 } |
|
133 |
|
134 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
135 DrawOpaqueMaskBackground(); |
|
136 gc->Activate( BitmapDevice() ); |
|
137 gc->Clear(aRect); |
|
138 |
|
139 gc->SetClippingRect( aRect ); |
|
140 TRect rect = Rect(); |
|
141 |
|
142 DrawFrame( gc, rect, iFrameID, iCenterID); |
|
143 |
|
144 for( TInt i = 0; i < iSubItems.Count(); i++ ) |
|
145 { |
|
146 if( iSubItems[i].iIsShow ) |
|
147 { |
|
148 DrawFrame( gc, |
|
149 iSubItems[i].iRect, |
|
150 iSubItems[i].iFrameID, |
|
151 iSubItems[i].iCenterID ); |
|
152 } |
|
153 } |
|
154 gc->CancelClippingRect(); |
|
155 } |
|
156 |
|
157 void CAknFepCtrlCommonBgCtrl::AddSubBgItemL( const TCommonBgCtrlSubItem& aSubItem ) |
|
158 { |
|
159 iSubItems.AppendL( aSubItem ); |
|
160 } |
|
161 |
|
162 void CAknFepCtrlCommonBgCtrl::ShowSubBgItem( TInt aIndex, TBool aShow ) |
|
163 { |
|
164 iSubItems[aIndex].iIsShow = aShow; |
|
165 } |
|
166 |
|
167 void CAknFepCtrlCommonBgCtrl::DrawFrame( CFbsBitGc* aGc, |
|
168 const TRect& aRect, |
|
169 TAknsItemID aFrameID, |
|
170 TAknsItemID aCenterID ) |
|
171 { |
|
172 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
173 TRect innerRect = aRect; |
|
174 innerRect.Shrink( 4, 4 ); |
|
175 |
|
176 AknsDrawUtils::DrawFrame( |
|
177 skin, *aGc, |
|
178 aRect, innerRect, |
|
179 aFrameID, aCenterID); |
|
180 } |
|
181 |
|
182 TCommonBgCtrlSubItem& CAknFepCtrlCommonBgCtrl::GetSubBgItem( TInt aIndex ) |
|
183 { |
|
184 return iSubItems[aIndex]; |
|
185 } |
|
186 // End Of File |