merge 3.0 from 2.0-ongoing@3243
[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 : public PlugUIBase, public Gtk::VBox
32 {
33   public:
34         AUPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>);
35         ~AUPluginUI ();
36         
37         gint get_preferred_height () { return prefheight; }
38         gint get_preferred_width () { return prefwidth; }
39         bool start_updating(GdkEventAny*);
40         bool stop_updating(GdkEventAny*);
41         
42         void activate ();
43         void deactivate ();
44
45         void lower_box_realized ();
46         void on_realize ();
47         void on_show ();
48         void on_hide ();
49         bool on_map_event (GdkEventAny*);
50         bool on_focus_in_event (GdkEventFocus*);
51         bool on_focus_out_event (GdkEventFocus*);
52
53         OSStatus carbon_event (EventHandlerCallRef nextHandlerRef, EventRef event);
54
55   private:
56         WindowRef wr;
57         boost::shared_ptr<ARDOUR::AUPlugin> au;
58         int prefheight;
59         int prefwidth;
60
61         Gtk::HBox     top_box;
62         Gtk::EventBox low_box;
63         Gtk::VBox vpacker;
64         Gtk::Label automation_mode_label;
65         Gtk::ComboBoxText automation_mode_selector;
66         Gtk::Label preset_label;
67
68         static std::vector<std::string> automation_mode_strings;
69
70         /* Cocoa */
71
72         NSWindow*           cocoa_window;
73         NSScrollView*       scroll_view;
74         NSView*             au_view;
75
76         /* Carbon */
77
78         NSWindow*            cocoa_parent;
79         ComponentDescription carbon_descriptor;
80         AudioUnitCarbonView  editView;
81         WindowRef            carbon_window;     
82         EventHandlerRef      carbon_event_handler;
83         bool                 _activating_from_app;
84         NSView*              packView;
85
86         bool test_cocoa_view_support ();
87         bool test_carbon_view_support ();
88         int  create_carbon_view ();
89         int  create_cocoa_view ();
90
91         int parent_carbon_window ();
92         int parent_cocoa_window ();
93         NSWindow* get_nswindow();
94
95         bool plugin_class_valid (Class pluginClass);
96 };
97
98 #endif /* __gtk2_ardour_auplugin_ui_h__  */