FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Movimiento post edicion xbrowse
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Movimiento post edicion xbrowse
Posted: Thu Feb 12, 2009 12:55 AM
saludos a la comunidad les tengo un nuevo aporte para el xBrowse,
a raiz de la sugurencia hecha por el colega Ariel

el cambio radica en poder hacer el movimiento que queramos cuando salimos de edicion en una celda,
se puede usar con FASTEDIT o si el

nos hemos encontrado muchas veces que al usar FastEdit al momemto de salir de edicion, el "cursor" se
posicionara en la proxima celda editable, pero siempre hacia la derecha, nunca hacia otra direccion, aqui
es donde entra el cambio elaborado, podemos decidir hacia que direccion ir...


empecemos con el cambio

abrir xbrowse.ch y agregar estas lineas

Code (text): Select all Collapse
<div class="text" id="{CB}" style="font-family: monospace;">#define MOVE_RIGHT            1
#define MOVE_LEFT             2
#define MOVE_UP               3
#define MOVE_DOWN             4
#define MOVE_NONE             5
#define MOVE_FAST_RIGHT       6
#define MOVE_FAST_LEFT        7
 
 </div>

la diferencia de los que tienen FAST es que hacen uso del FastEdit y lo respetan como tal,
los demas se posicionan en la siguiente celda sin importar si es la proxima celda editable, es decir,
no respetan la caracteristica del fastedit, asi este este activado,
esto hace que el movimiento por default sea MOVE_FAST_RIGHT

puedes hacer uso de los mismos movimientos sin el FastEdit, la diferencia es que los FAST no son tomados en cuenta...
si se usa los FAST con el FastEdit desactivado se asumira que no se puesto movimiento (MOVE_NONE)


abrir xbrowse.prg

agregar nueva data en la clase TXBrowse
Code (text): Select all Collapse
<div class="text" id="{CB}" style="font-family: monospace;"> 
   DATA nMoveType;      // 1 Move Right
        AS NUMERIC      // 2 Move Left
                        // 3 Move Up
                        // 4 Move down
                        // 5 No Move
                        // 6 Move Right with lFastedit features, only work with lFastEdit := .t.
                        // 7 Move left with lFastedit features, only work with lFastEdit := .t.
 </div>

ahora vamos a inicializar la data
en el methodo NEW de la clase TXBrowse

agregar
Code (text): Select all Collapse
<div class="text" id="{CB}" style="font-family: monospace;"> 
   ::nMoveType := MOVE_FAST_RIGHT
 </div>

cambiar el metodo GoNextCtrl de la clase TXBrowse por este

