本文整理汇总了C++中cString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ cString::size方法的具体用法?C++ cString::size怎么用?C++ cString::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cString
的用法示例。
在下文中一共展示了cString::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPUTParseCommandLine
// Parse the command line for the parameters
// Only parameters that are specified on the command line are updated, if there
// are no parameters for a value, the previous WindowParams settings passed in
// are preserved
//-----------------------------------------------------------------------------
CPUTResult CPUT_OGL::CPUTParseCommandLine(cString commandLine, CPUTWindowCreationParams *pWindowParams, cString *pFilename)
{
ASSERT( (NULL!=pWindowParams), _L("Required command line parsing parameter is NULL"));
ASSERT( (NULL!=pFilename), _L("Required command line parsing parameter is NULL"));
// there are no command line parameters, just return
if(0==commandLine.size())
{
return CPUT_SUCCESS;
}
return CPUT_SUCCESS;
}
示例2: SetText
void CPUTGUIElement::SetText(cString string)
{
DEBUG_PRINT(_L("GUIElement SetText: %s"), string.c_str());
mText = string;
if(mpFont && mpTextMaterial)
{
DEBUG_PRINT(_L("\t have font and material"));
if(!mpTextMesh)
{
#ifdef CPUT_FOR_DX11
mpTextMesh = new CPUTMeshDX11();
#else
mpTextMesh = new CPUTMeshOGL();
#endif
}
unsigned int numCharacters = (unsigned int) string.size();
unsigned int numVertices = numCharacters * 6;
CPUTGUIVertex* pVB = new CPUTGUIVertex[numVertices];
CPUTBufferElementInfo pGUIVertex[3] = {
{ "POSITION", 0, 0, CPUT_F32, 3, 3*sizeof(float), 0 },
{ "TEXCOORD", 0, 1, CPUT_F32, 2, 2*sizeof(float), 3*sizeof(float)},
{ "COLOR", 0, 2, CPUT_F32, 4, 4*sizeof(float), 5*sizeof(float)},
};
mpFont->LayoutText(NULL, &mTextWidth, &mTextHeight, mText, 0, 0);
mTextX = (mWidth-mTextWidth)/2;
mTextY = (mHeight-mTextHeight)/2;
mpFont->LayoutText(pVB, &mTextWidth, &mTextHeight, mText, 0, 0);
mpTextMesh->CreateNativeResources(NULL, 1, 3, pGUIVertex, numVertices, pVB, NULL, 0, NULL);
#ifdef CPUT_FOR_DX11
mpTextMesh->SetMeshTopology(CPUT_TOPOLOGY_INDEXED_TRIANGLE_LIST);
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
UINT numElements = ARRAYSIZE( layout );
ID3DBlob* pBlob = ((CPUTMaterialEffectDX11*)mpTextMaterial->GetMaterialEffects()[0])->GetVertexShader()->GetBlob();
CPUT_DX11::GetDevice()->CreateInputLayout( layout, numElements, pBlob->GetBufferPointer(), pBlob->GetBufferSize(), &mpVertexLayout );
CPUTSetDebugName( mpVertexLayout, "CPUT GUI InputLayout object");
#else
#endif
SAFE_DELETE_ARRAY(pVB);
}
}
示例3: AddSelectionItem
// Add an item to the selection list
//-----------------------------------------------------------------------------
CPUTResult CPUTDropdown::AddSelectionItem(const cString Item, bool bIsSelected)
{
// Don't allow adding 'empty' elements
// causes a spacing issue
if(0==Item.size())
{
return CPUT_ERROR_INVALID_PARAMETER;
}
// create a static item to hold the text
CPUTText *pNewItem = new CPUTText(mpFont);
pNewItem->SetText(Item, 0.35f); // set the text slightly higher than the 0.5 normal mode
mpListOfSelectableItems.push_back(pNewItem);
// Should this be the currently selected item?
if(bIsSelected)
{
mSelectedItemIndex = (int) mpListOfSelectableItems.size()-1;
}
// was this the first item added to an empty list?
if( 1==mpListOfSelectableItems.size() )
{
mSelectedItemIndex=0;
}
// mark that a resize of dropdown selection box is needed
mbSizeDirty = true;
Recalculate();
// position or size may move - force a recalculation of this control's location
// if it is managed by the auto-arrange function
if(this->IsAutoArranged())
{
CPUTGuiControllerDX11::GetController()->Resize();
}
return CPUT_SUCCESS;
}
示例4: CommandLineParams
// Parse the command line for the parameters
// Only parameters that are specified on the command line are updated, if there
// are no parameters for a value, the previous WindowParams settings passed in
// are preserved
//-----------------------------------------------------------------------------
CPUTResult CPUT_DX11::CPUTParseCommandLine(cString commandLine, CPUTWindowCreationParams *pWindowParams, cString *pFilename)
{
ASSERT( (NULL!=pWindowParams), _L("Required command line parsing parameter is NULL"));
ASSERT( (NULL!=pFilename), _L("Required command line parsing parameter is NULL"));
// there are no command line parameters, just return
if(0==commandLine.size())
{
return CPUT_SUCCESS;
}
// we do have parameters, so parse them.
#if defined (UNICODE) || defined(_UNICODE)
// convert command line to lowercase version
cString CommandLineParams(commandLine);
std::transform(CommandLineParams.begin(), CommandLineParams.end(), CommandLineParams.begin(), ::tolower);
// special case - double-clicked on a file
// In the case someone has associated .set files with CPUT, then the target set file comes in surrounded
// by quote marks (i.e. "c:\SoftwareOcclusionCulling\Asset\City.set"). If the first char is a quote mark, we're in this
// special case
if('"' == CommandLineParams[0])
{
pFilename->assign(&CommandLineParams[1]); // remove the leading " char
(*pFilename)[pFilename->size()-1] = '\0'; // remove the trailing " char
return CPUT_SUCCESS;
}
wchar_t separators[] = L" \t\n";
wchar_t* nextToken = NULL;
wchar_t* token = wcstok_s((wchar_t*)CommandLineParams.c_str(), separators, &nextToken);
while(token)
{
if('-' == token[0])
{
// parameter - get next token for which one
cString ParameterName(&token[1]);
if(0!=ParameterName.size())
{
if(0==ParameterName.compare(_L("width")))
{
// get the next value
token = wcstok_s(NULL, separators, &nextToken);
ASSERT(token, _L("-width command line parameter missing required numerical value"));
pWindowParams->windowWidth = _wtoi(token);
}
else if(0==ParameterName.compare(_L("height")))
{
// get the next value
token = wcstok_s(NULL, separators, &nextToken);
ASSERT(token, _L("-height command line parameter missing required numerical value"));
pWindowParams->windowHeight = _wtoi(token);
}
else if(0==ParameterName.compare(_L("fullscreen")))
{
// get the bool
token = wcstok_s(NULL, separators, &nextToken);
cString boolString(token);
if(0==boolString.compare(_L("true")))
{
pWindowParams->startFullscreen = true;
}
}
else if(0==ParameterName.compare(_L("vsync")))
{
// get the bool
token = wcstok_s(NULL, separators, &nextToken);
cString boolString(token);
if( (0==boolString.compare(_L("on"))) || (0==boolString.compare(_L("true"))) )
{
// vsync set to 30 FPS
pWindowParams->deviceParams.refreshRate = 30;
}
if( (0==boolString.compare(_L("off"))) || (0==boolString.compare(_L("false"))) )
{
pWindowParams->deviceParams.refreshRate = 0;
}
}
else if(0==ParameterName.compare(_L("xpos")))
{
// get the next value
token = wcstok_s(NULL, separators, &nextToken);
ASSERT(token, _L("-xpos command line parameter missing required numerical value"));
pWindowParams->windowPositionX = _wtoi(token);
}
else if(0==ParameterName.compare(_L("ypos")))
{
// get the next value
token = wcstok_s(NULL, separators, &nextToken);
ASSERT(token, _L("-ypos command line parameter missing required numerical value"));
pWindowParams->windowPositionY = _wtoi(token);
}
else if(0==ParameterName.compare(_L("file")))
{
// get the filename
//.........这里部分代码省略.........