#include <wx/srchctrl.h>
#include <wx/wx.h>
#include <boost/algorithm/string.hpp>
-#include <boost/bind.hpp>
-#include <boost/foreach.hpp>
+#include <boost/bind/bind.hpp>
#include <boost/optional.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
#include <iostream>
#include <iterator>
using std::string;
using std::vector;
using boost::optional;
-using boost::shared_ptr;
-using boost::weak_ptr;
+using std::shared_ptr;
+using std::weak_ptr;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
SetItemState (item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
EnsureVisible (item);
}
+ } else {
+ if (GetItemCount() > 0) {
+ /* The new list sometimes isn't visible without this */
+ EnsureVisible (0);
+ }
}
}
_matching_subtags.clear ();
boost::algorithm::to_lower(search);
- BOOST_FOREACH (dcp::LanguageTag::SubtagData const& i, _all_subtags) {
+ for (auto const& i: _all_subtags) {
if (
(boost::algorithm::to_lower_copy(i.subtag).find(search) != string::npos) ||
(boost::algorithm::to_lower_copy(i.description).find(search) != string::npos)) {
SetSizerAndFit (overall_sizer);
- bool have_language = false;
- vector<pair<dcp::LanguageTag::SubtagType, dcp::LanguageTag::SubtagData> > subtags = tag.subtags();
- for (vector<pair<dcp::LanguageTag::SubtagType, dcp::LanguageTag::SubtagData> >::const_iterator i = subtags.begin(); i != subtags.end(); ++i) {
- add_to_current_tag (i->first, i->second);
- if (i->first == dcp::LanguageTag::LANGUAGE) {
- have_language = true;
- }
- }
-
- if (!have_language) {
- add_to_current_tag (dcp::LanguageTag::LANGUAGE, dcp::LanguageTag::SubtagData("en", "English"));
- }
+ set (tag);
_add_script->Bind (wxEVT_BUTTON, boost::bind(&LanguageTagDialog::add_to_current_tag, this, dcp::LanguageTag::SCRIPT, boost::optional<dcp::LanguageTag::SubtagData>()));
_add_region->Bind (wxEVT_BUTTON, boost::bind(&LanguageTagDialog::add_to_current_tag, this, dcp::LanguageTag::REGION, boost::optional<dcp::LanguageTag::SubtagData>()));
vector<dcp::LanguageTag::VariantSubtag> variants;
vector<dcp::LanguageTag::ExtlangSubtag> extlangs;
- BOOST_FOREACH (Subtag i, _current_tag_subtags) {
+ for (auto i: _current_tag_subtags) {
if (!i.subtag) {
continue;
}
}
+void
+LanguageTagDialog::set (dcp::LanguageTag tag)
+{
+ _current_tag_subtags.clear ();
+ _current_tag_list->DeleteAllItems ();
+
+ bool have_language = false;
+ vector<pair<dcp::LanguageTag::SubtagType, dcp::LanguageTag::SubtagData> > subtags = tag.subtags();
+ for (vector<pair<dcp::LanguageTag::SubtagType, dcp::LanguageTag::SubtagData> >::const_iterator i = subtags.begin(); i != subtags.end(); ++i) {
+ add_to_current_tag (i->first, i->second);
+ if (i->first == dcp::LanguageTag::LANGUAGE) {
+ have_language = true;
+ }
+ }
+
+ if (!have_language) {
+ add_to_current_tag (dcp::LanguageTag::LANGUAGE, dcp::LanguageTag::SubtagData("en", "English"));
+ }
+}
+
+
string LanguageTagDialog::subtag_type_name (dcp::LanguageTag::SubtagType type)
{
switch (type) {
_add_region->Enable ();
_add_variant->Enable ();
_add_external->Enable ();
- BOOST_FOREACH (Subtag const& i, _current_tag_subtags) {
+ for (auto const& i: _current_tag_subtags) {
switch (i.type) {
case dcp::LanguageTag::SCRIPT:
_add_script->Enable (false);