### ----------------------------------------------------
### -- Qt::QtWidgets
### -- Licenses: GPL-3.0-or-later
### -- Authors: Yves Guillemot <yc.guillemot@wanadoo.fr>
### -- File: lib/Qt/QtWidgets/Callbacks.rakumod
### ----------------------------------------------------

# 
# This file has been automatically generated by RaQt_maker V0.0.7.
# To modify and regenerate it, see the source code available here: 
#         https://github.com/yguillemot/RaQt_maker
# 



use NativeCall;
use Qt::QtWidgets::QtHelpers:ver<0.0.7>:auth<zef:yguillemot>:api<2>;
use Qt::QtWidgets::QtWrappers:ver<0.0.7>:auth<zef:yguillemot>:api<2>;
use Qt::QtWidgets::ConnectionManager:ver<0.0.7>:auth<zef:yguillemot>:api<2>;

use Qt::QtWidgets::QSize:ver<0.0.7>:auth<zef:yguillemot>:api<2>;

use Qt::QtWidgets::QPaintEvent;
use Qt::QtWidgets::QTimerEvent;
use Qt::QtWidgets::QEvent;
use Qt::QtWidgets::QGraphicsSceneMouseEvent;
use Qt::QtWidgets::QEvent;
use Qt::QtWidgets::QCloseEvent;
use Qt::QtWidgets::QObject;
 use Qt::QtWidgets::QEvent;
use Qt::QtWidgets::QMouseEvent;
use Qt::QtWidgets::QPainter;
 use Qt::QtWidgets::QRectF;
use Qt::QtWidgets::QPointF;
use Qt::QtWidgets::QResizeEvent;
use Qt::QtWidgets::QKeyEvent;



sub slotCallback(int32 $objectId, Str $slotName)
{
    $CM.objs{$objectId}."$slotName"();
}

sub slotCallbackInt(int32 $objectId, Str $slotName, int64 $i)
{
    $CM.objs{$objectId}."$slotName"($i);
}

sub slotCallbackInt2(int32 $objectId, Str $slotName, int64 $i1, int64 $i2)
{
    $CM.objs{$objectId}."$slotName"($i1, $i2);
}

sub slotCallbackStr(int32 $objectId, Str $slotName, Str $s)
{
# say "   *** slotCallbackStr slotName=$slotName s=$s";
    $CM.objs{$objectId}."$slotName"($s);
}

sub slotCallbackIntStr(int32 $objectId, Str $slotName, int64 $i, Str $s)
{
    $CM.objs{$objectId}."$slotName"($i, $s);
}

sub slotCallbackBool(int32 $objectId, Str $slotName, int8 $b)
{
    $CM.objs{$objectId}."$slotName"(?$b);
}

