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.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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 := "<font color=blue>" + cArg + "</font>"
|
||||
cArg := "<font color=red><b>" + cArg + "</b></font>"
|
||||
ENDIF
|
||||
IF nnn == len( aArgs )
|
||||
cArgs += cArg
|
||||
cArgs += "<br>" + " " + cArg
|
||||
ELSE
|
||||
cArgs += cArg + "<font color=red><b>" + "," + "</b></font>"
|
||||
cArgs += "<br>" + " " + cArg + "<font color=red><b>" + "," + "</b></font>"
|
||||
ENDIF
|
||||
NEXT
|
||||
cPro := "<p style='white-space:pre'>" + "<b>" + substr( cProto, 1, n - 1 ) + "</b>" + ;
|
||||
nCols += iif( nCols <= len( cFunc ), 0, 1 )
|
||||
|
||||
//cPro := "<p style='white-space:pre'>" + "<font color=darkgreen><b>" + cFunc + "</b></font>" + ;
|
||||
cPro := "<p style='white-space:pre'>" + "<b>" + cFunc + "</b>" + ;
|
||||
"<font color=red><b>" + "(" + "</b></font>" + ;
|
||||
cArgs + ;
|
||||
"<font color=red><b>" + ")" + "</font>" + "</b></p>"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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; };
|
||||
|
||||
@@ -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" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user