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  |
 |
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
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Tue May 13 20:09:00 CEST 2025
Total time taken to generate the page: 0.04132 seconds
|