QTableView: class updated - parameters checking - formatting

/*

  Qt5xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 5

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

*/

#include "hbclass.ch"
#include "qt5xhb_clsid.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QHEADERVIEW
REQUEST QMODELINDEX
#endif

CLASS QTableView INHERIT QAbstractItemView

   DATA class_id INIT Class_Id_QTableView
   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD clearSpans
   METHOD columnAt
   METHOD columnSpan
   METHOD columnViewportPosition
   METHOD columnWidth
   METHOD gridStyle
   METHOD horizontalHeader
   METHOD isColumnHidden
   METHOD isCornerButtonEnabled
   METHOD isRowHidden
   METHOD isSortingEnabled
   METHOD rowAt
   METHOD rowHeight
   METHOD rowSpan
   METHOD rowViewportPosition
   METHOD setColumnHidden
   METHOD setColumnWidth
   METHOD setCornerButtonEnabled
   METHOD setGridStyle
   METHOD setHorizontalHeader
   METHOD setRowHeight
   METHOD setRowHidden
   METHOD setSortingEnabled
   METHOD setSpan
   METHOD setVerticalHeader
   METHOD setWordWrap
   METHOD showGrid
   METHOD sortByColumn
   METHOD verticalHeader
   METHOD wordWrap
   METHOD indexAt
   METHOD setModel
   METHOD setRootIndex
   METHOD setSelectionModel
   METHOD hideColumn
   METHOD hideRow
   METHOD resizeColumnToContents
   METHOD resizeColumnsToContents
   METHOD resizeRowToContents
   METHOD resizeRowsToContents
   METHOD selectColumn
   METHOD selectRow
   METHOD setShowGrid
   METHOD showColumn
   METHOD showRow
   DESTRUCTOR destroyObject

END CLASS

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

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#include <QTableView>
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_clsid.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#include <QTableView>
#endif

/*
QTableView ( QWidget * parent = 0 )
*/
HB_FUNC_STATIC( QTABLEVIEW_NEW )
{
  QWidget * par1 = ISNIL(1)? 0 : (QWidget *) _qt5xhb_itemGetPtr(1);
  QTableView * o = new QTableView ( par1 );
  _qt5xhb_storePointerAndFlag( o, false );
}

HB_FUNC_STATIC( QTABLEVIEW_DELETE )
{
  QTableView * obj = (QTableView *) 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 clearSpans ()
*/
HB_FUNC_STATIC( QTABLEVIEW_CLEARSPANS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->clearSpans (  );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
int columnAt ( int x ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_COLUMNAT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->columnAt ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int columnSpan ( int row, int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_COLUMNSPAN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      hb_retni( obj->columnSpan ( (int) hb_parni(1), (int) hb_parni(2) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int columnViewportPosition ( int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_COLUMNVIEWPORTPOSITION )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->columnViewportPosition ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int columnWidth ( int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_COLUMNWIDTH )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->columnWidth ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
Qt::PenStyle gridStyle () const
*/
HB_FUNC_STATIC( QTABLEVIEW_GRIDSTYLE )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retni( obj->gridStyle (  ) );
  }
}

/*
QHeaderView * horizontalHeader () const
*/
HB_FUNC_STATIC( QTABLEVIEW_HORIZONTALHEADER )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QHeaderView * ptr = obj->horizontalHeader (  );
    _qt5xhb_createReturnClass ( ptr, "QHEADERVIEW" );
  }
}

/*
bool isColumnHidden ( int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ISCOLUMNHIDDEN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retl( obj->isColumnHidden ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
bool isCornerButtonEnabled () const
*/
HB_FUNC_STATIC( QTABLEVIEW_ISCORNERBUTTONENABLED )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->isCornerButtonEnabled (  ) );
  }
}

/*
bool isRowHidden ( int row ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ISROWHIDDEN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retl( obj->isRowHidden ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
bool isSortingEnabled () const
*/
HB_FUNC_STATIC( QTABLEVIEW_ISSORTINGENABLED )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->isSortingEnabled (  ) );
  }
}

/*
int rowAt ( int y ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ROWAT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->rowAt ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int rowHeight ( int row ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ROWHEIGHT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->rowHeight ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int rowSpan ( int row, int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ROWSPAN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      hb_retni( obj->rowSpan ( (int) hb_parni(1), (int) hb_parni(2) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int rowViewportPosition ( int row ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ROWVIEWPORTPOSITION )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->rowViewportPosition ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
void setColumnHidden ( int column, bool hide )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETCOLUMNHIDDEN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) && ISLOG(2) )
    {
      obj->setColumnHidden ( (int) hb_parni(1), (bool) hb_parl(2) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setColumnWidth ( int column, int width )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETCOLUMNWIDTH )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      obj->setColumnWidth ( (int) hb_parni(1), (int) hb_parni(2) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setCornerButtonEnabled ( bool enable )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETCORNERBUTTONENABLED )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISLOG(1) )
    {
      obj->setCornerButtonEnabled ( (bool) hb_parl(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setGridStyle ( Qt::PenStyle style )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETGRIDSTYLE )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      int par1 = hb_parni(1);
      obj->setGridStyle (  (Qt::PenStyle) par1 );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setHorizontalHeader ( QHeaderView * header )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETHORIZONTALHEADER )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISQHEADERVIEW(1) )
    {
      QHeaderView * par1 = (QHeaderView *) _qt5xhb_itemGetPtr(1);
      obj->setHorizontalHeader ( par1 );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setRowHeight ( int row, int height )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETROWHEIGHT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      obj->setRowHeight ( (int) hb_parni(1), (int) hb_parni(2) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setRowHidden ( int row, bool hide )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETROWHIDDEN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) && ISLOG(2) )
    {
      obj->setRowHidden ( (int) hb_parni(1), (bool) hb_parl(2) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setSortingEnabled ( bool enable )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETSORTINGENABLED )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISLOG(1) )
    {
      obj->setSortingEnabled ( (bool) hb_parl(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setSpan ( int row, int column, int rowSpanCount, int columnSpanCount )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETSPAN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) && ISNUM(3) && ISNUM(4) )
    {
      obj->setSpan ( (int) hb_parni(1), (int) hb_parni(2), (int) hb_parni(3), (int) hb_parni(4) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setVerticalHeader ( QHeaderView * header )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETVERTICALHEADER )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISQHEADERVIEW(1) )
    {
      QHeaderView * par1 = (QHeaderView *) _qt5xhb_itemGetPtr(1);
      obj->setVerticalHeader ( par1 );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setWordWrap ( bool on )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETWORDWRAP )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISLOG(1) )
    {
      obj->setWordWrap ( (bool) hb_parl(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
bool showGrid () const
*/
HB_FUNC_STATIC( QTABLEVIEW_SHOWGRID )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->showGrid (  ) );
  }
}

/*
void sortByColumn ( int column, Qt::SortOrder order )
*/
HB_FUNC_STATIC( QTABLEVIEW_SORTBYCOLUMN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      int par2 = hb_parni(2);
      obj->sortByColumn ( (int) hb_parni(1),  (Qt::SortOrder) par2 );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
QHeaderView * verticalHeader () const
*/
HB_FUNC_STATIC( QTABLEVIEW_VERTICALHEADER )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    QHeaderView * ptr = obj->verticalHeader (  );
    _qt5xhb_createReturnClass ( ptr, "QHEADERVIEW" );
  }
}

/*
bool wordWrap () const
*/
HB_FUNC_STATIC( QTABLEVIEW_WORDWRAP )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    hb_retl( obj->wordWrap (  ) );
  }
}

