Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / FUi_ClipboardPopupEvent.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        FUi_ClipboardPopupEvent.cpp
20  * @brief       This is the implementation for the _ClipboardPopupEvent class.
21  * @version     1.0
22  */
23
24 #include <new>
25 #include <unique_ptr.h>
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include "FUi_ClipboardPopupEvent.h"
29
30 using namespace std;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Runtime;
33 using namespace Tizen::Graphics;
34
35 namespace Tizen { namespace Ui
36 {
37 /**
38  * @class       _ClipboardPopupEventArg
39  * @brief       This class is used as the argument to clipboard-popup event listener.
40  *
41  */
42 class _ClipboardPopupEventArg
43         : public Tizen::Base::Runtime::IEventArg
44         , public Tizen::Base::Object
45 {
46 public:
47         _ClipboardPopupEventArg(_ClipboardPopupState clipboardPopupState, Dimension& clipboardPopupSize);
48
49         virtual ~_ClipboardPopupEventArg(void);
50
51         _ClipboardPopupState GetClipboardPopupState(void) const;
52         Dimension GetClipboardPopupSize(void) const;
53
54 private:
55         _ClipboardPopupEventArg(const _ClipboardPopupEventArg& rhs);
56         _ClipboardPopupEventArg& operator =(const _ClipboardPopupEventArg& rhs);
57
58 private:
59         _ClipboardPopupState __clipboardPopupState;
60         Dimension __clipboardPopupSize;
61 }; // _ClipboardPopupEventArg
62
63 _ClipboardPopupEventArg::_ClipboardPopupEventArg(_ClipboardPopupState clipboardPopupState, Dimension& clipboardPopupSize)
64         : __clipboardPopupState(clipboardPopupState)
65         , __clipboardPopupSize(clipboardPopupSize)
66 {
67 }
68
69 _ClipboardPopupEventArg::~_ClipboardPopupEventArg(void)
70 {
71 }
72
73 _ClipboardPopupState
74 _ClipboardPopupEventArg::GetClipboardPopupState(void) const
75 {
76         return __clipboardPopupState;
77 }
78
79 Dimension
80 _ClipboardPopupEventArg::GetClipboardPopupSize(void) const
81 {
82         return __clipboardPopupSize;
83 }
84
85 _ClipboardPopupEvent*
86 _ClipboardPopupEvent::CreateInstanceN(void)
87 {
88         unique_ptr<_ClipboardPopupEvent> pClipboardPopupEvent(new (std::nothrow) _ClipboardPopupEvent());
89         SysTryReturn(NID_UI, pClipboardPopupEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
90
91         result r = GetLastResult();
92         SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
93
94         SetLastResult(E_SUCCESS);
95
96         return pClipboardPopupEvent.release();
97 }
98
99 IEventArg*
100 _ClipboardPopupEvent::CreateClipboardPopupEventArgN(_ClipboardPopupState clipboardPopupState, Dimension& clipboardPopupSize)
101 {
102         ClearLastResult();
103
104         unique_ptr<_ClipboardPopupEventArg> pClipboardPopupEventArg(new (std::nothrow) _ClipboardPopupEventArg(clipboardPopupState, clipboardPopupSize));
105         SysTryReturn(NID_UI, pClipboardPopupEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
106
107         result r = GetLastResult();
108         SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
109
110         return pClipboardPopupEventArg.release();
111 }
112
113 _ClipboardPopupEvent::~_ClipboardPopupEvent(void)
114 {
115 }
116
117 void
118 _ClipboardPopupEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
119 {
120         _IClipboardPopupEventListener* pEventListener = dynamic_cast <_IClipboardPopupEventListener*>(&listener);
121         SysTryReturnVoidResult(NID_UI, pEventListener, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid.");
122
123         const _ClipboardPopupEventArg* pArg = dynamic_cast <const _ClipboardPopupEventArg*>(&arg);
124         SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid.");
125
126         _ClipboardPopupState state = pArg->GetClipboardPopupState();
127         Dimension clipboardPopupSize = pArg->GetClipboardPopupSize();
128
129         switch (state)
130         {
131         case _CLIPBOARD_POPUP_STATE_OPENED:
132                 pEventListener->OnClipboardPopupOpened(clipboardPopupSize);
133                 break;
134         case _CLIPBOARD_POPUP_STATE_CLOSED:
135                 pEventListener->OnClipboardPopupClosed();
136                 break;
137         case _CLIPBOARD_POPUP_STATE_BOUNDS_CHANGED:
138                 pEventListener->OnClipboardPopupBoundsChanged(clipboardPopupSize);
139                 break;
140         default:
141                 SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given.");
142                 break;
143         }
144
145         SetLastResult(E_SUCCESS);
146 }
147
148 _ClipboardPopupEvent::_ClipboardPopupEvent(void)
149 {
150         result r = _Event::Initialize();
151         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
152
153         SetLastResult(E_SUCCESS);
154 }
155
156 }} // Tizen::Ui