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.

127 lines
3.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. #include "win32_headers.h"
  24. #include "../../../src/juce_core/basics/juce_StandardHeader.h"
  25. BEGIN_JUCE_NAMESPACE
  26. #include "../../../src/juce_core/misc/juce_PlatformUtilities.h"
  27. #include "../../../src/juce_appframework/application/juce_SystemClipboard.h"
  28. #include "../../../src/juce_appframework/gui/components/windows/juce_AlertWindow.h"
  29. //==============================================================================
  30. #if ! JUCE_ONLY_BUILD_CORE_LIBRARY
  31. bool AlertWindow::showNativeDialogBox (const String& title,
  32. const String& bodyText,
  33. bool isOkCancel)
  34. {
  35. return MessageBox (0, bodyText, title,
  36. (isOkCancel) ? MB_OKCANCEL
  37. : MB_OK) == IDOK;
  38. }
  39. #endif
  40. //==============================================================================
  41. void PlatformUtilities::beep()
  42. {
  43. MessageBeep (MB_OK);
  44. }
  45. //==============================================================================
  46. #if JUCE_MSVC
  47. #pragma warning (disable : 4127) // "Conditional expression is constant" warning
  48. #endif
  49. #if ! JUCE_ONLY_BUILD_CORE_LIBRARY
  50. void SystemClipboard::copyTextToClipboard (const String& text) throw()
  51. {
  52. if (OpenClipboard (0) != 0)
  53. {
  54. if (EmptyClipboard() != 0)
  55. {
  56. const int len = text.length();
  57. if (len > 0)
  58. {
  59. HGLOBAL bufH = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE,
  60. (len + 1) * sizeof (wchar_t));
  61. if (bufH != 0)
  62. {
  63. wchar_t* const data = (wchar_t*) GlobalLock (bufH);
  64. text.copyToBuffer (data, len);
  65. GlobalUnlock (bufH);
  66. SetClipboardData (CF_UNICODETEXT, bufH);
  67. }
  68. }
  69. }
  70. CloseClipboard();
  71. }
  72. }
  73. const String SystemClipboard::getTextFromClipboard() throw()
  74. {
  75. String result;
  76. if (OpenClipboard (0) != 0)
  77. {
  78. HANDLE bufH = GetClipboardData (CF_UNICODETEXT);
  79. if (bufH != 0)
  80. {
  81. const wchar_t* const data = (const wchar_t*) GlobalLock (bufH);
  82. if (data != 0)
  83. {
  84. result = String (data, (int) (GlobalSize (bufH) / sizeof (tchar)));
  85. GlobalUnlock (bufH);
  86. }
  87. }
  88. CloseClipboard();
  89. }
  90. return result;
  91. }
  92. #endif
  93. END_JUCE_NAMESPACE