54 |
42 |
55 CPenUiWndCtrl::~CPenUiWndCtrl() |
43 CPenUiWndCtrl::~CPenUiWndCtrl() |
56 { |
44 { |
57 delete iPopupWnd; |
45 delete iPopupWnd; |
58 |
46 |
59 delete iIncallBubble; |
|
60 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
47 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
61 |
48 |
62 if ( GfxTransEffect::IsRegistered( this ) ) |
49 if ( GfxTransEffect::IsRegistered( this ) ) |
63 { |
50 { |
64 // abort component effects (possibly appear effect) |
51 // abort component effects (possibly appear effect) |
65 // if aknnote gets destroyed without user interaction or timers |
52 // if aknnote gets destroyed without user interaction or timers |
66 GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort ); |
53 GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort ); |
67 GfxTransEffect::Deregister(this); //Always deregister in destructor. |
54 GfxTransEffect::Deregister(this); //Always deregister in destructor. |
68 } |
55 } |
69 #endif |
56 #endif |
70 if ( iAutoRefreshTimer && iAutoRefreshTimer->IsActive() ) |
|
71 { |
|
72 iAutoRefreshTimer->Cancel(); |
|
73 } |
|
74 delete iAutoRefreshTimer; |
|
75 |
|
76 |
|
77 Clean(); |
|
78 |
|
79 |
|
80 delete iCursorWnd; |
|
81 } |
57 } |
82 |
58 |
83 void CPenUiWndCtrl::ConstructL() |
59 void CPenUiWndCtrl::ConstructL() |
84 { |
60 { |
85 CreateWindowL(iWndGroup); |
61 CreateWindowL(iWndGroup); |
86 SetComponentsToInheritVisibility(); |
62 SetComponentsToInheritVisibility(); |
87 |
63 |
88 Window().SetRequiredDisplayMode( EColor16MA ); |
64 Window().SetRequiredDisplayMode( EColor16MA ); |
89 iIncallBubble = CAknIncallBubble::NewL(); |
65 MakeVisible( EFalse ); |
90 |
|
91 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
66 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
92 // only change registration, if not registered, don't register |
67 // only change registration, if not registered, don't register |
93 if (!GfxTransEffect::IsRegistered( this ) ) |
68 if (!GfxTransEffect::IsRegistered( this ) ) |
94 { |
69 { |
95 GfxTransEffect::Register( this, TUid::Uid( 0x2000B477 )); |
70 GfxTransEffect::Register( this, TUid::Uid( 0x2000B477 )); |
96 } |
71 } |
97 #endif |
72 #endif |
98 // ActivateL(); |
73 // ActivateL(); |
99 iPopupWnd = CPenUiPopWnd::NewL(iWndGroup,iBitmap,this); |
74 iPopupWnd = CPenUiPopWnd::NewL(iWndGroup,iBitmap,this); |
100 |
|
101 iAutoRefreshTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
102 |
|
103 iCursorWnd = new (ELeave) CCursorWindow(this); |
|
104 //iCursorWnd->ConstructL(this); |
|
105 iCursorWnd->SetContainerWindowL(*this); |
|
106 |
|
107 // Update the cursor color |
|
108 SetCursorColor(); |
|
109 |
|
110 MakeVisible( EFalse ); |
|
111 } |
75 } |
112 |
76 |
113 |
77 |
114 void CPenUiWndCtrl::Draw(const TRect& aRect) const |
78 void CPenUiWndCtrl::Draw(const TRect& aRect) const |
115 { |
79 { |
116 if (iNotUpdating) |
80 CWindowGc& gc = SystemGc(); |
|
81 |
|
82 if ( iShowPopup ) |
|
83 { |
|
84 //layout is extended by popup |
|
85 gc.SetClippingRect( iLayoutClipRect ); |
|
86 gc.BitBlt( aRect.iTl, iBitmap, aRect ); |
|
87 // Add to fix NGA refresh problem |
|
88 CCoeEnv::Static()->WsSession().Flush(); |
|
89 CCoeEnv::Static()->WsSession().Finish(); |
117 return; |
90 return; |
118 |
91 } |
119 CWindowGc& gc = SystemGc(); |
92 |
120 if (iShowPopup) |
|
121 { |
|
122 //layout is extended by popup |
|
123 TRect rect = aRect; |
|
124 rect.Intersection(iLayoutClipRect); |
|
125 TPoint pos = rect.iTl - iLayoutClipRect.iTl; |
|
126 gc.BitBlt(pos, iBitmap, rect); |
|
127 #ifdef FIX_FOR_NGA |
|
128 //draw bubble |
|
129 for ( TInt i = 0; i < iBubblesCtrl.Count(); ++i ) |
|
130 { |
|
131 gc.BitBlt(iBubblesPos[i].iTl, iBubblesArea[i]); |
|
132 } |
|
133 #endif |
|
134 return; |
|
135 //layout is extended by popup |
|
136 //gc.SetClippingRect( iLayoutClipRect ); |
|
137 } |
|
138 #ifdef FIX_FOR_NGA |
|
139 gc.BitBlt(TPoint(0, 0), iBitmap, Rect()); |
|
140 //draw bubble |
|
141 for ( TInt i = 0; i < iBubblesCtrl.Count(); ++i ) |
|
142 { |
|
143 gc.BitBlt(iBubblesPos[i].iTl, iBubblesArea[i]); |
|
144 } |
|
145 #else |
|
146 gc.BitBlt(aRect.iTl,iBitmap,aRect); |
93 gc.BitBlt(aRect.iTl,iBitmap,aRect); |
147 #endif |
94 // Add to fix NGA refresh problem |
148 |
|
149 } |
|
150 |
|
151 void CPenUiWndCtrl::RefreshUI() |
|
152 { |
|
153 StopRefreshTimer(); |
|
154 |
|
155 if ( iShowPopup ) |
|
156 { |
|
157 iPopupWnd->DrawNow(); |
|
158 } |
|
159 else |
|
160 { |
|
161 DrawNow(); |
|
162 } |
|
163 CCoeEnv::Static()->WsSession().Flush(); |
95 CCoeEnv::Static()->WsSession().Flush(); |
164 CCoeEnv::Static()->WsSession().Finish(); |
96 CCoeEnv::Static()->WsSession().Finish(); |
165 |
|
166 } |
|
167 |
|
168 void CPenUiWndCtrl::Clean() |
|
169 { |
|
170 iCursorBmp = NULL; |
|
171 iBubblesArea.Close(); |
|
172 iBubblesCtrl.Close(); |
|
173 iBubblesPos.Close(); |
|
174 iBubblesMaskArea.Close(); |
|
175 iPopRegion.Close(); |
|
176 iChangedBmp= NULL; |
|
177 iBackground = EFalse; |
|
178 iNotUpdating = EFalse; |
|
179 } |
|
180 |
|
181 CCursorWindow::CCursorWindow(CPenUiWndCtrl* aParent) |
|
182 :iParent(aParent) |
|
183 { |
|
184 } |
|
185 |
|
186 void CCursorWindow::SetCursorVisible(TBool aFlag) |
|
187 { |
|
188 iCursorVisible = aFlag; |
|
189 DrawNow(); |
|
190 } |
|
191 void CCursorWindow::Draw(const TRect &aRect ) const |
|
192 { |
|
193 if(!iCursorVisible) |
|
194 return; |
|
195 |
|
196 CWindowGc& gc = SystemGc(); |
|
197 iParent->DrawCursor(gc); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CPenUiWndCtrl::SetCursorColor |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CPenUiWndCtrl::SetCursorColor() |
|
205 { |
|
206 // Set default cursor color to black |
|
207 TRgb color( KRgbBlack ); |
|
208 // if the skin is enabled |
|
209 if ( AknsUtils::AvkonSkinEnabled()) |
|
210 { |
|
211 // Get the text color under current theme |
|
212 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
213 color, |
|
214 KAknsIIDQsnTextColors, |
|
215 EAknsCIQsnTextColorsCG60 ); |
|
216 } |
|
217 |
|
218 // Set the cursor color |
|
219 iCursorColor = color; |
|
220 } |
|
221 |
|
222 void CPenUiWndCtrl::DrawCursor(CWindowGc& aGc) const |
|
223 { |
|
224 aGc.SetPenColor( iCursorColor ); |
|
225 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
226 aGc.SetBrushColor( iCursorColor ); |
|
227 aGc.SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
|
228 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
229 aGc.SetPenSize( TSize(1,1)); |
|
230 |
|
231 TRect drawRect = iCursorRect; |
|
232 if(!iPopRegion.IsEmpty() && iPopRegion.Intersects(iCursorRect)) |
|
233 { |
|
234 RRegion r; |
|
235 r.AddRect(iCursorRect); |
|
236 const TRect* rl = iPopRegion.RectangleList(); |
|
237 |
|
238 for(TInt i = 0 ; i < iPopRegion.Count(); ++i) |
|
239 { |
|
240 drawRect = iCursorRect; |
|
241 drawRect.Intersection(rl[i]); |
|
242 if(!drawRect.IsEmpty()) |
|
243 r.SubRect(drawRect); |
|
244 } |
|
245 |
|
246 for(TInt ii = 0; ii < r.Count(); ++ii) |
|
247 { |
|
248 aGc.DrawRect(r.RectangleList()[ii]); |
|
249 } |
|
250 r.Close(); |
|
251 } |
|
252 else |
|
253 aGc.DrawRect(iCursorRect); |
|
254 |
|
255 // restore normal draw mode |
|
256 aGc.SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
257 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
258 |
|
259 } |
|
260 void CPenUiWndCtrl::UpdateCursor(TBool aOnFlag,const CFbsBitmap* aCursorBmp,const TRect& aRect) |
|
261 { |
|
262 if(iNotUpdating || !IsReadyToDraw()) |
|
263 { |
|
264 //some times when layout is diabled, the cursor is still change its pos, and draw to the last place |
|
265 //when layout enabled. So we set the cursor invisible, and wait for next cursor updating event. |
|
266 iCursorWnd->SetCursorVisible(EFalse); |
|
267 return; |
|
268 } |
|
269 |
|
270 iCursorPos = aRect.iTl; |
|
271 |
|
272 if(iCursorRect != aRect) |
|
273 { |
|
274 iCursorRect = aRect; |
|
275 iCursorWnd->SetRect(iCursorRect); |
|
276 } |
|
277 iCursorWnd->SetCursorVisible(aOnFlag); |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // CPenUiWndCtrl::UpdateBubble |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 void CPenUiWndCtrl::UpdateBubble( const TUint32 aCtrl, |
|
285 const CFbsBitmap* aBmp, |
|
286 const CFbsBitmap* aMask, |
|
287 const TRect& aPos, |
|
288 TBool aFlag ) |
|
289 { |
|
290 |
|
291 // Check whether the Ctrl address is exist |
|
292 TInt idx = iBubblesCtrl.Find( aCtrl ); |
|
293 |
|
294 |
|
295 if(aFlag) |
|
296 { |
|
297 if(KErrNotFound == idx) |
|
298 { |
|
299 |
|
300 iBubblesCtrl.Append( aCtrl ); |
|
301 |
|
302 iBubblesArea.Append(aBmp); |
|
303 iBubblesMaskArea.Append(aMask); |
|
304 iBubblesPos.Append(aPos); |
|
305 } |
|
306 else |
|
307 { |
|
308 iBubblesPos[idx] = aPos; |
|
309 } |
|
310 |
|
311 } |
|
312 else |
|
313 { |
|
314 //remove |
|
315 if(idx != KErrNotFound) |
|
316 { |
|
317 |
|
318 iBubblesCtrl.Remove( idx ); |
|
319 |
|
320 iBubblesArea.Remove(idx); |
|
321 iBubblesMaskArea.Remove(idx); |
|
322 iBubblesPos.Remove(idx); |
|
323 } |
|
324 } |
|
325 Invalidate(Rect(), ETrue); |
|
326 } |
|
327 void CPenUiWndCtrl::UpdateICFArea(const CFbsBitmap* aBmp,const TPoint& aPos) |
|
328 { |
|
329 iICFBmp = const_cast<CFbsBitmap*>(aBmp); |
|
330 iIcfPos = aPos; |
|
331 Invalidate(Rect(), ETrue); |
|
332 } |
|
333 |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // CPenUiWndCtrl::UpdateChangedArea |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 void CPenUiWndCtrl::UpdateChangedArea( const TUint32 aCtrl, |
|
340 const CFbsBitmap* aBmp,const TRect& aPos,TBool aFlag) |
|
341 { |
|
342 UpdateBubble( aCtrl, aBmp, 0, aPos, aFlag ); |
|
343 return; |
|
344 } |
|
345 |
|
346 |
|
347 void CPenUiWndCtrl::SetPopupArea(const TRect& aRect, TBool aFlag) |
|
348 { |
|
349 if(aFlag) //add pop area |
|
350 { |
|
351 iPopRegion.AddRect(aRect); |
|
352 } |
|
353 else |
|
354 { |
|
355 iPopRegion.SubRect(aRect); |
|
356 } |
|
357 } |
97 } |
358 |
98 |
359 TInt CPenUiWndCtrl::WndPriority() |
99 TInt CPenUiWndCtrl::WndPriority() |
360 { |
100 { |
361 return iPriority; |
101 return iPriority; |
690 void CPenUiWndCtrl::SetResourceChange(TBool aResourceChange) |
408 void CPenUiWndCtrl::SetResourceChange(TBool aResourceChange) |
691 { |
409 { |
692 iResourceChange = aResourceChange; |
410 iResourceChange = aResourceChange; |
693 } |
411 } |
694 |
412 |
695 void CPenUiWndCtrl::HandleNGASpecificSignal(TInt aEventType, const TDesC& aEventData) |
|
696 { |
|
697 switch(aEventType) |
|
698 { |
|
699 case ESignalPopupWndClosed: |
|
700 { |
|
701 ClosePopup(); |
|
702 } |
|
703 break; |
|
704 case ESignalUpdateCursor : |
|
705 { |
|
706 struct SData |
|
707 { |
|
708 TBool onOff; |
|
709 CFbsBitmap* bmp; |
|
710 TRect rect; |
|
711 } data; |
|
712 |
|
713 data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() ))); |
|
714 UpdateCursor(data.onOff,data.bmp,data.rect); |
|
715 |
|
716 } |
|
717 break; |
|
718 case ESignalPopupArea: |
|
719 { |
|
720 struct SData |
|
721 { |
|
722 TRect rr; |
|
723 TBool flag; |
|
724 } data; |
|
725 |
|
726 data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() ))); |
|
727 SetPopupArea(data.rr,data.flag); |
|
728 } |
|
729 break; |
|
730 case ESignalUpdateICFArea: |
|
731 { |
|
732 struct SData |
|
733 { |
|
734 CFbsBitmap* bmp; |
|
735 TPoint pos; |
|
736 } data; |
|
737 |
|
738 data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() ))); |
|
739 UpdateICFArea(data.bmp,data.pos); |
|
740 } |
|
741 break; |
|
742 case ESignalUpdateBubble: |
|
743 { |
|
744 struct SData |
|
745 { |
|
746 TUint32 ctrl; |
|
747 TBool flag; |
|
748 TRect pos; |
|
749 CFbsBitmap* bmp; |
|
750 CFbsBitmap* mask; |
|
751 } data; |
|
752 data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() ))); |
|
753 UpdateBubble( data.ctrl, data.bmp, data.mask, data.pos, data.flag ); |
|
754 } |
|
755 break; |
|
756 case ESignalUpdateChangedArea: |
|
757 { |
|
758 struct SData |
|
759 { |
|
760 TUint32 ctrl; |
|
761 TBool flag; |
|
762 CFbsBitmap* bmp; |
|
763 TRect pos; |
|
764 } data; |
|
765 data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() ))); |
|
766 UpdateChangedArea( data.ctrl, data.bmp, data.pos, data.flag ); |
|
767 } |
|
768 break; |
|
769 case ESignalRegisterBkControl: |
|
770 { |
|
771 |
|
772 struct SData |
|
773 { |
|
774 //TBool bChangeFrameId; |
|
775 |
|
776 TAknsItemID frameID; |
|
777 TAknsItemID centerID; |
|
778 RArray<TCommonBgCtrlSubItem> *subItems; |
|
779 } data; |
|
780 data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() ))); |
|
781 iSubItems = data.subItems; |
|
782 iFrameID = data.frameID; |
|
783 iCenterID = data.centerID; |
|
784 iBackground = ETrue; |
|
785 } |
|
786 break; |
|
787 case ESignalDisableUpdating: |
|
788 { |
|
789 iNotUpdating = * (reinterpret_cast<TBool*>( const_cast<TUint16*>( aEventData.Ptr() ))); |
|
790 if(iNotUpdating) |
|
791 { |
|
792 UpdateCursor(EFalse,NULL,iCursorWnd?iCursorWnd->Rect():TRect(TPoint(0,0),TSize(0,0))); |
|
793 } |
|
794 } |
|
795 break; |
|
796 case ESignalDrawBackground: |
|
797 { |
|
798 struct SData |
|
799 { |
|
800 CFbsBitGc* gc; |
|
801 CFbsBitmap* bmp; |
|
802 TRect rect; |
|
803 } data; |
|
804 data = * (reinterpret_cast<SData*>( const_cast<TUint16*>( aEventData.Ptr() ))); |
|
805 DrawBubbleAsBackground(data.gc,data.bmp,data.rect); |
|
806 } |
|
807 break; |
|
808 default: |
|
809 break; |
|
810 } |
|
811 |
|
812 } |
|
813 |
|
814 void CPenUiWndCtrl::DrawBkground(CWindowGc& aGc,const TRect& aRect) const |
|
815 { |
|
816 |
|
817 DrawFrame(aGc,aRect, iFrameID, iCenterID); |
|
818 |
|
819 for( TInt i = 0; i < (*iSubItems).Count(); i++ ) |
|
820 { |
|
821 if( (*iSubItems)[i].iIsShow ) |
|
822 { |
|
823 DrawFrame(aGc, (*iSubItems)[i].iRect, |
|
824 (*iSubItems)[i].iFrameID, |
|
825 (*iSubItems)[i].iCenterID ); |
|
826 } |
|
827 } |
|
828 |
|
829 } |
|
830 |
|
831 void CPenUiWndCtrl::DrawBubbleAsBackground(CFbsBitGc* aGc, CFbsBitmap* aBmp, const TRect& aRect) |
|
832 { |
|
833 for(TInt i = 0 ; i < iBubblesArea.Count(); ++i) |
|
834 { |
|
835 if(iBubblesArea[i] != aBmp) //not draw same bitmap |
|
836 { |
|
837 //gc.BitBlt(iBubblesPos[i],iBubblesArea[i]); |
|
838 TRect r = aRect; |
|
839 TRect rect2 = iBubblesPos[i]; |
|
840 r.Intersection(rect2); |
|
841 if(!r.IsEmpty()) |
|
842 { |
|
843 TRect src = r; |
|
844 r.Move(TPoint(-aRect.iTl.iX,-aRect.iTl.iY)); |
|
845 src.Move(TPoint(-rect2.iTl.iX,-rect2.iTl.iY)); |
|
846 aGc->BitBlt(r.iTl, iBubblesArea[i], src); |
|
847 } |
|
848 } |
|
849 } |
|
850 |
|
851 } |
|
852 |
|
853 |
|
854 CCoeControl* CPenUiWndCtrl::ComponentControl(TInt) const |
|
855 { |
|
856 return iCursorWnd; |
|
857 } |
|
858 TInt CPenUiWndCtrl::CountComponentControls() const |
|
859 { |
|
860 return 1; |
|
861 } |
|
862 |
|
863 |
|
864 void CPenUiWndCtrl::DrawFrame(CWindowGc& aGc, const TRect& aRect,TAknsItemID aFrameID, |
|
865 TAknsItemID aCenterID ) const |
|
866 { |
|
867 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
868 TRect innerRect = aRect; |
|
869 innerRect.Shrink( 4, 4 ); |
|
870 |
|
871 AknsDrawUtils::DrawFrame( |
|
872 skin, aGc, |
|
873 aRect, innerRect, |
|
874 aFrameID, aCenterID); |
|
875 } |
|
876 |
|
877 void CPenUiWndCtrl::RestartRefreshTimer() |
|
878 { |
|
879 StopRefreshTimer(); |
|
880 |
|
881 TTimeIntervalMicroSeconds32 t1 = KAutoRefreshTimer * 1000; |
|
882 TTimeIntervalMicroSeconds32 t2 = KAutoRefreshLongTimer * 1000; |
|
883 iAutoRefreshTimer->Start( t1, t2, TCallBack(AutoRefreshTimerCallback, this) ); |
|
884 } |
|
885 |
|
886 void CPenUiWndCtrl::StopRefreshTimer() |
|
887 { |
|
888 if ( iAutoRefreshTimer->IsActive() ) |
|
889 { |
|
890 iAutoRefreshTimer->Cancel(); |
|
891 } |
|
892 } |
|
893 |
|
894 void CPenUiWndCtrl::LiftUpPriority() |
|
895 { |
|
896 TInt priority = GetWndPriority(); |
|
897 iPriority = priority; |
|
898 iWndGroup.SetOrdinalPosition( 0, iPriority); |
|
899 DrawableWindow()->SetOrdinalPosition( 0, iPriority); |
|
900 } |
|
901 |
|
902 //End Of File |
413 //End Of File |
903 // class CInternalBkCtrl |
414 // class CInternalBkCtrl |
904 CInternalBkCtrl::CInternalBkCtrl(RWindowGroup& aWndGroup) |
415 CInternalBkCtrl::CInternalBkCtrl(RWindowGroup& aWndGroup) |
905 :iWndGroup(aWndGroup) |
416 :iWndGroup(aWndGroup) |
906 { |
417 { |