The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-7 by Raw Material Software ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the
  7. GNU General Public License, as published by the Free Software Foundation;
  8. either version 2 of the License, or (at your option) any later version.
  9. JUCE is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with JUCE; if not, visit www.gnu.org/licenses or write to the
  15. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16. Boston, MA 02111-1307 USA
  17. ------------------------------------------------------------------------------
  18. If you'd like to release a closed-source product which uses JUCE, commercial
  19. licenses are also available: visit www.rawmaterialsoftware.com/juce for
  20. more information.
  21. ==============================================================================
  22. */
  23. // (This file gets included by juce_win32_NativeCode.cpp, rather than being
  24. // compiled on its own).
  25. #if JUCE_INCLUDED_FILE
  26. //==============================================================================
  27. void SystemClipboard::copyTextToClipboard (const String& text) throw()
  28. {
  29. if (OpenClipboard (0) != 0)
  30. {
  31. if (EmptyClipboard() != 0)
  32. {
  33. const int len = text.length();
  34. if (len > 0)
  35. {
  36. HGLOBAL bufH = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE,
  37. (len + 1) * sizeof (wchar_t));
  38. if (bufH != 0)
  39. {
  40. wchar_t* const data = (wchar_t*) GlobalLock (bufH);
  41. text.copyToBuffer (data, len);
  42. GlobalUnlock (bufH);
  43. SetClipboardData (CF_UNICODETEXT, bufH);
  44. }
  45. }
  46. }
  47. CloseClipboard();
  48. }
  49. }
  50. const String SystemClipboard::getTextFromClipboard() throw()
  51. {
  52. String result;
  53. if (OpenClipboard (0) != 0)
  54. {
  55. HANDLE bufH = GetClipboardData (CF_UNICODETEXT);
  56. if (bufH != 0)
  57. {
  58. const wchar_t* const data = (const wchar_t*) GlobalLock (bufH);
  59. if (data != 0)
  60. {
  61. result = String (data, (int) (GlobalSize (bufH) / sizeof (tchar)));
  62. GlobalUnlock (bufH);
  63. }
  64. }
  65. CloseClipboard();
  66. }
  67. return result;
  68. }
  69. #endif