XBrowse / Array / 9.07

XBrowse / Array / 9.07

Postby TimStone » Tue Aug 25, 2009 10:52 pm

I have discovered a strange behavior with xBrowse in 9.07 ( with xHarbour / xBuilder )

The following code

Code: Select all  Expand view
REDEFINE XBROWSE oLBxa ID 2100 OF oDlu ;
            ON DBLCLICK( aPar[ oLbxa:nAt, 1 ] := IIF( aPar[ oLbxa:nAt, 1 ] = "I", "E", "I" ), oDlu:update() ) ;
            MESSAGE "Double click on an item to change the Estimate/Invoice status" UPDATE
        // Attach the database
        oLbxa:setArray( aPar )
        // Add the columns
        ADD TO oLbxa DATA ARRAY ELEMENT 1 HEADER "S" ALIGN CENTER
        ADD TO oLbxa DATA ARRAY ELEMENT 2 HEADER "Quantity" ALIGN RIGHT
        ADD TO oLbxa DATA ARRAY ELEMENT 3 HEADER "Partnumber" ALIGN LEFT
        ADD TO oLbxa DATA ARRAY ELEMENT 4 HEADER "Description" ALIGN LEFT
        add to oLbxa Header "     " data SPACE(20 ) // for blank at the end of the header
        // Provide the header gradient
        oLbxa:bClrGrad := { | lInvert | If( ! lInvert, { { 0.50,16776960,16777215 }, ;
            { 0.50,16777215,16776960 } }, { { 0.50,128,16777215 }, { 0.50,16777215,128 } } ) }
        // Set the header and row heights
        oLbxa:nHeaderHeight := 30
        oLbxa:nRowHeight := 24
        // Turn off horizontal scrolling
        oLbxa:lHScroll := .F.
        // Set the styles
        oLbxa:nMarqueeStyle := MARQSTYLE_HIGHLROW
        oLbxa:nColDividerStyle := LINESTYLE_RAISED
        oLbxa:nRowDividerStyle := LINESTYLE_RAISED
 



has a problem with the display. Although I specify the headers, first I get the columns displayed with Col 1, Col 2, Col 3 Etch on the top, and then I get a second set of columns with the proper headers displayed.

I would appreciate some thoughts on this.
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 / Array / 9.07

Postby nageswaragunupudi » Wed Aug 26, 2009 3:04 am

SetArray() method automatically adds all the columns.
So please add another line after SetArray like this:
Code: Select all  Expand view
oLbxa:setArray( aPar )
oLbxa:aCols := {}  
 

This solves the above issue.

May I suggest another simpler way to code the above ?
Code: Select all  Expand view
  REDEFINE XBROWSE oLBxa ID 2100 OF oDlu ;
      COLUMNS 1, 2, 3, 4 ;       // This is line is not necessary if there are only 4 columns in the array
      HEADERS "S", "Quantity", "Partnumber", "Description"  ARRAY aPar ;
      ON DBLCLICK < your code > MESSAGE <your msg >
 

XBrowse automatically aligns numerics and dates to RIGHT. We need to use alignment clauses only if we want an unconventional alignment.
You may not need to add a blank column at the end, unless you need it for some specific purpose.
Please try this alternative code and see if this is okay for you.
Regards

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

Re: XBrowse / Array / 9.07

Postby TimStone » Wed Aug 26, 2009 4:06 pm

Thank you
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 / Array / 9.07

Postby TimStone » Wed Aug 26, 2009 6:17 pm

The first suggestion solved the problem.

The alternative did not work. It will not compile.

I found, with txbrowse, that I have to add a blank column at the end if the data does not fill the control space allotted. This is because the header coloring only applies to specified columns and does not stretch the width of the browse control ( on a REDEFINE )
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 / Array / 9.07

Postby hua » Thu Aug 27, 2009 1:40 am

TimStone wrote:I found, with txbrowse, that I have to add a blank column at the end if the data does not fill the control space allotted. This is because the header coloring only applies to specified columns and does not stretch the width of the browse control ( on a REDEFINE )


Tim, have you tried using oXbrw:nStretchCol property to have the whole control filled? You could specify either a specific column number to stretch or make use of constants such as STRETCHCOL_LAST

HTH
Last edited by hua on Thu Aug 27, 2009 3:42 am, edited 1 time in total.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: XBrowse / Array / 9.07

Postby TimStone » Thu Aug 27, 2009 2:33 am

Thank you. I was not aware of that option.

I am transforming from tsBrowse to xBrowse. I'm happy with the results, but there are things to learn. I'm also optimizing code throughout my program which is a LOT, but it is improving performance.
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 / Array / 9.07

Postby hua » Thu Aug 27, 2009 3:30 am

I'm still in the process of learning too. Here's the complete constant that can be assigned to nStretchCol property (from xbrowse.ch):
Code: Select all  Expand view
#define STRETCHCOL_NONE       nil
#define STRETCHCOL_LAST       -1
#define STRETCHCOL_WIDEST     -2
 
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: XBrowse / Array / 9.07

Postby nageswaragunupudi » Thu Aug 27, 2009 3:41 am

I'm still in the process of learning too. Here's the complete constant that can be assigned to
nStretchCol property (from xbrowse.ch):


STRETCHCOL_NONE is the default. No column is stretched.
You know STRETCHCOL_LAST. It is self explanatory.
We can also write
oBrw:nStretchCol := 3 or 4 or any number. In that case, XBrowse stretches that column only.

For example, if the last column is a numeric or date, it appears awkward if that last column is stretched. Instead it looks better to stretch some middle column which is a character value. In that case we can specify that column number.

STRETCHCOL_WIDEST:
If we specify this, XBrowse finds out that column containing a character value which is already the widest column. This column is stretched. From my personal experience, this option presents a more acceptable view.

This is because the header coloring only applies to specified columns and does not stretch the width of the browse control


This is a bug got introduced when multiple headers were provided. Earlier the entier header was painted in color. Hope this will be fixed soon.
Regards

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

Re: XBrowse / Array / 9.07

Postby nageswaragunupudi » Thu Aug 27, 2009 4:01 am

Mr TimStone

The alternative did not work. It will not compile

I have this sample code which compiles well and works well. Please try compiling this code. If this works you can modify your code accordingly. This approach saves a lot of coding and is easier to write and maintain.
Code: Select all  Expand view
#include "FiveWin.Ch"
#include "xbrowse.ch"
//------------------------------------------------------------------//

function Main()

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

   DEFINE DIALOG oDlg SIZE 440,240 PIXEL
   @ 10,10 XBROWSE oBrw SIZE 200,100 PIXEL OF oDlg ;
      COLUMNS 1, 2, 3, 4 ;
      HEADERS 'No', 'Description', 'Number', 'Date' ;
      ARRAY aData ;
      ON DBLCLICK MsgInfo( 'ok' ) ;
      MESSAGE 'my message'

   WITH OBJECT oBrw
      :lHScroll         := .F.
      :nMarqueeStyle    := MARQSTYLE_HIGHLROW
      :nColDividerStyle := LINESTYLE_RAISED
      :nRowDividerStyle := LINESTYLE_RAISED
      :nStretchCol      := STRETCHCOL_WIDEST
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return ( 0 )
 


Image

Please note the automatic alignment of numbers and dates and also automatic allotment of column-widths.
Regards

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

Re: XBrowse / Array / 9.07

Postby TimStone » Thu Aug 27, 2009 6:51 pm

I spent time with various formats yesterday without success. I am using a REDEFINE. I will experiment more in other files today.
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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Enrico Maria Giordano, Google [Bot] and 69 guests