xBrowse questions

xBrowse questions

Postby TimStone » Thu Jun 11, 2009 4:05 pm

I'm converting tsBrowse controls to xbrowse ( 9.05 FWH ). I've gone through the samples, etc. and people have a variety of ways to setup the xbrowse control. In my case, I use it on a dialog with other data displayed, so I am using it with a REDEFINE.

Using tsbrowse, the following code allows me to add a column using an array:

oLbxd:setArray( aParItm )
ADD COLUMN TO BROWSE oLbxd DATA ARRAY ELEMENT 2 HEADER "Number" SIZE 130 ALIGN 0,1
ADD COLUMN TO BROWSE oLbxd DATA ARRAY ELEMENT 3 HEADER "Description" SIZE 250 ALIGN 0,1
ADD COLUMN TO BROWSE oLbxd DATA ARRAY ELEMENT 4 HEADER "Charge" SIZE 130 ALIGN 2,1

What would be the equivalent code in txbrowse ?

Also, using tsbrowse, I can add a bitmap by first defining it:

aBmp := { LoadBitMap( GetResources( ) , "CM1" ), ;
LoadBitMap( GetResources( ), "CM2" ), LoadBitMap(GetResources( ), "CM3") }


And then in the browse, I can use:

add column to oLbxo header aBmp[1] data IIF( oWrkOrd:totals,aBmp[3],;
IIF( oWrkOrd:ordnot, aBmp[ 1 ], aBmp[ 2 ] )) ALIGN 0,1 size 30 BITMAP

What would be the equivalent code in txbrowse ?

Samples are great, but they all seem to use the same methodology,. I sure wish we had some newer documentation on xbrowse ? It would be a major boost.

Thanks for the input.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: xBrowse questions

Postby Antonio Linares » Thu Jun 11, 2009 4:31 pm

Tim,

In FWH\samples\TestXBrw.prg you can find this code:
Code: Select all  Expand view

   DEFINE DIALOG oDlg RESOURCE "TEST" OF oWnd

   oBrw := TXBrowse():New( oWnd )

/* Another way:
   oBrw:CreateFromResource( 101 )

   oBrw:SetArray( { { "first", "row" }, { "second", "row" } } )
   oBrw:aCols[ 1 ]:cHeader = "An array"
   oBrw:aCols[ 2 ]:cHeader = "test"
   oBrw:aCols[ 1 ]:bClrStd = { || { CLR_WHITE, CLR_BLUE } }
   oBrw:aCols[ 2 ]:bClrStd = { || { CLR_WHITE, CLR_BLUE } }
*/


   REDEFINE XBROWSE oBrw ID 101  ;
      HEADERS "An array", "test" ;
      OF oDlg ;
      ARRAY { { "first", "row" }, { "second", "row" } } AUTOCOLS ;
      COLORS CLR_WHITE, CLR_BLUE

   ACTIVATE DIALOG oDlg ;
     ON INIT ( oBrw:SetColor( CLR_WHITE, CLR_BLUE ) )
 
regards, saludos

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

Re: xBrowse questions

Postby TimStone » Thu Jun 11, 2009 4:55 pm

I was trying to stay with the ADD COLUMN command syntax. I have so many browses to replace that I wanted to keep the coding as similar as possible. So far, arrays and bitmaps were the only issues ... everything else is transfering nicely. Note the array in this case is multidimensional ... 4 elements x the number of data records.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: xBrowse questions

Postby Antonio Linares » Thu Jun 11, 2009 6:26 pm

Tim,

You can also use:
Code: Select all  Expand view

ADD [ COLUMN ] [<oCol>] TO [ XBROWSE ] <oBrw> ;
            [ AT <nAt> ] ;
            [ <dat: DATA, SHOWBLOCK> <uData> ] ;
            ...
 

Please review FWH\include\xbrowse.ch to see the complete syntax, thanks
regards, saludos

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

Re: xBrowse questions

Postby nageswaragunupudi » Fri Jun 12, 2009 1:29 am

Here is an example ( prepared for a different purpose ) showing
1. Using ADD TO oBrw syntax for adding data, bitmaps
2. Different picture clauses for date formats
3. Editing numbers and automatic maintenance of totals in footers

