Fixed the bg image issues in popup group of controls.
[platform/framework/native/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 Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0/
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 namespace Tizen { namespace Graphics { namespace _Text {
34         class TextObject;
35 }}} // Tizen::Graphics::_Text
36
37 namespace Tizen { namespace Ui { namespace Controls
38 {
39
40 class Button;
41 class _MessageBox;
42 class _Label;
43 class _Scroll;
44 class _ScrollPanel;
45
46 /**
47  * @class _MessageBoxPresenter
48  * @brief
49  * @since       2.0
50  *
51  *
52  *
53  *
54  */
55 class _MessageBoxPresenter
56         : public _PopupPresenter
57         , virtual public Tizen::Base::Runtime::IEventListener
58 {
59 // Lifecycle
60 public:
61         _MessageBoxPresenter(void);
62         virtual ~_MessageBoxPresenter(void);
63
64 // Operations
65 public:
66         result Initialize(_MessageBox& msgbox);
67
68         virtual void Draw(void);
69
70         virtual result ShowAndWait(int& modalResult);
71
72         result OnChangeLayout(_ControlOrientation orientation);
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         virtual void OnDrawFocus(void);
79
80         bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
81
82         void UpdateButtonString(void);
83
84         void InitializeAccessibilityElement(void);
85
86         bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element);
87 //Accessor
88 public:
89         float GetBodyTextHeight(void) const;
90         float GetBodyTextObjHeight(void) const;
91
92         Tizen::Graphics::FloatRectangle GetTextBounds(void) const;
93
94 protected:
95         virtual void ProcessEvent(void);
96         virtual _Popup* GetCore(void);
97 private:
98         _MessageBoxPresenter(const _MessageBoxPresenter& rhs);
99         _MessageBoxPresenter& operator =(const _MessageBoxPresenter& rhs);
100
101         result CreateButtons(void);
102         void FindButtonAndResult(const _ControlHandle handle);
103
104         float CalculateButtonAreaHeight(void);
105         Tizen::Graphics::FloatRectangle CalculateButtonPositionAndSize(int buttonIndex);
106
107         void SetReturnValue(MessageBoxModalResult rtn);
108         int GetReturnValue(void) const;
109
110         float GetLabelHeight(Tizen::Graphics::_Text::TextObject* textObject, wchar_t* text, int length, float fontSize, FloatRectangle bounds, bool isTitle);
111         float GetLeftRightLabelMargin(void);
112
113         void GetButtonString(void);
114
115 // Inner class
116 private:
117         class _MessageBoxButtonListener
118                 : public ITouchEventListener
119                 , public IKeyEventListener
120                 , virtual public Tizen::Base::Runtime::IEventListener
121         {
122 public:
123                 _MessageBoxButtonListener(void);
124                 virtual ~_MessageBoxButtonListener(void);
125
126                 _ControlHandle GetClickedButtonHandle(void) const;
127                 bool IsButtonClicked(void);
128                 void SetBeginModal(bool beginModal);
129                 bool GetBeginModal(void);
130
131 protected:
132                 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
133                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo);
134                 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
135                                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo) {}
136                 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
137                                                                                                 const Tizen::Ui::TouchEventInfo& touchInfo);
138                 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
139                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo);
140                 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
141                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo) {}
142                 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
143                                                                                         const Tizen::Ui::TouchEventInfo& touchInfo) {}
144                 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition,
145                                                                                                 const Tizen::Ui::TouchEventInfo& touchInfo) {}
146                 virtual void OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
147                 virtual void OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
148                 virtual void OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode) {}
149
150 private:
151                 _ControlHandle __buttonHandle;
152
153                 bool __buttonPressFlag;
154                 bool __buttonReleaseState;
155                 bool __beginModal;
156
157                 Tizen::Graphics::FloatPoint __point;
158
159         }; // class _MessageBoxButtonListener
160
161
162 private:
163         enum
164         {
165                 MSGBOX_BUTTON_CLICKED = 0xFF,
166                 MSGBOX_BUTTON_CLOSE,
167                 MSGBOX_BUTTON_CANCEL
168         };
169
170 // Attributes
171 private:
172         _MessageBox* __pMessageBox;
173         _MessageBoxButtonListener* __pButtonListener;
174         MessageBoxModalResult __msgboxResult;
175
176         static const int MSGBOX_MAX_BUTTON_NUM = 3;
177
178         Tizen::Ui::Controls::Button* __pButtons[MSGBOX_MAX_BUTTON_NUM];
179         Tizen::Base::String __buttonText[MSGBOX_MAX_BUTTON_NUM];
180
181         Tizen::Graphics::_Text::TextObject* __pBodyTextObject;
182
183         Tizen::Graphics::FloatRectangle __textBounds;
184         Tizen::Graphics::FloatRectangle __titleBgBounds;
185         Tizen::Graphics::FloatRectangle __buttonBgBounds;
186
187
188         Tizen::Ui::Controls::_Label* __pLabel;
189         Tizen::Ui::Controls::_Scroll* __pScroll;
190         Tizen::Ui::Controls::_ScrollPanel* __pScrollPanel;
191
192         float __scrollPos;
193         int __buttonNum;
194         float __prevPositionY;
195         float __textObjHeight;
196
197         bool __touchPressFlag;
198         bool __scrollStart;
199         bool __btnClickFlag;
200         bool __bodyClickFlag;
201         bool __touchOutBounds;
202         bool __beginModal;
203
204 }; // _MessageBoxPresenter
205
206
207 }}} // Tizen::Ui::Controls
208
209 #endif  // _FUI_CTRL_INTERNAL_MESSAGEBOX_PRESENTER_H_