move utility functions into a dedicated namespace
[ardour.git] / gtk2_ardour / big_clock_window.cc
index b080167d345cdb22f74e8258ac286aeaa5b72797..28b7b286ab075dedfe478f91c0f11bf72c913cda 100644 (file)
 
 */
 
-#ifdef WAF_BUILD
-#include "gtk2ardour-config.h"
-#endif
+#include <algorithm>
+#include <string>
+#include <vector>
 
-#include "big_clock_window.h"
+#include "ardour_ui.h"
 #include "audio_clock.h"
+#include "big_clock_window.h"
+#include "public_editor.h"
+#include "utils.h"
 
 #include "i18n.h"
 
+using std::min;
+using std::string;
+using namespace ARDOUR_UI_UTILS;
 
 BigClockWindow::BigClockWindow (AudioClock& c) 
        : ArdourWindow (_("Big Clock"))
        , clock (c)
        , resize_in_progress (false)
+       , original_height (0)
+       , original_width (0)
+       , original_font_size (0)
 {
        ARDOUR_UI::Clock.connect (sigc::mem_fun (clock, &AudioClock::set));
 
        clock.set_corner_radius (0.0);
        clock.mode_changed.connect (sigc::mem_fun (*this, &BigClockWindow::reset_aspect_ratio));
 
-       win->set_keep_above (true);
-       win->set_border_width (0);
-       win->add (*clock);
+       set_keep_above (true);
+       set_border_width (0);
+       add (clock);
+       clock.show_all ();
 }
 
 void
 BigClockWindow::on_unmap ()
 {
+       ArdourWindow::on_unmap ();
+
        PublicEditor::instance().reset_focus ();
 }
 
 bool
 BigClockWindow::on_key_press_event (GdkEventKey* ev)
 {
-       return relay_key_press (ev);
+       return relay_key_press (ev, this);
 }
 
 void
@@ -82,23 +94,12 @@ BigClockWindow::on_size_allocate (Gtk::Allocation& alloc)
 {
        ArdourWindow::on_size_allocate (alloc);
 
-       if (!big_clock_resize_in_progress) {
+       if (!resize_in_progress) {
                Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &BigClockWindow::text_resizer), 0, 0));
                resize_in_progress = true;
        }
 }
 
-void
-BigClockWindow::float (Gtk::Window* parent)
-{
-       if (parent) {
-               set_transient_for (*parent);
-       } else {
-               /* Gtkmm doesn't allow a call to this for a null parent */
-               gtk_window_set_transient_for (big_clock_window->gobj(), (GtkWindow*) 0);
-       }
-}
-
 void
 BigClockWindow::reset_aspect_ratio ()
 {
@@ -139,11 +140,11 @@ BigClockWindow::text_resizer (int, int)
        if (size != current_size) {
 
                string family = fd.get_family();
-               char buf[family.length()+16];
-               snprintf (buf, family.length()+16, "%s %d", family.c_str(), size);
+               std::vector<char> buf(family.length()+16);
+               snprintf (&buf[0], family.length()+16, "%s %d", family.c_str(), size);
 
                try {
-                       Pango::FontDescription fd (buf);
+                       Pango::FontDescription fd (&buf[0]);
                        Glib::RefPtr<Gtk::RcStyle> rcstyle = clock.get_modifier_style ();
                        rcstyle->set_font (fd);
                        clock.modify_style (rcstyle);