本文整理汇总了C++中LLString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ LLString::size方法的具体用法?C++ LLString::size怎么用?C++ LLString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLString
的用法示例。
在下文中一共展示了LLString::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFile
// Reads a .tga file and creates an LLImageTGA with its data.
bool LLImageTGA::loadFile( const LLString& path )
{
S32 len = path.size();
if( len < 5 )
{
return false;
}
LLString extension = path.substr( len - 4, 4 );
LLString::toLower(extension);
if( ".tga" != extension )
{
return false;
}
FILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */
if( !file )
{
llwarns << "Couldn't open file " << path << llendl;
return false;
}
S32 file_size = 0;
if (!fseek(file, 0, SEEK_END))
{
file_size = ftell(file);
fseek(file, 0, SEEK_SET);
}
U8* buffer = allocateData(file_size);
S32 bytes_read = fread(buffer, 1, file_size, file);
if( bytes_read != file_size )
{
deleteData();
llwarns << "Couldn't read file " << path << llendl;
return false;
}
fclose( file );
if( !updateData() )
{
llwarns << "Couldn't decode file " << path << llendl;
deleteData();
return false;
}
return true;
}
示例2: createDialog
void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 default_option,
const LLString& msg_in, const LLString::format_map_t& args,
const LLString& edit_text)
{
setBackgroundVisible(TRUE);
setBackgroundOpaque(TRUE);
const LLFontGL* font = gResMgr->getRes( font_name );
const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
const S32 EDITOR_HEIGHT = 20;
// Buttons
std::vector<LLString> default_option_list;
mNumOptions = optionsp->size();
if( 0 == mNumOptions )
{
default_option_list.push_back("Close");
optionsp = &default_option_list;
default_option = 0;
mNumOptions = 1;
}
const std::vector<LLString>& options = *optionsp;
mButtonData = new ButtonData[mNumOptions];
// Calc total width of buttons
S32 button_width = 0;
S32 sp = font->getWidth("OO");
for( S32 i = 0; i < mNumOptions; i++ )
{
S32 w = S32(font->getWidth( options[i] ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD;
button_width = llmax( w, button_width );
}
S32 btn_total_width = button_width;
if( mNumOptions > 1 )
{
btn_total_width = (mNumOptions * button_width) + ((mNumOptions - 1) * BTN_HPAD);
}
// Message: create text box using raw string, as text has been structure deliberately
// Use size of created text box to generate dialog box size
LLString msg = msg_in;
format( msg, args );
llwarns << "Alert: " << msg << llendl;
LLTextBox* msg_box = new LLTextBox( "Alert message", msg, (F32)MAX_ALLOWED_MSG_WIDTH, font );
const LLRect& text_rect = msg_box->getRect();
S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
S32 dialog_height = text_rect.getHeight() + 3 * VPAD + BTN_HEIGHT;
if (hasTitleBar())
{
dialog_height += LINE_HEIGHT; // room for title bar
}
if (edit_text.size() > 0)
{
dialog_width = llmax(dialog_width, S32(font->getWidth( edit_text ) + 0.99f));
dialog_height += EDITOR_HEIGHT;
}
if (mCaution)
{
// Make room for the caution icon.
dialog_width += 32 + HPAD;
}
reshape( dialog_width, dialog_height, FALSE );
S32 msg_y = mRect.getHeight() - VPAD;
S32 msg_x = HPAD;
if (hasTitleBar())
{
msg_y -= LINE_HEIGHT; // room for title
}
if (mCaution)
{
LLIconCtrl* icon = new LLIconCtrl("icon", LLRect(msg_x, msg_y, msg_x+32, msg_y-32), "notify_caution_icon.tga");
icon->setMouseOpaque(FALSE);
addChild(icon);
msg_x += 32 + HPAD;
msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertCautionTextColor" ) );
}
else
{
msg_box->setColor( LLUI::sColorsGroup->getColor( "AlertTextColor" ) );
}
LLRect rect;
rect.setLeftTopAndSize( msg_x, msg_y, text_rect.getWidth(), text_rect.getHeight() );
msg_box->setRect( rect );
addChild(msg_box);
// Buttons
S32 button_left = (mRect.getWidth() - btn_total_width) / 2;
for( S32 i = 0; i < mNumOptions; i++ )
{
LLRect button_rect;
button_rect.setOriginAndSize( button_left, VPAD, button_width, BTN_HEIGHT );
LLButton* btn = new LLButton(
//.........这里部分代码省略.........
示例3: DisplayReleaseNotes
OSStatus DisplayReleaseNotes(void)
{
OSStatus err;
IBNibRef nib = NULL;
WindowRef window = NULL;
err = CreateNibReference(CFSTR("SecondLife"), &nib);
if(err == noErr)
{
CreateWindowFromNib(nib, CFSTR("Release Notes"), &window);
}
if(err == noErr)
{
// Get the text view control
HIViewRef textView;
ControlID id;
id.signature = 'text';
id.id = 0;
LLString releaseNotesText;
_read_file_into_string(releaseNotesText, "releasenotes.txt"); // Flawfinder: ignore
err = HIViewFindByID(HIViewGetRoot(window), id, &textView);
if(err == noErr)
{
// Convert from the encoding used in the release notes.
CFStringRef str = CFStringCreateWithBytes(
NULL,
(const UInt8*)releaseNotesText.c_str(),
releaseNotesText.size(),
kCFStringEncodingWindowsLatin1, // This matches the way the Windows version displays the release notes.
FALSE);
if(str != NULL)
{
int size = CFStringGetLength(str);
if(size > 0)
{
UniChar *chars = new UniChar[size + 1];
CFStringGetCharacters(str, CFRangeMake(0, size), chars);
err = TXNSetData(HITextViewGetTXNObject(textView), kTXNUnicodeTextData, chars, size * sizeof(UniChar), kTXNStartOffset, kTXNStartOffset);
delete[] chars;
}
CFRelease(str);
}
else
{
// Creating the string failed. Probably an encoding problem. Display SOMETHING...
err = TXNSetData(HITextViewGetTXNObject(textView), kTXNTextData, releaseNotesText.c_str(), releaseNotesText.size(), kTXNStartOffset, kTXNStartOffset);
}
}
// Set the selection to the beginning of the text and scroll it into view.
if(err == noErr)
{
err = TXNSetSelection(HITextViewGetTXNObject(textView), kTXNStartOffset, kTXNStartOffset);
}
if(err == noErr)
{
// This function returns void.
TXNShowSelection(HITextViewGetTXNObject(textView), false);
}
}
if(err == noErr)
{
ShowWindow(window);
}
if(err == noErr)
{
// Set up an event handler for the window.
EventHandlerRef handler = NULL;
EventTypeSpec handlerEvents[] =
{
{ kEventClassCommand, kEventCommandProcess }
};
InstallWindowEventHandler(
window,
NewEventHandlerUPP(simpleDialogHandler),
GetEventTypeCount (handlerEvents),
handlerEvents,
(void*)window,
&handler);
}
if(err == noErr)
{
RunAppModalLoopForWindow(window);
//.........这里部分代码省略.........