diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f0bcaa55fd..27a7358ef6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,15 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-18 19:15 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbide/hbide.prg + * contrib/hbide/idemisc.prg + * contrib/hbxbp/Makefile + * contrib/hbxbp/xbpgeneric.prg + + contrib/hbxbp/xbpqtuiloader.prg + + Started XbpQtUiLoader() CLASS TO manage .ui components. + A work-in-progress. + 2009-12-18 16:01 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/generator/hbqtgen.prg * contrib/hbide/hbide.prg diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 757e9cbbd9..1329b97ec2 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -1517,6 +1517,7 @@ METHOD HbIde:executeAction( cKey ) ::lDockRVisible := !( ::lDockRVisible ) CASE cKey == "Compile" + TestXbpQtUiLoader() CASE cKey == "CompilePPO" ENDCASE @@ -1944,3 +1945,17 @@ METHOD HbIde:readProcessInfo( nMode, iBytes ) RETURN nil /*----------------------------------------------------------------------*/ + +FUNCTION TestXbpQtUiLoader() + LOCAL oUiLoader + + oUiLoader := XbpQtUiLoader():new() + oUiLoader:file := s_resPath + "finddialog.ui" + oUiLoader:create() + + oUiLoader:setText( "comboFindWhat", "Harbour" ) + + RETURN Nil + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index fb2defd8ce..abd66a4d8b 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -417,3 +417,185 @@ FUNCTION FilesToSources( aFiles ) RETURN aSrc /*----------------------------------------------------------------------*/ + +FUNCTION RequestModules() + + hbxbp_just( QAbstractButton():new() ) + hbxbp_just( QAbstractItemModel():new() ) + hbxbp_just( QAbstractItemView():new() ) + hbxbp_just( QAbstractListModel():new() ) + hbxbp_just( QAbstractPrintDialog():new() ) + hbxbp_just( QAbstractScrollArea():new() ) + hbxbp_just( QAbstractSlider():new() ) + hbxbp_just( QAbstractSpinBox():new() ) + hbxbp_just( QAbstractTableModel():new() ) + hbxbp_just( QAction():new() ) + hbxbp_just( QApplication():new() ) + hbxbp_just( QBitmap():new() ) + hbxbp_just( QBoxLayout():new() ) + hbxbp_just( QBrush():new() ) + hbxbp_just( QButtonGroup():new() ) + hbxbp_just( QCalendarWidget():new() ) + hbxbp_just( QCheckBox():new() ) + hbxbp_just( QClipboard():new() ) + hbxbp_just( QColor():new() ) + hbxbp_just( QColorDialog():new() ) + hbxbp_just( QComboBox():new() ) + hbxbp_just( QCommandLinkButton():new() ) + hbxbp_just( QCommonStyle():new() ) + hbxbp_just( QConicalGradient():new() ) + hbxbp_just( QCoreApplication():new() ) + hbxbp_just( QCursor():new() ) + hbxbp_just( QDateEdit():new() ) + hbxbp_just( QDateTime():new() ) + hbxbp_just( QDateTimeEdit():new() ) + hbxbp_just( QDesktopWidget():new() ) + hbxbp_just( QDial():new() ) + hbxbp_just( QDialog():new() ) + hbxbp_just( QDir():new() ) + hbxbp_just( QDirModel():new() ) + hbxbp_just( QDockWidget():new() ) + hbxbp_just( QDoubleSpinBox():new() ) + hbxbp_just( QDropEvent():new() ) + hbxbp_just( QDragMoveEvent():new() ) + hbxbp_just( QDragEnterEvent():new() ) + hbxbp_just( QDragLeaveEvent():new() ) + hbxbp_just( QErrorMessage():new() ) + hbxbp_just( QEvent():new() ) + hbxbp_just( QEventLoop():new() ) + hbxbp_just( QFileDialog():new() ) + hbxbp_just( QFileSystemModel():new() ) + hbxbp_just( QFocusEvent():new() ) + hbxbp_just( QFocusFrame():new() ) + hbxbp_just( QFont():new() ) + hbxbp_just( QFontComboBox():new() ) + hbxbp_just( QFontDatabase():new() ) + hbxbp_just( QFontDialog():new() ) + hbxbp_just( QFontInfo():new() ) + hbxbp_just( QFontMetrics():new() ) + hbxbp_just( QFontMetricsF():new() ) + hbxbp_just( QFormLayout():new() ) + hbxbp_just( QFrame():new() ) + hbxbp_just( QFtp():new() ) + hbxbp_just( QGradient():new() ) + hbxbp_just( QGridLayout():new() ) + hbxbp_just( QGroupBox():new() ) + hbxbp_just( QHBoxLayout():new() ) + hbxbp_just( QHeaderView():new() ) + hbxbp_just( QHttp():new() ) + hbxbp_just( QIcon():new() ) + hbxbp_just( QImage():new() ) + hbxbp_just( QImageReader():new() ) + hbxbp_just( QImageWriter():new() ) + hbxbp_just( QInputDialog():new() ) + hbxbp_just( QInputEvent():new() ) + hbxbp_just( QIODevice():new() ) + hbxbp_just( QKeyEvent():new() ) + hbxbp_just( QKeySequence():new() ) + hbxbp_just( QLabel():new() ) + hbxbp_just( QLatin1Char():new() ) + hbxbp_just( QLatin1String():new() ) + hbxbp_just( QLayout():new() ) + hbxbp_just( QLayoutItem():new() ) + hbxbp_just( QLCDNumber():new() ) + hbxbp_just( QLine():new() ) + hbxbp_just( QLinearGradient():new() ) + hbxbp_just( QLineEdit():new() ) + hbxbp_just( QList():new() ) + hbxbp_just( QListView():new() ) + hbxbp_just( QListWidget():new() ) + hbxbp_just( QListWidgetItem():new() ) + hbxbp_just( QMainWindow():new() ) + hbxbp_just( QMenu():new() ) + hbxbp_just( QMenuBar():new() ) + hbxbp_just( QMessageBox():new() ) + hbxbp_just( QModelIndex():new() ) + hbxbp_just( QMouseEvent():new() ) + hbxbp_just( QMoveEvent():new() ) + hbxbp_just( QObject():new() ) + hbxbp_just( QPaintDevice():new() ) + hbxbp_just( QPageSetupDialog():new() ) + hbxbp_just( QPainter():new() ) + hbxbp_just( QPaintEvent():new() ) + hbxbp_just( QPalette():new() ) + hbxbp_just( QPen():new() ) + hbxbp_just( QPicture():new() ) + hbxbp_just( QPixmap():new() ) + hbxbp_just( QPoint():new() ) + hbxbp_just( QPointF():new() ) + hbxbp_just( QPrintDialog():new() ) + hbxbp_just( QPrintEngine():new() ) + hbxbp_just( QPrinter():new() ) + hbxbp_just( QPrintPreviewDialog():new() ) + hbxbp_just( QProcess():new() ) + hbxbp_just( QProgressBar():new() ) + hbxbp_just( QProgressDialog():new() ) + hbxbp_just( QPushButton():new() ) + hbxbp_just( QRadialGradient():new() ) + hbxbp_just( QRadioButton():new() ) + hbxbp_just( QRect():new() ) + hbxbp_just( QRectF():new() ) + hbxbp_just( QRegion():new() ) + hbxbp_just( QResizeEvent():new() ) + hbxbp_just( QResource():new() ) + hbxbp_just( QScrollArea():new() ) + hbxbp_just( QScrollBar():new() ) + hbxbp_just( QSignalMapper():new() ) + hbxbp_just( QSize():new() ) + hbxbp_just( QSizeF():new() ) + hbxbp_just( QSizeGrip():new() ) + hbxbp_just( QSizePolicy():new() ) + hbxbp_just( QSlider():new() ) + hbxbp_just( QSound():new() ) + hbxbp_just( QSpinBox():new() ) + hbxbp_just( QSplashScreen():new() ) + hbxbp_just( QSplitter():new() ) + hbxbp_just( QStandardItem():new() ) + hbxbp_just( QStandardItemModel():new() ) + hbxbp_just( QStatusBar():new() ) + hbxbp_just( QStringList():new() ) + hbxbp_just( QStringListModel():new() ) + hbxbp_just( QSystemTrayIcon():new() ) + hbxbp_just( QTabBar():new() ) + hbxbp_just( QTableView():new() ) + hbxbp_just( QTableWidget():new() ) + hbxbp_just( QTableWidgetItem():new() ) + hbxbp_just( QTabWidget():new() ) + hbxbp_just( QTextBlock():new() ) + hbxbp_just( QTextBlockFormat():new() ) + hbxbp_just( QTextBlockGroup():new() ) + hbxbp_just( QTextBrowser():new() ) + hbxbp_just( QTextBoundaryFinder():new() ) + hbxbp_just( QTextCharFormat():new() ) + hbxbp_just( QTextCodec():new() ) + hbxbp_just( QTextCursor():new() ) + hbxbp_just( QTextDecoder():new() ) + hbxbp_just( QTextDocument():new() ) + hbxbp_just( QTextDocumentFragment():new() ) + hbxbp_just( QTextDocumentWriter():new() ) + hbxbp_just( QTextEdit():new() ) + hbxbp_just( QTextFrame():new() ) + hbxbp_just( QTextItem():new() ) + hbxbp_just( QTextLayout():new() ) + hbxbp_just( QTextLength():new() ) + hbxbp_just( QTextLine():new() ) + hbxbp_just( QTextObject():new() ) + hbxbp_just( QTextStream():new() ) + hbxbp_just( QTimeEdit():new() ) + hbxbp_just( QTimer():new() ) + hbxbp_just( QToolBar():new() ) + hbxbp_just( QToolBox():new() ) + hbxbp_just( QToolButton():new() ) + hbxbp_just( QTreeView():new() ) + hbxbp_just( QTreeWidget():new() ) + hbxbp_just( QTreeWidgetItem():new() ) + hbxbp_just( QUrl():new() ) + hbxbp_just( QVariant():new() ) + hbxbp_just( QVBoxLayout():new() ) + hbxbp_just( QWheelEvent():new() ) + hbxbp_just( QWidget():new() ) + hbxbp_just( QWidgetItem():new() ) + + RETURN NIL + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/Makefile b/harbour/contrib/hbxbp/Makefile index a753dc1efa..9b62cd28de 100644 --- a/harbour/contrib/hbxbp/Makefile +++ b/harbour/contrib/hbxbp/Makefile @@ -41,6 +41,7 @@ PRG_SOURCES := \ xbpprinter.prg \ xbpprintdialog.prg \ xbpbrowse.prg \ + xbpqtuiloader.prg \ PRG_HEADERS := \ xbp.ch \ diff --git a/harbour/contrib/hbxbp/xbpgeneric.prg b/harbour/contrib/hbxbp/xbpgeneric.prg index 87abafda00..9d9ed4c4aa 100644 --- a/harbour/contrib/hbxbp/xbpgeneric.prg +++ b/harbour/contrib/hbxbp/xbpgeneric.prg @@ -288,6 +288,8 @@ FUNCTION GraMakeRGBColor( aRGB ) RETURN nRGB +/*----------------------------------------------------------------------*/ + FUNCTION hbxbp_ConvertAFactFromXBP( cMode, xValue ) SWITCH Upper( cMode ) @@ -357,3 +359,8 @@ FUNCTION hbxbp_ConvertAFactFromXBP( cMode, xValue ) RETURN xValue /*----------------------------------------------------------------------*/ + +FUNCTION hbxbp_Just() + RETURN nil + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpqtuiloader.prg b/harbour/contrib/hbxbp/xbpqtuiloader.prg new file mode 100644 index 0000000000..f2eaaff33a --- /dev/null +++ b/harbour/contrib/hbxbp/xbpqtuiloader.prg @@ -0,0 +1,215 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Source file for the Xbp*Classes + * + * Copyright 2008 Pritpal Bedi + * 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. + * + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* + * EkOnkar + * ( The LORD is ONE ) + * + * Xbase++ Syntax Inspired XbpQtUiLoader Class + * + * Pritpal Bedi + * 18Decy2009 + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +#include "hbclass.ch" +#include "common.ch" +#include "inkey.ch" + +#include "xbp.ch" +#include "appevent.ch" + +/*----------------------------------------------------------------------*/ + +CLASS XbpQtUiLoader INHERIT XbpWindow + + DATA file INIT "" + DATA modal INIT .t. + DATA parts INIT hb_hash() + DATA baseWidget + DATA widgets INIT {} + + METHOD new() + METHOD create() + METHOD configure() VIRTUAL + METHOD destroy() VIRTUAL + METHOD loadUI() + METHOD loadContents() + METHOD loadWidgets() + + ERROR HANDLER OnError() + + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD XbpQtUiLoader:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpQtUiLoader:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + IF !empty( ::file ) .and. file( ::file ) + ::loadContents( ::file ) + ::oWidget := ::loadUI( ::file ) + + IF !empty( ::oWidget ) + ::loadWidgets() + ::oWidget:show() + ENDIF + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpQtUiLoader:loadWidgets() + LOCAL a_, pPtr, bBlock, x, cBlock + + FOR EACH a_ IN ::widgets + IF a_:__enumIndex() > 1 + cBlock := "{|| " + a_[ 1 ] + "() }" + + pPtr := Qt_findChild( ::oWidget, a_[ 2 ] ) + bBlock := &( cBlock ) + + x := eval( bBlock ) + IF hb_isObject( x ) + x:pPtr := pPtr + ENDIF + ::parts[ a_[ 2 ] ] := x + ENDIF + NEXT + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpQtUiLoader:loadContents( cUiFull ) + LOCAL cBuffer := memoread( cUiFull ) + LOCAL n, cClass, cWidget + + DO WHILE .t. + IF ( n := at( "widget class=", cBuffer ) ) == 0 + EXIT + ENDIF + cBuffer := substr( cBuffer, n + 13 ) + + n := at( "name=", cBuffer ) + cClass := alltrim( strtran( substr( cBuffer, 1, n-1 ), '"', "" ) ) + cBuffer := substr( cBuffer, n + 5 ) + + n := at( ">", cBuffer ) + cWidget := alltrim( strtran( substr( cBuffer, 1, n-1 ), '"', "" ) ) + + HBXBP_DEBUG( "XbpQtUiLoader:loadContents", cClass, cWidget ) + + aadd( ::widgets, { cClass, cWidget } ) + ENDDO + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpQtUiLoader:loadUI( cUiFull ) + LOCAL qWidget, qUiLoader, qFile + + qFile := QFile():new( cUiFull ) + IF qFile:open( 1 ) + qUiLoader := QUiLoader():new() + qWidget := QWidget():configure( qUiLoader:load( qFile, IF( empty( ::oParent ), NIL, QT_PTROFXBP( ::oParent ) ) ) ) + qFile:close() + ENDIF + + RETURN qWidget + +/*----------------------------------------------------------------------*/ + +#if 0 /* Syntax */ + oUI:setText( "editWidget", "Some Text" ) + ^^^ XbpQtUiLoader() + ^^^^^^^ HBQT Object Method + ^^^^^^^^^^^^ Object Name In the Widget + ^^^^^^^^^^^ Value to be posted +#endif + +METHOD OnError( ... ) + LOCAL cMsg, xReturn, cWidget + LOCAL aP, aPP := {} + + cMsg := __GetMessage() + IF SubStr( cMsg, 1, 1 ) == "_" + cMsg := SubStr( cMsg, 2 ) + ENDIF + + aP := hb_aParams() + cWidget := aP[ 1 ] + + aeval( aP, {|e| aadd( aPP, e ) }, 2 ) + + IF hb_hHasKey( ::parts, cWidget ) + xReturn := hb_ExecFromArray( ::parts[ cWidget ], cMsg, aPP ) + ENDIF + + RETURN xReturn + +/*----------------------------------------------------------------------*/