66a93305a865df091352a95cfedc1f44feb77331
[dcpomatic.git] / src / wx / rating_dialog.h
1 /*
2     Copyright (C) 2019-2022 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 <dcp/rating.h>
23 #include <dcp/warnings.h>
24 LIBDCP_DISABLE_WARNINGS
25 #include <wx/wx.h>
26 LIBDCP_ENABLE_WARNINGS
27 #include <boost/signals2.hpp>
28
29
30 class wxChoice;
31 class wxListView;
32 class wxNotebook;
33 class wxSearchCtrl;
34
35
36 class RatingDialogPage : public wxPanel
37 {
38 public:
39         RatingDialogPage (wxNotebook* notebook);
40         virtual dcp::Rating get () const = 0;
41         virtual bool set (dcp::Rating rating) = 0;
42
43         /** Emitted when the page has been changed, the parameter being true if OK
44          *  should now be enabled in the main dialogue.
45          */
46         boost::signals2::signal<void (bool)> Changed;
47 };
48
49
50 class StandardRatingDialogPage : public RatingDialogPage
51 {
52 public:
53         StandardRatingDialogPage (wxNotebook* notebook);
54
55         dcp::Rating get () const override;
56         bool set (dcp::Rating rating) override;
57
58 private:
59         void search_changed ();
60         void found_systems_view_selection_changed ();
61         void update_found_system_selection ();
62
63         wxSearchCtrl* _search;
64         wxListView* _found_systems_view;
65         boost::optional<dcp::RatingSystem> _selected_system;
66         wxChoice* _rating;
67         std::vector<dcp::RatingSystem> _found_systems;
68 };
69
70
71 class CustomRatingDialogPage : public RatingDialogPage
72 {
73 public:
74         CustomRatingDialogPage (wxNotebook* notebook);
75
76         dcp::Rating get () const override;
77         bool set (dcp::Rating rating) override;
78
79 private:
80         void changed ();
81
82         wxTextCtrl* _agency;
83         wxTextCtrl* _rating;
84 };
85
86
87 class RatingDialog : public wxDialog
88 {
89 public:
90         RatingDialog (wxWindow* parent);
91
92         void set (dcp::Rating r);
93         dcp::Rating get () const;
94
95 private:
96         void setup_sensitivity (bool ok_valid);
97         void page_changed ();
98
99         wxNotebook* _notebook;
100
101         StandardRatingDialogPage* _standard_page;
102         CustomRatingDialogPage* _custom_page;
103         RatingDialogPage* _active_page;
104 };
105