Image

I hope this sample covers the issues raised in this post.
Code: Select all  Expand view

#include 'fivewin.ch'
#include 'xbrowse.ch'

function Main()

   local oDlg, oBrw
   local aData := { ;
     { 1, 'One   ', nil, date(), 23456 }, ;
     { 2, 'Two   ', '2222', date()-1, 345 } , ;
     { 3, 'Three', '3333', date()-2, 789 }, ;
     { 4, 'Four', '4444', date()-3, 234 } }

    DEFINE DIALOG oDlg SIZE 540,340 PIXEL TITLE 'Xbrowse'

   @ 10,10 XBROWSE oBrw ;
      SIZE 250,150 PIXEL OF oDlg ;
      ARRAY aData ;
      CELL LINES FOOTERS FASTEDIT

   ADD TO oBrw ARRAY ELEMENT 1 HEADER 'SlNo' SIZE 50 CENTER

   // In XBrowse, ALIGN clause is mostly not necessary
   // Date and numeric values are automatically right aligned
   // and other types are left aligned
   // We need to use ALIGN clause if (a) we want a different
   // behavior
   // In the above line, we can write 'ALIGN CENTER' or
   // simply 'CENTER'
   // By default all headers, footers and data are aligned
   // same way. We can change the behaviour by assiging
   // oCol:nHeadStrAlign := AL_RIGHT, etc.

   ADD TO oBrw DATA oBrw:KeyNo() % 2 + 1 BITMAP IN 'OPEN', 'CLOSE'
   WITH OBJECT ATail( oBrw:aCols )
      :AddResource( 'FOLDER' )
      :nHeadBmpNo := 3
   END

   ADD TO oBrw ARRAY ELEMENT 1 BITMAP IN 'OPEN','CLOSE','FOLDER','FIND'
   WITH OBJECT ATail( oBrw:aCols )
      :nHeadBmpNo := 2
   END

   ADD TO oBrw ARRAY ELEMENT 2 HEADER 'Description' SIZE 70 ;
      BITMAP BMPDATA oBrw:KeyNo() IN 'FOLDER','OPEN','FIND','CLOSE'

   WITH OBJECT ATail( oBrw:aCols )
      :nHeadBmpNo := 1
   END


   ADD TO oBrw ARRAY ELEMENT 4 HEADER 'Date'
   ADD TO oBrw ARRAY ELEMENT 4 HEADER 'Date2' PICTURE 'mmm dd, yyyy'
   // can use even these kinds of date formats

   ADD TO oBrw ARRAY ELEMENT 5 HEADER 'Amount' ;
      PICTURE '99,999.99' EDITABLE

   WITH OBJECT ATail( oBrw:aCols )
      :lTotal     := .t.
      :nTotal     := 0
   END
   // This will show total as footer
   // Any edit of column automatically changes the total
   // MakeTotals() method computes totals

   oBrw:nStretchCol  := STRETCHCOL_WIDEST

   oBrw:CreateFromCode()


   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oBrw:MakeTotals() )

return nil


RC file
Code: Select all  Expand view
FOLDER     BITMAP "c:\fwh\bitmaps\16x16\folder3.bmp"
CLOSE    BITMAP "c:\fwh\bitmaps\16x16\folder.bmp"
OPEN     BITMAP "c:\fwh\bitmaps\16x16\Open.bmp"
FIND     BITMAP "c:\fwh\bitmaps\16x16\find.bmp"
 
Regards

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

Re: xBrowse questions

Postby Rick Lipkin » Fri Jun 12, 2009 1:12 pm

Rao

Interesting column total routine .. I have a numeric column already defined in an ado recordset .. how would I use maketotals() in that scenario ?

Rick
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse questions

Postby nageswaragunupudi » Fri Jun 12, 2009 11:39 pm

Rick Lipkin wrote:Rao

Interesting column total routine .. I have a numeric column already defined in an ado recordset .. how would I use maketotals() in that scenario ?

Rick

Same syntax works for any data (ado, rdd, array ). After defining the columns either in @ .. xbrowse command or in ADD TO oBrw command,

