Merge master.
[dcpomatic.git] / src / wx / imagemagick_content_dialog.cc
1 /*
2     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include <wx/spinctrl.h>
21 #include "lib/imagemagick_content.h"
22 #include "imagemagick_content_dialog.h"
23 #include "wx_util.h"
24
25 using boost::shared_ptr;
26
27 ImageMagickContentDialog::ImageMagickContentDialog (wxWindow* parent, shared_ptr<ImageMagickContent> content)
28         : wxDialog (parent, wxID_ANY, _("Image"))
29 {
30         wxFlexGridSizer* grid = new wxFlexGridSizer (3, 6, 6);
31         grid->AddGrowableCol (1, 1);
32
33         {
34                 add_label_to_sizer (grid, this, (_("Duration")));
35                 wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
36                 _video_length = new wxSpinCtrl (this);
37                 s->Add (_video_length);
38                 /// TRANSLATORS: this is an abbreviation for seconds, the unit of time
39                 add_label_to_sizer (s, this, _("s"));
40                 grid->Add (s);
41         }
42
43         wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
44         overall_sizer->Add (grid, 1, wxEXPAND | wxALL, 6);
45
46         wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
47         if (buttons) {
48                 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
49         }
50
51         SetSizer (overall_sizer);
52         overall_sizer->Layout ();
53         overall_sizer->SetSizeHints (this);
54
55         checked_set (_video_length, content->video_length () / 24);
56 }
57
58 int
59 ImageMagickContentDialog::video_length () const
60 {
61         return _video_length->GetValue ();
62 }