Code (fw): Select all Collapse
 
 
METHOD GoNextCtrl(hWnd)  CLASS TXBrowse
 
   local oCol
   local aCols
   local nCol, nNextPos, n
   local lDir := .f.
   local nI
   local nOldMove
 
   If hWnd != Nil
      If ::nLastKey == 9
         PostMessage(hWnd, WM_KEYDOWN, VK_RETURN)
      Endif
      return nil
   Endif
 
   if ::nColSel == ::nLastEditCol
      ::nLastEditCol := 0
 
      if ::nLastKey == VK_DOWN
         ::Select( 0 )
         ::GoDown()
         ::Select( 1 )
      elseif ::nLastKey == VK_UP
         ::Select( 0 )
         ::GoUp()
         ::Select( 1 )
      else
         if ::lFastEdit
                DO CASE
               CASE ::nMoveType == MOVE_FAST_RIGHT
                  nNextPos    := 0
                  if ::nColSel < Len( ::aDisplay )
                     nNextPos := AScan( ::aDisplay, { |i| ::aCols[ i ]:nEditType > 0 }, ::nColSel + 1 )
                  endif
                  if nNextPos > 0
                     if ::IsDisplayPosVisible( nNextPos, .t. )
                        ::nColSel   := nNextPos
                        if ::FullPaint()
                           ::Super:Refresh( .t. ) //::Paint()
                        else
                           ::DrawLine( .t. )
                        endif
                     else
                        for n := ::nColSel + 1 to nNextPos
                           ::GoRight()
                        next n
                     endif
                  else
                     ::GoLeftMost()
                     nNextPos := AScan( ::aDisplay, { |i| ::aCols[ i ]:nEditType > 0 } )
                     if nNextPos > 1
                        if ::IsDisplayPosVisible( nNextPos, .t. )
                           ::nColSel   := nNextPos
                           ::DrawLine( .t. )
                        else
                           for n := 2 to nNextPos
                              ::GoRight()
                           next
                        endif
                     endif
                     if ::lAutoAppend .or. ::nDataRows > ::nRowSel                                
                        if ::bPastEof == NIL .and. ::nDataRows = ::nRowSel                       
                           MsgStop( "::bPastEof not defined","Fivewin: Class TXBrowse" )   
                           return NIL                                                                             
                        else                                                                                             
                           ::Select( 0 )                                                                            
                           ::GoDown()                                                                               
                           ::Select( 1 )                                                                            
                        endif                                                                                            
                     endif                                                                                             
                  endif
                  
               CASE ::nMoveType == MOVE_RIGHT
                  nNextPos    := ::nColSel + 1
                  if !::IsDisplayPosVisible( nNextPos, .t. )
                     ::GoLeftMost()
                     if ::nDataRows > ::nRowSel 
                      ::GoDown()
                     endif
                  else
                     ::GoRight()
                  endif
               CASE ::nMoveType == MOVE_FAST_LEFT
                  nNextPos    := ::SelectedCol():nCreationOrder  - 1
                  nI := nNextPos
                  if nNextPos > 0
                    while ::aCols[ nI ]:nEditType < 1
                        if ( --nI ) == 0
                            exit
                        endif
                    enddo
                  endif
 
                  nNextPos := ascan(::aDisplay,{|i| i = nI } )
                  if nNextPos > 0
                     if ::IsDisplayPosVisible( nNextPos, .t. )
                        ::nColSel   := nNextPos
                        if ::FullPaint()
                           ::Super:Refresh( .t. ) //::Paint()
                        else
                           ::DrawLine( .t. )
                        endif
                     endif
                  else
                     if nI > 0
                        for n := ::aDisplay[ ::nColSel ] - 1 to nI step -1
                           ::GoLeft()
                        next n
                     else
                        ::GoRightMost()
                        nI := len( ::aCols )
                        while ::aCols[ nI ]:nEditType < 1
                           if ( --nI ) == 0
                              exit
                           endif
                        enddo
                     
                                          nNextPos := ascan(::aDisplay,{|i| i = nI } )
                        if nNextPos > 0
                           if ::IsDisplayPosVisible( nNextPos, .t. )
                              ::nColSel   := nNextPos
                              ::DrawLine( .t. )
                           else
                              for n := ::aDisplay[ ::nColSel ] - 1 to nI step -1
                                 ::GoLeft()
                              next n
                           endif
                           if ::nDataRows > 1
                              ::GoUp()
                           endif
                        endif
                     endif
                  endif
                 
               CASE ::nMoveType == MOVE_LEFT
                  nNextPos  := ::aDisplay[ ::nColSel ] - 1
                  if nNextPos > 0
                    ::GoLeft()
                  else
                     ::GoRightMost()
                     if ::nRowSel > 1
                      ::GoUp()
                     endif
                                    endif                  
                                    
                           CASE ::nMoveType == MOVE_DOWN
                  if ::lAutoAppend .and. ( ::nLen == 0 .or. ::eof() .or. ::KeyNo() == ::nLen )
                     if ::bPastEof == NIL .and. ::nDataRows = ::nRowSel                       
                        MsgStop( "::bPastEof not defined","Fivewin: Class TXBrowse" )   
                        return NIL                                                                             
                     else                                                                                             
                        ::Select( 0 )                                                                            
                        ::GoDown()
                        ::Select( 1 )                                                                            
                     endif
                  else
                     ::GoDown()
                     ::refresh()
                  endif                                                                                             
                  
                           CASE ::nMoveType == MOVE_UP
                  ::GoUp()
                  ::refresh()
                 
            ENDCASE
         else
         nOldMove := ::nMoveType
         if ::nMoveType == MOVE_FAST_LEFT .or. ::nMoveType == MOVE_FAST_RIGHT
            ::nMoveType := MOVE_NONE
         endif
 
         DO CASE
            CASE ::nMoveType == MOVE_RIGHT
               ::GoRight()
               ::refresh()
            
            CASE ::nMoveType == MOVE_LEFT
                 ::GoLeft()
                 ::refresh()
                            
                        CASE ::nMoveType == MOVE_DOWN
                           ::GoDown()
               ::refresh()
                  
                        CASE ::nMoveType == MOVE_UP
               ::GoUp()
               ::refresh()
            ENDCASE         
            ::nMoveType := nOldMove
         endif
      endif
   endif
 
