Problemas con @ browse FiveLinux-harbour

Problemas con @ browse FiveLinux-harbour

Postby jgayoso » Fri Apr 29, 2011 12:44 pm

Tengo 2 problemas en el código adjunto:
1) ¿Como hago para personalizar el ancho de cada columna? Salen todas del mismo ancho.
2) ¿Se puede usar y como, los metodos KeyDown() o LButtonDown() para marcar, en vez de un button?

Se agradece cualquier ayuda a mi problema... :cry:

DEFINE DIALOG oDlg TITLE hb_strtoutf8(cTitle) SIZE 510, 350
@ 1, 1 BROWSE oBrw OF oDlg ;
HEADERS hb_strtoutf8("Selección"), hb_strtoutf8("Descripción"), hb_strtoutf8("Archivo") ;
FIELDS If( vdbf_[ oBrw:nAt ][ 1 ], "X", " " ), vdbf_[ oBrw:nAt ][ 2 ], vdbf_[ oBrw:nAt ][ 3 ]
oBrw:SetArray( vdbf_ )
oBrw:nRowPos = 2
oBrw:nAt = 2

@31, 3 BUTTON "Seleccionar" OF oDlg SIZE 120, 33 ACTION ( vdbf_[ oBrw:nRowPos ][ 1 ] := ! vdbf_[ oBrw:nRowPos ][ 1 ], oBrw:Refresh() )
@31, 19 BUTTON "Aceptar" OF oDlg SIZE 120, 33 ACTION ( lModal:=.F., aSeleccion := {cValor}, oDlg:End() )
@31, 36 BUTTON "Cancelar" OF oDlg SIZE 120, 33 ACTION ( lModal:=.F., lRetorno:=.F., aSeleccion:={}, oDlg:End() )
ACTIVATE DIALOG oDlg CENTERED
jgayoso
 
Posts: 170
Joined: Sat Aug 07, 2010 11:36 pm
Location: Chile

Re: Problemas con @ browse FiveLinux-harbour

Postby Antonio Linares » Thu May 05, 2011 5:46 pm

Jorge,

Si revisas FiveLinux/include/FiveLinux.ch verás que el comando BROWSE admite las siguientes claúsulas:
Code: Select all  Expand view

