edit a cell of a xbrowse

edit a cell of a xbrowse

Postby Silvio.Falconi » Thu Jun 09, 2022 11:34 am

I build a dialog to create matrices that I need to create reduced systems

Image

at the beginning I create an xbrowse with three columns and one row

the rows are the combinations of the matrix

and I can edit any cell,insert a number and then press return

problems arise when I add rows or columns

the columns can be max 10 while the rows can be infinite depending on the system that the user creates

when I create rows I made

Code: Select all  Expand view

static function AddRow( oBrw,nRow )
   local nTotal  := oBrw:nDataRows

   IF nRow < nTotal
      DeleteRow( oBrw )
   ELSE
      AAdd( oBrw:aArrayData, BlankRow(nRow) )

       oBrw:Refresh()
       oBrw:GoBottom()
   Endif
   return nil



when I create columns I made

Code: Select all  Expand view

static function AddCol( oBrw,nCol )
   local nTotal  := len(oBrw:aCols)
   local nPos    := nTotal

   IF nCol < nTotal
      oBrw:DelCol( nTotal )
       oBrw:Refresh()
      else
         IF nCol <= 10
            ADD COLUMN TO XBROWSE  oBrw
         Endif
      Endif


      For n=1 to len(oBrw:aCols)
         oBrw:aCols[n]:cheader :=ltrim(str(n))
         oBrw:aCols[n]:nWidth   := 30
         oBrw:aCols[n]:nEditType := EDIT_GET
      Next

   oBrw:Refresh()
   oBrw:GoBottom()

   return nil
 


any solution please ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: edit a cell of a xbrowse

Postby nageswaragunupudi » Fri Jun 10, 2022 6:19 pm

Try this sample as it is and then apply to your requirements.
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local aData := { { 1,2,3 }, { 4,5,6 } }
   local oDlg, oBrw, oFont
   local nRows    := Len( aData )
   local nCols    := Len( aData[ 1 ] )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
   DEFINE DIALOG oDlg SIZE 880,400 PIXEL TRUEPIXEL FONT oFont

   @ 20,140 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :RecSelShowKeyNo()
      AEval( :aCols, { |o,i| o:cHeader := LTrim( Str( i, 2 ) ) } )
      :nEditTypes    := EDIT_GET
      :nWidths       := 60
   END
   oBrw:CreateFromCode()

   @ 40,20 GET nRows SIZE 100,30 PIXEL OF oDlg SPINNER MIN 2 MAX 100 ;
      ON CHANGE ResizeArray( oBrw, nRows, nCols )
   @ 90,20 GET nCols SIZE 100,30 PIXEL OF oDlg SPINNER MIN 2 MAX 10 ;
      ON CHANGE ResizeArray( oBrw, nRows, nCols )

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

   XBROWSER aData

return nil

//----------------------------------------------------------------------------//

static function ResizeArray( oBrw, nRows, nCols )

   local aData    := oBrw:aArrayData
   local iRows, iCols, n

   iCols := Len( oBrw:aCols )
   if ( iRows := oBrw:nLen ) != nRows .or. iCols != nCols

      ASize( aData, nRows )
      if nCols != iCols
         AEval( aData, { |a| ASize( a, nCols ), ;
          If( nCols > iCols, AFill( a, 0, iCols + 1 ), nil ) }, 1, Min( iRows, nRows ) )
      endif
      for n := iRows + 1 to nRows
         aData[ n ]  := Array( nCols )
         AFill( aData[ n ], 0 )
      next
      //
      oBrw:SetArray( aData, .f., 0, .t. )
      WITH OBJECT oBrw
         AEval( :aCols, { |o,i| o:cHeader := LTrim( Str( i, 2 ) ) } )
         :nEditTypes    := EDIT_GET
         :nWidths       := 60
         :lFastEdit     := .t.
      END

   endif

return nil

//----------------------------------------------------------------------------//
 
Regards

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

Re: edit a cell of a xbrowse

Postby Silvio.Falconi » Fri Jun 10, 2022 9:13 pm

Fantastic You're Greate
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: edit a cell of a xbrowse

Postby nageswaragunupudi » Sat Jun 11, 2022 6:58 am

