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.

132 lines
4.3KB

  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. #if _MSC_VER
  24. // (these functions are in a separate file because of problems including windows.h
  25. // at the same time as the Digi headers)
  26. #include <windows.h>
  27. #include "../../juce_AudioFilterBase.h"
  28. #include "../../juce_AudioFilterEditor.h"
  29. //==============================================================================
  30. void JUCE_CALLTYPE attachSubWindow (void* hostWindow,
  31. int& titleW, int& titleH,
  32. Component* comp)
  33. {
  34. RECT clientRect;
  35. GetClientRect ((HWND) hostWindow, &clientRect);
  36. titleW = clientRect.right - clientRect.left;
  37. titleH = jmax (0, (clientRect.bottom - clientRect.top) - comp->getHeight());
  38. comp->setTopLeftPosition (0, titleH);
  39. comp->addToDesktop (0);
  40. HWND plugWnd = (HWND) comp->getWindowHandle();
  41. SetParent (plugWnd, (HWND) hostWindow);
  42. DWORD val = GetWindowLong (plugWnd, GWL_STYLE);
  43. val = (val & ~WS_POPUP) | WS_CHILD;
  44. SetWindowLong (plugWnd, GWL_STYLE, val);
  45. }
  46. void JUCE_CALLTYPE resizeHostWindow (void* hostWindow,
  47. int& titleW, int& titleH,
  48. Component* comp)
  49. {
  50. RECT clientRect, windowRect;
  51. GetClientRect ((HWND) hostWindow, &clientRect);
  52. GetWindowRect ((HWND) hostWindow, &windowRect);
  53. const int borderW = (windowRect.right - windowRect.left) - (clientRect.right - clientRect.left);
  54. const int borderH = (windowRect.bottom - windowRect.top) - (clientRect.bottom - clientRect.top);
  55. SetWindowPos ((HWND) hostWindow, 0, 0, 0,
  56. borderW + jmax (titleW, comp->getWidth()),
  57. borderH + comp->getHeight() + titleH,
  58. SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
  59. }
  60. #if ! JucePlugin_EditorRequiresKeyboardFocus
  61. static HWND findMDIParentOf (HWND w)
  62. {
  63. const int frameThickness = GetSystemMetrics (SM_CYFIXEDFRAME);
  64. while (w != 0)
  65. {
  66. HWND parent = GetParent (w);
  67. if (parent == 0)
  68. break;
  69. TCHAR windowType [32];
  70. zeromem (windowType, sizeof (windowType));
  71. GetClassName (parent, windowType, 31);
  72. if (String (windowType).equalsIgnoreCase (T("MDIClient")))
  73. {
  74. w = parent;
  75. break;
  76. }
  77. RECT windowPos;
  78. GetWindowRect (w, &windowPos);
  79. RECT parentPos;
  80. GetWindowRect (parent, &parentPos);
  81. int dw = (parentPos.right - parentPos.left) - (windowPos.right - windowPos.left);
  82. int dh = (parentPos.bottom - parentPos.top) - (windowPos.bottom - windowPos.top);
  83. if (dw > 100 || dh > 100)
  84. break;
  85. w = parent;
  86. if (dw == 2 * frameThickness)
  87. break;
  88. }
  89. return w;
  90. }
  91. void JUCE_CALLTYPE passFocusToHostWindow (void* hostWindow)
  92. {
  93. SetFocus (findMDIParentOf ((HWND) hostWindow));
  94. }
  95. #endif
  96. #endif