Factor out some common stuff and give a better tooltip on the 'refer' buttons when...
[dcpomatic.git] / src / wx / content_sub_panel.cc
1 /*
2     Copyright (C) 2012-2014 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 "content_sub_panel.h"
21 #include "content_panel.h"
22 #include "wx_util.h"
23 #include <wx/notebook.h>
24 #include <boost/foreach.hpp>
25
26 using std::list;
27 using std::string;
28 using boost::shared_ptr;
29
30 ContentSubPanel::ContentSubPanel (ContentPanel* p, wxString name)
31         : wxPanel (p->notebook(), wxID_ANY)
32         , _parent (p)
33         , _sizer (new wxBoxSizer (wxVERTICAL))
34 {
35         p->notebook()->AddPage (this, name, false);
36         SetSizer (_sizer);
37 }
38
39 void
40 ContentSubPanel::setup_refer_button (wxCheckBox* button, shared_ptr<DCPContent> dcp, bool can_reference, list<string> why_not) const
41 {
42         button->Enable (can_reference);
43
44         wxString s;
45         if (!dcp) {
46                 s = _("No DCP selected.");
47         } else if (!can_reference) {
48                 s = _("Cannot reference this DCP.  ");
49                 BOOST_FOREACH (string i, why_not) {
50                         s += std_to_wx(i) + wxT("  ");
51                 }
52         }
53         button->SetToolTip (s);
54 }