Page 1 of 1

Para Antonio: xBrowse nFreeze (APORTE)

PostPosted: Sun May 19, 2013 12:10 am
by FranciscoA
Antonio.
Vista la necesidad de un colega, expuesta aquí en el foro, y, por supuesto, la mía propia, viewtopic.php?f=6&t=26312#p144716 , me he puesto a trabajar en una solución, la cual creo que he encontrado.

La he probado bastante y no me ha dado ninguna falla.
Ahora el Method GoLeft() Class TXBrowse, detecta si se está utilizando columnas congeladas, y se comporta como lo necesitamos. Si al avanzar hacia la derecha, se ocultan columnas por las congeladas, al regresar hacia la izquierda y llegar a la primer columna despues de la nFreezed y se continua avanzando hacia la izquierda, van apareciendo las ocultas, mientras el cursor se mantiene en la misma columna, hasta que aparece la No. 1 despues de las congeladas, y hasta entonces continua avanzando sobre las congeladas. Aqui el codigo original, y el modificado por tu servidor.

//----------------------------------------------------------------------------//
/*
METHOD GoLeft( lOffset, lRefresh ) CLASS TXBrowse

::CancelEdit()

if ::nMarqueeStyle == MARQSTYLE_NOMARQUEE .or. ( ::nMarqueeStyle >= MARQSTYLE_HIGHLROW .and. ::bClrRowFocus == nil )
lOffset := .t.
endif

DEFAULT lOffset := .f.,;
lRefresh := .t.

if ( !lOffset .and. ::IsDisplayPosVisible( ::nColSel - 1 ) ) .or. ;
( ::nColOffset == 1 .and. ::nColSel > 1 )
::nColSel--
if lRefresh
if ::FullPaint()
::Super:Refresh( .t. )
else
::DrawLine( .t. )
endif
endif
elseif ::nColOffset > 1
::nColOffset--
::GetDisplayCols()
if lRefresh
::Super:Refresh( ::FullPaint() )
endif
endif

if ::oHScroll != nil
::oHScroll:GoUp()
endif
::Change( .f. )

return nil
*/


Code: Select all  Expand view
//-----------------------------------------------------
//Method GoLeft() modified by Francisco J. Alegría P. - May 18, 2013
//------------------------------------------------------
METHOD GoLeft( lOffset, lRefresh )  CLASS TXBrowse
local oFirstCol

   ::CancelEdit()

   if ::nMarqueeStyle == MARQSTYLE_NOMARQUEE  .or. ( ::nMarqueeStyle >= MARQSTYLE_HIGHLROW .and. ::bClrRowFocus == nil ) ;
      .or. ::nFreeze > 0
      lOffset := .t.
   endif

   DEFAULT lOffset  := .f.,;
           lRefresh := .t.

IF !lOffset

   if ( ::IsDisplayPosVisible( ::nColSel - 1 ) ) .or. ;
      ( ::nColOffset == 1 .and. ::nColSel > 1 )
      ::nColSel--
      if lRefresh
         if ::FullPaint()
            ::Super:Refresh( .t. )
         else
            ::DrawLine( .t. )
         endif
      endif
   elseif ::nColOffset > 1
      ::nColOffset--
      ::GetDisplayCols()
      if lRefresh
         ::Super:Refresh( ::FullPaint() )
      endif
   endif

ELSE

   if ::SelectedCol():nCreationOrder == 1
      return nil
   endif

   oFirstCol := if ( ::nFreeze > 0, ::aCols[::nFreeze+1], ::aCols[1] )

   if ::IsDisplayPosVisible( oFirstCol:nPos, .t. )
      ::nColSel--
      if lRefresh
         ::Super:Refresh( .t. )
      endif

   else
      ::nColSel--
      if lRefresh
         ::Super:Refresh( .t. )
      endif

      if ::nColSel == ::nFreeze
         ::GoRight()
         ::nColOffSet--
         ::GetDisplayCols()
         if lRefresh
            ::Super:Refresh( ::FullPaint() )
         endif
         if ::oHScroll != nil
            ::oHScroll:GoUp()
         endif
      endif
   endif

ENDIF

   if ::oHScroll != nil
      ::oHScroll:GoUp()
   endif
   ::Change( .f. )

return nil
 

Espero que sea de utilidad.
Saludos.

Re: Para Antonio: xBrowse nFreeze (APORTE)

PostPosted: Sun May 19, 2013 3:02 pm
by rolando
Francisco,

Muy bueno lo tuyo.

Lo probé en mi sistema y funciona bien en casi todos los casos.

Pero tengo un xBrowse de 5 columnas en el cual hago un freeze en la columna 5 (para que no se vaya del dialog por recursos al darle a la flechita derecha).

Ahí daba un error cuando se quería volver hacia la izquierda (le suma 1 a la columna cuando ::nFreeze > 0 y, justo el freeze está en la última columna del xBrowse).

Le hice una pequeña reforma a lo tuyo y pongo a tu consideración, acá me funciona correcto.

Code: Select all  Expand view
//  oFirstCol := if ( ::nFreeze > 0, ::aCols[::nFreeze+1], ::aCols[1] )

     oFirstCol := if ( ::nFreeze > 0 .and. ::nFreeze<len(::aCols), ::aCols[::nFreeze+1], ::aCols[1] )


