Use xBrowse with object instead of array

Use xBrowse with object instead of array

Postby sambomb » Thu Feb 02, 2012 10:30 am

Hi, im version 8.04 I could use the xBrowse with an object instead of an array.
In 10.06 I can't.

Code: Select all  Expand view

   //-- Objeto de recebimento --------------------------------------------//
   oRecto := TRecebimento():New()
   
   //-- xBrowse ----------------------------------------------------------//
   oBrx := TXBrowse():New( oDlg )
   oBrx:CreateFromResource( 301 )
   oBrx:lHScroll := .T.

    //-- oRecto:aTitulos is an array of objects
   oBrx:SetArray( oRecto:aTitulos, .T. ,6, {5,6,3,9,10,21,22,8,16,23,27} )  
   
   xBrowseStyle(oBrx)  
   oBrx:nDataType := DATATYPE_ARRAY
   
    oBrx:bKeyDown := {| nKey, nFlags | KeyDownDlg(nKey, nFlags)}
   oBrx:bLDblClick := { || BtnClickMarcar() }    //---------------> Duplo click
   oBrx:bClrStd := { ||{CLR_BLACK,ClrPaneBrw()}} //---------------> Mudar cor de fundo
   
   *****--- Colunas ---*****

   oBrx:aCols[ 01 ]:cHeader := "Data emissao"
   oBrx:aCols[ 01 ]:nDataStrAlign := AL_CENTER
   oBrx:aCols[ 01 ]:nHeadStrAlign := AL_CENTER
 
   oBrx:aCols[ 02 ]:cHeader := "Data vencimento"
   oBrx:aCols[ 02 ]:nDataStrAlign := AL_CENTER
   oBrx:aCols[ 02 ]:nHeadStrAlign := AL_CENTER
 
   oBrx:aCols[ 03 ]:cHeader := "Título"
   oBrx:aCols[ 03 ]:nDataStrAlign := AL_LEFT
   oBrx:aCols[ 03 ]:nHeadStrAlign := AL_LEFT
 
   oBrx:aCols[ 04 ]:cHeader := "Valor a pagar"
   oBrx:aCols[ 04 ]:nDataStrAlign := AL_RIGHT
   oBrx:aCols[ 04 ]:nHeadStrAlign := AL_RIGHT
 
   oBrx:aCols[ 05 ]:cHeader := "Valor pago"
   oBrx:aCols[ 05 ]:nDataStrAlign := AL_RIGHT
   oBrx:aCols[ 05 ]:nHeadStrAlign := AL_RIGHT
 
   oBrx:aCols[ 06 ]:cHeader := "Vr. original"
   oBrx:aCols[ 06 ]:nDataStrAlign := AL_RIGHT
   oBrx:aCols[ 06 ]:nHeadStrAlign := AL_RIGHT
 
   oBrx:aCols[ 07 ]:cHeader := "Vr. devolvido"
   oBrx:aCols[ 07 ]:nDataStrAlign := AL_RIGHT
   oBrx:aCols[ 07 ]:nHeadStrAlign := AL_RIGHT
 
   oBrx:aCols[ 08 ]:cHeader := "Retirado"
   oBrx:aCols[ 08 ]:nDataStrAlign := AL_LEFT
   oBrx:aCols[ 08 ]:nHeadStrAlign := AL_LEFT
   oBrx:aCols[ 08 ]:nWidth        := 170  

   oBrx:aCols[ 09 ]:cHeader := "Histórico"
   oBrx:aCols[ 09 ]:nDataStrAlign := AL_LEFT
   oBrx:aCols[ 09 ]:nHeadStrAlign := AL_LEFT
   oBrx:aCols[ 09 ]:nWidth        := 200  

   oBrx:aCols[ 10 ]:cHeader := "Vr. já pago"
   oBrx:aCols[ 10 ]:nDataStrAlign := AL_RIGHT
   oBrx:aCols[ 10 ]:nHeadStrAlign := AL_RIGHT

   oBrx:aCols[ 11 ]:cHeader := "Dt. parcial"
   oBrx:aCols[ 11 ]:nDataStrAlign := AL_RIGHT
   oBrx:aCols[ 11 ]:nHeadStrAlign := AL_RIGHT
   
