QtTest: module updated to use the file qt4xhb_common.h

/*

  Qt4xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 4

  Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br>

*/

#include "hbclass.ch"
#include "qt4xhb_clsid.ch"

CLASS QTestEventList

   DATA pointer
   DATA class_id INIT Class_Id_QTestEventList
   DATA self_destruction INIT .f.

   METHOD new1
   METHOD new2
   METHOD new
   METHOD delete
   METHOD addDelay
   METHOD addKeyClick1
   METHOD addKeyClick2
   METHOD addKeyClick
   METHOD addKeyClicks
   METHOD addKeyPress1
   METHOD addKeyPress2
   METHOD addKeyPress
   METHOD addKeyRelease1
   METHOD addKeyRelease2
   METHOD addKeyRelease
   METHOD addMouseClick
   METHOD addMouseDClick
   METHOD addMouseMove
   METHOD addMousePress
   METHOD addMouseRelease
   METHOD clear
   METHOD simulate
   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction
   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QTestEventList
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <QTestEventList>

#include "qt4xhb_common.h"
#include "qt4xhb_clsid.h"
#include "qt4xhb_utils.h"

/*
QTestEventList ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_NEW1 )
{
  QTestEventList * o = NULL;
  o = new QTestEventList (  );
  PHB_ITEM self = hb_stackSelfItem();
  PHB_ITEM ptr = hb_itemPutPtr( NULL,(QTestEventList *) o );
  hb_objSendMsg( self, "_pointer", 1, ptr );
  hb_itemRelease( ptr );
  hb_itemReturn( self );
}

/*
QTestEventList ( const QTestEventList & other )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_NEW2 )
{
  QTestEventList * o = NULL;
  QTestEventList * par1 = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
  o = new QTestEventList ( *par1 );
  PHB_ITEM self = hb_stackSelfItem();
  PHB_ITEM ptr = hb_itemPutPtr( NULL,(QTestEventList *) o );
  hb_objSendMsg( self, "_pointer", 1, ptr );
  hb_itemRelease( ptr );
  hb_itemReturn( self );
}

//[1]QTestEventList ()
//[2]QTestEventList ( const QTestEventList & other )

HB_FUNC_STATIC( QTESTEVENTLIST_NEW )
{
  if( ISNUMPAR(0) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_NEW1 );
  }
  else if( ISNUMPAR(1) && ISQTESTEVENTLIST(1) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_NEW2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QTESTEVENTLIST_DELETE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addDelay ( int msecs )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDDELAY )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addDelay ( hb_parni(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyClick (  (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyClick ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK2 );
  }
}

/*
void addKeyClicks ( const QString & keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICKS )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QString par1 = hb_parc(1);
    obj->addKeyClicks ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyPress (  (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyPress ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS2 );
  }
}

/*
void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyRelease (  (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyRelease ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE2 );
  }
}

/*
void addMouseClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSECLICK )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseClick (  (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, ISNIL(4)? -1 : hb_parni(4) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseDClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEDCLICK )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseDClick (  (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, ISNIL(4)? -1 : hb_parni(4) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseMove ( QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEMOVE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QPoint par1 = ISNIL(1)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseMove ( par1, ISNIL(2)? -1 : hb_parni(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMousePress ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEPRESS )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMousePress (  (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, ISNIL(4)? -1 : hb_parni(4) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseRelease ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSERELEASE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseRelease (  (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, ISNIL(4)? -1 : hb_parni(4) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void clear ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_CLEAR )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->clear (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void simulate ( QWidget * w )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_SIMULATE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QWidget * par1 = (QWidget *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->simulate ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP

/*

  Qt4xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 4

  Copyright (C) 2012-2017 Marcos Antonio Gambeta <marcosgambeta@uol.com.br>

*/

#include "hbclass.ch"
#include "qt4xhb_clsid.ch"

CLASS QTestEventList

   DATA pointer
   DATA class_id INIT Class_Id_QTestEventList
   DATA self_destruction INIT .f.

   METHOD new1
   METHOD new2
   METHOD new
   METHOD delete
   METHOD addDelay
   METHOD addKeyClick1
   METHOD addKeyClick2
   METHOD addKeyClick
   METHOD addKeyClicks
   METHOD addKeyPress1
   METHOD addKeyPress2
   METHOD addKeyPress
   METHOD addKeyRelease1
   METHOD addKeyRelease2
   METHOD addKeyRelease
   METHOD addMouseClick
   METHOD addMouseDClick
   METHOD addMouseMove
   METHOD addMousePress
   METHOD addMouseRelease
   METHOD clear
   METHOD simulate
   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction
   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject () CLASS QTestEventList
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <QTestEventList>