Saludos.

Rolando :D

Re: Para Antonio: xBrowse nFreeze (APORTE)

PostPosted: Sun May 19, 2013 8:19 pm
by FranciscoA
Rolando,
Es correcto. He integrado tu modificacion.
Code: Select all  Expand view
//-----------------------------------------------------
//Method GoLeft() modified by Francisco J. Alegría P. - May 18, 2013
//------------------------------------------------------
METHOD GoLeft( lOffset, lRefresh )  CLASS TXBrowse
local oFirstCol

   ::CancelEdit()

   if ::nMarqueeStyle == MARQSTYLE_NOMARQUEE  .or. ( ::nMarqueeStyle >= MARQSTYLE_HIGHLROW .and. ::bClrRowFocus == nil ) ;
      .or. ::nFreeze > 0
      lOffset := .t.
   endif

   DEFAULT lOffset  := .f.,;
           lRefresh := .t.

IF !lOffset

   if ( ::IsDisplayPosVisible( ::nColSel - 1 ) ) .or. ;
      ( ::nColOffset == 1 .and. ::nColSel > 1 )
      ::nColSel--
      if lRefresh
         if ::FullPaint()
            ::Super:Refresh( .t. )
         else
            ::DrawLine( .t. )
         endif
      endif
   elseif ::nColOffset > 1
      ::nColOffset--
      ::GetDisplayCols()
      if lRefresh
         ::Super:Refresh( ::FullPaint() )
      endif
   endif

ELSE

   if ::SelectedCol():nCreationOrder == 1
      return nil
   endif

   //oFirstCol := if ( ::nFreeze > 0, ::aCols[::nFreeze+1], ::aCols[1] )
   oFirstCol := if ( ::nFreeze > 0 .and. ::nFreeze < len(::aCols), ::aCols[::nFreeze+1], ::aCols[1] )  //Rolando

   if ::IsDisplayPosVisible( oFirstCol:nPos, .t. )
      ::nColSel--
      if lRefresh
         ::Super:Refresh( .t. )
      endif

   else
      ::nColSel--
      if lRefresh
         ::Super:Refresh( .t. )
      endif

      if ::nColSel == ::nFreeze
         ::GoRight()
         ::nColOffSet--
         ::GetDisplayCols()
         if lRefresh
            ::Super:Refresh( ::FullPaint() )
         endif
         if ::oHScroll != nil
            ::oHScroll:GoUp()
         endif
      endif
   endif

ENDIF

   if ::oHScroll != nil
      ::oHScroll:GoUp()
   endif
   ::Change( .f. )

return nil
 

Gracias por ayudarme a depurar el codigo.
Saludos.

Re: Para Antonio: xBrowse nFreeze (APORTE)

PostPosted: Mon May 20, 2013 2:18 pm
by Antonio Linares
Francisco, Rolando,

Incluido para el próximo build, muchas gracias! :-)

Re: Para Antonio: xBrowse nFreeze (APORTE)

PostPosted: Fri May 24, 2013 2:35 am
by AIDA
Muy bueno :mrgreen:

Muchos tenquius :D


Saluditos :wink:

Re: Para Antonio: xBrowse nFreeze (APORTE)

PostPosted: Mon May 27, 2013 3:35 pm
by nageswaragunupudi
Mr FranciscoA

To get what you want I suggest a very simple modification to the existing code.
I have inserted 3 lines of code. You can see below:

Code: Select all  Expand view
METHOD GoLeft( lOffset, lRefresh )  CLASS TXBrowse

   ::CancelEdit()

   if ::nMarqueeStyle == MARQSTYLE_NOMARQUEE  .or. ( ::nMarqueeStyle >= MARQSTYLE_HIGHLROW .and. ::bClrRowFocus == nil )
      lOffset := .t.
   endif

   DEFAULT lOffset  := .f., lRefresh := .t.

   // Begin insert new code
   if ::nFreeze > 0 .and. ::nColOffSet > 1 .and. ::nColSel == ::nFreeze + 1
      lOffset := .t.
   endif
   // end of inserted code

   if ( !lOffset .and. ::IsDisplayPosVisible( ::nColSel - 1 ) ) .or. ;
      ( ::nColOffset == 1 .and. ::nColSel > 1 )
      ::nColSel--
      if lRefresh
         if ::FullPaint()
            ::Super:Refresh( .t. )
         else
            ::DrawLine( .t. )
         endif
      endif
   elseif ::nColOffset > 1
      ::nColOffset--
      ::GetDisplayCols()
      if lRefresh
         ::Super:Refresh( ::FullPaint() )
      endif
   endif

   if ::oHScroll != nil
      ::oHScroll:GoUp()
   endif
   ::Change( .f. )

return nil

 

Can you please try this?
In my tests this is working satisfactorily.

Re: Para Antonio: xBrowse nFreeze (APORTE)

PostPosted: Tue May 28, 2013 1:40 am
by FranciscoA
Mr nageswaragunupudi,
Yes, I've done some tests and your code is working fine for me. I modified mine.
Thank you for your attention.

Si, hice algunas pruebas y su código está bien, para mi. He cambiado el mio.
Gracias por su atención.