Fix build for newer libdcp.
[dcpomatic.git] / src / wx / verify_dcp_dialog.cc
1 /*
2     Copyright (C) 2018 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 #include "verify_dcp_dialog.h"
22 #include "wx_util.h"
23 #include <dcp/verify.h>
24 #include <wx/richtext/richtextctrl.h>
25 #include <boost/foreach.hpp>
26
27 using std::list;
28
29 VerifyDCPDialog::VerifyDCPDialog (wxWindow* parent, list<dcp::VerificationNote> notes)
30         : wxDialog (parent, wxID_ANY, _("DCP verification"))
31 {
32         wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
33         _text = new wxRichTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (400, 300), wxRE_READONLY);
34         sizer->Add (_text, 1, wxEXPAND | wxALL, 6);
35
36         wxStdDialogButtonSizer* buttons = CreateStdDialogButtonSizer (0);
37         sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
38         buttons->SetAffirmativeButton (new wxButton (this, wxID_OK));
39         buttons->Realize ();
40
41         SetSizer (sizer);
42         sizer->Layout ();
43         sizer->SetSizeHints (this);
44
45         _text->GetCaret()->Hide ();
46
47         if (notes.empty ()) {
48                 _text->BeginStandardBullet (N_("standard/circle"), 1, 50);
49                 _text->WriteText (_("DCP validates OK."));
50                 _text->EndStandardBullet ();
51                 return;
52         }
53
54         BOOST_FOREACH (dcp::VerificationNote i, notes) {
55                 switch (i.type()) {
56                 case dcp::VerificationNote::VERIFY_NOTE:
57                         _text->BeginStandardBullet (N_("standard/circle"), 1, 50);
58                         break;
59                 case dcp::VerificationNote::VERIFY_WARNING:
60                         _text->BeginStandardBullet (N_("standard/diamond"), 1, 50);
61                         break;
62                 case dcp::VerificationNote::VERIFY_NOTE:
63                         _text->BeginSymbolBullet (N_("!"), 1, 50);
64                         break;
65                 }
66
67                 _text->WriteText (std_to_wx (i.note()));
68                 _text->Newline ();
69
70                 switch (i.type()) {
71                 case dcp::VerificationNote::VERIFY_NOTE:
72                 case dcp::VerificationNote::VERIFY_WARNING:
73                         _text->EndStandardBullet ();
74                         break;
75                 case dcp::VerificationNote::VERIFY_ERROR:
76                         _text->EndSymbolBullet ();
77                         break;
78                 }
79         }
80 }