Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlMessageBox.cpp
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                FUiCtrlMessageBox.cpp
20  * @brief       This file contains implementation of MessageBox class
21  */
22
23 #include <FUiCtrlMessageBox.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_MessageBoxImpl.h"
26
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::App;
31
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36
37 MessageBox::MessageBox(void)
38 {
39         //empty statement
40 }
41
42 MessageBox::~MessageBox(void)
43 {
44         //empty statement
45 }
46
47 result
48 MessageBox::Construct(const String& title, const String& text, MessageBoxStyle style, unsigned long timeout)
49 {
50         result r = E_SUCCESS;
51         int maxLength = 0;
52
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.");
55
56         pMessageBoxImpl = _MessageBoxImpl::CreateMessageBoxImplN(this);
57         r = GetLastResult();
58         SysTryReturn(NID_UI_CTRL, pMessageBoxImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
59
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.");
63
64         //Set _MessageBoxImpl
65         _pControlImpl = pMessageBoxImpl;
66
67         r = pMessageBoxImpl->Initialize(title, text, style, timeout);
68         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
69
70         return r;
71
72 CATCH:
73         delete pMessageBoxImpl;
74
75         _pControlImpl = null;
76
77         return r;
78 }
79
80 result
81 MessageBox::ShowAndWait(int& modalResult)
82 {
83         _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
84         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
85
86         result r = pMessageBoxImpl->ShowAndWait(modalResult);
87         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
88
89         return E_SUCCESS;
90 }
91
92 String
93 MessageBox::GetTitleText(void) const
94 {
95         const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
96         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
97
98         return pMessageBoxImpl->GetTitleText();
99 }
100
101 String
102 MessageBox::GetText(void) const
103 {
104         const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
105         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
106
107         return pMessageBoxImpl->GetText();
108 }
109
110 MessageBoxStyle
111 MessageBox::GetMessageBoxStyle(void) const
112 {
113         const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
114         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
115
116         return pMessageBoxImpl->GetMessageBoxStyle();
117 }
118
119 unsigned long
120 MessageBox::GetTimeout(void) const
121 {
122         const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
123         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
124
125         return pMessageBoxImpl->GetTimeout();
126 }
127
128 void
129 MessageBox::SetColor(const Color& color)
130 {
131         _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
132         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
133
134         pMessageBoxImpl->SetColor(color);
135 }
136
137 Color
138 MessageBox::GetColor(void) const
139 {
140         const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
141         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
142
143         return pMessageBoxImpl->GetColor();
144 }
145
146 void
147 MessageBox::SetTitleTextColor(const Color& color)
148 {
149         _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
150         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
151
152         pMessageBoxImpl->SetTitleTextColor(color);
153 }
154
155 Color
156 MessageBox::GetTitleTextColor(void) const
157 {
158         const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
159         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
160
161         return pMessageBoxImpl->GetTitleTextColor();
162 }
163
164 void
165 MessageBox::SetTextColor(const Color& color)
166 {
167         _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
168         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
169
170         pMessageBoxImpl->SetTextColor(color);
171 }
172
173 Color
174 MessageBox::GetTextColor(void) const
175 {
176         const _MessageBoxImpl* pMessageBoxImpl = _MessageBoxImpl::GetInstance(*this);
177         SysAssertf(pMessageBoxImpl != null, "Not-yet constructed. Construct() should be called before use.");
178
179         return pMessageBoxImpl->GetTextColor();
180 }
181
182 }}} // Tizen::Ui::Controls