Hand-apply b737b25e10a4bcfb8cb645e95a089192347b4805 from master; more deflickering.
[dcpomatic.git] / src / wx / wx_util.cc
index 0119799d26aaa3d0c8ff17dde466169877d6fd78..a46ba98e27a55ebbc998db346f53de2c3d8af52b 100644 (file)
@@ -179,6 +179,29 @@ checked_set (wxChoice* widget, string value)
        }
 }
 
+void
+checked_set (wxChoice* widget, vector<pair<string, string> > items)
+{
+       vector<pair<string, string> > current;
+       for (unsigned int i = 0; i < widget->GetCount(); ++i) {
+               current.push_back (
+                       make_pair (
+                               wx_to_std (widget->GetString (i)),
+                               string_client_data (widget->GetClientObject (i))
+                               )
+                       );
+       }
+
+       if (current == items) {
+               return;
+       }
+
+       widget->Clear ();
+       for (vector<pair<string, string> >::const_iterator i = items.begin(); i != items.end(); ++i) {
+               widget->Append (std_to_wx (i->first), new wxStringClientData (std_to_wx (i->second)));
+       }
+}
+
 void
 checked_set (wxTextCtrl* widget, string value)
 {
@@ -187,6 +210,14 @@ checked_set (wxTextCtrl* widget, string value)
        }
 }
 
+void
+checked_set (wxTextCtrl* widget, wxString value)
+{
+       if (widget->GetValue() != value) {
+               widget->ChangeValue (value);
+       }
+}
+
 void
 checked_set (wxStaticText* widget, string value)
 {
@@ -195,6 +226,14 @@ checked_set (wxStaticText* widget, string value)
        }
 }
 
+void
+checked_set (wxStaticText* widget, wxString value)
+{
+       if (widget->GetLabel() != value) {
+               widget->SetLabel (value);
+       }
+}
+
 void
 checked_set (wxCheckBox* widget, bool value)
 {