return nil


aqui les dejo un ejemplo

Code (fw): Select all Collapse
 
#include "FiveWin.ch"
#include "xbrowse.ch"
 
function main()
 
   local aArray1 := {}
 
   local oWnd, ;
         oMenu,;
         oBrw
 
   local nI
   
   
   for nI = 1 to 20
   aadd( aArray1, { "Row:"+StrZero(nI,2)+" Col:01",;
                                "Row:"+StrZero(nI,2)+" Col:02",;
                                "Row:"+StrZero(nI,2)+" Col:03",;
                                "Row:"+StrZero(nI,2)+" Col:04",;
                                "Row:"+StrZero(nI,2)+" Col:05",;
                                "Row:"+StrZero(nI,2)+" Col:06" } )
   next
   
  
   menu oMenu
      menuitem "Movimientos"
         menu
            menuitem "MOVE_RIGHT" action oBrw:nMoveType := MOVE_RIGHT when oBrw:nMoveType != MOVE_RIGHT 
            menuitem "MOVE_LEFT"  action oBrw:nMoveType := MOVE_LEFT  when oBrw:nMoveType != MOVE_LEFT
            menuitem "MOVE_UP"    action oBrw:nMoveType := MOVE_UP    when oBrw:nMoveType != MOVE_UP
            menuitem "MOVE_DOWN"  action oBrw:nMoveType := MOVE_DOWN  when oBrw:nMoveType != MOVE_DOWN
            menuitem "MOVE_NONE"  action oBrw:nMoveType := MOVE_NONE when oBrw:nMoveType != MOVE_NONE
            menuitem "MOVE_FAST_RIGHT" action oBrw:nMoveType := MOVE_FAST_RIGHT  when oBrw:nMoveType != MOVE_FAST_RIGHT
            menuitem "MOVE_FAST_LEFT"  action oBrw:nMoveType := MOVE_FAST_LEFT   when oBrw:nMoveType != MOVE_FAST_LEFT
         endmenu
     menuitem "FastEdit"
        menu
           menuitem "Activado"    action oBrw:lFastEdit:=.t. when !oBrw:lFastEdit
           menuitem "Desactivado" action oBrw:lFastEdit:=.f. when oBrw:lFastEdit
        endmenu
   endmenu
   
   
   define window oWnd title "test" menu oMenu
   
   oBrw:= txbrowse():new( oWnd )
   oBrw:nRowHeight := 25
   oBrw:nColDividerStyle    := LINESTYLE_BLACK
   oBrw:nRowDividerStyle    := LINESTYLE_BLACK
   oBrw:SetArray( aArray1 )
   
   aeval( oBrw:aCols, {| o | o:nEditType := 1, o:bPopUp := { |o| ColMenu( o ) } } )
   
   oBrw:CreateFromCode()
   
   oWnd:oClient := oBrw
   
   
   ACTIVATE window oWnd 
 
 
return nil 
 
 
static function ColMenu( ocol )
 
   local oPop
 
   MENU oPop POPUP 2007
      MenuAddItem( "Edit", ,oCol:nEditType > 0, .t., ;
         { |oItem| oCol:nEditType := If( oCol:nEditType > 0, 0, 1 ), ;
            oItem:SetCheck( oCol:nEditType > 0 ), ;
            oCol:oBrw:SetFocus() } )
 
   ENDMENU
 
return oPop
Posts: 581
Joined: Tue Oct 11, 2005 11:28 AM
Re: Movimiento post edicion xbrowse
Posted: Thu Feb 12, 2009 07:01 PM

Daniel,

Esta era una das cosas que me hacia falta en xbrowse. Muchas gracias por el aporte.

Saludos,

Kleyber Derick



FWH / xHb / xDevStudio / SQLLIB
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Movimiento post edicion xbrowse
Posted: Thu Feb 12, 2009 07:08 PM

a la orden... :)

Posts: 71
Joined: Mon Jan 28, 2008 11:18 AM
Re: Movimiento post edicion xbrowse
Posted: Fri Feb 13, 2009 10:25 AM

é possível adicionar essa alteração na minha lib ?

como faço ?

Daniel Lopes Filho - Campo Grande,MS,Brasil
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6693) + gtwvw + fw 10.2 + vsx e
fw pcc (ainda não usei)
msn : zazibr@hotmail.com

Continue the discussion