/* Sample */
CLASS TRecebimento

   DATA nIdRecebimento      AS NUMERIC    INIT -1           PUBLIC
   DATA cIdCliente          AS CHARACTER  INIT ""           PUBLIC
   DATA cIdVendedor         AS CHARACTER  INIT ""           PUBLIC
   DATA dData               AS DATE       INIT Date()       PUBLIC
   DATA aTitulos            AS ARRAY      INIT {}           READONLY
   DATA nJuros              AS NUMERIC    INIT 0            PUBLIC
   DATA lJuros                                              PUBLIC
   DATA nTotalReceber       AS NUMERIC    INIT 0            PUBLIC
   DATA cFileName           AS NUMERIC    INIT ""           PUBLIC
   DATA nPreRecebimento     AS NUMERIC    INIT 0            PUBLIC
   DATA nTolerancia         AS NUMERIC    INIT 0            PUBLIC
   DATA nDesconto           AS NUMERIC    INIT 0            PUBLIC
   DATA nAcrescimo          AS NUMERIC    INIT 0            PUBLIC
   DATA nIdDevolucao        AS NUMERIC    INIT 0            PUBLIC
   DATA nMulta              AS NUMERIC    INIT 0            PUBLIC
   DATA lMulta                                              PUBLIC

CLASS TTitulo STATIC

   //-- Acessado como matriz, adicionar atributos ao final. Obs.: Começa em 2
   DATA nRecno              AS NUMERIC    INIT 0            PUBLIC // 02
   DATA cIdTitulo           AS CHARACTER  INIT ""           PUBLIC // 03
   DATA nValor              AS NUMERIC    INIT 0            PUBLIC // 04
   DATA dEmissao            AS DATE       INIT Date()       PUBLIC // 05
   DATA dVencimento         AS DATE       INIT Date()       PUBLIC // 06
   DATA dPagamento          AS DATE       INIT Date()       PUBLIC // 07
   DATA cRetirado           AS CHARACTER  INIT ""           PUBLIC // 08
   DATA nValorJuros         AS NUMERIC    INIT 0            PUBLIC // 09
   DATA nValorPago          AS NUMERIC    INIT 0            PUBLIC // 10
   DATA cIdVendedor         AS CHARACTER  INIT 0            PUBLIC // 11
   DATA lEstorno            AS NUMERIC    INIT .F.          PUBLIC // 12
   DATA cIdRestanteConta    AS CHARACTER  INIT ""           PUBLIC // 13
   DATA nIdRecebimento      AS NUMERIC    INIT 0            PUBLIC // 14
   DATA dEntrada            AS DATE       INIT Date()       PUBLIC // 15
   DATA cHistorico          AS CHARACTER  INIT ""           PUBLIC // 16
   DATA cOperador           AS CHARACTER  INIT ""           PUBLIC // 17
   DATA cTpLanca            AS CHARACTER  INIT ""           PUBLIC // 18
   DATA nJuros              AS NUMERIC    INIT 0            PUBLIC // 19
   DATA cCodRetirado        AS CHARACTER  INIT ''           PUBLIC // 20
   DATA nVrOriginal         AS NUMERIC    INIT 0            PUBLIC // 21
   DATA nVrDevolucao        AS NUMERIC    INIT 0            PUBLIC // 22
   DATA nVrRecebido         AS NUMERIC    INIT 0            PUBLIC // 23
   DATA nIdDevolucao        AS NUMERIC    INIT 0            PUBLIC // 24
   DATA nPerMulta           AS NUMERIC    INIT 0            PUBLIC // 25
   DATA cFlagRec            AS CHARACTER  INIT ""           PUBLIC // 26
   DATA dDtParcial          AS DATE       INIT Date()       PUBLIC // 27

 
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Use xBrowse with object instead of array

