Page 1 of 1

DCBROWSE with custom row editor

Posted: Sun Jan 16, 2022 9:52 am
by Maxz
Hi Roger,
I need to create a function that opens a rectangle overwriting the row of a selected browse, when i press ENTER o double click, like that:
img1.jpg
img1.jpg (182.58 KiB) Viewed 3690 times
in this way I can manage the record information well without having to use the standard cell editor that you have provided in the dcbrowse

for example:
@ x,y DCBROWSE oBrowse SIZE 100,25 ID "BROWSE" ;
CURSORMODE XBPBRW_CURSOR_ROW ALIAS cAlias ;
DATALINK {|a,oGet|MY_FUNCTION(oGet)}


static function MY_FUNCTION (oGet)
LOCAL GetOptions,GetList:={}
LOCAL nRow,nCol

nRow := * how i can retreive the row position of the browse ?

// field#1
field_1:=cAlias->FIELD1
nCol:= * how i can retreive the #1 column position of the browse ?
@ nRow,nCol DCGET field_1

// field#2
field_2:=cAlias->FIELD2
nCol:= * how i can retreive the #2 column position of the browse ?
@ nRow,nCol DCGET field_2

..
..
DCGETOPTIONS CONFIRM NOTITLE NORESIZE NOTASKLIST HIDE
DCREAD GUI OPTIONS GetOptions FIT MODAL ..... EVAL {|o| <positioning_at_browse_row_and_column> }

REPLACE ....

return nil

Re: DCBROWSE with custom row editor

Posted: Sun Jan 16, 2022 10:52 am
by rdonnay
You may want to look at \exp20\samples\celledit\celledit.prg

This will give you a starting point.
It does not use the built-in cell-editing system, but instead gives you the control you would want.

Re: DCBROWSE with custom row editor

Posted: Tue Jan 18, 2022 2:40 pm
by Maxz
img2.jpg
img2.jpg (43.83 KiB) Viewed 3662 times
aSize:=oBrowse:currentSize() // aSize[1] contain the width of browse (vertical scroll bar included, right ?)

nRowPos := oBrowse:rowPos // number of row selected when i double click or press enter in the browse

// coordinates of #1 cell of browse
oColumn := oBrowse:getColumn( 1 )
oCell := oColumn:dataArea
aRect := oCell:CellRect( nRowPos ) // aRect[4]-aRect[2] is the HEIGHT of the row

I don't know how to calculate the x,y coordinates to place my edit area (blue rectangle) upper the selected row of the browse

Re: DCBROWSE with custom row editor

Posted: Wed Jan 19, 2022 7:14 am
by rdonnay
I keep looking at your question and don't know how to answer it, other than writing a bunch of code for you.
I had hoped that you would be able to figure this out from the sample I referred to you.

If I had more time, I would help you, but I am inundated with work at the moment.

Re: DCBROWSE with custom row editor

Posted: Wed Jan 19, 2022 11:57 am
by Wolfgang Ciriack
I do the calculation in my DCBrowse to open the context menu (oPopupMenu) at the Mouse position as follows:

Code: Select all

     DCBROWSE .....
     EVAL {|o| o:ItemRbDown := {|aMPos, aLC, oBr| DC_GetRefresh(oPopupMenu), ActRbMenu(aMPos, aLC, oBr, oPopupMenu)}}
...
Function ActRbMenu(aMPos, aLC, oBr, oRightMenu)
LOCAL nRight := aLC[2] - oBr:ColPos
LOCAL nDown  := aLC[1] - oBr:RowPos
LOCAL nLeft  := 0, nUp := 0, i := 0

   if nRight < 0
      nLeft := nRight * -1
   endif
   if nDown < 0
      nUp := nDown * -1
   endif
   for i := 1 to nUp
      oBr:Up()
   next
   for i := 1 to nDown
      oBr:Down()
   next
   for i := 1 to nRight
      oBr:Right()
   next
   for i := 1 to nLeft
      oBr:Left()
   next
   oBr:RefreshAll()
   oRightMenu:PopUp(oBr, aMPos)
return (NIL)
Perhaps you can adopt that to your needs.

Re: DCBROWSE with custom row editor

Posted: Thu Jan 27, 2022 8:09 am
by Maxz
now I'm using a formula that assumes that the height of the header of the browse is equal to that of the row, eg.:

aSize:=oBrowse:currentSize()
aPos:=oBrowse:currentPos()
nColPos := oBrowse:colPos
nRowPos := oBrowse:rowPos

oFirstColumn := oBrowse:getColumn( 1 ) // #column1
oFirstCell := oFirstColumn:dataArea
aFirstRect := oFirstCell:CellRect( nRowPos )

nRowHeight:=aFirstRect[4]-aFirstRect[2]

ROW_Y_POS := nRowHeight*nRowPos

but, how do you calculate the height of the head of the browse, correctly ?

Re: DCBROWSE with custom row editor

Posted: Thu Jan 27, 2022 11:50 am
by rdonnay
oColumn:heading:currentSize()[2]