d77cc8ad46698e2ad0ec67b75687aff5e0b08dc0
[dcpomatic.git] / src / wx / preset_colour_conversion_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/statline.h>
21 #include "lib/colour_conversion.h"
22 #include "wx_util.h"
23 #include "preset_colour_conversion_dialog.h"
24 #include "colour_conversion_editor.h"
25 #include <iostream>
26
27 using std::string;
28 using std::cout;
29
30 PresetColourConversionDialog::PresetColourConversionDialog (wxWindow* parent)
31         : wxDialog (parent, wxID_ANY, _("Colour conversion"))
32         , _editor (new ColourConversionEditor (this, true))
33 {
34         wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
35         SetSizer (overall_sizer);
36
37         wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
38         table->AddGrowableCol (1, 1);
39         add_label_to_sizer (table, this, _("Name"), true);
40         _name = new wxTextCtrl (this, wxID_ANY, wxT (""));
41         table->Add (_name, 1, wxEXPAND | wxALL);
42
43         overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
44         overall_sizer->Add (new wxStaticLine (this, wxID_ANY), 0, wxEXPAND);
45         overall_sizer->Add (_editor);
46
47         wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
48         if (buttons) {
49                 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
50         }
51
52         overall_sizer->Layout ();
53         overall_sizer->SetSizeHints (this);
54 }
55
56 PresetColourConversion
57 PresetColourConversionDialog::get () const
58 {
59         PresetColourConversion pc;
60         pc.name = wx_to_std (_name->GetValue ());
61         pc.conversion = _editor->get ();
62         return pc;
63 }
64
65 void
66 PresetColourConversionDialog::set (PresetColourConversion c)
67 {
68         _name->SetValue (std_to_wx (c.name));
69         _editor->set (c.conversion);
70 }