VSTEditor.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * VSTEditor.h
  3. * -----------
  4. * Purpose: Implementation of the custom plugin editor window that is used if a plugin provides an own editor GUI.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #include "AbstractVstEditor.h"
  12. OPENMPT_NAMESPACE_BEGIN
  13. #ifdef MPT_WITH_VST
  14. class COwnerVstEditor : public CAbstractVstEditor
  15. {
  16. protected:
  17. CStatic m_plugWindow;
  18. int m_width = 0, m_height = 0;
  19. public:
  20. COwnerVstEditor(CVstPlugin &plugin) : CAbstractVstEditor(plugin) { }
  21. ~COwnerVstEditor() override { }
  22. // Plugins may request to change the GUI size.
  23. bool IsResizable() const override { return true; }
  24. bool SetSize(int contentWidth, int contentHeight) override;
  25. void UpdateParamDisplays() override;
  26. bool OpenEditor(CWnd *parent) override;
  27. void DoClose() override;
  28. protected:
  29. afx_msg BOOL OnEraseBkgnd(CDC *) { return TRUE; }
  30. afx_msg void OnPaint();
  31. LRESULT OnPreTranslateKeyDown(WPARAM wParam, LPARAM lParam) { return HandlePreTranslateMessage(WM_KEYDOWN, wParam, lParam); }
  32. LRESULT OnPreTranslateKeyUp(WPARAM wParam, LPARAM lParam) { return HandlePreTranslateMessage(WM_KEYUP, wParam, lParam); }
  33. LRESULT OnPreTranslateSysKeyDown(WPARAM wParam, LPARAM lParam) { return HandlePreTranslateMessage(WM_SYSKEYDOWN, wParam, lParam); }
  34. LRESULT OnPreTranslateSysKeyUp(WPARAM wParam, LPARAM lParam) { return HandlePreTranslateMessage(WM_SYSKEYUP, wParam, lParam); }
  35. LRESULT HandlePreTranslateMessage(UINT message, WPARAM wParam, LPARAM lParam)
  36. {
  37. MSG msg = {m_plugWindow, message, wParam, lParam, 0, {}};
  38. return HandleKeyMessage(msg);
  39. }
  40. DECLARE_MESSAGE_MAP()
  41. };
  42. #endif // MPT_WITH_VST
  43. OPENMPT_NAMESPACE_END