diff --git a/harbour/ChangeLog b/harbour/ChangeLog
index d34acb177d..54f8edd8d3 100644
--- a/harbour/ChangeLog
+++ b/harbour/ChangeLog
@@ -16,6 +16,23 @@
The license applies to all entries newer than 2009-04-28.
*/
+2010-07-10 19:15 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
+ * contrib/hbqt/qth/HBQPlainTextEdit.qth
+ * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp
+ * contrib/hbqt/qtgui/THBQPlainTextEdit.prg
+ + Added: two more arguments in :hbShowPrototype().
+
+ * contrib/hbqt/doc/en/class_hbqplaintextedit.txt
+ * contrib/hbqt/hbqt_hbqplaintextedit.cpp
+ * contrib/hbqt/hbqt_hbqplaintextedit.h
+
+ * contrib/hbide/ideedit.prg
+ + Implemented: vertical display of proto-tip.
+ Now if number or arguments in a funtion prototype are
+ more than 1, the tip will be presented as vertical
+ list. An image to this effect will follow in reply to
+ this message.
+
2010-07-10 12:03 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
! Adjusted horizontal position of proto-tip.
diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg
index 9db15ddb94..f620de7ad1 100644
--- a/harbour/contrib/hbide/ideedit.prg
+++ b/harbour/contrib/hbide/ideedit.prg
@@ -121,6 +121,9 @@ CLASS IdeEdit INHERIT IdeObject
DATA nProtoCol INIT -1
DATA isSuspended INIT .F.
+ DATA nProtoRows INIT 1
+ DATA nProtoCols INIT 10
+
DATA fontFamily
DATA pointSize
DATA currentPointSize
@@ -420,7 +423,7 @@ METHOD IdeEdit:connectEditSignals( oEdit )
/*----------------------------------------------------------------------*/
METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 )
- LOCAL pAct, qAct, n, qEdit, oo, qCursor, cProto
+ LOCAL pAct, qAct, n, qEdit, oo, qCursor, cProto, nRows, nCols
HB_SYMBOL_UNUSED( p1 )
@@ -508,8 +511,10 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 )
IF ::nProtoLine != -1
IF ::getLineNo() == ::nProtoLine .AND. ::getColumnNo() >= ::nProtoCol + 1
- IF !empty( cProto := hbide_formatProto_1( ::cProtoOrg, ::getLine(), ::nProtoCol, ::getColumnNo() ) )
- ::cProto := cProto
+ IF !empty( cProto := hbide_formatProto_1( ::cProtoOrg, ::getLine(), ::nProtoCol, ::getColumnNo(), @nRows, @nCols ) )
+ ::cProto := cProto
+ ::nProtoRows := nRows
+ ::nProtoCols := nCols
::showProtoType()
ENDIF
ENDIF
@@ -2184,7 +2189,7 @@ METHOD IdeEdit:showPrototype( cProto )
::nProtoLine := ::getLineNo()
::nProtoCol := ::getColumnNo()
ENDIF
- ::qEdit:hbShowPrototype( ::cProto )
+ ::qEdit:hbShowPrototype( ::cProto, ::nProtoRows, ::nProtoCols )
ENDIF
RETURN Self
@@ -2196,6 +2201,8 @@ METHOD IdeEdit:hidePrototype()
::nProtoLine := -1
::nProtoCol := -1
::cProto := ""
+ ::nProtoCols := 10
+ ::nProtoRows := 1
::qEdit:hbShowPrototype( "" )
ENDIF
RETURN Self
@@ -2419,8 +2426,8 @@ FUNCTION hbide_isHarbourKeyword( cWord, oIde )
/*----------------------------------------------------------------------*/
-FUNCTION hbide_formatProto_1( cProto, cText, nProtoCol, nCurCol )
- LOCAL s, nArgs, cArgs, aArgs, cArg, n, n1, i, nnn, cPro
+FUNCTION hbide_formatProto_1( cProto, cText, nProtoCol, nCurCol, nRows, nCols )
+ LOCAL s, nArgs, cArgs, aArgs, cArg, n, n1, i, nnn, cPro, cFunc
IF nCurCol > nProtoCol
n := at( "(", cProto ) ; n1 := at( ")", cProto )
@@ -2435,25 +2442,39 @@ FUNCTION hbide_formatProto_1( cProto, cText, nProtoCol, nCurCol )
ENDIF
NEXT
+ nRows := 1; nCols := 0
+
IF nArgs > 0
- cProto := StrTran( cProto, "<", "<" ) ; cProto := StrTran( cProto, ">", ">" )
n := at( "(", cProto ) ; n1 := at( ")", cProto )
+ cFunc := substr( cProto, 1, n - 1 )
cArgs := substr( cProto, n + 1, n1 - n - 1 )
aArgs := hb_aTokens( cArgs, "," )
cArgs := ""
+ nCols := len( cFunc ) + 1
FOR EACH cArg IN aArgs
+ cArg := alltrim( cArg )
+
+ nRows++
+ nCols := max( nCols, len( cArg ) + 3 )
+
+ cArg := StrTran( cArg, "<", "<" )
+ cArg := StrTran( cArg, ">", ">" )
+
nnn := cArg:__enumIndex()
IF nnn == nArgs
- cArg := "" + cArg + ""
+ cArg := "" + cArg + ""
ENDIF
IF nnn == len( aArgs )
- cArgs += cArg
+ cArgs += "
" + " " + cArg
ELSE
- cArgs += cArg + "" + "," + ""
+ cArgs += "
" + " " + cArg + "" + "," + ""
ENDIF
NEXT
- cPro := "
" + "" + substr( cProto, 1, n - 1 ) + "" + ; + nCols += iif( nCols <= len( cFunc ), 0, 1 ) + + //cPro := "
" + "" + cFunc + "" + ; + cPro := "
" + "" + cFunc + "" + ; "" + "(" + "" + ; cArgs + ; "" + ")" + "" + "
" diff --git a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt index 5a00ad4b56..cf2062adff 100644 --- a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt +++ b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt @@ -60,7 +60,7 @@ :hbMoveLine( nIDirection ) -> NIL :hbGetSelectedText() -> cQString :hbTextUnderCursor() -> cQString - :hbShowPrototype( cTip ) -> NIL + :hbShowPrototype( cTip, nRows, nCols ) -> NIL :hbSetCompleter( pCompleter ) -> NIL :hbSetCurrentLineColor( pColor ) -> NIL :hbSetLineAreaBkColor( pColor ) -> NIL diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index c23f8c020e..214388bc47 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -147,13 +147,22 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent ttFrame = new QFrame( this ); ttFrame->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); - ttLayout = new QHBoxLayout( ttFrame ); + ttLayout = new QVBoxLayout( ttFrame ); ttFrame->setLayout( ttLayout ); - ttLabel = new QLabel(); - //ttLabel->setWordWrap( true ); + ttLabel = new QLabel( ttFrame ); + ttLabel->setWordWrap( true ); ttLabel->setText( "" ); hbSetProtoStyle(); ttLayout->addWidget( ttLabel ); + + ttTextEdit = new QTextEdit( ttFrame ); + ttTextEdit->setStyleSheet( "background-color: rgb(255,255,174); border: 1px solid black;" );// padding: 3px;" ); + ttTextEdit->setFocusPolicy( Qt::NoFocus ); + ttTextEdit->setReadOnly( true ); + ttTextEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + ttTextEdit->setFont( QFont( "Courier New", 10 ) ); + ttLayout->addWidget( ttTextEdit ); + ttFrame->setFocusPolicy( Qt::NoFocus ); ttFrame->hide(); @@ -166,6 +175,58 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent /*----------------------------------------------------------------------*/ +void HBQPlainTextEdit::hbShowPrototype( const QString & tip, int rows, int cols ) +{ + if( rows <= 1 ) + { + ttLabel->setText( tip ); + ttTextEdit->setText( "" ); + ttTextEdit->hide(); + ttLabel->show(); + } + else + { + ttLabel->setText( "" ); + ttTextEdit->setText( tip ); + ttLabel->hide(); + ttTextEdit->show(); + } + + if( tip == ( QString ) "" ) + { + isTipActive = false; + ttFrame->hide(); + } + else + { + isTipActive = true; + + if( rows > 1 ) + { + int h = ( ttTextEdit->fontMetrics().height() * rows ) + 12 + 24; + int w = ( ttTextEdit->fontMetrics().averageCharWidth() * cols ) + 12 + 24; + + ttFrame->setMinimumHeight( h ); + ttFrame->setMinimumWidth( w ); + ttFrame->setMaximumHeight( h ); + ttFrame->setMaximumWidth( w ); + } + + QRect r = cursorRect(); + int w = ttFrame->width(); + + int x = r.x()-r.width(); + int nOff = viewport()->width() - ( x + w ); + if( nOff < 0 ) + x = qMax( 0, x + nOff ); + ttFrame->move( qMax( 0, x ), r.y() + 7 + horzRulerHeight ); + + ttFrame->show(); + } +} + +/*----------------------------------------------------------------------*/ + HBQPlainTextEdit::~HBQPlainTextEdit() { #if 0 @@ -225,34 +286,6 @@ void HBQPlainTextEdit::hbSetProtoStyle( const QString & css ) /*----------------------------------------------------------------------*/ -void HBQPlainTextEdit::hbShowPrototype( const QString & tip ) -{ - ttLabel->setText( tip ); - - if( tip == ( QString ) "" ) - { - isTipActive = false; - - ttFrame->hide(); - } - else - { - isTipActive = true; - - QRect r = cursorRect(); - int w = ttLabel->width(); - int x = r.x()-r.width(); - int nOff = viewport()->width() - ( x + w ); - if( nOff < 0 ) - x = qMax( 0, x + nOff ); - ttFrame->move( qMax( 0, x ), r.y() + 7 + horzRulerHeight ); - - ttFrame->show(); - } -} - -/*----------------------------------------------------------------------*/ - bool HBQPlainTextEdit::event( QEvent *event ) { if( event->type() == QEvent::KeyPress ) diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index 428777e88a..e88b479c23 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -124,8 +124,9 @@ private: QWidget * lineNumberArea; QFrame * horzRuler; QFrame * ttFrame; - QHBoxLayout * ttLayout; + QVBoxLayout * ttLayout; QLabel * ttLabel; + QTextEdit * ttTextEdit; int spaces; bool numberBlock; bool highlightCurLine; @@ -192,7 +193,7 @@ public slots: QString hbTextUnderCursor(); void hbNumberBlockVisible( bool b ); bool hbNumberBlockVisible(); - void hbShowPrototype( const QString & tip ); + void hbShowPrototype( const QString & tip, int rows, int cols ); void hbSetCompleter( QCompleter * completer ) { c = completer; }; void hbSetCurrentLineColor( const QColor & color ) { m_currentLineColor = color; }; void hbSetLineAreaBkColor( const QColor & color ) { m_lineAreaBkColor = color; }; diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 85c51e1c2b..618f248dab 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -609,16 +609,16 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBTEXTUNDERCURSOR ) } /* - * void hbShowPrototype( const QString & tip ) + * void hbShowPrototype( const QString & tip, int rows, int cols ) */ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSHOWPROTOTYPE ) { HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); if( p ) - ( p )->hbShowPrototype( HBQPlainTextEdit::tr( hb_parc( 2 ) ) ); + ( p )->hbShowPrototype( HBQPlainTextEdit::tr( hb_parc( 2 ) ), hb_parni( 3 ), hb_parni( 4 ) ); else { - HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBSHOWPROTOTYPE FP=( p )->hbShowPrototype( HBQPlainTextEdit::tr( hb_parc( 2 ) ) ); p is NULL" ) ); + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBSHOWPROTOTYPE FP=( p )->hbShowPrototype( HBQPlainTextEdit::tr( hb_parc( 2 ) ), hb_parni( 3 ), hb_parni( 4 ) ); p is NULL" ) ); } } diff --git a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg index ef07643b02..7dae01892a 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -99,7 +99,7 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD hbMoveLine( nIDirection ) METHOD hbGetSelectedText() METHOD hbTextUnderCursor() - METHOD hbShowPrototype( cTip ) + METHOD hbShowPrototype( cTip, nRows, nCols ) METHOD hbSetCompleter( pCompleter ) METHOD hbSetCurrentLineColor( pColor ) METHOD hbSetLineAreaBkColor( pColor ) @@ -259,8 +259,8 @@ METHOD HBQPlainTextEdit:hbTextUnderCursor() RETURN Qt_HBQPlainTextEdit_hbTextUnderCursor( ::pPtr ) -METHOD HBQPlainTextEdit:hbShowPrototype( cTip ) - RETURN Qt_HBQPlainTextEdit_hbShowPrototype( ::pPtr, cTip ) +METHOD HBQPlainTextEdit:hbShowPrototype( cTip, nRows, nCols ) + RETURN Qt_HBQPlainTextEdit_hbShowPrototype( ::pPtr, cTip, nRows, nCols ) METHOD HBQPlainTextEdit:hbSetCompleter( pCompleter ) diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index 45b69f355b..1807a802d0 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -130,7 +130,7 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) void hbMoveLine( int iDirection ) QString hbGetSelectedText() QString hbTextUnderCursor() - void hbShowPrototype( const QString & tip ) + void hbShowPrototype( const QString & tip, int rows, int cols ) void hbSetCompleter( QCompleter * completer ) void hbSetCurrentLineColor( const QColor & color ) void hbSetLineAreaBkColor( const QColor & color )