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 » Wrapping text in ArrayCtrl cells
Wrapping text in ArrayCtrl cells [message #31076] Thu, 03 February 2011 23:14 Go to previous message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
How to add text rows to an ArrayCtrl, keeping cell widths constant, and at the same time resizing cell height, so that I visualize entered text in full? I mean, I´d like to be able to wrap text down when it does not fit cell size.

I´ve tried this using DocEdits (which wrap long lines automatically), but it didn´t work:
// in .h file:
ArrayCtrl wraparray;

...

// somewhere in code initialization:
wraparray.AddColumn().Ctrls(THISBACK(CreateDocEdit));

...

// DocEdit factory callback:
MyProg::CreateDocEdit(One<Ctrl>& x)
{
	x.Create<DocEdit>().NoBackground().SetFrame(NullFrame()).Disable();
}

...

// Adding rows: here's where I guess things go wrong!
void MyProg::AddRowsToWrapArray(Vector<Value>& rows) 
{
	int line, cy_height;
	const int FONT_HEIGHT = GetTextSize("text sample", GetStdFont()).cy;

// this is weird, but necessary, or last included row won't show properly:

	if(wraparray.GetCount() > 0)
		wraparray.Remove(wraparray.GetCount() - 1);

	for(int ix = 0; ix < rows.GetCount(); ix ++) {
		wraparray.Add(rows[ix]);
		line = wraparray.GetCount() - 1;
		DocEdit * de = (DocEdit*)wraparray.GetCtrl(line, 0);
		cy_height = (de->GetLineCount() + 1)*FONT_HEIGHT;
		de->SetRectY(0, cy_height);
		wraparray.SetLineCy(line, cy_height);
		de->RefreshLayout();
	}

// this is weird, but necessary, or last included row won't show properly:
	wraparray.Add();
}



the DocEdit's do not seem to resize right, and I really would not like that the DocEdit scrollbars showed up for scrolling down hidden text because of wrong resizing.
What am I doing wrong?
Is there another simpler way of doing it?
Could it be possible to have a method like "void SetWrapLines(bool wrap = true);" for ArrayCtrl?

Thanks!!

[Updated on: Thu, 03 February 2011 23:29]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GridCtrl with Option problem under linux
Next Topic: Newbie question: ArrayCtrl::IsModified(int ii) not work at expected.
Goto Forum:
  


Current Time: Thu Apr 18 02:04:51 CEST 2024

Total time taken to generate the page: 0.02257 seconds