2 Copyright (C) 2012 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.
21 #include "dcp_range_dialog.h"
24 DCPRangeDialog::DCPRangeDialog (wxWindow* p, Film* f)
25 : wxDialog (p, wxID_ANY, _("DCP Range"))
28 wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6);
30 _whole = new wxRadioButton (this, wxID_ANY, _("Whole film"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
31 table->Add (_whole, 1);
34 _first = new wxRadioButton (this, wxID_ANY, _("First"));
37 wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
38 _n_frames = new wxSpinCtrl (this, wxID_ANY);
40 add_label_to_sizer (s, this, "frames");
45 _cut = new wxRadioButton (this, wxID_ANY, _("Cut remainder"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
49 _black_out = new wxRadioButton (this, wxID_ANY, _("Black-out remainder"));
50 table->Add (_black_out);
52 _n_frames->SetRange (1, INT_MAX - 1);
53 if (_film->dcp_frames() > 0) {
54 _whole->SetValue (false);
55 _first->SetValue (true);
56 _n_frames->SetValue (_film->dcp_frames ());
58 _whole->SetValue (true);
59 _first->SetValue (false);
60 _n_frames->SetValue (24);
63 _black_out->Enable (_film->dcp_trim_action() == BLACK_OUT);
64 _cut->Enable (_film->dcp_trim_action() == CUT);
66 _whole->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::whole_toggled), 0, this);
67 _first->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::first_toggled), 0, this);
68 _cut->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (DCPRangeDialog::cut_toggled), 0, this);
69 _n_frames->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (DCPRangeDialog::n_frames_changed), 0, this);
71 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
72 overall_sizer->Add (table);
74 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
76 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
79 SetSizer (overall_sizer);
80 overall_sizer->SetSizeHints (this);
86 DCPRangeDialog::whole_toggled (wxCommandEvent &)
93 DCPRangeDialog::first_toggled (wxCommandEvent &)
100 DCPRangeDialog::set_sensitivity ()
102 _n_frames->Enable (_first->GetValue ());
103 _black_out->Enable (_first->GetValue ());
104 _cut->Enable (_first->GetValue ());
108 DCPRangeDialog::cut_toggled (wxCommandEvent &)
115 DCPRangeDialog::n_frames_changed (wxCommandEvent &)
121 DCPRangeDialog::emit_changed ()
124 if (!_whole->GetValue ()) {
125 frames = _n_frames->GetValue ();
128 TrimAction action = CUT;
129 if (_black_out->GetValue ()) {
133 Changed (frames, action);