diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4146a3622d..007eb7409f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,13 @@ The license applies to all entries newer than 2009-04-28. */ +2011-05-26 14:25 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/gtwvg/tests/wvgtbrowser.prg + * contrib/gtwvg/tests/wvgutilities.prg + * contrib/gtwvg/wvgclass.prg + + Implemented: scrollbars used along TbrowseWVG() in demowvg + as requested by Zoran. + 2011-05-25 21:13 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/idechangelog.prg % Advanced: more complete. You can play building the current entry. diff --git a/harbour/contrib/gtwvg/tests/wvgtbrowser.prg b/harbour/contrib/gtwvg/tests/wvgtbrowser.prg index cecc633d30..26cf0f2215 100644 --- a/harbour/contrib/gtwvg/tests/wvgtbrowser.prg +++ b/harbour/contrib/gtwvg/tests/wvgtbrowser.prg @@ -58,7 +58,7 @@ FUNCTION WvtMyBrowse() //----------------------------------------------------------------------// FUNCTION ExecBrowser( oCrt ) - LOCAL nKey, bBlock, oBrowse , aLastPaint, i, pGT + LOCAL nKey, bBlock, oBrowse , aLastPaint, i, pGT, oVBar, oHBar LOCAL cFileIndex, cFileDbf, cRDD, nIndex, oTBar, cScr, info_ LOCAL lEnd := .f. LOCAL aBlocks := {} @@ -139,6 +139,8 @@ FUNCTION ExecBrowser( oCrt ) aAdd( aBlocks, {|| Wvt_DrawGridHorz( oBrowse:nTop+3, oBrowse:nLeft, oBrowse:nRight, oBrowse:nBottom - oBrowse:nTop - 2 ) } ) aAdd( aBlocks, {|| Wvt_DrawGridVert( oBrowse:nTop, oBrowse:nBottom, oBrowse:aColumnsSep, len( oBrowse:aColumnsSep ) ) } ) + BuildScrollBars( oBrowse, @aBlocks, @oVBar, @oHBar ) + aLastPaint := WvtSetBlocks( aBlocks ) DispBox( 0, 0, maxrow(), maxcol(), " ", "N/W" ) @@ -150,7 +152,7 @@ FUNCTION ExecBrowser( oCrt ) While !lEnd oBrowse:ForceStable() - nKey := InKey( 0, INKEY_ALL + HB_INKEY_GTEVENT ) + nKey := InKey( 0, INKEY_ALL + HB_INKEY_GTEVENT ) do case case nKey == K_F12 @@ -167,12 +169,18 @@ FUNCTION ExecBrowser( oCrt ) case nKey == K_F7 hb_gtInfo( HB_GTI_RESIZABLE, .t. ) - case BrwHandleKey( oBrowse, nKey, @lEnd ) + case ( oVBar:HandleEvent( nKey ) .or. oHBar:HandleEvent( nKey ) ) + oBrowse:forceStable() + + case BrwHandleKey( oBrowse, nKey, @lEnd, oVBar, oHBar ) case nKey == HB_K_RESIZE oBrowse:nBottom := maxrow() - 3 oBrowse:nRight := maxcol() - 5 + oVBar:configure( oBrowse:nTop, oBrowse:nRight+1, oBrowse:nBottom, oBrowse:nRight+2 ) + oHBar:configure( oBrowse:nBottom+1, oBrowse:nLeft, oBrowse:nBottom+1, oBrowse:nRight ) + DispBox( 0, 0, maxrow(), maxcol(), " ", "N/W" ) DispOutAt( oBrowse:nTop-2, oBrowse:nleft, padc( cFileDbf, oBrowse:nRight - oBrowse:nLeft + 1 ), "W+/W" ) DispOutAt( maxrow(), 0, padc( ' ',maxcol()+1), 'B/W' ) @@ -276,7 +284,7 @@ STATIC FUNCTION VouBlockField( i ) //-------------------------------------------------------------------// -STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd ) +STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd, oVBar, oHBar ) LOCAL lRet := .t. do case @@ -334,14 +342,89 @@ STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd ) case nKey == K_MWFORWARD oBrowse:up() + case nKey == K_SBTHUMBTRACKVERT + OrdKeyGoTo( oVBar:GetPos() ) + oBrowse:refreshAll() + oBrowse:forceStable() + lRet := .f. + + case nKey == K_SBTHUMBTRACKHORZ + oBrowse:ColPos := oHBar:GetPos() + oBrowse:refreshAll() + oBrowse:forceStable() + lRet := .f. + + case nKey == K_SBLINEUP + oBrowse:up() + + case nKey == K_SBLINEDOWN + oBrowse:down() + + case nKey == K_SBPAGEUP + oBrowse:PageUp() + + case nKey == K_SBPAGEDOWN + oBrowse:PageDown() + + case nKey == K_SBLINELEFT + oBrowse:Left() + + case nKey == K_SBLINERIGHT + oBrowse:Right() + + case nKey == K_SBPAGELEFT + oBrowse:Left() + + case nKey == K_SBPAGERIGHT + oBrowse:right() + otherwise lRet := .f. endcase + IF lRet + oVBar:SetPos( OrdKeyCount(), OrdKeyNo() ) + oHBar:SetPos( oBrowse:ColCount, oBrowse:ColPos ) + ENDIF + RETURN lRet -//-------------------------------------------------------------------// +/*----------------------------------------------------------------------*/ + +STATIC FUNCTION BuildScrollbars( oBrw, aPaint, oVBar, oHBar ) + + oVBar := WvtScrollBar():New( oBrw, 999991, oBrw:nTop, oBrw:nRight+1, oBrw:nBottom, oBrw:nRight+2 ) + oVBar:nBarType := WVT_SCROLLBAR_VERT + oVBar:bTotal := {|| OrdKeyCount() } + oVBar:bCurrent := {|| OrdKeyNo() } + oVBar:aPxlBtnTop := { -2,2,0,0 } + oVBar:aPxlBtnBtm := { 0,2,2,0 } + oVBar:aPxlScroll := { 0,2,0,0 } + oVBar:Create() + + aadd( aPaint, oVBar:bBtnLeftTop ) + aadd( aPaint, oVBar:bBtnRightBottom ) + aadd( aPaint, oVBar:bBtnScroll ) + + oHBar := WvtScrollBar():New( oBrw, 999990, oBrw:nBottom+1, oBrw:nLeft, oBrw:nBottom+1, oBrw:nRight ) + oHBar:nBarType := 2 + oHBar:bTotal := {|| oBrw:ColCount } + oHBar:bCurrent := {|| oBrw:ColPos } + oHBar:aPxlBtnLft := { 2,-2,0,0 } + oHBar:aPxlBtnRgt := { 2, 0,0,2 } + oHBar:aPxlScroll := { 2, 0,0,0 } + oHBar:Create() + + aadd( aPaint, oHBar:bBtnLeftTop ) + aadd( aPaint, oHBar:bBtnRightBottom ) + aadd( aPaint, oHBar:bBtnScroll ) + + RETURN NIL + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ STATIC FUNCTION BrwOnEvent( oWvtBrw, cPaintID, oBrowse, nKey ) LOCAL lRet := .t., lRefAll := .f. diff --git a/harbour/contrib/gtwvg/tests/wvgutilities.prg b/harbour/contrib/gtwvg/tests/wvgutilities.prg index 2b53198e43..9fcd1069c2 100644 --- a/harbour/contrib/gtwvg/tests/wvgutilities.prg +++ b/harbour/contrib/gtwvg/tests/wvgutilities.prg @@ -507,3 +507,15 @@ FUNCTION GetResource( cName ) /*----------------------------------------------------------------------*/ +FUNCTION uiDebug( ... ) + LOCAL aP := hb_aParams() + LOCAL s := "" + + aeval( aP, {|e| s += hb_valTOstr( e ) + " " } ) + + WAPI_OutputDebugString( s ) + + RETURN NIL + +/*----------------------------------------------------------------------*/ + \ No newline at end of file diff --git a/harbour/contrib/gtwvg/wvgclass.prg b/harbour/contrib/gtwvg/wvgclass.prg index 5acad8da50..0dd8dd7371 100644 --- a/harbour/contrib/gtwvg/wvgclass.prg +++ b/harbour/contrib/gtwvg/wvgclass.prg @@ -796,19 +796,19 @@ CLASS WvtObject ASSIGN ToolTip( cTip ) INLINE ::cToolTip := cTip DATA bHandleEvent - DATA bOnCreate - DATA bOnSelect - DATA bOnFocus - DATA bOnRefresh - DATA bOnLeftUp - DATA bOnLeftDown - DATA bOnMMLeftDown - DATA bOnLeftPressed - DATA bTooltip - DATA bSaveSettings - DATA bRestSettings - DATA bOnHilite - DATA bOnDeHilite + DATA bOnCreate INIT {|| NIL } + DATA bOnSelect INIT {|| NIL } + DATA bOnFocus INIT {|| NIL } + DATA bOnRefresh INIT {|| NIL } + DATA bOnLeftUp INIT {|| NIL } + DATA bOnLeftDown INIT {|| NIL } + DATA bOnMMLeftDown INIT {|| NIL } + DATA bOnLeftPressed INIT {|| NIL } + DATA bTooltip INIT {|| NIL } + DATA bSaveSettings INIT {|| NIL } + DATA bRestSettings INIT {|| NIL } + DATA bOnHilite INIT {|| NIL } + DATA bOnDeHilite INIT {|| NIL } ACCESS nChildren INLINE len( ::aChildren ) DATA nIndexOrder @@ -2522,8 +2522,7 @@ METHOD wvtScrollbar:Create() ::bBtnRightBottom := ; {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnRgt,4 ) } ::bBtnScroll := ; - {|| Wvt_DrawScrollThumbHorz( ::nSTop,::nSLeft,::nSBottom,::nSRight,; - ::aPxlScroll,::nThumbPos ) } + {|| Wvt_DrawScrollThumbHorz( ::nSTop,::nSLeft,::nSBottom,::nSRight, ::aPxlScroll,::nThumbPos ) } ::bBtnLeftTopDep := ; {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnLft,2,.t. ) } ::bBtnRightBottomDep := ; @@ -2552,7 +2551,57 @@ METHOD wvtScrollbar:Configure( nTop, nLeft, nBottom, nRight ) ::nBottom := nBottom ::nRight := nRight - ::Create() + IF ::nBarType == WVT_SCROLLBAR_VERT + ::nRight := ::nLeft + 1 + ::nBottom := max( 7, ::nBottom ) + + ::nBtn1Top := ::nTop + ::nBtn1Left := ::nLeft + ::nBtn1Bottom := ::nTop + ::nBtn1Right := ::nRight + + ::nBtn2Top := ::nBottom + ::nBtn2Left := ::nLeft + ::nBtn2Bottom := ::nBottom + ::nBtn2Right := ::nRight + + ::nSTop := ::nTop + 1 + ::nSLeft := ::nLeft + ::nSBottom := ::nBottom - 1 + ::nSRight := ::nRight + + ::nScrollUnits := ::nSBottom - ::nSTop + 1 + + ::nTotal := Eval( ::bTotal ) + ::nCurrent := Eval( ::bCurrent ) + ::ThumbPos() + ELSE + ::nBottom := ::nTop + ::nRight := max( 11, ::nRight ) + + ::nBtn1Top := ::nTop + ::nBtn1Left := ::nLeft + ::nBtn1Bottom := ::nBottom + ::nBtn1Right := ::nLeft + 1 + + ::nBtn2Top := ::nTop + ::nBtn2Left := ::nRight - 1 + ::nBtn2Bottom := ::nBottom + ::nBtn2Right := ::nRight + + ::nSTop := ::nTop + ::nSLeft := ::nLeft + 2 + ::nSBottom := ::nBottom + ::nSRight := ::nRight - 2 + + ::nScrollUnits := ::nSRight - ::nSLeft + 1 + + ::nTotal := Eval( ::bTotal ) + ::nCurrent := Eval( ::bCurrent ) + + ::ThumbPos() + ENDIF + ::Refresh() RETURN Self