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
39namespace Pt {
40
41namespace Forms {
42
43class Window;
44class PushButton;
45class FlowLayout;
46class Application;
47
58class 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
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
Connectable()
Default constructor.
Provides the runtime root of a Forms user interface.
Definition Application.h:88
Reusable view used as application content.
Definition Control.h:107
virtual Window * onActiveWindow()
Returns the active text-entry window, or 0.
virtual void onBegin()
Starts the platform or custom text-entry session.
virtual void onFinish()
Finishes the platform or custom text-entry session.
DefaultInputMethod()
Creates the default input method.
Arranges children in a single row or column.
Definition FlowLayout.h:72
virtual ~InputMethod()
Destructor.
void begin(Control &control)
Begins a session for control.
void finish()
Ends the current session.
virtual void onBegin()=0
Starts the platform or custom text-entry session.
Widget * receiver() const
Returns the current receiver, or 0.
bool isVisible() const
Returns true when the method is showing UI.
void sendEvent(const KeyEvent &ev)
Sends ev to the current receiver.
virtual Window * onActiveWindow()=0
Returns the active text-entry window, or 0.
virtual void onFinish()=0
Finishes the platform or custom text-entry session.
Window * activeWindow()
Returns the method's active window, or 0.
InputMethod()
Creates an inactive input method.
Key press or release.
Definition KeyEvent.h:50
Command button with optional toggle, icon, and caption.
Definition PushButton.h:77
Common type of every visual Forms object.
Definition Widget.h:105
Form presented by a window manager.
Definition Window.h:99
uint_type uint64_t
Unsigned 64-bit integer type.
Definition Api-Types.h:66
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33