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.

138 lines
4.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #if _MSC_VER
  19. // (these functions are in their own file because of problems including windows.h
  20. // at the same time as the Digi headers)
  21. #include <windows.h>
  22. #ifdef _MSC_VER
  23. #pragma pack (push, 8)
  24. #endif
  25. #include "../juce_PluginHeaders.h"
  26. #ifdef _MSC_VER
  27. #pragma pack (pop)
  28. #endif
  29. #if JucePlugin_Build_RTAS
  30. //==============================================================================
  31. void JUCE_CALLTYPE attachSubWindow (void* hostWindow,
  32. int& titleW, int& titleH,
  33. Component* comp)
  34. {
  35. RECT clientRect;
  36. GetClientRect ((HWND) hostWindow, &clientRect);
  37. titleW = clientRect.right - clientRect.left;
  38. titleH = jmax (0, (int) (clientRect.bottom - clientRect.top) - comp->getHeight());
  39. comp->setTopLeftPosition (0, titleH);
  40. comp->addToDesktop (0);
  41. HWND plugWnd = (HWND) comp->getWindowHandle();
  42. SetParent (plugWnd, (HWND) hostWindow);
  43. DWORD val = GetWindowLong (plugWnd, GWL_STYLE);
  44. val = (val & ~WS_POPUP) | WS_CHILD;
  45. SetWindowLong (plugWnd, GWL_STYLE, val);
  46. val = GetWindowLong ((HWND) hostWindow, GWL_STYLE);
  47. SetWindowLong ((HWND) hostWindow, GWL_STYLE, val | WS_CLIPCHILDREN);
  48. }
  49. void JUCE_CALLTYPE resizeHostWindow (void* hostWindow,
  50. int& titleW, int& titleH,
  51. Component* comp)
  52. {
  53. RECT clientRect, windowRect;
  54. GetClientRect ((HWND) hostWindow, &clientRect);
  55. GetWindowRect ((HWND) hostWindow, &windowRect);
  56. const int borderW = (windowRect.right - windowRect.left) - (clientRect.right - clientRect.left);
  57. const int borderH = (windowRect.bottom - windowRect.top) - (clientRect.bottom - clientRect.top);
  58. SetWindowPos ((HWND) hostWindow, 0, 0, 0,
  59. borderW + jmax (titleW, comp->getWidth()),
  60. borderH + comp->getHeight() + titleH,
  61. SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
  62. }
  63. #if ! JucePlugin_EditorRequiresKeyboardFocus
  64. static HWND findMDIParentOf (HWND w)
  65. {
  66. const int frameThickness = GetSystemMetrics (SM_CYFIXEDFRAME);
  67. while (w != 0)
  68. {
  69. HWND parent = GetParent (w);
  70. if (parent == 0)
  71. break;
  72. TCHAR windowType [32];
  73. zeromem (windowType, sizeof (windowType));
  74. GetClassName (parent, windowType, 31);
  75. if (String (windowType).equalsIgnoreCase (T("MDIClient")))
  76. {
  77. w = parent;
  78. break;
  79. }
  80. RECT windowPos;
  81. GetWindowRect (w, &windowPos);
  82. RECT parentPos;
  83. GetWindowRect (parent, &parentPos);
  84. int dw = (parentPos.right - parentPos.left) - (windowPos.right - windowPos.left);
  85. int dh = (parentPos.bottom - parentPos.top) - (windowPos.bottom - windowPos.top);
  86. if (dw > 100 || dh > 100)
  87. break;
  88. w = parent;
  89. if (dw == 2 * frameThickness)
  90. break;
  91. }
  92. return w;
  93. }
  94. void JUCE_CALLTYPE passFocusToHostWindow (void* hostWindow)
  95. {
  96. SetFocus (findMDIParentOf ((HWND) hostWindow));
  97. }
  98. #endif
  99. #endif
  100. #endif