#xcommand @ <nRow>, <nCol> BROWSE <oBrw> ;
             [ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
             [ <headers: HEAD, HEADER, HEADERS, TITLE> <cHeading,...> ] ;
             [ FIELDS <Expr1> [,<ExprN>] ] ;
             [ <sizes: FIELDSIZES, SIZES, COLSIZES> <aColSizes,...> ] ;
             [ FIELDS <Expr1> [,<ExprN>] ] ;
             [ ALIAS <cAlias> ] ;
         [ SIZE <nWidth>, <nHeight> ] ;
         [ <update: UPDATE> ] ;
      => ;
             [ <oBrw> := ] TWBrowse():New( <nRow>, <nCol>,;
         [<oWnd>], [\{<cHeading>\}], [\{<aColSizes>\}],;
         \{ \{|o|<Expr1>\} [ ,\{|o|<ExprN>\} ] \}, <cAlias>,;
         <nWidth>, <nHeight>, <.update.> )
 

luego puedes especificar:
@ ..., ... BROWSE ... COLSIZES 30, 80, 70 ...
un valor para cada ancho de columna :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41408
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Problemas con @ browse FiveLinux-harbour

Postby Antonio Linares » Thu May 05, 2011 5:55 pm

Para poder seleccionar usando el teclado, tenemos que modificar el método KeyDown() para que evalúe bKeyDown en caso de estar definido:
Code: Select all  Expand view

METHOD KeyDown( nKey ) CLASS TWBrowse

   do case
      case nKey == K_DOWN
           ::GoDown()
       ::oVScroll:SetValue( ::oVScroll:GetValue() + 1 )

      case nKey == K_UP
           ::GoUp()
       ::oVScroll:SetValue( ::oVScroll:GetValue() - 1 )

      case nKey == K_HOME
           ::GoTop()
       ::oVScroll:SetValue( 1 )

      case nKey == K_END
           ::GoBottom()

      case nKey == K_PAGEUP
           ::PageUp()

      case nKey == K_PAGEDOWN
           ::PageDown()

      case nKey == K_LEFT
           ::GoLeft()
       ::oHScroll:SetValue( ::oHScroll:GetValue() - 1 )

      case nKey == K_RIGHT
           ::GoRight()
       ::oHScroll:SetValue( ::oHScroll:GetValue() + 1 )
   endcase

   if ! Empty( ::bKeyDown )
      Eval( ::bKeyDown, nKey, Self )
   endif

return nil
 

De igual forma hay que modificar el método LButtonDown() para que procese bLClicked en caso de estar definido:
Code: Select all  Expand view

METHOD LButtonDown( nRow, nCol ) CLASS TWBrowse

   local nRowSize := ::nHeight / ::nRowCount()
   local nRowAt   := Int( nRow / nRowSize )
   local nRowPos  := ::nRowPos
   local nSkipped

   ::SetFocus()

   if nRowAt == 0 .or. nRowAt == nRowPos
      return nil
   endif

   ::DrawLine( nRowPos )
   if ( nSkipped := ::Skip( nRowAt - nRowPos ) ) != 0
      ::nRowPos = nRowAt
      ::oVScroll:SetValue( ::oVScroll:GetValue() + ( nRowAt - nRowPos ) )
      if ! Empty( ::bLClicked )
         Eval( ::bLClicked, nRowAt, nCol, Self )
      endif
   endif
   ::DrawSelect()

return nil
 

Vamos a incorporar estos cambios en FiveLinux y te enviamos las nuevas librerias :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41408
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Problemas con @ browse FiveLinux-harbour

Postby Antonio Linares » Thu May 05, 2011 6:06 pm

El ejemplo quedaría asi:
Code: Select all  Expand view

// Using a browse to display a multidimensional array

#include "FiveLinux.ch"

function Main()

   local oWnd, oBrw, aTest := { { .F., "one", "two" }, { .F., "three", "four" }, { .F., "five", "six" } }

   DEFINE WINDOW oWnd TITLE "Testing Browses" SIZE 522, 317

   @ 2, 2 BROWSE oBrw OF oWnd ;
      HEADERS "Selected", "First", "Second" ;
      FIELDS  If( aTest[ oBrw:nAt ][ 1 ], "X", " " ), aTest[ oBrw:nAt ][ 2 ], aTest[ oBrw:nAt ][ 3 ]

   oBrw:SetArray( aTest )
   oBrw:nRowPos = 2
   oBrw:nAt = 2

   oBrw:bKeyDown = { | nKey | If( nKey == 32, ( aTest[ oBrw:nRowPos ][ 1 ] := ! aTest[ oBrw:nRowPos ][ 1 ], oBrw:Refresh() ),) }
   oBrw:bLClicked = { | nRowAt, nCol | If( nCol < 80, ( aTest[ oBrw:nRowPos ][ 1 ] := ! aTest[ oBrw:nRowPos ][ 1 ], oBrw:Refresh() ),) }

   @ 28, 2 BUTTON "_Ok" OF oWnd ACTION oWnd:End()
   
   @ 28, 30 BUTTON "Add" OF oWnd ACTION ( AAdd( aTest, { .F., "five", "six" } ), oBrw:SetArray( aTest ), oBrw:GoTop(), oBrw:Refresh() )

   @ 28, 40 BUTTON "Select" OF oWnd ACTION ( aTest[ oBrw:nRowPos ][ 1 ] := ! aTest[ oBrw:nRowPos ][ 1 ], oBrw:Refresh() )

   ACTIVATE WINDOW oWnd

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41408
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Problemas con @ browse FiveLinux-harbour

Postby jgayoso » Tue May 10, 2011 2:51 pm

Ok Antonio, una vez mas todo bien.

Resulto perfecto.

Se agradece.
jgayoso
 
Posts: 170
Joined: Sat Aug 07, 2010 11:36 pm
Location: Chile


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 36 guests