AuboCaps  0.5.0
keyboard_number_input.h
Go to the documentation of this file.
1 #ifndef AUBO_SCOPE_KEYBOARD_NUMBER_INPUT_H
2 #define AUBO_SCOPE_KEYBOARD_NUMBER_INPUT_H
3 
4 #include <string>
5 #include <memory>
6 #include <functional>
9 
10 class QWidget;
11 
12 namespace arcs {
13 namespace aubo_scope {
14 
15 /**
16  * Interface representing the virtual numeric keypad used for configuring it and
17  * requesting it to be displayed in PolyScope.
18  *
19  * @tparam <T> The (generic) type parameter for the interface representing the
20  * type of input data entered by the end user via the virtual keypad. Relevant
21  * types are e.g. {@link Integer} and {@link Double}.
22  *
23  */
24 template <typename T>
26 {
27 public:
30  virtual ~KeyboardNumberInput();
31 
32  /**
33  * <p>
34  * Sets an input validator for the virtual numeric keypad. This validator
35  * will be used to validate the input entered by the end user. Some standard
36  * validators are available in {@link
37  * userinteraction.inputvalidation.InputValidationFactory}.
38  * </p>
39  *
40  * <p>
41  * Specifying an input validator is recommended, but optional.
42  * </p>
43  *
44  * In case {@link InputValidator#isValid(Object)} returns
45  * <code>false</code>, the accept button on the virtual keypad will be
46  * disabled and the error message from {@link
47  * InputValidator#getMessage(Object)} will be shown.
48  *
49  * @param validator the validator to be used to validate keypad user input.
50  * @return this KeyboardNumberInput object.
51  * @throws NullPointerException in case the validator is <code>null</code>.
52  */
53  void setErrorValidator(const std::shared_ptr<InputValidator<T>> &validator);
54 
55  /**
56  * Sets the initial value which will be displayed when the virtual numeric
57  * keypad is shown.
58  *
59  * @param initialValue the initial value for the virtual keypad.
60  * @return this KeyboardNumberInput object.
61  */
62  void setInitialValue(T initialValue);
63 
64  /**
65  * This method requests the virtual numeric keypad to be shown.
66  *
67  * @param component the JTextField that will be used to define the screen
68  * position of the virtual keypad. The component must be visible on the
69  * screen at the time of showing the keypad.
70  * @param callback the callback to be used when the end user exits the
71  * keypad by accepting or canceling the input.
72  * @throws NullPointerException in case any parameter is <code>null</code>.
73  */
74  void show(QWidget *component, const std::function<void(bool, T)> &callback);
75 
76 private:
77  friend class DataSwitch;
79  void *d_{ nullptr };
80 };
81 
85 
86 } // namespace aubo_scope
87 } // namespace arcs
88 
89 #endif
Interface representing the virtual numeric keypad used for configuring it and requesting it to be dis...
#define ARCS_ABI_EXPORT
Definition: class_forward.h:16