46e4cde12fa77d6ef5eba9bb0786e9fa4246fa31
[ardour.git] / gtk2_ardour / au_pluginui.h
1 #ifndef __gtk2_ardour_auplugin_ui_h__
2 #define __gtk2_ardour_auplugin_ui_h__
3
4 #include <AppKit/AppKit.h>
5 #include <Carbon/Carbon.h>
6 #include <AudioUnit/AudioUnit.h>
7
8 /* fix up stupid apple macros */
9
10 #undef check
11 #undef require
12 #undef verify
13
14 #include <gtkmm/box.h>
15 #include "plugin_ui.h"
16
17 namespace ARDOUR {
18         class AUPlugin;
19         class PluginInsert;
20         class Redirect;
21 }
22
23 class AUPluginUI : public PlugUIBase, public Gtk::VBox
24 {
25   public:
26         AUPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>);
27         ~AUPluginUI ();
28         
29         gint get_preferred_height () { return prefheight; }
30         gint get_preferred_width () { return prefwidth; }
31         bool start_updating(GdkEventAny*);
32         bool stop_updating(GdkEventAny*);
33         
34         virtual void activate ();
35         virtual void deactivate ();
36
37         void on_realize ();
38         void on_show ();
39         void on_hide ();
40         bool on_map_event (GdkEventAny*);
41         bool on_focus_in_event (GdkEventFocus*);
42         bool on_focus_out_event (GdkEventFocus*);
43
44         OSStatus carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event);
45
46   private:
47         boost::shared_ptr<ARDOUR::AUPlugin> au;
48         int prefheight;
49         int prefwidth;
50
51         /* Cocoa */
52
53         NSWindow*           cocoa_window;
54         NSScrollView*       scroll_view;
55         NSView*             au_view;
56
57         /* Carbon */
58
59         NSWindow*            cocoa_parent;
60         ComponentDescription carbon_descriptor;
61         AudioUnitCarbonView  editView;
62         WindowRef            carbon_window;     
63         EventHandlerRef      carbon_event_handler;
64         bool                 carbon_parented;
65         bool                 cocoa_parented;
66         bool                 _activating_from_app;
67
68         void test_view_support (bool&, bool&);
69         bool test_cocoa_view_support ();
70         bool test_carbon_view_support ();
71         int  create_carbon_view (bool generic);
72         int  create_cocoa_view ();
73
74         int parent_carbon_window ();
75         int parent_cocoa_window ();
76         NSWindow* get_nswindow();
77
78         bool plugin_class_valid (Class pluginClass);
79 };
80
81 #endif /* __gtk2_ardour_auplugin_ui_h__  */