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 FUiCtrlMessageBox.cpp
20 * @brief This file contains implementation of MessageBox class
23 #include <FUiCtrlMessageBox.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_MessageBoxImpl.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::App;
33 namespace Tizen { namespace Ui { namespace Controls
37 MessageBox::MessageBox(void)
42 MessageBox::~MessageBox(void)
48 MessageBox::Construct(const String& title, const String& text, MessageBoxStyle style, unsigned long timeout)
53 _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
54 SysAssertf(pMessageBoxImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
56 pMessageBoxImpl = _MessageBoxImpl::CreateMessageBoxImplN(this);
58 SysTryReturn(NID_UI_CTRL, pMessageBoxImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
60 maxLength = pMessageBoxImpl->GetMaxTextLength();
61 SysTryCatch(NID_UI_CTRL, text.GetLength() <= maxLength,
62 r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Text length is too long to create MessageBox.");
65 _pControlImpl = pMessageBoxImpl;
67 r = pMessageBoxImpl->Initialize(title, text, style, timeout);
68 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
73 delete pMessageBoxImpl;
81 MessageBox::ShowAndWait(int& modalResult)
83 _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
84 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
86 result r = pMessageBoxImpl->ShowAndWait(modalResult);
87 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
93 MessageBox::GetTitleText(void) const
95 const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
96 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
98 return pMessageBoxImpl->GetTitleText();
102 MessageBox::GetText(void) const
104 const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
105 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
107 return pMessageBoxImpl->GetText();
111 MessageBox::GetMessageBoxStyle(void) const
113 const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
114 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
116 return pMessageBoxImpl->GetMessageBoxStyle();
120 MessageBox::GetTimeout(void) const
122 const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
123 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
125 return pMessageBoxImpl->GetTimeout();
129 MessageBox::SetColor(const Color& color)
131 _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
132 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
134 pMessageBoxImpl->SetColor(color);
138 MessageBox::GetColor(void) const
140 const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
141 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
143 return pMessageBoxImpl->GetColor();
147 MessageBox::SetTitleTextColor(const Color& color)
149 _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
150 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
152 pMessageBoxImpl->SetTitleTextColor(color);
156 MessageBox::GetTitleTextColor(void) const
158 const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
159 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
161 return pMessageBoxImpl->GetTitleTextColor();
165 MessageBox::SetTextColor(const Color& color)
167 _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
168 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
170 pMessageBoxImpl->SetTextColor(color);
174 MessageBox::GetTextColor(void) const
176 const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
177 SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
179 return pMessageBoxImpl->GetTextColor();
182 }}} // Tizen::Ui::Controls