Merge master.
[dcpomatic.git] / src / wx / wx_util.cc
index 048f87908e8c72770e973f0450a36767c1b747f3..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)
 {
@@ -297,6 +306,12 @@ wx_get (wxChoice* w)
        return w->GetSelection ();
 }
 
+double
+wx_get (wxSpinCtrlDouble* w)
+{
+       return w->GetValue ();
+}
+
 void
 run_gui_loop ()
 {
@@ -304,3 +319,21 @@ run_gui_loop ()
                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;
+}