[Gambas-user] Request: TableView cell offset
Benoit Minisini
gambas at ...1...
Wed Feb 11 21:10:36 CET 2004
On Wednesday 11 February 2004 19:16, ron wrote:
> Hallo Benoit,
>
> I was so nice to try it myself.
well done man :-)
>
> 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?
When you recompile a component, you must exec "gbi -a" in a shell to update
the component *.info files. the help browser use these files to fill its
treeview.
> 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!
Thanks.
>
> 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.
This function returns the pos of an item in tableview coordinates.
rowPos() returns the pos in contents coordinates. So I must substract
contentsY() to go viewport coordinates, and then add clipper()->y() to go to
TableView coordinates.
It is hard for me to explain that in english. Read the QScrollView
documentation in the QT doc to get more explanations.
>
> 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
Maybe there is a problem, because I'm not sure that header width() and
height() are valid when the TableView is not yet shown. And so these methods
will return incorrect values in a _new() or Form_Open() method.
This a problem with many QT complex widgets, whose layout is deferred the
later as possible.
This is a reason I didn't used these methods in CTABLEITEM_X/Y
> /* 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"),
>
>
>
I will insert your functions in the next version. But tell me if they work
during a _new() method.
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list