214 |
214 |
215 // ---------------------------------------------------------------------------- |
215 // ---------------------------------------------------------------------------- |
216 // Navi button class definition |
216 // Navi button class definition |
217 // ---------------------------------------------------------------------------- |
217 // ---------------------------------------------------------------------------- |
218 // |
218 // |
219 NONSHARABLE_CLASS(CAknSctNaviButton) : public CBase |
219 NONSHARABLE_CLASS(CAknSctNaviButton) : public CBase, public MCoeControlObserver |
220 { |
220 { |
221 public: |
221 public: |
222 static CAknSctNaviButton* NewL( |
222 static CAknSctNaviButton* NewL(const CCoeControl& aParent, TInt aButtonId, TResourceReader& reader); |
223 const CCoeControl& aParent, |
|
224 TInt aButtonId, |
|
225 TResourceReader& reader); |
|
226 ~CAknSctNaviButton(); |
223 ~CAknSctNaviButton(); |
227 |
224 |
228 private: |
225 private: |
229 CAknSctNaviButton(TInt aButtonId); |
226 CAknSctNaviButton(TInt aButtonId); |
230 void ConstructL( |
227 void ConstructL(const CCoeControl& aParent, TResourceReader& reader); |
231 const CCoeControl& aParent, |
228 |
232 TResourceReader& reader); |
229 private: // from MCoeControlObserver |
|
230 virtual void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType); |
233 |
231 |
234 public: |
232 public: |
|
233 void SetObserver(MCoeControlObserver* aObserver); |
235 void SetFocused(TBool aState); |
234 void SetFocused(TBool aState); |
236 void SetEnabled(TBool aState); |
235 void SetEnabled(TBool aState); |
237 TBool IsFocused(); |
236 TBool IsFocused(); |
238 TBool IsEnabled(); |
237 TBool IsEnabled(); |
239 |
238 |
240 public: |
239 public: |
241 CAknButton* iButtonControl; |
240 CAknButton* iButtonControl; |
|
241 MCoeControlObserver* iObserver; |
242 TInt iButtonId; |
242 TInt iButtonId; |
243 TBool iPressed; |
243 TBool iPressed; |
244 TBool iRepeat; |
244 TBool iRepeat; |
245 }; |
245 }; |
246 |
246 |
247 // ---------------------------------------------------------------------------- |
247 // ---------------------------------------------------------------------------- |
248 // Table Navi class definition |
248 // Table Navi class definition |
249 // ---------------------------------------------------------------------------- |
249 // ---------------------------------------------------------------------------- |
250 // |
250 // |
251 NONSHARABLE_CLASS(CAknSctTableNavi) : public CAknControl, public MAknSctFocusHandler |
251 NONSHARABLE_CLASS(CAknSctTableNavi) : public CAknControl, public MAknSctFocusHandler, public MCoeControlObserver |
252 { |
252 { |
253 public: |
253 public: |
254 CAknSctTableNavi(CAknCharMap* aCharMap, CAknCharMapExtension* aExtension); |
254 CAknSctTableNavi(CAknCharMap* aCharMap, CAknCharMapExtension* aExtension); |
255 ~CAknSctTableNavi(); |
255 ~CAknSctTableNavi(); |
256 |
256 |
257 public: // from CCoeControl |
257 public: // from CCoeControl |
258 TInt CountComponentControls() const; |
258 TInt CountComponentControls() const; |
259 CCoeControl* ComponentControl( TInt aIndex ) const; |
259 CCoeControl* ComponentControl( TInt aIndex ) const; |
260 virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode); |
260 virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode); |
261 void ConstructFromResourceL(TResourceReader& aReader); |
261 void ConstructFromResourceL(TResourceReader& aReader); |
262 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
263 virtual TSize MinimumSize(); |
262 virtual TSize MinimumSize(); |
264 virtual void SizeChanged(); |
263 virtual void SizeChanged(); |
|
264 |
|
265 public: // from MCoeControlObserver |
|
266 void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType); |
265 |
267 |
266 public: // from MAknSctFocusHandler |
268 public: // from MAknSctFocusHandler |
267 virtual CCoeControl* FocusedControl(); |
269 virtual CCoeControl* FocusedControl(); |
268 virtual TBool EnterControl(TInt aX, TInt aY); |
270 virtual TBool EnterControl(TInt aX, TInt aY); |
269 virtual void MoveFocus(TInt aX, TInt aY); |
271 virtual void MoveFocus(TInt aX, TInt aY); |
270 virtual TBool ExitWithKey(TInt aKeycode); |
272 virtual TBool ExitWithKey(TInt aKeycode); |
271 virtual TBool LeaveControl(); |
273 virtual TBool LeaveControl(); |
272 |
274 |
273 public: |
275 public: |
274 TInt TableCount(); |
276 TInt TableCount(); |
|
277 void UpdateNextTableButtonL(); |
|
278 |
|
279 private: |
275 void TableExitL(); |
280 void TableExitL(); |
276 static TInt DoTableExit(TAny* aThis); |
281 static TInt TableExitCallBackL(TAny* aThis); |
277 void UpdateNextTableButtonL(); |
282 void DoTableExitL(); |
278 |
283 |
|
284 void NextTableL(); |
|
285 static TInt NextTableCallBackL(TAny* aThis); |
|
286 void DoNextTableL(); |
|
287 |
279 private: |
288 private: |
280 TInt ButtonPosition(TInt aButtonIndex) const; |
289 TInt ButtonPosition(TInt aButtonIndex) const; |
281 TInt SetStatusChanged(); |
|
282 void NextTableL(); |
|
283 |
290 |
284 private: // data |
291 private: // data |
285 TInt iButtonIndex; |
292 TInt iButtonIndex; |
286 RPointerArray<CAknSctNaviButton> iButtonArray; |
293 RPointerArray<CAknSctNaviButton> iButtonArray; |
287 CAknCharMap* iCharMap; |
294 CAknCharMap* iCharMap; |
740 return response; |
758 return response; |
741 } |
759 } |
742 |
760 |
743 void CAknSctTableNavi::TableExitL() |
761 void CAknSctTableNavi::TableExitL() |
744 { |
762 { |
745 delete iIdle; |
763 if(!iIdle) |
746 iIdle = 0; |
764 { |
747 iIdle = CIdle::NewL(CActive::EPriorityStandard); |
765 iIdle = CIdle::NewL(CActive::EPriorityStandard); |
748 iIdle->Start(TCallBack(DoTableExit, this)); |
766 } |
749 } |
767 |
750 |
768 iIdle->Cancel(); |
751 TInt CAknSctTableNavi::DoTableExit(TAny* aThis) |
769 iIdle->Start(TCallBack(TableExitCallBackL, this)); |
752 { |
770 } |
753 return ((CAknSctTableNavi*)aThis)->SetStatusChanged(); |
771 |
|
772 TInt CAknSctTableNavi::TableExitCallBackL(TAny* aThis) |
|
773 { |
|
774 ((CAknSctTableNavi*)aThis)->DoTableExitL(); |
|
775 return KErrNone; |
|
776 } |
|
777 |
|
778 void CAknSctTableNavi::DoTableExitL() |
|
779 { |
|
780 iCharMap->SetStatusChanged(EAknCharSelectedTableExitButton); |
|
781 } |
|
782 |
|
783 void CAknSctTableNavi::NextTableL() |
|
784 { |
|
785 if(!iIdle) |
|
786 { |
|
787 iIdle = CIdle::NewL(CActive::EPriorityStandard); |
|
788 } |
|
789 |
|
790 iIdle->Cancel(); |
|
791 iIdle->Start(TCallBack(NextTableCallBackL, this)); |
|
792 } |
|
793 |
|
794 TInt CAknSctTableNavi::NextTableCallBackL(TAny* aThis) |
|
795 { |
|
796 ((CAknSctTableNavi*)aThis)->DoNextTableL(); |
|
797 return KErrNone; |
|
798 } |
|
799 |
|
800 void CAknSctTableNavi::DoNextTableL() |
|
801 { |
|
802 iCharMap->SetStatusChanged(EAknCharSelectedNextTableButton); |
754 } |
803 } |
755 |
804 |
756 TInt CAknSctTableNavi::ButtonPosition(TInt aButtonIndex) const |
805 TInt CAknSctTableNavi::ButtonPosition(TInt aButtonIndex) const |
757 { |
806 { |
758 // buttons behind the 1th are behavior as one button |
807 // buttons behind the 1th are behavior as one button |
759 return (aButtonIndex==0) ? 0 : 1; |
808 return (aButtonIndex==0) ? 0 : 1; |
760 } |
|
761 |
|
762 TInt CAknSctTableNavi::SetStatusChanged() |
|
763 { |
|
764 TRAPD(err, iCharMap->SetStatusChanged(EAknCharSelectedTableExitButton)); |
|
765 return err; |
|
766 } |
|
767 |
|
768 void CAknSctTableNavi::NextTableL() |
|
769 { |
|
770 iCharMap->SetStatusChanged(EAknCharSelectedNextTableButton); |
|
771 } |
809 } |
772 |
810 |
773 void CAknSctTableNavi::ConstructFromResourceL(TResourceReader& aReader) |
811 void CAknSctTableNavi::ConstructFromResourceL(TResourceReader& aReader) |
774 { |
812 { |
775 // Table navi buttons. |
813 // Table navi buttons. |
779 TInt buttonId = aReader.ReadInt16(); |
817 TInt buttonId = aReader.ReadInt16(); |
780 TInt resId = aReader.ReadInt32(); |
818 TInt resId = aReader.ReadInt32(); |
781 TResourceReader buttonReader; |
819 TResourceReader buttonReader; |
782 iCoeEnv->CreateResourceReaderLC(buttonReader, resId); |
820 iCoeEnv->CreateResourceReaderLC(buttonReader, resId); |
783 CAknSctNaviButton* buttonObj = CAknSctNaviButton::NewL(*this, buttonId, buttonReader); |
821 CAknSctNaviButton* buttonObj = CAknSctNaviButton::NewL(*this, buttonId, buttonReader); |
|
822 buttonObj->SetObserver(this); |
784 iButtonArray.Append(buttonObj); |
823 iButtonArray.Append(buttonObj); |
785 CleanupStack::PopAndDestroy(); // buttonReader |
824 CleanupStack::PopAndDestroy(); // buttonReader |
786 } |
825 } |
787 } |
|
788 |
|
789 void CAknSctTableNavi::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
790 { |
|
791 if (AknLayoutUtils::PenEnabled() && Rect().Contains(aPointerEvent.iPosition)) |
|
792 { |
|
793 if (aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
794 { |
|
795 iPressedButtonIndex = -1; |
|
796 |
|
797 for (TInt index = 0; index < iButtonArray.Count(); index++) |
|
798 { |
|
799 CAknSctNaviButton* buttonObj = iButtonArray[index]; |
|
800 if(buttonObj->IsEnabled()) |
|
801 { |
|
802 TRect buttonRect = buttonObj->iButtonControl->Rect(); |
|
803 if (buttonRect.Contains(aPointerEvent.iPosition)) |
|
804 { |
|
805 iPressedButtonIndex = index; |
|
806 } |
|
807 } |
|
808 } |
|
809 } |
|
810 else if (aPointerEvent.iType == TPointerEvent::EButton1Up) |
|
811 { |
|
812 if(iPressedButtonIndex >= 0) |
|
813 { |
|
814 CAknSctNaviButton* buttonObj = iButtonArray[iPressedButtonIndex]; |
|
815 if(buttonObj->IsEnabled()) |
|
816 { |
|
817 iButtonIndex = iPressedButtonIndex; |
|
818 |
|
819 TRect buttonRect = buttonObj->iButtonControl->Rect(); |
|
820 if (buttonRect.Contains(aPointerEvent.iPosition)) |
|
821 { |
|
822 switch (buttonObj->iButtonId) |
|
823 { |
|
824 case EAknSctTableNaviExit: |
|
825 { |
|
826 iExtension->iKeyOkEvent = ETrue; |
|
827 TableExitL(); |
|
828 } |
|
829 return; |
|
830 |
|
831 case EAknSctTableNaviSpecialChar: |
|
832 case EAknSctTableNaviEmotion: |
|
833 { |
|
834 NextTableL(); |
|
835 } |
|
836 return; |
|
837 |
|
838 default: |
|
839 break; |
|
840 } |
|
841 } |
|
842 } |
|
843 } |
|
844 } |
|
845 } |
|
846 |
|
847 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
848 } |
826 } |
849 |
827 |
850 TSize CAknSctTableNavi::MinimumSize() |
828 TSize CAknSctTableNavi::MinimumSize() |
851 { |
829 { |
852 return Rect().Size(); |
830 return Rect().Size(); |
6614 else if ( iExtension->iSingleClickEnabled ) |
6627 else if ( iExtension->iSingleClickEnabled ) |
6615 { |
6628 { |
6616 iExtension->iHighlightVisible = EFalse; |
6629 iExtension->iHighlightVisible = EFalse; |
6617 DrawCursor(); |
6630 DrawCursor(); |
6618 } |
6631 } |
6619 |
|
6620 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
6621 |
6632 |
6622 // if Stylus is lifted we clear all flags. |
6633 // if Stylus is lifted we clear all flags. |
6623 if (aPointerEvent.iType == TPointerEvent::EButton1Up) |
6634 if (aPointerEvent.iType == TPointerEvent::EButton1Up) |
6624 { |
6635 { |
6625 iExtension->iFlags &= (~EAknCharMapButton1DownInGrid); |
6636 iExtension->iFlags &= (~EAknCharMapButton1DownInGrid); |
6626 iExtension->iFlags &= (~EAknCharMapHasBeenScrolledByDrag); |
6637 iExtension->iFlags &= (~EAknCharMapHasBeenScrolledByDrag); |
6627 iExtension->iFlags &= (~EAknCharMapPressedDown); |
6638 iExtension->iFlags &= (~EAknCharMapPressedDown); |
6628 if ( !iSBFrame ) |
6639 if ( iSBFrame ) |
6629 { |
6640 { |
6630 return; |
6641 CEikScrollBar* vScrollBar = iSBFrame->VerticalScrollBar(); |
6631 } |
6642 if(vScrollBar) |
6632 CEikScrollBar* vScrollBar = iSBFrame->VerticalScrollBar(); |
6643 { |
6633 if(vScrollBar) |
6644 vScrollBar->HandlePointerEventL(aPointerEvent); |
6634 { |
6645 } |
6635 vScrollBar->HandlePointerEventL(aPointerEvent); |
6646 } |
6636 } |
6647 } |
6637 } |
6648 } |
6638 } |
6649 else |
|
6650 { |
|
6651 if(iExtension->iSingleClickEnabled) |
|
6652 { |
|
6653 iExtension->iHighlightVisible = EFalse; |
|
6654 DrawCursor(); |
|
6655 } |
|
6656 } |
|
6657 |
|
6658 CCoeControl::HandlePointerEventL(aPointerEvent); |
6639 } |
6659 } |
6640 |
6660 |
6641 // ----------------------------------------------------------------------------- |
6661 // ----------------------------------------------------------------------------- |
6642 // CAknCharMap::SetObserver |
6662 // CAknCharMap::SetObserver |
6643 // Sets the observer. |
6663 // Sets the observer. |