/*
virtual QModelIndex indexAt ( const QPoint & pos ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_INDEXAT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISQPOINT(1) )
    {
      QPoint * par1 = (QPoint *) _qt5xhb_itemGetPtr(1);
      QModelIndex * ptr = new QModelIndex( obj->indexAt ( *par1 ) );
      _qt5xhb_createReturnClass ( ptr, "QMODELINDEX", true );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
virtual void setModel ( QAbstractItemModel * model )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETMODEL )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISQABSTRACTITEMMODEL(1) )
    {
      QAbstractItemModel * par1 = (QAbstractItemModel *) _qt5xhb_itemGetPtr(1);
      obj->setModel ( par1 );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
virtual void setRootIndex ( const QModelIndex & index )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETROOTINDEX )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISQMODELINDEX(1) )
    {
      QModelIndex * par1 = (QModelIndex *) _qt5xhb_itemGetPtr(1);
      obj->setRootIndex ( *par1 );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
virtual void setSelectionModel ( QItemSelectionModel * selectionModel )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETSELECTIONMODEL )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISQITEMSELECTIONMODEL(1) )
    {
      QItemSelectionModel * par1 = (QItemSelectionModel *) _qt5xhb_itemGetPtr(1);
      obj->setSelectionModel ( par1 );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void hideColumn ( int column )
*/
HB_FUNC_STATIC( QTABLEVIEW_HIDECOLUMN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->hideColumn ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void hideRow ( int row )
*/
HB_FUNC_STATIC( QTABLEVIEW_HIDEROW )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->hideRow ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void resizeColumnToContents ( int column )
*/
HB_FUNC_STATIC( QTABLEVIEW_RESIZECOLUMNTOCONTENTS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->resizeColumnToContents ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void resizeColumnsToContents ()
*/
HB_FUNC_STATIC( QTABLEVIEW_RESIZECOLUMNSTOCONTENTS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->resizeColumnsToContents (  );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void resizeRowToContents ( int row )
*/
HB_FUNC_STATIC( QTABLEVIEW_RESIZEROWTOCONTENTS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->resizeRowToContents ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void resizeRowsToContents ()
*/
HB_FUNC_STATIC( QTABLEVIEW_RESIZEROWSTOCONTENTS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    obj->resizeRowsToContents (  );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void selectColumn ( int column )
*/
HB_FUNC_STATIC( QTABLEVIEW_SELECTCOLUMN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->selectColumn ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void selectRow ( int row )
*/
HB_FUNC_STATIC( QTABLEVIEW_SELECTROW )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->selectRow ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShowGrid ( bool show )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETSHOWGRID )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISLOG(1) )
    {
      obj->setShowGrid ( (bool) hb_parl(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void showColumn ( int column )
*/
HB_FUNC_STATIC( QTABLEVIEW_SHOWCOLUMN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->showColumn ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void showRow ( int row )
*/
HB_FUNC_STATIC( QTABLEVIEW_SHOWROW )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->showRow ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

#pragma ENDDUMP

/*

  Qt5xHb - bibliotecas de ligao entre Harbour/xHarbour e Qt Framework 5

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

*/

#include "hbclass.ch"
#include "qt5xhb_clsid.ch"

#ifndef QT5XHB_NO_REQUESTS
REQUEST QHEADERVIEW
REQUEST QMODELINDEX
#endif

CLASS QTableView INHERIT QAbstractItemView

   DATA class_id INIT Class_Id_QTableView
   DATA class_flags INIT 1
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD clearSpans
   METHOD columnAt
   METHOD columnSpan
   METHOD columnViewportPosition
   METHOD columnWidth
   METHOD gridStyle
   METHOD horizontalHeader
   METHOD isColumnHidden
   METHOD isCornerButtonEnabled
   METHOD isRowHidden
   METHOD isSortingEnabled
   METHOD rowAt
   METHOD rowHeight
   METHOD rowSpan
   METHOD rowViewportPosition
   METHOD setColumnHidden
   METHOD setColumnWidth
   METHOD setCornerButtonEnabled
   METHOD setGridStyle
   METHOD setHorizontalHeader
   METHOD setRowHeight
   METHOD setRowHidden
   METHOD setSortingEnabled
   METHOD setSpan
   METHOD setVerticalHeader
   METHOD setWordWrap
   METHOD showGrid
   METHOD sortByColumn
   METHOD verticalHeader
   METHOD wordWrap
   METHOD indexAt
   METHOD setModel
   METHOD setRootIndex
   METHOD setSelectionModel
   METHOD hideColumn
   METHOD hideRow
   METHOD resizeColumnToContents
   METHOD resizeColumnsToContents
   METHOD resizeRowToContents
   METHOD resizeRowsToContents
   METHOD selectColumn
   METHOD selectRow
   METHOD setShowGrid
   METHOD showColumn
   METHOD showRow
   DESTRUCTOR destroyObject

END CLASS

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

#pragma BEGINDUMP

#include <Qt>

#ifndef __XHARBOUR__
#include <QTableView>
#endif

#include "qt5xhb_common.h"
#include "qt5xhb_clsid.h"
#include "qt5xhb_utils.h"

#ifdef __XHARBOUR__
#include <QTableView>
#endif

/*
QTableView ( QWidget * parent = 0 )
*/
HB_FUNC_STATIC( QTABLEVIEW_NEW )
{
  QWidget * par1 = ISNIL(1)? 0 : (QWidget *) _qt5xhb_itemGetPtr(1);
  QTableView * o = new QTableView ( par1 );
  _qt5xhb_storePointerAndFlag( o, false );
}

HB_FUNC_STATIC( QTABLEVIEW_DELETE )
{
  QTableView * obj = (QTableView *) 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 clearSpans ()
*/
HB_FUNC_STATIC( QTABLEVIEW_CLEARSPANS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->clearSpans (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
int columnAt ( int x ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_COLUMNAT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->columnAt ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int columnSpan ( int row, int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_COLUMNSPAN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      hb_retni( obj->columnSpan ( (int) hb_parni(1), (int) hb_parni(2) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int columnViewportPosition ( int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_COLUMNVIEWPORTPOSITION )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->columnViewportPosition ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int columnWidth ( int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_COLUMNWIDTH )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->columnWidth ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
Qt::PenStyle gridStyle () const
*/
HB_FUNC_STATIC( QTABLEVIEW_GRIDSTYLE )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retni( obj->gridStyle (  ) );
  }
}

/*
QHeaderView * horizontalHeader () const
*/
HB_FUNC_STATIC( QTABLEVIEW_HORIZONTALHEADER )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QHeaderView * ptr = obj->horizontalHeader (  );
    _qt5xhb_createReturnClass ( ptr, "QHEADERVIEW" );
  }
}

/*
bool isColumnHidden ( int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ISCOLUMNHIDDEN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retl( obj->isColumnHidden ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
bool isCornerButtonEnabled () const
*/
HB_FUNC_STATIC( QTABLEVIEW_ISCORNERBUTTONENABLED )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isCornerButtonEnabled (  ) );
  }
}

/*
bool isRowHidden ( int row ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ISROWHIDDEN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retl( obj->isRowHidden ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
bool isSortingEnabled () const
*/
HB_FUNC_STATIC( QTABLEVIEW_ISSORTINGENABLED )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->isSortingEnabled (  ) );
  }
}

/*
int rowAt ( int y ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ROWAT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->rowAt ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int rowHeight ( int row ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ROWHEIGHT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->rowHeight ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int rowSpan ( int row, int column ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ROWSPAN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      hb_retni( obj->rowSpan ( (int) hb_parni(1), (int) hb_parni(2) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
int rowViewportPosition ( int row ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_ROWVIEWPORTPOSITION )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      hb_retni( obj->rowViewportPosition ( (int) hb_parni(1) ) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
}

/*
void setColumnHidden ( int column, bool hide )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETCOLUMNHIDDEN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) && ISLOG(2) )
    {
      obj->setColumnHidden ( (int) hb_parni(1), (bool) hb_parl(2) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setColumnWidth ( int column, int width )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETCOLUMNWIDTH )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      obj->setColumnWidth ( (int) hb_parni(1), (int) hb_parni(2) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setCornerButtonEnabled ( bool enable )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETCORNERBUTTONENABLED )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISLOG(1) )
    {
      obj->setCornerButtonEnabled ( (bool) hb_parl(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setGridStyle ( Qt::PenStyle style )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETGRIDSTYLE )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    int par1 = hb_parni(1);
    obj->setGridStyle (  (Qt::PenStyle) par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setHorizontalHeader ( QHeaderView * header )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETHORIZONTALHEADER )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QHeaderView * par1 = (QHeaderView *) _qt5xhb_itemGetPtr(1);
    obj->setHorizontalHeader ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setRowHeight ( int row, int height )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETROWHEIGHT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      obj->setRowHeight ( (int) hb_parni(1), (int) hb_parni(2) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setRowHidden ( int row, bool hide )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETROWHIDDEN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) && ISLOG(2) )
    {
      obj->setRowHidden ( (int) hb_parni(1), (bool) hb_parl(2) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setSortingEnabled ( bool enable )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETSORTINGENABLED )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISLOG(1) )
    {
      obj->setSortingEnabled ( (bool) hb_parl(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setSpan ( int row, int column, int rowSpanCount, int columnSpanCount )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETSPAN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) && ISNUM(3) && ISNUM(4) )
    {
      obj->setSpan ( (int) hb_parni(1), (int) hb_parni(2), (int) hb_parni(3), (int) hb_parni(4) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setVerticalHeader ( QHeaderView * header )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETVERTICALHEADER )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QHeaderView * par1 = (QHeaderView *) _qt5xhb_itemGetPtr(1);
    obj->setVerticalHeader ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setWordWrap ( bool on )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETWORDWRAP )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISLOG(1) )
    {
      obj->setWordWrap ( (bool) hb_parl(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
bool showGrid () const
*/
HB_FUNC_STATIC( QTABLEVIEW_SHOWGRID )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->showGrid (  ) );
  }
}

/*
void sortByColumn ( int column, Qt::SortOrder order )
*/
HB_FUNC_STATIC( QTABLEVIEW_SORTBYCOLUMN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) && ISNUM(2) )
    {
      int par2 = hb_parni(2);
      obj->sortByColumn ( (int) hb_parni(1),  (Qt::SortOrder) par2 );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
QHeaderView * verticalHeader () const
*/
HB_FUNC_STATIC( QTABLEVIEW_VERTICALHEADER )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QHeaderView * ptr = obj->verticalHeader (  );
    _qt5xhb_createReturnClass ( ptr, "QHEADERVIEW" );
  }
}

/*
bool wordWrap () const
*/
HB_FUNC_STATIC( QTABLEVIEW_WORDWRAP )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    hb_retl( obj->wordWrap (  ) );
  }
}

/*
virtual QModelIndex indexAt ( const QPoint & pos ) const
*/
HB_FUNC_STATIC( QTABLEVIEW_INDEXAT )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QPoint * par1 = (QPoint *) _qt5xhb_itemGetPtr(1);
    QModelIndex * ptr = new QModelIndex( obj->indexAt ( *par1 ) );
    _qt5xhb_createReturnClass ( ptr, "QMODELINDEX", true );
  }
}