oCol:lTotal := .t.
oCol:nTotal := 0 // if we already know the total, we can assign the total value.

There is no need to separately assign cFooter or bFooter. XBrowse knows :ntotal is to be shown as footer with the same picture format applicable to the column.

( Note: In case of ADO and RDD, there is no need to specify the picture clause / column size. XBrowse makes a picture clause based on the field width and decimals and also the column size )

After this whenever we call oBrw:MakeTotals(), XBrowse calculates totals for all columns into oCol:nTotal, where oCol:lTotal is .t. and oCol:ntotal is numeric.

oBrw:RefreshFooters() redraws footers only

If a column is edited and if that columns lTotal is true and nTotal is numeric, the xbrowse automatically changes the oCol:nTotal with the difference between the original value and the edited value and redraws that columns footer. We do not have to write any special code in our program to recompute totals and repaint the footer.
Regards

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

Re: xBrowse questions

Postby Rick Lipkin » Sat Jun 13, 2009 12:08 am

Rao

I worked thru the same solution earlier today .. I looked at the \samples.. testtxx examples .. I did a quick loop and got my totals and placed them in the correct footer column ..

As far as any dynamic re-calc .. not really necessary .. however, I may need to re-visit that decision.

Rick
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse questions

Postby nageswaragunupudi » Sat Jun 13, 2009 12:14 am

>
I did a quick loop and got my totals
>
Instead of our doing it, xbrowse does it for us.
Regards

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

Re: xBrowse questions

Postby Rick Lipkin » Sat Jun 13, 2009 12:21 am

Rao

I tried .. could not get any results .. here is my code :

Rick

Code: Select all  Expand view

//----------------------------------------
Static Func _Hhimport( oRsImport, xDATE, oPCAS, oBtn3 )

LOCAL oDlg1,oLbx1,cTITLE,oBtn1,oBtn2
LOCAL SAYING, nHOURS, nMINUTES

SAYING := "There are Encore Records that can be Imported in PCAS"+chr(10)
SAYING += "Would you like to view them now ?"+chr(10)

IF MsgYesNo( SAYING )
ELSE
   RETURN(NIL)
ENDIF

nHOURS   := 0
nMINUTES := 0

oRsImport:MoveFirst()
DO WHILE .not. oRsImport:eof

   nHOURS   := nHOURS+oRsImport:Fields("hours"):Value
   nMINUTES := nMINUTES+oRsImport:Fields("minutes"):Value
   oRsImport:MoveNext()

ENDDO

oRsImport:MoveFirst()

cTITLE := "Potential PCAS Import records for Date "+DTOC(xDATE )

DEFINE DIALOG oDlg1 RESOURCE "PCASIMPT"  ;
       COLOR "N/W"                       ;
       TITLE cTITLE                      ;

   REDEFINE xBROWSE oLbx1 ;
      ID 111 of oDlg1     ;
      RECORDSET oRsImport ;
      AUTOSORT AUTOCOLS FOOTERS LINES CELL

   oLbx1:oCol("HOURS"):nTOTAL  := nHOURS
   oLbx1:oCol("HOURS"):lTOTAL  := .t.
   oLbx1:oCol("MINUTES"):nTOTAL  := nMINUTES
   oLbx1:oCol("MINUTES"):lTOTAL  := .t.


   REDEFINE BUTTON oBTN1 ID 112 of oDLG1     ;
       ACTION ( _Loadum( oRsImport, oDlg1, oBtn3 ) ) ;
       DEFAULT

   REDEFINE BUTTON oBTN2 ID 118 of oDLG1     ;
       ACTION ( oDlg1:End() )

ACTIVATE DIALOG oDlg1 ;
    ON INIT( oLbx1:SetFocus(), .F. )


RETURN(NIL)

 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse questions

Postby nageswaragunupudi » Sat Jun 13, 2009 3:57 am

Mr Rick

Please include oLbx1:MakeTotals() in the INIT clause
Code: Select all  Expand view
ACTIVATE DIALOG oDlg1 ;
    ON INIT( oLbx1:MakeTotals(), oLbx1:SetFocus(), .F. )
 

Also you may initialize :nTotal := 0, to know that the totals are really made by xbrowse.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 106 guests