Postby sambomb » Fri Feb 03, 2012 10:35 am

Solved.

Modifications in xBrowse.prg
Code: Select all  Expand view

Method SetRDD()
      //if ValType( aRows[ 1 ] ) == 'A'//-- Samir 02/02/2012
      if ValType( aRows[ 1 ] ) $ 'A,O'
Method SetArray()
         //if ValType( aData[ 1 ] ) == 'A' //-- Samir 02/02/2012
         if ValType( aData[ 1 ] ) $ 'A,O'
Method ArrCell()
      //if ValType( uVal ) == 'A' //-- Samir 02/02/2012
      if ValType( uVal ) $ 'A,O'
Method ArrCellSet()
      //if ValType( uRow ) == 'A' //-- Samir 02/02/2012
      if ValType( uRow ) == 'A,O'
Method Adjust()
   //if ValType( ::oBrw:aArrayData ) == 'A' //-- Samir 02/02/2012
   if ValType( ::oBrw:aArrayData ) $ 'A,O'
 
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Use xBrowse with object instead of array

Postby Antonio Linares » Fri Feb 03, 2012 12:02 pm

Samir,

Many thanks! :-)

I send you the most recent xbrowse.prg source. Please test your changes in it and let us know how it goes, thanks! :-)
regards, saludos

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

Re: Use xBrowse with object instead of array

Postby sambomb » Fri Feb 03, 2012 4:08 pm

Error: Unresolved external '_HB_FUN_FIELDINEXPR' referenced from C:\TRADE8\OBJ\BALCAOFW@\XBROWSE.OBJ
Error: Unresolved external '_HB_FUN_ORDERTAGINFO' referenced from C:\TRADE8\OBJ\BALCAOFW@\XBROWSE.OBJ
Error: Unresolved external '_HB_FUN_FW_DECODE' referenced from C:\TRADE8\OBJ\BALCAOFW@\XBROWSE.OBJ
Error: Unresolved external '_HB_FUN_FW_VALTOEXP' referenced from C:\TRADE8\OBJ\BALCAOFW@\XBROWSE.OBJ
Error: Unresolved external '_HB_FUN_EXCELOBJ' referenced from C:\TRADE8\OBJ\BALCAOFW@\XBROWSE.OBJ
Error: Unresolved external '_HB_FUN_SUNCALCOBJ' referenced from C:\TRADE8\OBJ\BALCAOFW@\XBROWSE.OBJ
Error: Unresolved external '_HB_FUN_FWNUMFORMAT' referenced from C:\TRADE8\OBJ\BALCAOFW@\XBROWSE.OBJ

P.S.: My version is 10.06
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Use xBrowse with object instead of array

Postby nageswaragunupudi » Tue Feb 07, 2012 7:41 am

