Cleanup of various dialogs by inherting TableDialog.
authorCarl Hetherington <cth@carlh.net>
Wed, 26 Mar 2014 16:43:34 +0000 (16:43 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 26 Mar 2014 16:43:34 +0000 (16:43 +0000)
26 files changed:
src/wx/audio_gain_dialog.cc
src/wx/audio_gain_dialog.h
src/wx/cinema_dialog.cc
src/wx/cinema_dialog.h
src/wx/dci_metadata_dialog.cc
src/wx/dci_metadata_dialog.h
src/wx/dolby_certificate_dialog.cc
src/wx/dolby_certificate_dialog.h
src/wx/doremi_certificate_dialog.cc
src/wx/download_certificate_dialog.cc
src/wx/download_certificate_dialog.h
src/wx/gain_calculator_dialog.cc
src/wx/gain_calculator_dialog.h
src/wx/new_film_dialog.cc
src/wx/new_film_dialog.h
src/wx/properties_dialog.cc
src/wx/properties_dialog.h
src/wx/repeat_dialog.cc
src/wx/repeat_dialog.h
src/wx/screen_dialog.cc
src/wx/screen_dialog.h
src/wx/server_dialog.cc
src/wx/server_dialog.h
src/wx/table_dialog.cc [new file with mode: 0644]
src/wx/table_dialog.h [new file with mode: 0644]
src/wx/wscript

index 7622e443e279bddd0c8814c6314860930f4860eb..b9b2c1fb7267db01f603fac8cb8c6d67ffd58cc8 100644 (file)
 #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
index 370e9f1bcf51f17eab024f2f072d74916741faca..673919c249fe2f0bec8dc56a97c9145aa618706a 100644 (file)
 
 */
 
-#include <wx/wx.h>
+#include "table_dialog.h"
 
 class wxSpinCtrlDouble;
 
-class AudioGainDialog : public wxDialog
+class AudioGainDialog : public TableDialog
 {
 public:
        AudioGainDialog (wxWindow *, int, int, float);
index e663fc3b80f96129e66e98f6bd1e115c8b4f6966..782481d54f6e332c299fdb908750d7769cc16911 100644 (file)
 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
index 02520eea985fd473df543c53aeaf9e7656793f83..26520a4127203e5ef8ff12af0ac0bae323dfe902 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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 <wx/wx.h>
+#include "table_dialog.h"
 
-class CinemaDialog : public wxDialog
+class CinemaDialog : public TableDialog
 {
 public:
        CinemaDialog (wxWindow *, std::string, std::string name = "", std::string email = "");
index e28ddd855dced41ee0e1cd6364fbbb568005f3e4..700e1b154b10377a5557f60d9178c5b48b659422 100644 (file)
 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
index 240d5535e02bceb36ab26539c8c29065600ec741..7b93a3ab6cac8bdd5dc0dac7efb7d0fb294ee0fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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
 
 */
 
-#include <wx/dialog.h>
 #include <wx/textctrl.h>
 #include <boost/shared_ptr.hpp>
 #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);
index d44c9e737816a61c8069fd6a2f383bbf51ef2da3..5d9dc5a31df56d67cfdc9ba0f9f7626bcc617ec8 100644 (file)
@@ -30,23 +30,19 @@ using std::cout;
 DolbyCertificateDialog::DolbyCertificateDialog (wxWindow* parent, boost::function<void (boost::filesystem::path)> 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<string> const countries = ftp_ls ("");
+       _country->Clear ();
        for (list<string>::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<string> const cinemas = ftp_ls (wx_to_std (_country->GetStringSelection()));
        _cinema->Clear ();
        for (list<string>::const_iterator i = cinemas.begin(); i != cinemas.end(); ++i) {
                _cinema->Append (std_to_wx (*i));
        }
-       _message->SetLabel ("");
 }
 
 void
index 7c8e6c525351211fd7f6019c147e8ef82390bc92..92b3407e9a7858e6e80143f78291e03614a62a4a 100644 (file)
@@ -25,10 +25,9 @@ class DolbyCertificateDialog : public DownloadCertificateDialog
 public:
        DolbyCertificateDialog (wxWindow *, boost::function<void (boost::filesystem::path)>);
 
-       void setup ();
-
 private:
        void download ();
+       void setup_countries ();
        void country_selected ();
        void cinema_selected ();
        std::list<std::string> ftp_ls (std::string) const;
index 51f2a357925dbf4de67470f67cf8d88ce8b09770..4b37b1ae6c4d3d560380746813e27a53c1c338b5 100644 (file)
@@ -30,13 +30,8 @@ using boost::function;
 DoremiCertificateDialog::DoremiCertificateDialog (wxWindow* parent, function<void (boost::filesystem::path)> 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 ();
 }
index 44a366bfa77d13da401be8eda8fe8f7c6cee4073..bd3841f193205491c995382d6bbff35fdad7bb54 100644 (file)
 using boost::function;
 
 DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent, function<void (boost::filesystem::path)> 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 ();
 }
index 11f1afe424a55591f67699b7b1e3226f1b870632..d881749227b8ac58a6cb6397e4e43bcbd4eb9a72 100644 (file)
 #include <wx/wx.h>
 #include <boost/function.hpp>
 #include <boost/filesystem.hpp>
+#include "table_dialog.h"
 
-class DownloadCertificateDialog : public wxDialog
+class DownloadCertificateDialog : public TableDialog
 {
 public:
        DownloadCertificateDialog (wxWindow *, boost::function<void (boost::filesystem::path)>);
-       virtual void setup () {}
 
 protected:
        void add_common_widgets ();
index f9880c0440d513c727deea6cf790b3818ceb1f67..d49dfae70841acca22765d9c824bb53d0af83ab7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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
 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
index 363a91a2bf878b3b1cdd77b7f86c8e016e2ed4d5..2228ab73e8d018189fe31a007aca0ddd4b243456 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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 <wx/wx.h>
+#include "table_dialog.h"
 
-class GainCalculatorDialog : public wxDialog
+class GainCalculatorDialog : public TableDialog
 {
 public:
        GainCalculatorDialog (wxWindow* parent);
index f6d91028267a98bbd719bc6da4cdc797369e6315..8f317f42ffa665f72d007579da3e90ec3dfc1337 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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<boost::filesystem::path> 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 ()
index a835c7cebae4ebbfe251eb85d29af30c5120bffe..5ec5863c67340901357e4d7fca2db4dd0451e961 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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
 #include <wx/wx.h>
 #include <wx/filepicker.h>
 #include "wx_util.h"
+#include "table_dialog.h"
 
 class DirPickerCtrl;
 
-class NewFilmDialog : public wxDialog
+class NewFilmDialog : public TableDialog
 {
 public:
        NewFilmDialog (wxWindow *);
index 11510cd0f0ef7d1fa84fb3aaabca90131c493a26..28247bc33eb3c62b9ef85a7dea83785be7b4fa54 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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> 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<string> (_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
index 03e0f01aa796ed99a5a06bb588f79bc4162d91a0..aeb8927b254458db68138dd4bbabe13d22e5e7b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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
 */
 
 #include <wx/wx.h>
+#include "table_dialog.h"
 
 class Film;
 class ThreadedStaticText;
 
-class PropertiesDialog : public wxDialog
+class PropertiesDialog : public TableDialog
 {
 public:
        PropertiesDialog (wxWindow *, boost::shared_ptr<Film>);
 
 private:
        std::string frames_already_encoded () const;
-       void layout ();
 
        boost::shared_ptr<Film> _film;
-       wxFlexGridSizer* _table;
        wxStaticText* _frames;
        wxStaticText* _disk;
        ThreadedStaticText* _encoded;
index 3721c61b926ab0d5b369606e54ddb05d99f18fa6..574dcd1c0cdab38a4967ee48ca51dd5d96e6ef36 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
 
     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
 #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
index cbcc6bb7a2fae25d149298d868fde3211351326d..0e20830978a226fd574d73f368cc6953405ac6c0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
 
     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 <wx/wx.h>
 #include <wx/spinctrl.h>
+#include "table_dialog.h"
 
-class RepeatDialog : public wxDialog
+class RepeatDialog : public TableDialog
 {
 public:
        RepeatDialog (wxWindow *);
index ca278a233fc5fe59b5d20df19209b2622486bf1b..232afa33c1fee2715dfc4240128d6c82c835dc1e 100644 (file)
@@ -32,29 +32,24 @@ using std::cout;
 using boost::shared_ptr;
 
 ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, shared_ptr<libdcp::Certificate> 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 ();
        }
index 385707ea839785dbd6c42a22b34e27f40a59ecce..3601a8f6c133e57a556ce22db289fa5bd732629a 100644 (file)
 #include <wx/wx.h>
 #include <boost/shared_ptr.hpp>
 #include <libdcp/certificates.h>
+#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<libdcp::Certificate> c = boost::shared_ptr<libdcp::Certificate> ());
index 04da9ad7d1496516f729bce120960dc4fe67d3ca..37f68da295e6fc9715c169366698a87ad8aa2b86 100644 (file)
@@ -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
index 9d758d7c0489c5d38e73d122e138adbaa6bb3312..b434b0e1a1e058a34f9e1e694c66c7173f7dd42a 100644 (file)
@@ -17,9 +17,9 @@
 
 */
 
-#include <wx/wx.h>
+#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 (file)
index 0000000..571fcf3
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+    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 (file)
index 0000000..23017c3
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+    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 <wx/wx.h>
+
+class TableDialog : public wxDialog
+{
+public:
+       TableDialog (wxWindow* parent, wxString title, int columns, bool cancel);
+
+protected:
+       template<class T>
+       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
index 2fa37216b33fed605d688e57a891bf9179642484..a04df2d41751a718f72f3f30584cf2109c94a1ee 100644 (file)
@@ -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