Qt6: added QInputMethod and QKeyCombination classes to the C bindings.

(cherry picked from commit b915e78b9a)

Co-authored-by: Željan Rikalo <zeljko@lazarus-ide.org>
This commit is contained in:
Željan Rikalo 2024-11-22 07:27:40 +00:00 committed by Željan Rikalo
parent 3a11092878
commit 1c8b820866
7 changed files with 494 additions and 0 deletions

View File

@ -0,0 +1,111 @@
//******************************************************************************
// Copyright (c) 2024 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#include "qinputmethod_c.h"
void QInputMethod_anchorRectangle(QInputMethodH handle, QRectFH retval)
{
*(QRectF *)retval = ((QInputMethod *)handle)->anchorRectangle();
}
void QInputMethod_cursorRectangle(QInputMethodH handle, QRectFH retval)
{
*(QRectF *)retval = ((QInputMethod *)handle)->cursorRectangle();
}
Qt::LayoutDirection QInputMethod_inputDirection(QInputMethodH handle)
{
return (Qt::LayoutDirection) ((QInputMethod *)handle)->inputDirection();
}
void QInputMethod_inputItemClipRectangle(QInputMethodH handle, QRectFH retval)
{
*(QRectF *)retval = ((QInputMethod *)handle)->inputItemClipRectangle();
}
void QInputMethod_inputItemRectangle(QInputMethodH handle, QRectFH retval)
{
*(QRectF *)retval = ((QInputMethod *)handle)->inputItemRectangle();
}
void QInputMethod_inputItemTransform(QInputMethodH handle, QTransformH retval)
{
*(QTransform *)retval = ((QInputMethod *)handle)->inputItemTransform();
}
bool QInputMethod_isAnimating(QInputMethodH handle)
{
return (bool) ((QInputMethod *)handle)->isAnimating();
}
void QInputMethod_keyboardRectangle(QInputMethodH handle, QRectFH retval)
{
*(QRectF *)retval = ((QInputMethod *)handle)->keyboardRectangle();
}
void QInputMethod_locale(QInputMethodH handle, QLocaleH retval)
{
*(QLocale *)retval = ((QInputMethod *)handle)->locale();
}
void QInputMethod_setInputItemRectangle(QInputMethodH handle, QRectFH rect)
{
((QInputMethod *)handle)->setInputItemRectangle(*(const QRectF*)rect);
}
void QInputMethod_setInputItemTransform(QInputMethodH handle, QTransformH transform)
{
((QInputMethod *)handle)->setInputItemTransform(*(const QTransform*)transform);
}
bool QInputMethod_isVisible(QInputMethodH handle)
{
return (bool) ((QInputMethod *)handle)->isVisible();
}
void QInputMethod_setVisible(QInputMethodH handle, bool visible)
{
((QInputMethod *)handle)->setVisible(visible);
}
void QInputMethod_commit(QInputMethodH handle)
{
((QInputMethod *)handle)->commit();
}
void QInputMethod_hide(QInputMethodH handle)
{
((QInputMethod *)handle)->hide();
}
void QInputMethod_invokeAction(QInputMethodH handle, QInputMethod::Action a, int cursorPosition)
{
((QInputMethod *)handle)->invokeAction(a, cursorPosition);
}
void QInputMethod_reset(QInputMethodH handle)
{
((QInputMethod *)handle)->reset();
}
void QInputMethod_show(QInputMethodH handle)
{
((QInputMethod *)handle)->show();
}
void QInputMethod_update(QInputMethodH handle, Qt::InputMethodQueries queries)
{
((QInputMethod *)handle)->update(queries);
}

View File

