Merge master.
[dcpomatic.git] / src / wx / wx_util.cc
index a5399e62ea4d798c2957c36eb20a6586e84c3e0f..94a08f37289625eaf4c660ab4ba5c81d6b5cab36 100644 (file)
@@ -189,6 +189,15 @@ checked_set (wxSpinCtrl* widget, int value)
        }
 }
 
+void
+checked_set (wxSpinCtrlDouble* widget, double value)
+{
+       /* XXX: completely arbitrary epsilon */
+       if (fabs (widget->GetValue() - value) < 1e-16) {
+               widget->SetValue (value);
+       }
+}
+
 void
 checked_set (wxChoice* widget, int value)
 {
@@ -296,3 +305,35 @@ wx_get (wxChoice* w)
 {
        return w->GetSelection ();
 }
+
+double
+wx_get (wxSpinCtrlDouble* w)
+{
+       return w->GetValue ();
+}
+
+void
+run_gui_loop ()
+{
+       while (wxTheApp->Pending ()) {
+               wxTheApp->Dispatch ();
+       }
+}
+
+/** @param s String of the form Context|String
+ *  @return translation, or String if no translation is available.
+ */
+wxString
+context_translation (wxString s)
+{
+       wxString t = wxGetTranslation (s);
+       if (t == s) {
+               /* No translation; strip the context */
+               int c = t.Find (wxT ("|"));
+               if (c != wxNOT_FOUND) {
+                       t = t.Mid (c + 1);
+               }
+       }
+
+       return t;
+}