#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbvm.h"
#include "hbstack.h"
#ifndef __XHARBOUR__
#include "hbapicls.h"
#define ISNIL HB_ISNIL
#define ISLOG HB_ISLOG
#define ISNUM HB_ISNUM
#define ISCHAR HB_ISCHAR
#define ISPOINTER HB_ISPOINTER
#define ISOBJECT HB_ISOBJECT
#define ISARRAY HB_ISARRAY
#endif
#include "qt4xhb_clsid.h"
#include "qt4xhb_utils.h"

/*
QTestEventList ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_NEW1 )
{
  QTestEventList * o = NULL;
  o = new QTestEventList (  );
  PHB_ITEM self = hb_stackSelfItem();
  PHB_ITEM ptr = hb_itemPutPtr( NULL,(QTestEventList *) o );
  hb_objSendMsg( self, "_pointer", 1, ptr );
  hb_itemRelease( ptr );
  hb_itemReturn( self );
}

/*
QTestEventList ( const QTestEventList & other )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_NEW2 )
{
  QTestEventList * o = NULL;
  QTestEventList * par1 = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
  o = new QTestEventList ( *par1 );
  PHB_ITEM self = hb_stackSelfItem();
  PHB_ITEM ptr = hb_itemPutPtr( NULL,(QTestEventList *) o );
  hb_objSendMsg( self, "_pointer", 1, ptr );
  hb_itemRelease( ptr );
  hb_itemReturn( self );
}

//[1]QTestEventList ()
//[2]QTestEventList ( const QTestEventList & other )

HB_FUNC_STATIC( QTESTEVENTLIST_NEW )
{
  if( ISNUMPAR(0) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_NEW1 );
  }
  else if( ISNUMPAR(1) && ISQTESTEVENTLIST(1) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_NEW2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QTESTEVENTLIST_DELETE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addDelay ( int msecs )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDDELAY )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addDelay ( hb_parni(1) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyClick (  (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyClick ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK2 );
  }
}

/*
void addKeyClicks ( const QString & keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICKS )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QString par1 = hb_parc(1);
    obj->addKeyClicks ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyPress (  (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyPress ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS2 );
  }
}

/*
void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE1 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->addKeyRelease (  (Qt::Key) hb_parni(1), ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE2 )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    char par1 = ISCHAR(1)? (char) hb_parc(1)[0] : (ISNUM(1)? hb_parni(1) : 0);
    obj->addKeyRelease ( par1, ISNIL(2)? Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? -1 : hb_parni(3) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE2 );
  }
}

/*
void addMouseClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSECLICK )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseClick (  (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, ISNIL(4)? -1 : hb_parni(4) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseDClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEDCLICK )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseDClick (  (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, ISNIL(4)? -1 : hb_parni(4) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseMove ( QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEMOVE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QPoint par1 = ISNIL(1)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseMove ( par1, ISNIL(2)? -1 : hb_parni(2) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMousePress ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEPRESS )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMousePress (  (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, ISNIL(4)? -1 : hb_parni(4) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseRelease ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSERELEASE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  int par2 = ISNIL(2)? 0 :  hb_parni(2);
  if( obj )
  {
    QPoint par3 = ISNIL(3)? QPoint() : *(QPoint *) hb_itemGetPtr( hb_objSendMsg( hb_param(3, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->addMouseRelease (  (Qt::MouseButton) hb_parni(1), (Qt::KeyboardModifiers) par2, par3, ISNIL(4)? -1 : hb_parni(4) );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void clear ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_CLEAR )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    obj->clear (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void simulate ( QWidget * w )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_SIMULATE )
{
  QTestEventList * obj = (QTestEventList *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QWidget * par1 = (QWidget *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
    obj->simulate ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP


codegen/QtGui/QGestureRecognizer.prg: updated

Modified:
codegen/QtGui/QGestureRecognizer.prg

%%
%% Qt4xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 4
%%
%% Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$header

#include "hbclass.ch"

#ifndef QT4XHB_NO_REQUESTS
REQUEST QGESTURE
#endif

$beginClass

   METHOD delete
   METHOD create
   METHOD recognize
   METHOD reset
   METHOD registerRecognizer
   METHOD unregisterRecognizer

$endClass

$destructor

#pragma BEGINDUMP

$includes

#include <QGesture>

$deleteMethod

$prototype=virtual QGesture * create ( QObject * target )
$virtualMethod=|QGesture *|create|QObject *

$prototype=virtual Result recognize ( QGesture * gesture, QObject * watched, QEvent * event ) = 0
$virtualMethod=|QGestureRecognizer::Result|recognize|QGesture *,QObject *,QEvent *

$prototype=virtual void reset ( QGesture * gesture )
$virtualMethod=|void|reset|QGesture *

$prototype=static Qt::GestureType registerRecognizer ( QGestureRecognizer * recognizer )
$staticMethod=|Qt::GestureType|registerRecognizer|QGestureRecognizer *

$prototype=static void unregisterRecognizer ( Qt::GestureType type )
$staticMethod=|void|unregisterRecognizer|Qt::GestureType

$extraMethods

#pragma ENDDUMP

%%
%% Qt4xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 4
%%
%% Copyright (C) 2018 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>
%%

$header

#include "hbclass.ch"

#ifndef QT4XHB_NO_REQUESTS
REQUEST QGESTURE
#endif

$beginClass

   METHOD delete
   METHOD create
   METHOD recognize
   METHOD reset
   METHOD registerRecognizer
   METHOD unregisterRecognizer

$endClass

$destructor

#pragma BEGINDUMP

$includes

#include <QGesture>

$deleteMethod

$prototype=virtual QGesture * create ( QObject * target )
$virtualMethod=|QGesture *|create|QObject *

$prototype=virtual Result recognize ( QGesture * gesture, QObject * watched, QEvent * event ) = 0
HB_FUNC_STATIC( QGESTURERECOGNIZER_RECOGNIZE )
{
  QGestureRecognizer * obj = (QGestureRecognizer *) hb_itemGetPtr( hb_objSendMsg( hb_stackSelfItem(), "POINTER", 0 ) );
  if( obj )
  {
    QGesture * par1 = (QGesture *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) );
    hb_retni( (int) obj->recognize ( par1, PQOBJECT(2), PQEVENT(3) ) );
  }
}

$prototype=virtual void reset ( QGesture * gesture )
$virtualMethod=|void|reset|QGesture *

$prototype=static Qt::GestureType registerRecognizer ( QGestureRecognizer * recognizer )
$staticMethod=|Qt::GestureType|registerRecognizer|QGestureRecognizer *

$prototype=static void unregisterRecognizer ( Qt::GestureType type )
$staticMethod=|void|unregisterRecognizer|Qt::GestureType

$extraMethods

#pragma ENDDUMP


simplify data constructor Mehr to not accumulate redundant label

import "LangPrelude.prg"

data Free :: Tag ~> Row Tag * ~> * where
  Klar :: Label t -> Free t {}r
  Mehr :: DiffLabel t t' -> Free t r -> Free t {t'=a;r}r
-- deriving Record(f)

notMentionedIn :: Label a -> Record sh -> Maybe (Free a sh)
notMentionedIn l {} = Just $ Klar l
notMentionedIn l {m=v; r} = do
                            diff <- case sameLabel l m of
                                    R x -> Just x
      	      	      	      	    _ -> Nothing
                            r' <- notMentionedIn l r
                            return $ Mehr diff r'
                       where monad maybeM

Just test1 = `a `notMentionedIn` {`g=7, `h='a'}
Nothing = `a `notMentionedIn` {`g=7, `a='a'}
Nothing = `a `notMentionedIn` {`a=7, `b='b'}

import "LangPrelude.prg"

data Free :: Tag ~> Row Tag * ~> * where
  Klar :: Label t -> Free t {}r
  Mehr :: Label t -> DiffLabel t t' -> Free t r -> Free t {t'=a;r}r
-- deriving Record(f)

notMentionedIn :: Label a -> Record sh -> Maybe (Free a sh)
notMentionedIn l {} = Just $ Klar l
notMentionedIn l {m=v; r} = do
                            diff <- case sameLabel l m of
                                    R x -> Just x
      	      	      	      	    _ -> Nothing
                            r' <- notMentionedIn l r
                            return $ Mehr l diff r'
                       where monad maybeM

Just test1 = `a `notMentionedIn` {`g=7, `h='a'}
Nothing = `a `notMentionedIn` {`g=7, `a='a'}
Nothing = `a `notMentionedIn` {`a=7, `b='b'}


[DBFNTX] Failed to open NTX files when no extension was passed

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

USING System
USING System.Collections.Generic
USING System.Text
USING XSharp.RDD.Support

BEGIN NAMESPACE XSharp.RDD.NTX

    INTERNAL SEALED CLASS NtxOrderList
        PRIVATE _focusNtx AS LONG
        PRIVATE _Orders AS List<NtxOrder>
        PRIVATE _oRdd AS DBFNTX
        PRIVATE _currentOrder AS NtxOrder
        INTERNAL PROPERTY Count AS LONG GET _Orders:Count
        INTERNAL PROPERTY Focus AS LONG GET _focusNtx
        INTERNAL PROPERTY CurrentOrder AS NtxOrder GET _currentOrder SET _currentOrder := value
        INTERNAL PROPERTY SELF[index AS LONG ] AS NtxOrder
                GET
                    IF ((index >= 0) .AND. (index < _Orders:Count))
                        RETURN _Orders[index]
                    ENDIF
                    RETURN NULL

                END GET
            END PROPERTY

            INTERNAL CONSTRUCTOR(area AS DBFNTX )
                SELF:_focusNtx := 0
                SELF:_Orders := List<NtxOrder>{}
                SELF:_oRdd := area
                SELF:_currentOrder := NULL

            INTERNAL METHOD Add(oi AS DbOrderInfo , filePath AS STRING ) AS LOGIC
                LOCAL isOk AS LOGIC
                LOCAL ntxIndex := NULL AS NtxOrder
                //
                isOk := FALSE
                VAR cExt := System.IO.Path.GetExtension(filePath)
                IF String.IsNullOrEmpty(cExt)
                    filePath := System.IO.Path.ChangeExtension(filePath, NtxOrder.NTX_EXTENSION)
                ENDIF
                 IF File(filePath)
                    filePath := FPathName()
                    TRY

                        IF SELF:_Orders:Count >= 16
                            SELF:_oRdd:_dbfError(Subcodes.ERDD_NTXLIMIT, Gencode.EG_LIMIT,  filePath)
                            isOk := FALSE
                        ELSE

                            ntxIndex := NtxOrder{SELF:_oRdd, filePath}
                            SELF:_Orders:Add(ntxIndex)
                            isOk := ntxIndex:Open(oi)
                            IF isOk
                                SELF:_focusNtx := SELF:_Orders:Count
                                SELF:_currentOrder := ntxIndex
                                oi:BagName := ntxIndex:FileName
                            ELSE
                                SELF:_Orders:Remove(ntxIndex)
                            ENDIF
                        ENDIF

                    CATCH e AS Exception
                        XSharp.RuntimeState.LastRddError := e
                        isOk := FALSE
                        IF ntxIndex != NULL .AND. SELF:_Orders:Contains(ntxIndex)
                            SELF:_Orders:Remove(ntxIndex)
                        ENDIF
                    END TRY
                    IF !isOk
                        SELF:_focusNtx := 0
                        SELF:_currentOrder := NULL
                    ENDIF
                ENDIF
                RETURN isOk

            INTERNAL METHOD Create(dboci AS DbOrderCreateInfo ) AS LOGIC
                LOCAL ntxIndex AS NtxOrder
                LOCAL isOk AS LOGIC
                //
                TRY
                    ntxIndex := NtxOrder{SELF:_oRdd}
                    isOk := ntxIndex:Create(dboci)
                    IF (!isOk)
                        RETURN isOk
                    ENDIF
                    SELF:_Orders:Add(ntxIndex)
                    SELF:_focusNtx := SELF:_Orders:Count
                    SELF:_currentOrder := ntxIndex
                    ntxIndex:GoTop()
                    RETURN isOk

                CATCH e AS Exception
                    System.Diagnostics.Debug.WriteLine(e:Message)
                    RETURN FALSE
                END TRY

            INTERNAL METHOD Delete( orderInfo AS DbOrderInfo) AS LOGIC
                LOCAL ntxIndex AS NtxOrder
                LOCAL found AS LOGIC
                LOCAL pos AS INT
                //
                IF (SELF:_Orders:Count == 0)
                    RETURN TRUE
                ENDIF
                //
                IF ( orderInfo:AllTags )
                    RETURN SELF:CloseAll()
                ENDIF
                //
                found := FALSE
                pos := SELF:_Orders:Count
                WHILE pos > 0
                    ntxIndex := SELF:_Orders[pos - 1]
                    IF ( ntxIndex:OrderName == orderInfo:BagName )
                        ntxIndex:Flush()
                        ntxIndex:Close()
                        //
                        SELF:_Orders:RemoveAt(pos - 1)
                        found := TRUE
                        EXIT
                    ENDIF
                ENDDO
                IF ( found )
                    IF ( SELF:_Orders:Count > 0 ) .AND. ( ( pos >= SELF:_focusNtx ) .AND. (pos < SELF:_Orders:Count ) )
                        SELF:_focusNtx :=- 1
                        SELF:_currentOrder := SELF:_Orders[pos - 1]
                    ELSE
                        SELF:_focusNtx := 0
                        SELF:_currentOrder := NULL
                    ENDIF
                ENDIF
                RETURN TRUE

            INTERNAL METHOD CloseAll() AS LOGIC
                LOCAL ntxIndex AS NtxOrder
                //
                IF (SELF:_Orders:Count == 0)
                    RETURN TRUE
                ENDIF
                //
                WHILE SELF:_Orders:Count > 0
                    ntxIndex := SELF:_Orders[SELF:_Orders:Count - 1]
                    ntxIndex:Flush()
                    ntxIndex:Close()
                    //
                    SELF:_Orders:RemoveAt(SELF:_Orders:Count - 1)
                ENDDO
                SELF:_focusNtx := 0
                SELF:_currentOrder := NULL
                RETURN TRUE

            INTERNAL METHOD SetFocus(oi AS DbOrderInfo ) AS LOGIC
                LOCAL currentOrder AS NtxOrder
                LOCAL isOk AS LOGIC
                //
                currentOrder := SELF:_currentOrder
                IF (currentOrder != NULL)
                    oi:BagName := currentOrder:FileName
                ELSE
                    oi:BagName := NULL
                ENDIF
                SELF:_focusNtx := 0
                SELF:_currentOrder := NULL
                SELF:_focusNtx := SELF:FindOrder(oi)
                isOk := FALSE
                IF (SELF:_focusNtx >= 0)
                    isOk := SELF:_oRdd:GoCold()
                    IF currentOrder != NULL_OBJECT
                        currentOrder:SetOffLine()
                    ENDIF
                    IF (isOk)
                        IF SELF:_focusNtx == 0
                            _currentOrder := NULL
                        ELSE
                            SELF:_currentOrder := SELF:_Orders[SELF:_focusNtx - 1]
                            SELF:_currentOrder:SetOffLine()
                        ENDIF
                    ENDIF
                ELSE
                    isOk := FALSE
                    SELF:_oRdd:_dbfError(Subcodes.ERDD_INVALID_ORDER, Gencode.EG_NOORDER,  NULL)
                ENDIF
                RETURN isOk

          METHOD OrderPos(oToFind AS NtxOrder) AS LONG
                LOCAL nPos := 0 AS LONG
                IF oToFind != NULL
                    FOREACH oOrder AS NtxOrder IN _Orders
                        ++nPos
                        IF oToFind == oOrder
                            RETURN nPos
                        ENDIF
                    NEXT
                ENDIF
                RETURN 0
            INTERNAL METHOD Rebuild() AS LOGIC
                LOCAL ordCondInfo AS DbOrderCondInfo
                LOCAL isOk AS LOGIC
                //
                ordCondInfo := SELF:_oRdd:_OrderCondInfo
                isOk := SELF:GoCold()
                IF (!isOk)
                    RETURN FALSE
                ENDIF
                //
                FOREACH order AS NtxOrder IN SELF:_Orders
                    isOk := order:Truncate()
                    IF isOk
                        IF !order:Unique .AND. !order:Conditional .AND. !order:Descending .AND. !ordCondInfo:Scoped
                            isOk := order:_CreateIndex()
                        ELSE
                            isOk := order:_CreateUnique(ordCondInfo)
                        ENDIF
                    ENDIF
                NEXT
                IF !isOk
                    isOk := SELF:Flush()
                    IF !isOk
                        RETURN isOk
                    ENDIF
                    isOk := SELF:_oRdd:GoTop()
                ENDIF
                RETURN isOk

            INTERNAL METHOD FindOrder(info AS DbOrderInfo ) AS LONG
                LOCAL result AS LONG
                LOCAL num AS LONG
                //
                result := -1
                IF info == NULL .OR. info:Order == NULL
                    RETURN SELF:_focusNtx
                ENDIF
                //
                BEGIN SWITCH Type.GetTypeCode(info:Order:GetType())
                CASE TypeCode.String
                    result := SELF:__GetNamePos((STRING)info:Order)
                CASE TypeCode.Int16
                CASE TypeCode.Int32
                CASE TypeCode.Int64
                CASE TypeCode.Single
                CASE TypeCode.Double
                    num := Convert.ToInt32(info:Order)
                    IF ((num >= 0) .AND. (num <= SELF:_Orders:Count))
                        result := num
                    ENDIF
                OTHERWISE
                    result := -1
                END SWITCH
            RETURN result

        INTERNAL METHOD Flush() AS LOGIC
            LOCAL isOk AS LOGIC
            LOCAL i AS LONG
            LOCAL ntxIndex AS NtxOrder
            //
            isOk := TRUE
            FOR i := 0 TO SELF:_Orders:Count-1
                ntxIndex := SELF:_Orders[i]
                isOk := ntxIndex:Commit()
                IF !isOk
                    EXIT
                ENDIF
            NEXT
            RETURN isOk

        INTERNAL METHOD GoCold() AS LOGIC
            LOCAL isOk AS LOGIC
            LOCAL i AS LONG
            LOCAL ntxIndex AS NtxOrder
            //
            isOk := TRUE
            FOR i := 0 TO SELF:_Orders:Count-1
                ntxIndex := SELF:_Orders[i]
                isOk := ntxIndex:GoCold()
                IF (!isOk)
                    EXIT
                ENDIF
            NEXT
            RETURN isOk

        INTERNAL METHOD GoHot() AS LOGIC
            LOCAL isOk AS LOGIC
            LOCAL i AS LONG
            LOCAL ntxIndex AS NtxOrder
            //
            isOk := TRUE
            FOR i := 0 TO SELF:_Orders:Count-1
                ntxIndex := SELF:_Orders[i]
                isOk := ntxIndex:GoHot()
                IF (!isOk)
                    EXIT
                ENDIF
            NEXT
            RETURN isOk

        PRIVATE METHOD __GetNamePos(orderName AS STRING ) AS LONG
            LOCAL i AS LONG
            LOCAL ntxIndex AS NtxOrder
            //
            IF (SELF:_Orders:Count > 0)
                FOR i := 0 TO SELF:_Orders:Count-1
                    ntxIndex := SELF:_Orders[i]
                    IF (String.Equals(ntxIndex:OrderName, orderName, StringComparison.OrdinalIgnoreCase))
                        RETURN i + 1
                    ENDIF
                NEXT
            ENDIF
            RETURN 0

    END CLASS

END NAMESPACE

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

USING System
USING System.Collections.Generic
USING System.Text
USING XSharp.RDD.Support

BEGIN NAMESPACE XSharp.RDD.NTX

    INTERNAL SEALED CLASS NtxOrderList
        PRIVATE _focusNtx AS LONG
        PRIVATE _Orders AS List<NtxOrder>
        PRIVATE _oRdd AS DBFNTX
        PRIVATE _currentOrder AS NtxOrder
        INTERNAL PROPERTY Count AS LONG GET _Orders:Count
        INTERNAL PROPERTY Focus AS LONG GET _focusNtx
        INTERNAL PROPERTY CurrentOrder AS NtxOrder GET _currentOrder SET _currentOrder := value
        INTERNAL PROPERTY SELF[index AS LONG ] AS NtxOrder
                GET
                    IF ((index >= 0) .AND. (index < _Orders:Count))
                        RETURN _Orders[index]
                    ENDIF
                    RETURN NULL

                END GET
            END PROPERTY

            INTERNAL CONSTRUCTOR(area AS DBFNTX )
                SELF:_focusNtx := 0
                SELF:_Orders := List<NtxOrder>{}
                SELF:_oRdd := area
                SELF:_currentOrder := NULL

            INTERNAL METHOD Add(oi AS DbOrderInfo , filePath AS STRING ) AS LOGIC
                LOCAL isOk AS LOGIC
                LOCAL ntxIndex := NULL AS NtxOrder
                //
                isOk := FALSE
                 IF File(oi:BagName)
                    oi:BagName := FPathName()
                    TRY

                        IF SELF:_Orders:Count >= 16
                            SELF:_oRdd:_dbfError(Subcodes.ERDD_NTXLIMIT, Gencode.EG_LIMIT,  filePath)
                            isOk := FALSE
                        ELSE

                            ntxIndex := NtxOrder{SELF:_oRdd, filePath}
                            SELF:_Orders:Add(ntxIndex)
                            isOk := ntxIndex:Open(oi)
                            IF isOk
                                SELF:_focusNtx := SELF:_Orders:Count
                                SELF:_currentOrder := ntxIndex
                                oi:BagName := ntxIndex:FileName
                            ELSE
                                SELF:_Orders:Remove(ntxIndex)
                            ENDIF
                        ENDIF

                    CATCH e AS Exception
                        XSharp.RuntimeState.LastRddError := e
                        isOk := FALSE
                        IF ntxIndex != NULL .AND. SELF:_Orders:Contains(ntxIndex)
                            SELF:_Orders:Remove(ntxIndex)
                        ENDIF
                    END TRY
                    IF !isOk
                        SELF:_focusNtx := 0
                        SELF:_currentOrder := NULL
                    ENDIF
                ENDIF
                RETURN isOk

            INTERNAL METHOD Create(dboci AS DbOrderCreateInfo ) AS LOGIC
                LOCAL ntxIndex AS NtxOrder
                LOCAL isOk AS LOGIC
                //
                TRY
                    ntxIndex := NtxOrder{SELF:_oRdd}
                    isOk := ntxIndex:Create(dboci)
                    IF (!isOk)
                        RETURN isOk
                    ENDIF
                    SELF:_Orders:Add(ntxIndex)
                    SELF:_focusNtx := SELF:_Orders:Count
                    SELF:_currentOrder := ntxIndex
                    ntxIndex:GoTop()
                    RETURN isOk

                CATCH e AS Exception
                    System.Diagnostics.Debug.WriteLine(e:Message)
                    RETURN FALSE
                END TRY

            INTERNAL METHOD Delete( orderInfo AS DbOrderInfo) AS LOGIC
                LOCAL ntxIndex AS NtxOrder
                LOCAL found AS LOGIC
                LOCAL pos AS INT
                //
                IF (SELF:_Orders:Count == 0)
                    RETURN TRUE
                ENDIF
                //
                IF ( orderInfo:AllTags )
                    RETURN SELF:CloseAll()
                ENDIF
                //
                found := FALSE
                pos := SELF:_Orders:Count
                WHILE pos > 0
                    ntxIndex := SELF:_Orders[pos - 1]
                    IF ( ntxIndex:OrderName == orderInfo:BagName )
                        ntxIndex:Flush()
                        ntxIndex:Close()
                        //
                        SELF:_Orders:RemoveAt(pos - 1)
                        found := TRUE
                        EXIT
                    ENDIF
                ENDDO
                IF ( found )
                    IF ( SELF:_Orders:Count > 0 ) .AND. ( ( pos >= SELF:_focusNtx ) .AND. (pos < SELF:_Orders:Count ) )
                        SELF:_focusNtx :=- 1
                        SELF:_currentOrder := SELF:_Orders[pos - 1]
                    ELSE
                        SELF:_focusNtx := 0
                        SELF:_currentOrder := NULL
                    ENDIF
                ENDIF
                RETURN TRUE

            INTERNAL METHOD CloseAll() AS LOGIC
                LOCAL ntxIndex AS NtxOrder
                //
                IF (SELF:_Orders:Count == 0)
                    RETURN TRUE
                ENDIF
                //
                WHILE SELF:_Orders:Count > 0
                    ntxIndex := SELF:_Orders[SELF:_Orders:Count - 1]
                    ntxIndex:Flush()
                    ntxIndex:Close()
                    //
                    SELF:_Orders:RemoveAt(SELF:_Orders:Count - 1)
                ENDDO
                SELF:_focusNtx := 0
                SELF:_currentOrder := NULL
                RETURN TRUE

            INTERNAL METHOD SetFocus(oi AS DbOrderInfo ) AS LOGIC
                LOCAL currentOrder AS NtxOrder
                LOCAL isOk AS LOGIC
                //
                currentOrder := SELF:_currentOrder
                IF (currentOrder != NULL)
                    oi:BagName := currentOrder:FileName
                ELSE
                    oi:BagName := NULL
                ENDIF
                SELF:_focusNtx := 0
                SELF:_currentOrder := NULL
                SELF:_focusNtx := SELF:FindOrder(oi)
                isOk := FALSE
                IF (SELF:_focusNtx >= 0)
                    isOk := SELF:_oRdd:GoCold()
                    IF currentOrder != NULL_OBJECT
                        currentOrder:SetOffLine()
                    ENDIF
                    IF (isOk)
                        IF SELF:_focusNtx == 0
                            _currentOrder := NULL
                        ELSE
                            SELF:_currentOrder := SELF:_Orders[SELF:_focusNtx - 1]
                            SELF:_currentOrder:SetOffLine()
                        ENDIF
                    ENDIF
                ELSE
                    isOk := FALSE
                    SELF:_oRdd:_dbfError(Subcodes.ERDD_INVALID_ORDER, Gencode.EG_NOORDER,  NULL)
                ENDIF
                RETURN isOk

          METHOD OrderPos(oToFind AS NtxOrder) AS LONG
                LOCAL nPos := 0 AS LONG
                IF oToFind != NULL
                    FOREACH oOrder AS NtxOrder IN _Orders
                        ++nPos
                        IF oToFind == oOrder
                            RETURN nPos
                        ENDIF
                    NEXT
                ENDIF
                RETURN 0
            INTERNAL METHOD Rebuild() AS LOGIC
                LOCAL ordCondInfo AS DbOrderCondInfo
                LOCAL isOk AS LOGIC
                //
                ordCondInfo := SELF:_oRdd:_OrderCondInfo
                isOk := SELF:GoCold()
                IF (!isOk)
                    RETURN FALSE
                ENDIF
                //
                FOREACH order AS NtxOrder IN SELF:_Orders
                    isOk := order:Truncate()
                    IF isOk
                        IF !order:Unique .AND. !order:Conditional .AND. !order:Descending .AND. !ordCondInfo:Scoped
                            isOk := order:_CreateIndex()
                        ELSE
                            isOk := order:_CreateUnique(ordCondInfo)
                        ENDIF
                    ENDIF
                NEXT
                IF !isOk
                    isOk := SELF:Flush()
                    IF !isOk
                        RETURN isOk
                    ENDIF
                    isOk := SELF:_oRdd:GoTop()
                ENDIF
                RETURN isOk

            INTERNAL METHOD FindOrder(info AS DbOrderInfo ) AS LONG
                LOCAL result AS LONG
                LOCAL num AS LONG
                //
                result := -1
                IF info == NULL .OR. info:Order == NULL
                    RETURN SELF:_focusNtx
                ENDIF
                //
                BEGIN SWITCH Type.GetTypeCode(info:Order:GetType())
                CASE TypeCode.String
                    result := SELF:__GetNamePos((STRING)info:Order)
                CASE TypeCode.Int16
                CASE TypeCode.Int32
                CASE TypeCode.Int64
                CASE TypeCode.Single
                CASE TypeCode.Double
                    num := Convert.ToInt32(info:Order)
                    IF ((num >= 0) .AND. (num <= SELF:_Orders:Count))
                        result := num
                    ENDIF
                OTHERWISE
                    result := -1
                END SWITCH
            RETURN result

        INTERNAL METHOD Flush() AS LOGIC
            LOCAL isOk AS LOGIC
            LOCAL i AS LONG
            LOCAL ntxIndex AS NtxOrder
            //
            isOk := TRUE
            FOR i := 0 TO SELF:_Orders:Count-1
                ntxIndex := SELF:_Orders[i]
                isOk := ntxIndex:Commit()
                IF !isOk
                    EXIT
                ENDIF
            NEXT
            RETURN isOk

        INTERNAL METHOD GoCold() AS LOGIC
            LOCAL isOk AS LOGIC
            LOCAL i AS LONG
            LOCAL ntxIndex AS NtxOrder
            //
            isOk := TRUE
            FOR i := 0 TO SELF:_Orders:Count-1
                ntxIndex := SELF:_Orders[i]
                isOk := ntxIndex:GoCold()
                IF (!isOk)
                    EXIT
                ENDIF
            NEXT
            RETURN isOk

        INTERNAL METHOD GoHot() AS LOGIC
            LOCAL isOk AS LOGIC
            LOCAL i AS LONG
            LOCAL ntxIndex AS NtxOrder
            //
            isOk := TRUE
            FOR i := 0 TO SELF:_Orders:Count-1
                ntxIndex := SELF:_Orders[i]
                isOk := ntxIndex:GoHot()
                IF (!isOk)
                    EXIT
                ENDIF
            NEXT
            RETURN isOk

        PRIVATE METHOD __GetNamePos(orderName AS STRING ) AS LONG
            LOCAL i AS LONG
            LOCAL ntxIndex AS NtxOrder
            //
            IF (SELF:_Orders:Count > 0)
                FOR i := 0 TO SELF:_Orders:Count-1
                    ntxIndex := SELF:_Orders[i]
                    IF (String.Equals(ntxIndex:OrderName, orderName, StringComparison.OrdinalIgnoreCase))
                        RETURN i + 1
                    ENDIF
                NEXT
            ENDIF
            RETURN 0

    END CLASS

END NAMESPACE