| DeathBaba ( @ 2009-07-04 04:27:00 |
| Entry tags: | c++, ceikedwin, programming, s60, symbian |
Set CEikEdwin layout - retrieve text editor height
Example: you want 1-line text editor, and want to center it inside some parent CCoeControl. To do it, you should know the height of the 1 line of text. Here is the magic:
CParent::ConstructL(TRect const & aRect)
{
InitComponentArrayL();
// create editor
iEditor = new (ELeave) CEikEdwin();
iEditor->SetContainerWindowL(*this);
TInt flags = CEikEdwin::ENoWrap;
iEditor->ConstructL(flags, 0, 256, 1);
Components().AppendLC(iEditor);
CleanupStack::Pop();
iEditor->SetFocus(ETrue);
// set parent control size and position first
SetRect(aRect);
// at this point editor will have correct height set
TInt heightOfTextLine = iEditor->Size().iHeight;
}
Note: Don't forget to use AddToStackL(iParentWindowControl) and forward OfferKeyEventL() directly into the editor, it will work also on the touch devices.