xbrowse:brwfitsize(.T.)

xbrowse:brwfitsize(.T.)

Postby Franklin Demont » Sun Mar 24, 2013 4:51 pm

Code: Select all  Expand view

#include "FiveWin.ch"
#include "xbrowse.ch"
PROC MAIN()
********************
LOCAL oDlg
LOCAL WinTit := "Test BrwFitSize"
LOCAL oBrw1 , oBrw2 , aData1 , aData2 , aData

aData1 := {"el 1","el 2", "el 3"}
aData2 := {{"el 1",{"el 11","el 12" , "el 13" , "el 14","el 15" , "el 16"}},;
           {"el 2",{"el 21","el 22" , "el 23"}},;
                     {"el 3",{"el 31","el 32" , "el 33" , "el 34","el 35" , "el 36"}}}
aData := aData2[1,2]
 DEFINE DIALOG oDlg SIZE 900,600 PIXEL TITLE WinTit

 @ 2 ,2 XBROWSE oBrw1 OF oDlg ARRAY aData1;
                    SIZE 50 , 230 PIXEL;
          AUTOCOLS LINES

 WITH OBJECT oBrw1
    :lRecordSelector := .F.
    :lHscroll        := .F.
    :bChange :=  {|self,lRow|oBrw2:aArrayData := aData2[oBrw1:nArrayAt,2] ,;
                             oBrw2:BrwFitSize(.T.) , oBrw2:Refresh(.T.)}
    :CreateFromCode()
 END
 
 @ 2, 100 XBROWSE oBrw2 OF oDlg ARRAY aData;
                    SIZE 50 , 230 PIXEL;
          AUTOCOLS LINES

 WITH OBJECT oBrw2
    :lRecordSelector := .F.
    :lHscroll        := .F.
    :CreateFromCode()
 END

ACTIVATE DIALOG oDlg CENTER ON INIT oBrw2:BrwFitSize(.T.)
RETURN
 


Starting this aplication , RowCount() from oBrw2 is adjusted to 6 elements , the second browse fit's to 6 elements.

Giving el2 from obrw1 (second row) focus adjust rowcount() from obrw2 to 3 elements , the second browse fit's to 3 elements , CORRECT !

Giving el3 from obrw1 (third row) focus adjust rowcount() from obrw2 to 3 elements , the second browse fit's to 3 elements , FALSE , it should be 6 !

Originally oBrw2 could have 24 elements. BrwFitsize overwrite oBrw2:nHeight , the originally value is lost

I added a second parameter to BrwFitSize (nMaxRow) , BrwFitSize should be replaced with BrwFitSize(.T.,nMaxRow)

Code: Select all  Expand view

LOCAL nMaxRow
......
  :bChange :=  {|self,lRow|oBrw2:aArrayData := aData2[oBrw1:nArrayAt,2] ,;
                             oBrw2:BrwFitSize(.T. , nMaxRow) , oBrw2:Refresh(.T.)}
......
ACTIVATE DIALOG oDlg CENTER ON INIT (nMaxRow := oBrw2:RowCount() , oBrw2:BrwFitSize(.T. , nMaxRow))

METHOD BrwFitSize( lReSize , nMaxRow ) CLASS TXBrowse
...
DEFAULT nMaxRow := ::RowCount()
...
nHeight  := Max( 3, Min( nMaxRow, ::KeyCount() ) ) * ::nRowHeight + ;
                        If( ::lHeader, ::nHeaderHeight, 0 ) + ;
                        If( ::lFooter, ::nFooterHeight, 0 ) + 1 + nY
 


Frank
test
Franklin Demont
 
Posts: 166
Joined: Wed Aug 29, 2012 8:25 am

Re: xbrowse:brwfitsize(.T.)

Postby nageswaragunupudi » Mon Mar 25, 2013 7:45 am

Glad to see somone using this method.
The method was originally written for one time use initially to adjust sizes. Your use of this method is interesting.

Incorporated your suggestion in the next release.
Regards

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

Re: xbrowse:brwfitsize(.T.)

Postby Franklin Demont » Mon Mar 25, 2013 9:25 am

nageswaragunupudi wrote:Glad to see somone using this method.
The method was originally written for one time use initially to adjust sizes. Your use of this method is interesting.

Incorporated your suggestion in the next release.


Thanks for your kind words.

Another possible solution is to create a new DATA in Txbrowse , nMaxrow.

First lines from BrwFitsize

local nMaxRow
IF ::nMaxRow == nil
::nMaxRow := ::RowCount()
END
DEFAULT nMaxRow := ::nMaxrow

Then we can call Brwfitsize as usual and must give no attention to set nMaxrow in the calling routine.

Another change i made was to provide two parameters to resize : lHresize and lVresize.

Frank
Code: Select all  Expand view

PROC MAIN()
********************
LOCAL oDlg
LOCAL WinTit := "Test BrwFitSize"
LOCAL oBrw1 , oBrw2 , aData1 , aData2 , aData
LOCAL nMaxRow

aData1 := {"el 1","el 2", "el 3"}
aData2 := {{"el 1",{"el 11","el 12" , "el 13" , "el 14","el 15" , "el 16"}},;
           {"el 2",{"el 21","el 22" , "el 23"}},;
                     {"el 3",{"el 31","el 32" , "el 33" , "el 34","el 35" , "el 36"}}}
aData := aData2[1,2]
 DEFINE DIALOG oDlg SIZE 900,600 PIXEL TITLE WinTit

 @ 2 ,2 XBROWSE oBrw1 OF oDlg ARRAY aData1;
                    SIZE 50 , 230 PIXEL;
          AUTOCOLS LINES

 WITH OBJECT oBrw1
    :lRecordSelector := .F.
    :lHscroll        := .F.
    :bChange :=  {|self,lRow|oBrw2:aArrayData := aData2[oBrw1:nArrayAt,2] ,;
                             oBrw2:BrwFitSize(.T.) , oBrw2:Refresh(.T.)}
    :CreateFromCode()
 END

 
 @ 2, 100 XBROWSE oBrw2 OF oDlg ARRAY aData;
                    SIZE 50 , 230 PIXEL;
          AUTOCOLS LINES

 WITH OBJECT oBrw2
    :lRecordSelector := .F.
    :lHscroll        := .F.
    :CreateFromCode()
 END

ACTIVATE DIALOG oDlg CENTER ON INIT (oBrw2:BrwFitSize(.T. ))
RETURN
 


In Xbrowse :
Code: Select all  Expand view

METHOD BrwFitSize( lReSize  ) CLASS TXBrowse

   local oRect, nX, nY
   local nWidth      := ::nWidth
   local nHeight     := ::nHeight
   local nMaxRow     := ::RowCount()
   IF ! __ObjHasData(self,"nMaxRow")
     __ObjAddData(self,"nMaxRow")   
   END
   IF ::nMaxRow == nil
     ::nMaxRow := ::RowCount()
   END
   nMaxRow := ::nMaxRow
   
   if ::lAdjusted

      DEFAULT lReSize   := .f.

      oRect    := ::GetCliRect()
      nX             := nWidth  - oRect:nWidth
      nY             := nHeight - oRect:nHeight

      nWidth         := ::GetDisplayColsWidth() + 1 + nX
      nHeight        := Max( 3, Min( nMaxRow, ::KeyCount() ) ) * ::nRowHeight + ;
                        If( ::lHeader, ::nHeaderHeight, 0 ) + ;
                        If( ::lFooter, ::nFooterHeight, 0 ) + 1 + nY
.....
 
test
Franklin Demont
 
Posts: 166
Joined: Wed Aug 29, 2012 8:25 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], paquitohm and 30 guests