This is another variant.
Please check:
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local aData := { { 1,2,3 }, { 4,5,6 } }
   local oDlg, oBrw, oFont
   local nRows    := Len( aData )
   local nCols    := Len( aData[ 1 ] )
   local nMaxCols := 10

   if nMaxCols > nCols
      AEval( aData, { |aRow| ASize( aRow, nMaxCols ), AFill( aRow, 0, nCols + 1 ) } )
   endif

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
   DEFINE DIALOG oDlg SIZE 880,400 PIXEL TRUEPIXEL FONT oFont

   @ 20,140 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :RecSelShowKeyNo()
      AEval( :aCols, { |o,i| o:cHeader := LTrim( Str( i, 2 ) ), o:lHide := i > nCols } )
      :nEditTypes    := EDIT_GET
      :nWidths       := 60
      :lAllowColHiding     := .f.
      :lAllowColSwapping   := .f.
   END
   oBrw:CreateFromCode()

   @ 40,20 GET nRows SIZE 100,30 PIXEL OF oDlg SPINNER MIN 2 MAX 100 ;
      ON CHANGE ResizeRows( oBrw, nRows )
   @ 90,20 GET nCols SIZE 100,30 PIXEL OF oDlg SPINNER MIN 2 MAX 10 ;
      ON CHANGE ( AEval( oBrw:aCols, { |o,i| o:lHide := i > nCols } ), ;
                  oBrw:Refresh() )

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

   if Len( aData ) > nRows
      ASize( aData, nRows )
   endif
   if Len( aData[ 1 ] ) > nCols
      AEval( aData, { |a| ASize( a, nCols ) } )
   endif

   XBROWSER aData

return nil

//----------------------------------------------------------------------------//

static function ResizeRows( oBrw, nRows )

   do while Len( oBrw:aArrayData ) < nRows
      AAdd( oBrw:aArrayData, Array( Len( oBrw:aArrayData[ 1 ] ) ) )
      AFill( ATail( oBrw:aArrayData ), 0 )
   enddo

   if nRows < Len( oBrw:aArrayData )
      oBrw:bKeyCount    := { || nRows }
   else
      oBrw:bKeyCount    := { || Len( oBrw:aArrayData ) }
   endif

   oBrw:Refresh()

return nil

//----------------------------------------------------------------------------//
 
Regards

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

Re: edit a cell of a xbrowse

Postby Silvio.Falconi » Sat Jun 11, 2022 8:41 am

I have problems, i saw the test tonight.
First the Array must be empty and only 1x3.
Then I cannot stop the resizing of Columms and Roses.
I insert Aldo The commands lallow....:=.f. but not run ok.
And Inot now how resolved.
Then when I edit It take the valute only of I Press return.
If I move with mouse and digit Numbers then It not save the valute on Cell .
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: edit a cell of a xbrowse

Postby nageswaragunupudi » Sat Jun 11, 2022 10:25 am

i do not understand you clearly.
Please explain point by point clearly.
Regards

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

Re: edit a cell of a xbrowse

Postby Silvio.Falconi » Sat Jun 11, 2022 11:54 am

nageswaragunupudi wrote:i do not understand you clearly.
Please explain point by point clearly.


Sorry I wrote it from my smartphone while driving...... I explain you

This is my test (with your functions)

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

function Matrix()
local oDlg, oBrw, oFont, oBold, oFontGet
local nBottom   := 33
local nRight    := 80
local nWidth    := Max( nRight * DLG_CHARPIX_W, 180 )
local nHeight   := nBottom * DLG_CHARPIX_H
local oPanelTitle
local oGrp:=array(3)

local oBtnClose,oBtnSave,oBtnPrint
local oBtnReset,oBtnInsert

   local aData     :=  {{ 1,2,3 } }   //, { 4,5,6 }       {}
   local nRows     := Len( aData )
   local nCols     := Len( aData[ 1 ] )
   local nNumbers  :=10
   local nGuarantee:= 1
   local nPoints   := 1

 DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-10
 DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12  BOLD
 DEFINE FONT oFontGet NAME "TAHOMA" SIZE 0,-14


