DCBROWSE with custom row editor

This forum is for eXpress++ general support.
Post Reply
Message
Author
Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

DCBROWSE with custom row editor

#1 Post 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 1225 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

User avatar
rdonnay
Site Admin
Posts: 4529
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSE with custom row editor

#2 Post 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.
The eXpress train is coming - and it has more cars.

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: DCBROWSE with custom row editor

#3 Post by Maxz »

img2.jpg
img2.jpg (43.83 KiB) Viewed 1197 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

User avatar
rdonnay
Site Admin
Posts: 4529
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSE with custom row editor

#4 Post 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.
The eXpress train is coming - and it has more cars.

Wolfgang Ciriack
Posts: 454
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: DCBROWSE with custom row editor

#5 Post 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.
_______________________
Best Regards
Wolfgang

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: DCBROWSE with custom row editor

#6 Post 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 ?

User avatar
rdonnay
Site Admin
Posts: 4529
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCBROWSE with custom row editor

#7 Post by rdonnay »

oColumn:heading:currentSize()[2]
The eXpress train is coming - and it has more cars.

Post Reply