AuboCaps  0.4.1
keyboard_expression_input.h
Go to the documentation of this file.
1 #ifndef AUBO_SCOPE_KEYBOARD_EXPRESSION_INPUT_H
2 #define AUBO_SCOPE_KEYBOARD_EXPRESSION_INPUT_H
3 
4 #include <memory>
5 #include <functional>
6 
10 
11 class QWidget;
12 
13 namespace arcs {
14 namespace aubo_scope {
15 
16 ARCS_CLASS_FORWARD(Expression);
17 ARCS_CLASS_FORWARD(KeyboardExpressionInput);
18 
19 /**
20  * Interface representing the virtual keyboard used for configuring it and
21  * requesting it to be displayed in PolyScope.
22  */
24 {
25 public:
28  virtual ~KeyboardExpressionInput();
29 
30  /**
31  * <p>
32  * Sets an input validator for the virtual keyboard. This validator will be
33  * used to validate the input entered by the user. Some standard validators
34  * are available in {@link
35  * domain.userinteraction.inputvalidation.InputValidationFactory}.
36  * </p>
37  *
38  * <p>
39  * Specifying an input validator is recommended, but optional.
40  * </p>
41  *
42  * In case {@link InputValidator#isValid(Object)} (in this case parameter is
43  * {@link String}) returns <code>false</code>, the accept button on the
44  * virtual keyboard will be disabled and the error message from {@link
45  * InputValidator#getMessage(Object)} (parameter is {@link String}) will be
46  * shown.
47  *
48  * @param validator the validator to be used to validate keyboard user
49  * input.
50  * @return this KeyboardTextInput object.
51  * @throws NullPointerException in case the validator is <code>null</code>.
52  */
53  void setErrorValidator(
54  const std::shared_ptr<InputValidator<ExpressionPtr>> &validator);
55 
56  /**
57  * Sets the text which will be displayed when the virtual keyboard is shown.
58  *
59  * @param initialExpression the initial text for the virtual keyboard.
60  * @return this KeyboardTextInput object.
61  */
62  void setInitialValue(const ExpressionPtr &initialExpression);
63 
64  /**
65  * This method requests the virtual keyboard to be shown.
66  *
67  * @param component the JTextField that will be used to define the screen
68  * position of the virtual keyboard. 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 user exits the keyboard
71  * by accepting or canceling the input.
72  * @throws NullPointerException in case any parameter is <code>null</code>.
73  */
74  void show(QWidget *component,
75  const std::function<void(bool, const ExpressionPtr &)> &callback);
76 
77 private:
78  friend class DataSwitch;
80  void *d_{ nullptr };
81 };
82 } // namespace aubo_scope
83 } // namespace arcs
84 
85 #endif
ARCS_CLASS_FORWARD(GripForceCapability)
Interface representing the virtual keyboard used for configuring it and requesting it to be displayed...
#define ARCS_ABI_EXPORT
Definition: class_forward.h:16