1 /* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
4 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
6 This program 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.
11 This program 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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <boost/lexical_cast.hpp>
24 #include <boost/bind.hpp>
26 #include "lib/config.h"
27 #include "properties_dialog.h"
31 using std::stringstream;
33 using std::setprecision;
34 using boost::shared_ptr;
35 using boost::lexical_cast;
37 PropertiesDialog::PropertiesDialog (wxWindow* parent, shared_ptr<Film> film)
38 : wxDialog (parent, wxID_ANY, _("Film Properties"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
41 wxFlexGridSizer* table = new wxFlexGridSizer (2, 3, 6);
43 add_label_to_sizer (table, this, _("Frames"));
44 _frames = new wxStaticText (this, wxID_ANY, wxT (""));
45 table->Add (_frames, 1, wxALIGN_CENTER_VERTICAL);
47 add_label_to_sizer (table, this, _("Disk space required"));
48 _disk = new wxStaticText (this, wxID_ANY, wxT (""));
49 table->Add (_disk, 1, wxALIGN_CENTER_VERTICAL);
51 add_label_to_sizer (table, this, _("Frames already encoded"));
52 _encoded = new ThreadedStaticText (this, _("counting..."), boost::bind (&PropertiesDialog::frames_already_encoded, this));
53 table->Add (_encoded, 1, wxALIGN_CENTER_VERTICAL);
55 _frames->SetLabel (std_to_wx (lexical_cast<string> (_film->time_to_video_frames (_film->length()))));
56 double const disk = ((double) _film->j2k_bandwidth() / 8) * _film->length() / (TIME_HZ * 1073741824.0f);
58 s << fixed << setprecision (1) << disk << wx_to_std (_("Gb"));
59 _disk->SetLabel (std_to_wx (s.str ()));
61 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
62 overall_sizer->Add (table, 0, wxALL, 6);
64 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
66 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
69 SetSizer (overall_sizer);
70 overall_sizer->SetSizeHints (this);
74 PropertiesDialog::frames_already_encoded () const
78 u << _film->encoded_frames ();
79 } catch (boost::thread_interrupted &) {
83 if (_film->length()) {
84 /* XXX: encoded_frames() should check which frames have been encoded */
85 u << " (" << (_film->encoded_frames() * 100 / _film->time_to_video_frames (_film->length())) << "%)";