MyGUI 3.4.1
MyGUI_ClipboardManager.cpp
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#include "MyGUI_Precompiled.h"
9#include "MyGUI_Gui.h"
10#include "MyGUI_TextIterator.h"
11#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
13#endif
14
15namespace MyGUI
16{
17
19
22 mWindowsClipboardHandler(nullptr),
23#endif
24 mIsInitialise(false),
25 mSingletonHolder(this)
26 {
27 }
28
30 {
31 MYGUI_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice");
32 MYGUI_LOG(Info, "* Initialise: " << getClassTypeName());
33
34#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
35 mWindowsClipboardHandler = new WindowsClipboardHandler();
36 mWindowsClipboardHandler->initialise();
37#endif
38
39 MYGUI_LOG(Info, getClassTypeName() << " successfully initialized");
40 mIsInitialise = true;
41 }
42
44 {
45 MYGUI_ASSERT(mIsInitialise, getClassTypeName() << " is not initialised");
46 MYGUI_LOG(Info, "* Shutdown: " << getClassTypeName());
47
48#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
49 mWindowsClipboardHandler->shutdown();
50 delete mWindowsClipboardHandler;
51 mWindowsClipboardHandler = nullptr;
52#endif
53
54 MYGUI_LOG(Info, getClassTypeName() << " successfully shutdown");
55 mIsInitialise = false;
56 }
57
58 void ClipboardManager::setClipboardData(const std::string& _type, const std::string& _data)
59 {
60 mClipboardData[_type] = _data;
61
62 eventClipboardChanged(_type, _data);
63 }
64
65 void ClipboardManager::clearClipboardData(const std::string& _type)
66 {
67 MapString::iterator iter = mClipboardData.find(_type);
68 if (iter != mClipboardData.end()) mClipboardData.erase(iter);
69 }
70
71 std::string ClipboardManager::getClipboardData(const std::string& _type) const
72 {
73 std::string ret;
74 MapString::const_iterator iter = mClipboardData.find(_type);
75 if (iter != mClipboardData.end())
76 ret = (*iter).second;
77
78 // Give delegates a chance to fill the clipboard with data
79 eventClipboardRequested(_type, ret);
80 return ret;
81 }
82
83} // namespace MyGUI
#define MYGUI_ASSERT(exp, dest)
#define MYGUI_LOG(level, text)
#define MYGUI_PLATFORM
#define MYGUI_PLATFORM_WIN32
delegates::CMultiDelegate2< const std::string &, std::string & > eventClipboardRequested
static const char * getClassTypeName()
delegates::CMultiDelegate2< const std::string &, const std::string & > eventClipboardChanged
void clearClipboardData(const std::string &_type)
void setClipboardData(const std::string &_type, const std::string &_data)
std::string getClipboardData(const std::string &_type) const
MYGUI_SINGLETON_DEFINITION(ClipboardManager)