No-op; rename a whole load of wx constants to their shorter equivalents.
[dcpomatic.git] / src / wx / hints_dialog.cc
1 /*
2     Copyright (C) 2012-2016 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 "hints_dialog.h"
22 #include "wx_util.h"
23 #include "lib/film.h"
24 #include "lib/hints.h"
25 #include "lib/config.h"
26 #include <wx/richtext/richtextctrl.h>
27 #include <boost/foreach.hpp>
28
29 using std::max;
30 using std::vector;
31 using std::string;
32 using boost::shared_ptr;
33 using boost::optional;
34 using boost::dynamic_pointer_cast;
35
36 HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr<Film> film, bool ok)
37         : wxDialog (parent, wxID_ANY, _("Hints"))
38         , _film (film)
39 {
40         wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
41         _text = new wxRichTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (400, 300), wxRE_READONLY);
42         sizer->Add (_text, 1, wxEXPAND | wxALL, 6);
43
44         if (!ok) {
45                 wxCheckBox* b = new wxCheckBox (this, wxID_ANY, _("Don't show hints again"));
46                 sizer->Add (b, 0, wxALL, 6);
47                 b->Bind (wxEVT_CHECKBOX, bind (&HintsDialog::shut_up, this, _1));
48         }
49
50         wxStdDialogButtonSizer* buttons = CreateStdDialogButtonSizer (0);
51         sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
52         if (ok) {
53                 buttons->SetAffirmativeButton (new wxButton (this, wxID_OK));
54         } else {
55                 buttons->SetAffirmativeButton (new wxButton (this, wxID_OK, _("Make DCP anyway")));
56                 buttons->SetNegativeButton (new wxButton (this, wxID_CANCEL, _("Go back")));
57         }
58
59         buttons->Realize ();
60
61         SetSizer (sizer);
62         sizer->Layout ();
63         sizer->SetSizeHints (this);
64
65         _text->GetCaret()->Hide ();
66
67         boost::shared_ptr<Film> locked_film = _film.lock ();
68         if (locked_film) {
69                 _film_changed_connection = locked_film->Changed.connect (boost::bind (&HintsDialog::film_changed, this));
70                 _film_content_changed_connection = locked_film->ContentChanged.connect (boost::bind (&HintsDialog::film_changed, this));
71         }
72
73         film_changed ();
74 }
75
76 void
77 HintsDialog::film_changed ()
78 {
79         _text->Clear ();
80
81         boost::shared_ptr<Film> film = _film.lock ();
82         if (!film) {
83                 return;
84         }
85
86         vector<string> hints = get_hints (film);
87
88         if (hints.empty ()) {
89                 _text->WriteText (_("There are no hints: everything looks good!"));
90         } else {
91                 _text->BeginStandardBullet (N_("standard/circle"), 1, 50);
92                 BOOST_FOREACH (string i, hints) {
93                         _text->WriteText (std_to_wx (i));
94                         _text->Newline ();
95                 }
96                 _text->EndSymbolBullet ();
97         }
98 }
99
100 void
101 HintsDialog::shut_up (wxCommandEvent& ev)
102 {
103         Config::instance()->set_show_hints_before_make_dcp (!ev.IsChecked());
104 }