From d172b689ab29ee8e4ddec2863310483abb679fbf Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Wed, 15 Jul 2009 02:15:18 +0000 Subject: [PATCH] 2009-07-14 19:06 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbxbp/xbpfontdialog.prg * contrib/hbxbp/xbprtf.prg + Implemented :print( oXbpPrinter, lOnlySelection ) in XbpRTF() class. TODO: is not functional yet. + Implemented :selFont GETSET METHOD - Harbour Extension - this accepts XbpFont() object as new font. * contrib/hbxbp/tests/demoxbp.prg + Demonstrated the use of XbpFontDialog() with XbpRTF(). 1. Click on tab. 2. Select some text. 3. Click on Push Button - it will open Font Dialog on the left-top corner. 4. Move around in the font dialog, select every factor available, change it, you will see the effects on selected text in . --- harbour/ChangeLog | 16 +++++++++++ harbour/contrib/hbxbp/tests/demoxbp.prg | 38 +++++++++++++++++++++++-- harbour/contrib/hbxbp/xbpfontdialog.prg | 5 ++++ harbour/contrib/hbxbp/xbprtf.prg | 36 +++++++++++++++++++---- 4 files changed, 88 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 17cf090d21..d66c4129dd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,22 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-14 19:06 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbxbp/xbpfontdialog.prg + * contrib/hbxbp/xbprtf.prg + + Implemented :print( oXbpPrinter, lOnlySelection ) in XbpRTF() class. + TODO: is not functional yet. + + Implemented :selFont GETSET METHOD - Harbour Extension - this accepts + XbpFont() object as new font. + + * contrib/hbxbp/tests/demoxbp.prg + + Demonstrated the use of XbpFontDialog() with XbpRTF(). + 1. Click on tab. + 2. Select some text. + 3. Click on Push Button - it will open Font Dialog on the left-top corner. + 4. Move around in the font dialog, select every factor available, change it, + you will see the effects on selected text in . + 2009-07-15 03:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/pp/Makefile * config/hpux/global.cf diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index b4cf36cfa4..62277fb666 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -1234,6 +1234,8 @@ FUNCTION Build_Rtf( oWnd ) LOCAL sz_:= oWnd:currentSize() LOCAL nW := 50, nG := 8, nH := 20, nT := sz_[2]-55 + //--------------------------------// + oBtn := XbpPushButton():new( oWnd, , {10+(nW+nG)*0, nT}, {nW,nH} ) oBtn:caption := 'Image' oBtn:create() @@ -1266,6 +1268,8 @@ FUNCTION Build_Rtf( oWnd ) oBtn:create() oBtn:activate := {|| oRtf:selItalic := .t. } + //-----------------------------------// + oBtn := XbpPushButton():new( oWnd, , {10+(nW+nG)*0, nT-25}, {nW,nH} ) oBtn:caption := 'Load' oBtn:create() @@ -1286,9 +1290,28 @@ FUNCTION Build_Rtf( oWnd ) oBtn:create() oBtn:activate := {|x| x := oRTF:selFontSize, IF( x == 0, x := 11, ), oRTF:selFontSize := x-1 } - //------------------------// + oBtn := XbpPushButton():new( oWnd, , {10+(nW+nG)*4, nT-25}, {nW,nH} ) + oBtn:caption := 'Print' + oBtn:create() + oBtn:activate := {|| oRTF:print( , .t. ) } + + oBtn := XbpPushButton():new( oWnd, , {10+(nW+nG)*5, nT-25}, {nW,nH} ) + oBtn:caption := 'Replace' + oBtn:create() + oBtn:activate := {|x| x := oRTF:selText, oRTF:selText := "Harbour" } + + //-----------------------------------// + + oBtn := XbpPushButton():new( oWnd, , {10+(nW+nG)*0, nT-50}, {nW,nH} ) + oBtn:caption := 'Font' + oBtn:create() + oBtn:activate := {|| RtfApplyFont( oRtf ) } + + + + //-----------------------------------// oRTF := XbpRtf():new( oWnd ) - oRTF:create( , , { 10,10 }, { sz_[ 1 ]-23, sz_[ 2 ]-100 } ) + oRTF:create( , , { 10,10 }, { sz_[ 1 ]-23, sz_[ 2 ]-125 } ) oRTF:setColorBG( GraMakeRGBColor( {255,255,200} ) ) oRTF:setFontCompoundName( "12.Times" ) @@ -1396,3 +1419,14 @@ STATIC FUNCTION RtfSaveDocument( oRTF ) /*----------------------------------------------------------------------*/ +STATIC FUNCTION RtfApplyFont( oRTF ) + LOCAL oDlg + + oDlg := XbpFontDialog():new( oRTF, , , , { 20,20 } ) + oDlg:create() + oDlg:activateApply := {|oFont| oRTF:selFont := oFont } + oDlg:display( 0 ) + + RETURN nil + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpfontdialog.prg b/harbour/contrib/hbxbp/xbpfontdialog.prg index 5bc19ca02a..dcda1d8acf 100644 --- a/harbour/contrib/hbxbp/xbpfontdialog.prg +++ b/harbour/contrib/hbxbp/xbpfontdialog.prg @@ -232,6 +232,11 @@ METHOD XbpFontDialog:exeBlock( nEvent, p1 ) ELSE ::oWidget:accept() ENDIF + + CASE nEvent == 4 /* SIMULATE sl_activateApply for timebeing */ + IF hb_isBlock( ::sl_activateApply ) + eval( ::sl_activateApply, ::XbpFontObject(), NIL, self ) + ENDIF ENDCASE RETURN nRet diff --git a/harbour/contrib/hbxbp/xbprtf.prg b/harbour/contrib/hbxbp/xbprtf.prg index 118e92b7f3..f08737b155 100644 --- a/harbour/contrib/hbxbp/xbprtf.prg +++ b/harbour/contrib/hbxbp/xbprtf.prg @@ -134,7 +134,7 @@ CLASS XbpRtf INHERIT XbpWindow METHOD redo() METHOD insertText( cText ) METHOD insertImage( cImageFile ) - + METHOD selFont SETGET /**/ DATA sl_xbeRTF_Change @@ -328,9 +328,15 @@ METHOD XbpRtf:paste() METHOD XbpRtf:print( oXbpPrinter, lOnlySelection ) - HB_SYMBOL_UNUSED( oXbpPrinter ) - HB_SYMBOL_UNUSED( lOnlySelection ) + IF !hb_isObject( oXbpPrinter ) + oXbpPrinter := XbpPrinter():new():create() + ENDIF + IF hb_isLogical( lOnlySelection ) .and. lOnlySelection + ::oWidget:print( QT_PTROF( oXbpPrinter:oWidget ) ) + ELSE + ::oWidget:print( QT_PTROF( oXbpPrinter:oWidget ) ) + ENDIF RETURN Self /*----------------------------------------------------------------------*/ @@ -469,6 +475,22 @@ METHOD XbpRtf:selColor( ... ) ENDIF RETURN xRet +/*----------------------------------------------------------------------*/ +// This is Harour Extension +// +METHOD XbpRtf:selFont( ... ) // "" + LOCAL xRet := NIL + LOCAL aP := hb_aParams() + + IF len( aP ) >= 1 .and. hb_isObject( aP[ 1 ] ) + ::oTextCharFormat:pPtr := ::oCurCursor:charFormat() + IF ::oTextCharFormat:isValid() + ::oTextCharFormat:setFont( QT_PTROF( aP[ 1 ]:oWidget ) ) + ::oCurCursor:setCharFormat( QT_PTROF( ::oTextCharFormat ) ) + ENDIF + ENDIF + RETURN xRet + /*----------------------------------------------------------------------*/ METHOD XbpRtf:selFontName( ... ) // "" @@ -617,8 +639,12 @@ METHOD XbpRtf:selText( ... ) // "" LOCAL xRet := "" LOCAL aP := hb_aParams() - IF len( aP ) >= 1 - + IF( ::oCurCursor:hasSelection() ) + xRet := ::oCurCursor:selectedText() + ENDIF + IF len( aP ) >= 1 .and. hb_isChar( aP[ 1 ] ) + ::oCurCursor:removeSelectedText() + ::oCurCursor:insertText( aP[ 1 ] ) ENDIF RETURN xRet