Page 7 of 7

Re: My MyTable/MyGrid

Posted: Sat Jul 03, 2021 12:18 am
by eck49
Hi Cyllceaux
Sorry to keep bothering you...
MyTable version 3228.
How do I extract the contents of a cell which is not selected - and which may not even be visible?

Code: Select all

*table\GetCell(r,c)
which I might expect to return a list element from which I could perhaps \GetText seems just to return 0.

And, incidentally, I find \GetPosition() returns the visible position (row number) not the data position as an earlier post suggests.

Re: My MyTable/MyGrid

Posted: Sat Jul 03, 2021 1:55 pm
by Cyllceaux
Hi eck...

I tested it on table2.

this workes fine. Because this tables has no invisible rows.

Code: Select all

	Define *cell.MyTableCell=*table\GetCell(1,1)
	Debug *cell\GetText() ; Test 2_2
now on tree1.

Code: Select all

	Define *cell.MyTableCell=*tree\GetCell(1,0)
	Define *row.MyTableRow=*cell\GetRow()
	Debug *cell\GetText() ; Stamm 2
	Debug *row\GetPosition() ; 1, because index started at 0
	Debug *row\GetVisiblePosition() ; 1111
Since Version 3623 you can do this:

Code: Select all

	Define *vcell.MyTableCell=*tree\GetVisibleCell(12,0)
	Define *vrow.MyTableRow=*vcell\GetRow()
	Debug *vcell\GetText() ; Blatt 10
	Debug *vrow\GetPosition(); 9, the Position in the sublist of the parent row
	Debug *vrow\GetVisiblePosition() ; 12
I let this code in "test/tree.pb". so you can try it :)

Re: My MyTable/MyGrid

Posted: Sat Jul 03, 2021 6:20 pm
by eck49
@ Cyllceaux

Thanks. First example is fine in the test - there must be something awry in my 'real' code which I need to probe further.

But there is something odd with the middle example. I don't have a tree1 example as downloaded on 25 June, so I put this into tree2 just above the Resize procedure, with the results shown in the comments.

Code: Select all

	;vv 2021-07-03 start
	Define *cell.MyTableCell = *tree\GetCell(5,0)       ;<< 5
	Define *row.MyTableRow   = *cell\GetRow()
	Debug *cell\GetText()                               ;Stamm 6
	Debug *row\GetPosition()                            ;49  'Stamm 6' is the contents of the 50th visible cell in the column
	Debug *row\GetVisiblePosition()                       ;Interface method not found
	;^^ 2021-07-03 end
No GetVisiblePosition method.... and GetPosition is giving what I would expect from GetVisiblePosition.
Still on version 3228.

I'm downloading version 3634 (latest on Github) which may sort this out. But I won't have a chance to try it out for a day or so.

Re: My MyTable/MyGrid

Posted: Sun Jul 04, 2021 10:53 am
by Cyllceaux
Don't forget... it's still in development :)

And GetVisiblePosition is only available after a redraw

Re: My MyTable/MyGrid

Posted: Mon Jul 05, 2021 4:18 pm
by eck49
@ Cyllceaux
Don't forget... it's still in development
Not forgotten, thanks.

Earlier issues now all sorted, thanks.

Can I suggest a simple renaming?

There are three single integer answers to the question 'What row is this?" - perhaps for a selected row, for example.
Take the tree table with Stamm1-3 collapsed, and taking the Stamm4/Ast1/Zweig1/Blatt2 row.

1. It is row 46 (approx, counted by hand!) which is the row if all the Stamm/Ast/Zweig above it were expanded.
As far as I am aware this number is not made public. Debatable whether it is needed, but since it is unique it could be one way of specifying where a new row should be inserted.

2. Row 7, as returned by GetVisiblePosition

3. Row 1, as returned by GetPosition.
As you point out in your comment in the 3rd code snippet of your 3 July post, GetPosition returns the position in the sublist below Stamm4/Ast1/Zweig1
Perhaps it would be helpful to rename GetPosition to GetSubPosition or GetLevelPosition or something similar?

Re: My MyTable/MyGrid

Posted: Tue Jul 06, 2021 9:13 am
by Cyllceaux
hey eck
  1. Adding rows are easy. inserting rows aren't at my focus. I thought about it, but I never used it on TreeGadget or ListIconGadget. But I will add it after my big refactoring.
  2. I'm not sure what you want to say.
  3. You are right. I changed it to GetLevelPosition