DEFINE DIALOG oDlg SIZE  nWidth, nHeight  ;
   PIXEL TRUEPIXEL  FONT oFont   ;  //RESIZABLE
   TiTle "Manage Matrix"



 @ 70, 180 XBROWSE oBrw SIZE 395,300 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS CELL LINES NOBORDER FASTEDIT

           SetupBrowseMatrix(oBrw)


    @ 70,10 SAY "Total quantity of numbers" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 160,10 SAY "Development (nr. for  column)" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 230,10 SAY "Combinations" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 340,7 SAY  "Guarantee" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 340,130 SAY "points" SIZE 30,24 PIXEL OF oDlg FONT oFont
    @ 375,7 SAY "width" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 375,130 SAY "numbers" SIZE 35,24 PIXEL OF oDlg FONT oFont


   @ 90,10 GET nNumbers SIZE 100,24 PIXEL;
             SPINNER MIN 5 MAX 90  OF oDlg  ;
             PICTURE "99"   FONT oFontGet

   @ 250 ,10 GET nRows SIZE 100,24 PIXEL OF oDlg SPINNER MIN 2 MAX 100 ;
      ON CHANGE ResizeArray( oBrw, nRows, nCols )  FONT oFontGet

   @ 180,10 GET nCols SIZE 100,24 PIXEL OF oDlg SPINNER MIN  3 MAX 10 ;
      ON CHANGE ResizeArray( oBrw, nRows, nCols ) FONT oFontGet

    @ 335 ,55 GET nGuarantee SIZE 50,24 PIXEL;
             SPINNER MIN 1  MAX 10  OF oDlg  ;
             PICTURE "99"  FONT oFontGet

     @ 370 ,55 GET nPoints  SIZE 50,24 PIXEL;
             SPINNER MIN 1  MAX 10  OF oDlg  ;
             PICTURE "99"  FONT oFontGet



    @ 50,175 GROUP oGrp[1] To 410,oDlg:nWidth-20 Label "Matrix" TRANSPARENT PIXEL  OF oDlg
    @ 50,2   GROUP oGrp[2] To 300,170 Label "Reduced System" TRANSPARENT PIXEL  OF oDlg
    @ 310,2 GROUP oGrp[3] To 410,170 Label "Guarantee" TRANSPARENT PIXEL  OF oDlg




     @ 100,10 BUTTON oBtnReset PROMPT "Reset" of oDlg    SIZE 80,22 ACTION NIL
     @ 100,10 BUTTON oBtnInsert PROMPT "Insert" of oDlg  SIZE 80,22 ACTION NIL
     @ 100,10 BUTTON oBtnPrint PROMPT "Print" of oDlg  SIZE 80,22 ACTION oBrw:Report()
     @ 100,10 BUTTON oBtnClose PROMPT "Close" of oDlg  SIZE 80,22 ACTION oDlg:End()
     @ 100,10 BUTTON oBtnSave  PROMPT "Save"  of oDlg  SIZE 80,22 ACTION NIL


  oDlg:bResized := <||
                local oRect := oDlg:GetCliRect()
                oBtnPrint:nLeft    := oRect:nRight - 200
                oBtnPrint:nTop     := oRect:nBottom - 45
                oBtnClose:nLeft    := oRect:nRight - 100
                oBtnClose:nTop     := oRect:nBottom - 45
                oBtnSave:nLeft     := oRect:nRight - 300
                oBtnSave:nTop      := oRect:nBottom - 45
                oBtnReset:nLeft    := oRect:nLeft+10
                oBtnReset:nTop     := oRect:nBottom - 45
                oBtnInsert:nLeft   := oRect:nLeft+100
                oBtnInsert:nTop    := oRect:nBottom - 45

                oBrw:nWidth        := oRect:nWidth - 210
                oPanelTitle:nTop   := oRect:ntop
                oPanelTitle:nLeft  := oRect:nleft+2
                oPanelTitle:nwidth := oRect:nRight

                           RETURN NIL
                       >

   ACTIVATE DIALOG oDlg CENTERED;
               ON INIT (oPanelTitle:=Paneltitle(oDlg),;
                        SayTexttitle(oPanelTitle,oFont) ,;
                        Eval(oDlg:bResized))

   RELEASE FONT oFont, oBold, oFontGet

   XBROWSER aData

return nil

static function ResizeArray( oBrw, nRows, nCols )

   local aData    := oBrw:aArrayData
   local iRows, iCols, n

   iCols := Len( oBrw:aCols )
   if ( iRows := oBrw:nLen ) != nRows .or. iCols != nCols

      ASize( aData, nRows )
      if nCols != iCols
         AEval( aData, { |a| ASize( a, nCols ), ;
          If( nCols > iCols, AFill( a, 0, iCols + 1 ), nil ) }, 1, Min( iRows, nRows ) )
      endif
      for n := iRows + 1 to nRows
         aData[ n ]  := Array( nCols )
         AFill( aData[ n ], 0 )
      next
      //
      oBrw:SetArray( aData, .f., 0, .t. )
      WITH OBJECT oBrw
         AEval( :aCols, { |o,i| o:cHeader := LTrim( Str( i, 2 ) ) } )
         :nEditTypes    := EDIT_GET
         :nWidths       := 30
         :lFastEdit     := .t.
      END

   endif

return nil

//----------------------------------------------------------------------------//
static function SetupBrowseMatrix(oBrw)

 WITH OBJECT oBrw
      :RecSelShowKeyNo()

      AEval( :aCols, { |o,i| o:cHeader := LTrim( Str( i, 2 ) ) } )

         :nEditTypes    := EDIT_GET
         :nWidths       := 30

         :lHscroll            := .f.
         :lVscroll            := .t.
         :l2007               := .f.
         :l2015               := .f.

         :lAllowRowSizing     := .f.
         :lAllowColSwapping   := .f.
         :lAllowColHiding     := .f.



         :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
         :nColDividerStyle    := LINESTYLE_LIGHTGRAY
         :bRecSelHeader    := { || " " }
         :SetStyle( 2018 )

         :CreateFromCode()
   END
  return nil
