diff options
Diffstat (limited to 'shared/util.h')
-rw-r--r-- | shared/util.h | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/shared/util.h b/shared/util.h index 2c9af176..2aa48af9 100644 --- a/shared/util.h +++ b/shared/util.h @@ -30,23 +30,6 @@ wxString toStringSep(NumberType number); //convert number to wxString including void scrollToBottom(wxScrolledWindow* scrWindow); wxString utcTimeToLocalString(zen::Int64 utcTime); //throw std::runtime_error - - -//handle mapping of enum values to wxChoice controls -template <class Enum> -struct EnumDescrList -{ - EnumDescrList& add(Enum value, const wxString& text, const wxString& tooltip = wxEmptyString) - { - descrList.push_back(std::make_pair(value, std::make_pair(text, tooltip))); - return *this; - } - typedef std::vector<std::pair<Enum, std::pair<wxString, wxString> > > DescrList; - DescrList descrList; -}; -template <class Enum> void setEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl, Enum value); -template <class Enum> Enum getEnumVal(const EnumDescrList<Enum>& mapping, const wxChoice& ctrl); -template <class Enum> void updateTooltipEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl); } @@ -91,51 +74,6 @@ wxString toStringSep(NumberType number) { return ffs_Impl::includeNumberSeparator(zen::toString<wxString>(number)); } - -template <class Enum> -void setEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl, Enum value) -{ - ctrl.Clear(); - - int selectedPos = 0; - for (typename EnumDescrList<Enum>::DescrList::const_iterator i = mapping.descrList.begin(); i != mapping.descrList.end(); ++i) - { - ctrl.Append(i->second.first); - if (i->first == value) - { - selectedPos = i - mapping.descrList.begin(); - - if (!i->second.second.empty()) - ctrl.SetToolTip(i->second.second); - } - } - - ctrl.SetSelection(selectedPos); -} - -template <class Enum> -Enum getEnumVal(const EnumDescrList<Enum>& mapping, const wxChoice& ctrl) -{ - const int selectedPos = ctrl.GetSelection(); - - if (0 <= selectedPos && selectedPos < static_cast<int>(mapping.descrList.size())) - return mapping.descrList[selectedPos].first; - else - { - assert(false); - return Enum(0); - } -} - -template <class Enum> void updateTooltipEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl) -{ - const Enum value = getEnumVal(mapping, ctrl); - - for (typename EnumDescrList<Enum>::DescrList::const_iterator i = mapping.descrList.begin(); i != mapping.descrList.end(); ++i) - if (i->first == value) - ctrl.SetToolTip(i->second.second); -} - } |