make ardour3 build and link on OS X (tiger, at least)
[ardour.git] / gtk2_ardour / au_pluginui.h
1 #ifndef __gtk2_ardour_auplugin_ui_h__
2 #define __gtk2_ardour_auplugin_ui_h__
3
4 #include <vector>
5 #include <string>
6
7 #include <AppKit/AppKit.h>
8 #include <Carbon/Carbon.h>
9 #include <AudioUnit/AudioUnitCarbonView.h>
10 #include <AudioUnit/AudioUnit.h>
11
12 /* fix up stupid apple macros */
13
14 #undef check
15 #undef require
16 #undef verify
17
18 #include <gtkmm/box.h>
19 #include <gtkmm/combobox.h>
20 #include <gtkmm/button.h>
21 #include <gtkmm/label.h>
22
23 #include "plugin_ui.h"
24
25 namespace ARDOUR {
26         class AUPlugin;
27         class PluginInsert;
28         class IOProcessor;
29 }
30
31 class AUPluginUI;
32
33 @interface NotificationObject : NSObject {
34         @private
35                 AUPluginUI* plugin_ui;
36                 NSWindow* cocoa_parent;
37                 NSWindow* top_level_parent;
38 }
39 @end
40
41 class AUPluginUI : public PlugUIBase, public Gtk::VBox
42 {
43   public:
44         AUPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>);
45         ~AUPluginUI ();
46
47         gint get_preferred_height () { return prefheight; }
48         gint get_preferred_width () { return prefwidth; }
49         bool start_updating(GdkEventAny*);
50         bool stop_updating(GdkEventAny*);
51
52         void activate ();
53         void deactivate ();
54
55         bool non_gtk_gui() const { return true; }
56
57         void lower_box_realized ();
58         void cocoa_view_resized ();
59         void on_realize ();
60         void on_show ();
61         void on_hide ();
62         bool on_map_event (GdkEventAny*);
63         bool on_focus_in_event (GdkEventFocus*);
64         bool on_focus_out_event (GdkEventFocus*);
65         void forward_key_event (GdkEventKey*);
66
67         bool on_window_show (const std::string& /*title*/);
68         void on_window_hide ();
69
70         OSStatus carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event);
71
72   private:
73         WindowRef wr;
74         boost::shared_ptr<ARDOUR::AUPlugin> au;
75         int prefheight;
76         int prefwidth;
77
78         Gtk::HBox     top_box;
79         Gtk::EventBox low_box;
80         Gtk::VBox vpacker;
81         Gtk::Label automation_mode_label;
82         Gtk::ComboBoxText automation_mode_selector;
83         Gtk::Label preset_label;
84
85         static std::vector<std::string> automation_mode_strings;
86
87         /* Cocoa */
88
89         NSWindow*           cocoa_window;
90         NSView*             au_view;
91
92         /* Carbon */
93
94         NSWindow*            cocoa_parent;
95         ComponentDescription carbon_descriptor;
96         AudioUnitCarbonView  editView;
97         WindowRef            carbon_window;
98         EventHandlerRef      carbon_event_handler;
99         bool                 _activating_from_app;
100         NotificationObject* _notify;
101
102         bool test_cocoa_view_support ();
103         bool test_carbon_view_support ();
104         int  create_carbon_view ();
105         int  create_cocoa_view ();
106
107         int parent_carbon_window ();
108         int parent_cocoa_window ();
109         NSWindow* get_nswindow();
110
111         bool plugin_class_valid (Class pluginClass);
112 };
113
114 #endif /* __gtk2_ardour_auplugin_ui_h__  */