With the recent versions of xbrowse ( probably last one or two years and definitely 10.06 it is easy to browse any object without any code.

use xbrowse command:

XBrowse( oWnd ) or XBrowse( oDlg ) or XBrowse( oBrw )

Normal program code:

@ <r>, <c> XBROWSE <oBrw> SIZE <w>,<h> DATASOURCE oObject

As simple as that.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Use xBrowse with object instead of array

Postby nageswaragunupudi » Tue Feb 07, 2012 8:07 am

Sample Code:
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local oDlg, oBrw, oFont

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 400,500 PIXEL FONT oFont
   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      OBJECT oDlg CELL LINES NOBORDER

   WITH OBJECT oBrw
      :bClrSel       := { || { CLR_WHITE, CLR_GRAY } }
      :nStretchCol   := STRETCHCOL_WIDEST
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg
   RELEASE FONT oFont

return nil
 

Above code works with 10.06 also.

Screen Shot:
Image

Above code displays data and values of the Dialog object in the top left browse.
Double click on the value of oFont displays Browse of the Font object ( See top right )
Again double click on the value of oRect object in Browse of Font object, we see browse of data and values of TRect object.
All this without long lines of coding.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Use xBrowse with object instead of array

Postby nageswaragunupudi » Tue Feb 07, 2012 3:17 pm

Browsing Array of Objects:
Works with 10.06 and current versions.
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local aObj, oDlg, oBrw, oFont

   aObj  := { ;
      TTemp():New( 1, 'One',   Date()     ), ;
      TTemp():New( 2, 'Two',   Date() + 2 ), ;
      TTemp():New( 3, 'Three', Date() + 3 )  }

   SET DATE ITALIAN
   SET CENTURY ON

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 400,200 PIXEL FONT oFont

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      FIELDS oBrw:aRow:nVal, oBrw:aRow:cVal, oBrw:aRow:dVal ;
      HEADERS "Number", "CharVal", "Date" ;
      COLSIZES 50,100,100 ;
      ARRAY aObj CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := STRETCHCOL_WIDEST
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

CLASS TTemp

   DATA nVal, cVal, dVal

   METHOD New( a, b, c ) CONSTRUCTOR

ENDCLASS

METHOD New( a, b, c ) CLASS TTemp

   ::nVal   := a
   ::cVal   := b
   ::dVal   := c

return Self
 


ScreenShot:
Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Use xBrowse with object instead of array

Postby sambomb » Tue Feb 07, 2012 4:16 pm

In my sample I use an array of Objects, not just one object to take the info inside it
It's like the last sample, but in my sample I redefine from resource, can you please test it in a similar way?
Last edited by sambomb on Tue Feb 07, 2012 4:19 pm, edited 1 time in total.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Use xBrowse with object instead of array

Postby nageswaragunupudi » Tue Feb 07, 2012 4:19 pm

sambomb wrote:In my sample I use an array of Objects, not just one object to take the info inside it


I understand please
My above posting is to display array of objects.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Use xBrowse with object instead of array

Postby sambomb » Tue Feb 07, 2012 4:21 pm

nageswaragunupudi wrote:
sambomb wrote:In my sample I use an array of Objects, not just one object to take the info inside it


I understand please
My above posting is to display array of objects.


Last post edited.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Use xBrowse with object instead of array

Postby nageswaragunupudi » Tue Feb 07, 2012 5:53 pm

Using resource:
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local aObj, oDlg, oBrw, oFont
   local o

   aObj  := { ;
      TTemp():New( 1, 'One',   Date()     ), ;
      TTemp():New( 2, 'Two',   Date() + 2 ), ;
      TTemp():New( 3, 'Three', Date() + 3 )  }

   SET DATE ITALIAN
   SET CENTURY ON

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg RESOURCE "DIALOG_1" PIXEL FONT oFont

   REDEFINE XBROWSE oBrw ID 101 OF oDlg ;
      FIELDS oBrw:aRow:nVal, oBrw:aRow:cVal, oBrw:aRow:dVal ;
      HEADERS "Number", "CharVal", "Date" ;
      COLSIZES 70,100,100 ;
      ARRAY aObj CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := STRETCHCOL_WIDEST
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

CLASS TTemp

   DATA nVal, cVal, dVal

   METHOD New( a, b, c ) CONSTRUCTOR

ENDCLASS

METHOD New( a, b, c ) CLASS TTemp

   ::nVal   := a
   ::cVal   := b
   ::dVal   := c

return Self
 


Resource:
Code: Select all  Expand view
DIALOG_1 DIALOG 77, 98, 361, 202
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "TESTDLG"
FONT 8, "MS Sans Serif"
{
 DEFPUSHBUTTON "OK", IDOK, 177, 174, 50, 14
 PUSHBUTTON "Cancel", IDCANCEL, 237, 174, 50, 14
 PUSHBUTTON "Help", IDHELP, 297, 174, 50, 14
 CONTROL "", 101, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 16, 10, 329, 147
}


Screenshot:
Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests