本文整理汇总了C++中TBuf16::MaxLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TBuf16::MaxLength方法的具体用法?C++ TBuf16::MaxLength怎么用?C++ TBuf16::MaxLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBuf16
的用法示例。
在下文中一共展示了TBuf16::MaxLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetEmergencyNumber
void CAknEcsNote::SetEmergencyNumber( const TDesC& aMatchedNumber )
{
TRect screen(iAvkonAppUi->ApplicationRect());
TAknLayoutRect mainPane;
mainPane.LayoutRect(screen, AKN_LAYOUT_WINDOW_main_pane(screen, 0, 1, 1));
TAknLayoutRect popupNoteWindow;
AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() );
TInt variety( 0 );
if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight )
{
variety = 5;
}
else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft )
{
variety = 8;
}
else
{
variety = 2;
}
popupNoteWindow.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::popup_note_window( variety ));
TAknLayoutText textRect;
textRect.LayoutText(popupNoteWindow.Rect(), AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(4));
// Size of a temporary buffer that contains new lines, spaces and
// emergency number for a note.
TBuf16<KAknEcsMaxMatchingLength+80> number;
number.Append('\n');
number.Append('\n');
TInt spaceCharWidthInPixels = textRect.Font()->CharWidthInPixels(' ');
if (spaceCharWidthInPixels < 1)
{
// Avoid divide by zero situation even the space char would have zero length.
spaceCharWidthInPixels = 1;
}
TInt length = (textRect.TextRect().Width() - textRect.Font()->TextWidthInPixels(aMatchedNumber))
/ spaceCharWidthInPixels;
const TInt matchedNumberLength = aMatchedNumber.Length();
const TInt numberLength = number.Length();
const TInt numberMaxLength = number.MaxLength();
if ( numberLength + length + matchedNumberLength > numberMaxLength)
{
// To make sure that buffer overflow does not happen.
length = numberMaxLength - numberLength - matchedNumberLength;
}
for (int i = 0; i < length ; i++)
{
number.Append(' ');
}
number.Append(aMatchedNumber);
TRAP_IGNORE(SetTextL(number));
}
示例2: ptr
void CDebugLogPrint::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
{
TBuf16<256> buf;
TInt pos=aDes.LocateReverse(' ');
if (pos<0)
pos=0;
buf.Copy(aDes.Mid(pos));
buf.Append(' ');
TInt bufLen=buf.Length();
TPtr16 ptr(&buf[bufLen],buf.MaxLength()-bufLen);
ptr.Copy(aDes2);
buf.SetLength(bufLen+aDes2.Length());
_LIT(KDebugFormatString, "%S");
RDebug::Print(KDebugFormatString, &buf);
}
示例3: GetAnEntry
EXPORT_C void CIpuTestHarness::GetAnEntry(const TDesC& ourPrompt, TDes& currentstring)
//
// Get an input string from the user, displaying a supplied prompt and default string value
{
// If we're scripting, try reading from script first
TInt readScriptErr = KErrNotFound;
if (iScriptRunning)
{
readScriptErr = ReadLineFromScript(currentstring);
}
if (!readScriptErr)
return;
// Either not scripting, or hit end of script - continue with user input
TBuf16<KMaxUserEntrySize> ourLine;
TBuf<KMaxUserEntrySize> tempstring; //tempstring is a unicode descriptor
//create a temporary buffer where the
//unicode strings are stored in order to
//be displayed
ourLine.Zero ();
tempstring.Copy(currentstring); //Copy current string to Unicode buffer
TKeyCode key = EKeyNull; //current string buffer is 8 bits wide.
//Unicode string bufffer (tempstring) is 16 bits wide.
for (;;)
{
if (ourLine.Length () == 0)
{
iTest.Console()->SetPos (0, iTest.Console()->WhereY ());
iTest.Console()->Printf (_L ("%S"), &ourPrompt);
if (tempstring.Length () != 0) //get tempstring's number of items
iTest.Console()->Printf (_L (" = %S"), &tempstring); //if not zero print them to iTest.Console()
iTest.Console()->Printf (_L (" : "));
iTest.Console()->ClearToEndOfLine ();
}
key = iTest.Getch();
if (key == EKeyBackspace)
{
if (ourLine.Length() !=0)
{
ourLine.SetLength(ourLine.Length()-1);
iTest.Console()->Printf (_L ("%c"), key);
iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY());
iTest.Console()->ClearToEndOfLine();
} // end if (ourLine.Length() !=0)
} // end if (key == KeyBackSpace)
if (key == EKeyDelete)
{
ourLine.Zero();
iTest.Console()->SetPos (0, iTest.Console()->WhereY ());
iTest.Console()->ClearToEndOfLine ();
tempstring.Copy(ourLine);
break;
}
if (key == EKeyEnter)
break;
if (key < 32)
{
continue;
}
ourLine.Append (key);
iTest.Console()->Printf (_L ("%c"), key);
iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY());
iTest.Console()->ClearToEndOfLine();
if (ourLine.Length () == ourLine.MaxLength ())
break;
} // end of for statement
if ((key == EKeyEnter) && (ourLine.Length () == 0))
tempstring.Copy (currentstring); //copy contents of 8 bit "ourLine" descriptor
iTest.Console()->SetPos (0, iTest.Console()->WhereY ());
iTest.Console()->ClearToEndOfLine ();
iTest.Console()->Printf (_L ("%S"), &ourPrompt);
if ((key == EKeyEnter) && (ourLine.Length() !=0))
tempstring.Copy(ourLine);
if (tempstring.Length () != 0) //if temstring length is not zero
{
iTest.Console()->Printf (_L (" = %S\n"), &tempstring); //print the contents to iTest.Console()
LogIt(_L ("%S = %S\n"), &ourPrompt, &tempstring);
}
else
//iTest.Console()->Printf (_L (" is empty"));
iTest.Console()->Printf (_L ("\n"));
currentstring.Copy(tempstring); //copy 16 bit tempstring descriptor back
}