Refactoring:

1. Use C++ style cast instead of C style
2. Deleted unused code from Search
This commit is contained in:
YuSanka 2020-11-26 13:45:30 +01:00
parent d9be78d4cb
commit 7f22ce63f6
18 changed files with 110 additions and 256 deletions

View file

@ -38,39 +38,6 @@ using t_back_to_init = std::function<void(const std::string&)>;
wxString double_to_string(double const value, const int max_precision = 4);
class RevertButton : public ScalableButton
{
bool hidden = false; // never show button if it's hidden ones
public:
// RevertButton() {}
// RevertButton(wxWindow* parent, wxWindowID id, const wxString& label = wxEmptyString,
// const wxPoint& pos = wxDefaultPosition,
// const wxSize& size = wxDefaultSize, long style = 0,
// const wxValidator& validator = wxDefaultValidator,
// const wxString& name = wxTextCtrlNameStr)
// {
// this->Create(parent, id, label, pos, size, style, validator, name);
// }
RevertButton(
wxWindow *parent,
const std::string& icon_name = ""
) :
ScalableButton(parent, wxID_ANY, icon_name) {}
// overridden from wxWindow base class
virtual bool
AcceptsFocusFromKeyboard() const { return false; }
void set_as_hidden() {
Hide();
hidden = true;
}
virtual bool Show(bool show = true) override {
return wxButton::Show(hidden ? false : show);
}
};
class Field {
protected:
// factory function to defer and enforce creation of derived type.
@ -283,14 +250,14 @@ public:
void propagate_value();
wxWindow* window {nullptr};
virtual void set_value(const std::string& value, bool change_event = false) {
void set_value(const std::string& value, bool change_event = false) {
m_disable_change_event = !change_event;
dynamic_cast<wxTextCtrl*>(window)->SetValue(wxString(value));
m_disable_change_event = false;
}
virtual void set_value(const boost::any& value, bool change_event = false) override;
virtual void set_last_meaningful_value() override;
virtual void set_na_value() override;
void set_value(const boost::any& value, bool change_event = false) override;
void set_last_meaningful_value() override;
void set_na_value() override;
boost::any& get_value() override;
@ -392,7 +359,7 @@ public:
void set_selection();
void set_value(const std::string& value, bool change_event = false);
void set_value(const boost::any& value, bool change_event = false);
void set_value(const boost::any& value, bool change_event = false) override;
void set_values(const std::vector<std::string> &values);
void set_values(const wxArrayString &values);
boost::any& get_value() override;
@ -448,7 +415,7 @@ public:
// Propagate value from field to the OptionGroupe and Config after kill_focus/ENTER
void propagate_value(wxTextCtrl* win);
void set_value(const Vec2d& value, bool change_event = false);
void set_value(const boost::any& value, bool change_event = false);
void set_value(const boost::any& value, bool change_event = false) override;
boost::any& get_value() override;
void msw_rescale() override;
@ -478,7 +445,7 @@ public:
dynamic_cast<wxStaticText*>(window)->SetLabel(wxString::FromUTF8(value.data()));
m_disable_change_event = false;
}
void set_value(const boost::any& value, bool change_event = false) {
void set_value(const boost::any& value, bool change_event = false) override {
m_disable_change_event = !change_event;
dynamic_cast<wxStaticText*>(window)->SetLabel(boost::any_cast<wxString>(value));
m_disable_change_event = false;
@ -509,7 +476,7 @@ public:
void BUILD() override;
void set_value(const int value, bool change_event = false);
void set_value(const boost::any& value, bool change_event = false);
void set_value(const boost::any& value, bool change_event = false) override;
boost::any& get_value() override;
void enable() override {