2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrl_MessageBoxImpl.cpp
20 * @brief This is the implementation file for the _MessageBoxImpl class.
25 #include <FBaseSysLog.h>
26 #include "FUi_ControlImplManager.h"
27 #include "FUi_CoordinateSystemUtils.h"
28 #include "FUi_ResourceManager.h"
29 #include "FUiCtrl_FrameImpl.h"
30 #include "FUiCtrl_MessageBoxImpl.h"
31 #include "FUiCtrl_Form.h"
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Base;
38 namespace Tizen { namespace Ui { namespace Controls
43 _MessageBoxImpl::GetInstance(MessageBox& pMessageBox)
45 return static_cast <_MessageBoxImpl*>(pMessageBox._pControlImpl);
48 const _MessageBoxImpl*
49 _MessageBoxImpl::GetInstance(const MessageBox& pMessageBox)
51 return static_cast <const _MessageBoxImpl*>(pMessageBox._pControlImpl);
54 _MessageBoxImpl::_MessageBoxImpl(MessageBox* pPublic, _MessageBox* pCore)
55 : _WindowImpl(pPublic, pCore)
60 _MessageBoxImpl::~_MessageBoxImpl(void)
66 _MessageBoxImpl::CreateMessageBoxImplN(MessageBox* pControl)
70 _MessageBox* pCore = null;
71 _MessageBoxImpl* pImpl = null;
73 pCore = _MessageBox::CreateMessageBoxN();
75 SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r));
77 pImpl = new (std::nothrow) _MessageBoxImpl(pControl, pCore);
78 r = CheckConstruction(pCore, pImpl);
79 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
85 _MessageBoxImpl::Initialize(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout)
89 FloatRectangle bounds;
92 float maxHeight = 0.0f;
93 float defaultWidth = 0.0f;
95 _ControlOrientation orientation;
97 r = GetCore().Initialize(title, text, style, timeout);
98 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
100 orientation = GetCore().GetOrientation();
101 GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, orientation, maxHeight);
102 GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, defaultWidth);
104 totalH = GetCore().GetTotalHeight();
106 if (totalH > maxHeight)
108 bounds = GetCenterAlignRect(defaultWidth, maxHeight);
112 bounds = GetCenterAlignRect(defaultWidth, totalH);
115 r = SetBounds(bounds);
116 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
125 _MessageBoxImpl::GetPublicClassName(void) const
127 return "Tizen::Ui::Controls::MessageBox";
131 _MessageBoxImpl::GetPublic(void) const
133 return static_cast <const MessageBox&>(_ControlImpl::GetPublic());
137 _MessageBoxImpl::GetPublic(void)
139 return static_cast <MessageBox&>(_ControlImpl::GetPublic());
143 _MessageBoxImpl::GetCore(void) const
145 return static_cast <const _MessageBox&>(_ControlImpl::GetCore());
149 _MessageBoxImpl::GetCore(void)
151 return static_cast <_MessageBox&>(_ControlImpl::GetCore());
155 _MessageBoxImpl::ShowAndWait(int& modalResult)
157 SysTryReturn(NID_UI_CTRL, GetVisibleState() != false, E_SYSTEM,
158 E_SYSTEM, "[E_SYSTEM] This control is not visible");
160 return GetCore().ShowAndWait(modalResult);
164 _MessageBoxImpl::SetColor(const Color& color)
166 return GetCore().SetColor(color);
170 _MessageBoxImpl::GetColor() const
172 return GetCore().GetColor();
176 _MessageBoxImpl::SetTitleTextColor(const Color& color)
178 return GetCore().SetTitleTextColor(color);
182 _MessageBoxImpl::GetTitleTextColor() const
184 return GetCore().GetTitleTextColor();
187 _MessageBoxImpl::SetTextColor(const Color& color)
189 return GetCore().SetTextColor(color);
193 _MessageBoxImpl::GetTextColor() const
195 return GetCore().GetTextColor();
199 _MessageBoxImpl::GetMessageBoxStyle(void) const
201 return GetCore().GetMsgBoxStyle();
205 _MessageBoxImpl::GetTitleText(void) const
207 return GetCore().GetTitleText();
211 _MessageBoxImpl::GetText(void) const
213 return GetCore().GetText();
217 _MessageBoxImpl::GetTimeout(void) const
219 return GetCore().GetTimeout();
223 _MessageBoxImpl::GetMaxTextLength(void) const
226 GET_FIXED_VALUE_CONFIG(MESSAGEBOX::TEXT_MAX_LENGTH, GetCore().GetOrientation(), maxLength);
232 _MessageBoxImpl::GetCenterAlignRect(float width, float height) const
237 FloatDimension screenRect = _ControlManager::GetInstance()->GetScreenSizeF();
239 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
241 float temp = screenRect.width;
242 screenRect.width = screenRect.height;
243 screenRect.height = temp;
246 x = (screenRect.width - width) / 2.0f;
247 y = (screenRect.height - height) / 2.0f;
249 return FloatRectangle(x, y, width, height);
254 _MessageBoxImpl::OnChangeLayout(_ControlOrientation orientation)
256 result r = E_SUCCESS;
261 FloatRectangle bounds;
263 GetCore().OnChangeLayout(orientation);
266 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
271 GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, orientation, maxHeight);
272 GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, orientation, defaultWidth);
274 totalH = GetCore().GetTotalHeight();
276 if (totalH > maxHeight)
281 bounds = GetCenterAlignRect(defaultWidth, totalH);
283 r = SetBounds(bounds);
288 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
294 }}} // Tizen::Ui::Controls