[Gambas-user] Request: TableView cell offset
ron
ronstk at ...239...
Wed Feb 11 19:16:14 CET 2004
Hallo Benoit,
I was so nice to try it myself.
Is is functional but I miss the way how to get the documentation also in the
helpbrowser. Do I have it done the right way for Benoit rulez?
int = TableView.RowAt( ypos as integer)
int = TableView.ColumnAt( xpos as integer)
xpos and ypos are the position from mouse.x and mouse.y at the MouseDown event
and gives me the excact row and column numbers now before the MouseClick
updates to .Row and .Column values.
The returning values are -1 if the MouseDown is outside the cell grid.
Row and Column headers or the blank space.
The GamC instead of GamBas it beautifull to use!
BTW
In the code I found after all this part of code
BEGIN_PROPERTY(CTABLEITEM_y)
GB.ReturnInteger(WIDGET->rowPos(THIS->row) - WIDGET->contentsY() +
WIDGET->clipper()->y());
END_PROPERTY
Here it is just done the oposit way
When this function didn't substract contentsY and add clipper()->y()
it was posible to iterate the way i did in my example.
Greeting from happy,
Ron
--------------------------------------------------------------------------------------
Code I made is as follows, above the
BEGIN_METHOD(CTABLEVIEW_move_to, GB_INTEGER row; GB_INTEGER col)
I add the commented code to show where i find the info.
/* add ron begin */
// ypos is position in whole tableview area
BEGIN_METHOD(CTABLEVIEW_rowat, GB_INTEGER ypos)
int ypos = VARG(ypos);
// add offset frame
// coming from 'Q_EXPORT QScrollview Q_PROPERTY' in qscrollview.h
ypos = ypos + WIDGET->contentsY();
// must sub horizontal header height
if (!WIDGET->horizontalHeader()->isHidden())
ypos = ypos - WIDGET->horizontalHeader()->height();
// comming from 'QM_EXPORT_TABLE QTable public virtual' in qtable.h
int row = WIDGET->rowAt(ypos);
GB.ReturnInteger(row);
END_PROPERTY
// xpos is position in whole tableview area
BEGIN_METHOD(CTABLEVIEW_columnat, GB_INTEGER xpos)
int xpos = VARG(xpos);
// add offset frame
// coming from 'Q_EXPORT QScrollview Q_PROPERTY' in qscrollview.h
xpos = xpos + WIDGET->contentsX();
// must sub vertical header width
if (!WIDGET->verticalHeader()->isHidden())
xpos = xpos - WIDGET->verticalHeader()->width();
// comming from 'QM_EXPORT_TABLE QTable public virtual' in qtable.h
int col = WIDGET->columnAt(xpos);
GB.ReturnInteger(col);
END_PROPERTY
/* add ron end */
in 'GB_DESC CTableViewDesc[] =' i add following
GB_PROPERTY("Column", "i", CTABLEVIEW_column),
/* add ron begin */
GB_METHOD("RowAt","i",CTABLEVIEW_rowat,"(Y)i"),
GB_METHOD("ColumnAt","i",CTABLEVIEW_columnat,"(X)i"),
/* add ron end */
GB_METHOD("MoveTo", NULL, CTABLEVIEW_move_to, "(Row)i(Column)i"),
More information about the User
mailing list