Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
slashupp is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  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
Re: BUG: ArrayCtrl - sorting [message #44245 is a reply to message #44242] Wed, 11 February 2015 09:39 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member

thx mirek - will switch my project's code to using display until then
however Attrtext is much easier to use

just an idle thought that occurred when I looked at the source again:
try to write this example using ANY other gui-developer (Windows, QT,
GTK, wxWidgets, ...) and you end-up with miles of code...
Re: BUG: ArrayCtrl - sorting [message #44249 is a reply to message #44245] Thu, 12 February 2015 20:07 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
AttrText improved so that sorting in your example should work out-of-box now...
Previous Topic: GridCtrl: Add Option inside a column header
Next Topic: GridCtrl: How to display a menu on header right click?
Goto Forum:
  


Current Time: Thu Mar 28 11:10:26 CET 2024

Total time taken to generate the page: 0.00992 seconds