//---------------------------------------------------------------------------------------------------------//

 static function Paneltitle(oDlg)
  local oPanel,oBrush
  Local aGrad:= { RGB(173,216,230),RGB(255,255,255)}
  DEFINE BRUSH oBrush GRADIENT aGrad
     oPanel:=Tpanel():New( 45, 2, 88, oDlg:nWidth-20, oDlg)
     oPanel:SetBrush( oBrush )
    // oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }
     return oPanel
//---------------------------------------------------------------------------------------------------------//

static function  SayTexttitle(oPanelTitle,oFont)

   @ 10,10 SAY "Creation Reduced Matrix" SIZE 150,24 PIXEL OF oPanelTitle FONT oFont  TRANSPARENT

  RETURN NIL

 




Image


(1) on SetupBrowseMatrix(oBrw) function there are these commands

:lAllowRowSizing := .f.
:lAllowColSwapping := .f.
:lAllowColHiding := .f.

But I can resize the rows and columns...why ?

(2) when I enter a number by moving between the cells with the mouse, the value is not saved if I don't remember to press enter

(3) at the beginning the array must be empty and with only one row and three columns

(4) if the end user wants to automatically delete all the values in all the rows what should I do?

(5) if in memory I have saved a text for example
1,2,3,4,5
5,4,6,7,8
5,3,6,2,1
how could I do to automatically insert it in the array and then in the browse?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: edit a cell of a xbrowse

Postby nageswaragunupudi » Sat Jun 11, 2022 5:42 pm

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

function Matrix()
local oDlg, oBrw, oFont, oBold, oFontGet
local nBottom   := 33
local nRight    := 80
local nWidth    := Max( nRight * DLG_CHARPIX_W, 180 )
local nHeight   := nBottom * DLG_CHARPIX_H
local oPanelTitle
local oGrp:=array(3)

local oBtnClose,oBtnSave,oBtnPrint
local oBtnReset,oBtnInsert

   local aData     :=  {{ 0,0,0}} //{{ 1,2,3 } }   //, { 4,5,6 }       {}
   local nRows     := Len( aData )
   local nCols     := Len( aData[ 1 ] )
   local nNumbers  :=10
   local nGuarantee:= 1
   local nPoints   := 1

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-10
   DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12  BOLD
   DEFINE FONT oFontGet NAME "TAHOMA" SIZE 0,-14


   DEFINE DIALOG oDlg SIZE  nWidth, nHeight  ;
      PIXEL TRUEPIXEL  FONT oFont   ;  //RESIZABLE
      TiTle "Manage Matrix"



   @ 70, 180 XBROWSE oBrw SIZE 395,300 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS CELL LINES NOBORDER FASTEDIT

      SetupBrowseMatrix(oBrw)
      oBrw:RecSelShowKeyNo()
      oBrw:CreateFromCode()


    @ 70,10 SAY "Total quantity of numbers" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 160,10 SAY "Development (nr. for  column)" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 230,10 SAY "Combinations" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 340,7 SAY  "Guarantee" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 340,130 SAY "points" SIZE 30,24 PIXEL OF oDlg FONT oFont
    @ 375,7 SAY "width" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 375,130 SAY "numbers" SIZE 35,24 PIXEL OF oDlg FONT oFont


   @ 90,10 GET nNumbers SIZE 100,24 PIXEL;
             SPINNER MIN 5 MAX 90  OF oDlg  ;
             PICTURE "99"   FONT oFontGet

   @ 250 ,10 GET nRows SIZE 100,24 PIXEL OF oDlg SPINNER MIN 1 MAX 100 ;
      ON CHANGE ResizeArray( oBrw, nRows, nCols )  FONT oFontGet

   @ 180,10 GET nCols SIZE 100,24 PIXEL OF oDlg SPINNER MIN  3 MAX 10 ;
      ON CHANGE ResizeArray( oBrw, nRows, nCols ) FONT oFontGet

    @ 335 ,55 GET nGuarantee SIZE 50,24 PIXEL;
             SPINNER MIN 1  MAX 10  OF oDlg  ;
             PICTURE "99"  FONT oFontGet

     @ 370 ,55 GET nPoints  SIZE 50,24 PIXEL;
             SPINNER MIN 1  MAX 10  OF oDlg  ;
             PICTURE "99"  FONT oFontGet



    @ 50,175 GROUP oGrp[1] To 410,oDlg:nWidth-20 Label "Matrix" TRANSPARENT PIXEL  OF oDlg
    @ 50,2   GROUP oGrp[2] To 300,170 Label "Reduced System" TRANSPARENT PIXEL  OF oDlg
    @ 310,2 GROUP oGrp[3] To 410,170 Label "Guarantee" TRANSPARENT PIXEL  OF oDlg




     @ 100,10 BUTTON oBtnReset PROMPT "Reset" of oDlg    SIZE 80,22 ACTION SetZeros( oBrw )
     @ 100,10 BUTTON oBtnInsert PROMPT "Insert" of oDlg  SIZE 80,22 ACTION NewData( oBrw, nil )
     @ 100,10 BUTTON oBtnPrint PROMPT "Print" of oDlg  SIZE 80,22 ACTION oBrw:Report()
     @ 100,10 BUTTON oBtnClose PROMPT "Close" of oDlg  SIZE 80,22 ACTION oDlg:End()
     @ 100,10 BUTTON oBtnSave  PROMPT "Save"  of oDlg  SIZE 80,22 ACTION NIL


  oDlg:bResized := <||
                local oRect := oDlg:GetCliRect()
                oBtnPrint:nLeft    := oRect:nRight - 200
                oBtnPrint:nTop     := oRect:nBottom - 45
                oBtnClose:nLeft    := oRect:nRight - 100
                oBtnClose:nTop     := oRect:nBottom - 45
                oBtnSave:nLeft     := oRect:nRight - 300
                oBtnSave:nTop      := oRect:nBottom - 45
                oBtnReset:nLeft    := oRect:nLeft+10
                oBtnReset:nTop     := oRect:nBottom - 45
                oBtnInsert:nLeft   := oRect:nLeft+100
                oBtnInsert:nTop    := oRect:nBottom - 45

                oBrw:nWidth        := oRect:nWidth - 210
                oPanelTitle:nTop   := oRect:ntop
                oPanelTitle:nLeft  := oRect:nleft+2
                oPanelTitle:nwidth := oRect:nRight

                           RETURN NIL
                       >

   ACTIVATE DIALOG oDlg CENTERED;
               ON INIT (oPanelTitle:=Paneltitle(oDlg),;
                        SayTexttitle(oPanelTitle,oFont) ,;
                        Eval(oDlg:bResized))

   RELEASE FONT oFont, oBold, oFontGet

   XBROWSER aData

