Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / cpp / Sample / Tizen C++ / UiGestureDetector / UiGestureDetector / project / inc / SampleCustomGestureDetectorForm.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.tizenopensource.org/license
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 #ifndef _SAMPLE_CUSTOM_GESTURE_DETECTOR_H_
18 #define _SAMPLE_CUSTOM_GESTURE_DETECTOR_H_
19
20 #include <FUiITouchCustomGestureEventListener.h>
21 #include "BaseForm.h"
22
23 class SampleCustomGestureDetector:
24         public Osp::Ui::TouchGestureDetector
25 {
26 public:
27         SampleCustomGestureDetector(const Osp::Graphics::Rectangle &rect);
28         virtual ~SampleCustomGestureDetector(void);
29
30         void AddEventListener(const Osp::Ui::ITouchCustomGestureEventListener& listener);
31         void RemoveEventListener(const Osp::Ui::ITouchCustomGestureEventListener& listener);
32
33         virtual void OnTouchPressed(Osp::Ui::Control& source, const Osp::Ui::TouchEventInfo& touchInfo);
34         virtual void OnTouchMoved(Osp::Ui::Control& source, const Osp::Ui::TouchEventInfo& touchInfo);
35         virtual void OnTouchReleased(Osp::Ui::Control& source, const Osp::Ui::TouchEventInfo& touchInfo);
36         virtual void OnTouchCanceled(Osp::Ui::Control& source, const Osp::Ui::TouchEventInfo& touchInfo);
37
38 private:
39         double GetAngle(int x1, int y1, int x2, int y2) const;
40
41 private:
42         Osp::Graphics::Point    __previousPoint;
43         Osp::Graphics::Point    __startPoint;
44         Osp::Graphics::Point    __centerPoint;
45         Osp::Graphics::Rectangle        __touchAreaBounds;
46         int __fingerCount;
47         bool __directionChanged;
48 };
49
50 class SampleCustomGestureDetectorForm:
51         public BaseForm,
52         public Osp::Ui::ITouchCustomGestureEventListener
53 {
54 public:
55         SampleCustomGestureDetectorForm(void);
56         virtual ~SampleCustomGestureDetectorForm();
57
58         virtual bool Initialize(void);
59
60         virtual result OnInitializing(void);
61         virtual result OnTerminating(void);
62
63         virtual void OnCustomGestureStarted(Osp::Ui::TouchGestureDetector& gestureDetector);
64         virtual void OnCustomGestureChanged(Osp::Ui::TouchGestureDetector& gestureDetector);
65         virtual void OnCustomGestureFinished(Osp::Ui::TouchGestureDetector& gestureDetector);
66         virtual void OnCustomGestureCanceled(Osp::Ui::TouchGestureDetector& gestureDetector);
67         virtual void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
68
69         virtual result OnDraw(void);
70         Osp::Ui::Controls::Label* GetTouchArea(void);   
71 private:
72         static const int ID_BUTTON_CLEAR = 101;
73         Osp::Ui::Controls::Label* __pTouchArea;
74         Osp::Ui::Controls::Label* __pTouchResult;
75         Osp::Ui::Controls::Button* __pClearButton;
76         SampleCustomGestureDetector* __pCustomGesture;
77         Osp::Graphics::Canvas* __pCanvas;
78 };
79
80 #endif /* _SAMPLE_CUSTOM_GESTURE_DETECTOR_H_ */