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 » Multiline popups in GridCtrl
Multiline popups in GridCtrl [message #23467] Wed, 21 October 2009 11:36 Go to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Hi,

Is it possible to show multi line pop-ups in GridCtrl?
When I insert multi line text (each line ended with '\n') into cell, pop-up shows everything in a single line. That behavior is inconsistent with ArrayCtrl which is able to show it correctly.
Re: Multiline popups in GridCtrl [message #23468 is a reply to message #23467] Wed, 21 October 2009 12:24 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Zbych wrote on Wed, 21 October 2009 05:36

Hi,

Is it possible to show multi line pop-ups in GridCtrl?
When I insert multi line text (each line ended with '\n') into cell, pop-up shows everything in a single line. That behavior is inconsistent with ArrayCtrl which is able to show it correctly.

Not at the moment. I remeber that I wanted popup to use particular display assigned with the cell so it was able to use the same fonts, colors and stuff but I came acrros some complications I gave up. But I'll try once again Smile
Re: Multiline popups in GridCtrl [message #23598 is a reply to message #23468] Tue, 03 November 2009 15:16 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 696
Registered: December 2005
Location: Budapest, Hungary
Contributor
You can do it using your own Display class.
The trick is, that you have to overload GetStdSize and Paint virtual methods in your own Display class.
Re: Multiline popups in GridCtrl [message #23600 is a reply to message #23598] Tue, 03 November 2009 20:45 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

zsolt wrote on Tue, 03 November 2009 09:16

You can do it using your own Display class.
The trick is, that you have to overload GetStdSize and Paint virtual methods in your own Display class.

I haven't announced that, but GridCtrl now automatically wraps the text in popup and make it bigger if necessary.
Re: Multiline popups in GridCtrl [message #23613 is a reply to message #23600] Wed, 04 November 2009 15:55 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
unodgs wrote on Tue, 03 November 2009 20:45

I haven't announced that, but GridCtrl now automatically wraps the text in popup and make it bigger if necessary.


Hi,

I've found a few problems:
1. Text is not displayed correctly if text height is bigger than cell height. You should limit y-coordinate of text to values >= 0.
index.php?t=getfile&id=1976&private=0

2. When column width is lower than text width, text in pop-up is not centered correctly, new line sign is visible.
index.php?t=getfile&id=1977&private=0

3. Pop-up is empty when there is AttrText in cell.

Problem with pop-up is visible if font resolution is 120DPI.
Test code:
struct App : TopWindow
{
	typedef App CLASSNAME;
	GridCtrl grid;
	App(){
		Add(grid.SizePos());
		grid.AddColumn("Name");
		grid.AddColumn("Surname");
    }

};

GUI_APP_MAIN
{
	App a;
	a.grid.Add(AttrText("New name in cell name"));
	a.grid.Add("New name1 in cell surname\nNew name2 in cell surname2\nNew name3 in cell surname3\nNew name4 in cell surname\nNew name5 in cell surname2\nNew name6 in cell surname3\n");
	a.Run();
}





  • Attachment: grid1.PNG
    (Size: 1.91KB, Downloaded 970 times)
  • Attachment: grid2.PNG
    (Size: 4.42KB, Downloaded 1201 times)
Re: Multiline popups in GridCtrl [message #23614 is a reply to message #23613] Thu, 05 November 2009 00:41 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Thanks for reporting this. I think I have finally fixed 2 and 3. But I don't understand what's wrong with point 1. The text is Y-centered - in this case on the middle of the cell there is a middle line from multiline text.
Re: Multiline popups in GridCtrl [message #23615 is a reply to message #23614] Thu, 05 November 2009 08:18 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
unodgs wrote on Thu, 05 November 2009 00:41

But I don't understand what's wrong with point 1. The text is Y-centered - in this case on the middle of the cell there is a middle line from multiline text.


The problem is that text in the cell is hardly readable. As you can see only part of line 3 and 4 is visible. I wouldn't call it correct solution. In my opinion text should be displayed starting from line 1. See how ArrayCtrls displays such things.
Re: Multiline popups in GridCtrl [message #23617 is a reply to message #23615] Thu, 05 November 2009 11:52 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

I came to the conclusion you're right. When there is not enough space to center a text it should be top aligned then. I push this change up to the repository together with other changes.
Re: Multiline popups in GridCtrl [message #23638 is a reply to message #23617] Mon, 09 November 2009 11:56 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
unodgs wrote on Thu, 05 November 2009 11:52

I push this change up to the repository together with other changes.


Hi,
I've found a few other problems:

1. When I move mouse cursor from one cell to another, pop-up shows content of the previous cell:
index.php?t=getfile&id=1981&private=0

2. column sum doesn't add last row:
index.php?t=getfile&id=1980&private=0

3. Pop-up on cell with number (column #1) causes an assertion:
index.php?t=getfile&id=1982&private=0
index.php?t=getfile&id=1983&private=0

Test code:
struct App : public TopWindow
{
	typedef App CLASSNAME;
	Button ok;
	GridCtrl grid;
	void AddToGrid();
	
	App(){
	grid.HSizePosZ(10,10);
	Sizeable();
        Add(grid.SizePos().HSizePos(50,50).VSizePosZ(50,50));
        grid.SummaryRow();
        grid.AddColumn( "Name").DoSum("%d");
        grid.AddColumn( "Surname").DoSum("%d");
	grid.ColorRows(); 
		
	ok.WhenPush = THISBACK(AddToGrid);  
	ok.SetLabel(t_("OK")).HCenterPosZ(76, -84).BottomPosZ(8, 32);
	Add(ok);
	}
};

void App::AddToGrid(){
		grid.Clear();
		for(int l=0; l<3; l++){
			grid.Add(l, 1);	
		}
		Beep(1000,100);
}

GUI_APP_MAIN
{
	App app;
	app.Run();
}
  • Attachment: grid3.PNG
    (Size: 2.23KB, Downloaded 1177 times)
  • Attachment: grid4.PNG
    (Size: 4.59KB, Downloaded 856 times)
  • Attachment: grid5.PNG
    (Size: 3.12KB, Downloaded 1090 times)
  • Attachment: grid6.PNG
    (Size: 2.26KB, Downloaded 1184 times)

[Updated on: Mon, 09 November 2009 13:37]

Report message to a moderator

Re: Multiline popups in GridCtrl [message #23641 is a reply to message #23638] Mon, 09 November 2009 18:09 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Thanks a lot for finding all those bugs and test cases (that really makes bugs fixing much easier)! All fixed now. Please try the latest svn.
Re: Multiline popups in GridCtrl [message #23754 is a reply to message #23641] Thu, 19 November 2009 15:31 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
unodgs wrote on Mon, 09 November 2009 18:09

Please try the latest svn.


Thank you!

Re: Multiline popups in GridCtrl [message #23776 is a reply to message #23754] Fri, 20 November 2009 15:59 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Another problem. In my application I use WhenCursor callback to enable/disable ToolBar. Inside this callback I check if any row is selected by calling IsCursor. The problem is that IsCursor gives incorrect state of cursor at that time (probably WhenCursor callback is executed to early in GridCtrl::SetCursor0).

Steps:
1. click add
2. click on some row - tool bar should be enabled (but it is not)
3. click second time - now tool bar is enabled.
4. click clear - now grid is empty, but callback is not executed (in my opinion should be, because cursor is gone) and tool bar is not deactivated.

Test code:
struct App : public TopWindow
{
	typedef App CLASSNAME;
	Button ok;
	Button clear;
	ToolBar tool;
	GridCtrl grid;
	
	void AddToGrid();
	void ClearGrid();
	void MyToolBar(Bar& bar);

	void ToolBarRefresh();
	App();	
	
};

App::App()
{
		Sizeable();
		grid.HSizePosZ(10,10);
		tool.Set(THISBACK(MyToolBar));
		
		AddFrame(tool);
        Add(grid.SizePos().HSizePos(0,0).VSizePosZ(0,50));
        grid.AddColumn( "Name").DoSum("%d");
        grid.AddColumn( "Surname").DoSum("%d");
		grid.WhenCursor = THISBACK(ToolBarRefresh);
		
		ok.WhenPush = THISBACK(AddToGrid);
		clear.WhenPush = THISBACK(ClearGrid);  
		ok.SetLabel(t_("Add")).HCenterPosZ(76, -84).BottomPosZ(8, 32);
		clear.SetLabel(t_("Clear")).HCenterPosZ(76, 80).BottomPosZ(8, 32);
		Add(ok);
		Add(clear);		
}

void App::AddToGrid(){
	for(int l=0; l<5; l++){
		grid.Add(l, Format("Row %d\nRow %d\nRow %d\n", l,l,l));	
	}
}

void App::ClearGrid()
{
	grid.Clear();
}

void App::MyToolBar(Bar& bar)
{
	bar.Add(grid.IsCursor(), "File", Image::Wait() , THISBACK(ClearGrid));
	bar.Add(grid.IsCursor(), "File", Image::Wait() , THISBACK(ClearGrid));
}

void App::ToolBarRefresh()
{
	tool.Set(THISBACK(MyToolBar));
	Beep(1000,100);
}

GUI_APP_MAIN
{
	App app;
	app.Run();
}
Re: Multiline popups in GridCtrl [message #23816 is a reply to message #23776] Tue, 24 November 2009 13:29 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Yes, you're rigth. WhenCursor is called very early in SetCursor method. It's mainly to have ability in callback to call CancelCursor() that prevents cursor from changing its position. On the other hand I agree that IsCursorValid and others methods should return correct values in the callback. I have fixed all your problems. The only thing that holds me with commiting the code is I found painting algorithm very slow if line ends with \n char.
Re: Multiline popups in GridCtrl [message #23880 is a reply to message #23816] Mon, 30 November 2009 09:34 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
unodgs wrote on Tue, 24 November 2009 13:29

I have fixed all your problems. The only thing that holds me with commiting the code is I found painting algorithm very slow if line ends with \n char.


Any progress in solving painting problem? Since this problem is not associated with callbacks maybe you could break your improvements into two commits.

Re: Multiline popups in GridCtrl [message #23881 is a reply to message #23880] Mon, 30 November 2009 10:11 Go to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Yes, you're right. Sorry for the delay - I've just been busy with other things. I'll commit all changes except this painting today.
Previous Topic: IsMultiSelect() bugfix in ArrayCtrl
Next Topic: Paste column in GridCtrl
Goto Forum:
  


Current Time: Sat Apr 20 02:10:23 CEST 2024

Total time taken to generate the page: 0.06732 seconds