return nil

static function ResizeArray( oBrw, nRows, nCols )

   local aData    := oBrw:aArrayData
   local iRows, iCols, n

   iCols := Len( oBrw:aCols )
   if ( iRows := oBrw:nLen ) != nRows .or. iCols != nCols

      ASize( aData, nRows )
      if nCols != iCols
         AEval( aData, { |a| ASize( a, nCols ), ;
          If( nCols > iCols, AFill( a, 0, iCols + 1 ), nil ) }, 1, Min( iRows, nRows ) )
      endif
      for n := iRows + 1 to nRows
         aData[ n ]  := Array( nCols )
         AFill( aData[ n ], 0 )
      next
      //
      oBrw:SetArray( aData, .f., 0, .t. )
      SetupBrowseMatrix( oBrw )

   endif

return nil

//----------------------------------------------------------------------------//
static function SetupBrowseMatrix( oBrw )

 WITH OBJECT oBrw
//      :RecSelShowKeyNo()

      AEval( :aCols, { |o,i| o:cHeader := LTrim( Str( i, 2 ) ) } )

         :nEditTypes    := EDIT_GET
         :nWidths       := 30

         :lHscroll            := .f.
         :lVscroll            := .t.
         :l2007               := .f.
         :l2015               := .f.

         :lAllowRowSizing     := .f.
         :lAllowColSwapping   := .f.
         :lAllowColHiding     := .f.
         // NEW
         :lAllowSizings       := .f.
         :lAutoSaves          := .t.


         :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
         :nColDividerStyle    := LINESTYLE_LIGHTGRAY
         :bRecSelHeader    := { || " " }
         :SetStyle( 2018 )

//         :CreateFromCode()
   END
  return nil
//---------------------------------------------------------------------------------------------------------//

 static function Paneltitle(oDlg)
  local oPanel,oBrush
  Local aGrad:= { RGB(173,216,230),RGB(255,255,255)}
  DEFINE BRUSH oBrush GRADIENT aGrad
     oPanel:=Tpanel():New( 45, 2, 88, oDlg:nWidth-20, oDlg)
     oPanel:SetBrush( oBrush )
    // oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }
     return oPanel
//---------------------------------------------------------------------------------------------------------//

static function  SayTexttitle(oPanelTitle,oFont)

   @ 10,10 SAY "Creation Reduced Matrix" SIZE 150,24 PIXEL OF oPanelTitle FONT oFont  TRANSPARENT

RETURN NIL

//----------------------------------------------------------------------------//

static function SetZeros( oBrw )

   AEval( oBrw:aArrayData, { |aRow| AFill( aRow, 0 ) } )
   oBrw:Refresh()

return nil

//----------------------------------------------------------------------------//

