/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
-#include "lib/warnings.h"
+#ifndef DCPOMATIC_LANGUAGE_TAG_DIALOG_H
+#define DCPOMATIC_LANGUAGE_TAG_DIALOG_H
+
+
#include <dcp/language_tag.h>
-DCPOMATIC_DISABLE_WARNINGS
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
#include <wx/wx.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
class wxListCtrl;
-class LanguageSubtagPanel;
+/** A dialog to choose a language e.g.
+ *
+ * English en
+ * German de
+ * Portuguese for Brazil pt-BR
+ *
+ * It displays the full names of languages in one column, and the tag in the other,
+ * and has a button to add a new language using FullLanguageTagDialog.
+ */
class LanguageTagDialog : public wxDialog
{
public:
- class Subtag
- {
- public:
- Subtag (dcp::LanguageTag::SubtagType type_, boost::optional<dcp::LanguageTag::SubtagData> subtag_)
- : type (type_)
- , subtag (subtag_)
- {}
-
- dcp::LanguageTag::SubtagType type;
- boost::optional<dcp::LanguageTag::SubtagData> subtag;
- std::string last_search;
- };
-
- LanguageTagDialog (wxWindow* parent, dcp::LanguageTag tag);
+ LanguageTagDialog (wxWindow* parent, dcp::LanguageTag tag = dcp::LanguageTag("en"));
dcp::LanguageTag get () const;
-
+ void set (dcp::LanguageTag tag);
private:
+ void add_language ();
+ void populate_list ();
- std::string subtag_type_name (dcp::LanguageTag::SubtagType type);
- void search_changed (std::string search);
- void add_to_current_tag (dcp::LanguageTag::SubtagType type, boost::optional<dcp::LanguageTag::SubtagData> subtag);
- void remove_from_current_tag ();
- void current_tag_selection_changed ();
- void chosen_subtag_changed (boost::optional<dcp::LanguageTag::SubtagData> selection);
- void setup_sensitivity ();
-
- std::vector<Subtag> _current_tag_subtags;
- wxListCtrl* _current_tag_list;
- LanguageSubtagPanel* _choose_subtag_panel;
- wxButton* _add_script;
- wxButton* _add_region;
- wxButton* _add_variant;
- wxButton* _add_external;
- wxButton* _remove;
-};
-
-
-
-class RegionSubtagDialog : public wxDialog
-{
-public:
- RegionSubtagDialog (wxWindow* parent, dcp::LanguageTag::RegionSubtag region);
-
- boost::optional<dcp::LanguageTag::RegionSubtag> get () const;
-
-private:
- LanguageSubtagPanel* _panel;
+ std::vector<dcp::LanguageTag> _presets;
+ std::vector<dcp::LanguageTag> _custom;
+ wxListCtrl* _list;
};
+#endif