X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fcontent_widget.h;h=3fa1f0ddc20c168d6d45d0cdf773c2d872f93db9;hb=aeb835a18c8df347e0ed68fb24631b320abeb611;hp=8b76160443fd0cf31fe34e75e710ec0faf5a3d64;hpb=26daeb63ed25a161a3911d715a04535a102d632a;p=dcpomatic.git diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h index 8b7616044..3fa1f0ddc 100644 --- a/src/wx/content_widget.h +++ b/src/wx/content_widget.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "wx_util.h" @@ -40,7 +41,7 @@ * @param V Data type of state as used by the view. */ template -class ContentWidget +class ContentWidget : public boost::noncopyable { public: /** @param parent Parent window. @@ -89,7 +90,7 @@ public: } _connections.clear (); - + _content = content; _wrapped->Enable (!_content.empty ()); @@ -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 */ @@ -139,9 +141,9 @@ public: } _ignore_model_changes = false; } - + private: - + void set_single () { if (_wrapped->IsShown ()) { @@ -150,7 +152,7 @@ private: _sizer->Detach (_button); _button->Hide (); - _sizer->Add (_wrapped, _position); + _sizer->Add (_wrapped, _position, _span); _wrapped->Show (); _sizer->Layout (); } @@ -160,11 +162,11 @@ private: if (_button->IsShown ()) { return; } - + _wrapped->Hide (); _sizer->Detach (_wrapped); _button->Show (); - _sizer->Add (_button, _position); + _sizer->Add (_button, _position, _span); _sizer->Layout (); } @@ -182,10 +184,11 @@ private: update_from_model (); } } - + T* _wrapped; wxGridBagSizer* _sizer; wxGBPosition _position; + wxGBSpan _span; wxButton* _button; List _content; int _property; @@ -227,6 +230,30 @@ public: } }; +template +class ContentSpinCtrlDouble : public ContentWidget +{ +public: + ContentSpinCtrlDouble ( + wxWindow* parent, + wxSpinCtrlDouble* wrapped, + int property, + boost::function getter, + boost::function setter + ) + : ContentWidget ( + parent, + wrapped, + property, + getter, setter, + &caster, + &caster + ) + { + wrapped->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ContentWidget::view_changed, this)); + } +}; + template class ContentChoice : public ContentWidget {