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_ResourceManager.h"
28 #include "FUiCtrl_FrameImpl.h"
29 #include "FUiCtrl_MessageBoxImpl.h"
30 #include "FUiCtrl_Form.h"
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Base;
37 namespace Tizen { namespace Ui { namespace Controls
42 _MessageBoxImpl::GetInstance(MessageBox& pMessageBox)
44 return static_cast <_MessageBoxImpl*>(pMessageBox._pControlImpl);
47 const _MessageBoxImpl*
48 _MessageBoxImpl::GetInstance(const MessageBox& pMessageBox)
50 return static_cast <const _MessageBoxImpl*>(pMessageBox._pControlImpl);
53 _MessageBoxImpl::_MessageBoxImpl(MessageBox* pPublic, _MessageBox* pCore)
54 : _WindowImpl(pPublic, pCore)
59 _MessageBoxImpl::~_MessageBoxImpl(void)
65 _MessageBoxImpl::CreateMessageBoxImplN(MessageBox* pControl)
69 _MessageBox* pCore = null;
70 _MessageBoxImpl* pImpl = null;
72 pCore = _MessageBox::CreateMessageBoxN();
74 SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r));
76 pImpl = new (std::nothrow) _MessageBoxImpl(pControl, pCore);
77 r = CheckConstruction(pCore, pImpl);
78 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
84 _MessageBoxImpl::Initialize(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout)
94 r = GetCore().Initialize(title, text, style, timeout);
95 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
97 GET_SHAPE_CONFIG(MESSAGEBOX::MAX_HEIGHT, GetCore().GetOrientation(), maxHeight);
98 GET_SHAPE_CONFIG(MESSAGEBOX::DEFAULT_WIDTH, GetCore().GetOrientation(), defaultWidth);
100 totalH = GetCore().GetTotalHeight();
102 if (totalH > maxHeight)
104 bounds = GetCenterAlignRect(defaultWidth, maxHeight);
108 bounds = GetCenterAlignRect(defaultWidth, totalH);
111 r = SetBounds(bounds);
112 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
121 _MessageBoxImpl::GetPublicClassName(void) const
123 return "Tizen::Ui::Controls::MessageBox";
127 _MessageBoxImpl::GetPublic(void) const
129 return static_cast <const MessageBox&>(_ControlImpl::GetPublic());
133 _MessageBoxImpl::GetPublic(void)
135 return static_cast <MessageBox&>(_ControlImpl::GetPublic());
139 _MessageBoxImpl::GetCore(void) const
141 return static_cast <const _MessageBox&>(_ControlImpl::GetCore());
145 _MessageBoxImpl::GetCore(void)
147 return static_cast <_MessageBox&>(_ControlImpl::GetCore());
151 _MessageBoxImpl::ShowAndWait(int& modalResult)
153 SysTryReturn(NID_UI_CTRL, GetVisibleState() != false, E_SYSTEM,
154 E_SYSTEM, "[E_SYSTEM] This control is not visible");
156 return GetCore().ShowAndWait(modalResult);
160 _MessageBoxImpl::SetColor(const Color& color)
162 return GetCore().SetColor(color);
166 _MessageBoxImpl::GetColor() const
168 return GetCore().GetColor();
172 _MessageBoxImpl::SetTitleTextColor(const Color& color)
174 return GetCore().SetTitleTextColor(color);
178 _MessageBoxImpl::GetTitleTextColor() const
180 return GetCore().GetTitleTextColor();
183 _MessageBoxImpl::SetTextColor(const Color& color)
185 return GetCore().SetTextColor(color);
189 _MessageBoxImpl::GetTextColor() const
191 return GetCore().GetTextColor();
195 _MessageBoxImpl::GetMessageBoxStyle(void) const
197 return GetCore().GetMsgBoxStyle();
201 _MessageBoxImpl::GetTitleText(void) const
203 return GetCore().GetTitleText();
207 _MessageBoxImpl::GetText(void) const
209 return GetCore().GetText();
213 _MessageBoxImpl::GetTimeout(void) const
215 return GetCore().GetTimeout();
219 _MessageBoxImpl::GetMaxTextLength(void) const
222 GET_FIXED_VALUE_CONFIG(MESSAGEBOX::TEXT_MAX_LENGTH, GetCore().GetOrientation(), maxLength);
228 _MessageBoxImpl::GetCenterAlignRect(int width, int height) const
233 Dimension screenRect = _ControlManager::GetInstance()->GetScreenSize();
235 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
237 int temp = screenRect.width;
238 screenRect.width = screenRect.height;
239 screenRect.height = temp;
242 x = (screenRect.width - width) / 2;
243 y = (screenRect.height - height) / 2;
245 return Rectangle(x, y, width, height);
250 _MessageBoxImpl::OnChangeLayout(_ControlOrientation orientation)
252 result r = E_SUCCESS;
253 Dimension portraitSize;
254 Dimension landscapeSize;
256 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
258 portraitSize = Dimension(GetBounds().width, GetBounds().height);
259 landscapeSize = Dimension(portraitSize.height, portraitSize.width);
263 portraitSize = Dimension(GetBounds().height, GetBounds().width);
264 landscapeSize = Dimension(portraitSize.height, portraitSize.width);
267 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
272 r = SetBounds(GetCenterAlignRect(portraitSize.width, portraitSize.height));
273 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
283 r = SetBounds(GetCenterAlignRect(landscapeSize.width, landscapeSize.height));
284 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
290 return GetCore().OnChangeLayout(orientation);
294 }}} // Tizen::Ui::Controls