static function NewData( oBrw, cData )

   local aNewData
   local n

   DEFAULT  cData := ;
   "1,2,3,4,5" + CRLF + ;
   "5,4,6,7,8" + CRLF + ;
   "5,3,6,2,1"

   cData := StrTran( cData, CRLF, CHR(10) )
   aNewData := HB_ATokens( cData, CHR(10) )
   AEval( aNewData, { |c,i| aNewData[ i ] := HB_ATokens( c, "," ) } )
   for n := 1 to Len( aNewData )
      AEval( aNewData[ n ], { |c,i| aNewData[ n, i ] := Val( c ) } )
   next

   ResizeArray( oBrw, Len( aNewData ), Len( aNewData[ 1 ] ) )

   for n := 1 to Len( aNewData )
      oBrw:aArrayData[ n ] := aNewData[ n ]
   next

   SetupBrowseMatrix( oBrw )

return nil

//----------------------------------------------------------------------------//
 
Regards

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

Re: edit a cell of a xbrowse

Postby nageswaragunupudi » Sun Jun 12, 2022 1:56 am

But I can resize the rows and columns...why ?

oBrw:lAllowRowSizing := .f. // prevent row sizing
oCol:lAllowSizing := .f. // prevent col resizing of a particular column
oBrw:lAllowSizings := .f. // prent resizing of all columns.

(2) when I enter a number by moving between the cells with the mouse, the value is not saved if I don't remember to press enter

This is the default behaviour and is safe.
For what you want, set
oCol:lAutoSave := .t.
for all columns, set oBrw:lAutoSaves := .t.

(3) at the beginning the array must be empty and with only one row and three columns

Start with
local aData := {{0,0,0}}

(4) if the end user wants to automatically delete all the values in all the rows what should I do?

(5) if in memory I have saved a text for example
1,2,3,4,5
5,4,6,7,8
5,3,6,2,1
how could I do to automatically insert it in the array and then in the browse?

I posted functions in my latest revision
Regards

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

Re: edit a cell of a xbrowse

Postby Silvio.Falconi » Sun Jun 12, 2022 12:00 pm

nageswaragunupudi wrote:
But I can resize the rows and columns...why ?

oBrw:lAllowRowSizing := .f. // prevent row sizing
oCol:lAllowSizing := .f. // prevent col resizing of a particular column
oBrw:lAllowSizings := .f. // prent resizing of all columns.

(2) when I enter a number by moving between the cells with the mouse, the value is not saved if I don't remember to press enter

This is the default behaviour and is safe.
For what you want, set
oCol:lAutoSave := .t.
for all columns, set oBrw:lAutoSaves := .t.

(3) at the beginning the array must be empty and with only one row and three columns

Start with
local aData := {{0,0,0}}

(4) if the end user wants to automatically delete all the values in all the rows what should I do?

(5) if in memory I have saved a text for example
1,2,3,4,5
5,4,6,7,8
5,3,6,2,1
how could I do to automatically insert it in the array and then in the browse?

I posted functions in my latest revision
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: edit a cell of a xbrowse

Postby Silvio.Falconi » Sun Jun 12, 2022 12:06 pm

nageswaragunupudi wrote:
But I can resize the rows and columns...why ?

oBrw:lAllowRowSizing := .f. // prevent row sizing
oCol:lAllowSizing := .f. // prevent col resizing of a particular column
oBrw:lAllowSizings := .f. // prent resizing of all columns.

(2) when I enter a number by moving between the cells with the mouse, the value is not saved if I don't remember to press enter

This is the default behaviour and is safe.
For what you want, set
oCol:lAutoSave := .t.
for all columns, set oBrw:lAutoSaves := .t.

(3) at the beginning the array must be empty and with only one row and three columns

Start with
local aData := {{0,0,0}}

(4) if the end user wants to automatically delete all the values in all the rows what should I do?

(5) if in memory I have saved a text for example
1,2,3,4,5
5,4,6,7,8
5,3,6,2,1
how could I do to automatically insert it in the array and then in the browse?

I posted functions in my latest revision


I saw all and I saw there are commands I not known.thanks
Today I'm studying how save It because I allready a dbf on oldest app with 10fields , now I must decide if use the dbf or save the reduced system on file ascii

A questione how can i print (on report method) the adata without zeros? Or put a "--" instead of zeros?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: edit a cell of a xbrowse

Postby nageswaragunupudi » Sun Jun 12, 2022 3:31 pm

oBrw:cEditPictures := "@Z 999"
Regards

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

Re: edit a cell of a xbrowse

Postby Silvio.Falconi » Thu Oct 20, 2022 9:48 am

nageswaragunupudi wrote:oBrw:cEditPictures := "@Z 999"



Nages,
How can I do to insert a line between two lines and recalculate the line number (RecSelShowKeyNo)?
How can I delete a line, I have tried with aDel but then it is not good

when I import a new schema cData does not refresh the get columns / rows
sample on New data function I load a file txt the procedure insert tha data into oBrw but then not refresh the number of row and cols on the get



Code: Select all  Expand view

#include "fivewin.ch"
#include "constant.ch"

