MyGUI: MyGUI_ClipboardManager.cpp Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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"
8#include "MyGUI_ClipboardManager.h"
9#include "MyGUI_Gui.h"
10#include "MyGUI_TextIterator.h"
11#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
12#include "MyGUI_WindowsClipboardHandler.h"
13#endif
14
15namespace MyGUI
16{
17
18 MYGUI_SINGLETON_DEFINITION(ClipboardManager);
19
20 ClipboardManager::ClipboardManager() :
21#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
22 mWindowsClipboardHandler(nullptr),
23#endif
24 mIsInitialise(false),
25 mSingletonHolder(this)
26 {
27 }
28
29 void ClipboardManager::initialise()
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
43 void ClipboardManager::shutdown()
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
MyGUI_ClipboardManager.h
MYGUI_ASSERT
#define MYGUI_ASSERT(exp, dest)
Definition MyGUI_Diagnostic.h:29
MYGUI_LOG
#define MYGUI_LOG(level, text)
Definition MyGUI_Diagnostic.h:17
MyGUI_Gui.h
MYGUI_PLATFORM
#define MYGUI_PLATFORM
Definition MyGUI_Platform.h:26
MYGUI_PLATFORM_WIN32
#define MYGUI_PLATFORM_WIN32
Definition MyGUI_Platform.h:11
MyGUI_Precompiled.h
MYGUI_SINGLETON_DEFINITION
#define MYGUI_SINGLETON_DEFINITION(ClassName)
Definition MyGUI_Singleton.h:123
MyGUI_TextIterator.h
MyGUI_WindowsClipboardHandler.h
MyGUI::ClipboardManager
Definition MyGUI_ClipboardManager.h:21
MyGUI::ClipboardManager::eventClipboardRequested
delegates::CMultiDelegate2< const std::string &, std::string & > eventClipboardRequested
Definition MyGUI_ClipboardManager.h:59
MyGUI::ClipboardManager::ClipboardManager
ClipboardManager()
Definition MyGUI_ClipboardManager.cpp:20
MyGUI::ClipboardManager::getClassTypeName
static const char * getClassTypeName()
MyGUI::ClipboardManager::eventClipboardChanged
delegates::CMultiDelegate2< const std::string &, const std::string & > eventClipboardChanged
Definition MyGUI_ClipboardManager.h:51
MyGUI::ClipboardManager::clearClipboardData
void clearClipboardData(const std::string &_type)
Definition MyGUI_ClipboardManager.cpp:65
MyGUI::ClipboardManager::setClipboardData
void setClipboardData(const std::string &_type, const std::string &_data)
Definition MyGUI_ClipboardManager.cpp:58
MyGUI::ClipboardManager::shutdown
void shutdown()
Definition MyGUI_ClipboardManager.cpp:43
MyGUI::ClipboardManager::initialise
void initialise()
Definition MyGUI_ClipboardManager.cpp:29
MyGUI::ClipboardManager::getClipboardData
std::string getClipboardData(const std::string &_type) const
Definition MyGUI_ClipboardManager.cpp:71
MyGUI
Definition MyGUI_ActionController.h:15