Basic grunt-work, untested and unfinished, but it compiles.
[dcpomatic.git] / src / wx / subtitle_view.cc
1 /*
2     Copyright (C) 2014 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 "lib/text_subtitle_decoder.h"
22 #include "lib/content_subtitle.h"
23 #include "lib/film.h"
24 #include "lib/text_subtitle_content.h"
25 #include "subtitle_view.h"
26 #include "wx_util.h"
27
28 using std::list;
29 using boost::shared_ptr;
30 using boost::dynamic_pointer_cast;
31
32 SubtitleView::SubtitleView (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Decoder> decoder, DCPTime position)
33         : wxDialog (parent, wxID_ANY, _("Subtitles"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
34 {
35         _list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL);
36
37         {
38                 wxListItem ip;
39                 ip.SetId (0);
40                 ip.SetText (_("Start"));
41                 ip.SetWidth (100);
42                 _list->InsertColumn (0, ip);
43         }
44
45         {
46                 wxListItem ip;
47                 ip.SetId (1);
48                 ip.SetText (_("End"));
49                 ip.SetWidth (100);
50                 _list->InsertColumn (1, ip);
51         }
52
53         {
54                 wxListItem ip;
55                 ip.SetId (2);
56                 ip.SetText (_("Subtitle"));
57                 ip.SetWidth (640);
58                 _list->InsertColumn (2, ip);
59         }
60
61         wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
62         sizer->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
63
64         wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
65         if (buttons) {
66                 sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
67         }
68
69 #if 0
70         XXX
71
72         list<ContentTextSubtitle> subs = decoder->subtitle->get_text (ContentTimePeriod (ContentTime(), ContentTime::max ()), true, true);
73         FrameRateChange const frc = film->active_frame_rate_change (position);
74         int n = 0;
75         for (list<ContentTextSubtitle>::const_iterator i = subs.begin(); i != subs.end(); ++i) {
76                 for (list<dcp::SubtitleString>::const_iterator j = i->subs.begin(); j != i->subs.end(); ++j) {
77                         wxListItem list_item;
78                         list_item.SetId (n);
79                         _list->InsertItem (list_item);
80                         ContentTimePeriod const p = i->period ();
81                         _list->SetItem (n, 0, std_to_wx (p.from.timecode (frc.source)));
82                         _list->SetItem (n, 1, std_to_wx (p.to.timecode (frc.source)));
83                         _list->SetItem (n, 2, std_to_wx (j->text ()));
84                         ++n;
85                 }
86         }
87 #endif
88
89         SetSizerAndFit (sizer);
90 }