function Matrix()
local oDlg, oBrw, oFont, oBold, oFontGet
local nBottom   := 33
local nRight    := 80
local nWidth    := Max( nRight * DLG_CHARPIX_W, 180 )
local nHeight   := nBottom * DLG_CHARPIX_H
local oPanelTitle
local oGrp:=array(3)

local aGet:=array(10)

local oBtnClose,oBtnSave,oBtnPrint
local oBtnReset,oBtnInsert

   local aData     :=  {{ 0,0,0}} //{{ 1,2,3 } }   //, { 4,5,6 }       {}
   local nRows     := Len( aData )
   local nCols     := Len( aData[ 1 ] )
   local nNumbers  :=10
   local nGuarantee:= 1
   local nPoints   := 1

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-10
   DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12  BOLD
   DEFINE FONT oFontGet NAME "TAHOMA" SIZE 0,-14


   DEFINE DIALOG oDlg SIZE  nWidth, nHeight  ;
      PIXEL TRUEPIXEL  FONT oFont  RESIZABLE ;  //RESIZABLE
      TiTle "Manage Matrix"



   @ 70, 180 XBROWSE oBrw SIZE 395,300 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS CELL LINES NOBORDER FASTEDIT

      SetupBrowseMatrix(oBrw)
      oBrw:RecSelShowKeyNo()
      oBrw:CreateFromCode()


    @ 70,10 SAY "Total quantity of numbers" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 160,10 SAY "Development (nr. for  column)" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 230,10 SAY "Combinations" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 340,7 SAY  "Guarantee" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 340,130 SAY "points" SIZE 30,24 PIXEL OF oDlg FONT oFont
    @ 375,7 SAY "width" SIZE 150,24 PIXEL OF oDlg FONT oFont
    @ 375,130 SAY "numbers" SIZE 35,24 PIXEL OF oDlg FONT oFont


   @ 90,10 GET aget[1] VAR nNumbers SIZE 100,24 PIXEL;
             SPINNER MIN 5 MAX 90  OF oDlg  ;
             PICTURE "99"   FONT oFontGet

   @ 250 ,10 GET aget[2] VAR nRows SIZE 100,24 PIXEL OF oDlg SPINNER MIN 1 MAX 100 ;
     PICTURE "99" ON CHANGE ResizeArray( oBrw, nRows, nCols, aGet )  FONT oFontGet UPDATE

   @ 180,10 GET aget[3] VAR nCols SIZE 100,24 PIXEL OF oDlg SPINNER MIN  3 MAX 10 ;
     PICTURE "99" ON CHANGE ResizeArray( oBrw, nRows, nCols, aGet ) FONT oFontGet UPDATE

    @ 335 ,55 GET nGuarantee SIZE 50,24 PIXEL;
             SPINNER MIN 1  MAX 10  OF oDlg  ;
             PICTURE "99"  FONT oFontGet

     @ 370 ,55 GET nPoints  SIZE 50,24 PIXEL;
             SPINNER MIN 1  MAX 10  OF oDlg  ;
             PICTURE "99"  FONT oFontGet



    @ 50,175 GROUP oGrp[1] To 410,oDlg:nWidth-20 Label "Matrix" TRANSPARENT PIXEL  OF oDlg
    @ 50,2   GROUP oGrp[2] To 300,170 Label "Reduced System" TRANSPARENT PIXEL  OF oDlg
    @ 310,2 GROUP oGrp[3] To 410,170 Label "Guarantee" TRANSPARENT PIXEL  OF oDlg




     @ 100,10 BUTTON oBtnReset PROMPT "Reset" of oDlg    SIZE 80,22 ACTION SetZeros( oBrw )
     @ 100,10 BUTTON oBtnInsert PROMPT "Insert" of oDlg  SIZE 80,22 ACTION NewData( oBrw, nil , aGet)
     @ 100,10 BUTTON oBtnPrint PROMPT "Print" of oDlg  SIZE 80,22 ACTION oBrw:Report()
     @ 100,10 BUTTON oBtnClose PROMPT "Close" of oDlg  SIZE 80,22 ACTION oDlg:End()
     @ 100,10 BUTTON oBtnSave  PROMPT "Save"  of oDlg  SIZE 80,22 ACTION NIL


  oDlg:bResized := <||
                local oRect := oDlg:GetCliRect()
                oBtnPrint:nLeft    := oRect:nRight - 200
                oBtnPrint:nTop     := oRect:nBottom - 45
                oBtnClose:nLeft    := oRect:nRight - 100
                oBtnClose:nTop     := oRect:nBottom - 45
                oBtnSave:nLeft     := oRect:nRight - 300
                oBtnSave:nTop      := oRect:nBottom - 45
                oBtnReset:nLeft    := oRect:nLeft+10
                oBtnReset:nTop     := oRect:nBottom - 45
                oBtnInsert:nLeft   := oRect:nLeft+100
                oBtnInsert:nTop    := oRect:nBottom - 45

                oBrw:nWidth        := oRect:nWidth - 210
                oPanelTitle:nTop   := oRect:ntop
                oPanelTitle:nLeft  := oRect:nleft+2
                oPanelTitle:nwidth := oRect:nRight

                           RETURN NIL
                       >

   ACTIVATE DIALOG oDlg CENTERED;
               ON INIT (oPanelTitle:=Paneltitle(oDlg),;
                        SayTexttitle(oPanelTitle,oFont) ,;
                        Eval(oDlg:bResized))

   RELEASE FONT oFont, oBold, oFontGet

   XBROWSER aData

