Use libdcp's warnings.h
[dcpomatic.git] / src / wx / screens_panel.h
1 /*
2     Copyright (C) 2015-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/warnings.h>
23 LIBDCP_DISABLE_WARNINGS
24 #include <wx/srchctrl.h>
25 #include <wx/treelist.h>
26 #include <wx/wx.h>
27 LIBDCP_ENABLE_WARNINGS
28 #include <boost/signals2.hpp>
29 #include <list>
30 #include <map>
31 #include <set>
32
33
34 namespace dcpomatic {
35         class Screen;
36 }
37
38
39 class Cinema;
40 struct UCollator;
41
42
43 class ScreensPanel : public wxPanel
44 {
45 public:
46         explicit ScreensPanel (wxWindow* parent);
47         ~ScreensPanel ();
48
49         std::vector<std::shared_ptr<dcpomatic::Screen>> screens () const;
50         void setup_sensitivity ();
51
52         boost::signals2::signal<void ()> ScreensChanged;
53
54 private:
55         void add_cinemas ();
56         boost::optional<wxTreeListItem> add_cinema (std::shared_ptr<Cinema>, wxTreeListItem previous);
57         boost::optional<wxTreeListItem> add_screen (std::shared_ptr<Cinema>, std::shared_ptr<dcpomatic::Screen>);
58         void add_cinema_clicked ();
59         void edit_cinema_clicked ();
60         void remove_cinema_clicked ();
61         void add_screen_clicked ();
62         void edit_screen_clicked ();
63         void remove_screen_clicked ();
64         void selection_changed_shim (wxTreeListEvent &);
65         void selection_changed ();
66         void search_changed ();
67         void checkbox_changed (wxTreeListEvent& ev);
68         std::shared_ptr<Cinema> cinema_for_operation () const;
69         void set_screen_checked (wxTreeListItem item, bool checked);
70         void setup_cinema_checked_state (wxTreeListItem screen);
71         int compare (std::string const& utf8_a, std::string const& utf8_b);
72         void check_all ();
73         void uncheck_all ();
74
75         std::shared_ptr<Cinema> item_to_cinema (wxTreeListItem item) const;
76         std::shared_ptr<dcpomatic::Screen> item_to_screen (wxTreeListItem item) const;
77         boost::optional<wxTreeListItem> cinema_to_item (std::shared_ptr<Cinema> cinema) const;
78         boost::optional<wxTreeListItem> screen_to_item (std::shared_ptr<dcpomatic::Screen> screen) const;
79
80         wxSearchCtrl* _search;
81         wxTreeListCtrl* _targets;
82         wxButton* _add_cinema;
83         wxButton* _edit_cinema;
84         wxButton* _remove_cinema;
85         wxButton* _add_screen;
86         wxButton* _edit_screen;
87         wxButton* _remove_screen;
88         wxButton* _check_all;
89         wxButton* _uncheck_all;
90
91         /* We want to be able to search (and so remove selected things from the view)
92          * but not deselect them, so we maintain lists of selected cinemas and screens.
93          */
94         std::vector<std::shared_ptr<Cinema>> _selected_cinemas;
95         std::vector<std::shared_ptr<dcpomatic::Screen>> _selected_screens;
96         /* Likewise with checked screens, except that we can work out which cinemas
97          * are checked from which screens are checked, so we don't need to store the
98          * cinemas.
99          */
100         std::set<std::shared_ptr<dcpomatic::Screen>> _checked_screens;
101
102         std::map<wxTreeListItem, std::shared_ptr<Cinema>> _item_to_cinema;
103         std::map<wxTreeListItem, std::shared_ptr<dcpomatic::Screen>> _item_to_screen;
104         std::map<std::shared_ptr<Cinema>, wxTreeListItem> _cinema_to_item;
105         std::map<std::shared_ptr<dcpomatic::Screen>, wxTreeListItem> _screen_to_item;
106
107         bool _ignore_selection_change = false;
108         bool _ignore_check_change = false;
109
110         UCollator* _collator = nullptr;
111 };