diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 691612bcbd..79c2b2424c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,51 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-08 11:30 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + + contrib/hbqt/hbqt_hbqtmymainwindow.cpp + * contrib/hbqt/hbqt_slots.cpp + * contrib/hbqt/Makefile + * MyMainWindow() class moved to separate source file. + * Deleted commented debug calls. + * Code formatting. + ! Fix to call mutex initialization on MyMainWindows creation, + to guarantee its present. Anyhow current method is still not + safe. + % Cleaned some casts. + ; TOFIX: mutex initialization in MyMainWindow. + ; TOFIX: MyMainWindow is a leakable resource and it _is_ + leaked from hbxbp. + + * contrib/hbxbp/xbpsle.prg + * contrib/hbxbp/xbplistbox.prg + * contrib/hbxbp/xbprtf.prg + * contrib/hbxbp/xbpbrowse.prg + * contrib/hbxbp/xbpwindow.prg + * contrib/hbxbp/xbpcombobox.prg + * contrib/hbxbp/xbppushbutton.prg + * contrib/hbxbp/xbp.ch + * contrib/hbxbp/xbptreeview.prg + * contrib/hbxbp/xbpdialog.prg + * contrib/hbxbp/xbpspinbutton.prg + * contrib/hbxbp/xbpgeneric.prg + * contrib/hbide/hbide.prg + * :createFromQtPtr() -> hbCreateFromQtPtr() + ! Fixed few non-Xbase++ public functions to hold the + hbxbp_ prefix in their names. + It probably needs further cleanup. + % Highly optimized ConvertAFact(), now goes by the + name hbxbp_ConvertAFactFromXBP(). Only one conversion + was used in code, so I dropped the other, but it can be + readded similarly if ever needed. + ! Mutex destroy moved to the end of EXIT PROC, anyway + it's still not safe and should be solved differently. + (TOFIX) + ; TOFIX: hbxbp_SetEventFilter() is passed to several function, + but this function has no return value. + + * contrib/hbcairo/core.c + * Minor. + 2009-12-07 23:43 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/hbqt_hbqtdbfmodel.cpp * contrib/hbqt/hbqt_slots.cpp diff --git a/harbour/contrib/hbcairo/core.c b/harbour/contrib/hbcairo/core.c index 9d7bd3a5a6..53a3d1fc5f 100644 --- a/harbour/contrib/hbcairo/core.c +++ b/harbour/contrib/hbcairo/core.c @@ -118,10 +118,9 @@ HB_FUNC( CAIRO_DESTROY ) { cairo_destroy( *ppCairo ); *ppCairo = NULL; - return; } - - hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + else + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } @@ -186,9 +185,9 @@ HB_FUNC( CAIRO_SURFACE_DESTROY ) { cairo_surface_destroy( *ppSurface ); *ppSurface = NULL; - return; } - hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + else + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } @@ -253,17 +252,17 @@ HB_FUNC( CAIRO_PATH_DESTROY ) { cairo_path_destroy( *ppPath ); *ppPath = NULL; - return; } - hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + else + hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } /* ============ cairo_path_t * iterator support ============ */ -/* +/* * NOTE: Path iterator functions are is not cairo functions. - * This is only a way to pass path data to .prg level + * This is only a way to pass path data to .prg level */ typedef struct @@ -433,7 +432,7 @@ HB_FUNC( CAIRO_PATH_ITERATOR_SET_POINTS ) #endif ulLen = hb_arrayLen( pArray ); - if( pIterator->iPos < pPath->num_data && pIterator->iPos != -1 && + if( pIterator->iPos < pPath->num_data && pIterator->iPos != -1 && ( ULONG ) pPath->data[ pIterator->iPos ].header.length == ulLen + 1 ) { PHB_ITEM pItem; @@ -448,7 +447,7 @@ HB_FUNC( CAIRO_PATH_ITERATOR_SET_POINTS ) pData[ i ].point.x = hb_arrayGetND( pItem, 1 ); pData[ i ].point.y = hb_arrayGetND( pItem, 2 ); } - else + else { hb_retl( 0 ); return; diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 67653d7460..c734b57ef1 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -1541,16 +1541,16 @@ METHOD HbIde:findReplace( cUi ) // ::qFindDlg:setWindowFlags( Qt_Sheet ) // - ::oFind := XbpComboBox():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboFindWhat" ) ) - ::oRepl := XbpComboBox():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboReplaceWith" ) ) + ::oFind := XbpComboBox():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboFindWhat" ) ) + ::oRepl := XbpComboBox():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboReplaceWith" ) ) - ::oPBFind := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonFind" ) ) + ::oPBFind := XbpPushButton():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonFind" ) ) ::oPBFind:activate := {|| ::qCurEdit:find( QLineEdit():configure( ::oFind:oWidget:lineEdit() ):text() ) } - ::oPBRepl := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonReplace" ) ) + ::oPBRepl := XbpPushButton():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonReplace" ) ) ::oPBRepl:activate := {|t| t := QLineEdit():configure( ::oRepl:oWidget:lineEdit() ):text() } - ::oPBClose := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonClose" ) ) + ::oPBClose := XbpPushButton():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonClose" ) ) ::oPBClose:activate := {|| ::qFindDlg:hide() } ENDIF ENDIF @@ -1648,13 +1648,13 @@ METHOD HbIde:fetchProjectProperties() ::aPrpObjs := { qPrjType, oPrjTtl, oPrjLoc, oPrjWrk, oPrjDst, oPrjOut, oPrjLau, oPrjLEx, oPrjInc, oPrjSrc, oPrjMta, oPrjHbp, oPrjCmp } - oPBCn := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( pPrpDlg, "buttonCn" ) ) + oPBCn := XbpPushButton():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( pPrpDlg, "buttonCn" ) ) oPBCn:activate := {|| qPrpDlg:close() } - oPBSv := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( pPrpDlg, "buttonSave" ) ) + oPBSv := XbpPushButton():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( pPrpDlg, "buttonSave" ) ) oPBSv:activate := {|| ::saveProject() } - oPBOk := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( pPrpDlg, "buttonSaveExit" ) ) + oPBOk := XbpPushButton():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( pPrpDlg, "buttonSaveExit" ) ) oPBOk:activate := {|| ::saveProject(), qPrpDlg:close() } - oPBSelect := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( pPrpDlg, "buttonSelect" ) ) + oPBSelect := XbpPushButton():new():hbCreateFromQtPtr( , , , , , , Qt_findChild( pPrpDlg, "buttonSelect" ) ) oPBSelect:activate := {|| ::addSourcesToProject() } oTabWidget := QTabWidget():configure( Qt_FindChild( pPrpDlg, "tabWidget" ) ) diff --git a/harbour/contrib/hbqt/Makefile b/harbour/contrib/hbqt/Makefile index 5c040569d9..12051ca701 100644 --- a/harbour/contrib/hbqt/Makefile +++ b/harbour/contrib/hbqt/Makefile @@ -26,6 +26,7 @@ moc_slots.cpp : $(TOP)$(ROOT)contrib/hbqt/hbqt_slots.h CPP_SOURCES += \ hbqt_hbqtdbfmodel.cpp \ hbqt_hbqtmydrawingarea.cpp \ + hbqt_hbqtmymainwindow.cpp \ hbqt_hbqtsyntaxhighlighter.cpp \ hbqt_hbqttableview.cpp \ diff --git a/harbour/contrib/hbqt/hbqt_hbqtmymainwindow.cpp b/harbour/contrib/hbqt/hbqt_hbqtmymainwindow.cpp new file mode 100644 index 0000000000..0589c86cf5 --- /dev/null +++ b/harbour/contrib/hbqt/hbqt_hbqtmymainwindow.cpp @@ -0,0 +1,314 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Marcos Antonio Gambeta + * + * Copyright 2009 Pritpal Bedi + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ + +#include "hbapi.h" +#include "hbapiitm.h" +#include "hbthread.h" +#include "hbvm.h" + +#include "hbqt.h" + +#if QT_VERSION >= 0x040500 + +#include "hbqt_slots.h" + +static PHB_ITEM s_mutex = NULL; + +MyMainWindow::MyMainWindow( PHB_ITEM pBlock, int iThreadID ) +{ + Qt::WindowFlags flags = Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint | + Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint | + Qt::CustomizeWindowHint | Qt::WindowTitleHint | + Qt::Window; + setWindowFlags( flags ); + setFocusPolicy( Qt::StrongFocus ); + setAttribute( Qt::WA_DeleteOnClose ); + //setAttribute( Qt::WA_NoSystemBackground ); + //setAttribute( Qt::WA_PaintOnScreen ); + //setMouseTracking( true ); + + block = pBlock; + threadID = iThreadID; +} + +MyMainWindow::~MyMainWindow( void ) +{ +#if defined( __HB_DEBUG__ ) +hbqt_debug( " MyMainWindow::~MyMainWindow 0" ); +#endif + if( block ) + { + hb_itemRelease( block ); + block = NULL; + } +#if defined( __HB_DEBUG__ ) +hbqt_debug( " MyMainWindow::~MyMainWindow 1" ); +#endif +} + +void MyMainWindow::paintEvent( QPaintEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Paint ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + hb_threadMutexUnlock( s_mutex ); +} + +bool MyMainWindow::event( QEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + bool bRet = QWidget::event( event ); + hb_threadMutexUnlock( s_mutex ); + return bRet; +} + +void MyMainWindow::focusInEvent( QFocusEvent *event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::FocusIn ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::focusInEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::focusOutEvent( QFocusEvent *event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::FocusOut ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::focusOutEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::keyPressEvent( QKeyEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::KeyPress ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::keyPressEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::mouseDoubleClickEvent( QMouseEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::MouseButtonDblClick ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::mouseDoubleClickEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::mouseMoveEvent( QMouseEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::MouseMove ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::mouseMoveEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::mousePressEvent( QMouseEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::MouseButtonPress ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::mousePressEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::mouseReleaseEvent( QMouseEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::MouseButtonRelease ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::mouseReleaseEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::wheelEvent( QWheelEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Wheel ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::wheelEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::resizeEvent( QResizeEvent * event ) +{ + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Resize ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + QWidget::resizeEvent( event ); + hb_threadMutexUnlock( s_mutex ); +} + +void MyMainWindow::closeEvent( QCloseEvent * event ) +{ +#if defined( __HB_DEBUG__ ) +hbqt_debug( " close event(%i)", threadID ); +#endif + hb_threadMutexLock( s_mutex ); + if( hb_vmRequestReenter() ) + { + PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Close ); + PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); + hb_vmEvalBlockV( block, 2, p0, p1 ); + hb_itemRelease( p0 ); + hb_itemRelease( p1 ); + hb_vmRequestRestore(); + } + hb_threadMutexUnlock( s_mutex ); +} + +HB_FUNC( QT_MYMAINWINDOW ) +{ + if( s_mutex == NULL ) + s_mutex = hb_threadMutexCreate(); + + hb_retptr( ( MyMainWindow * ) new MyMainWindow( hb_itemNew( hb_param( 1, HB_IT_BLOCK ) ), hb_parni( 2 ) ) ); +} + +HB_FUNC( QT_MYMAINWINDOW_DESTROY ) +{ + hbqt_par_MyMainWindow( 1 )->~MyMainWindow(); +} + +HB_FUNC( QT_MUTEXCREATE ) +{ + if( s_mutex == NULL ) + s_mutex = hb_threadMutexCreate(); +} + +HB_FUNC( QT_MUTEXDESTROY ) +{ + if( s_mutex != NULL ) + { + hb_itemRelease( s_mutex ); + s_mutex = NULL; + } +} + +#endif diff --git a/harbour/contrib/hbqt/hbqt_slots.cpp b/harbour/contrib/hbqt/hbqt_slots.cpp index f328a84e7f..871e9996cf 100644 --- a/harbour/contrib/hbqt/hbqt_slots.cpp +++ b/harbour/contrib/hbqt/hbqt_slots.cpp @@ -57,7 +57,6 @@ #include "hbvm.h" #include "hbapiitm.h" #include "hbstack.h" -#include "hbthread.h" #include "hbqt.h" @@ -75,8 +74,6 @@ #include #include -static PHB_ITEM s_mutex = NULL; - /*----------------------------------------------------------------------*/ typedef struct @@ -123,6 +120,21 @@ static Slots * qt_getEventSlots( void ) return HB_GETQTEVENTSLOTS()->slot; } +HB_FUNC( QT_SETEVENTFILTER ) +{ + qt_setEventFilter(); +} + +HB_FUNC( QT_SETEVENTSLOTS ) +{ + qt_setEventSlots(); +} + +HB_FUNC( QT_QEVENTFILTER ) +{ + hb_retptr( qt_getEventFilter() ); +} + /*----------------------------------------------------------------------*/ Slots::Slots( QObject* parent ) : QObject( parent ) @@ -1123,6 +1135,7 @@ HB_FUNC( QT_SLOTS_DESTROY ) Events::Events( QObject * parent ) : QObject( parent ) { } + Events::~Events() { listBlock.clear(); @@ -1131,14 +1144,9 @@ Events::~Events() bool Events::eventFilter( QObject * object, QEvent * event ) { QEvent::Type eventtype = event->type(); -#if defined( __HB_DEBUG__ ) -//hbqt_debug( "0 Events::eventFilter = %i", ( int ) eventtype ); -#endif + if( ( int ) eventtype == 0 ) { -#if defined( __HB_DEBUG__ ) -//hbqt_debug( "x Events::eventFilter = 0" ); -#endif return false; } @@ -1147,352 +1155,87 @@ bool Events::eventFilter( QObject * object, QEvent * event ) int found = object->property( prop ).toInt(); if( found == 0 ) { -#if defined( __HB_DEBUG__ ) -//hbqt_debug( "f Events::eventFilter = %s %i", " found=0", ( int ) eventtype ); -#endif return false; } - //bool ret = false; bool ret = true; + if( found <= listBlock.size() && listObj.at( found - 1 ) == object && hb_vmRequestReenter() ) { PHB_ITEM pObject = hb_itemPutPtr( NULL, object ); PHB_ITEM pEvent = hb_itemPutPtr( NULL, event ); -#if defined( __HB_DEBUG__ ) -//hbqt_debug( "0 Events::eventFilter = %i", ( int ) eventtype ); -#endif ret = hb_itemGetL( hb_vmEvalBlockV( ( PHB_ITEM ) listBlock.at( found - 1 ), 2, pObject, pEvent ) ); -#if defined( __HB_DEBUG__ ) -//hbqt_debug( "1 Events::eventFilter = %s", ret ? " yes" : " no" ); -#endif hb_itemRelease( pObject ); hb_itemRelease( pEvent ); hb_vmRequestRestore(); if( eventtype == QEvent::Close ) - { event->ignore(); - } } -#if defined( __HB_DEBUG__ ) -//hbqt_debug( "1 Events::eventFilter = %i", ( int ) eventtype ); -#endif + return ret; } -HB_FUNC( QT_SETEVENTFILTER ) -{ - qt_setEventFilter(); -} -HB_FUNC( QT_SETEVENTSLOTS ) -{ - qt_setEventSlots(); -} HB_FUNC( QT_EVENTS_DESTROY ) { qt_getEventFilter()->~Events(); } -HB_FUNC( QT_QEVENTFILTER ) -{ - hb_retptr( qt_getEventFilter() ); -} - HB_FUNC( QT_CONNECT_EVENT ) { QObject * object = ( QObject* ) hbqt_gcpointer( 1 ); /* get sender */ - if( object == NULL ) + if( object ) { - hb_retl( HB_FALSE ); - return; + int type = hb_parni( 2 ); + PHB_ITEM codeblock = hb_itemNew( hb_param( 3, HB_IT_BLOCK | HB_IT_BYREF ) ); + Events * s_e = qt_getEventFilter(); + + char prop[ 20 ]; + hb_snprintf( prop, sizeof( prop ), "%s%i%s", "P", type, "P" ); /* Make it a unique identifier */ + + s_e->listBlock << codeblock; + s_e->listObj << object; + + object->setProperty( prop, ( int ) s_e->listBlock.size() ); + + hb_retl( HB_TRUE ); } - - int type = hb_parni( 2 ); - PHB_ITEM codeblock = hb_itemNew( hb_param( 3, HB_IT_BLOCK | HB_IT_BYREF ) ); - Events * s_e = qt_getEventFilter(); - - char prop[ 20 ]; - hb_snprintf( prop, sizeof( prop ), "%s%i%s", "P", type, "P" ); /* Make it a unique identifier */ - - s_e->listBlock << codeblock; - s_e->listObj << object; - - object->setProperty( prop, ( int ) s_e->listBlock.size() ); - - hb_retl( HB_TRUE ); + else + hb_retl( HB_FALSE ); } HB_FUNC( QT_DISCONNECT_EVENT ) { + HB_BOOL bRet = HB_FALSE; QObject * object = ( QObject* ) hbqt_gcpointer( 1 ); - if( object == NULL ) + if( object ) { - hb_retl( HB_FALSE ); - return; - } + int type = hb_parni( 2 ); + Events * s_e = qt_getEventFilter(); - int type = hb_parni( 2 ); - bool bRet = false; - Events * s_e = qt_getEventFilter(); + char prop[ 10 ]; + hb_snprintf( prop, sizeof( prop ), "%s%i%s", "P", type, "P" ); /* Make it a unique identifier */ - char prop[ 10 ]; - hb_snprintf( prop, sizeof( prop ), "%s%i%s", "P", type, "P" ); /* Make it a unique identifier */ - - int i = object->property( prop ).toInt(); - if( i > 0 && i <= s_e->listBlock.size() ) - { - hb_itemRelease( s_e->listBlock.at( i - 1 ) ); - s_e->listBlock[ i - 1 ] = NULL; - s_e->listObj[ i - 1 ] = NULL; - object->setProperty( prop, QVariant() ); - bRet = true; + int i = object->property( prop ).toInt(); + if( i > 0 && i <= s_e->listBlock.size() ) + { + hb_itemRelease( s_e->listBlock.at( i - 1 ) ); + s_e->listBlock[ i - 1 ] = NULL; + s_e->listObj[ i - 1 ] = NULL; + object->setProperty( prop, QVariant() ); + bRet = HB_TRUE; #if defined( __HB_DEBUG__ ) hbqt_debug( " QT_DISCONNECT_EVENT: %i", type ); #endif + } } + hb_retl( bRet ); } -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ - -MyMainWindow::MyMainWindow( PHB_ITEM pBlock, int iThreadID ) -{ - Qt::WindowFlags flags = Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint | - Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint | - Qt::CustomizeWindowHint | Qt::WindowTitleHint | - Qt::Window; - setWindowFlags( flags ); - setFocusPolicy( Qt::StrongFocus ); - setAttribute( Qt::WA_DeleteOnClose ); - //setAttribute( Qt::WA_NoSystemBackground ); - //setAttribute( Qt::WA_PaintOnScreen ); - //setMouseTracking( true ); - - block = pBlock; - threadID = iThreadID; -} -MyMainWindow::~MyMainWindow( void ) -{ -#if defined( __HB_DEBUG__ ) -hbqt_debug( " MyMainWindow::~MyMainWindow 0" ); -#endif - if( block ) - { - hb_itemRelease( block ); - block = NULL; - } -#if defined( __HB_DEBUG__ ) -hbqt_debug( " MyMainWindow::~MyMainWindow 1" ); -#endif -} -void MyMainWindow::paintEvent( QPaintEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Paint ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - hb_threadMutexUnlock( s_mutex ); -} -bool MyMainWindow::event( QEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - bool bRet = QWidget::event( event ); - hb_threadMutexUnlock( s_mutex ); - return bRet; -} -void MyMainWindow::focusInEvent( QFocusEvent *event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::FocusIn ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::focusInEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::focusOutEvent( QFocusEvent *event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::FocusOut ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::focusOutEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::keyPressEvent( QKeyEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::KeyPress ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::keyPressEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::mouseDoubleClickEvent( QMouseEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::MouseButtonDblClick ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::mouseDoubleClickEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::mouseMoveEvent( QMouseEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::MouseMove ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::mouseMoveEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::mousePressEvent( QMouseEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::MouseButtonPress ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::mousePressEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::mouseReleaseEvent( QMouseEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::MouseButtonRelease ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::mouseReleaseEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::wheelEvent( QWheelEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Wheel ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::wheelEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::resizeEvent( QResizeEvent * event ) -{ - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Resize ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - QWidget::resizeEvent( event ); - hb_threadMutexUnlock( s_mutex ); -} -void MyMainWindow::closeEvent( QCloseEvent * event ) -{ -#if defined( __HB_DEBUG__ ) -hbqt_debug( " close event(%i)", threadID ); -#endif - hb_threadMutexLock( s_mutex ); - if( hb_vmRequestReenter() ) - { - PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Close ); - PHB_ITEM p1 = hb_itemPutPtr( NULL, event ); - hb_vmEvalBlockV( block, 2, p0, p1 ); - hb_itemRelease( p0 ); - hb_itemRelease( p1 ); - hb_vmRequestRestore(); - } - hb_threadMutexUnlock( s_mutex ); -} - -HB_FUNC( QT_MYMAINWINDOW ) -{ - PHB_ITEM bBlock = hb_itemNew( ( PHB_ITEM ) hb_param( 1, HB_IT_BLOCK ) ); - hb_retptr( ( MyMainWindow * ) new MyMainWindow( bBlock, hb_parni( 2 ) ) ); -} - -HB_FUNC( QT_MYMAINWINDOW_DESTROY ) -{ - hbqt_par_MyMainWindow( 1 )->~MyMainWindow(); -} - -HB_FUNC( QT_MUTEXCREATE ) -{ - if( s_mutex == NULL ) - { - s_mutex = hb_threadMutexCreate(); - } -} - -HB_FUNC( QT_MUTEXDESTROY ) -{ - if( s_mutex != NULL ) - { - hb_itemRelease( s_mutex ); - s_mutex = NULL; - } -} - /*----------------------------------------------------------------------*/ #endif diff --git a/harbour/contrib/hbxbp/xbp.ch b/harbour/contrib/hbxbp/xbp.ch index feabf2c488..de7afb76cc 100644 --- a/harbour/contrib/hbxbp/xbp.ch +++ b/harbour/contrib/hbxbp/xbp.ch @@ -17,9 +17,6 @@ #define HBXBP_EVENT_HANDLED 0 #define HBXBP_EVENT_UNHANDLED 1 -#define XBTOQT_FROM_XB 1 -#define XBTOQT_FROM_QT 2 - /*----------------------------------------------------------------------*/ #define XBP_AUTOSIZE -1 diff --git a/harbour/contrib/hbxbp/xbpbrowse.prg b/harbour/contrib/hbxbp/xbpbrowse.prg index fb808406dc..b92fd62dbe 100644 --- a/harbour/contrib/hbxbp/xbpbrowse.prg +++ b/harbour/contrib/hbxbp/xbpbrowse.prg @@ -1116,7 +1116,7 @@ METHOD fetchColumnInfo( nInfo, nArea, nRow, nCol ) CLASS XbpBrowse IF hb_isBlock( oCol:colorBlock ) aColor := eval( oCol:colorBlock, ::cellValueA( nRow, nCol ) ) IF hb_isArray( aColor ) .and. hb_isNumeric( aColor[ 1 ] ) - RETURN ConvertAFact( "Color", XBTOQT_FROM_XB, aColor[ 1 ] ) + RETURN hbxbp_ConvertAFactFromXBP( "Color", aColor[ 1 ] ) ELSE RETURN oCol:dFgColor ENDIF @@ -1128,7 +1128,7 @@ METHOD fetchColumnInfo( nInfo, nArea, nRow, nCol ) CLASS XbpBrowse IF hb_isBlock( oCol:colorBlock ) aColor := eval( oCol:colorBlock, ::cellValueA( nRow, nCol ) ) IF hb_isArray( aColor ) .and. hb_isNumeric( aColor[ 2 ] ) - RETURN ConvertAFact( "Color", XBTOQT_FROM_XB, aColor[ 2 ] ) + RETURN hbxbp_ConvertAFactFromXBP( "Color", aColor[ 2 ] ) ELSE RETURN oCol:dBgColor ENDIF @@ -4212,16 +4212,16 @@ METHOD configure() CLASS XbpColumn ::cHeading := ::aPresParams[ n,2 ] ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_HA_FGCLR } ) ) > 0 - ::hFgColor := ConvertAFact( "Color", XBTOQT_FROM_XB, ::aPresParams[ n,2 ] ) + ::hFgColor := hbxbp_ConvertAFactFromXBP( "Color", ::aPresParams[ n,2 ] ) ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_HA_BGCLR } ) ) > 0 - ::hBgColor := ConvertAFact( "Color", XBTOQT_FROM_XB, ::aPresParams[ n,2 ] ) + ::hBgColor := hbxbp_ConvertAFactFromXBP( "Color", ::aPresParams[ n,2 ] ) ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_HA_HEIGHT } ) ) > 0 ::hHeight := ::aPresParams[ n,2 ] ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_HA_ALIGNMENT } ) ) > 0 - ::hAlignment := ConvertAFact( "Alignment", XBTOQT_FROM_XB, ::aPresParams[ n,2 ] ) + ::hAlignment := hbxbp_ConvertAFactFromXBP( "Alignment", ::aPresParams[ n,2 ] ) ::hAlignment += Qt_AlignVCenter ENDIF @@ -4233,10 +4233,10 @@ METHOD configure() CLASS XbpColumn ::dAlignment += Qt_AlignVCenter ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_DA_FGCLR } ) ) > 0 - ::dFgColor := ConvertAFact( "Color", XBTOQT_FROM_XB, ::aPresParams[ n,2 ] ) + ::dFgColor := hbxbp_ConvertAFactFromXBP( "Color", ::aPresParams[ n,2 ] ) ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_DA_BGCLR } ) ) > 0 - ::dBgColor := ConvertAFact( "Color", XBTOQT_FROM_XB, ::aPresParams[ n,2 ] ) + ::dBgColor := hbxbp_ConvertAFactFromXBP( "Color", ::aPresParams[ n,2 ] ) ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_DA_ROWHEIGHT } ) ) > 0 ::dHeight := ::aPresParams[ n,2 ] @@ -4250,16 +4250,16 @@ METHOD configure() CLASS XbpColumn ::cFooting := ::aPresParams[ n,2 ] ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_FA_FGCLR } ) ) > 0 - ::fFgColor := ConvertAFact( "Color", XBTOQT_FROM_XB, ::aPresParams[ n,2 ] ) + ::fFgColor := hbxbp_ConvertAFactFromXBP( "Color", ::aPresParams[ n,2 ] ) ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_FA_BGCLR } ) ) > 0 - ::fBgColor := ConvertAFact( "Color", XBTOQT_FROM_XB, ::aPresParams[ n,2 ] ) + ::fBgColor := hbxbp_ConvertAFactFromXBP( "Color", ::aPresParams[ n,2 ] ) ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_FA_HEIGHT } ) ) > 0 ::fHeight := ::aPresParams[ n,2 ] ENDIF IF ( n := ascan( ::aPresParams, {|e_| e_[ 1 ] == XBP_PP_COL_FA_ALIGNMENT } ) ) > 0 - ::fAlignment := ConvertAFact( "Alignment", XBTOQT_FROM_XB, ::aPresParams[ n,2 ] ) + ::fAlignment := hbxbp_ConvertAFactFromXBP( "Alignment", ::aPresParams[ n,2 ] ) ::fAlignment += Qt_AlignVCenter ENDIF @@ -4414,4 +4414,3 @@ METHOD XbpCellGroup:itemSelected() RETURN Self /*----------------------------------------------------------------------*/ - diff --git a/harbour/contrib/hbxbp/xbpcombobox.prg b/harbour/contrib/hbxbp/xbpcombobox.prg index 5dc222fd47..00928ecc5a 100644 --- a/harbour/contrib/hbxbp/xbpcombobox.prg +++ b/harbour/contrib/hbxbp/xbpcombobox.prg @@ -81,7 +81,7 @@ CLASS XbpComboBox INHERIT XbpWindow METHOD new() METHOD create() - METHOD createFromQtPtr() + METHOD hbCreateFromQtPtr() METHOD configure() VIRTUAL METHOD destroy() METHOD exeBlock() @@ -163,7 +163,7 @@ METHOD XbpComboBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /*----------------------------------------------------------------------*/ -METHOD XbpComboBox:createFromQtPtr( oParent, oOwner, aPos, aSize, aPresParams, lVisible, pQtObject ) +METHOD XbpComboBox:hbCreateFromQtPtr( oParent, oOwner, aPos, aSize, aPresParams, lVisible, pQtObject ) ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) diff --git a/harbour/contrib/hbxbp/xbpdialog.prg b/harbour/contrib/hbxbp/xbpdialog.prg index 2ca5093c0f..f9774a6fa1 100644 --- a/harbour/contrib/hbxbp/xbpdialog.prg +++ b/harbour/contrib/hbxbp/xbpdialog.prg @@ -153,14 +153,14 @@ METHOD XbpDialog:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) QT_SetEventFilter() /* Thread specific event buffer */ - InitializeEventBuffer() + hbxbp_InitializeEventBuffer() /* Install Event Loop per Dialog Basis */ ::oEventLoop := QEventLoop():new( ::pWidget ) - SetEventLoop( ::oEventLoop ) + hbxbp_SetEventLoop( ::oEventLoop ) /* Instal Event Filter */ - ::oWidget:installEventFilter( SetEventFilter() ) + ::oWidget:installEventFilter( hbxbp_SetEventFilter() ) ::connectWindowEvents() // diff --git a/harbour/contrib/hbxbp/xbpgeneric.prg b/harbour/contrib/hbxbp/xbpgeneric.prg index 1b04eb1ef7..edd6903e1b 100644 --- a/harbour/contrib/hbxbp/xbpgeneric.prg +++ b/harbour/contrib/hbxbp/xbpgeneric.prg @@ -95,7 +95,7 @@ THREAD STATIC t_oEventLoop /*----------------------------------------------------------------------*/ -INIT PROCEDURE Qt_Start() +INIT PROCEDURE hbxbp_Start() Qt_MutexCreate() @@ -107,9 +107,7 @@ INIT PROCEDURE Qt_Start() /*----------------------------------------------------------------------*/ -EXIT PROCEDURE Qt_End() - - Qt_MutexDestroy() +EXIT PROCEDURE hbxbp_End() t_oDummy := NIL t_oAppWindow := NIL @@ -122,13 +120,16 @@ EXIT PROCEDURE Qt_End() #if 0 s_oApp:oWidget:pPtr := 0 #endif + + Qt_MutexDestroy() + RETURN /*----------------------------------------------------------------------*/ /* * Will be called from XbpDialog() | XbpCRT() */ -FUNCTION InitializeEventBuffer() +FUNCTION hbxbp_InitializeEventBuffer() IF empty( t_events ) t_events := array( EVENT_BUFFER ) @@ -139,7 +140,7 @@ FUNCTION InitializeEventBuffer() /*----------------------------------------------------------------------*/ -FUNCTION ClearEventBuffer() +FUNCTION hbxbp_ClearEventBuffer() IF !empty( t_events ) aeval( t_events, {|e,i| e := e, t_events[ i ] := NIL } ) @@ -150,13 +151,13 @@ FUNCTION ClearEventBuffer() /*----------------------------------------------------------------------*/ -FUNCTION SetEventFilter() +FUNCTION hbxbp_SetEventFilter() RETURN QT_QEventFilter() /*----------------------------------------------------------------------*/ -FUNCTION SetEventLoop( oELoop ) +FUNCTION hbxbp_SetEventLoop( oELoop ) t_oEventLoop := oELoop @@ -174,7 +175,7 @@ FUNCTION PostAppEvent( nEvent, mp1, mp2, oXbp ) /*----------------------------------------------------------------------*/ /* - * Internal to the XbpParts , Must NOT be called from Application Code + * Internal to the XbpParts, must NOT be called from application code */ FUNCTION SetAppEvent( nEvent, mp1, mp2, oXbp ) @@ -301,67 +302,71 @@ FUNCTION GraMakeRGBColor( aRGB ) RETURN nRGB -/*----------------------------------------------------------------------*/ +FUNCTION hbxbp_ConvertAFactFromXBP( cMode, xValue ) -FUNCTION ConvertAFact( cMode, nFrom, xValue ) - LOCAL n, a_:= {} + SWITCH Upper( cMode ) + CASE "COLOR" + SWITCH xValue + CASE GRA_CLR_WHITE ; RETURN Qt_white + CASE GRA_CLR_BLACK ; RETURN Qt_black + CASE GRA_CLR_BLUE ; RETURN Qt_blue + CASE GRA_CLR_RED ; RETURN Qt_red + CASE GRA_CLR_PINK ; RETURN Qt_magenta + CASE GRA_CLR_GREEN ; RETURN Qt_green + CASE GRA_CLR_CYAN ; RETURN Qt_cyan + CASE GRA_CLR_YELLOW ; RETURN Qt_yellow + CASE GRA_CLR_DARKGRAY ; RETURN Qt_darkGray + CASE GRA_CLR_DARKBLUE ; RETURN Qt_darkBlue + CASE GRA_CLR_DARKRED ; RETURN Qt_darkRed + CASE GRA_CLR_DARKPINK ; RETURN Qt_darkMagenta + CASE GRA_CLR_DARKGREEN ; RETURN Qt_darkGreen + CASE GRA_CLR_DARKCYAN ; RETURN Qt_darkCyan + CASE GRA_CLR_BROWN ; RETURN Qt_darkYellow + CASE GRA_CLR_PALEGRAY ; RETURN Qt_lightGray + ENDSWITCH + EXIT - cMode := upper( cMode ) + CASE "RTFVERTICALALIGN" + SWITCH xValue + CASE 0; RETURN QTextCharFormat_AlignNormal + CASE 1; RETURN QTextCharFormat_AlignSuperScript + CASE -1; RETURN QTextCharFormat_AlignSubScript + ENDSWITCH + EXIT - DO CASE - CASE cMode == "COLOR" - aadd( a_, { GRA_CLR_WHITE , Qt_white } ) - aadd( a_, { GRA_CLR_BLACK , Qt_black } ) - aadd( a_, { GRA_CLR_BLUE , Qt_blue } ) - aadd( a_, { GRA_CLR_RED , Qt_red } ) - aadd( a_, { GRA_CLR_PINK , Qt_magenta } ) - aadd( a_, { GRA_CLR_GREEN , Qt_green } ) - aadd( a_, { GRA_CLR_CYAN , Qt_cyan } ) - aadd( a_, { GRA_CLR_YELLOW , Qt_yellow } ) - aadd( a_, { GRA_CLR_DARKGRAY , Qt_darkGray } ) - aadd( a_, { GRA_CLR_DARKBLUE , Qt_darkBlue } ) - aadd( a_, { GRA_CLR_DARKRED , Qt_darkRed } ) - aadd( a_, { GRA_CLR_DARKPINK , Qt_darkMagenta } ) - aadd( a_, { GRA_CLR_DARKGREEN , Qt_darkGreen } ) - aadd( a_, { GRA_CLR_DARKCYAN , Qt_darkCyan } ) - aadd( a_, { GRA_CLR_BROWN , Qt_darkYellow } ) - aadd( a_, { GRA_CLR_PALEGRAY , Qt_lightGray } ) + CASE "RTFSELALIGNMENT" + SWITCH xValue + CASE XBPRTF_ALIGN_LEFT ; RETURN Qt_AlignLeft + CASE XBPRTF_ALIGN_RIGHT ; RETURN Qt_AlignRight + CASE XBPRTF_ALIGN_CENTER; RETURN Qt_AlignCenter + ENDSWITCH + EXIT - CASE cMode == "RTFVERTICALALIGN" - aadd( a_, { 0, QTextCharFormat_AlignNormal } ) - aadd( a_, { 1, QTextCharFormat_AlignSuperScript } ) - aadd( a_, { -1, QTextCharFormat_AlignSubScript } ) + CASE "ALIGNMENT" + SWITCH xValue + CASE XBPALIGN_TOP ; RETURN Qt_AlignTop + CASE XBPALIGN_BOTTOM ; RETURN Qt_AlignBottom + CASE XBPALIGN_LEFT ; RETURN Qt_AlignLeft + CASE XBPALIGN_RIGHT ; RETURN Qt_AlignRight + CASE XBPALIGN_VCENTER; RETURN Qt_AlignVCenter + CASE XBPALIGN_HCENTER; RETURN Qt_AlignHCenter + ENDSWITCH + EXIT - CASE cMode == "RTFSELALIGNMENT" - aadd( a_, { XBPRTF_ALIGN_LEFT , Qt_AlignLeft } ) - aadd( a_, { XBPRTF_ALIGN_RIGHT , Qt_AlignRight } ) - aadd( a_, { XBPRTF_ALIGN_CENTER, Qt_AlignCenter } ) + CASE "BRWNAVIGATE" + SWITCH xValue + CASE xbeK_DOWN ; RETURN QAbstractItemView_MoveDown + CASE xbeK_UP ; RETURN QAbstractItemView_MoveUp + CASE xbeK_RIGHT; RETURN QAbstractItemView_MoveRight + CASE xbeK_LEFT ; RETURN QAbstractItemView_MoveLeft + CASE xbeK_HOME ; RETURN QAbstractItemView_MoveHome + CASE xbeK_END ; RETURN QAbstractItemView_MoveEnd + CASE xbeK_PGUP ; RETURN QAbstractItemView_MovePageUp + CASE xbeK_PGDN ; RETURN QAbstractItemView_MovePageDown + ENDSWITCH + EXIT - CASE cMode == "ALIGNMENT" - aadd( a_, { XBPALIGN_TOP , Qt_AlignTop } ) - aadd( a_, { XBPALIGN_BOTTOM , Qt_AlignBottom } ) - aadd( a_, { XBPALIGN_LEFT , Qt_AlignLeft } ) - aadd( a_, { XBPALIGN_RIGHT , Qt_AlignRight } ) - aadd( a_, { XBPALIGN_VCENTER, Qt_AlignVCenter } ) - aadd( a_, { XBPALIGN_HCENTER, Qt_AlignHCenter } ) - - CASE cMode == "BRWNAVIGATE" - aadd( a_, { xbeK_DOWN , QAbstractItemView_MoveDown } ) - aadd( a_, { xbeK_UP , QAbstractItemView_MoveUp } ) - aadd( a_, { xbeK_RIGHT, QAbstractItemView_MoveRight } ) - aadd( a_, { xbeK_LEFT , QAbstractItemView_MoveLeft } ) - aadd( a_, { xbeK_HOME , QAbstractItemView_MoveHome } ) - aadd( a_, { xbeK_END , QAbstractItemView_MoveEnd } ) - aadd( a_, { xbeK_PGUP , QAbstractItemView_MovePageUp } ) - aadd( a_, { xbeK_PGDN , QAbstractItemView_MovePageDown } ) - - CASE cMode == "SOMEOTHER" - - ENDCASE - - IF ( n := ascan( a_, {|e_| e_[ nFrom ] == xValue } ) ) > 0 - RETURN a_[ n, IF( nFrom == 2, 1, 2 ) ] - ENDIF + ENDSWITCH RETURN xValue diff --git a/harbour/contrib/hbxbp/xbplistbox.prg b/harbour/contrib/hbxbp/xbplistbox.prg index a980dc2314..5dd1d0ec7f 100644 --- a/harbour/contrib/hbxbp/xbplistbox.prg +++ b/harbour/contrib/hbxbp/xbplistbox.prg @@ -178,7 +178,7 @@ METHOD XbpListBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oWidget:setMouseTracking( .t. ) /* Window Events */ - ::oWidget:installEventFilter( SetEventFilter() ) + ::oWidget:installEventFilter( hbxbp_SetEventFilter() ) ::connectEvent( ::pWidget, QEvent_ContextMenu, {|o,e| ::grabEvent( QEvent_ContextMenu, e, o ) } ) /* Signal-slots */ diff --git a/harbour/contrib/hbxbp/xbppushbutton.prg b/harbour/contrib/hbxbp/xbppushbutton.prg index abceb3e4b4..e98575f0ba 100644 --- a/harbour/contrib/hbxbp/xbppushbutton.prg +++ b/harbour/contrib/hbxbp/xbppushbutton.prg @@ -88,7 +88,7 @@ CLASS XbpPushButton INHERIT XbpWindow METHOD new() METHOD create() - METHOD createFromQtPtr() + METHOD hbCreateFromQtPtr() METHOD configure() METHOD destroy() @@ -136,7 +136,7 @@ METHOD XbpPushButton:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible /*----------------------------------------------------------------------*/ -METHOD XbpPushButton:createFromQtPtr( oParent, oOwner, aPos, aSize, aPresParams, lVisible, pQtObject ) +METHOD XbpPushButton:hbCreateFromQtPtr( oParent, oOwner, aPos, aSize, aPresParams, lVisible, pQtObject ) ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) diff --git a/harbour/contrib/hbxbp/xbprtf.prg b/harbour/contrib/hbxbp/xbprtf.prg index b5836aa6ef..51bbc91c0a 100644 --- a/harbour/contrib/hbxbp/xbprtf.prg +++ b/harbour/contrib/hbxbp/xbprtf.prg @@ -406,7 +406,7 @@ METHOD XbpRtf:selAlignment( ... ) // XBPRTF_ALIGN_LEFT IF len( aP ) >= 1 .and. hb_isNumeric( aP[ 1 ] ) oTBFormat := QTextBlockFormat():configure( ::oCurCursor:blockFormat() ) xRet := oTBFormat:alignment() - oTBFormat:setAlignment( ConvertAFact( "RTFSELALIGNMENT", XBTOQT_FROM_XB, aP[ 1 ] ) ) + oTBFormat:setAlignment( hbxbp_ConvertAFactFromXBP( "RTFSELALIGNMENT", aP[ 1 ] ) ) ::oCurCursor:setBlockFormat( QT_PTROF( oTBFormat ) ) ENDIF RETURN xRet @@ -450,7 +450,7 @@ METHOD XbpRtf:selCharOffset( ... ) // 0 IF ::oTextCharFormat:isValid() nAlign := IF( aP[ 1 ] < 0, -1, IF( aP[ 1 ] > 0, 1, 0 ) ) xRet := ::oTextCharFormat:verticalAlignment() - ::oTextCharFormat:setVerticalAlignment( ConvertAFact( "RtfVerticalAlign", XBTOQT_FROM_XB, nAlign ) ) + ::oTextCharFormat:setVerticalAlignment( hbxbp_ConvertAFactFromXBP( "RtfVerticalAlign", nAlign ) ) ::oCurCursor:setCharFormat( QT_PTROF( ::oTextCharFormat ) ) ENDIF ENDIF @@ -467,7 +467,7 @@ METHOD XbpRtf:selColor( ... ) ::oTextCharFormat:pPtr := ::oCurCursor:charFormat() IF ::oTextCharFormat:isValid() xRet := ::oTextCharFormat:foreground() - nColor := ConvertAFact( "COLOR", XBTOQT_FROM_XB, aP[ 1 ] ) + nColor := hbxbp_ConvertAFactFromXBP( "COLOR", aP[ 1 ] ) oColor := QColor():new( nColor ) oBrush := QBrush():new( "QColor", QT_PTROF( oColor ) ) ::oTextCharFormat:setForeground( QT_PTROF( oBrush ) ) diff --git a/harbour/contrib/hbxbp/xbpsle.prg b/harbour/contrib/hbxbp/xbpsle.prg index 4adbf8fc04..ce2bd58b07 100644 --- a/harbour/contrib/hbxbp/xbpsle.prg +++ b/harbour/contrib/hbxbp/xbpsle.prg @@ -146,7 +146,7 @@ METHOD XbpSLE:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oWidget:setMaxLength( ::bufferLength ) #if 0 - QT_QObject_InstallEventFilter( ::pWidget, SetEventFilter() ) + QT_QObject_InstallEventFilter( ::pWidget, hbxbp_SetEventFilter() ) ::connectEvent( ::pWidget, QEvent_FocusIn , {|o,e| ::exeBlock( 7, e, o ) } ) ::connectEvent( ::pWidget, QEvent_FocusOut, {|o,e| ::exeBlock( 8, e, o ) } ) diff --git a/harbour/contrib/hbxbp/xbpspinbutton.prg b/harbour/contrib/hbxbp/xbpspinbutton.prg index eb0975b9a7..a5a4c69127 100644 --- a/harbour/contrib/hbxbp/xbpspinbutton.prg +++ b/harbour/contrib/hbxbp/xbpspinbutton.prg @@ -154,7 +154,7 @@ METHOD XbpSpinButton:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ::oWidget:setAlignment( es_[ ::align ] ) #if 0 //////////////////////////////////// - QT_QObject_InstallEventFilter( ::pWidget, SetEventFilter() ) + QT_QObject_InstallEventFilter( ::pWidget, hbxbp_SetEventFilter() ) HBXBP_DEBUG( "XbpSpinButton:create 2" ) ::connectEvent( ::pWidget, QEvent_FocusIn , {|o,e| ::exeBlock( 7, e, o ) } ) ::connectEvent( ::pWidget, QEvent_FocusOut, {|o,e| ::exeBlock( 8, e, o ) } ) diff --git a/harbour/contrib/hbxbp/xbptreeview.prg b/harbour/contrib/hbxbp/xbptreeview.prg index 2431193861..72bf08e3b1 100644 --- a/harbour/contrib/hbxbp/xbptreeview.prg +++ b/harbour/contrib/hbxbp/xbptreeview.prg @@ -168,7 +168,7 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oRootItem:oWidget := oW /* Window Events */ - ::oWidget:installEventFilter( SetEventFilter() ) + ::oWidget:installEventFilter( hbxbp_SetEventFilter() ) ::connectEvent( ::pWidget, QEvent_ContextMenu, {|o,e| ::grabEvent( QEvent_ContextMenu, e, o ) } ) //::connect( ::pWidget, "currentItemChanged(QTWItem)" , {|o,p1,p2| ::exeBlock( 1, p1, p2, o ) } ) diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index c71dc7c758..73b782ad28 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -143,7 +143,7 @@ EXPORTED: /* LIFE CYCLE */ METHOD init() METHOD create() - METHOD createFromQtPtr() VIRTUAL + METHOD hbCreateFromQtPtr() VIRTUAL METHOD configure() METHOD destroy() @@ -414,7 +414,7 @@ METHOD XbpWindow:connectEvent( pWidget, nEvent, bBlock ) METHOD XbpWindow:connectWindowEvents() - //::oWidget:installEventFilter( SetEventFilter() ) + //::oWidget:installEventFilter( hbxbp_SetEventFilter() ) ::connectEvent( ::pWidget, QEvent_MouseMove , {|o,e| ::grabEvent( QEvent_MouseMove , e, o ) } ) ::connectEvent( ::pWidget, QEvent_MouseButtonPress , {|o,e| ::grabEvent( QEvent_MouseButtonPress , e, o ) } ) @@ -739,7 +739,7 @@ METHOD XbpWindow:destroy() //HBXBP_DEBUG( hb_threadId(),"Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ), memory( 1001 ), hbqt_getMemUsed() ) IF cXbp == "XBPDIALOG" - SetEventLoop( NIL ) + hbxbp_SetEventLoop( NIL ) ::oEventLoop:exit( 0 ) ::oEventLoop:pPtr := 0 SetAppWindow( XbpObject():new() ) @@ -752,7 +752,7 @@ METHOD XbpWindow:destroy() aeval( ::aEConnections, {|e_,i| Qt_DisConnect_Event( e_[ 1 ], e_[ 2 ] ), ; ::aEConnections[ i,1 ] := NIL, ::aEConnections[ i,2 ] := NIL, ::aEConnections[ i ] := NIL } ) ::aEConnections := {} - ::oWidget:removeEventFilter( SetEventFilter() ) + ::oWidget:removeEventFilter( hbxbp_SetEventFilter() ) ENDIF IF Len( ::aChildren ) > 0 @@ -764,7 +764,7 @@ METHOD XbpWindow:destroy() ::clearSlots() IF cXbp == "XBPDIALOG" - ClearEventBuffer() + hbxbp_ClearEventBuffer() Qt_Slots_Destroy() Qt_Events_Destroy() Qt_MyMainWindow_Destroy( QT_PTROF( ::oWidget ) )