[Gambas-user] Request: TableView cell offset

Rob sourceforge-raindog2 at ...94...
Tue Feb 10 20:50:56 CET 2004


On Tuesday 10 February 2004 05:24, ron wrote:
> What I need is a posibility to get the actual column and row
> number on the MouseDown and MouseMove events.
> Using the mouse.x and .y works but the first row/column must
> be top/left If I can get the scroll offsets I think it is
> perfect.

I had to come up with a way to do this in a CD ripping program 
I've been working on (so I could pop a textbox up over an entry 
in a Columnview.)  Here's my code, though it will need a lot of 
work to be useful to anyone else:

PUBLIC SUB Tracklist_Edit(tk AS ColumnView)
  
  DIM i AS Integer
  DIM o AS Integer
  DIM iHeight AS Integer
    
  o = tk.item.key
  
  FOR i = 0 TO tk.clientheight
    tk.find(4, i)
    IF o = tk.item.key THEN BREAK
  NEXT
  
  iheight = getItemHeight(tk)
  
  entry = NEW textbox(devicetabs) AS "Entry"
  entry.y = i + tk.y + iheight + 4
  entry.x = tk.columns[0].width 
  entry.w = tk.columns[1].width
  entry.h = iheight
  entry.text = tk.item[1]
  entry.setfocus()
  
  
END


PUBLIC FUNCTION getItemHeight(mycv AS ColumnView) AS Integer
  
  DIM o AS String
  DIM p AS String
  DIM fst AS String
  DIM scd AS String
  DIM i AS Integer
  DIM i1 AS Integer
  DIM i2 AS Integer
  
  IF NOT mycv.available THEN mycv.moveto(1)
  o = mycv.item.key
  mycv.find(4,0)
  fst = mycv.item.key
  scd = fst
  i = 0
  DO WHILE mycv.find(4,i)
    i = i + 1
  LOOP
  
  DO WHILE scd = fst
    i = i + 1
    mycv.find(4,i)
    scd = mycv.item.key
  LOOP
  i1 = i
  
  fst = scd
  DO WHILE fst = scd
    i = i + 1
    mycv.find(4,i)
    fst = mycv.item.key
  LOOP
  'Message.info(i - i1)
  mycv.moveto(o)
  RETURN i - i1
  
END


It works beautifully, though I haven't tried it with a font size 
other than my own ;)

Rob





More information about the User mailing list