X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fwx_util.cc;h=cf8b75dd24b78a66a6c0c7438514ca2b57bd2292;hb=cb1dfa9ec09af2abf6d10e4bf2764476db83841b;hp=048f87908e8c72770e973f0450a36767c1b747f3;hpb=cfdd68eb5fb0ef8423e860103ad4e5510994f1da;p=dcpomatic.git diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 048f87908..cf8b75dd2 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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,10 +306,26 @@ wx_get (wxChoice* w) return w->GetSelection (); } -void -run_gui_loop () +double +wx_get (wxSpinCtrlDouble* w) { - while (wxTheApp->Pending ()) { - wxTheApp->Dispatch (); + return w->GetValue (); +} + +/** @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; }