@ -0,0 +1,38 @@
//******************************************************************************
// Copyright (c) 2024 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#ifndef QINPUTMETHOD_C_H
#define QINPUTMETHOD_C_H
#include <QtGui>
#include "pascalbind.h"
C_EXPORT void QInputMethod_anchorRectangle(QInputMethodH handle, QRectFH retval);
C_EXPORT void QInputMethod_cursorRectangle(QInputMethodH handle, QRectFH retval);
C_EXPORT Qt::LayoutDirection QInputMethod_inputDirection(QInputMethodH handle);
C_EXPORT void QInputMethod_inputItemClipRectangle(QInputMethodH handle, QRectFH retval);
C_EXPORT void QInputMethod_inputItemRectangle(QInputMethodH handle, QRectFH retval);
C_EXPORT void QInputMethod_inputItemTransform(QInputMethodH handle, QTransformH retval);
C_EXPORT bool QInputMethod_isAnimating(QInputMethodH handle);
C_EXPORT void QInputMethod_keyboardRectangle(QInputMethodH handle, QRectFH retval);
C_EXPORT void QInputMethod_locale(QInputMethodH handle, QLocaleH retval);
C_EXPORT void QInputMethod_setInputItemRectangle(QInputMethodH handle, QRectFH rect);
C_EXPORT void QInputMethod_setInputItemTransform(QInputMethodH handle, QTransformH transform);
C_EXPORT bool QInputMethod_isVisible(QInputMethodH handle);
C_EXPORT void QInputMethod_setVisible(QInputMethodH handle, bool visible);
C_EXPORT void QInputMethod_commit(QInputMethodH handle);
C_EXPORT void QInputMethod_hide(QInputMethodH handle);
C_EXPORT void QInputMethod_invokeAction(QInputMethodH handle, QInputMethod::Action a, int cursorPosition);
C_EXPORT void QInputMethod_reset(QInputMethodH handle);
C_EXPORT void QInputMethod_show(QInputMethodH handle);
C_EXPORT void QInputMethod_update(QInputMethodH handle, Qt::InputMethodQueries queries);
#endif

View File

@ -0,0 +1,168 @@
//******************************************************************************
// Copyright (c) 2024 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#ifndef QINPUTMETHOD_HOOK_H
#define QINPUTMETHOD_HOOK_H
#include <qinputmethod.h>
#include "qobject_hook.h"
class QInputMethod_hook : public QObject_hook {
Q_OBJECT
public:
QInputMethod_hook(QObject *handle) : QObject_hook(handle) {
actionRectangleChanged_event.func = NULL;
animatingChanged_event.func = NULL;
cursorRectangleChanged_event.func = NULL;
inputDirectionChanged_event.func = NULL;
inputItemClipRectangleChanged_event.func = NULL;
keyboardRectangleChanged_event.func = NULL;
localeChanged_event.func = NULL;
visibleChanged_event.func = NULL;
}
void hook_actionRectangleChanged(QHook &hook) {
if ( !actionRectangleChanged_event.func )
connect(handle, SIGNAL(actionRectangleChanged()), this, SLOT(actionRectangleChanged_hook()));
actionRectangleChanged_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(actionRectangleChanged()), this, SLOT(actionRectangleChanged_hook()));
}
void hook_animatingChanged(QHook &hook) {
if ( !animatingChanged_event.func )
connect(handle, SIGNAL(animatingChanged()), this, SLOT(animatingChanged_hook()));
animatingChanged_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(animatingChanged()), this, SLOT(animatingChanged_hook()));
}
void hook_cursorRectangleChanged(QHook &hook) {
if ( !cursorRectangleChanged_event.func )
connect(handle, SIGNAL(cursorRectangleChanged()), this, SLOT(cursorRectangleChanged_hook()));
cursorRectangleChanged_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(cursorRectangleChanged()), this, SLOT(cursorRectangleChanged_hook()));
}
void hook_inputDirectionChanged(QHook &hook) {
if ( !inputDirectionChanged_event.func )
connect(handle, SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), this, SLOT(inputDirectionChanged_hook(Qt::LayoutDirection)));
inputDirectionChanged_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), this, SLOT(inputDirectionChanged_hook(Qt::LayoutDirection)));
}
void hook_inputItemClipRectangleChanged(QHook &hook) {
if ( !inputItemClipRectangleChanged_event.func )
connect(handle, SIGNAL(inputItemClipRectangleChanged()), this, SLOT(inputItemClipRectangleChanged_hook()));
inputItemClipRectangleChanged_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(inputItemClipRectangleChanged()), this, SLOT(inputItemClipRectangleChanged_hook()));
}
void hook_keyboardRectangleChanged(QHook &hook) {
if ( !keyboardRectangleChanged_event.func )
connect(handle, SIGNAL(keyboardRectangleChanged()), this, SLOT(keyboardRectangleChanged_hook()));
keyboardRectangleChanged_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(keyboardRectangleChanged()), this, SLOT(keyboardRectangleChanged_hook()));
}
void hook_localeChanged(QHook &hook) {
if ( !localeChanged_event.func )
connect(handle, SIGNAL(localeChanged()), this, SLOT(localeChanged_hook()));
localeChanged_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(localeChanged()), this, SLOT(localeChanged_hook()));
}
void hook_visibleChanged(QHook &hook) {
if ( !visibleChanged_event.func )
connect(handle, SIGNAL(visibleChanged()), this, SLOT(visibleChanged_hook()));
visibleChanged_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(visibleChanged()), this, SLOT(visibleChanged_hook()));
}
private slots:
void actionRectangleChanged_hook() {
if ( actionRectangleChanged_event.func ) {
typedef void (*func_type)(void *data);
(*(func_type)actionRectangleChanged_event.func)(actionRectangleChanged_event.data);
}
}
void animatingChanged_hook() {
if ( animatingChanged_event.func ) {
typedef void (*func_type)(void *data);
(*(func_type)animatingChanged_event.func)(animatingChanged_event.data);
}
}
void cursorRectangleChanged_hook() {
if ( cursorRectangleChanged_event.func ) {
typedef void (*func_type)(void *data);
(*(func_type)cursorRectangleChanged_event.func)(cursorRectangleChanged_event.data);
}
}
void inputDirectionChanged_hook(Qt::LayoutDirection direction) {
if ( inputDirectionChanged_event.func ) {
typedef void (*func_type)(void *data, Qt::LayoutDirection direction);
(*(func_type)inputDirectionChanged_event.func)(inputDirectionChanged_event.data, direction);
}
}
void inputItemClipRectangleChanged_hook() {
if ( inputItemClipRectangleChanged_event.func ) {
typedef void (*func_type)(void *data);
(*(func_type)inputItemClipRectangleChanged_event.func)(inputItemClipRectangleChanged_event.data);
}
}
void keyboardRectangleChanged_hook() {
if ( keyboardRectangleChanged_event.func ) {
typedef void (*func_type)(void *data);
(*(func_type)keyboardRectangleChanged_event.func)(keyboardRectangleChanged_event.data);
}
}
void localeChanged_hook() {
if ( localeChanged_event.func ) {
typedef void (*func_type)(void *data);
(*(func_type)localeChanged_event.func)(localeChanged_event.data);
}
}
void visibleChanged_hook() {
if ( visibleChanged_event.func ) {
typedef void (*func_type)(void *data);
(*(func_type)visibleChanged_event.func)(visibleChanged_event.data);
}
}
private:
QHook actionRectangleChanged_event;
QHook animatingChanged_event;
QHook cursorRectangleChanged_event;
QHook inputDirectionChanged_event;
QHook inputItemClipRectangleChanged_event;
QHook keyboardRectangleChanged_event;
QHook localeChanged_event;
QHook visibleChanged_event;
};
#endif