Re: My MyTable/MyGrid

Posted: Tue Jul 06, 2021 4:51 pm
by eck49
Hi Cyllceaux

Using the same paragraph numbers...

1. Does the user want to add rows by user code somewhere in the middle of the table after the table has been created? If the table has a sort facility (as yours does), my practice has been to include a hidden column containing a key, add the new row anywhere in the table with an appropriate value in the key and then sort. Whilst the new rows are still in draft form and perhaps not yet conforming to the requirements of the main body of rows it can be convenient to have them all together for checking before sorting them into place. But that's just been my habit in the past.

Therefore I don't need to know the position as counted in paragraph 1.

But others may do things differently and prefer to manage things using a row number like Excel, which is independent of the row contents.

2. It delivers, as they say, what it says on the tin. I'm not making any suggestion, it's fine. :)

3. Thanks for adopting my suggestion

Re: My MyTable/MyGrid

Posted: Tue Jul 06, 2021 7:29 pm
by eck49
Is there a way of setting the background colour of a whole column?

Code: Select all

	*style\SetBackColor(RGBA(240,5,5,255))
after creating a column just affects the header cell.
(likewise foreground colour)
There is a *style\SetFrontColor too, which doesn't do anything as far as I can see - at least in table1.

And any way of setting the colour (Fore or Back) of an individual cell?

Parallel to Set would be Get, too.

Re: My MyTable/MyGrid

Posted: Thu Jul 08, 2021 7:05 pm
by eck49
If the Canvas is resized and the width is reduced because the table does not fill it (perhaps it has been redrawn with fewer columns) the vertical scroll bar is no longer accessible. Is this something MyTable could deal with easily or do you envisage that the user would delete and recreate the canvas & Table?

Re: My MyTable/MyGrid

Posted: Fri Jul 09, 2021 4:54 am
by Cyllceaux
hey eck
eck49 wrote: Is there a way of setting the background colour of a whole column?
you mean, with the cells in it? For Table, Grid or Tree?
eck49 wrote: There is a *style\SetFrontColor too, which doesn't do anything as far as I can see - at least in table1.
At first I had only "Back" and "Front" Color. Cause PB differs between them. Bot Than I had Fonts and normally they have ForeColor. So I added both. But at the moment I only use them for the background of the table.
eck49 wrote: And any way of setting the colour (Fore or Back) of an individual cell?
Sure... any Cell has his own Style object. So you can set colors for every cell. You see this in Test/table13
eck49 wrote: If the Canvas is resized and the width is reduced because the table does not fill it (perhaps it has been redrawn with fewer columns) the vertical scroll bar is no longer accessible. Is this something MyTable could deal with easily or do you envisage that the user would delete and recreate the canvas & Table?
hm... normally the scrollbars only disappear, if there is nothing to scroll. The resize triggers the recalc and redraw. (except you disabled it (setRedraw(#False), than it will not recalc)

Re: My MyTable/MyGrid

Posted: Fri Jul 09, 2021 2:34 pm
by eck49
hi Cyllceaux
eck49 wrote:
Is there a way of setting the background colour of a whole column?
you mean, with the cells in it? For Table, Grid or Tree?
I was thinking of Table.
Sure... any Cell has his own Style object. So you can set colors for every cell. You see this in Test/table13
Thanks. I'll have a look at that. A column could be coloured cell by cell, of course.
eck49 wrote:
If the Canvas is resized and the width is reduced because the table does not fill it (perhaps it has been redrawn with fewer columns) the vertical scroll bar is no longer accessible. Is this something MyTable could deal with easily or do you envisage that the user would delete and recreate the canvas & Table?
hm... normally the scrollbars only disappear, if there is nothing to scroll. The resize triggers the recalc and redraw. (except you disabled it (setRedraw(#False), than it will not recalc)
The only problem here seems to be my muddled thinking. Having painted the Table on a Canvas wider than it needs to be (because the particular incoming data did not need all the columns allowed for) there is grey empty Canvas between the Table and the vertical scrollbar. So resizing the Canvas (not the Table) by making it narrower makes the scrollbar invisible - still there, I guess, just inaccessible. Since the scrollbar is a distinct gadget, I can relocate it myself! My muddled thinking had MyTable totally in charge of the scrollbar when they are not as tightly linked as that. My apologies for being obtuse.

Re: My MyTable/MyGrid

Posted: Thu Feb 17, 2022 9:28 am
by Cyllceaux