Audio plugin host https://kx.studio/carla
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.

juce_NSViewComponent.h 3.0KB

9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_NSVIEWCOMPONENT_H_INCLUDED
  18. #define JUCE_NSVIEWCOMPONENT_H_INCLUDED
  19. #if JUCE_MAC || DOXYGEN
  20. //==============================================================================
  21. /**
  22. A Mac-specific class that can create and embed an NSView inside itself.
  23. To use it, create one of these, put it in place and make sure it's visible in a
  24. window, then use setView() to assign an NSView to it. The view will then be
  25. moved and resized to follow the movements of this component.
  26. Of course, since the view is a native object, it'll obliterate any
  27. juce components that may overlap this component, but that's life.
  28. */
  29. class JUCE_API NSViewComponent : public Component
  30. {
  31. public:
  32. //==============================================================================
  33. /** Create an initially-empty container. */
  34. NSViewComponent();
  35. /** Destructor. */
  36. ~NSViewComponent();
  37. /** Assigns an NSView to this peer.
  38. The view will be retained and released by this component for as long as
  39. it is needed. To remove the current view, just call setView (nullptr).
  40. Note: a void* is used here to avoid including the cocoa headers as
  41. part of the juce.h, but the method expects an NSView*.
  42. */
  43. void setView (void* nsView);
  44. /** Returns the current NSView.
  45. Note: a void* is returned here to avoid the needing to include the cocoa
  46. headers, so you should just cast the return value to an NSView*.
  47. */
  48. void* getView() const;
  49. /** Resizes this component to fit the view that it contains. */
  50. void resizeToFitView();
  51. //==============================================================================
  52. /** @internal */
  53. void paint (Graphics&) override;
  54. /** @internal */
  55. void alphaChanged() override;
  56. /** @internal */
  57. static ReferenceCountedObject* attachViewToComponent (Component&, void*);
  58. private:
  59. ReferenceCountedObjectPtr<ReferenceCountedObject> attachment;
  60. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NSViewComponent)
  61. };
  62. #endif
  63. #endif // JUCE_NSVIEWCOMPONENT_H_INCLUDED