Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » BUG: ArrayCtrl - sorting (Does not sort when content uses Attrtext)
BUG: ArrayCtrl - sorting [message #44241] |
Wed, 11 February 2015 09:02 |
slashupp
Messages: 231 Registered: July 2009
|
Experienced Member |
|
|
(debian, upp v8048)
1. Cannot pass ArrayCtrl by reference (see source below)
2. col2 in ac2 does not sort when using Attrtext on content (see source below)
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct acstest : public TopWindow
{
typedef acstest CLASSNAME;
Label l1,l2;
ArrayCtrl ac1, ac2;
acstest();
//void DoSort(ArrayCtrl &ac, int col) { ac.ToggleSortColumn(col); ac.DoColumnSort(); } <<<--- MANY compile errors - why?
void DoSort(ArrayCtrl *pac, int col) { pac->ToggleSortColumn(col); pac->DoColumnSort(); }
};
acstest::acstest()
{
Title("ArrayCtrl-Sorting-test");
SetRect(50,50,750,750);
Add(l1.SetLabel(t_("no attrtext - sort OK")).LeftPosZ(5, 245).TopPosZ(5, 15));
Add(ac1.LeftPosZ(5, 245).TopPosZ(20, 475));
ac1.AddColumn("col1").HeaderTab().WhenAction=THISBACK2(DoSort, &ac1, 0);
ac1.AddColumn("col2").HeaderTab().WhenAction=THISBACK2(DoSort, &ac1, 1);
ac1.AddColumn("col3").HeaderTab().WhenAction=THISBACK2(DoSort, &ac1, 2);
ac1.Add("bbb","ccc","aaa");
ac1.Add("aaa","bbb","ccc");
ac1.Add("ccc","aaa","bbb");
Add(l2.SetLabel(t_("'col2' with attrtext - sort fails on 'col2'")).LeftPosZ(250, 245).TopPosZ(5, 15));
Add(ac2.LeftPosZ(250, 245).TopPosZ(20, 475));
ac2.AddColumn("col1").HeaderTab().WhenAction=THISBACK2(DoSort, &ac2, 0);
ac2.AddColumn("col2").HeaderTab().WhenAction=THISBACK2(DoSort, &ac2, 1); //does not happen
ac2.AddColumn("col3").HeaderTab().WhenAction=THISBACK2(DoSort, &ac2, 2);
ac2.Add("bbb",AttrText("ccc").Align(ALIGN_CENTER).NormalInk(Red()),"aaa");
ac2.Add("aaa",AttrText("bbb").Align(ALIGN_CENTER).NormalInk(Green()),"ccc");
ac2.Add("ccc",AttrText("aaa").Align(ALIGN_CENTER).NormalInk(Blue()),"bbb");
}
GUI_APP_MAIN
{
acstest().Run();
}
[Updated on: Wed, 11 February 2015 09:03] Report message to a moderator
|
|
|
Re: BUG: ArrayCtrl - sorting [message #44242 is a reply to message #44241] |
Wed, 11 February 2015 09:12 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Hi,
1: you really cannot do that. Callback has to do copy of additional parameters. Using pointer there, as you did, is completely adquate.
2: AttrText, at this time, does not have defined ordering. It was originally meant as simple utility. If you need Sorting, you must use normal text and add its decorations by using Display.
However, that said... I am often running into the same issue with AttrText, and in fact it is technically possible to change it in a way that will make direct using for sorting (and other things...) possible. I am adding this as feature request, so sooner or later it will be possible....
Mirek
|
|
|
|
|
Goto Forum:
Current Time: Thu Apr 25 01:40:45 CEST 2024
Total time taken to generate the page: 2.01009 seconds
|