InputMethod.h
1 /* Copyright (C) 2016 Marc Boris Duerner
2  Copyright (C) 2016 Laurentiu-Gheorghe Crisan
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  As a special exception, you may use this file as part of a free
10  software library without restriction. Specifically, if other files
11  instantiate templates or use macros or inline functions from this
12  file, or you compile this file and link it with other files to
13  produce an executable, this file does not by itself cause the
14  resulting executable to be covered by the GNU General Public
15  License. This exception does not however invalidate any other
16  reasons why the executable file might be covered by the GNU Library
17  General Public License.
18 
19  This library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  Lesser General Public License for more details.
23 
24  You should have received a copy of the GNU Lesser General Public
25  License along with this library; if not, write to the Free Software
26  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27  MA 02110-1301 USA
28 */
29 
30 #ifndef Pt_Forms_InputMethod_H
31 #define Pt_Forms_InputMethod_H
32 
33 #include <Pt/Forms/Api.h>
34 #include <Pt/Forms/KeyEvent.h>
35 #include <Pt/Forms/MouseEvent.h>
36 
37 #include <Pt/Connectable.h>
38 
39 namespace Pt {
40 
41 namespace Forms {
42 
43 class Window;
44 class PushButton;
45 class FlowLayout;
46 class Application;
47 
58 class PT_FORMS_API InputMethod
59 {
60  friend class Application;
61 
62  public:
66 
69  virtual ~InputMethod();
70 
73  bool isVisible() const;
74 
78 
83  void begin(Control& control);
84 
87  void finish();
88 
91  Widget* receiver() const;
92 
95  void sendEvent(const KeyEvent& ev);
96 
97  protected:
100  virtual void onBegin() = 0;
101 
104  virtual void onFinish() = 0;
105 
108  virtual Window* onActiveWindow() = 0;
109 
110  private:
111  void registerApplication(Application& app);
112 
113  void unregisterApplication(Application& app);
114 
115  private:
116  Application* _app;
117  Pt::uint64_t _receiver;
118  KeyEvent _keyEvent;
119  bool _isVisible;
120 };
121 
122 
128  , public Connectable
129 {
130  public:
134 
138 
139  protected:
140  virtual void onBegin();
141 
142  virtual void onFinish();
143 
144  virtual Window* onActiveWindow();
145 
146  private:
147  void onKeyPress();
148 
149  private:
150  Window* _window;
151  FlowLayout* _layout;
152  PushButton* _keyButtonA;
153  PushButton* _keyButtonB;
154 };
155 
156 } // namespace
157 
158 } // namespace
159 
160 #endif
Core module.
Definition: Allocator.h:33
Key press or release.
Definition: KeyEvent.h:50
DefaultInputMethod()
Creates the default input method.
Widget * receiver() const
Returns the current receiver, or 0.
void sendEvent(const KeyEvent &ev)
Sends ev to the current receiver.
Window * activeWindow()
Returns the method's active window, or 0.
Form presented by a window manager.
Definition: Window.h:99
Command button with optional toggle, icon, and caption.
Definition: PushButton.h:77
Common type of every visual Forms object.
Definition: Widget.h:105
virtual Window * onActiveWindow()=0
Returns the active text-entry window, or 0.
Reusable view used as application content.
Definition: Control.h:107
bool isVisible() const
Returns true when the method is showing UI.
void finish()
Ends the current session.
virtual void onFinish()=0
Finishes the platform or custom text-entry session.
Connection Management for Signal and Slot Objects.
Definition: Connectable.h:50
Provides the runtime root of a Forms user interface.
Definition: Application.h:88
virtual void onBegin()=0
Starts the platform or custom text-entry session.
Extension for platform or custom text entry.
Definition: InputMethod.h:59
InputMethod()
Creates an inactive input method.
Arranges children in a single row or column.
Definition: FlowLayout.h:72
Provides the application-owned default input method.
Definition: InputMethod.h:129
~DefaultInputMethod()
Destructor.
virtual void onBegin()
Starts the platform or custom text-entry session.
virtual void onFinish()
Finishes the platform or custom text-entry session.
void begin(Control &control)
Begins a session for control.
virtual Window * onActiveWindow()
Returns the active text-entry window, or 0.
virtual ~InputMethod()
Destructor.
uint_type uint64_t
Unsigned 64-bit integer type.
Definition: Api-Types.h:62