Fcitx
inputpanel.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017-2017 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 #ifndef _FCITX_INPUTPANEL_H_
8 #define _FCITX_INPUTPANEL_H_
9 
10 #include <functional>
11 #include <fcitx/candidatelist.h>
12 #include "fcitxcore_export.h"
13 
14 /// \addtogroup FcitxCore
15 /// \{
16 /// \file
17 /// \brief Class for input panel in UI.
18 
19 namespace fcitx {
20 
21 class InputPanelPrivate;
22 class InputContext;
23 
24 using CustomInputPanelCallback = std::function<void(InputContext *)>;
25 
26 /**
27  * Input Panel is usually a floating window that is display at the cursor of
28  * input.
29  *
30  * But it can also be a embedded fixed window. The actual representation is
31  * implementation-defined. In certain cases, all the information input panel is
32  * forwarded to client and will be drawn by client.
33  *
34  * A common input panel is shown as
35  *
36  * | Aux Up | Preedit |
37  * |----------|------------------|
38  * | Aux down | Candidate 1, 2.. |
39  * Or
40  * | Aux Up | Preedit |
41  * |--------|--------------------|
42  * | Aux down ||
43  * | Candidate 1 ||
44  * | Candidate 2 ||
45  * | ... ||
46  * | Candidate n ||
47  */
48 class FCITXCORE_EXPORT InputPanel {
49 public:
50  /// Construct a Input Panel associated with given input context.
52  virtual ~InputPanel();
53 
54  const Text &preedit() const;
55  void setPreedit(const Text &text);
56 
57  const Text &auxUp() const;
58  void setAuxUp(const Text &text);
59 
60  const Text &auxDown() const;
61  void setAuxDown(const Text &text);
62 
63  /// The preedit text embedded in client window.
64  const Text &clientPreedit() const;
65  void setClientPreedit(const Text &clientPreedit);
66 
67  std::shared_ptr<CandidateList> candidateList() const;
68  void setCandidateList(std::unique_ptr<CandidateList> candidate);
69 
70  /**
71  * Return the current input panel display callback.
72  *
73  * @see setCustomInputPanelCallback
74  * @return current custom ui callback
75  * @since 5.0.24
76  */
77  const CustomInputPanelCallback &customInputPanelCallback() const;
78 
79  /**
80  * Set a custom callback to display the input panel.
81  *
82  * When this is set,
83  * Instance::updateUserInterface(UserInterfaceComponent::InputPanel) will
84  * trigger a call to the callback function instead. The capability flag
85  * ClientSideInputPanel will not be respected, but the clientPreedit will
86  * still be sent if InputContext::updatePreedit is called.
87  *
88  * All the UI display batching logic still applies. The actual update that
89  * triggers this callback will be called as a deferred event after current
90  * event. If you need UI update right away (rare), you can still true as
91  * immediate to Instance::updateUserInterface.
92  *
93  * @param callback callback to display input panel.
94  *
95  * @since 5.0.24
96  */
97  void setCustomInputPanelCallback(CustomInputPanelCallback callback);
98 
99  const CustomInputPanelCallback &customVirtualKeyboardCallback() const;
100 
101  void setCustomVirtualKeyboardCallback(CustomInputPanelCallback callback);
102 
103  void reset();
104 
105  /// Whether input panel is totally empty.
106  bool empty() const;
107 
108 private:
109  std::unique_ptr<InputPanelPrivate> d_ptr;
110  FCITX_DECLARE_PRIVATE(InputPanel);
111 };
112 } // namespace fcitx
113 
114 #endif // _FCITX_INPUTPANEL_H_
Definition: action.cpp:12
A class represents a formatted string.
Definition: text.h:27
Input Panel is usually a floating window that is display at the cursor of input.
Definition: inputpanel.h:48
An input context represents a client of Fcitx.
Definition: inputcontext.h:45