View File

@ -0,0 +1,64 @@
//******************************************************************************
// Copyright (c) 2024 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#include "qinputmethod_hook_c.h"
QInputMethod_hookH QInputMethod_hook_Create(QObjectH handle)
{
return (QInputMethod_hookH) new QInputMethod_hook((QObject*)handle);
}
void QInputMethod_hook_Destroy(QInputMethod_hookH handle)
{
delete (QInputMethod_hook *)handle;
}
void QInputMethod_hook_hook_actionRectangleChanged(QInputMethod_hookH handle, QHookH hook)
{
((QInputMethod_hook *)handle)->hook_actionRectangleChanged(hook);
}
void QInputMethod_hook_hook_animatingChanged(QInputMethod_hookH handle, QHookH hook)
{
((QInputMethod_hook *)handle)->hook_animatingChanged(hook);
}
void QInputMethod_hook_hook_cursorRectangleChanged(QInputMethod_hookH handle, QHookH hook)
{
((QInputMethod_hook *)handle)->hook_cursorRectangleChanged(hook);
}
void QInputMethod_hook_hook_inputDirectionChanged(QInputMethod_hookH handle, QHookH hook)
{
((QInputMethod_hook *)handle)->hook_inputDirectionChanged(hook);
}
void QInputMethod_hook_hook_inputItemClipRectangleChanged(QInputMethod_hookH handle, QHookH hook)
{
((QInputMethod_hook *)handle)->hook_inputItemClipRectangleChanged(hook);
}
void QInputMethod_hook_hook_keyboardRectangleChanged(QInputMethod_hookH handle, QHookH hook)
{
((QInputMethod_hook *)handle)->hook_keyboardRectangleChanged(hook);
}
void QInputMethod_hook_hook_localeChanged(QInputMethod_hookH handle, QHookH hook)
{
((QInputMethod_hook *)handle)->hook_localeChanged(hook);
}
void QInputMethod_hook_hook_visibleChanged(QInputMethod_hookH handle, QHookH hook)
{
((QInputMethod_hook *)handle)->hook_visibleChanged(hook);
}

