2010-05-18 22:57 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbqt/doc/en/class_hbqplaintextedit.txt
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
* contrib/hbqt/hbqt_hbqplaintextedit.h
* contrib/hbqt/qtgui/HBQPlainTextEdit.cpp
* contrib/hbqt/qtgui/THBQPlainTextEdit.prg
* contrib/hbqt/qth/HBQPlainTextEdit.qth
* contrib/hbide/ideedit.prg
* contrib/hbide/ideeditor.prg
* contrib/hbide/idesaveload.prg
* contrib/hbide/ideshortcuts.prg
+ Implemented: proper hbIDEMap protocol. Now you can keep open
"Source Thumbnail" dock and keep on clicking the tabs. Current
source map will be displayed inside.
hbIDEMap Features:
1. hbIDEMap carries highlighted code lines which are visible
in main editing instance window. Navigaing the editor also
changes highlighted area corresponding to main instance.
2. All keyboard mappings are active in the map also which implies
that you can exercise copy operations which can be pasted
in the current code, a very useful feature.
This commit is contained in:
@@ -17,6 +17,31 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-05-18 22:57 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbqt/doc/en/class_hbqplaintextedit.txt
|
||||
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
|
||||
* contrib/hbqt/hbqt_hbqplaintextedit.h
|
||||
* contrib/hbqt/qtgui/HBQPlainTextEdit.cpp
|
||||
* contrib/hbqt/qtgui/THBQPlainTextEdit.prg
|
||||
* contrib/hbqt/qth/HBQPlainTextEdit.qth
|
||||
* contrib/hbide/ideedit.prg
|
||||
* contrib/hbide/ideeditor.prg
|
||||
* contrib/hbide/idesaveload.prg
|
||||
* contrib/hbide/ideshortcuts.prg
|
||||
|
||||
+ Implemented: proper hbIDEMap protocol. Now you can keep open
|
||||
"Source Thumbnail" dock and keep on clicking the tabs. Current
|
||||
source map will be displayed inside.
|
||||
|
||||
hbIDEMap Features:
|
||||
|
||||
1. hbIDEMap carries highlighted code lines which are visible
|
||||
in main editing instance window. Navigaing the editor also
|
||||
changes highlighted area corresponding to main instance.
|
||||
2. All keyboard mappings are active in the map also which implies
|
||||
that you can exercise copy operations which can be pasted
|
||||
in the current code, a very useful feature.
|
||||
|
||||
2010-05-18 18:55 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
|
||||
* contrib/hbqt/hbqt_hbqplaintextedit.h
|
||||
|
||||
@@ -1305,7 +1305,6 @@ METHOD IdeEdit:toggleLineSelectionMode()
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEdit:clearSelection()
|
||||
//::qEdit:hbSetSelectionInfo( { -1,-1,-1,-1,1 } )
|
||||
::qEdit:hbSetSelectionMode( 0, .t. )
|
||||
RETURN Self
|
||||
|
||||
|
||||
@@ -167,8 +167,9 @@ CLASS IdeEditsManager INHERIT IdeObject
|
||||
METHOD pageUp()
|
||||
METHOD pageDown()
|
||||
|
||||
METHOD find( cString )
|
||||
METHOD find( cString, nPosFrom )
|
||||
METHOD showThumbnail()
|
||||
METHOD changeThumbnail()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -1103,12 +1104,19 @@ METHOD IdeEditsManager:showThumbnail()
|
||||
ENDIF
|
||||
RETURN Self
|
||||
/*----------------------------------------------------------------------*/
|
||||
METHOD IdeEditsManager:changeThumbnail()
|
||||
LOCAL oEdit
|
||||
IF !empty( oEdit := ::getEditorCurrent() )
|
||||
oEdit:changeThumbnail()
|
||||
ENDIF
|
||||
RETURN Self
|
||||
/*----------------------------------------------------------------------*/
|
||||
// Locating
|
||||
/*----------------------------------------------------------------------*/
|
||||
METHOD IdeEditsManager:find( cString )
|
||||
METHOD IdeEditsManager:find( cString, nPosFrom )
|
||||
LOCAL oEdit
|
||||
IF !empty( oEdit := ::getEditObjectCurrent() )
|
||||
oEdit:find( cString )
|
||||
oEdit:find( cString, nPosFrom )
|
||||
ENDIF
|
||||
RETURN Self
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -1179,6 +1187,8 @@ CLASS IdeEditor INHERIT IdeObject
|
||||
METHOD setTabImage( qEdit )
|
||||
METHOD applyTheme( cTheme )
|
||||
METHOD showThumbnail()
|
||||
METHOD changeThumbnail()
|
||||
METHOD scrollThumbnail()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -1266,6 +1276,8 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, a
|
||||
::qCqEdit := ::oEdit:qEdit
|
||||
::qCoEdit := ::oEdit
|
||||
|
||||
::connect( ::oEdit:qEdit, "updateRequest(QRect,int)", {|| ::scrollThumbnail() } )
|
||||
|
||||
::qDocument := QTextDocument():configure( ::qEdit:document() )
|
||||
::qDocLayout := QPlainTextDocumentLayout():new( ::qDocument )
|
||||
::qDocument:setDocumentLayout( ::qDocLayout )
|
||||
@@ -1297,6 +1309,8 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, a
|
||||
METHOD IdeEditor:destroy()
|
||||
LOCAL n, oEdit
|
||||
|
||||
::disconnect( ::oEdit:qEdit, "updateRequest(QRect,int)" )
|
||||
|
||||
IF !empty( ::qTimerSave )
|
||||
::disconnect( ::qTimerSave, "timeout()" )
|
||||
::qTimerSave:stop()
|
||||
@@ -1481,6 +1495,7 @@ METHOD IdeEditor:activateTab( mp1, mp2, oXbp )
|
||||
oEdit:qCoEdit:toggleLineNumbers()
|
||||
oEdit:qCoEdit:toggleCurrentLineHighlightMode()
|
||||
oEdit:qCoEdit:dispStatusInfo()
|
||||
oEdit:changeThumbnail()
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
@@ -1581,7 +1596,7 @@ METHOD IdeEditor:showThumbnail()
|
||||
::qTNFont := QFont():new()
|
||||
::qTNFont:setFamily( "Courier New" )
|
||||
::qTNFont:setFixedPitch( .t. )
|
||||
::qTNFont:setPointSize( 6 )
|
||||
::qTNFont:setPointSize( 5 )
|
||||
|
||||
::qThumbnail := IdeEdit():new( Self, 0 ):create()
|
||||
IF ::cType != "U"
|
||||
@@ -1589,13 +1604,40 @@ METHOD IdeEditor:showThumbnail()
|
||||
ENDIF
|
||||
|
||||
::qThumbnail:qEdit:setFont( ::qTNFont )
|
||||
::oSourceThumbnailDock:oWidget:setWidget( ::qThumbnail:qEdit )
|
||||
::qThumbnail:lReadOnly := .t.
|
||||
::qThumbnail:setReadOnly( .t. )
|
||||
::qThumbnail:qEdit:setTextInteractionFlags( Qt_TextSelectableByMouse + Qt_TextSelectableByKeyboard )
|
||||
ENDIF
|
||||
|
||||
::oSourceThumbnailDock:oWidget:setWidget( ::qThumbnail:qEdit )
|
||||
::qThumbnail:qEdit:clear()
|
||||
::qThumbnail:qEdit:setPlainText( hb_memoRead( ::sourceFile ) )
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEditor:changeThumbnail()
|
||||
|
||||
IF ::lLoaded .AND. ::oSourceThumbnailDock:oWidget:isVisible()
|
||||
::showThumbnail()
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEditor:scrollThumbnail()
|
||||
LOCAL qScroll
|
||||
|
||||
IF ::lLoaded .AND. ::oSourceThumbnailDock:oWidget:isVisible() .AND. !empty( ::qThumbnail )
|
||||
qScroll := QScrollBar():configure( ::oEdit:qEdit:verticalScrollBar() )
|
||||
QScrollBar():configure( ::qThumbnail:qEdit:verticalScrollBar() ):setValue( qScroll:value() )
|
||||
|
||||
::oEdit:qEdit:hbGetViewportInfo()
|
||||
|
||||
::qThumbnail:qEdit:hbHighlightArea( ::oEdit:aViewportInfo[ 1 ], 0, ::oEdit:aViewportInfo[ 1 ]+::oEdit:aViewportInfo[ 3 ]-1, 0, 1 )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -76,8 +76,6 @@ STATIC FUNCTION hbide_saveSettings( oIde )
|
||||
hb_fNameSplit( oIde:cProjIni, @cPath )
|
||||
hbqt_QMainWindow_saveSettings( cPath + "settings.ide", "hbidesettings", oIde:oDlg:oWidget:pPtr )
|
||||
|
||||
* hbqt_QMainWindow_saveSettings( oIde:cProjIni, "hbidesettings", oIde:oDlg:oWidget:pPtr )
|
||||
|
||||
RETURN nil
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -88,8 +86,6 @@ FUNCTION hbide_restSettings( oIde )
|
||||
hb_fNameSplit( oIde:cProjIni, @cPath )
|
||||
hbqt_QMainWindow_restSettings( cPath + "settings.ide", "hbidesettings", oIde:oDlg:oWidget:pPtr )
|
||||
|
||||
* hbqt_QMainWindow_restSettings( oIde:cProjIni, "hbidesettings", oIde:oDlg:oWidget:pPtr )
|
||||
|
||||
RETURN nil
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -222,6 +222,7 @@ CLASS IdeShortcuts INHERIT IdeObject
|
||||
METHOD panHome()
|
||||
METHOD pageUp()
|
||||
METHOD pageDown()
|
||||
METHOD find( cString, nPosFrom )
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -1204,6 +1205,9 @@ METHOD IdeShortcuts:pageUp()
|
||||
METHOD IdeShortcuts:pageDown()
|
||||
RETURN ::oEM:pageDown()
|
||||
/*----------------------------------------------------------------------*/
|
||||
METHOD IdeShortcuts:find( cString, nPosFrom )
|
||||
RETURN ::oEM:find( cString, nPosFrom )
|
||||
/*----------------------------------------------------------------------*/
|
||||
// Public API Definitions
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -1489,6 +1493,9 @@ METHOD IdeShortcuts:loadMethods()
|
||||
aadd( ::aMethods, { 'getText()' , ;
|
||||
'getText()' , ;
|
||||
'Returns current selected text.' } )
|
||||
aadd( ::aMethods, { 'find( cString[, nFromPos ] )' , ;
|
||||
'find( "" )' , ;
|
||||
'Finds the <cString> from current location. If not found it searches backward. If <nFromPos> is given, it searches from this position and no backward search is performed.' } )
|
||||
|
||||
|
||||
aadd( ::aMethods, { ' Activating Dialogs', ;
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
:hbSetMatchBraces( lAll ) -> NIL
|
||||
:hbGetViewportInfo() -> NIL
|
||||
:hbApplyKey( nKey, nModifiers, cTxt ) -> NIL
|
||||
:hbHighlightArea( nTop, nLeft, nBottom, nRight, nMode ) -> NIL
|
||||
|
||||
$DESCRIPTION$
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent
|
||||
isSelectionByApplication = false;
|
||||
hitTestRow = -1;
|
||||
hitTestColumn = -1;
|
||||
highlight = QRect( -1, -1, -1, -1 );
|
||||
|
||||
connect( this, SIGNAL( blockCountChanged( int ) ) , this, SLOT( hbUpdateLineNumberAreaWidth( int ) ) );
|
||||
connect( this, SIGNAL( updateRequest( const QRect &, int ) ), this, SLOT( hbUpdateLineNumberArea( const QRect &, int ) ) );
|
||||
@@ -258,6 +259,20 @@ bool HBQPlainTextEdit::event( QEvent *event )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void HBQPlainTextEdit::hbHighlightArea( int top, int left, int bottom, int right, int mode )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( mode );
|
||||
|
||||
highlight.setTop( top );
|
||||
highlight.setLeft( left );
|
||||
highlight.setBottom( bottom );
|
||||
highlight.setRight( right );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void HBQPlainTextEdit::hbSetSelectionColor( const QColor & color )
|
||||
{
|
||||
m_selectionColor = color;
|
||||
@@ -334,11 +349,10 @@ void HBQPlainTextEdit::hbGetViewportInfo()
|
||||
|
||||
hb_arrayNew( p2, 6 );
|
||||
|
||||
QTextCursor ct = cursorForPosition( QPoint( 2,2 ) );
|
||||
int t = ct.blockNumber();
|
||||
int c = ct.columnNumber();
|
||||
int rows = viewport()->height() / fontMetrics().height();
|
||||
int cols = viewport()->width() / fontMetrics().averageCharWidth();
|
||||
int t = firstVisibleBlock().blockNumber();
|
||||
int c = hbFirstVisibleColumn();
|
||||
int rows = viewport()->height() / fontMetrics().height();
|
||||
int cols = viewport()->width() / fontMetrics().averageCharWidth();
|
||||
|
||||
hb_arraySetNI( p2, 1, t );
|
||||
hb_arraySetNI( p2, 2, c );
|
||||
@@ -1200,11 +1214,11 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
|
||||
// The following keys are forwarded by the completer to the widget
|
||||
switch( event->key() )
|
||||
{
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Escape:
|
||||
case Qt::Key_Tab:
|
||||
case Qt::Key_Backtab:
|
||||
case Qt::Key_Enter :
|
||||
case Qt::Key_Return :
|
||||
case Qt::Key_Escape :
|
||||
case Qt::Key_Tab :
|
||||
case Qt::Key_Backtab :
|
||||
event->ignore();
|
||||
return; // let the completer do default behavior
|
||||
case Qt::Key_Space:
|
||||
@@ -1337,6 +1351,7 @@ void HBQPlainTextEdit::paintEvent( QPaintEvent * event )
|
||||
++blockNumber;
|
||||
}
|
||||
this->hbPaintSelection( event );
|
||||
this->hbPaintHighlight( event );
|
||||
|
||||
#if 0
|
||||
//if( event->rect().width() == cursorWidth() && event->rect().height() == cursorRect().height() )
|
||||
@@ -1490,6 +1505,32 @@ void HBQPlainTextEdit::lineNumberAreaPaintEvent( QPaintEvent *event )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void HBQPlainTextEdit::hbPaintHighlight( QPaintEvent * event )
|
||||
{
|
||||
if( highlight.top() > -1 )
|
||||
{
|
||||
int fontHeight = fontMetrics().height();
|
||||
int t = firstVisibleBlock().blockNumber();
|
||||
int b = t + ( viewport()->height() / fontHeight ) + 1;
|
||||
int rb = highlight.top();
|
||||
int re = highlight.bottom();
|
||||
|
||||
if( re >= t && rb < b )
|
||||
{
|
||||
QPainter p( viewport() );
|
||||
int top = ( ( rb <= t ) ? 0 : ( ( rb - t ) * fontHeight ) );
|
||||
int btm = ( ( re - t + 1 ) * fontHeight ) - top;
|
||||
|
||||
btm = btm > viewport()->height() ? viewport()->height() : btm;
|
||||
|
||||
QRect r( 0, top, viewport()->width(), btm );
|
||||
p.fillRect( r, QBrush( QColor( 255,255,0 ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void HBQPlainTextEdit::hbPaintSelection( QPaintEvent * event )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( event );
|
||||
|
||||
@@ -151,6 +151,7 @@ private:
|
||||
bool isSelectionByApplication;
|
||||
int hitTestRow;
|
||||
int hitTestColumn;
|
||||
QRect highlight;
|
||||
|
||||
|
||||
protected:
|
||||
@@ -202,12 +203,14 @@ public slots:
|
||||
void hbSetMatchBraces( bool all ){ m_matchBracesAll = all; };
|
||||
void hbGetViewportInfo();
|
||||
void hbApplyKey( int key, Qt::KeyboardModifiers modifiers = 0, const QString & txt = "" );
|
||||
void hbHighlightArea( int, int, int, int, int );
|
||||
|
||||
private slots:
|
||||
void hbSlotCursorPositionChanged();
|
||||
void hbUpdateLineNumberArea( const QRect &, int );
|
||||
void hbUpdateHorzRuler( const QRect &, int );
|
||||
void hbPaintSelection( QPaintEvent * );
|
||||
void hbPaintHighlight( QPaintEvent * );
|
||||
bool hbKeyPressSelection( QKeyEvent * );
|
||||
void hbClearSelection();
|
||||
void hbUpdateCaret();
|
||||
|
||||
@@ -818,6 +818,20 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBAPPLYKEY )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* void hbHighlightArea( int top, int left, int bottom, int right, int mode )
|
||||
*/
|
||||
HB_FUNC( QT_HBQPLAINTEXTEDIT_HBHIGHLIGHTAREA )
|
||||
{
|
||||
HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 );
|
||||
if( p )
|
||||
( p )->hbHighlightArea( hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ), hb_parni( 6 ) );
|
||||
else
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBHIGHLIGHTAREA FP=( p )->hbHighlightArea( hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ), hb_parni( 6 ) ); p is NULL" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#endif /* #if QT_VERSION >= 0x040500 */
|
||||
|
||||
@@ -114,6 +114,7 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit
|
||||
METHOD hbSetMatchBraces( lAll )
|
||||
METHOD hbGetViewportInfo()
|
||||
METHOD hbApplyKey( nKey, nModifiers, cTxt )
|
||||
METHOD hbHighlightArea( nTop, nLeft, nBottom, nRight, nMode )
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -314,3 +315,7 @@ METHOD HBQPlainTextEdit:hbGetViewportInfo()
|
||||
METHOD HBQPlainTextEdit:hbApplyKey( nKey, nModifiers, cTxt )
|
||||
RETURN Qt_HBQPlainTextEdit_hbApplyKey( ::pPtr, nKey, nModifiers, cTxt )
|
||||
|
||||
|
||||
METHOD HBQPlainTextEdit:hbHighlightArea( nTop, nLeft, nBottom, nRight, nMode )
|
||||
RETURN Qt_HBQPlainTextEdit_hbHighlightArea( ::pPtr, nTop, nLeft, nBottom, nRight, nMode )
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT )
|
||||
void hbSetMatchBraces( bool all )
|
||||
void hbGetViewportInfo()
|
||||
void hbApplyKey( int key, Qt::KeyboardModifiers modifiers = 0, const QString & txt )
|
||||
void hbHighlightArea( int top, int left, int bottom, int right, int mode )
|
||||
</SLOTS>
|
||||
|
||||
<SIGNALS>
|
||||
|
||||
Reference in New Issue
Block a user