sub slotCallbackQSize(int32 $objectId, Str $slotName, Pointer $size)
{
    my QSize $a1 = QSize.new($size);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub slotCallbackPointer(int32 $objectId, Str $slotName, Pointer $p)
{
    # say "   *** slotCallbackPointer objid=$objectId slotName=$slotName ", $p;

    $CM.objs{$objectId}."$slotName"($p);
}

sub callback(int32 $objectId, Str $slotName)
{
    $CM.objs{$objectId}."$slotName"()
}

sub callbackIntReturnsInt(int32 $objectId, Str $slotName, int32 $a1)
{
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQCloseEvent(int32 $objectId, Str $slotName, Pointer $event)
{
    my QCloseEvent $a1 = QCloseEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQEvent(int32 $objectId, Str $slotName, Pointer $event)
{
    my QEvent $a1 = QEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQEventReturnsBool(int32 $objectId, Str $slotName, Pointer $event)
{
    my QEvent $a1 = QEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQGraphicsSceneMouseEvent(int32 $objectId, Str $slotName, Pointer $event)
{
    my QGraphicsSceneMouseEvent $a1 = QGraphicsSceneMouseEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQKeyEvent(int32 $objectId, Str $slotName, Pointer $event)
{
    my QKeyEvent $a1 = QKeyEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQMouseEvent(int32 $objectId, Str $slotName, Pointer $event)
{
    my QMouseEvent $a1 = QMouseEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQObjectQEventReturnsBool(int32 $objectId, Str $slotName, Pointer $watched, Pointer $event)
{
    my QObject $a1 = QObject.new($watched);
    my QEvent $a2 = QEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1, $a2)
}

sub callbackQPaintEvent(int32 $objectId, Str $slotName, Pointer $event)
{
    my QPaintEvent $a1 = QPaintEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQPainterQRectF(int32 $objectId, Str $slotName, Pointer $painter, Pointer $rect)
{
    my QPainter $a1 = QPainter.new($painter);
    my QRectF $a2 = QRectF.new($rect);
    $CM.objs{$objectId}."$slotName"($a1, $a2)
}

sub callbackQPointFReturnsBool(int32 $objectId, Str $slotName, Pointer $point)
{
    my QPointF $a1 = QPointF.new($point);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQResizeEvent(int32 $objectId, Str $slotName, Pointer $event)
{
    my QResizeEvent $a1 = QResizeEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackQTimerEvent(int32 $objectId, Str $slotName, Pointer $event)
{
    my QTimerEvent $a1 = QTimerEvent.new($event);
    $CM.objs{$objectId}."$slotName"($a1)
}

sub callbackReturnsBool(int32 $objectId, Str $slotName)
{
    $CM.objs{$objectId}."$slotName"()
}

sub callbackReturnsQRectF(int32 $objectId, Str $slotName)
{
    $CM.objs{$objectId}."$slotName"()
}



sub slotCallbackComplexSig(int32 $objectId, Str $slotName, int32 $dataId)
{
    my ($capt, $ok) = $CM.getData($dataId);

    # say "Stack: " ~ Backtrace.new;
    # say "just before calling the slot ", $slotName;
    # say "ok = ", $ok;
    # say $capt.gist;
    # say "objectId : ", $objectId;
    # say $CM.objs{$objectId}.gist;

    if (!$ok) {
        note "INTERNAL ERROR: Data(Id=$dataId) not found in capture cache";
        # Should we die ???
        return;
    }
    $CM.objs{$objectId}."$slotName"(|$capt);
}


##############################################################################

# Called from QApplication.new
sub QtSetupEverything is export     # TODO : Should not be exported from here
{
    # Start the connections manager if needed
    $CM = ConnectionsManager.new if !$CM;

    # Register the addresses of the callbacks
    QWSetupSlotCallback(&slotCallback);
    QWSetupSlotCallbackInt(&slotCallbackInt);
    QWSetupSlotCallbackInt2(&slotCallbackInt2);
    QWSetupSlotCallbackStr(&slotCallbackStr);
    QWSetupSlotCallbackIntStr(&slotCallbackIntStr);
    QWSetupSlotCallbackBool(&slotCallbackBool);
    QWSetupSlotCallbackQSize(&slotCallbackQSize);
    QWSetupSlotCallbackPointer(&slotCallbackPointer);
    QWSetupSlotCallbackComplexSig(&slotCallbackComplexSig);

    QWSetupcallback(&callback);
    QWSetupcallbackIntReturnsInt(&callbackIntReturnsInt);
    QWSetupcallbackQCloseEvent(&callbackQCloseEvent);
    QWSetupcallbackQEvent(&callbackQEvent);
    QWSetupcallbackQEventReturnsBool(&callbackQEventReturnsBool);
    QWSetupcallbackQGraphicsSceneMouseEvent(&callbackQGraphicsSceneMouseEvent);
    QWSetupcallbackQKeyEvent(&callbackQKeyEvent);
    QWSetupcallbackQMouseEvent(&callbackQMouseEvent);
    QWSetupcallbackQObjectQEventReturnsBool(&callbackQObjectQEventReturnsBool);
    QWSetupcallbackQPaintEvent(&callbackQPaintEvent);
    QWSetupcallbackQPainterQRectF(&callbackQPainterQRectF);
    QWSetupcallbackQPointFReturnsBool(&callbackQPointFReturnsBool);
    QWSetupcallbackQResizeEvent(&callbackQResizeEvent);
    QWSetupcallbackQTimerEvent(&callbackQTimerEvent);
    QWSetupcallbackReturnsBool(&callbackReturnsBool);
    QWSetupcallbackReturnsQRectF(&callbackReturnsQRectF);

}

 


