Build fixes for Boost >= 1.73
[dcpomatic.git] / src / wx / content_widget.h
index e5125680bcfe59bfa607cf08af79044392190b0b..52a5e5851a9b09ecaef7bcea415b1c7b66007be5 100644 (file)
@@ -52,6 +52,7 @@ public:
         *  @param part Part of Content that the property is in (e.g. &Content::video)
         *  @param model_getter Function on the Content to get the value.
         *  @param model_setter Function on the Content to set the value.
+        *  @param view_changed Function called when the view has changed; useful for linking controls.
         *  @param view_to_model Function to convert a view value to a model value.
         *  @param model_to_view Function to convert a model value to a view value.
         */
@@ -62,6 +63,7 @@ public:
                boost::function<boost::shared_ptr<S> (Content*)> part,
                boost::function<U (S*)> model_getter,
                boost::function<void (S*, U)> model_setter,
+               boost::function<void ()> view_changed,
                boost::function<U (V)> view_to_model,
                boost::function<V (U)> model_to_view
                )
@@ -72,6 +74,7 @@ public:
                , _part (part)
                , _model_getter (model_getter)
                , _model_setter (model_setter)
+               , _view_changed (view_changed)
                , _view_to_model (view_to_model)
                , _model_to_view (model_to_view)
                , _ignore_model_changes (false)
@@ -105,7 +108,11 @@ public:
                update_from_model ();
 
                for (typename List::iterator i = _content.begin(); i != _content.end(); ++i) {
+#if BOOST_VERSION >= 106100
+                       _connections.push_back ((*i)->Change.connect (boost::bind (&ContentWidget::model_changed, this, boost::placeholders::_1, boost::placeholders::_3)));
+#else
                        _connections.push_back ((*i)->Change.connect (boost::bind (&ContentWidget::model_changed, this, _1, _3)));
+#endif
                }
        }
 
@@ -146,14 +153,22 @@ public:
                for (size_t i = 0; i < _content.size(); ++i) {
                        boost::bind (_model_setter, _part (_content[i].get()).get(), _view_to_model (wx_get (_wrapped))) ();
                }
+               if (_view_changed) {
+                       _view_changed ();
+               }
                _ignore_model_changes = false;
        }
 
+       void show (bool s)
+       {
+               _wrapped->Show (s);
+       }
+
 private:
 
        void set_single ()
        {
-               if (_wrapped->IsShown ()) {
+               if (_wrapped->IsShown() || !_sizer) {
                        return;
                }
 
@@ -166,7 +181,7 @@ private:
 
        void set_multiple ()
        {
-               if (_button->IsShown ()) {
+               if (_button->IsShown() || !_sizer) {
                        return;
                }
 
@@ -202,6 +217,7 @@ private:
        boost::function<boost::shared_ptr<S> (Content *)> _part;
        boost::function<U (S*)> _model_getter;
        boost::function<void (S*, U)> _model_setter;
+       boost::function<void ()> _view_changed;
        boost::function<U (V)> _view_to_model;
        boost::function<V (U)> _model_to_view;
        std::list<boost::signals2::connection> _connections;
@@ -224,7 +240,8 @@ public:
                int property,
                boost::function<boost::shared_ptr<S> (Content *)> part,
                boost::function<int (S*)> getter,
-               boost::function<void (S*, int)> setter
+               boost::function<void (S*, int)> setter,
+               boost::function<void ()> view_changed = boost::function<void ()>()
                )
                : ContentWidget<S, wxSpinCtrl, int, int> (
                        parent,
@@ -232,6 +249,7 @@ public:
                        property,
                        part,
                        getter, setter,
+                       view_changed,
                        &caster<int, int>,
                        &caster<int, int>
                        )
@@ -250,7 +268,8 @@ public:
                int property,
                boost::function<boost::shared_ptr<S> (Content *)> part,
                boost::function<double (S*)> getter,
-               boost::function<void (S*, double)> setter
+               boost::function<void (S*, double)> setter,
+               boost::function<void ()> view_changed = boost::function<void ()>()
                )
                : ContentWidget<S, wxSpinCtrlDouble, double, double> (
                        parent,
@@ -258,6 +277,7 @@ public:
                        property,
                        part,
                        getter, setter,
+                       view_changed,
                        &caster<double, double>,
                        &caster<double, double>
                        )
@@ -278,7 +298,8 @@ public:
                boost::function<U (S*)> getter,
                boost::function<void (S*, U)> setter,
                boost::function<U (int)> view_to_model,
-               boost::function<int (U)> model_to_view
+               boost::function<int (U)> model_to_view,
+               boost::function<void ()> view_changed = boost::function<void()>()
                )
                : ContentWidget<S, wxChoice, U, int> (
                        parent,
@@ -287,6 +308,7 @@ public:
                        part,
                        getter,
                        setter,
+                       view_changed,
                        view_to_model,
                        model_to_view
                        )