2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <wx/spinctrl.h>
21 #include "lib/imagemagick_content.h"
22 #include "imagemagick_content_dialog.h"
25 using boost::shared_ptr;
26 using boost::dynamic_pointer_cast;
28 ImageMagickContentDialog::ImageMagickContentDialog (wxWindow* parent, shared_ptr<ImageMagickContent> content)
29 : wxDialog (parent, wxID_ANY, _("Image"))
32 wxFlexGridSizer* grid = new wxFlexGridSizer (3, 6, 6);
33 grid->AddGrowableCol (1, 1);
36 add_label_to_sizer (grid, this, (_("Duration")));
37 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
38 _video_length = new wxSpinCtrl (this);
39 s->Add (_video_length);
40 /// TRANSLATORS: this is an abbreviation for seconds, the unit of time
41 add_label_to_sizer (s, this, _("s"));
45 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
46 overall_sizer->Add (grid, 1, wxEXPAND | wxALL, 6);
48 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
50 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
53 SetSizer (overall_sizer);
54 overall_sizer->Layout ();
55 overall_sizer->SetSizeHints (this);
57 checked_set (_video_length, content->video_length () / 24);
58 _video_length->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (ImageMagickContentDialog::video_length_changed), 0, this);
62 ImageMagickContentDialog::video_length_changed (wxCommandEvent &)
64 shared_ptr<ImageMagickContent> c = _content.lock ();
69 c->set_video_length (_video_length->GetValue() * 24);