Allow KDM output panel widgets to be created with specific parents.
authorCarl Hetherington <cth@carlh.net>
Sat, 28 Dec 2024 23:53:27 +0000 (00:53 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 1 Jan 2025 00:54:38 +0000 (01:54 +0100)
src/wx/kdm_output_panel.cc
src/wx/kdm_output_panel.h
src/wx/tall_kdm_output_panel.cc

index 3548d4dee33b5b86e2c0758007e1b74d31c90a4a..3788c3fce2e5b0dc6ec48e0d46f94f48d65e8796 100644 (file)
@@ -66,63 +66,50 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
        , _forensic_mark_audio (true)
        , _forensic_mark_audio_up_to (12)
 {
-       _type = new KDMChoice (this);
-       _type->set(Config::instance()->default_kdm_type());
-       _advanced = new Button(this, _("Advanced..."));
-       _annotation_text = new wxTextCtrl(this, wxID_ANY);
 
-       _container_name_format = new NameFormatEditor (this, Config::instance()->kdm_container_name_format(), dcp::NameFormat::Map(), dcp::NameFormat::Map(), "");
 
-       dcp::NameFormat::Map titles;
-       titles['f'] = wx_to_std (_("film name"));
-       titles['c'] = wx_to_std (_("cinema"));
-       titles['s'] = wx_to_std (_("screen"));
-       titles['b'] = wx_to_std (_("from date/time"));
-       titles['e'] = wx_to_std (_("to date/time"));
-       dcp::NameFormat::Map ex;
-       ex['f'] = "Bambi";
-       ex['c'] = "Lumière";
-       ex['s'] = "Screen 1";
-       ex['b'] = "2012/03/15 12:30";
-       ex['e'] = "2012/03/22 02:30";
-       _filename_format = new NameFormatEditor (this, Config::instance()->kdm_filename_format(), titles, ex, ".xml");
+}
 
-       _write_to = new CheckBox (this, _("Write to"));
+
+void
+KDMOutputPanel::create_destination_widgets(wxWindow* parent)
+{
+       _write_to = new CheckBox(parent, _("Write to"));
 
 #ifdef DCPOMATIC_USE_OWN_PICKER
-       _folder = new DirPickerCtrl (this);
+       _folder = new DirPickerCtrl(parent);
 #else
-       _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, char_to_wx(wxDirSelectorPromptStr), wxDefaultPosition, wxSize (300, -1));
+       _folder = new wxDirPickerCtrl(parent, wxID_ANY, wxEmptyString, char_to_wx(wxDirSelectorPromptStr), wxDefaultPosition, wxSize(300, -1));
 #endif
 
        auto path = Config::instance()->default_kdm_directory();
        if (path) {
-               _folder->SetPath (std_to_wx (path->string ()));
+               _folder->SetPath(std_to_wx(path->string()));
        } else {
-               _folder->SetPath (wxStandardPaths::Get().GetDocumentsDir());
+               _folder->SetPath(wxStandardPaths::Get().GetDocumentsDir());
        }
 
-       _write_flat = new wxRadioButton (this, wxID_ANY, _("Write all KDMs to the same folder"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
-       _write_folder = new wxRadioButton (this, wxID_ANY, _("Write a folder for each cinema's KDMs"));
-       _write_zip = new wxRadioButton (this, wxID_ANY, _("Write a ZIP file for each cinema's KDMs"));
+       _write_flat = new wxRadioButton(parent, wxID_ANY, _("Write all KDMs to the same folder"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
+       _write_folder = new wxRadioButton(parent, wxID_ANY, _("Write a folder for each cinema's KDMs"));
+       _write_zip = new wxRadioButton(parent, wxID_ANY, _("Write a ZIP file for each cinema's KDMs"));
 
-       _email = new CheckBox (this, _("Send by email"));
-       _add_email_addresses = new wxButton(this, wxID_ANY, _("Set additional email addresses..."));
+       _email = new CheckBox(parent, _("Send by email"));
+       _add_email_addresses = new wxButton(parent, wxID_ANY, _("Set additional email addresses..."));
 
        switch (Config::instance()->last_kdm_write_type().get_value_or(Config::KDM_WRITE_FLAT)) {
        case Config::KDM_WRITE_FLAT:
-               _write_flat->SetValue (true);
+               _write_flat->SetValue(true);
                break;
        case Config::KDM_WRITE_FOLDER:
-               _write_folder->SetValue (true);
+               _write_folder->SetValue(true);
                break;
        case Config::KDM_WRITE_ZIP:
-               _write_zip->SetValue (true);
+               _write_zip->SetValue(true);
                break;
        }
 
-       _write_to->SetValue (Config::instance()->write_kdms_to_disk());
-       _email->SetValue (Config::instance()->email_kdms());
+       _write_to->SetValue(Config::instance()->write_kdms_to_disk());
+       _email->SetValue(Config::instance()->email_kdms());
 
        _write_to->bind(&KDMOutputPanel::write_to_changed, this);
        _email->bind(&KDMOutputPanel::email_changed, this);
@@ -130,7 +117,34 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
        _write_flat->Bind   (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
        _write_folder->Bind (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
        _write_zip->Bind    (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
-       _advanced->Bind     (wxEVT_BUTTON, boost::bind (&KDMOutputPanel::advanced_clicked, this));
+}
+
+
+void
+KDMOutputPanel::create_details_widgets(wxWindow* parent)
+{
+       _type = new KDMChoice(parent);
+       _type->set(Config::instance()->default_kdm_type());
+       _advanced = new Button(parent, _("Advanced..."));
+       _annotation_text = new wxTextCtrl(parent, wxID_ANY);
+
+       _container_name_format = new NameFormatEditor(parent, Config::instance()->kdm_container_name_format(), dcp::NameFormat::Map(), dcp::NameFormat::Map(), "");
+
+       dcp::NameFormat::Map titles;
+       titles['f'] = wx_to_std (_("film name"));
+       titles['c'] = wx_to_std (_("cinema"));
+       titles['s'] = wx_to_std (_("screen"));
+       titles['b'] = wx_to_std (_("from date/time"));
+       titles['e'] = wx_to_std (_("to date/time"));
+       dcp::NameFormat::Map ex;
+       ex['f'] = "Bambi";
+       ex['c'] = "Lumière";
+       ex['s'] = "Screen 1";
+       ex['b'] = "2012/03/15 12:30";
+       ex['e'] = "2012/03/22 02:30";
+       _filename_format = new NameFormatEditor(parent, Config::instance()->kdm_filename_format(), titles, ex, ".xml");
+
+       _advanced->Bind(wxEVT_BUTTON, boost::bind (&KDMOutputPanel::advanced_clicked, this));
 }
 
 
index 447588fe74127d5d00b3f5dc79666b2b3d0dd4a0..dd4dbb1fc8c443b7e35c1458a9046c700112aa2c 100644 (file)
@@ -75,6 +75,9 @@ public:
        boost::signals2::signal<void ()> MethodChanged;
 
 protected:
+       void create_destination_widgets(wxWindow* parent);
+       void create_details_widgets(wxWindow* parent);
+
        KDMChoice* _type;
        wxTextCtrl* _annotation_text;
        NameFormatEditor* _container_name_format;
index 1fb5cd958485c95dade1364700cf35804991d005..d0bb3d7dde81593178f1371407464e1ac161fd40 100644 (file)
@@ -63,6 +63,9 @@ using namespace boost::placeholders;
 TallKDMOutputPanel::TallKDMOutputPanel(wxWindow* parent)
        : KDMOutputPanel(parent)
 {
+       create_destination_widgets(this);
+       create_details_widgets(this);
+
        auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, 0);
        table->AddGrowableCol (1);