|
|
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Ctrls<>() Callback / Disable some rows
Ctrls<>() Callback / Disable some rows [message #9991] |
Tue, 12 June 2007 22:31 |
kcabobert
Messages: 51 Registered: January 2007 Location: USA
|
Member |
|
|
I have two issues... but don't want two threads (I'm lazy...).
First, let me setup the problem:
1) I have an ArrayCtrl which I populate dynamically (I read the values from a database based on search criteria entered elsewhere).
2) My ArrayCtrl has an Index column (via AddIndex("primary_key","id")), a column of options (via AddColumn("use","Use").Ctrls<Option>()), and a name column (via AddColumn("name","Name")).
3.a) I need to SOMETIMES assign a callback to the option column that will uncheck all other options (like a radio ctrl), other times multiple selections are OK. I can do this if I can reliably figure out in which row the option that triggered the callback resides (I need people to be able to select via mouse or keyboard).
3.b) In some cases I may want one option completely disabled (in other words one row disabled). However, I still need the row to list. In these cases removing the option ctrl is acceptable.
I have found two threads which appear to have similar needs / problems:
http://www.ultimatepp.org/forum/index.php?t=msg&th=602
http://www.ultimatepp.org/forum/index.php?t=msg&th=605
I am not so clear on what exactly the GridCtrl does... but I gather that it may allow me to accomplish this? As a note, I think I would prefer to leave this as an ArrayCtrl.
I have used the WhenCtrlsAction callback on the ArrayCtrl, but can not reliably decided which row tripped the callback.
Thanks for your help / thoughts,
Robert
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #9992 is a reply to message #9991] |
Tue, 12 June 2007 23:02 |
|
In GridCtrl when control does its action the cursor is always moved to the cell that owns it (this is one of the main difference to the ArrayCtrl). Knowing that you can easily determine control (cell) position in WhenUpdateCell using GetCursorPos() or GetCursor() if you're intrested only in row position.
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #9993 is a reply to message #9992] |
Tue, 12 June 2007 23:04 |
kcabobert
Messages: 51 Registered: January 2007 Location: USA
|
Member |
|
|
Here is a general question: why ArrayCtrl and GridCtrl? Why not merge the two to simplify the library?
-- Added --
And here is my favorite part: where is the documentation on GridCtrl, and is it actually maintained? I see that it is segregated from the other controls... so I assume it is not maintained with the rest of the UPP code?
Is it possible to accomplish my needs using ArrayCtrl? I previously had the functioning by creating the Options using SetCtrl(..., new Option) then setting the details.
When I upgraded to the new upp version the Ctrls appears as gray boxes (in Windows, Linux, and Mac). My beta testers were less than pleased with the prospect of having to resize a column to check the box each time. I need to get an updated version of my software rolled out so I need to find a [quick] reliable solution.
Thoughts?
[Updated on: Tue, 12 June 2007 23:10] Report message to a moderator
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #9994 is a reply to message #9993] |
Tue, 12 June 2007 23:36 |
|
kcabobert wrote on Tue, 12 June 2007 17:04 | Here is a general question: why ArrayCtrl and GridCtrl? Why not merge the two to simplify the library?
|
They can't be merged (at least now). ArrayCtrl is the base array contol from the very begining and is used in many applications. I have created GridCtrl just to fit my needs (read about its features at my page).
Quote: |
And here is my favorite part: where is the documentation on GridCtrl, and is it actually maintained? I see that it is segregated from the other controls... so I assume it is not maintained with the rest of the UPP code?
|
Documentation is the weakest point of GridCtrl. There is only unfinished tutorial (in GridCtrl package) and HomeBudget as an example. As for maintaining - you're wrong It's actively developed. My time is very limited right now but I'll try to write better documentation soon.
|
|
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #9998 is a reply to message #9991] |
Wed, 13 June 2007 09:33 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
kcabobert wrote on Tue, 12 June 2007 16:31 |
2) My ArrayCtrl has an Index column (via AddIndex("primary_key","id")), a column of options (via AddColumn("use","Use").Ctrls<Option>()), and a name column (via AddColumn("name","Name")).
|
Just a note: This was supposed to use those Id (or SqlId) things, like:
Id PRIMARY_KEY("PRIMARY_KEY"); // possibly global, "Id constant"
....
AddIndex(PRIMARY_KEY, "id");
Using char * there works as well, but it is a but more error prone (you can mistype the string) and U++ has to perform char * -> Id conversion. That is especially not very helpful if you are looping through the ArrayCtrl values.
3.a) I need to SOMETIMES assign a callback to the option column that will uncheck all other options (like a radio ctrl), other times multiple selections are OK. I can do this if I can reliably figure out in which row the option that triggered the callback resides (I need people to be able to select via mouse or keyboard).
3.b) In some cases I may want one option completely disabled (in other words one row disabled). However, I still need the row to list. In these cases removing the option ctrl is acceptable.
Well, Ctrls part of ArrayCtrl seems to be really deficient.
I was thinking about the issue a lot and really the problem seems to be that we have stepped out of U++ paradigm here, introducing class factory, which is nice to solve simple problems, but fails with more complicated ones.
I plan to add some other interface for embeding widgets into ArrayCtrl that will rather use widgets that belong outside the ArrayCtrl (e.g. in the dialog). Something like:
struct MyDialog {
Array<Option> option;
void OptionColumn(Ptr<Ctrl>& ctrl, int index)
{
ctrl = &option.At(index);
}
MyDialog() {
list.AddColumn("Options").Ctrls(THISBACK(OptionColumn));
}
};
This way, you would have the full access to the list of options.
What do you think?
Mirek
|
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #10000 is a reply to message #9999] |
Wed, 13 June 2007 10:37 |
|
Quote: | I wasn't trying to demean the project...
|
Why did you think I thought so? I did not.
Quote: |
Is this correct? Why not add it to GridCtrl.h?
void Set(int r, Id c, const Value &val)
{
Set(r,aliases.Get(c),val);
}
|
Ok, I will add it. But you can use now:
grid(COLUMN_ID) = val
or
grid.Set(COLUMN_ID, val);
to set value of cell in row pointed internally by rowidx. rowidx changes automaticaly if you add new row or change cursor position.
Quote: |
The asm code doesn't compile right... but I assume that is on my end.
I get an error about line 918 ("inline Item& GetItem(int n, int m);"). It seems the function body is missing....
|
Please use latest dev package. All those problems should be corrected there.
[Updated on: Wed, 13 June 2007 10:38] Report message to a moderator
|
|
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #10021 is a reply to message #10017] |
Thu, 14 June 2007 08:18 |
|
Quote: | Well, that is fine, but it does not address my issue. I need to be able to set a cell's value that is in a different row than the cursor. I do not always know the column position... but I do know the column name. Hence the need for a Set( row, col_id, value ) method.
|
Set(row, Id, value) is already in UVS.
|
|
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #10065 is a reply to message #9991] |
Mon, 18 June 2007 20:27 |
kcabobert
Messages: 51 Registered: January 2007 Location: USA
|
Member |
|
|
I also think you have some inconsistent behavior with Get{...} and Set{...}. Some appear to auto-adjust for the Fixed{Column,Row} count and some do not.
For example, when using a index from 0 to GetCount to check the value of a particular column, and set the cell equal to zero if the cell value is one, I have to specify the FixedCount offset when getting values... but not when setting values.
Consider the below snippet:
const int offset = gridctrl.GetFixedCount(),
pos = gridctrl.GetCursor();
if ( atoi(gridctrl.Get("checked").ToString())==1 )
for ( int t=0; t<gridctrl.GetCount(); t++ )
if ( (t!=pos) && (atoi(gridctrl.Get(t+offset,"checked").ToString())==1)) {
gridctrl.Set(t,"checked",0);
}
[Updated on: Mon, 18 June 2007 20:28] Report message to a moderator
|
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #10069 is a reply to message #10065] |
Mon, 18 June 2007 21:57 |
|
Quote: | I also think you have some inconsistent behavior with Get{...} and Set{...}. Some appear to auto-adjust for the Fixed{Column,Row} count and some do not.
|
You're right. It looks like I missed this one:
Value GridCtrl::Get(int r, const char * alias)
{
return Get0(r, aliases.Get(alias));
}
It's fixed now! Thanks.
|
|
|
|
Re: Ctrls<>() Callback / Disable some rows [message #10074 is a reply to message #10073] |
Mon, 18 June 2007 23:50 |
|
I put here current implementation of GridCtrl::Get(row, Id) to show there is no r + fixed_rows as you suggested, but only r. I modified it and now it's in current uvs (internal versioning system of U++). I will release a new dev release and update SVN as only I get my main computer working. Sorry for shortcuts in my answers
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 02:21:59 CEST 2024
Total time taken to generate the page: 0.03680 seconds
|
|
|