View File

@ -0,0 +1,29 @@
//******************************************************************************
// Copyright (c) 2024 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#ifndef QINPUTMETHOD_HOOK_C_H
#define QINPUTMETHOD_HOOK_C_H
#include "qinputmethod_hook.h"
C_EXPORT QInputMethod_hookH QInputMethod_hook_Create(QObjectH handle);
C_EXPORT void QInputMethod_hook_Destroy(QInputMethod_hookH handle);
C_EXPORT void QInputMethod_hook_hook_actionRectangleChanged(QInputMethod_hookH handle, QHookH hook);
C_EXPORT void QInputMethod_hook_hook_animatingChanged(QInputMethod_hookH handle, QHookH hook);
C_EXPORT void QInputMethod_hook_hook_cursorRectangleChanged(QInputMethod_hookH handle, QHookH hook);
C_EXPORT void QInputMethod_hook_hook_inputDirectionChanged(QInputMethod_hookH handle, QHookH hook);
C_EXPORT void QInputMethod_hook_hook_inputItemClipRectangleChanged(QInputMethod_hookH handle, QHookH hook);
C_EXPORT void QInputMethod_hook_hook_keyboardRectangleChanged(QInputMethod_hookH handle, QHookH hook);
C_EXPORT void QInputMethod_hook_hook_localeChanged(QInputMethod_hookH handle, QHookH hook);
C_EXPORT void QInputMethod_hook_hook_visibleChanged(QInputMethod_hookH handle, QHookH hook);
#endif

View File

@ -0,0 +1,57 @@
//******************************************************************************
// Copyright (c) 2024 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#include "qkeycombination_c.h"
QKeyCombinationH QKeyCombination_Create(Qt::Key key)
{
return (QKeyCombinationH) new QKeyCombination(key);
}
QKeyCombinationH QKeyCombination_Create(Qt::Modifiers modifiers, Qt::Key key)
{
return (QKeyCombinationH) new QKeyCombination(modifiers, key);
}
QKeyCombinationH QKeyCombination_Create(Qt::KeyboardModifiers modifiers, Qt::Key key)
{
return (QKeyCombinationH) new QKeyCombination(modifiers, key);
}
void QKeyCombination_Destroy(QKeyCombinationH handle)
{
delete (QKeyCombination *)handle;
}
Qt::Key QKeyCombination_key(QKeyCombinationH handle)
{
return (Qt::Key) ((QKeyCombination *)handle)->key();
}
Qt::KeyboardModifiers QKeyCombination_keyboardModifiers(QKeyCombinationH handle)
{
return (Qt::KeyboardModifiers) ((QKeyCombination *)handle)->keyboardModifiers();
}
int QKeyCombination_toCombined(QKeyCombinationH handle)
{
return (int) ((QKeyCombination *)handle)->toCombined();
}
void QKeyCombination_fromCombined(int combined, QKeyCombinationH retval)
{
*(QKeyCombination *) retval = QKeyCombination::fromCombined(combined);
}

View File

@ -0,0 +1,27 @@
//******************************************************************************
// Copyright (c) 2024 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#ifndef QKEYCOMBINATION_C_H
#define QKEYCOMBINATION_C_H
#include <QtGui>
#include "pascalbind.h"
C_EXPORT QKeyCombinationH QKeyCombination_Create(Qt::Key key = Qt::Key_unknown);
C_EXPORT QKeyCombinationH QKeyCombination_Create2(Qt::Modifiers modifiers, Qt::Key key = Qt::Key_unknown);
C_EXPORT QKeyCombinationH QKeyCombination_Create3(Qt::KeyboardModifiers modifiers, Qt::Key key = Qt::Key_unknown);
C_EXPORT void QKeyCombination_Destroy(QKeyCombinationH handle);
C_EXPORT Qt::Key QKeyCombination_key(QKeyCombinationH handle);
C_EXPORT Qt::KeyboardModifiers QKeyCombination_keyboardModifiers(QKeyCombinationH handle);
C_EXPORT int QKeyCombination_toCombined(QKeyCombinationH handle);
C_EXPORT void QKeyCombination_fromCombined(int combined, QKeyCombinationH retval);
#endif