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