EDITOR: Number of lines

Login to reply to this topic.
Thu, 2005-11-24 10:21
Joined: 2005-11-16
Forum posts: 34
I am trying to find a way to know how many lines are being displayed in a richtextbox but no luck at all. Yeah, I know it's simple but I can't find any article about it.

Here is my code that will use it:
Code:
TKeyResponse CRTF_XMLContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
switch(aKeyEvent.iCode) {
case EKeyUpArrow:{
if (intLineCounter > 0) {
intLineCounter--;
iRtEd->MoveDisplayL(TCursorPosition::EFLineUp);
}
break;
}

case EKeyDownArrow:{
//if (intLineCounter <= ???????  ) { // <-------- I will have to put it here
intLineCounter++;
iRtEd->MoveDisplayL(TCursorPosition::EFLineDown);
//}
break;
}

default: { // trip lang
return iRtEd->OfferKeyEventL(aKeyEvent, aType);
break;
}
}

TBuf<255> msg;
msg.AppendNum(intLineCounter);

iEikonEnv->InfoMsg(msg);
return EKeyWasNotConsumed;
}    

It will be useful in validating if I should continue scrolling down the editor or just ignore any down key after the end of the lines.

I hope somebody can help me this time.

Thu, 2005-11-24 10:46
Joined: 2005-11-16
Forum posts: 34
Re: EDITOR: Number of lines
Here is a neat trick you can use in finding out how many lines of texts there are in your editor window:

Code:
while (iRtEd->CursorPos()!=iRtEd->TextLength()) {
iRtEd->MoveCursorL(TCursorPosition::EFLineDown, EFalse);
intMaxLines++;
}

This is perfectly handy when using a read only/display only rich text box and still want to have the usual functionality of your UP/DOWN arrows (similar to a browser app):

Code:
TKeyResponse CRTF_XMLContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
switch(aKeyEvent.iCode) {
case EKeyUpArrow:{
if (intLineCounter > 0) {
intLineCounter--;
iRtEd->MoveDisplayL(TCursorPosition::EFLineUp);
}
break;
}

case EKeyDownArrow:{
if (intLineCounter < intMaxLines ) {
intLineCounter++;
iRtEd->MoveDisplayL(TCursorPosition::EFLineDown);
} else {
iEikonEnv->InfoMsg(_L("Past end of line."));
}
break;
}

default: { // trip lang
return iRtEd->OfferKeyEventL(aKeyEvent, aType);
break;
}
}

TBuf<255> msg;
msg.AppendNum(intLineCounter);
msg.Append(_L("/"));
msg.AppendNum(intMaxLines);

iEikonEnv->InfoMsg(msg);
return EKeyWasNotConsumed;
}   
Fri, 2005-11-25 11:02
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2006
Re: EDITOR: Number of lines
You can get this information directly from the Edwin. "Simply" use

Code:
TextLayout()->GetLineNumber(TextLength())


 Check our Playing with Edwin page for more.

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Sun, 2006-06-11 01:57
Joined: 2005-08-09
Forum posts: 29
Re: EDITOR: Number of lines
Quote
You can get this information directly from the Edwin. "Simply" use


Code:
TextLayout()->GetLineNumber(TextLength())


 Check our Playing with Edwin page for more.

There is no such function in s60 or UIQ 2.x , i think it is only in Symbian os 9.1 SDK.
Sun, 2006-06-11 09:41
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2006
Re: EDITOR: Number of lines
Quote from: rapidlord
Quote
You can get this information directly from the Edwin. "Simply" use


Code:
TextLayout()->GetLineNumber(TextLength())


 Check our Playing with Edwin page for more.

There is no such function in s60 or UIQ 2.x , i think it is only in Symbian os 9.1 SDK.
Believe me it's there.... I already used these succesfully on a S80 v2 and S60 v2 application. It's just not documented so you have to go through the headers to find out those methods.

Btw it'is in frmtlay.h...

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Sun, 2006-06-11 10:30
Joined: 2005-11-20
Forum posts: 1242
Re: EDITOR: Number of lines
Fun with undocumented functions for otherwise boring Sunday mornings Smiley

I did find it in S60, but not in UIQ 2.1, not in frmtlay.h nor in any other header file. The UIQ and the S60 versions of the header file frmtlay.h are identical over large parts, but just where the S60 header file shows GetLineNumber (just below ExtendFormattingToCoverPosL) there is nothing corresponding in the UIQ header file...

René Brunner

Thu, 2006-06-15 09:47
Joined: 2003-12-05
Forum posts: 672
Re: EDITOR: Number of lines
Quote from: rbrunner
Fun with undocumented functions for otherwise boring Sunday mornings Smiley

I did find it in S60, but not in UIQ 2.1, not in frmtlay.h nor in any other header file. The UIQ and the S60 versions of the header file frmtlay.h are identical over large parts, but just where the S60 header file shows GetLineNumber (just below ExtendFormattingToCoverPosL) there is nothing corresponding in the UIQ header file...


I also thought a long time ago, that the generic UI components and classes (CEikXxx) are identical in UIQ and Series 60 (nowadays S60). But then I took a look at the S60 header files....
  • Login to reply to this topic.