3cb5a4c2064d4cf4d8cbdca75a84615a6c56fb7c from master; use j2c_uuid and pcm_uuid for...
[dcpomatic.git] / src / wx / content_widget.h
index 8b76160443fd0cf31fe34e75e710ec0faf5a3d64..6f406dadbc926e92c094b74d53366327b6d08093 100644 (file)
@@ -27,6 +27,7 @@
 #include <vector>
 #include <wx/wx.h>
 #include <wx/gbsizer.h>
+#include <wx/spinctrl.h>
 #include <boost/function.hpp>
 #include "wx_util.h"
 
@@ -40,7 +41,7 @@
  *  @param V Data type of state as used by the view.
  */
 template <class S, class T, typename U, typename V>
-class ContentWidget
+class ContentWidget : public boost::noncopyable
 {
 public:
        /** @param parent Parent window.
@@ -102,11 +103,12 @@ public:
        }
 
        /** Add this widget to a wxGridBagSizer */
-       void add (wxGridBagSizer* sizer, wxGBPosition position)
+       void add (wxGridBagSizer* sizer, wxGBPosition position, wxGBSpan span = wxDefaultSpan)
        {
                _sizer = sizer;
                _position = position;
-               _sizer->Add (_wrapped, _position);
+               _span = span;
+               _sizer->Add (_wrapped, _position, _span);
        }
 
        /** Update the view from the model */
@@ -150,7 +152,7 @@ private:
 
                _sizer->Detach (_button);
                _button->Hide ();
-               _sizer->Add (_wrapped, _position);
+               _sizer->Add (_wrapped, _position, _span);
                _wrapped->Show ();
                _sizer->Layout ();
        }
@@ -164,7 +166,7 @@ private:
                _wrapped->Hide ();
                _sizer->Detach (_wrapped);
                _button->Show ();
-               _sizer->Add (_button, _position);
+               _sizer->Add (_button, _position, _span);
                _sizer->Layout ();
        }
 
@@ -186,6 +188,7 @@ private:
        T* _wrapped;
        wxGridBagSizer* _sizer;
        wxGBPosition _position;
+       wxGBSpan _span;
        wxButton* _button;
        List _content;
        int _property;
@@ -227,6 +230,30 @@ public:
        }
 };
 
+template <class S>
+class ContentSpinCtrlDouble : public ContentWidget<S, wxSpinCtrlDouble, double, double>
+{
+public:
+       ContentSpinCtrlDouble (
+               wxWindow* parent,
+               wxSpinCtrlDouble* wrapped,
+               int property,
+               boost::function<double (S*)> getter,
+               boost::function<void (S*, double)> setter
+               )
+               : ContentWidget<S, wxSpinCtrlDouble, double, double> (
+                       parent,
+                       wrapped,
+                       property,
+                       getter, setter,
+                       &caster<double, double>,
+                       &caster<double, double>
+                       )
+       {
+               wrapped->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ContentWidget<S, wxSpinCtrlDouble, double, double>::view_changed, this));
+       }
+};
+
 template <class S, class U>
 class ContentChoice : public ContentWidget<S, wxChoice, U, int>
 {