TextBox* TextBox::create(Theme::Style* style, Properties* properties) { TextBox* textBox = new TextBox(); textBox->initialize(style, properties); return 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; } }
TextBox* TextBox::create(const char* id, Theme::Style* style) { TextBox* textBox = new TextBox(); textBox->_id = id ? id : ""; textBox->initialize("TextBox", style, NULL); return textBox; }
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; }
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 ) ); }
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() ); }
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(); }
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; }
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; }
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()); }
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); }
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; }
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; }
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(); }
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 }
static int SendText(lua_State *L) { const char* str = lua_tostring(L, 2); std::basic_string<Uint16> text = Helper::GetUTF16(str); lua_rawgeti(L, 1, 0); SceneNode *node = static_cast<SceneNode*>(lua_touserdata(L, 3)); TextBox *pt = dynamic_cast<TextBox*>(node->obj); pt->SetWordsToRender(text); pt->SetPerformState(TextBox::running); return 0; }
//Learned to do from ajduberstien and the cinder samples Textbox and TextTest //satifies requirement void RoyalSocietyRGApp::render(){ Font ft = Font("Times new roman",20); string ms = "Press the up arrow to move Up, down arrow to move down,left to move left, right to move right and T to increase transparency"; TextBox tbox = TextBox().alignment( TextBox::CENTER ).font(ft).size( tSize.x, tSize.y ).text( ms ); tbox.setColor( Color( 0.0f, 0.85f, 1.0f ) ); tbox.setBackgroundColor( ColorA( 0.5, 0, 0, 1 ) ); Vec2i sz = tbox.measure(); console() << "Height: " << sz.y << endl; texture_font_ = gl::Texture( tbox.render() ); }
// Renders the tweet into a gl::Texture, using TextBox for type rendering gl::Texture GoodNightMorningApp::renderTweet( const Tweet &tweet, float width, const Color &textColor, float backgroundAlpha ) { TextBox header = TextBox().font( mHeaderFont ).color( textColor ).text( "@" + tweet.getUser() ); Surface headerSurface = header.render(); TextBox phrase = TextBox().size( Vec2f( width - 48 - 4, TextBox::GROW ) ).font( mFont ).color( textColor ).text( tweet.getPhrase() ); Surface textSurface = phrase.render(); Surface result( textSurface.getWidth() + 56, std::max( headerSurface.getHeight() + textSurface.getHeight() + 10, 56 ), true ); ip::fill( &result, ColorA( 1, 1, 1, backgroundAlpha ) ); if( tweet.getIcon() ) result.copyFrom( tweet.getIcon(), tweet.getIcon().getBounds(), Vec2i( 4, 4 ) ); ip::blend( &result, headerSurface, headerSurface.getBounds(), Vec2i( result.getWidth() - 4 - headerSurface.getWidth(), textSurface.getHeight() + 6 ) ); ip::blend( &result, textSurface, textSurface.getBounds(), Vec2i( 56, 4 ) ); return result; }
void Monitor::draw() { gl::enableAlphaBlending(); gl::color( mColorBack ); gl::drawSolidRect( mArea ); gl::color( mColorFrame ); gl::drawStrokedRect( mArea ); // draw header text TextBox label = TextBox().alignment( TextBox::CENTER ).font( mFont ).size( Vec2i( mArea.getWidth(), TextBox::GROW ) ).text( mName ); label.setColor( mColorTitle ); Surface surfaceLabel = label.render(); gl::draw( surfaceLabel, mArea.getUL()); // draw header line Vec2i posHeader1 = mArea.getUL(); posHeader1.y += surfaceLabel.getHeight(); Vec2i posHeader2 = posHeader1; posHeader1.x += mArea.getWidth(); gl::drawLine( posHeader1, posHeader2 ); int heightAll = posHeader1.y; for( std::vector< shared_ptr< Section > >::iterator p = mSections.begin(); p != mSections.end(); ++p ) { int heightAct = (*p)->getHeight( mArea.getWidth()); int heightMax = mArea.y2 - heightAll; Vec2i pos = Vec2i( mArea.getX1(), heightAll ); (*p)->draw( pos, mArea.getWidth(), heightMax ); heightAll += heightAct; if( mArea.y2 < heightAll ) break; } // draw header line Vec2i posResize1 = mArea.getLR(); posResize1 -= 2; Vec2i posResize2 = posResize1; posResize2.y -= 5; Vec2i posResize3 = posResize1; posResize3.x -= 5; gl::drawLine( posResize1, posResize2 ); gl::drawLine( posResize1, posResize3 ); gl::disableAlphaBlending(); }
// manually build a string of numerical digits, filtering out everything else void iosKeyboardApp::processNumerical( const KeyEvent &event ) { if( event.getCode() == KeyEvent::KEY_BACKSPACE && ! mNumericalTextView.mText.empty() ) mNumericalTextView.mText.pop_back(); else if( isdigit( event.getChar() ) ) { mNumericalTextView.mText.push_back( event.getChar() ); Rectf fitRect = mNumericalTextView.getTextBounds(); TextBox tbox = TextBox().font( mFont ).text( mNumericalTextView.mText ).size( TextBox::GROW, TextBox::GROW ); vec2 size = tbox.measure(); if( size.x > fitRect.getWidth() ) { console() << "OVERFLOW" << endl; mNumericalTextView.mText.pop_back(); } } }
void handleMouseMove(int x, int y) { std::ostringstream msg; msg << "X:" << x << ", Y:" << y; coordinates.setText(msg.str()); glutPostRedisplay(); }
/* Note that this results with an origin in the center of the screen. Not sure that * I'm too wild about this so that might change in the future. */ void handleReshape(int width, int height) { GLdouble size; GLdouble aspect; /* Use the whole window. */ glViewport(0, 0, width, height); /* We are going to do some 2-D orthographic drawing. */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); size = (GLdouble) ((width >= height) ? width : height) / 2.0; if (width <= height) { aspect = (GLdouble) height / (GLdouble) width; glOrtho(-size, size, -size * aspect, size * aspect, -100000.0, 100000.0); } else { aspect = (GLdouble) width / (GLdouble) height; glOrtho(-size * aspect, size * aspect, -size, size, -100000.0, 100000.0); } /* Make the world and window coordinates coincide so that 1.0 in */ /* model space equals one pixel in window space. */ glScaled(aspect, aspect, 1.0); /* Now determine where to draw things. */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); coordinates.setLocation(-width / 2.0 + 2, height / 2.0 - 2); }
void Game::Render() { _window.BeginDraw(); _world.Render(*_window.GetRenderWindow()); _snake.Render(*_window.GetRenderWindow()); _textBox.Render(*_window.GetRenderWindow()); _window.EndDraw(); }
void TextRenderingApp::resize( ResizeEvent event ) { // allow 20 pixels margin Area box( Vec2i::zero(), event.getSize() ); box.expand(-20, -20); mTextBox.setSize( box.getSize() ); }
void NOC_5_07_RevoluteJointApp::draw() { gl::clear( Color::white() ); glPushMatrix(); if( randFloat( 1.0 ) < 0.1 ) { float sz = randFloat( 4.0, 8.0 ); mParticles.push_back( new Particle( mWorld, Vec2f( randFloat( getWindowWidth() / 2 - 100, getWindowWidth() / 2 + 100 ) , -20.0 ), sz ) ); } // Look at all particles // Draw all particles for( vector<Particle*>::iterator p = mParticles.begin(); p != mParticles.end(); ++p ) { (*p)->display(); } if(mParticles.size() > 0){ for( vector<Particle*>::iterator p = mParticles.end()-1; p != mParticles.begin(); --p ) { if ((*p)->done()) { mParticles.erase( p ); } } } // Draw the windmill mWindmill->display(); glPopMatrix(); // draw the text string status = "OFF"; if( mWindmill->motorOn() ) status = "ON"; TextBox tbox = TextBox().size( Vec2i( 200, TextBox::GROW ) ).text( "Click mouse to toggle motor.\nMotor: " + status ); tbox.setBackgroundColor( ColorA( 0, 0, 0, 0 ) ); Vec2i sz = tbox.measure(); gl::enableAlphaBlending(); glPushMatrix(); gl::translate( Vec2f( 10.0, getWindowHeight() - sz.y -10.0 ) ); gl::draw( gl::Texture( tbox.render() ) ); glPopMatrix(); }
//************************************************************************* // Method: GetItemInstance // Description: Gets the SIOptionInstance object for a given SIOption // // Parameters: // item - Item to query // // Return Value: SIOptionInstance object //************************************************************************* SIOptionInstance* SIOptionsListView::GetItemInstance(SIOption* item) { SIOptionInstance* instance = dynamic_cast<SIOptionInstance*>(itemInstance->Item[item]); if (instance) return instance; instance = new SIOptionInstance(); // Create the control for editing the setting ComboBox* comboBox; TextBox* textBox; switch (item->type) { case SIOptionType::BooleanOption: comboBox = new ComboBox(); comboBox->DropDownStyle = ComboBoxStyle::DropDownList; comboBox->Items->Add(S"Disabled"); comboBox->Items->Add(S"Enabled"); comboBox->SelectedIndex = 0; comboBox->SelectedIndexChanged += new EventHandler(this, OnItemTextChanged); instance->control = comboBox; break; case SIOptionType::IntegerOption: textBox = new TextBox(); textBox->Text = "0"; textBox->Select(0, 0); textBox->TextChanged += new EventHandler(this, OnItemTextChanged); instance->control = textBox; break; case SIOptionType::StringOption: textBox = new TextBox(); textBox->Text = ""; textBox->Select(0, 0); textBox->TextChanged += new EventHandler(this, OnItemTextChanged); instance->control = textBox; break; } instance->control->Location = System::Drawing::Point(0, 0); instance->control->Width = controlHeader->Width; itemInstance->Add(item, instance); return instance; }
/********************************************************* * insertItem * *********************************************************/ void Menu::insertItem(std::string text, std::string imageFile, bool avaible) { TextBox* novo; /* Insert Picture */ if(!imageFile.empty()) { insertPicture(x,y,0,0, imageFile.c_str()); numPictures++; } /* Insert Text Box */ novo = insertTextBox(x,y,x+200,y+200,0,text); novo->setAvailable(avaible); if(text.length() > maxCharac) { maxCharac = (int)text.length(); } }
void EventTypeLabel::Map(map<uint32_t, next::Event> *events){ Font font(app::loadResource(RES_AKKURAT_BOLD), SESSION_LABEL_META_FONT_SIZE * SESSION_LABEL_META_FONT_SCALAR); TextBox textBox; textBox.setFont(font); textBox.setWidth( SESSION_LABEL_SESSION_META_BOX_WIDTH); textBox.setFontSize( SESSION_LABEL_META_FONT_SIZE); textBox.setColorFont( SESSION_LABEL_SESSION_META_FONT_COLOR); for(map<uint32_t, next::Event>::const_iterator itr = events->begin(); itr != events->end(); ++itr){ const string& type = itr->second.type; textBox.setString(type); sMapTypeTexture[type] = TextBoxTexture(); sMapTypeTexture[type].calculatedSize = textBox.getCalculatedSize(); sMapTypeTexture[type].texcoords = textBox.getTexcoords(); sMapTypeTexture[type].topleft = textBox.getTopLeft(); sMapTypeTexture[type].texture = gl::Texture(Surface(textBox.getTexture())); } }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutCreateWindow("OGL Console Sandbox"); console.setLocation(-240, 120); console.setSize(480, 240); coordinates.setLocation(0, 0); coordinates.setSize(150, 30); glutDisplayFunc(handleDisplay); glutKeyboardFunc(handleKeyboard); glutSpecialFunc(handleSpecialKeyboard); glutReshapeFunc(handleReshape); glutMouseFunc(handleMouse); glutMainLoop(); }
void handleDisplay() { // Clear the window glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); console.draw(); coordinates.draw(); // Swap buffers (color buffers, makes previous render visible) glutSwapBuffers(); }