本文整理汇总了C++中TextBox类的典型用法代码示例。如果您正苦于以下问题:C++ TextBox类的具体用法?C++ TextBox怎么用?C++ TextBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TextBox
TextBox* TextBox::create(Theme::Style* style, Properties* properties)
{
TextBox* textBox = new TextBox();
textBox->initialize(style, properties);
return textBox;
}
示例2: TextBox
void NOC_8_07_TreeStochasticApp::draw()
{
if( newTree ){
// clear out the window with black
gl::clear( Color::white() );
gl::color( Color::black() );
TextBox tbox = TextBox().size( Vec2i( getWindowWidth(), TextBox::GROW ) ).text( "Click mouse to generate a new tree" );
tbox.setBackgroundColor( ColorA( 0, 0, 0, 0 ) );
gl::enableAlphaBlending();
gl::pushMatrices();
gl::translate( Vec2f( 10.0, getWindowHeight() - 20.0 ) );
gl::draw( gl::Texture( tbox.render() ) );
gl::popMatrices();
gl::color( Color::black() );
// Start the tree from the bottom of the screen
gl::pushMatrices();
gl::translate( getWindowWidth() / 2, getWindowHeight() );
// Start the recursive branching!
branch( 60 );
gl::popMatrices();
newTree = false;
}
}
示例3: TextBox
TextBox* TextBox::create(const char* id, Theme::Style* style)
{
TextBox* textBox = new TextBox();
textBox->_id = id ? id : "";
textBox->initialize("TextBox", style, NULL);
return textBox;
}
示例4: pNew
TextBox* GUIEngine::AddTextBox( const rString& name, Rectangle boundingBox, const rString& parent )
{
TextBox* txtBox = pNew( TextBox, name, parent, boundingBox );
txtBox->GetTextDefinitionRef().FontID = m_CurrentFontID;
AddChild( name, txtBox, parent );
return txtBox;
}
示例5: Color
void LineBreakTestApp::draw()
{
// clear out the window with black
gl::enableAlphaBlending();
gl::clear( Color( 0, 0, 0 ) );
gl::color( ColorA::white() );
pos.x = 0;
pos.y = 10;
// const char *s = "a just.";
const char *s = "just some stuff\n\nthat\nis longer than one line. I mean substantially longer...";
// const char *s = "消費増税\n\n法案をめぐる事前事前事前審査を行っていた民主党税調などの合同総会は28日未明、「名目3%程度、実質2%程度」の経済成長率の数値目標を付則に盛り込んだ新たな修正案を了承し、前原誠司政調会長に対応を一任した。野内閣は30日に閣議決定を行う。";
// for( size_t l = 1; l < 30; ++l ) {
// std::cout << l << ":" << std::endl;
lineBreakUtf8( s,std::bind( lineWidth, std::placeholders::_1, std::placeholders::_2, maxWidth ), print );
// }
gl::color( ColorA( 1, 0, 0, 0.5 ) );
TextBox box;
box.setSize( ivec2( maxWidth, TextBox::GROW ) );
box.setFont( font );
box.setText( s );
gl::Texture t = box.render();
gl::draw( t );
gl::color( Color( 0, 1, 0 ) );
gl::drawStrokedRect( Rectf( 0, 10, maxWidth, 800 ) );
}
示例6: TextBox
void NearestStarbucksApp::render(){
string txt = "Starbucks Visualizer\n Green saturation represents population in 2000. \n Red saturation represents population in 2010. \n Intermediate colors represent areas of change.\n Pale areas represent changes in regional person/Starbucks density. \n The redder the region, the more people in 2010. \n Press j to remove the pale spots. \n ? will toggle these instructions.";
TextBox tbox = TextBox().alignment( TextBox::CENTER ).font(master_font_).size( Vec2i( 512, 511) ).text( txt );
tbox.setColor( Color( 1.0f, 0.65f, 0.35f ) );
tbox.setBackgroundColor( ColorA( 0.5, 0, 0, 1 ) );
master_texture_font_ = gl::Texture( tbox.render() );
}
示例7: fonts
void TextRenderingApp::setup()
{
mShowBounds = false;
mShowWireframe= false;
mFrontColor = Color::black();
mBackColor = Color::white();
try {
// load fonts using the FontStore
fonts().loadFont( loadAsset("fonts/BubblegumSans-Regular.sdff") );
// create a text box (rectangular text area)
mTextBox = TextBox( getWindowSize() );
// set font and font size
mTextBox.setFont( fonts().getFont("BubblegumSans-Regular") );
mTextBox.setFontSize( 24.0f );
// break lines between words
mTextBox.setBoundary( Text::WORD );
// adjust space between lines
mTextBox.setLineSpace( 1.0f );
// load a long text and hand it to the text box
mTextBox.setText( loadString( loadAsset("fonts/readme.txt") ) );
// load and compile the Signed Distance Field shader
mSdfShader = gl::GlslProg( loadAsset("shaders/font_sdf_vert.glsl"), loadAsset("shaders/font_sdf_frag.glsl") );
}
catch( const std::exception & e ) {
console() << e.what() << std::endl;
}
updateWindowTitle();
}
示例8: TextBox
TextBox* Objects2dFactory::inputTextField(CCNode* scene, string initialText, float posX, float posY, float fontSize, AlignX alignX, AlignY alignY, float width, float height,
CCTextAlignment textAlignment, int maxNumberOfChars, ccColor3B textColor, ccColor3B placeHolderColor, int zOrder)
{
// Check arguments validity
if(scene == NULL)
return NULL;
// Get text field
TextBox* pTextField = new TextBox(initialText, fontSize, "Arial"/*Constants::getResourcesPath() + "SOResources/Fonts/AlphaFridgeMagnetsAllCap.ttf"*/, width, height, textAlignment, '|', maxNumberOfChars, textColor, placeHolderColor);
if(!pTextField)
return NULL;
// Set position
pTextField->setPosition(ccp(posX,posY));
// Set anchor
pTextField->setAnchorPoint(ccp(Constants::getAnchorValue(alignX), Constants::getAnchorValue(alignY)));
//// Mark to receive keyboard inputs (this is making the keyboard to open immediately)
//pTextField->attachWithIME();
// Add the label to the scene
scene->addChild(pTextField, zOrder);
// Isn't it necessary to save the object, to get the text?
return pTextField;
}
示例9: lineWidth
bool lineWidth( const char *s, size_t len, size_t maxLen )
{
//return len <= 6;
TextBox box;
box.setFont( font );
box.setText( string( s, len ) );
return box.measure().x < maxLen;
}
示例10: Font
void RoyalSocietyApp::helpMenu() {
Font menu_font = Font("Arial",32);
string menu = "Help Menu\n\n Keys: \n";
TextBox tbox = TextBox().alignment( TextBox::CENTER ).font(menu_font).size( Vec2i( 512, 511) ).text( menu );
tbox.setColor( Color( 1.0f, 1.0f, 1.0f ) );
tbox.setBackgroundColor( ColorA( 0.5, 0, 0, 1 ) );
gl::draw(tbox.render());
}
示例11: TextBox
void Lobby::setupWidgets(bool echoChat)
{
TextBox *textInput = new TextBox(7, 730, 600, "");
textInput->setAction(new SendChatTextAction(textInput, echoChat?(&messages):NULL, &username));
rootWidget->addChild(textInput);
TextDisplayWidget *textDisplay = new TextDisplayWidget(7, 0, 0, 715, fontMiddle, true, &messages);
rootWidget->addChild(textDisplay);
}
示例12: main
int main(int argc, char *argv[])
{
// The data for the pie chart
double data[] = {35, 30, 25, 7, 6, 5, 4, 3, 2, 1};
// The labels for the pie chart
const char *labels[] = {"Labor", "Production", "Facilities", "Taxes", "Misc",
"Legal", "Insurance", "Licenses", "Transport", "Interest"};
// Create a PieChart object of size 560 x 270 pixels, with a golden background
// and a 1 pixel 3D border
PieChart *c = new PieChart(560, 270, Chart::goldColor(), -1, 1);
// Add a title box using 15 pts Times Bold Italic font and metallic pink
// background color
c->addTitle("Project Cost Breakdown", "timesbi.ttf", 15)->setBackground(
Chart::metalColor(0xff9999));
// Set the center of the pie at (280, 135) and the radius to 110 pixels
c->setPieSize(280, 135, 110);
// Draw the pie in 3D with 20 pixels 3D depth
c->set3D(20);
// Use the side label layout method
c->setLabelLayout(Chart::SideLayout);
// Set the label box background color the same as the sector color, with glass
// effect, and with 5 pixels rounded corners
TextBox *t = c->setLabelStyle();
t->setBackground(Chart::SameAsMainColor, Chart::Transparent, Chart::glassEffect()
);
t->setRoundedCorners(5);
// Set the border color of the sector the same color as the fill color. Set the
// line color of the join line to black (0x0)
c->setLineColor(Chart::SameAsMainColor, 0x000000);
// Set the start angle to 135 degrees may improve layout when there are many
// small sectors at the end of the data array (that is, data sorted in descending
// order). It is because this makes the small sectors position near the
// horizontal axis, where the text label has the least tendency to overlap. For
// data sorted in ascending order, a start angle of 45 degrees can be used
// instead.
c->setStartAngle(135);
// Set the pie data and the pie labels
c->setData(DoubleArray(data, sizeof(data)/sizeof(data[0])), StringArray(labels,
sizeof(labels)/sizeof(labels[0])));
// Output the chart
c->makeChart("sidelabelpie.png");
//free up resources
delete c;
return 0;
}
示例13: GP_ASSERT
TextBox* TextBox::create(const char* id, Theme::Style* style)
{
GP_ASSERT(style);
TextBox* textBox = new TextBox();
if (id)
textBox->_id = id;
textBox->setStyle(style);
return textBox;
}
示例14: mIndex
Item::Item( int index, vec2 pos, const string &title, const string &desc, Surface palette )
: mIndex(index), mTitle( title ), mDesc( desc ), mPalette(palette)
{
// TODO: can you reuse layouts? If so, how do you clear the text?
// textures
TextLayout layout;
layout.clear( ColorA( 1, 1, 1, 0 ) );
layout.setFont( sSmallFont );
layout.setColor( Color::white() );
layout.addLine( mTitle );
mTitleTex = gl::Texture::create( layout.render( true ) );
TextLayout bigLayout;
bigLayout.clear( ColorA( 1, 1, 1, 0 ) );
bigLayout.setFont( sBigFont );
bigLayout.setColor( Color::white() );
bigLayout.addLine( mTitle );
mTitleBigTex = gl::Texture::create( bigLayout.render( true ) );
// title
mTitleStart = pos;
mTitleDest1 = vec2( pos.x - 25.0f, pos.y );
mTitleFinish = vec2( pos.x - 4.0f, 120.0f );
mTitleDest2 = vec2( mTitleFinish.x - 25.0f, mTitleFinish.y );
mMouseOverDest = mTitleStart + vec2( 7.0f, 0.0f );
mTitlePos = mTitleStart;
mTitleColor = Color( 0.7f, 0.7f, 0.7f );
mTitleAlpha = 1.0f;
mTitleWidth = mTitleTex->getWidth();
mTitleHeight = mTitleTex->getHeight();
// desc
mDescStart = vec2( mTitleStart.x + 25.0f, mTitleFinish.y + mTitleBigTex->getHeight() + 5.0f );
mDescDest = vec2( mTitleStart.x + 35.0f, mDescStart.y );
mDescPos = mDescStart;
mDescAlpha = 0.0f;
TextBox tbox = TextBox().alignment( TextBox::LEFT ).font( sSmallFont ).size( ivec2( 650.0f, TextBox::GROW ) ).text( mDesc );
mDescTex = gl::Texture::create( tbox.render() );
// bar
mBarPos = pos - vec2( 4.0f, 1.0f );
mBarWidth = 0.0f;
mBarHeight = mTitleHeight + 2.0f;
mMaxBarWidth = mTitleWidth + 22.0f;
mBarColor = Color::white();
mBarAlpha = 0.3f;
mFadeFloat = 1.0f;
mIsSelected = false;
mIsBeingSelected = false;
setColors();
}
示例15: toUtf16
void TextRenderingApp::updateWindowTitle()
{
#ifdef WIN32
std::wstringstream str;
str << "TextRenderingApp -";
str << " Font family: " << toUtf16( mTextBox.getFontFamily() );
str << " (" << mTextBox.getFontSize() << ")";
HWND hWnd = getRenderer()->getHwnd();
::SetWindowText( hWnd, str.str().c_str() );
#endif
}