From 9ab042cfd1980504010644a1870573c9aac670c7 Mon Sep 17 00:00:00 2001 From: VKamyshniy Date: Tue, 24 Jun 2014 19:06:00 +0300 Subject: [PATCH] [Summary] Adding support of Gtk::Entry, Gtk::Box. Improving code style. --- gtk2_ardour/waves_ui.cc | 28 ++++++++++++++++++++++++++-- gtk2_ardour/waves_ui.h | 6 ++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/waves_ui.cc b/gtk2_ardour/waves_ui.cc index 2f977675fa..f4946bcd3b 100644 --- a/gtk2_ardour/waves_ui.cc +++ b/gtk2_ardour/waves_ui.cc @@ -33,7 +33,7 @@ using namespace ARDOUR; std::map WavesUI::__xml_tree_cache; -WavesUI::WavesUI (std::string layout_script_file, Gtk::Container& root) +WavesUI::WavesUI (const std::string& layout_script_file, Gtk::Container& root) : _xml_tree (NULL) { // To avoid a need of reading the same file many times: @@ -287,7 +287,7 @@ WavesUI::create_ui (const XMLTree& layout, Gtk::Container& root) } const XMLTree* -WavesUI::load_layout (const std::string xml_file_name) +WavesUI::load_layout (const std::string& xml_file_name) { std::map::const_iterator it = __xml_tree_cache.find(xml_file_name); if (it != __xml_tree_cache.end()) { @@ -478,6 +478,19 @@ WavesUI::get_adjustment(const char* id) return *child; } + +Gtk::Box& +WavesUI::get_box (const char* id) +{ + Gtk::Box* child = dynamic_cast (get_object(id)); + if (child == NULL ) { + dbg_msg (std::string("Gtk::Box ") + id + " not found !"); + throw std::exception(); + } + return *child; +} + + Gtk::VBox& WavesUI::get_v_box (const char* id) { @@ -538,6 +551,17 @@ WavesUI::get_combo_box_text (const char* id) } +Gtk::Entry& +WavesUI::get_entry(const char* id) +{ + Gtk::Entry* child = dynamic_cast (get_object(id)); + if (child == NULL ) { + dbg_msg (std::string("Gtk::Entry ") + id + " not found !"); + throw std::exception(); + } + return *child; +} + WavesButton& WavesUI::get_waves_button (const char* id) { diff --git a/gtk2_ardour/waves_ui.h b/gtk2_ardour/waves_ui.h index 86fdadad8f..aa1a56dd10 100644 --- a/gtk2_ardour/waves_ui.h +++ b/gtk2_ardour/waves_ui.h @@ -39,15 +39,17 @@ using namespace ArdourCanvas::XMLUI; class WavesUI : public std::map { public: - WavesUI (std::string layout_script_file, Gtk::Container& root); + WavesUI (const std::string& layout_script_file, Gtk::Container& root); Gtk::Adjustment& get_adjustment (const char* id); + Gtk::Box& get_box (const char* id); Gtk::VBox& get_v_box (const char* id); Gtk::HBox& get_h_box (const char* id); Gtk::Layout& get_layout (const char* id); Gtk::Label& get_label (const char* id); Gtk::Image& get_image (const char* id); Gtk::ComboBoxText& get_combo_box_text (const char* id); + Gtk::Entry& get_entry(const char* id); WavesButton& get_waves_button (const char* id); Gtkmm2ext::Fader& get_fader (const char* id); const XMLTree* xml_tree() { return _xml_tree; } @@ -60,7 +62,7 @@ class WavesUI : public std::map { const XMLTree* _xml_tree; Gtk::Object* get_object(const char *id); - const XMLTree* load_layout (const std::string xml_file_name); + const XMLTree* load_layout (const std::string& xml_file_name); void create_ui (const XMLTree& layout, Gtk::Container& root); void create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk::Container& root); Gtk::Widget* create_widget (const XMLNode& definition, const XMLNodeMap& styles);