WSJT-X/HintedSpinBox.hpp
Bill Somerville 095fa7740e Proper custom spin boxes for frequency tolerance and T/R period
These were using a hijacked custom spin box that was designed only for
letters i.e. submodes. Now there are two new custom spin boxes.

HistedSpinBox:- can  be set with  a list  of integer values  which the
step  up and  down  will  follow. Optionally  limits  the maximum  and
minimum value  to the upper and  lower bounds of the  values set. Note
that intermediate values are still valid.

RestrictedSpinBox:- more like a combo  box because the provided values
are the only ones that can be set.

HintedSpinBox   is    used   for    the   frequency    tolerance   and
RestrictedSpinBox is used for T/R period.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7698 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-05-27 20:04:44 +00:00

54 lines
1.3 KiB
C++

#ifndef HINTED_SPIN_BOX_HPP_
#define HINTED_SPIN_BOX_HPP_
#include <vector>
#include <QSpinBox>
//
// HintedSpinBox - QSpinBox refinement with an optional sequence of
// discrete hints
//
// The hint sequence values are used as step values and can
// optionally define the minimum and maximum value. Intermediate
// values are allowed but the step up/down arrows and accelerator
// keys will only use the hints.
//
// Ensure that the default minimum and maximum values are sufficient
// to allow initial initialization if done before the hints are set.
//
class HintedSpinBox
: public QSpinBox
{
public:
typedef std::vector<int> values_type;
HintedSpinBox (QWidget * parent = nullptr)
: QSpinBox {parent}
{
}
// Initialize sequence of values allowed.
//
// This spin box behaves exactly as a standard QSpinBox if the
// sequence of values is empty.
//
// The minimum and maximum are automatically set to the lowest and
// highest value provided if required.
//
// Returns the previous sequence.
values_type values (values_type values, bool set_min_max = true);
// Read access to the values.
values_type const& values () const {return values_;}
protected:
// override the QSpinBox stepping
void stepBy (int steps) override;
private:
std::vector<int> values_;
};
#endif