2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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 FUi_ClipboardPopupEvent.cpp
20 * @brief This is the implementation for the _ClipboardPopupEvent class.
25 #include <unique_ptr.h>
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include "FUi_ClipboardPopupEvent.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Runtime;
33 using namespace Tizen::Graphics;
35 namespace Tizen { namespace Ui
38 * @class _ClipboardPopupEventArg
39 * @brief This class is used as the argument to clipboard-popup event listener.
42 class _ClipboardPopupEventArg
43 : public Tizen::Base::Runtime::IEventArg
44 , public Tizen::Base::Object
47 _ClipboardPopupEventArg(_ClipboardPopupState clipboardPopupState, Dimension& clipboardPopupSize);
49 virtual ~_ClipboardPopupEventArg(void);
51 _ClipboardPopupState GetClipboardPopupState(void) const;
52 Dimension GetClipboardPopupSize(void) const;
55 _ClipboardPopupEventArg(const _ClipboardPopupEventArg& rhs);
56 _ClipboardPopupEventArg& operator =(const _ClipboardPopupEventArg& rhs);
59 _ClipboardPopupState __clipboardPopupState;
60 Dimension __clipboardPopupSize;
61 }; // _ClipboardPopupEventArg
63 _ClipboardPopupEventArg::_ClipboardPopupEventArg(_ClipboardPopupState clipboardPopupState, Dimension& clipboardPopupSize)
64 : __clipboardPopupState(clipboardPopupState)
65 , __clipboardPopupSize(clipboardPopupSize)
69 _ClipboardPopupEventArg::~_ClipboardPopupEventArg(void)
74 _ClipboardPopupEventArg::GetClipboardPopupState(void) const
76 return __clipboardPopupState;
80 _ClipboardPopupEventArg::GetClipboardPopupSize(void) const
82 return __clipboardPopupSize;
86 _ClipboardPopupEvent::CreateInstanceN(void)
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.");
91 result r = GetLastResult();
92 SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
94 SetLastResult(E_SUCCESS);
96 return pClipboardPopupEvent.release();
100 _ClipboardPopupEvent::CreateClipboardPopupEventArgN(_ClipboardPopupState clipboardPopupState, Dimension& clipboardPopupSize)
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.");
107 result r = GetLastResult();
108 SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
110 return pClipboardPopupEventArg.release();
113 _ClipboardPopupEvent::~_ClipboardPopupEvent(void)
118 _ClipboardPopupEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
120 _IClipboardPopupEventListener* pEventListener = dynamic_cast <_IClipboardPopupEventListener*>(&listener);
121 SysTryReturnVoidResult(NID_UI, pEventListener, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid.");
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.");
126 _ClipboardPopupState state = pArg->GetClipboardPopupState();
127 Dimension clipboardPopupSize = pArg->GetClipboardPopupSize();
131 case _CLIPBOARD_POPUP_STATE_OPENED:
132 pEventListener->OnClipboardPopupOpened(clipboardPopupSize);
134 case _CLIPBOARD_POPUP_STATE_CLOSED:
135 pEventListener->OnClipboardPopupClosed();
137 case _CLIPBOARD_POPUP_STATE_BOUNDS_CHANGED:
138 pEventListener->OnClipboardPopupBoundsChanged(clipboardPopupSize);
141 SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given.");
145 SetLastResult(E_SUCCESS);
148 _ClipboardPopupEvent::_ClipboardPopupEvent(void)
150 result r = _Event::Initialize();
151 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
153 SetLastResult(E_SUCCESS);