X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fwx_util.cc;h=94a08f37289625eaf4c660ab4ba5c81d6b5cab36;hb=d2137ac5db409e686b4d9b3fa567935a5e416d41;hp=048f87908e8c72770e973f0450a36767c1b747f3;hpb=8102046b2f29e0c7b234c29bf204b056cb30e64f;p=dcpomatic.git diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 048f87908..94a08f372 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -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; +}