return nil

static function ResizeArray( oBrw, nRows, nCols, oControls )

   local aData    := oBrw:aArrayData
   local iRows, iCols, n

   iCols := Len( oBrw:aCols )
   if ( iRows := oBrw:nLen ) != nRows .or. iCols != nCols

      ASize( aData, nRows )
      if nCols != iCols
         AEval( aData, { |a| ASize( a, nCols ), ;
          If( nCols > iCols, AFill( a, 0, iCols + 1 ), nil ) }, 1, Min( iRows, nRows ) )
      endif
      for n := iRows + 1 to nRows
         aData[ n ]  := Array( nCols )
         AFill( aData[ n ], 0 )
      next
      //
      oBrw:SetArray( aData, .f., 0, .t. )
      SetupBrowseMatrix( oBrw )

   endif

   oControls[2]:SetText( Len( aData )      )
   oControls[3]:SetText(Len( aData[ 1 ] ) )
   oControls[2]:refresh()
   oControls[3]:refresh()

return nil

//----------------------------------------------------------------------------//

static function SetupBrowseMatrix( oBrw )

 WITH OBJECT oBrw
//      :RecSelShowKeyNo()

      AEval( :aCols, { |o,i| o:cHeader := LTrim( Str( i, 2 ) ) } )

         :nEditTypes    := EDIT_GET
         :nWidths       := 30

         :lHscroll            := .f.
         :lVscroll            := .t.
         :l2007               := .f.
         :l2015               := .f.

         :lAllowRowSizing     := .f.
         :lAllowColSwapping   := .f.
         :lAllowColHiding     := .f.
         // NEW
         :lAllowSizings       := .f.
         :lAutoSaves          := .t.


         :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
         :nColDividerStyle    := LINESTYLE_LIGHTGRAY
         :bRecSelHeader    := { || " " }
         :SetStyle( 2018 )

//         :CreateFromCode()
   END
   return nil


//---------------------------------------------------------------------------------------------------------//

 static function Paneltitle(oDlg)
  local oPanel,oBrush
  Local aGrad:= { RGB(173,216,230),RGB(255,255,255)}
  DEFINE BRUSH oBrush GRADIENT aGrad
     oPanel:=Tpanel():New( 45, 2, 88, oDlg:nWidth-20, oDlg)
     oPanel:SetBrush( oBrush )
    // oPanel:bPainted := { || oPanel:Box( 1,1,oPanel:nHeight-1,oPanel:nWidth-1 ) }
     return oPanel
//---------------------------------------------------------------------------------------------------------//

static function  SayTexttitle(oPanelTitle,oFont)

   @ 10,10 SAY "Creation Reduced Matrix" SIZE 150,24 PIXEL OF oPanelTitle FONT oFont  TRANSPARENT

RETURN NIL

//----------------------------------------------------------------------------//

static function SetZeros( oBrw )

   AEval( oBrw:aArrayData, { |aRow| AFill( aRow, 0 ) } )
   oBrw:Refresh()

return nil

//----------------------------------------------------------------------------//

static function NewData( oBrw, cData, oControls )

   local aNewData,cFile
   local n

   DEFAULT  cData := ;
   "1,2,3,4,5" + CRLF + ;
   "5,4,6,7,8" + CRLF + ;
   "5,3,6,2,1"

    cFile  :=  cGetFile( "TEXT (*.txt)| *.Txt|" +         ;
                             "All Files (*.*)| *.*"             ;
                            ,"Please select a text file", 4 )

    cData  := HB_MEMOREAD( cFile )

   cData := StrTran( cData, CRLF, CHR(10) )
   aNewData := HB_ATokens( cData, CHR(10) )
   AEval( aNewData, { |c,i| aNewData[ i ] := HB_ATokens( c, "," ) } )
   for n := 1 to Len( aNewData )
      AEval( aNewData[ n ], { |c,i| aNewData[ n, i ] := Val( c ) } )
   next

   ResizeArray( oBrw, Len( aNewData ), Len( aNewData[ 1 ] ),oControls )

   for n := 1 to Len( aNewData )
      oBrw:aArrayData[ n ] := aNewData[ n ]
   next

   SetupBrowseMatrix( oBrw )

return nil

----------------------------------------------------------------------------/
 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 109 guests

cron