+template <class T>
+class Timecode : public TimecodeBase
+{
+public:
+ Timecode (wxWindow* parent, bool set_button = true)
+ : TimecodeBase (parent, set_button)
+ {
+
+ }
+
+ void set (T t, float fps)
+ {
+ auto const hmsf = t.split (fps);
+
+ checked_set (_hours, dcp::raw_convert<std::string>(hmsf.h));
+ checked_set (_minutes, dcp::raw_convert<std::string>(hmsf.m));
+ checked_set (_seconds, dcp::raw_convert<std::string>(hmsf.s));
+ checked_set (_frames, dcp::raw_convert<std::string>(hmsf.f));
+
+ checked_set (_fixed, t.timecode (fps));
+ }
+
+ void set_hint (T t, float fps)
+ {
+ auto hmsf = t.split (fps);
+
+ _hours->SetHint (std_to_wx(dcp::raw_convert<std::string>(hmsf.h)));
+ _minutes->SetHint (std_to_wx(dcp::raw_convert<std::string>(hmsf.m)));
+ _seconds->SetHint (std_to_wx(dcp::raw_convert<std::string>(hmsf.s)));
+ _frames->SetHint (std_to_wx(dcp::raw_convert<std::string>(hmsf.f)));
+ }
+
+ dcpomatic::HMSF get () const
+ {
+ auto value_or_hint = [](wxTextCtrl const * t) {
+ auto s = wx_to_std (t->GetValue().IsEmpty() ? t->GetHint() : t->GetValue());
+ if (s.empty()) {
+ return 0;
+ }
+ return dcp::raw_convert<int>(s);
+ };
+
+ return { value_or_hint(_hours),
+ value_or_hint(_minutes),
+ value_or_hint(_seconds),
+ value_or_hint(_frames) };
+ }
+
+ T get (float fps) const
+ {
+ return T(get(), fps);
+ }
+};
+
+#endif