Supporters update.
[dcpomatic.git] / src / wx / invalid_certificate_period_dialog.cc
1 /*
2     Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic 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.
10
11     DCP-o-matic 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.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "invalid_certificate_period_dialog.h"
23 #include "wx_util.h"
24 #include "lib/kdm_util.h"
25 #include <dcp/warnings.h>
26 LIBDCP_DISABLE_WARNINGS
27 #include <wx/listctrl.h>
28 #include <wx/scrolwin.h>
29 LIBDCP_ENABLE_WARNINGS
30
31
32 InvalidCertificatePeriodDialog::InvalidCertificatePeriodDialog(wxWindow* parent, std::vector<KDMCertificatePeriod> const& periods)
33         : wxDialog(parent, wxID_ANY, _("Invalid certificates"))
34         , _list(new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT))
35 {
36         {
37                 wxListItem ip;
38                 ip.SetId(0);
39                 ip.SetText(_("Cinema"));
40                 ip.SetWidth(200);
41                 _list->InsertColumn(0, ip);
42         }
43
44         {
45                 wxListItem ip;
46                 ip.SetId(1);
47                 ip.SetText(_("Screen"));
48                 ip.SetWidth(50);
49                 _list->InsertColumn(1, ip);
50         }
51
52         {
53                 wxListItem ip;
54                 ip.SetId(2);
55                 ip.SetText(_("Certificate start"));
56                 ip.SetWidth(200);
57                 _list->InsertColumn(2, ip);
58         }
59
60         {
61                 wxListItem ip;
62                 ip.SetId(3);
63                 ip.SetText(_("Certificate end"));
64                 ip.SetWidth(200);
65                 _list->InsertColumn(3, ip);
66         }
67
68         int id = 0;
69         for (auto const& period: periods) {
70                 wxListItem item;
71                 item.SetId(id);
72                 _list->InsertItem(item);
73                 _list->SetItem(0, 0, std_to_wx(period.cinema_name));
74                 _list->SetItem(0, 1, std_to_wx(period.screen_name));
75                 _list->SetItem(0, 2, std_to_wx(period.from.as_string()));
76                 _list->SetItem(0, 3, std_to_wx(period.to.as_string()));
77         }
78
79         auto overall_sizer = new wxBoxSizer(wxVERTICAL);
80
81         auto constexpr width = 700;
82
83         auto question = new wxStaticText(this, wxID_ANY, _("Some KDMs would have validity periods which are outside the recipient certificate validity periods.  What do you want to do?"));
84         question->Wrap(width);
85         overall_sizer->Add(
86                 question,
87                 0,
88                 wxALL,
89                 DCPOMATIC_DIALOG_BORDER
90                 );
91
92         _list->SetSize({width, -1});
93         overall_sizer->Add(_list, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER);
94
95         auto buttons = CreateStdDialogButtonSizer(0);
96         if (buttons) {
97                 overall_sizer->Add(CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
98                 buttons->SetAffirmativeButton(new wxButton(this, wxID_OK, _("Create KDMs anyway")));
99                 buttons->SetCancelButton(new wxButton(this, wxID_CANCEL, _("Cancel")));
100                 buttons->Realize();
101         }
102
103         overall_sizer->Layout();
104         SetSizerAndFit(overall_sizer);
105 }
106