/*
virtual void setModel ( QAbstractItemModel * model )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETMODEL )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QAbstractItemModel * par1 = (QAbstractItemModel *) _qt5xhb_itemGetPtr(1);
    obj->setModel ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
virtual void setRootIndex ( const QModelIndex & index )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETROOTINDEX )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QModelIndex * par1 = (QModelIndex *) _qt5xhb_itemGetPtr(1);
    obj->setRootIndex ( *par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
virtual void setSelectionModel ( QItemSelectionModel * selectionModel )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETSELECTIONMODEL )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    QItemSelectionModel * par1 = (QItemSelectionModel *) _qt5xhb_itemGetPtr(1);
    obj->setSelectionModel ( par1 );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void hideColumn ( int column )
*/
HB_FUNC_STATIC( QTABLEVIEW_HIDECOLUMN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->hideColumn ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void hideRow ( int row )
*/
HB_FUNC_STATIC( QTABLEVIEW_HIDEROW )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->hideRow ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void resizeColumnToContents ( int column )
*/
HB_FUNC_STATIC( QTABLEVIEW_RESIZECOLUMNTOCONTENTS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->resizeColumnToContents ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void resizeColumnsToContents ()
*/
HB_FUNC_STATIC( QTABLEVIEW_RESIZECOLUMNSTOCONTENTS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->resizeColumnsToContents (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void resizeRowToContents ( int row )
*/
HB_FUNC_STATIC( QTABLEVIEW_RESIZEROWTOCONTENTS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->resizeRowToContents ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void resizeRowsToContents ()
*/
HB_FUNC_STATIC( QTABLEVIEW_RESIZEROWSTOCONTENTS )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    obj->resizeRowsToContents (  );
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void selectColumn ( int column )
*/
HB_FUNC_STATIC( QTABLEVIEW_SELECTCOLUMN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->selectColumn ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void selectRow ( int row )
*/
HB_FUNC_STATIC( QTABLEVIEW_SELECTROW )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->selectRow ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void setShowGrid ( bool show )
*/
HB_FUNC_STATIC( QTABLEVIEW_SETSHOWGRID )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    if( ISLOG(1) )
    {
      obj->setShowGrid ( (bool) hb_parl(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void showColumn ( int column )
*/
HB_FUNC_STATIC( QTABLEVIEW_SHOWCOLUMN )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->showColumn ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

/*
void showRow ( int row )
*/
HB_FUNC_STATIC( QTABLEVIEW_SHOWROW )
{
  QTableView * obj = (QTableView *) _qt5xhb_itemGetPtrStackSelfItem();
  if( obj )
  {
    if( ISNUM(1) )
    {
      obj->showRow ( (int) hb_parni(1) );
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
  }
  hb_itemReturn( hb_stackSelfItem() );
}

#pragma ENDDUMP


work in progress try to make l == ll for Star

-- parametric HOAS (PHOAS) representation of terms
-- advocated by Chipala and B. Oliveira
--

data Ptm :: * ~> * ~> * ~> Nat ~> * where
  Var :: a -> Ptm a t l ll
  Lam :: (a -> Ptm a t l ll) -> Ptm a t l ll
  Lev :: (l -> Ptm a t l ll) -> Ptm a t l ll
  App :: Ptm a t l ll -> Ptm a t l ll -> Ptm a t l ll
  Star :: Nat' l -> Ptm a t (Nat' l) ll
  Forall :: (t -> Ptm a t l ll) -> Ptm a t l ll
  TyVar :: t -> Ptm a t l ll

data Tm :: Nat ~> * where
  Tm :: (forall a t l . Ptm a t (Nat' l) ll) -> Tm ll

-- illegal
--
##test "not parametric"
 ill = Tm (Lam (\a -> a + 2))

##test "not parametric: expr var in level context"
 ill = Tm (Lev (\a -> App (Var a) (Var a)))

-- these are parametric
--
leg = Tm (Lam (\a -> App (Var a) (Var a)))

leg2 = Tm (Forall (\t -> TyVar t))
leg3 = Tm (Lev (\l -> Star l))

-- parametric HOAS (PHOAS) representation of terms
-- advocated by Chipala and B. Oliveira
--

data Ptm :: * ~> * ~> * ~> * where
  Var :: a -> Ptm a t l
  Lam :: (a -> Ptm a t l) -> Ptm a t l
  Lev :: (l -> Ptm a t l) -> Ptm a t l
  App :: Ptm a t l -> Ptm a t l -> Ptm a t l
  Star :: l -> Ptm a t l
  Forall :: (t -> Ptm a t l) -> Ptm a t l
  TyVar :: t -> Ptm a t l

data Tm = Tm (forall a t l . Ptm a t (Nat' l))

-- illegal
--
##test "not parametric"
 ill = Tm (Lam (\a -> a + 2))

##test "not parametric: expr var in level context"
 ill = Tm (Lev (\a -> App (Var a) (Var a)))

-- these are parametric
--
leg = Tm (Lam (\a -> App (Var a) (Var a)))

leg2 = Tm (Forall (\t -> TyVar t))


{Runtime] Rolled back changes from c5422e83d30948805f910a159a94282a5a72600e

//
// 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.Text
USING System.Globalization
USING System.Collections.Generic
USING System.Reflection

INTERNAL STATIC CLASS XSharp.ConversionHelpers
    STATIC INTERNAL usCulture AS CultureInfo
    STATIC CONSTRUCTOR
        usCulture := CultureInfo{"en-US"}
END CLASS

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2dw/*" />
FUNCTION Bin2DW(cUnsignedInt AS STRING) AS DWORD
    LOCAL dwResult := 0 AS DWORD
    IF cUnsignedInt!= NULL .AND. cUnsignedInt:Length >= 4
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{4}
        aBytes[0] := (BYTE) _AND(cUnsignedInt:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cUnsignedInt:Chars[1], 0xFF)
        aBytes[2] := (BYTE) _AND(cUnsignedInt:Chars[2], 0xFF)
        aBytes[3] := (BYTE) _AND(cUnsignedInt:Chars[3], 0xFF)
        dwResult := BitConverter.ToUInt32(aBytes, 0)
    ENDIF
    RETURN dwResult

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2i/*" />
FUNCTION Bin2I(cSignedInt AS STRING) AS SHORT
    LOCAL siResult := 0 AS SHORT
    IF cSignedInt!= NULL .AND. cSignedInt:Length >= 2
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{2}
        aBytes[0] := (BYTE) _AND(cSignedInt:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cSignedInt:Chars[1], 0xFF)
        siResult := BitConverter.ToInt16(aBytes, 0)
    ENDIF
    RETURN siResult

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2l/*" />
FUNCTION Bin2L(cSignedInt AS STRING) AS LONG
    LOCAL liResult := 0 AS LONG
    IF cSignedInt!= NULL .AND. cSignedInt:Length >= 4
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{4}
        aBytes[0] := (BYTE) _AND(cSignedInt:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cSignedInt:Chars[1], 0xFF)
        aBytes[2] := (BYTE) _AND(cSignedInt:Chars[2], 0xFF)
        aBytes[3] := (BYTE) _AND(cSignedInt:Chars[3], 0xFF)
        liResult := BitConverter.ToInt32(aBytes, 0)
    ENDIF
    RETURN liResult

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2logic/*" />
FUNCTION Bin2Logic(pszLogical AS STRING) AS LOGIC
    RETURN pszLogical != NULL .AND. pszLogical[0] != 0

///
/// Convert a intptr to a string
///
/// <include file="CoreComments.xml" path="Comments/PtrBin/*" />
/// <seealso cref='Bin2Ptr' >Bin2Ptr</seealso>
FUNCTION Ptr2Bin(p AS IntPtr) AS STRING
    IF IntPtr.Size == 4
        RETURN L2Bin( p:ToInt32())
    ELSE
        THROW NotSupportedException{}
    ENDIF

///
///
/// <param name="cPointer"></param>
/// <include file="CoreComments.xml" path="Comments/PtrBin/*" />
/// <seealso cref='Ptr2Bin' >Ptr2Bin</seealso>
FUNCTION Bin2Ptr(cPointer AS STRING) AS IntPtr
    IF IntPtr.Size == 4
        RETURN (IntPtr) Bin2L(cPointer)
    ELSE
        THROW NotSupportedException{}
    ENDIF

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2real4/*" />
FUNCTION Bin2Real4(cFloat AS STRING) AS REAL4
    LOCAL r4Result := 0 AS REAL4
    IF cFloat!= NULL .AND. cFloat:Length >= 4
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{4}
        aBytes[0] := (BYTE) _AND(cFloat:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cFloat:Chars[1], 0xFF)
        aBytes[2] := (BYTE) _AND(cFloat:Chars[2], 0xFF)
        aBytes[3] := (BYTE) _AND(cFloat:Chars[3], 0xFF)
        r4Result := BitConverter.ToSingle(aBytes, 0)
    ENDIF
    RETURN r4Result

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2real8/*" />
FUNCTION Bin2Real8(cFloat AS STRING) AS REAL8
    LOCAL r8Result := 0 AS REAL8
    IF cFloat!= NULL .AND. cFloat:Length >= 8
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{8}
        aBytes[0] := (BYTE) _AND(cFloat:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cFloat:Chars[1], 0xFF)
        aBytes[2] := (BYTE) _AND(cFloat:Chars[2], 0xFF)
        aBytes[3] := (BYTE) _AND(cFloat:Chars[3], 0xFF)
        aBytes[4] := (BYTE) _AND(cFloat:Chars[4], 0xFF)
        aBytes[5] := (BYTE) _AND(cFloat:Chars[5], 0xFF)
        aBytes[6] := (BYTE) _AND(cFloat:Chars[6], 0xFF)
        aBytes[7] := (BYTE) _AND(cFloat:Chars[7], 0xFF)
        r8Result := BitConverter.ToDouble(aBytes, 0)
    ENDIF
    RETURN r8Result

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2w/*" />
FUNCTION Bin2W(cUnsignedInt AS STRING) AS WORD
    LOCAL wResult := 0 AS WORD
    IF cUnsignedInt!= NULL .AND. cUnsignedInt:Length >= 2
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{2}
        aBytes[0] := (BYTE) _AND(cUnsignedInt:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cUnsignedInt:Chars[1], 0xFF)
        wResult := BitConverter.ToUInt16(aBytes, 0)
    ENDIF
    RETURN wResult

///
/// Convert a string value to a logic.
///
/// <param name="c"></param>
/// <returns>
/// </returns>
/// <seealso cref='LTOC' >LTOC</seealso>
/// <seealso cref='Logic2Bin' >Logic2Bin</seealso>

FUNCTION CTOL(c AS STRING) AS LOGIC
    IF c != NULL
        IF c[0] == 'T' .OR. c[0] == 't' .OR. c[0] == 'Y' .OR. c[0] =='y'
            RETURN TRUE
        ENDIF
    ENDIF
    RETURN FALSE

/// Convert a string value to a hexadecimal string.
/// <param name="cSource">String to convert</param>
/// <param name="lAddSpace">When TRUE then the inidividual characters are separated with a space in the result string</param>
/// <returns>A string with the hex representation of the value</returns>
/// <example>
///  ? _C2Hex("abcdef", TRUE)                // 61 62 63 64 65 66

///  ? _C2Hex("abcdef", FALSE)               // 616263646566

/// </example>
/// <seealso cref='M:XSharp.RT.Functions.AsHexString(XSharp.__Usual)' >AsHexString</seealso>
/// <seealso cref='C2Hex' >C2Hex</seealso>
FUNCTION _C2Hex(cSource AS STRING, lAddSpace as LOGIC) AS STRING
    LOCAL sb AS StringBuilder
    sb := StringBuilder{cSource:Length*2}
    FOREACH c AS CHAR IN cSource
        IF sb:Length > 0 .and. lAddSpace
            sb:Append(' ')
        ENDIF
        var s := String.Format("{0:X2}",(INT) c)
        sb:Append(s)
    NEXT
    RETURN sb:ToString()

/// Convert a string value to a hexadecimal string.
/// <param name="cSource">String to convert</param>
/// <returns>A string with the hex representation of the value</returns>
/// <example>
///  ? C2Hex("abcdef")               // 616263646566

/// </example>
/// <seealso cref='M:XSharp.RT.Functions.AsHexString(XSharp.__Usual)' >AsHexString</seealso>
/// <seealso cref='_C2Hex' >_C2Hex</seealso>
FUNCTION C2Hex(cSource AS STRING) AS STRING
    RETURN _C2Hex(cSource, FALSE)

// helper function to convert bytes to string

INTERNAL FUNCTION _bytes2String(byteArray AS BYTE[]) AS STRING
    LOCAL sb AS StringBuilder
    sb := StringBuilder{}
    FOREACH VAR b IN byteArray
        sb:Append( (CHAR) b)
    NEXT
    RETURN sb:ToString()

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/dw2bin/*" />
FUNCTION DW2Bin(dwValue AS DWORD) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( dwValue ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/hibyte/*" />
FUNCTION HiByte(wValue AS WORD) AS BYTE
    RETURN (BYTE) (wValue >> 8)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/hiword/*" />
FUNCTION HiWord(dwValue AS DWORD) AS WORD
    RETURN (WORD) (dwValue >> 16)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/i2bin/*" />
/// <seealso cref='Bin2I' >Bin2I</seealso>
FUNCTION I2Bin(siValue AS SHORT) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( siValue ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/l2bin/*" />
FUNCTION L2Bin(liValue AS LONG) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( liValue ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/lobyte/*" />
FUNCTION LoByte(wValue AS WORD) AS BYTE
    RETURN (BYTE) _AND(wValue, 0x00FF)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/loword/*" />
FUNCTION LoWord(dwValue AS DWORD) AS WORD
    RETURN (WORD) _AND(dwValue , 0xFFFF)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/logic2bin/*" />
FUNCTION Logic2Bin(lValue AS LOGIC) AS STRING
    IF lValue
        RETURN e"\x0001"
    ELSE
        RETURN e"\x0000"
    ENDIF

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/ltoc/*" />
FUNCTION LTOC(lValue AS LOGIC) AS STRING
    IF lValue
        RETURN "T"
    ELSE
        RETURN "F"
    ENDIF

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/real42bin/*" />
FUNCTION Real42Bin(r4Value AS REAL4) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( r4Value ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/real82bin/*" />
FUNCTION Real82Bin(r8Value AS REAL8) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( r8Value ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/w2bin/*" />
FUNCTION W2Bin(wValue AS WORD) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( wValue ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/val/*" />
FUNCTION _Val(cNumber AS STRING) AS OBJECT
    IF String.IsNullOrEmpty(cNumber)
      RETURN 0
    ENDIF
    cNumber := cNumber:Trim():ToUpper()
    // find non numeric characters in cNumber and trim the field to that length
    VAR pos := 0
    VAR done := FALSE
    VAR hex  := FALSE
    VAR hasdec := FALSE
    VAR hasexp := FALSE
    VAR cDec := (CHAR) RuntimeState.DecimalSep

    IF cDec != '.'
        cNumber := cNumber:Replace('.', cDec) // VO behavior...
        cNumber := cNumber:Replace(cDec, '.')
    ENDIF
    FOREACH VAR c IN cNumber
        SWITCH c
        CASE '0'
        CASE '1'
        CASE '2'
        CASE '3'
        CASE '4'
        CASE '5'
        CASE '6'
        CASE '7'
        CASE '8'
        CASE '9'
        CASE '-'
        CASE '+'
            NOP
        CASE '.'
        CASE ','
            IF c == ',' .AND. cDec != ',' // Don't ask, VO...
                done := TRUE
            ELSEIF hasdec
                done := TRUE
            ELSE
                hasdec := TRUE
            ENDIF
        CASE 'A'
        CASE 'B'
        CASE 'C'
        CASE 'D'
        CASE 'F'
            IF !hex
                done := TRUE
            ENDIF
        CASE 'E'
            // exponentional notation only allowed if decimal separator was there
            IF hasdec
                hasexp := TRUE
            ELSE
                IF !hex
                    done := TRUE
                ENDIF
            ENDIF
        CASE 'L'	// LONG result
        CASE 'U'	// DWORD result
            done := TRUE
        CASE 'X'
            IF pos == 1
                hex := TRUE
            ELSE
                done := TRUE
            ENDIF
        OTHERWISE
            done := TRUE
        END SWITCH
        IF done
            EXIT
        ENDIF
        pos += 1
    NEXT
    IF pos < cNumber:Length
        cNumber := cNumber:Substring(0, pos)
    ENDIF
    IF cNumber:IndexOfAny(<CHAR> {'.'}) > -1
        LOCAL r8Result := 0 AS REAL8
        IF cDec != '.'
            cNumber := cNumber:Replace(cDec, '.')
        ENDIF
        VAR style := NumberStyles.Number
        IF hasexp
            style |= NumberStyles.AllowExponent
        ENDIF
        IF System.Double.TryParse(cNumber, style, ConversionHelpers.usCulture, OUT r8Result)
            RETURN r8Result
        ENDIF
    ELSE
        LOCAL iResult := 0 AS INT64
        LOCAL style AS NumberStyles
        IF hex
            cNumber := cNumber:Substring(2)
            style := NumberStyles.HexNumber
        ELSE
            style := NumberStyles.Integer
        ENDIF
        IF System.Int64.TryParse(cNumber, style, ConversionHelpers.usCulture, OUT iResult)
            IF iResult < Int32.MaxValue .AND. iResult > Int32.MinValue
                RETURN (INT) iResult
            ENDIF
            RETURN iResult
        ENDIF
    ENDIF
    RETURN 0

FUNCTION GetPartialEnumName(cName as STRING, oType as System.Type) AS STRING
    LOCAL aFields   := oType:GetFields() AS FieldInfo[]
    LOCAL aNames    := List<STRING>{} AS List<STRING>
    FOREACH VAR oFld IN aFields
        IF oFld:IsLiteral .AND. oFld:Name:StartsWith(cName, StringComparison.OrdinalIgnoreCase)
            aNames:Add(oFld:Name)
        ENDIF
    NEXT
    IF aNames:Count == 1
        cName := aNames[0]
    ELSE
        cName := ""
    ENDIF
    RETURN cName

//
// 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.Text
USING System.Globalization
USING System.Collections.Generic
USING System.Reflection

INTERNAL STATIC CLASS XSharp.ConversionHelpers
    STATIC INTERNAL usCulture AS CultureInfo
    STATIC CONSTRUCTOR
        usCulture := CultureInfo{"en-US"}
END CLASS

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2dw/*" />
FUNCTION Bin2DW(cUnsignedInt AS STRING) AS DWORD
    LOCAL dwResult := 0 AS DWORD
    IF cUnsignedInt!= NULL .AND. cUnsignedInt:Length >= 4
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{4}
        aBytes[0] := (BYTE) _AND(cUnsignedInt:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cUnsignedInt:Chars[1], 0xFF)
        aBytes[2] := (BYTE) _AND(cUnsignedInt:Chars[2], 0xFF)
        aBytes[3] := (BYTE) _AND(cUnsignedInt:Chars[3], 0xFF)
        dwResult := BitConverter.ToUInt32(aBytes, 0)
    ENDIF
    RETURN dwResult

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2i/*" />
FUNCTION Bin2I(cSignedInt AS STRING) AS SHORT
    LOCAL siResult := 0 AS SHORT
    IF cSignedInt!= NULL .AND. cSignedInt:Length >= 2
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{2}
        aBytes[0] := (BYTE) _AND(cSignedInt:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cSignedInt:Chars[1], 0xFF)
        siResult := BitConverter.ToInt16(aBytes, 0)
    ENDIF
    RETURN siResult

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2l/*" />
FUNCTION Bin2L(cSignedInt AS STRING) AS LONG
    LOCAL liResult := 0 AS LONG
    IF cSignedInt!= NULL .AND. cSignedInt:Length >= 4
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{4}
        aBytes[0] := (BYTE) _AND(cSignedInt:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cSignedInt:Chars[1], 0xFF)
        aBytes[2] := (BYTE) _AND(cSignedInt:Chars[2], 0xFF)
        aBytes[3] := (BYTE) _AND(cSignedInt:Chars[3], 0xFF)
        liResult := BitConverter.ToInt32(aBytes, 0)
    ENDIF
    RETURN liResult

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2logic/*" />
FUNCTION Bin2Logic(pszLogical AS STRING) AS LOGIC
    RETURN pszLogical != NULL .AND. pszLogical[0] != 0

///
/// Convert a intptr to a string
///
/// <include file="CoreComments.xml" path="Comments/PtrBin/*" />
/// <seealso cref='Bin2Ptr' >Bin2Ptr</seealso>
FUNCTION Ptr2Bin(p AS IntPtr) AS STRING
    IF IntPtr.Size == 4
        RETURN L2Bin( p:ToInt32())
    ELSE
        THROW NotSupportedException{}
    ENDIF

///
///
/// <param name="cPointer"></param>
/// <include file="CoreComments.xml" path="Comments/PtrBin/*" />
/// <seealso cref='Ptr2Bin' >Ptr2Bin</seealso>
FUNCTION Bin2Ptr(cPointer AS STRING) AS IntPtr
    IF IntPtr.Size == 4
        RETURN (IntPtr) Bin2L(cPointer)
    ELSE
        THROW NotSupportedException{}
    ENDIF

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2real4/*" />
FUNCTION Bin2Real4(cFloat AS STRING) AS REAL4
    LOCAL r4Result := 0 AS REAL4
    IF cFloat!= NULL .AND. cFloat:Length >= 4
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{4}
        aBytes[0] := (BYTE) _AND(cFloat:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cFloat:Chars[1], 0xFF)
        aBytes[2] := (BYTE) _AND(cFloat:Chars[2], 0xFF)
        aBytes[3] := (BYTE) _AND(cFloat:Chars[3], 0xFF)
        r4Result := BitConverter.ToSingle(aBytes, 0)
    ENDIF
    RETURN r4Result

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2real8/*" />
FUNCTION Bin2Real8(cFloat AS STRING) AS REAL8
    LOCAL r8Result := 0 AS REAL8
    IF cFloat!= NULL .AND. cFloat:Length >= 8
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{8}
        aBytes[0] := (BYTE) _AND(cFloat:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cFloat:Chars[1], 0xFF)
        aBytes[2] := (BYTE) _AND(cFloat:Chars[2], 0xFF)
        aBytes[3] := (BYTE) _AND(cFloat:Chars[3], 0xFF)
        aBytes[4] := (BYTE) _AND(cFloat:Chars[4], 0xFF)
        aBytes[5] := (BYTE) _AND(cFloat:Chars[5], 0xFF)
        aBytes[6] := (BYTE) _AND(cFloat:Chars[6], 0xFF)
        aBytes[7] := (BYTE) _AND(cFloat:Chars[7], 0xFF)
        r8Result := BitConverter.ToDouble(aBytes, 0)
    ENDIF
    RETURN r8Result

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/bin2w/*" />
FUNCTION Bin2W(cUnsignedInt AS STRING) AS WORD
    LOCAL wResult := 0 AS WORD
    IF cUnsignedInt!= NULL .AND. cUnsignedInt:Length >= 2
        LOCAL aBytes AS BYTE[]
        aBytes := BYTE[]{2}
        aBytes[0] := (BYTE) _AND(cUnsignedInt:Chars[0], 0xFF)
        aBytes[1] := (BYTE) _AND(cUnsignedInt:Chars[1], 0xFF)
        wResult := BitConverter.ToUInt16(aBytes, 0)
    ENDIF
    RETURN wResult

///
/// Convert a string value to a logic.
///
/// <param name="c"></param>
/// <returns>
/// </returns>
/// <seealso cref='LTOC' >LTOC</seealso>
/// <seealso cref='Logic2Bin' >Logic2Bin</seealso>

FUNCTION CTOL(c AS STRING) AS LOGIC
    IF c != NULL
        IF c[0] == 'T' .OR. c[0] == 't' .OR. c[0] == 'Y' .OR. c[0] =='y'
            RETURN TRUE
        ENDIF
    ENDIF
    RETURN FALSE

/// Convert a string value to a hexadecimal string.
/// <param name="cSource">String to convert</param>
/// <param name="lAddSpace">When TRUE then the inidividual characters are separated with a space in the result string</param>
/// <returns>A string with the hex representation of the value</returns>
/// <example>
///  ? _C2Hex("abcdef", TRUE)                // 61 62 63 64 65 66

///  ? _C2Hex("abcdef", FALSE)               // 616263646566

/// </example>
/// <seealso cref='M:XSharp.RT.Functions.AsHexString(XSharp.__Usual)' >AsHexString</seealso>
/// <seealso cref='C2Hex' >C2Hex</seealso>
FUNCTION _C2Hex(cSource AS STRING, lAddSpace as LOGIC) AS STRING
    LOCAL sb AS StringBuilder
    sb := StringBuilder{cSource:Length*2}
    FOREACH c AS CHAR IN cSource
        IF sb:Length > 0 .and. lAddSpace
            sb:Append(' ')
        ENDIF
        var s := String.Format("{0:X2}",(INT) c)
        sb:Append(s)
    NEXT
    RETURN sb:ToString()

/// Convert a string value to a hexadecimal string.
/// <param name="cSource">String to convert</param>
/// <returns>A string with the hex representation of the value</returns>
/// <example>
///  ? C2Hex("abcdef")               // 616263646566

/// </example>
/// <seealso cref='M:XSharp.RT.Functions.AsHexString(XSharp.__Usual)' >AsHexString</seealso>
/// <seealso cref='_C2Hex' >_C2Hex</seealso>
FUNCTION C2Hex(cSource AS STRING) AS STRING
    RETURN _C2Hex(cSource, FALSE)

// helper function to convert bytes to string

INTERNAL FUNCTION _bytes2String(byteArray AS BYTE[]) AS STRING
    LOCAL sb AS StringBuilder
    sb := StringBuilder{}
    FOREACH VAR b IN byteArray
        sb:Append( (CHAR) b)
    NEXT
    RETURN sb:ToString()

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/dw2bin/*" />
FUNCTION DW2Bin(dwValue AS DWORD) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( dwValue ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/hibyte/*" />
FUNCTION HiByte(wValue AS WORD) AS BYTE
    RETURN (BYTE) (wValue >> 8)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/hibyte/*" />
FUNCTION HiByte(wValue AS SHORT) AS BYTE
    RETURN (BYTE) (wValue >> 8)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/hiword/*" />
FUNCTION HiWord(dwValue AS DWORD) AS WORD
    RETURN (WORD) (dwValue >> 16)

// <include file="VoFunctionDocs.xml" path="Runtimefunctions/hiword/*" />
FUNCTION HiWord(dwValue AS LONG) AS WORD
    RETURN (WORD) (dwValue >> 16)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/i2bin/*" />
/// <seealso cref='Bin2I' >Bin2I</seealso>
FUNCTION I2Bin(siValue AS SHORT) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( siValue ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/l2bin/*" />
FUNCTION L2Bin(liValue AS LONG) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( liValue ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/lobyte/*" />
FUNCTION LoByte(wValue AS WORD) AS BYTE
    RETURN (BYTE) _AND(wValue, 0x00FF)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/lobyte/*" />
FUNCTION LoByte(wValue AS SHORT) AS BYTE
    RETURN (BYTE) _AND(wValue, 0x00FF)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/loword/*" />
FUNCTION LoWord(dwValue AS DWORD) AS WORD
    RETURN (WORD) _AND(dwValue , 0xFFFF)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/loword/*" />
FUNCTION LoWord(dwValue AS INT) AS WORD
    RETURN (WORD) _AND(dwValue , 0xFFFF)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/logic2bin/*" />
FUNCTION Logic2Bin(lValue AS LOGIC) AS STRING
    IF lValue
        RETURN e"\x0001"
    ELSE
        RETURN e"\x0000"
    ENDIF

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/ltoc/*" />
FUNCTION LTOC(lValue AS LOGIC) AS STRING
    IF lValue
        RETURN "T"
    ELSE
        RETURN "F"
    ENDIF

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/real42bin/*" />
FUNCTION Real42Bin(r4Value AS REAL4) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( r4Value ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/real82bin/*" />
FUNCTION Real82Bin(r8Value AS REAL8) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( r8Value ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/w2bin/*" />
FUNCTION W2Bin(wValue AS WORD) AS STRING
    LOCAL byteArray := BitConverter.GetBytes( wValue ) AS BYTE[]
    RETURN _bytes2String(byteArray)

/// <include file="VoFunctionDocs.xml" path="Runtimefunctions/val/*" />
FUNCTION _Val(cNumber AS STRING) AS OBJECT
    IF String.IsNullOrEmpty(cNumber)
      RETURN 0
    ENDIF
    cNumber := cNumber:Trim():ToUpper()
    // find non numeric characters in cNumber and trim the field to that length
    VAR pos := 0
    VAR done := FALSE
    VAR hex  := FALSE
    VAR hasdec := FALSE
    VAR hasexp := FALSE
    VAR cDec := (CHAR) RuntimeState.DecimalSep

    IF cDec != '.'
        cNumber := cNumber:Replace('.', cDec) // VO behavior...
        cNumber := cNumber:Replace(cDec, '.')
    ENDIF
    FOREACH VAR c IN cNumber
        SWITCH c
        CASE '0'
        CASE '1'
        CASE '2'
        CASE '3'
        CASE '4'
        CASE '5'
        CASE '6'
        CASE '7'
        CASE '8'
        CASE '9'
        CASE '-'
        CASE '+'
            NOP
        CASE '.'
        CASE ','
            IF c == ',' .AND. cDec != ',' // Don't ask, VO...
                done := TRUE
            ELSEIF hasdec
                done := TRUE
            ELSE
                hasdec := TRUE
            ENDIF
        CASE 'A'
        CASE 'B'
        CASE 'C'
        CASE 'D'
        CASE 'F'
            IF !hex
                done := TRUE
            ENDIF
        CASE 'E'
            // exponentional notation only allowed if decimal separator was there
            IF hasdec
                hasexp := TRUE
            ELSE
                IF !hex
                    done := TRUE
                ENDIF
            ENDIF
        CASE 'L'	// LONG result
        CASE 'U'	// DWORD result
            done := TRUE
        CASE 'X'
            IF pos == 1
                hex := TRUE
            ELSE
                done := TRUE
            ENDIF
        OTHERWISE
            done := TRUE
        END SWITCH
        IF done
            EXIT
        ENDIF
        pos += 1
    NEXT
    IF pos < cNumber:Length
        cNumber := cNumber:Substring(0, pos)
    ENDIF
    IF cNumber:IndexOfAny(<CHAR> {'.'}) > -1
        LOCAL r8Result := 0 AS REAL8
        IF cDec != '.'
            cNumber := cNumber:Replace(cDec, '.')
        ENDIF
        VAR style := NumberStyles.Number
        IF hasexp
            style |= NumberStyles.AllowExponent
        ENDIF
        IF System.Double.TryParse(cNumber, style, ConversionHelpers.usCulture, OUT r8Result)
            RETURN r8Result
        ENDIF
    ELSE
        LOCAL iResult := 0 AS INT64
        LOCAL style AS NumberStyles
        IF hex
            cNumber := cNumber:Substring(2)
            style := NumberStyles.HexNumber
        ELSE
            style := NumberStyles.Integer
        ENDIF
        IF System.Int64.TryParse(cNumber, style, ConversionHelpers.usCulture, OUT iResult)
            IF iResult < Int32.MaxValue .AND. iResult > Int32.MinValue
                RETURN (INT) iResult
            ENDIF
            RETURN iResult
        ENDIF
    ENDIF
    RETURN 0

FUNCTION GetPartialEnumName(cName as STRING, oType as System.Type) AS STRING
    LOCAL aFields   := oType:GetFields() AS FieldInfo[]
    LOCAL aNames    := List<STRING>{} AS List<STRING>
    FOREACH VAR oFld IN aFields
        IF oFld:IsLiteral .AND. oFld:Name:StartsWith(cName, StringComparison.OrdinalIgnoreCase)
            aNames:Add(oFld:Name)
        ENDIF
    NEXT
    IF aNames:Count == 1
        cName := aNames[0]
    ELSE
        cName := ""
    ENDIF
    RETURN cName


[VOEditors] Fix for https://github.com/X-Sharp/XSharpPublic/issues/46 and https://github.com/X-Sharp/XSharpPublic/issues/441 (event code generation problems in the VOWED)

//
// 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.Collections.Generic
USING System.Windows.Forms
USING System.IO
USING Xide

BEGIN NAMESPACE XSharp.VOEditors
CLASS XSharp_VOWindowEditor INHERIT VOWindowEditor
	PROTECT oXProject AS XSharpModel.XProject
	PROTECT aStylesUsed AS List<STRING>		// List of styles used in this window
	CONSTRUCTOR(_oSurface AS Control , _oOptions AS WindowDesignerOptions , _oGrid AS DesignerGrid , _oToolBox AS ToolBox)
		SUPER(_oSurface , _oOptions , _oGrid , _oToolBox)
		aStylesUsed := List<STRING>{}
	RETURN

	METHOD AddStyles(aStyles AS STRING[]) AS VOID
		FOREACH cStyle AS STRING IN aStyles
			IF !aStylesUsed:Contains(cStyle)
				aStylesUsed:Add(cStyle)
			ENDIF
		NEXT
		RETURN

	PROTECTED VIRTUAL METHOD CreateControl(cControl AS STRING, oParent AS Control , cGuid AS STRING) AS DesignWindowItem
		LOCAL oItem AS XSharpDesignWindowItem
		// Use our own DesignWindowItem so we can collect the list of styles used
		oItem := XSharpDesignWindowItem{SELF , VOWindowEditorTemplate.Get(cControl)}
		IF String.IsNullOrEmpty(cGuid)
			cGuid := Guid.NewGuid():ToString()
		ENDIF
		oItem:cGuid := cGuid
		oParent:Controls:Add(oItem:Control)

		IF oItem:IsForm
			SELF:oWindowDesign	:= oItem
			SELF:oWindow		:= oItem:Control
		ENDIF

		IF oItem:Column != NULL
			oParent:Controls:Add(oItem:Column)
		END IF
		IF SELF:ViewMode == ViewMode.Browse
			oItem:lBrowseView := TRUE
			oItem:Control:Hide()
		ELSE
			IF oItem:Column != NULL_OBJECT
				oItem:Column:Hide()
			END IF
		ENDIF
	RETURN oItem

	METHOD Open(cFileName AS STRING) AS LOGIC
		VAR oFile := XSharpModel.XSolution.FindFile(cFileName)
		IF (oFile != NULL_OBJECT)
			oXProject := oFile:Project
		ENDIF
		IF oXProject == NULL
			XFuncs.ErrorBox("Cannot find project for file "+cFileName)
			RETURN FALSE
		ENDIF
		RETURN SUPER:Open(cFileName)

	PROTECTED METHOD GetSaveFileStreams(cVNFrmFileName AS STRING , oVNFrmStream REF FileStream , ;
								oRCStream AS EditorStream , oPrgStream AS EditorStream , oVhStream AS EditorStream , ;
								cVhName REF STRING , lVnfrmOnly AS LOGIC , lRcInSameFolder REF LOGIC) AS LOGIC
		LOCAL cRCFileName AS STRING
		LOCAL cPrgFileName AS STRING
		LOCAL cHeaderFile AS STRING
		LOCAL cFileName AS STRING
		LOCAL cBaseName AS STRING
		LOCAL oFileInfo AS FileInfo
		LOCAL oBaseDir AS DirectoryInfo
		LOCAL cBaseDir AS STRING
		LOCAL cAlternative AS STRING
		LOCAL lSuccess AS LOGIC
		LOCAL lError AS LOGIC
		LOCAL nAt AS INT

		TRY

			oFileInfo	:= FileInfo{cVNFrmFileName}
			oBaseDir	:= oFileInfo:Directory
			cBaseDir	:= oBaseDir:FullName
			cBaseName	:= oFileInfo:Name

			IF cBaseName:ToLower():Endswith(".vnfrm") .OR. cBaseName:ToLower():Endswith(".xsfrm")
				cBaseName	:= System.IO.Path.GetFileNameWithoutExtension(cBaseName)
			ENDIF
			cRCFileName		:= cBaseDir + "\Resources\" + cBaseName + ".rc"
			cAlternative	:= cBaseDir + "\" + cBaseName + ".rc"
			IF !File.Exists(cRCFileName) .AND. File.Exists(cAlternative)
				cRCFileName := cAlternative
				lRcInSameFolder := TRUE
			ENDIF

			cFileName	:= cBaseName
			nAt			:= cFileName:LastIndexOf('.')
			IF nAt != -1 // strip out window name
				cFileName := cFileName:Substring(0 , nAt)
			ENDIF
			cPrgFileName := cBaseDir + "\" + cFileName + ".prg"
			cHeaderFile  := System.IO.Path.ChangeExtension(cPrgFileName, ".vh")
			IF !File.Exists(cHeaderFile)
				cHeaderFile  := System.IO.Path.ChangeExtension(cHeaderFile, ".xh")
			ENDIF
			cAlternative := oBaseDir:Parent:FullName + "\" + cFileName + ".prg"
			IF !File.Exists(cPrgFileName)
				cPrgFileName := cAlternative
				cHeaderFile  := System.IO.Path.ChangeExtension(cPrgFileName, ".vh")
				IF !File.Exists(cHeaderFile)
					cHeaderFile  := System.IO.Path.ChangeExtension(cHeaderFile, ".xh")
				ENDIF
			ENDIF
			cVhName := System.IO.Path.GetFileName(cHeaderFile)

			lError := FALSE
			IF !lVnfrmOnly
				IF ! File.Exists(cRCFileName)
					cRCFileName := System.IO.Path.ChangeExtension(cVNFrmFileName, ".rc")
				ENDIF
				XFuncs.EnsureFileNodeExists(oXProject, cRCFileName)
				IF !File.Exists(cPrgFileName)
					XFuncs.ErrorBox("File was not found : " + cPrgFileName)
					lError := TRUE
				END IF
			END IF

			lSuccess := FALSE
			IF !lError
				IF !lVnfrmOnly
					oRCStream:Load(cRCFileName)
					oPrgStream:Load(cPrgFileName)
					IF File.Exists(cHeaderFile) // else old transporter version
						oVhStream:Load(cHeaderFile)
					ENDIF
					lSuccess := oRCStream:IsValid .AND. oPrgStream:IsValid
				ELSE
					lSuccess := TRUE
				END IF
			END IF
			IF lSuccess .AND. !lError
				lSuccess := FALSE
				oVNFrmStream := File.Open(cVNFrmFileName , FileMode.Create , FileAccess.Write , FileShare.None)
				lSuccess := TRUE
			ENDIF

		CATCH e AS Exception

			XFuncs.WarningBox(e:Message )
			lSuccess := FALSE

		END TRY

		IF !lSuccess
			IF oVNFrmStream != NULL
				oVNFrmStream:Close()
			ENDIF
			IF oRCStream:IsValid
				oRCStream:Close()
			ENDIF
			IF oPrgStream:IsValid
				oPrgStream:Close()
			ENDIF
			IF oVhStream:IsValid
				oVhStream:Close()
			ENDIF
		END IF

	RETURN lSuccess

	VIRTUAL METHOD Save() AS VOID
		SELF:Save(SELF:cDefaultFileName , FALSE)

	VIRTUAL METHOD Save(cVNFrmFileName AS STRING , lBinaryOnly AS LOGIC) AS LOGIC
		LOCAL oPrg , oVh  , oRC AS XSharp_EditorStream
		LOCAL lRcInSameFolder AS LOGIC
		LOCAL lOldTransporter AS LOGIC
		LOCAL oVNFrm AS FileStream
		LOCAL cVhName AS STRING

		IF cVNFrmFileName:ToUpper():Contains("~AUTORECOVER")
			lBinaryOnly := TRUE
		END IF

		SELF:ArrangeColumnsOrder(TRUE)
		SELF:ArrangeControlOrder()

		oPrg := XSharp_EditorStream{}
		oVh := XSharp_EditorStream{}
		oRc := XSharp_EditorStream{}

		oVNFrm := NULL; cVhName := NULL; lRcInSameFolder := FALSE // Grrr
		IF .NOT. SELF:GetSaveFileStreams(cVNFrmFileName , REF oVNFrm , oRC , oPrg , oVh , REF cVhName , lBinaryOnly , REF lRcInSameFolder)
			RETURN FALSE
		ENDIF

		lOldTransporter := .NOT. oVh:IsValid

		SELF:SaveToXml(oVNFrm)

		IF .NOT. lBinaryOnly
			LOCAL oCode AS CodeContents
			oCode := SELF:GetCodeContents()

			SELF:SaveRC(oRC , oCode , cVhName , lOldTransporter , lRcInSameFolder)

			IF oVh:IsValid
				SELF:SaveVh(oVh , oCode)
			END IF

			SELF:SavePrg(oPrg , oCode , lOldTransporter , cVhName)

			SELF:nActionSaved := SELF:nAction
		END IF

	RETURN TRUE

	METHOD SaveRC(oStream AS XSharp_EditorStream , oCode AS CodeContents , cVhName AS STRING , lOldTransporter AS LOGIC , lRcInSameFolder AS LOGIC) AS LOGIC
		LOCAL oGenerator AS CodeGenerator
		oGenerator := CodeGenerator{oStream:Editor}
		oGenerator:BeginCode()

		oGenerator:Clear()
		XFuncs.WriteHeader(oGenerator, "XSharp.FormEditor")
		// in x#, always add the #defines in the .rc header, no need to put them in a .vh anymore
		FOR LOCAL n := 0 UPTO oCode:aDefines:Count - 1
			oGenerator:AddDefine(oCode:aDefines[n] , oCode:aDefineValues[n])
		NEXT
		// Write the styles that are used in Alphabetical order
		aStylesUsed:Sort()
		FOREACH cStyle AS STRING IN SELF:aStylesUsed
			oGenerator:AddDefine(cStyle, "0x"+VODefines.GetDefineValue(cStyle):ToString("X8"))
		NEXT
		oGenerator:AddLine("")
		FOREACH cResource AS STRING IN oCode:aResource
			oGenerator:AddLine(cResource)
		NEXT
		oStream:Save()
	RETURN TRUE

	METHOD SavePrg(oDest AS XSharp_EditorStream , oCode AS CodeContents , lOldTransporter AS LOGIC , cVhName AS STRING) AS LOGIC
		LOCAL aEntity AS List<STRING>
		LOCAL cFormName AS STRING
		LOCAL cPrevName AS STRING

		LOCAL oGenerator AS CodeGenerator
		oGenerator := CodeGenerator{oDest:Editor}
		oGenerator:BeginCode()

		LOCAL ceTab AS STRING
		ceTab := ""

		cFormName := SELF:oWindowDesign:Name
		// needed for renaming a window:
		cPrevName := SELF:oWindowDesign:Name

		// don't delete the header file for now, maybe the .vh file contains defines for other windows in the same prg
		oGenerator:DeleteDefines(oCode:aDefines)
		oGenerator:RemoveDefines(cPrevName)
		oGenerator:AddXSharpDefines(oCode:aDefines , oCode:aDefineValues,TRUE)

		oGenerator:WriteEntity(EntityType._Class , cPrevName , cPrevName , EntityOptions.AddUser , oCode:aClass)
		oGenerator:WriteEntity(EntityType._Constructor , cFormName , cFormName , EntityOptions.None , oCode:aConstructor)

		LOCAL lAccessAssign AS LOGIC
		LOCAL oProp AS DesignProperty

		aEntity := List<STRING>{}

		oProp := SELF:oWindowDesign:GetPropertyByMember("NoAcc")
		lAccessAssign := oProp != NULL .AND. oProp:TextValue:Trim() == "" .AND. oProp:cPage != "_Hidden"
		FOREACH cName AS STRING IN oCode:aAccessAssign

			IF lAccessAssign
				aEntity:Clear()
				aEntity:Add(ceTab + "ACCESS " + cName)
				aEntity:Add(ceTab + ceTab+ "RETURN SELF:FieldGet( #" + cName + " )")
				oGenerator:WriteEntity(EntityType._Access , cName , cFormName , EntityOptions.None , aEntity)

				aEntity:Clear()
				aEntity:Add(ceTab + "ASSIGN " + cName + "( uValue )")
				aEntity:Add(ceTab + ceTab+"SELF:FieldPut( #" + cName + " , uValue )")
				oGenerator:WriteEntity(EntityType._Assign , cName , cFormName , EntityOptions.None , aEntity)

			ELSE
				oGenerator:DeleteEntity(EntityType._Access , cName , cFormName)
				oGenerator:DeleteEntity(EntityType._Assign , cName , cFormName)
			END IF
		NEXT

		oGenerator:WriteEndClass(cFormName)
		oGenerator:EndCode()
	RETURN oDest:Save()

	METHOD SaveVh(oStream AS XSharp_EditorStream , oCode AS CodeContents) AS LOGIC
		LOCAL oGenerator AS CodeGenerator
		oGenerator := CodeGenerator{oStream:Editor}
		oGenerator:BeginCode()

		oGenerator:DeleteDefines(oCode:aDefines)

		oStream:Save()
	RETURN TRUE

	// The following is the original vulcan code which generates callbacks in the code
	// Always generates the code directly in a VS editor file
	// Of course needs adjustment to work with x#'s project system

	ACCESS XFile AS XSharpModel.XFile
		LOCAL cPrgFileName AS STRING
		cPrgFileName := Funcs.GetModuleFilenameFromBinary(SELF:cDefaultFileName) + ".prg"

	RETURN XSharpModel.XSolution.FindFile(cPrgFileName)

	PROTECTED METHOD WriteCallback(oDesign AS DesignWindowItem , cName AS STRING) AS VOID
		LOCAL oProject AS XSharpModel.XProject
		LOCAL oFile AS XSharpModel.XFile
		LOCAL oType AS XSharpModel.XSourceTypeSymbol
		//LOCAL oEditor AS VulcanEditor
		LOCAL aLines AS List<STRING>
		LOCAL cClass AS STRING
		LOCAL lOpen AS LOGIC

		cClass := SELF:oWindowDesign:Name

		oFile := SELF:XFile
		IF oFile == NULL
			RETURN
		END IF
		oProject := oFile:Project

		IF cName == "Click"
			cName := oDesign:Name
			aLines := List<STRING>{}
			aLines:Add("METHOD " + cName + "( )")
			aLines:Add("")
			aLines:Add("RETURN NIL")
		ELSE
			aLines := GetTemplate(cName)
		END IF
		IF aLines == NULL
			XFuncs.WarningBox("Could not find code template for event: " + cName)
			RETURN
		END IF
		// Find Method for this class
	   VAR rootNs := oFile:Project:ProjectNode:RootNameSpace
      VAR usings := List<STRING>{}
      usings:Add(rootNs)
		oType := oProject:Lookup(cClass,usings)
		IF cName:ToUpper() == "CLASSDECLARATION"
	        IF (oType != NULL_OBJECT)
				oType:OpenEditor()
	            RETURN
	        ENDIF

        ELSEIF oType != NULL_OBJECT
			FOREACH VAR oMember IN oType:XMembers
				IF string.Compare(oMember:Name, cName, TRUE) == 0
					oMember:OpenEditor()
					RETURN
				ENDIF
			NEXT
        ENDIF
		lOpen := FALSE
		VAR source := oProject:ProjectNode:DocumentGetText(oFile:FullPath, REF lOpen)

		IF .NOT. lOpen
			oProject:ProjectNode:OpenElement(oFile:FullPath, 1,1)
		END IF
		source := oProject:ProjectNode:DocumentGetText(oFile:FullPath, REF lOpen)
		IF .NOT. lOpen .OR. source == NULL
			RETURN
		END IF

		VAR oEditor := XSharp_EditorStream{}
		oEditor:Load(oFile:FullPath)
      local nLine as LONG
      if oType != NULL
           // Apparently oType:Range:EndLine returns the end line minus one, so we have to add one
		   nLine := oType:Range:EndLine +1
      else
         nLine := aLines:Count-1
      ENDIF
		FOR LOCAL nTemplateLine :=  aLines:Count - 1 AS INT DOWNTO 0
            LOCAL cLine := aLines[nTemplateLine] AS STRING
			LOCAL cNew := VOWindowEditor.SubStituteTpl(cLine, cClass, oWindowDesign:cInitParams) AS STRING
			oFile:Project:ProjectNode:DocumentInsertLine(oFile:FullPath, nLine, cNew)
		NEXT
		oFile:Project:ProjectNode:OpenElement(oFile:FullPath, nLine,1)
		XSharpModel.XSolution.WalkFile(oFile:FullPath)
	RETURN

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.Collections.Generic
USING System.Windows.Forms
USING System.IO
USING Xide

BEGIN NAMESPACE XSharp.VOEditors
CLASS XSharp_VOWindowEditor INHERIT VOWindowEditor
	PROTECT oXProject AS XSharpModel.XProject
	PROTECT aStylesUsed AS List<STRING>		// List of styles used in this window
	CONSTRUCTOR(_oSurface AS Control , _oOptions AS WindowDesignerOptions , _oGrid AS DesignerGrid , _oToolBox AS ToolBox)
		SUPER(_oSurface , _oOptions , _oGrid , _oToolBox)
		aStylesUsed := List<STRING>{}
	RETURN

	METHOD AddStyles(aStyles AS STRING[]) AS VOID
		FOREACH cStyle AS STRING IN aStyles
			IF !aStylesUsed:Contains(cStyle)
				aStylesUsed:Add(cStyle)
			ENDIF
		NEXT
		RETURN

	PROTECTED VIRTUAL METHOD CreateControl(cControl AS STRING, oParent AS Control , cGuid AS STRING) AS DesignWindowItem
		LOCAL oItem AS XSharpDesignWindowItem
		// Use our own DesignWindowItem so we can collect the list of styles used
		oItem := XSharpDesignWindowItem{SELF , VOWindowEditorTemplate.Get(cControl)}
		IF String.IsNullOrEmpty(cGuid)
			cGuid := Guid.NewGuid():ToString()
		ENDIF
		oItem:cGuid := cGuid
		oParent:Controls:Add(oItem:Control)

		IF oItem:IsForm
			SELF:oWindowDesign	:= oItem
			SELF:oWindow		:= oItem:Control
		ENDIF

		IF oItem:Column != NULL
			oParent:Controls:Add(oItem:Column)
		END IF
		IF SELF:ViewMode == ViewMode.Browse
			oItem:lBrowseView := TRUE
			oItem:Control:Hide()
		ELSE
			IF oItem:Column != NULL_OBJECT
				oItem:Column:Hide()
			END IF
		ENDIF
	RETURN oItem

	METHOD Open(cFileName AS STRING) AS LOGIC
		VAR oFile := XSharpModel.XSolution.FindFile(cFileName)
		IF (oFile != NULL_OBJECT)
			oXProject := oFile:Project
		ENDIF
		IF oXProject == NULL
			XFuncs.ErrorBox("Cannot find project for file "+cFileName)
			RETURN FALSE
		ENDIF
		RETURN SUPER:Open(cFileName)

	PROTECTED METHOD GetSaveFileStreams(cVNFrmFileName AS STRING , oVNFrmStream REF FileStream , ;
								oRCStream AS EditorStream , oPrgStream AS EditorStream , oVhStream AS EditorStream , ;
								cVhName REF STRING , lVnfrmOnly AS LOGIC , lRcInSameFolder REF LOGIC) AS LOGIC
		LOCAL cRCFileName AS STRING
		LOCAL cPrgFileName AS STRING
		LOCAL cHeaderFile AS STRING
		LOCAL cFileName AS STRING
		LOCAL cBaseName AS STRING
		LOCAL oFileInfo AS FileInfo
		LOCAL oBaseDir AS DirectoryInfo
		LOCAL cBaseDir AS STRING
		LOCAL cAlternative AS STRING
		LOCAL lSuccess AS LOGIC
		LOCAL lError AS LOGIC
		LOCAL nAt AS INT

		TRY

			oFileInfo	:= FileInfo{cVNFrmFileName}
			oBaseDir	:= oFileInfo:Directory
			cBaseDir	:= oBaseDir:FullName
			cBaseName	:= oFileInfo:Name

			IF cBaseName:ToLower():Endswith(".vnfrm") .OR. cBaseName:ToLower():Endswith(".xsfrm")
				cBaseName	:= System.IO.Path.GetFileNameWithoutExtension(cBaseName)
			ENDIF
			cRCFileName		:= cBaseDir + "\Resources\" + cBaseName + ".rc"
			cAlternative	:= cBaseDir + "\" + cBaseName + ".rc"
			IF !File.Exists(cRCFileName) .AND. File.Exists(cAlternative)
				cRCFileName := cAlternative
				lRcInSameFolder := TRUE
			ENDIF

			cFileName	:= cBaseName
			nAt			:= cFileName:LastIndexOf('.')
			IF nAt != -1 // strip out window name
				cFileName := cFileName:Substring(0 , nAt)
			ENDIF
			cPrgFileName := cBaseDir + "\" + cFileName + ".prg"
			cHeaderFile  := System.IO.Path.ChangeExtension(cPrgFileName, ".vh")
			IF !File.Exists(cHeaderFile)
				cHeaderFile  := System.IO.Path.ChangeExtension(cHeaderFile, ".xh")
			ENDIF
			cAlternative := oBaseDir:Parent:FullName + "\" + cFileName + ".prg"
			IF !File.Exists(cPrgFileName)
				cPrgFileName := cAlternative
				cHeaderFile  := System.IO.Path.ChangeExtension(cPrgFileName, ".vh")
				IF !File.Exists(cHeaderFile)
					cHeaderFile  := System.IO.Path.ChangeExtension(cHeaderFile, ".xh")
				ENDIF
			ENDIF
			cVhName := System.IO.Path.GetFileName(cHeaderFile)

			lError := FALSE
			IF !lVnfrmOnly
				IF ! File.Exists(cRCFileName)
					cRCFileName := System.IO.Path.ChangeExtension(cVNFrmFileName, ".rc")
				ENDIF
				XFuncs.EnsureFileNodeExists(oXProject, cRCFileName)
				IF !File.Exists(cPrgFileName)
					XFuncs.ErrorBox("File was not found : " + cPrgFileName)
					lError := TRUE
				END IF
			END IF

			lSuccess := FALSE
			IF !lError
				IF !lVnfrmOnly
					oRCStream:Load(cRCFileName)
					oPrgStream:Load(cPrgFileName)
					IF File.Exists(cHeaderFile) // else old transporter version
						oVhStream:Load(cHeaderFile)
					ENDIF
					lSuccess := oRCStream:IsValid .AND. oPrgStream:IsValid
				ELSE
					lSuccess := TRUE
				END IF
			END IF
			IF lSuccess .AND. !lError
				lSuccess := FALSE
				oVNFrmStream := File.Open(cVNFrmFileName , FileMode.Create , FileAccess.Write , FileShare.None)
				lSuccess := TRUE
			ENDIF

		CATCH e AS Exception

			XFuncs.WarningBox(e:Message )
			lSuccess := FALSE

		END TRY

		IF !lSuccess
			IF oVNFrmStream != NULL
				oVNFrmStream:Close()
			ENDIF
			IF oRCStream:IsValid
				oRCStream:Close()
			ENDIF
			IF oPrgStream:IsValid
				oPrgStream:Close()
			ENDIF
			IF oVhStream:IsValid
				oVhStream:Close()
			ENDIF
		END IF

	RETURN lSuccess

	VIRTUAL METHOD Save() AS VOID
		SELF:Save(SELF:cDefaultFileName , FALSE)

	VIRTUAL METHOD Save(cVNFrmFileName AS STRING , lBinaryOnly AS LOGIC) AS LOGIC
		LOCAL oPrg , oVh  , oRC AS XSharp_EditorStream
		LOCAL lRcInSameFolder AS LOGIC
		LOCAL lOldTransporter AS LOGIC
		LOCAL oVNFrm AS FileStream
		LOCAL cVhName AS STRING

		IF cVNFrmFileName:ToUpper():Contains("~AUTORECOVER")
			lBinaryOnly := TRUE
		END IF

		SELF:ArrangeColumnsOrder(TRUE)
		SELF:ArrangeControlOrder()

		oPrg := XSharp_EditorStream{}
		oVh := XSharp_EditorStream{}
		oRc := XSharp_EditorStream{}

		oVNFrm := NULL; cVhName := NULL; lRcInSameFolder := FALSE // Grrr
		IF .NOT. SELF:GetSaveFileStreams(cVNFrmFileName , REF oVNFrm , oRC , oPrg , oVh , REF cVhName , lBinaryOnly , REF lRcInSameFolder)
			RETURN FALSE
		ENDIF

		lOldTransporter := .NOT. oVh:IsValid

		SELF:SaveToXml(oVNFrm)

		IF .NOT. lBinaryOnly
			LOCAL oCode AS CodeContents
			oCode := SELF:GetCodeContents()

			SELF:SaveRC(oRC , oCode , cVhName , lOldTransporter , lRcInSameFolder)

			IF oVh:IsValid
				SELF:SaveVh(oVh , oCode)
			END IF

			SELF:SavePrg(oPrg , oCode , lOldTransporter , cVhName)

			SELF:nActionSaved := SELF:nAction
		END IF

	RETURN TRUE

	METHOD SaveRC(oStream AS XSharp_EditorStream , oCode AS CodeContents , cVhName AS STRING , lOldTransporter AS LOGIC , lRcInSameFolder AS LOGIC) AS LOGIC
		LOCAL oGenerator AS CodeGenerator
		oGenerator := CodeGenerator{oStream:Editor}
		oGenerator:BeginCode()

		oGenerator:Clear()
		XFuncs.WriteHeader(oGenerator, "XSharp.FormEditor")
		// in x#, always add the #defines in the .rc header, no need to put them in a .vh anymore
		FOR LOCAL n := 0 UPTO oCode:aDefines:Count - 1
			oGenerator:AddDefine(oCode:aDefines[n] , oCode:aDefineValues[n])
		NEXT
		// Write the styles that are used in Alphabetical order
		aStylesUsed:Sort()
		FOREACH cStyle AS STRING IN SELF:aStylesUsed
			oGenerator:AddDefine(cStyle, "0x"+VODefines.GetDefineValue(cStyle):ToString("X8"))
		NEXT
		oGenerator:AddLine("")
		FOREACH cResource AS STRING IN oCode:aResource
			oGenerator:AddLine(cResource)
		NEXT
		oStream:Save()
	RETURN TRUE

	METHOD SavePrg(oDest AS XSharp_EditorStream , oCode AS CodeContents , lOldTransporter AS LOGIC , cVhName AS STRING) AS LOGIC
		LOCAL aEntity AS List<STRING>
		LOCAL cFormName AS STRING
		LOCAL cPrevName AS STRING

		LOCAL oGenerator AS CodeGenerator
		oGenerator := CodeGenerator{oDest:Editor}
		oGenerator:BeginCode()

		LOCAL ceTab AS STRING
		ceTab := ""

		cFormName := SELF:oWindowDesign:Name
		// needed for renaming a window:
		cPrevName := SELF:oWindowDesign:Name

		// don't delete the header file for now, maybe the .vh file contains defines for other windows in the same prg
		oGenerator:DeleteDefines(oCode:aDefines)
		oGenerator:RemoveDefines(cPrevName)
		oGenerator:AddXSharpDefines(oCode:aDefines , oCode:aDefineValues,TRUE)

		oGenerator:WriteEntity(EntityType._Class , cPrevName , cPrevName , EntityOptions.AddUser , oCode:aClass)
		oGenerator:WriteEntity(EntityType._Constructor , cFormName , cFormName , EntityOptions.None , oCode:aConstructor)

		LOCAL lAccessAssign AS LOGIC
		LOCAL oProp AS DesignProperty

		aEntity := List<STRING>{}

		oProp := SELF:oWindowDesign:GetPropertyByMember("NoAcc")
		lAccessAssign := oProp != NULL .AND. oProp:TextValue:Trim() == "" .AND. oProp:cPage != "_Hidden"
		FOREACH cName AS STRING IN oCode:aAccessAssign

			IF lAccessAssign
				aEntity:Clear()
				aEntity:Add(ceTab + "ACCESS " + cName)
				aEntity:Add(ceTab + ceTab+ "RETURN SELF:FieldGet( #" + cName + " )")
				oGenerator:WriteEntity(EntityType._Access , cName , cFormName , EntityOptions.None , aEntity)

				aEntity:Clear()
				aEntity:Add(ceTab + "ASSIGN " + cName + "( uValue )")
				aEntity:Add(ceTab + ceTab+"SELF:FieldPut( #" + cName + " , uValue )")
				oGenerator:WriteEntity(EntityType._Assign , cName , cFormName , EntityOptions.None , aEntity)

			ELSE
				oGenerator:DeleteEntity(EntityType._Access , cName , cFormName)
				oGenerator:DeleteEntity(EntityType._Assign , cName , cFormName)
			END IF
		NEXT

		oGenerator:WriteEndClass(cFormName)
		oGenerator:EndCode()
	RETURN oDest:Save()

	METHOD SaveVh(oStream AS XSharp_EditorStream , oCode AS CodeContents) AS LOGIC
		LOCAL oGenerator AS CodeGenerator
		oGenerator := CodeGenerator{oStream:Editor}
		oGenerator:BeginCode()

		oGenerator:DeleteDefines(oCode:aDefines)

		oStream:Save()
	RETURN TRUE

	// The following is the original vulcan code which generates callbacks in the code
	// Always generates the code directly in a VS editor file
	// Of course needs adjustment to work with x#'s project system

	ACCESS XFile AS XSharpModel.XFile
		LOCAL cPrgFileName AS STRING
		cPrgFileName := Funcs.GetModuleFilenameFromBinary(SELF:cDefaultFileName) + ".prg"

	RETURN XSharpModel.XSolution.FindFile(cPrgFileName)

	PROTECTED METHOD WriteCallback(oDesign AS DesignWindowItem , cName AS STRING) AS VOID
		LOCAL oProject AS XSharpModel.XProject
		LOCAL oFile AS XSharpModel.XFile
		LOCAL oType AS XSharpModel.XSourceTypeSymbol
		//LOCAL oEditor AS VulcanEditor
		LOCAL aLines AS List<STRING>
		LOCAL cClass AS STRING
		LOCAL lOpen AS LOGIC

		cClass := SELF:oWindowDesign:Name

		oFile := SELF:XFile
		IF oFile == NULL
			RETURN
		END IF
		oProject := oFile:Project

		IF cName == "Click"
			cName := oDesign:Name
			aLines := List<STRING>{}
			aLines:Add("METHOD " + cName + "( )")
			aLines:Add("")
			aLines:Add("RETURN NIL")
		ELSE
			aLines := GetTemplate(cName)
		END IF
		IF aLines == NULL
			XFuncs.WarningBox("Could not find code template for event: " + cName)
			RETURN
		END IF
		// Find Method for this class
	   VAR rootNs := oFile:Project:ProjectNode:RootNameSpace
      VAR usings := List<STRING>{}
      usings:Add(rootNs)
		oType := oProject:Lookup(cClass,usings)
		IF cName:ToUpper() == "CLASSDECLARATION"
	        IF (oType != NULL_OBJECT)
				oType:OpenEditor()
	            RETURN
	        ENDIF

        ELSEIF oType != NULL_OBJECT
			FOREACH VAR oMember IN oType:XMembers
				IF string.Compare(oMember:Name, cName, TRUE) == 0
					oMember:OpenEditor()
					RETURN
				ENDIF
			NEXT
        ENDIF
		lOpen := FALSE
		VAR source := oProject:ProjectNode:DocumentGetText(oFile:FullPath, REF lOpen)

		IF .NOT. lOpen
			oProject:ProjectNode:OpenElement(oFile:FullPath, 1,1)
		END IF
		source := oProject:ProjectNode:DocumentGetText(oFile:FullPath, REF lOpen)
		IF .NOT. lOpen .OR. source == NULL
			RETURN
		END IF

		VAR oEditor := XSharp_EditorStream{}
		oEditor:Load(oFile:FullPath)
      local nLine as LONG
      if oType != NULL
		   nLine := oType:Range:EndLine -1
      else
         nLine := aLines:Count-1
      ENDIF
		aLines:Reverse()
		FOREACH VAR cLine IN aLines
			VAR cNew := VOWindowEditor.SubStituteTpl(cLine, cClass, oWindowDesign:cInitParams)
			oFile:Project:ProjectNode:DocumentInsertLine(oFile:FullPath, nLine, cNew)
		NEXT
		oFile:Project:ProjectNode:OpenElement(oFile:FullPath, nLine,1)
		XSharpModel.XSolution.WalkFile(oFile:FullPath)
	RETURN

END CLASS

END NAMESPACE


clean up

clean up

-- simulate classes as propositions first

prop Functor :: (* ~> *) ~> * ~> * where
  Lfunctor :: Functor [] a
  Tfunctor :: Functor Tree a
  Pairfunctor :: Functor ((,) a) b

prop Monad' :: (* ~> *) ~> * ~> * where
  M :: Functor a b -> Monad' a b

data Tree a = Node a | Fork (Tree a) (Tree a)

data Test :: * where
  Test :: forall (a :: * ~> *) (t :: *) . Monad' a t => a t -> Test

-- simulate classes as propositions first

-- issue 87:
--isFunctor :: (* ~> *) ~> (* ~> *)
--{isFunctor []} = []

isFunctor :: (* ~> *) ~> Prop
{isFunctor []} = Success

prop Functor :: (* ~> *) ~> * ~> * where
  Lfunctor :: Functor [] a
  Tfunctor :: Functor Tree a
  Pairfunctor :: Functor ((,) a) b
--  Pairfunctor :: Functor c a -> Functor c b -> Functor c (a,b)

prop Monad' :: (* ~> *) ~> * ~> * where
  M :: Functor a b -> Monad' a b

data Tree a = Node a | Fork (Tree a) (Tree a)

data Test :: * where
  Test :: forall (a :: * ~> *) (t :: *) . Monad' a t => a t -> Test


Revert Stupid change

Revert Stupid change

init procedure my_init()
  memvar gtk
  public gtk := hbgi_import("Gtk")
  return

function Main()
  local win, button
  memvar gtk

  gtk:init(hb_aParams())

  win := gtk:Window:new(gtk:WindowType:POPUP)
  win:connect('delete-event', {|| gtk:main_quit() })
  button := gtk:Button:new_with_label(E"Click me\nRight now")
  button:connect('clicked', {|| gtk:main_quit() })
  win:add(button)

  win:show_all()
  gtk:main()
  win := NIL
  button := NIL
  return 0

/*
  Show use Webkit in Harbour using library HBGI
  If you press  mouse right button, show menu for navigate.
  2016 Rafa Carmona
*/

#define TRUE  .T.
#define FALSE .F.

MEMVAR gtk, gtkSource, gLib, WebKit

INIT PROCEDURE my_init()

   PUBLIC gtk := hbgi_import( "Gtk" )
   PUBLIC WebKit := hbgi_import( "WebKit" )

   RETURN

FUNCTION Main()

   LOCAL win, button, box, scroll, web, statusbar, contextid

   gtk:init( hb_AParams() )

   /* Create window */
   win := gtk:Window:new( gtk:WindowType:TOPLEVEL )

   /* Add Title at the window */
   win:set_title( "Harbour HBGI with WebKit" )

   /* Center Position window */
   win:set_position( gtk:WindowPosition:CENTER )

   /* Size by Default*/
   win:set_default_size( 800, 600 )

   /* Connect event delete-event for destroy window */
   win:connect( 'delete-event', {|| gtk:main_quit() } )

   /* Create Box vertical  */
   box := gtk:vbox:new( .F., 0 )

   /* Box add at Window */
   win:add( box )

   /* Create scroll*/
   scroll := gtk:scrolledWindow:New( NIL, NIL )

   /* Border 10*/
   scroll:set_border_width( 10 )

   /* Show ALWAYS scrollbar*/
   scroll:set_policy( gtk:PolicyType:AUTOMATIC, Gtk:PolicyType:ALWAYS )

   /* Add scroll at box*/
   box:add( scroll )

   /* Create WEBKIT! VERY EASY!! */
   web := Webkit:WebView:New()

   /* Put the web app into the webview */
   web:load_uri( "https://harbour.github.io/" )

   /* Add WebKit a scroll */
   scroll:add( web )

   /* Simple button , connect event clicked, exit app */
   button := gtk:button:new_with_label( "Exit" )
   button:connect( 'clicked', {|| gtk:main_quit() } )
   box:pack_start( button, .F., .F., 0 )

   /* Status Bar*/
   statusbar := gtk:statusbar:new()
   box:pack_end( statusbar, FALSE, TRUE, 0 )

   /*Push message in StatusBar*/
   contextid := statusbar:get_context_id( "Statusbar example" )
   statusbar:push( contextid, "WebKit example running with HBGI (c)2016 Rafa Carmona" )

   /* Show ALL widgets */
   win:show_all()

   /* Here, loop main events of GTK*/
   gtk:Main()
   win := NIL
   button := NIL
   Web := NIL
   scroll := NIL

   RETURN 0