From aa83980736583b34d54c3bf217b8689a3982b9c2 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 24 Nov 2009 22:26:30 +0000 Subject: [PATCH] 2009-11-24 14:20 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbxbp/xbplistbox.prg + contrib/hbide/resources/zoomin.png + contrib/hbide/resources/zoomout.png * contrib/hbide/ideactions.prg * contrib/hbide/idemisc.prg * contrib/hbide/hbide.prg + Added ZoomIn, ZoomOut toolbar buttons for in-place zoom-in/out text decoration. Very handy visualization. + Implemented undo/redo/cut/copy/paste/select all/to upper/to lower/invert case/ icons. ! Fixed many artifacts. Please play with the tool and report back your experiences. --- harbour/ChangeLog | 16 ++ harbour/contrib/hbide/hbide.prg | 232 ++++++++++++++------ harbour/contrib/hbide/ideactions.prg | 21 +- harbour/contrib/hbide/idemisc.prg | 4 +- harbour/contrib/hbide/resources/zoomin.png | Bin 0 -> 235 bytes harbour/contrib/hbide/resources/zoomout.png | Bin 0 -> 232 bytes harbour/contrib/hbxbp/xbplistbox.prg | 2 +- 7 files changed, 197 insertions(+), 78 deletions(-) create mode 100644 harbour/contrib/hbide/resources/zoomin.png create mode 100644 harbour/contrib/hbide/resources/zoomout.png diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e84b80bcb1..ad93e0e7b6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,22 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-11-24 14:20 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbxbp/xbplistbox.prg + + + contrib/hbide/resources/zoomin.png + + contrib/hbide/resources/zoomout.png + + * contrib/hbide/ideactions.prg + * contrib/hbide/idemisc.prg + * contrib/hbide/hbide.prg + + Added ZoomIn, ZoomOut toolbar buttons for in-place zoom-in/out + text decoration. Very handy visualization. + + Implemented undo/redo/cut/copy/paste/select all/to upper/to lower/invert case/ icons. + ! Fixed many artifacts. + + Please play with the tool and report back your experiences. + 2009-11-24 16:57 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/fscopy.c ! Fixed to use the same file opening method as in __COPYFILE(). diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index c5a2bb55bd..3ba45a6187 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -121,6 +121,7 @@ CLASS HbIde DATA qSplitterL DATA qSplitterR DATA qTabWidget + ACCESS qCurEdit INLINE iif( ::getCurrentTab() > 0, ::aTabs[ ::getCurrentTab(), 2 ], NIL ) /* XBP Objects */ DATA oDlg @@ -149,8 +150,8 @@ CLASS HbIde DATA oDlls DATA aProjData INIT {} - DATA lDockRVisible INIT .t. - DATA lDockBVisible INIT .t. + DATA lDockRVisible INIT .f. + DATA lDockBVisible INIT .f. DATA lTabCloseRequested INIT .f. METHOD new( cProjectOrSource ) @@ -195,6 +196,8 @@ CLASS HbIde METHOD createTags() METHOD loadUI() + METHOD manageFocusInEditor() + METHOD convertSelection() ENDCLASS @@ -322,11 +325,10 @@ METHOD HbIde:create( cProjectOrSource ) ELSEIF ( ::nEvent == xbeP_Keyboard .and. ::mp1 == xbeK_ESC ) ::closeSource() - #if 0 IF ::qTabWidget:count() == 0 - EXIT + ::oDockR:hide() + ::lDockRVisible := .f. ENDIF - #endif ENDIF ::oXbp:handleEvent( ::nEvent, ::mp1, ::mp2 ) @@ -341,6 +343,144 @@ METHOD HbIde:create( cProjectOrSource ) /*----------------------------------------------------------------------*/ +METHOD HbIde:executeAction( cKey ) + LOCAL cFile + + DO CASE + + CASE cKey == "Exit" + PostAppEvent( xbeP_Close, NIL, NIL, ::oDlg ) + + CASE cKey == "NewProject" + ::fetchNewProject() + + CASE cKey == "Open" + IF !empty( cFile := ::selectSource( "open" ) ) + ::oProjRoot:addItem( cFile ) + ::editSource( cFile ) + ENDIF + + CASE cKey == "Save" + ::saveSource( ::getCurrentTab(), .f. ) + + CASE cKey == "Close" + ::closeSource() + + CASE cKey == "Undo" + IF !empty( ::qCurEdit ) + ::qCurEdit:undo() + ENDIF + CASE cKey == "Redo" + IF !empty( ::qCurEdit ) + ::qCurEdit:redo() + ENDIF + CASE cKey == "Cut" + IF !empty( ::qCurEdit ) + ::qCurEdit:cut() + ENDIF + CASE cKey == "Copy" + IF !empty( ::qCurEdit ) + ::qCurEdit:copy() + ENDIF + CASE cKey == "Paste" + IF !empty( ::qCurEdit ) + ::qCurEdit:paste() + ENDIF + CASE cKey == "SelectAll" + IF !empty( ::qCurEdit ) + ::qCurEdit:selectAll() + ENDIF + CASE cKey == "ToUpper" + ::convertSelection( cKey ) + CASE cKey == "ToLower" + ::convertSelection( cKey ) + CASE cKey == "Invert" + ::convertSelection( cKey ) + CASE cKey == "ZoomIn" + IF !empty( ::qCurEdit ) + ::qCurEdit:zoomIn() + ENDIF + CASE cKey == "ZoomOut" + IF !empty( ::qCurEdit ) + ::qCurEdit:zoomOut() + ENDIF + + CASE cKey == "11" + IF ::lDockBVisible + ::oDockB:hide() + ::oDockB1:hide() + ::oDockB2:hide() + ::lDockBVisible := .f. + ELSEIF ::qTabWidget:count() > 0 + ::oDockB:show() + ::oDockB1:show() + ::oDockB2:show() + ::lDockBVisible := .t. + ENDIF + + CASE cKey == "12" + IF ::lDockRVisible + ::oDockR:hide() + ELSE + ::oDockR:show() + ENDIF + ::lDockRVisible := !( ::lDockRVisible ) + + ENDCASE + + ::manageFocusInEditor() + + RETURN nil + +/*----------------------------------------------------------------------*/ + +METHOD HbIde:convertSelection( cKey ) + LOCAL qCursor, cBuffer, i, s, nLen, c + //LOCAL nB, nE + + IF !empty( ::qCurEdit ) + qCursor := QTextCursor():configure( ::qCurEdit:textCursor() ) + IF qCursor:hasSelection() .and. !empty( cBuffer := qCursor:selectedText() ) + DO CASE + CASE cKey == "ToUpper" + cBuffer := upper( cBuffer ) + CASE cKey == "ToLower" + cBuffer := lower( cBuffer ) + CASE cKey == "Invert" + s := "" + nLen := len( cBuffer ) + FOR i := 1 TO nLen + c := substr( cBuffer, i, 1 ) + s += IF( isUpper( c ), lower( c ), upper( c ) ) + NEXT + cBuffer := s + ENDCASE + //nB := qCursor:selectionStart() + //nE := qCursor:selectionEnd() + qCursor:removeSelectedText() + //qCursor:beginEditBlock() + qCursor:insertText( cBuffer ) + //qCursor:select( QTextCursor_BlockUnderCursor ) + //qCursor:endEditBlock() + //qCursor:setPosition( nB-len(cBuffer)+1, QTextCursor_MoveAnchor ) + //::qCurEdit:find( cBuffer ) + ENDIF + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD HbIde:manageFocusInEditor() + + IF ::getCurrentTab() > 0 + ::aTabs[ ::getCurrentTab(), 2 ]:setFocus() + ENDIF + + RETURN self + +/*----------------------------------------------------------------------*/ + METHOD HbIde:updateFuncList() ::oFuncList:clear() @@ -415,6 +555,7 @@ METHOD HbIde:editSource( cSourceFile ) ::aSources := { cSourceFile } ::createTags() ::updateFuncList() + ::manageFocusInEditor() RETURN Self @@ -461,6 +602,7 @@ METHOD HbIde:closeSource() LOCAL nTab IF !empty( nTab := ::getCurrentTab() ) + ::oFuncList:clear() ::saveSource( nTab ) /* Destroy at Qt level */ ::qTabWidget:removeTab( ::qTabWidget:currentIndex() ) @@ -626,55 +768,6 @@ METHOD HbIde:buildProjectTree() /*----------------------------------------------------------------------*/ -METHOD HbIde:executeAction( cKey ) - LOCAL cFile - - DO CASE - - CASE cKey == "Exit" - PostAppEvent( xbeP_Close, NIL, NIL, ::oDlg ) - - CASE cKey == "NewProject" - ::fetchNewProject() - - CASE cKey == "Open" - IF !empty( cFile := ::selectSource( "open" ) ) - ::oProjRoot:addItem( cFile ) - ::editSource( cFile ) - ENDIF - - CASE cKey == "Save" - ::saveSource( ::getCurrentTab(), .f. ) - - CASE cKey == "Close" - ::closeSource() - - CASE cKey == "11" - IF ::lDockBVisible - ::oDockB:hide() - ::oDockB1:hide() - ::oDockB2:hide() - ELSE - ::oDockB:show() - ::oDockB1:show() - ::oDockB2:show() - ENDIF - ::lDockBVisible := !( ::lDockBVisible ) - - CASE cKey == "12" - IF ::lDockRVisible - ::oDockR:hide() - ELSE - ::oDockR:show() - ENDIF - ::lDockRVisible := !( ::lDockRVisible ) - - ENDCASE - - RETURN nil - -/*----------------------------------------------------------------------*/ - METHOD HbIde:buildStatusBar() LOCAL oPanel @@ -732,7 +825,9 @@ METHOD HbIde:manageProjectContext( mp1 ) aadd( aPops, { ::oCurProjItem:caption, {|| NIL } } ) aadd( aPops, { ::oCurProjItem:caption, {|| NIL } } ) - ExecPopup( aPops, mp1 ) + ExecPopup( aPops, mp1, ::oProjTree:oWidget ) + + ::manageFocusInEditor() ENDIF RETURN Self @@ -742,14 +837,17 @@ METHOD HbIde:manageProjectContext( mp1 ) METHOD HbIde:manageFuncContext( mp1 ) LOCAL aPops := {} - aadd( aPops, { 'Comment out' , {|| NIL } } ) - aadd( aPops, { 'Reformat' , {|| NIL } } ) - aadd( aPops, { 'Print' , {|| NIL } } ) - aadd( aPops, { 'Delete' , {|| NIL } } ) - aadd( aPops, { 'Move to another source', {|| NIL } } ) + IF ::oFuncList:numItems() > 0 + aadd( aPops, { 'Comment out' , {|| NIL } } ) + aadd( aPops, { 'Reformat' , {|| NIL } } ) + aadd( aPops, { 'Print' , {|| NIL } } ) + aadd( aPops, { 'Delete' , {|| NIL } } ) + aadd( aPops, { 'Move to another source', {|| NIL } } ) - ExecPopup( aPops, mp1 ) + ExecPopup( aPops, mp1, ::oFuncList:oWidget ) + ::manageFocusInEditor() + ENDIF RETURN Self /*----------------------------------------------------------------------*/ @@ -768,7 +866,7 @@ METHOD HbIde:buildFuncList() ::oFuncList := XbpListBox():new( ::oDockR ):create( , , { 0,0 }, { 100,400 }, , .t. ) ::oFuncList:setStyleSheet( GetStyleSheet( "QListView" ) ) - ::oFuncList:setColorBG( GraMakeRGBColor( { 210,120,220 } ) ) + //::oFuncList:ItemMarked := {|mp1, mp2, oXbp| ::gotoFunction( mp1, mp2, oXbp ) } ::oFuncList:ItemSelected := {|mp1, mp2, oXbp| ::gotoFunction( mp1, mp2, oXbp ) } /* Harbour Extension : prefixed with "hb" */ @@ -779,7 +877,7 @@ METHOD HbIde:buildFuncList() ::oDockR:oWidget:setWidget( QT_PTROFXBP( ::oFuncList ) ) ::oDlg:oWidget:addDockWidget_1( Qt_RightDockWidgetArea, QT_PTROFXBP( ::oDockR ), Qt_Horizontal ) - //::oDockR:hide() + ::oDockR:hide() RETURN Self @@ -814,7 +912,7 @@ METHOD HbIde:buildCompileResults() ::oDockB:oWidget:setWidget( QT_PTROFXBP( ::oCompileResult ) ) ::oDlg:oWidget:addDockWidget_1( Qt_BottomDockWidgetArea, QT_PTROFXBP( ::oDockB ), Qt_Vertical ) - //::oDockB:hide() + ::oDockB:hide() RETURN Self @@ -836,7 +934,7 @@ METHOD HbIde:buildLinkResults() ::oDockB1:oWidget:setWidget( QT_PTROFXBP( ::oLinkResult ) ) ::oDlg:oWidget:addDockWidget_1( Qt_BottomDockWidgetArea, QT_PTROFXBP( ::oDockB1 ), Qt_Vertical ) - //::oDockB1:hide() + ::oDockB1:hide() RETURN Self @@ -858,7 +956,7 @@ METHOD HbIde:buildOutputResults() ::oDockB2:oWidget:setWidget( QT_PTROFXBP( ::oOutputResult ) ) ::oDlg:oWidget:addDockWidget_1( Qt_BottomDockWidgetArea, QT_PTROFXBP( ::oDockB2 ), Qt_Vertical ) - //::oDockB2:hide() + ::oDockB2:hide() RETURN Self @@ -939,6 +1037,8 @@ METHOD HbIde:fetchNewProject() nRet := oDlg:oWidget:exec() + JustACall( nRet ) + HBXBP_DEBUG( "Done", nRet ) oDlg:destroy() diff --git a/harbour/contrib/hbide/ideactions.prg b/harbour/contrib/hbide/ideactions.prg index 8474620f96..c377719bbf 100644 --- a/harbour/contrib/hbide/ideactions.prg +++ b/harbour/contrib/hbide/ideactions.prg @@ -98,13 +98,13 @@ FUNCTION buildToolBar( oWnd, oIde ) oTBar:addItem( "Module Function List" , cResPath + "modulelist.png" , , , , , "12" ) // oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) - oTBar:addItem( "Undo" , cResPath + "undo.png" , , , , , "13" ) - oTBar:addItem( "Redo" , cResPath + "redo.png" , , , , , "14" ) + oTBar:addItem( "Undo" , cResPath + "undo.png" , , , , , "Undo" ) + oTBar:addItem( "Redo" , cResPath + "redo.png" , , , , , "Redo" ) oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) - oTBar:addItem( "Cut" , cResPath + "cut.png" , , , , , "15" ) - oTBar:addItem( "Copy" , cResPath + "copy.png" , , , , , "16" ) - oTBar:addItem( "Paste" , cResPath + "paste.png" , , , , , "17" ) - oTBar:addItem( "Select All" , cResPath + "selectall.png" , , , , , "18" ) + oTBar:addItem( "Cut" , cResPath + "cut.png" , , , , , "Cut" ) + oTBar:addItem( "Copy" , cResPath + "copy.png" , , , , , "Copy" ) + oTBar:addItem( "Paste" , cResPath + "paste.png" , , , , , "Paste" ) + oTBar:addItem( "Select All" , cResPath + "selectall.png" , , , , , "SelectAll" ) oTBar:addItem( "Column/Stream Selection" , cResPath + "stream.png" , , , , , "19" ) oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) oTBar:addItem( "Find" , cResPath + "find.png" , , , , , "20" ) @@ -114,11 +114,14 @@ FUNCTION buildToolBar( oWnd, oIde ) oTBar:addItem( "Goto Mark" , cResPath + "gotomark.png" , , , , , "23" ) oTBar:addItem( "Goto Line" , cResPath + "gotoline.png" , , , , , "24" ) oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) - oTBar:addItem( "To Upper" , cResPath + "toupper.png" , , , , , "25" ) - oTBar:addItem( "To Lower" , cResPath + "tolower.png" , , , , , "26" ) - oTBar:addItem( "Invert Case" , cResPath + "invertcase.png" , , , , , "27" ) + oTBar:addItem( "To Upper" , cResPath + "toupper.png" , , , , , "ToUpper" ) + oTBar:addItem( "To Lower" , cResPath + "tolower.png" , , , , , "ToLower" ) + oTBar:addItem( "Invert Case" , cResPath + "invertcase.png" , , , , , "Invert" ) oTBar:addItem( "Match Pairs" , cResPath + "matchobj.png" , , , , , "28" ) oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) + oTBar:addItem( "ZoomIn" , cResPath + "zoomin.png" , , , , , "ZoomIn" ) + oTBar:addItem( "ZoomOut" , cResPath + "zoomout.png" , , , , , "ZoomOut" ) + oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) oTBar:transparentColor := GraMakeRGBColor( { 0,255,255 } ) // GRA_CLR_INVALID oTBar:buttonClick := {|oButton| oIde:executeAction( oButton:key ) } diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index abd65f2c4b..9095cd1922 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -79,10 +79,10 @@ PROCEDURE JustACall() /*----------------------------------------------------------------------*/ -FUNCTION ExecPopup( aPops, aPos ) +FUNCTION ExecPopup( aPops, aPos, qParent ) LOCAL i, qPop, qPoint, qAct, nAct, cAct, xRet, pAct - qPop := QMenu():new() + qPop := QMenu():new( IF( hb_isObject( qParent ), QT_PTROF( qParent ), NIL ) ) FOR i := 1 TO len( aPops ) qPop:addAction( aPops[ i, 1 ] ) diff --git a/harbour/contrib/hbide/resources/zoomin.png b/harbour/contrib/hbide/resources/zoomin.png new file mode 100644 index 0000000000000000000000000000000000000000..fe4d7f215c10378563b193077bb5587e8a6c80f6 GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5he4R}c>anMpx|6j z7sn8b-ldZ+@-`T7xL9{Bw%}T9;N_lZyyb;t*U=+lhuRyfSr=yf{1z2@)AjeapCKAW z+)MZyqU_jTgtBxCGz2w>vL0~DcUbNDyidQ1VZj{6KW|#~Hu6VsMZ9}3(~x10qWv9) zu#QC;KgE3Z&c7KubEmyRiEv-0hL{!Ok!zeT5z$jGs`edum|`3+Bz+*SD(DYGM$nzV fE))Mhdd41*v~gTe~DWM4ftK?Yy literal 0 HcmV?d00001 diff --git a/harbour/contrib/hbide/resources/zoomout.png b/harbour/contrib/hbide/resources/zoomout.png new file mode 100644 index 0000000000000000000000000000000000000000..a158ac58a984e72dbe14c51ec0197ce24b1a6997 GIT binary patch literal 232 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5he4R}c>anMpx`V| z7sn8b-no-*3N|S4uYY%| z_+<8