Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_MessageBoxPresenter.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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://floralicense.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
18 /**
19  * @file                FUiCtrl_MessageBoxPresenter.h
20  * @brief       This is the header file for the _MessageBoxPresenter class.
21  *
22  * This header file contains the declarations of the %_MessageBoxPresenter class.
23  */
24
25 #ifndef _FUI_CTRL_INTERNAL_MESSAGEBOX_PRESENTER_H_
26 #define _FUI_CTRL_INTERNAL_MESSAGEBOX_PRESENTER_H_
27
28
29 #include <FUiIActionEventListener.h>
30 #include "FUi_UiTouchEvent.h"
31 #include "FUiCtrl_PopupPresenter.h"
32
33
34 namespace Tizen { namespace Ui { namespace Controls
35 {
36
37 class Button;
38 class _MessageBox;
39 class _Scroll;
40
41 /**
42  * @class _MessageBoxPresenter
43  * @brief
44  * @since       1.0
45  *
46  *
47  *
48  *
49  */
50 class _MessageBoxPresenter
51         : public _PopupPresenter
52         , virtual public Tizen::Base::Runtime::IEventListener
53 {
54 // Lifecycle
55 public:
56         _MessageBoxPresenter(void);
57         virtual ~_MessageBoxPresenter(void);
58
59 // Operations
60 public:
61         result Initialize(_MessageBox& msgbox);
62
63         virtual void Draw(void);
64
65         virtual result ShowAndWait(int& modalResult);
66
67         result OnAttachedToMainTree(void);
68
69         void OnFontChanged(Tizen::Graphics::Font* pFont);
70         void OnFontInfoRequested(unsigned long& style, int& size);
71
72         result SetFontInfo(unsigned long style, int size);
73
74         // get touch event from _MessageBox, for drawing scroll in TextObject
75         virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
76         virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
77         virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
78
79 //Accessor
80 public:
81         int GetBodyTextHeight(void) const;
82
83         Tizen::Graphics::Rectangle GetTitleBounds(void) const;
84         Tizen::Graphics::Rectangle GetTextBounds(void) const;
85
86 protected:
87         virtual void ProcessEvent(void);
88
89 private:
90         _MessageBoxPresenter(const _MessageBoxPresenter& rhs);
91         _MessageBoxPresenter& operator =(const _MessageBoxPresenter& rhs);
92
93         result CreateButtons(void);
94         void FindButtonAndResult(const _ControlHandle handle);
95
96         int CalculateButtonAreaHeight(void);
97         Tizen::Graphics::Rectangle CalculateButtonPositionAndSize(int buttonIndex);
98
99         void SetReturnValue(MessageBoxModalResult rtn);
100         int GetReturnValue(void) const;
101
102 // Inner class
103 private:
104         class _MessageBoxButtonListener
105                 : public ITouchEventListener
106                 , virtual public Tizen::Base::Runtime::IEventListener
107         {
108 public:
109                 _MessageBoxButtonListener(void);
110                 virtual ~_MessageBoxButtonListener(void);
111
112                 _ControlHandle GetClickedButtonHandle(void) const;
113                 bool IsButtonClicked(void);
114
115 protected:
116                 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
117                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo);
118                 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
119                                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo) {}
120                 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
121                                                                                                 const Tizen::Ui::TouchEventInfo& touchInfo);
122                 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
123                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo);
124                 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
125                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo) {}
126                 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
127                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo) {}
128                 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
129                                                                                                 const Tizen::Ui::TouchEventInfo& touchInfo) {}
130
131 private:
132                 _ControlHandle __buttonHandle;
133
134                 bool __buttonPressFlag;
135                 bool __buttonReleaseState;
136
137                 Tizen::Graphics::Point __point;
138
139         }; // class _MessageBoxButtonListener
140
141
142 private:
143         enum
144         {
145                 MSGBOX_BUTTON_CLICKED = 0xFF
146         };
147
148 // Attributes
149 private:
150         _MessageBox* __pMessageBox;
151         _MessageBoxButtonListener* __pButtonListener;
152         MessageBoxModalResult __msgboxResult;
153
154         Tizen::Ui::Controls::Button* __pButtons[3];
155
156     Tizen::Ui::_AccessibilityElement* __pTextAccessibilityElement;
157
158         Tizen::Graphics::_Text::TextObject* __pTitleTextObject;
159         Tizen::Graphics::_Text::TextObject* __pBodyTextObject;
160
161         Tizen::Graphics::Rectangle __titleBounds;
162         Tizen::Graphics::Rectangle __textBounds;
163
164         Tizen::Ui::Controls::_Scroll* __pScroll;
165
166         unsigned long __fontStyle;
167         int __fontSize;
168
169         int __scrollPos;
170         int __buttonNum;
171         int __prevPositionY;
172         int __textObjHeight;
173
174         bool __touchPressFlag;
175         bool __scrollStart;
176         bool __btnClickFlag;
177         bool __bodyClickFlag;
178         bool __touchOutBounds;
179
180 }; // _MessageBoxPresenter
181
182
183 }}} // Tizen::Ui::Controls
184
185 #endif  // _FUI_CTRL_INTERNAL_MESSAGEBOX_PRESENTER_H_