From 41b7a04cf3dedaa93aaf3c050db7a693281417f7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 26 Mar 2014 16:43:34 +0000 Subject: [PATCH] Cleanup of various dialogs by inherting TableDialog. --- src/wx/audio_gain_dialog.cc | 27 +++--------- src/wx/audio_gain_dialog.h | 4 +- src/wx/cinema_dialog.cc | 31 ++++---------- src/wx/cinema_dialog.h | 5 ++- src/wx/dci_metadata_dialog.cc | 57 ++++++++---------------- src/wx/dci_metadata_dialog.h | 6 +-- src/wx/dolby_certificate_dialog.cc | 35 ++++++++------- src/wx/dolby_certificate_dialog.h | 3 +- src/wx/doremi_certificate_dialog.cc | 9 +--- src/wx/download_certificate_dialog.cc | 27 +++++------- src/wx/download_certificate_dialog.h | 4 +- src/wx/gain_calculator_dialog.cc | 28 +++--------- src/wx/gain_calculator_dialog.h | 5 ++- src/wx/new_film_dialog.cc | 30 ++++--------- src/wx/new_film_dialog.h | 5 ++- src/wx/properties_dialog.cc | 41 +++++------------- src/wx/properties_dialog.h | 7 ++- src/wx/repeat_dialog.cc | 27 +++--------- src/wx/repeat_dialog.h | 5 ++- src/wx/screen_dialog.cc | 38 +++++----------- src/wx/screen_dialog.h | 3 +- src/wx/server_dialog.cc | 22 ++-------- src/wx/server_dialog.h | 4 +- src/wx/table_dialog.cc | 62 +++++++++++++++++++++++++++ src/wx/table_dialog.h | 47 ++++++++++++++++++++ src/wx/wscript | 1 + 26 files changed, 247 insertions(+), 286 deletions(-) create mode 100644 src/wx/table_dialog.cc create mode 100644 src/wx/table_dialog.h diff --git a/src/wx/audio_gain_dialog.cc b/src/wx/audio_gain_dialog.cc index 7622e443e..b9b2c1fb7 100644 --- a/src/wx/audio_gain_dialog.cc +++ b/src/wx/audio_gain_dialog.cc @@ -23,34 +23,19 @@ #include "wx_util.h" AudioGainDialog::AudioGainDialog (wxWindow* parent, int c, int d, float v) - : wxDialog (parent, wxID_ANY, _("Channel gain")) + : TableDialog (parent, _("Channel gain"), 3, true) { - wxFlexGridSizer* table = new wxFlexGridSizer (3, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - table->AddGrowableCol (1, 1); - - add_label_to_sizer (table, this, wxString::Format (_("Gain for content channel %d in DCP channel %d"), c + 1, d + 1), false); - _gain = new wxSpinCtrlDouble (this); - table->Add (_gain); - - add_label_to_sizer (table, this, _("dB"), false); - - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } - - SetSizer (overall_sizer); - overall_sizer->Layout (); - overall_sizer->SetSizeHints (this); + add (wxString::Format (_("Gain for content channel %d in DCP channel %d"), c + 1, d + 1), false); + _gain = add (new wxSpinCtrlDouble (this)); + add (_("dB"), false); _gain->SetRange (-144, 0); _gain->SetDigits (1); _gain->SetIncrement (0.1); _gain->SetValue (20 * log10 (v)); + + layout (); } float diff --git a/src/wx/audio_gain_dialog.h b/src/wx/audio_gain_dialog.h index 370e9f1bc..673919c24 100644 --- a/src/wx/audio_gain_dialog.h +++ b/src/wx/audio_gain_dialog.h @@ -17,11 +17,11 @@ */ -#include +#include "table_dialog.h" class wxSpinCtrlDouble; -class AudioGainDialog : public wxDialog +class AudioGainDialog : public TableDialog { public: AudioGainDialog (wxWindow *, int, int, float); diff --git a/src/wx/cinema_dialog.cc b/src/wx/cinema_dialog.cc index e663fc3b8..782481d54 100644 --- a/src/wx/cinema_dialog.cc +++ b/src/wx/cinema_dialog.cc @@ -23,30 +23,15 @@ using std::string; CinemaDialog::CinemaDialog (wxWindow* parent, string title, string name, string email) - : wxDialog (parent, wxID_ANY, std_to_wx (title)) + : TableDialog (parent, std_to_wx (title), 2, true) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - table->AddGrowableCol (1, 1); - - add_label_to_sizer (table, this, _("Name"), true); - _name = new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (256, -1)); - table->Add (_name, 1, wxEXPAND); - - add_label_to_sizer (table, this, _("Email address for KDM delivery"), true); - _email = new wxTextCtrl (this, wxID_ANY, std_to_wx (email), wxDefaultPosition, wxSize (256, -1)); - table->Add (_email, 1, wxEXPAND); - - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table, 1, wxEXPAND | wxALL, 6); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } - - SetSizer (overall_sizer); - overall_sizer->Layout (); - overall_sizer->SetSizeHints (this); + add (_("Name"), true); + _name = add (new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (256, -1))); + + add (_("Email address for KDM delivery"), true); + _email = add (new wxTextCtrl (this, wxID_ANY, std_to_wx (email), wxDefaultPosition, wxSize (256, -1))); + + layout (); } string diff --git a/src/wx/cinema_dialog.h b/src/wx/cinema_dialog.h index 02520eea9..26520a412 100644 --- a/src/wx/cinema_dialog.h +++ b/src/wx/cinema_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,8 +18,9 @@ */ #include +#include "table_dialog.h" -class CinemaDialog : public wxDialog +class CinemaDialog : public TableDialog { public: CinemaDialog (wxWindow *, std::string, std::string name = "", std::string email = ""); diff --git a/src/wx/dci_metadata_dialog.cc b/src/wx/dci_metadata_dialog.cc index e28ddd855..700e1b154 100644 --- a/src/wx/dci_metadata_dialog.cc +++ b/src/wx/dci_metadata_dialog.cc @@ -27,42 +27,31 @@ using boost::shared_ptr; DCIMetadataDialog::DCIMetadataDialog (wxWindow* parent, DCIMetadata dm) - : wxDialog (parent, wxID_ANY, _("DCI name"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) + : TableDialog (parent, _("DCI name"), 2, true) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - table->AddGrowableCol (1, 1); + add (_("Content version"), true); + _content_version = add (new wxSpinCtrl (this, wxID_ANY)); - add_label_to_sizer (table, this, _("Content version"), true); - _content_version = new wxSpinCtrl (this, wxID_ANY); - table->Add (_content_version, 1, wxEXPAND); + add (_("Audio Language (e.g. EN)"), true); + _audio_language = add (new wxTextCtrl (this, wxID_ANY)); - add_label_to_sizer (table, this, _("Audio Language (e.g. EN)"), true); - _audio_language = new wxTextCtrl (this, wxID_ANY); - table->Add (_audio_language, 1, wxEXPAND); - - add_label_to_sizer (table, this, _("Subtitle Language (e.g. FR)"), true); - _subtitle_language = new wxTextCtrl (this, wxID_ANY); - table->Add (_subtitle_language, 1, wxEXPAND); + add (_("Subtitle Language (e.g. FR)"), true); + _subtitle_language = add (new wxTextCtrl (this, wxID_ANY)); - add_label_to_sizer (table, this, _("Territory (e.g. UK)"), true); - _territory = new wxTextCtrl (this, wxID_ANY); - table->Add (_territory, 1, wxEXPAND); + add (_("Territory (e.g. UK)"), true); + _territory = add (new wxTextCtrl (this, wxID_ANY)); - add_label_to_sizer (table, this, _("Rating (e.g. 15)"), true); - _rating = new wxTextCtrl (this, wxID_ANY); - table->Add (_rating, 1, wxEXPAND); + add (_("Rating (e.g. 15)"), true); + _rating = add (new wxTextCtrl (this, wxID_ANY)); - add_label_to_sizer (table, this, _("Studio (e.g. TCF)"), true); - _studio = new wxTextCtrl (this, wxID_ANY); - table->Add (_studio, 1, wxEXPAND); + add (_("Studio (e.g. TCF)"), true); + _studio = add (new wxTextCtrl (this, wxID_ANY)); - add_label_to_sizer (table, this, _("Facility (e.g. DLA)"), true); - _facility = new wxTextCtrl (this, wxID_ANY); - table->Add (_facility, 1, wxEXPAND); + add (_("Facility (e.g. DLA)"), true); + _facility = add (new wxTextCtrl (this, wxID_ANY)); - add_label_to_sizer (table, this, _("Package Type (e.g. OV)"), true); - _package_type = new wxTextCtrl (this, wxID_ANY); - table->Add (_package_type, 1, wxEXPAND); + add (_("Package Type (e.g. OV)"), true); + _package_type = add (new wxTextCtrl (this, wxID_ANY)); _content_version->SetRange (1, 1024); @@ -75,17 +64,7 @@ DCIMetadataDialog::DCIMetadataDialog (wxWindow* parent, DCIMetadata dm) _facility->SetValue (std_to_wx (dm.facility)); _package_type->SetValue (std_to_wx (dm.package_type)); - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } - - SetSizer (overall_sizer); - overall_sizer->Layout (); - overall_sizer->SetSizeHints (this); + layout (); } DCIMetadata diff --git a/src/wx/dci_metadata_dialog.h b/src/wx/dci_metadata_dialog.h index 240d5535e..7b93a3ab6 100644 --- a/src/wx/dci_metadata_dialog.h +++ b/src/wx/dci_metadata_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,15 +17,15 @@ */ -#include #include #include #include "lib/dci_metadata.h" +#include "table_dialog.h" class wxSpinCtrl; class Film; -class DCIMetadataDialog : public wxDialog +class DCIMetadataDialog : public TableDialog { public: DCIMetadataDialog (wxWindow *, DCIMetadata); diff --git a/src/wx/dolby_certificate_dialog.cc b/src/wx/dolby_certificate_dialog.cc index d44c9e737..5d9dc5a31 100644 --- a/src/wx/dolby_certificate_dialog.cc +++ b/src/wx/dolby_certificate_dialog.cc @@ -30,23 +30,19 @@ using std::cout; DolbyCertificateDialog::DolbyCertificateDialog (wxWindow* parent, boost::function load) : DownloadCertificateDialog (parent, load) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - - _country = new wxChoice (this, wxID_ANY); - add_label_to_sizer (table, this, _("Country"), true); - table->Add (_country, 1, wxEXPAND | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_X_GAP); + add (_("Country"), true); + _country = add (new wxChoice (this, wxID_ANY)); _country->Append (N_("Hashemite Kingdom of Jordan")); - _cinema = new wxChoice (this, wxID_ANY); - add_label_to_sizer (table, this, _("Cinema"), true); - table->Add (_cinema, 1, wxEXPAND | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_X_GAP); - _cinema->Append (N_("Wometco Dominicana Palacio Del Cine")); - _overall_sizer->Add (table); + add (_("Cinema"), true); + _cinema = add (new wxChoice (this, wxID_ANY)); + _cinema->Append (N_("Motion Picture Solutions London Mobile & QC")); add_common_widgets (); _country->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificateDialog::country_selected, this)); _cinema->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DolbyCertificateDialog::cinema_selected, this)); + Bind (wxEVT_IDLE, boost::bind (&DolbyCertificateDialog::setup_countries, this)); _country->Clear (); _cinema->Clear (); @@ -110,28 +106,37 @@ DolbyCertificateDialog::ftp_ls (string dir) const } void -DolbyCertificateDialog::setup () +DolbyCertificateDialog::setup_countries () { - _message->SetLabel (_("Fetching available countries")); + if (_country->GetCount() > 0) { + /* Already set up */ + return; + } + + _country->Append (_("Fetching...")); + _country->SetSelection (0); run_gui_loop (); + list const countries = ftp_ls (""); + _country->Clear (); for (list::const_iterator i = countries.begin(); i != countries.end(); ++i) { _country->Append (std_to_wx (*i)); } - _message->SetLabel (""); } void DolbyCertificateDialog::country_selected () { - _message->SetLabel (_("Fetching available cinemas")); + _cinema->Clear (); + _cinema->Append (_("Fetching...")); + _cinema->SetSelection (0); run_gui_loop (); + list const cinemas = ftp_ls (wx_to_std (_country->GetStringSelection())); _cinema->Clear (); for (list::const_iterator i = cinemas.begin(); i != cinemas.end(); ++i) { _cinema->Append (std_to_wx (*i)); } - _message->SetLabel (""); } void diff --git a/src/wx/dolby_certificate_dialog.h b/src/wx/dolby_certificate_dialog.h index 7c8e6c525..92b3407e9 100644 --- a/src/wx/dolby_certificate_dialog.h +++ b/src/wx/dolby_certificate_dialog.h @@ -25,10 +25,9 @@ class DolbyCertificateDialog : public DownloadCertificateDialog public: DolbyCertificateDialog (wxWindow *, boost::function); - void setup (); - private: void download (); + void setup_countries (); void country_selected (); void cinema_selected (); std::list ftp_ls (std::string) const; diff --git a/src/wx/doremi_certificate_dialog.cc b/src/wx/doremi_certificate_dialog.cc index 51f2a3579..4b37b1ae6 100644 --- a/src/wx/doremi_certificate_dialog.cc +++ b/src/wx/doremi_certificate_dialog.cc @@ -30,13 +30,8 @@ using boost::function; DoremiCertificateDialog::DoremiCertificateDialog (wxWindow* parent, function load) : DownloadCertificateDialog (parent, load) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - - add_label_to_sizer (table, this, _("Server serial number"), true); - _serial = new wxTextCtrl (this, wxID_ANY); - table->Add (_serial, 1, wxEXPAND); - - _overall_sizer->Add (table, 1, wxALL, DCPOMATIC_DIALOG_BORDER); + add (_("Server serial number"), true); + _serial = add (new wxTextCtrl (this, wxID_ANY)); add_common_widgets (); } diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index 44a366bfa..bd3841f19 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -24,31 +24,26 @@ using boost::function; DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent, function load) - : wxDialog (parent, wxID_ANY, _("Download certificate")) + : TableDialog (parent, _("Download certificate"), 2, true) , _load (load) { - _overall_sizer = new wxBoxSizer (wxVERTICAL); + } void DownloadCertificateDialog::add_common_widgets () { - _download = new wxButton (this, wxID_ANY, _("Download")); - _overall_sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP); - _gauge = new wxGauge (this, wxID_ANY, 100); - _overall_sizer->Add (_gauge, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP); - _message = new wxStaticText (this, wxID_ANY, wxT ("")); - _overall_sizer->Add (_message, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); - if (buttons) { - _overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } + add_spacer (); + _download = add (new wxButton (this, wxID_ANY, _("Download"))); - SetSizer (_overall_sizer); - _overall_sizer->Layout (); - _overall_sizer->SetSizeHints (this); + add_spacer (); + _gauge = add (new wxGauge (this, wxID_ANY, 100)); + add_spacer (); + _message = add (new wxStaticText (this, wxID_ANY, wxT (""))); + _download->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DownloadCertificateDialog::download, this)); _download->Enable (false); + + layout (); } diff --git a/src/wx/download_certificate_dialog.h b/src/wx/download_certificate_dialog.h index 11f1afe42..d88174922 100644 --- a/src/wx/download_certificate_dialog.h +++ b/src/wx/download_certificate_dialog.h @@ -23,12 +23,12 @@ #include #include #include +#include "table_dialog.h" -class DownloadCertificateDialog : public wxDialog +class DownloadCertificateDialog : public TableDialog { public: DownloadCertificateDialog (wxWindow *, boost::function); - virtual void setup () {} protected: void add_common_widgets (); diff --git a/src/wx/gain_calculator_dialog.cc b/src/wx/gain_calculator_dialog.cc index f9880c044..d49dfae70 100644 --- a/src/wx/gain_calculator_dialog.cc +++ b/src/wx/gain_calculator_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,29 +24,15 @@ using namespace boost; GainCalculatorDialog::GainCalculatorDialog (wxWindow* parent) - : wxDialog (parent, wxID_ANY, _("Gain Calculator")) + : TableDialog (parent, _("Gain Calculator"), 2, true) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - table->AddGrowableCol (1, 1); + add (_("I want to play this back at fader"), true); + _wanted = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator (wxFILTER_NUMERIC))); - add_label_to_sizer (table, this, _("I want to play this back at fader"), true); - _wanted = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator (wxFILTER_NUMERIC)); - table->Add (_wanted, 1, wxEXPAND); + add (_("But I have to use fader"), true); + _actual = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator (wxFILTER_NUMERIC))); - add_label_to_sizer (table, this, _("But I have to use fader"), true); - _actual = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator (wxFILTER_NUMERIC)); - table->Add (_actual, 1, wxEXPAND); - - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } - - SetSizer (overall_sizer); - overall_sizer->SetSizeHints (this); + layout (); } float diff --git a/src/wx/gain_calculator_dialog.h b/src/wx/gain_calculator_dialog.h index 363a91a2b..2228ab73e 100644 --- a/src/wx/gain_calculator_dialog.h +++ b/src/wx/gain_calculator_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,8 +18,9 @@ */ #include +#include "table_dialog.h" -class GainCalculatorDialog : public wxDialog +class GainCalculatorDialog : public TableDialog { public: GainCalculatorDialog (wxWindow* parent); diff --git a/src/wx/new_film_dialog.cc b/src/wx/new_film_dialog.cc index f6d910282..8f317f42f 100644 --- a/src/wx/new_film_dialog.cc +++ b/src/wx/new_film_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,20 +32,12 @@ using namespace boost; boost::optional NewFilmDialog::_directory; NewFilmDialog::NewFilmDialog (wxWindow* parent) - : wxDialog (parent, wxID_ANY, _("New Film")) + : TableDialog (parent, _("New Film"), 2, true) { - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - SetSizer (overall_sizer); - - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - table->AddGrowableCol (1, 1); - overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - - add_label_to_sizer (table, this, _("Film name"), true); - _name = new wxTextCtrl (this, wxID_ANY); - table->Add (_name, 0, wxEXPAND); + add (_("Film name"), true); + _name = add (new wxTextCtrl (this, wxID_ANY)); - add_label_to_sizer (table, this, _("Create in folder"), true); + add (_("Create in folder"), true); #ifdef DCPOMATIC_USE_OWN_DIR_PICKER _folder = new DirPickerCtrl (this); @@ -58,17 +50,11 @@ NewFilmDialog::NewFilmDialog (wxWindow* parent) } _folder->SetPath (std_to_wx (_directory.get().string())); - table->Add (_folder, 1, wxEXPAND); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } - - overall_sizer->Layout (); - overall_sizer->SetSizeHints (this); + add (_folder); _name->SetFocus (); + + layout (); } NewFilmDialog::~NewFilmDialog () diff --git a/src/wx/new_film_dialog.h b/src/wx/new_film_dialog.h index a835c7ceb..5ec5863c6 100644 --- a/src/wx/new_film_dialog.h +++ b/src/wx/new_film_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,10 +20,11 @@ #include #include #include "wx_util.h" +#include "table_dialog.h" class DirPickerCtrl; -class NewFilmDialog : public wxDialog +class NewFilmDialog : public TableDialog { public: NewFilmDialog (wxWindow *); diff --git a/src/wx/properties_dialog.cc b/src/wx/properties_dialog.cc index 11510cd0f..28247bc33 100644 --- a/src/wx/properties_dialog.cc +++ b/src/wx/properties_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,47 +33,26 @@ using boost::shared_ptr; using boost::lexical_cast; PropertiesDialog::PropertiesDialog (wxWindow* parent, shared_ptr film) - : wxDialog (parent, wxID_ANY, _("Film Properties"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) + : TableDialog (parent, _("Film Properties"), 2, false) , _film (film) { - _table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + add (_("Frames"), true); + _frames = add (new wxStaticText (this, wxID_ANY, wxT (""))); - add_label_to_sizer (_table, this, _("Frames"), true); - _frames = new wxStaticText (this, wxID_ANY, wxT ("")); - _table->Add (_frames, 1, wxALIGN_CENTER_VERTICAL); + add (_("Disk space required"), true); + _disk = add (new wxStaticText (this, wxID_ANY, wxT (""))); - add_label_to_sizer (_table, this, _("Disk space required"), true); - _disk = new wxStaticText (this, wxID_ANY, wxT ("")); - _table->Add (_disk, 1, wxALIGN_CENTER_VERTICAL); - - add_label_to_sizer (_table, this, _("Frames already encoded"), true); - _encoded = new ThreadedStaticText (this, _("counting..."), boost::bind (&PropertiesDialog::frames_already_encoded, this)); + add (_("Frames already encoded"), true); + _encoded = add (new ThreadedStaticText (this, _("counting..."), boost::bind (&PropertiesDialog::frames_already_encoded, this))); _encoded->Finished.connect (boost::bind (&PropertiesDialog::layout, this)); - _table->Add (_encoded, 1, wxALIGN_CENTER_VERTICAL); - + _frames->SetLabel (std_to_wx (lexical_cast (_film->time_to_video_frames (_film->length())))); double const disk = double (_film->required_disk_space()) / 1073741824.0f; stringstream s; s << fixed << setprecision (1) << disk << wx_to_std (_("Gb")); _disk->SetLabel (std_to_wx (s.str ())); - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (_table, 0, wxALL, DCPOMATIC_DIALOG_BORDER); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } - - SetSizer (overall_sizer); - overall_sizer->SetSizeHints (this); -} - -void -PropertiesDialog::layout () -{ - _table->Layout (); - Fit (); + layout (); } string diff --git a/src/wx/properties_dialog.h b/src/wx/properties_dialog.h index 03e0f01aa..aeb8927b2 100644 --- a/src/wx/properties_dialog.h +++ b/src/wx/properties_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,21 +18,20 @@ */ #include +#include "table_dialog.h" class Film; class ThreadedStaticText; -class PropertiesDialog : public wxDialog +class PropertiesDialog : public TableDialog { public: PropertiesDialog (wxWindow *, boost::shared_ptr); private: std::string frames_already_encoded () const; - void layout (); boost::shared_ptr _film; - wxFlexGridSizer* _table; wxStaticText* _frames; wxStaticText* _disk; ThreadedStaticText* _encoded; diff --git a/src/wx/repeat_dialog.cc b/src/wx/repeat_dialog.cc index 3721c61b9..574dcd1c0 100644 --- a/src/wx/repeat_dialog.cc +++ b/src/wx/repeat_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,30 +21,15 @@ #include "wx_util.h" RepeatDialog::RepeatDialog (wxWindow* parent) - : wxDialog (parent, wxID_ANY, _("Repeat Content")) + : TableDialog (parent, _("Repeat Content"), 3, true) { - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - SetSizer (overall_sizer); - - wxFlexGridSizer* table = new wxFlexGridSizer (3, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - table->AddGrowableCol (1, 1); - overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - - add_label_to_sizer (table, this, _("Repeat"), true); - _number = new wxSpinCtrl (this, wxID_ANY); - table->Add (_number, 1); - - add_label_to_sizer (table, this, _("times"), false); + add (_("Repeat"), true); + _number = add (new wxSpinCtrl (this, wxID_ANY)); + add (_("times"), false); _number->SetRange (1, 1024); - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } - - overall_sizer->Layout (); - overall_sizer->SetSizeHints (this); + layout (); } int diff --git a/src/wx/repeat_dialog.h b/src/wx/repeat_dialog.h index cbcc6bb7a..0e2083097 100644 --- a/src/wx/repeat_dialog.h +++ b/src/wx/repeat_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,8 +19,9 @@ #include #include +#include "table_dialog.h" -class RepeatDialog : public wxDialog +class RepeatDialog : public TableDialog { public: RepeatDialog (wxWindow *); diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc index ca278a233..232afa33c 100644 --- a/src/wx/screen_dialog.cc +++ b/src/wx/screen_dialog.cc @@ -32,29 +32,24 @@ using std::cout; using boost::shared_ptr; ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, shared_ptr certificate) - : wxDialog (parent, wxID_ANY, std_to_wx (title)) + : TableDialog (parent, std_to_wx (title), 2, true) , _certificate (certificate) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6); - table->AddGrowableCol (1, 1); + add ("Name", true); + _name = add (new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (320, -1))); - add_label_to_sizer (table, this, "Name", true); - _name = new wxTextCtrl (this, wxID_ANY, std_to_wx (name), wxDefaultPosition, wxSize (320, -1)); - table->Add (_name, 1, wxEXPAND); + add ("Server manufacturer", true); + _manufacturer = add (new wxChoice (this, wxID_ANY)); - add_label_to_sizer (table, this, "Server manufacturer", true); - _manufacturer = new wxChoice (this, wxID_ANY); - table->Add (_manufacturer, 1, wxEXPAND); - - add_label_to_sizer (table, this, _("Certificate"), true); + add (_("Certificate"), true); wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); _load_certificate = new wxButton (this, wxID_ANY, _("Load from file...")); _download_certificate = new wxButton (this, wxID_ANY, _("Download")); s->Add (_load_certificate, 1, wxEXPAND); s->Add (_download_certificate, 1, wxEXPAND); - table->Add (s, 1, wxEXPAND); + add (s); - table->AddSpacer (0); + add_spacer (); _certificate_text = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (320, 256), wxTE_MULTILINE | wxTE_READONLY); if (certificate) { _certificate_text->SetValue (certificate->certificate ()); @@ -62,19 +57,7 @@ ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, shared_ wxFont font = wxSystemSettings::GetFont (wxSYS_ANSI_FIXED_FONT); font.SetPointSize (font.GetPointSize() / 2); _certificate_text->SetFont (font); - table->Add (_certificate_text, 1, wxEXPAND); - - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table, 1, wxEXPAND | wxALL, 6); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } - - SetSizer (overall_sizer); - overall_sizer->Layout (); - overall_sizer->SetSizeHints (this); + add (_certificate_text); _manufacturer->Append (_("Unknown")); _manufacturer->Append (_("Doremi")); @@ -87,6 +70,7 @@ ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, shared_ _manufacturer->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ScreenDialog::setup_sensitivity, this)); setup_sensitivity (); + layout (); } string @@ -129,12 +113,10 @@ ScreenDialog::download_certificate () { if (_manufacturer->GetStringSelection() == _("Doremi")) { DownloadCertificateDialog* d = new DoremiCertificateDialog (this, boost::bind (&ScreenDialog::load_certificate, this, _1)); - d->setup (); d->ShowModal (); d->Destroy (); } else if (_manufacturer->GetStringSelection() == _("Dolby")) { DownloadCertificateDialog* d = new DolbyCertificateDialog (this, boost::bind (&ScreenDialog::load_certificate, this, _1)); - d->setup (); d->ShowModal (); d->Destroy (); } diff --git a/src/wx/screen_dialog.h b/src/wx/screen_dialog.h index 385707ea8..3601a8f6c 100644 --- a/src/wx/screen_dialog.h +++ b/src/wx/screen_dialog.h @@ -20,10 +20,11 @@ #include #include #include +#include "table_dialog.h" class Progress; -class ScreenDialog : public wxDialog +class ScreenDialog : public TableDialog { public: ScreenDialog (wxWindow *, std::string, std::string name = "", boost::shared_ptr c = boost::shared_ptr ()); diff --git a/src/wx/server_dialog.cc b/src/wx/server_dialog.cc index 04da9ad7d..37f68da29 100644 --- a/src/wx/server_dialog.cc +++ b/src/wx/server_dialog.cc @@ -25,11 +25,8 @@ using std::string; using boost::shared_ptr; ServerDialog::ServerDialog (wxWindow* parent) - : wxDialog (parent, wxID_ANY, _("Server")) + : TableDialog (parent, _("Server"), 2, true) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); - table->AddGrowableCol (1, 1); - wxClientDC dc (parent); /* XXX: bit of a mystery why we need such a long string here */ wxSize size = dc.GetTextExtent (wxT ("255.255.255.255.255.255.255.255")); @@ -38,21 +35,10 @@ ServerDialog::ServerDialog (wxWindow* parent) wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); wxArrayString list; - add_label_to_sizer (table, this, _("Host name or IP address"), true); - _host = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, size); - table->Add (_host, 1, wxEXPAND | wxALL); - - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); - if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } + add (_("Host name or IP address"), true); + _host = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, size)); - SetSizer (overall_sizer); - overall_sizer->Layout (); - overall_sizer->SetSizeHints (this); + layout (); } void diff --git a/src/wx/server_dialog.h b/src/wx/server_dialog.h index 9d758d7c0..b434b0e1a 100644 --- a/src/wx/server_dialog.h +++ b/src/wx/server_dialog.h @@ -17,9 +17,9 @@ */ -#include +#include "table_dialog.h" -class ServerDialog : public wxDialog +class ServerDialog : public TableDialog { public: ServerDialog (wxWindow *); diff --git a/src/wx/table_dialog.cc b/src/wx/table_dialog.cc new file mode 100644 index 000000000..571fcf3a4 --- /dev/null +++ b/src/wx/table_dialog.cc @@ -0,0 +1,62 @@ +/* + Copyright (C) 2014 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "table_dialog.h" +#include "wx_util.h" + +TableDialog::TableDialog (wxWindow* parent, wxString title, int columns, bool cancel) + : wxDialog (parent, wxID_ANY, title) +{ + _overall_sizer = new wxBoxSizer (wxVERTICAL); + SetSizer (_overall_sizer); + + _table = new wxFlexGridSizer (columns, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + _table->AddGrowableCol (1, 1); + + _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); + + long int flags = wxOK; + if (cancel) { + flags |= wxCANCEL; + } + + wxSizer* buttons = CreateSeparatedButtonSizer (flags); + if (buttons) { + _overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } +} + +void +TableDialog::layout () +{ + _overall_sizer->Layout (); + _overall_sizer->SetSizeHints (this); +} + +void +TableDialog::add (wxString text, bool label) +{ + add_label_to_sizer (_table, this, text, label); +} + +void +TableDialog::add_spacer () +{ + _table->AddSpacer (0); +} diff --git a/src/wx/table_dialog.h b/src/wx/table_dialog.h new file mode 100644 index 000000000..23017c3b6 --- /dev/null +++ b/src/wx/table_dialog.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2014 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef DCPOMATIC_TABLE_DIALOG_H +#define DCPOMATIC_TABLE_DIALOG_H + +#include + +class TableDialog : public wxDialog +{ +public: + TableDialog (wxWindow* parent, wxString title, int columns, bool cancel); + +protected: + template + T* add (T* w) { + _table->Add (w, 1, wxEXPAND); + return w; + } + + void add (wxString text, bool label); + void add_spacer (); + + void layout (); + +private: + wxSizer* _overall_sizer; + wxFlexGridSizer* _table; +}; + +#endif diff --git a/src/wx/wscript b/src/wx/wscript index 2fa37216b..a04df2d41 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -38,6 +38,7 @@ sources = """ server_dialog.cc servers_list_dialog.cc subtitle_panel.cc + table_dialog.cc timecode.cc timeline.cc timeline_dialog.cc -- 2.30.2