当前位置: 首页>>代码示例>>C++>>正文


C++ TextButton::setText方法代码示例

本文整理汇总了C++中TextButton::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ TextButton::setText方法的具体用法?C++ TextButton::setText怎么用?C++ TextButton::setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextButton的用法示例。


在下文中一共展示了TextButton::setText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Window

	UfopaediaStartState::UfopaediaStartState()
	{
		_screen = false;

		// set background window
		_window = new Window(this, 256, 180, 32, 10, POPUP_BOTH);

		// set title
		_txtTitle = new Text(224, 17, 48, 33);

		// Set palette
		setInterface("ufopaedia");

		add(_window, "window", "ufopaedia");
		add(_txtTitle, "text", "ufopaedia");

		_btnOk = new TextButton(224, 12, 48, 167);
		add(_btnOk, "button1", "ufopaedia");

		// set buttons
		const std::vector<std::string> &list = _game->getMod()->getUfopaediaCategoryList();
		int y = 50;
		y -= 13 * (list.size() - 9);
		for (std::vector<std::string>::const_iterator i = list.begin(); i != list.end(); ++i)
		{
			TextButton *button = new TextButton(224, 12, 48, y);
			y += 13;

			add(button, "button1", "ufopaedia");

			button->setText(tr(*i));
			button->onMouseClick((ActionHandler)&UfopaediaStartState::btnSectionClick);

			_btnSections.push_back(button);
		}
		if (!_btnSections.empty())
			_txtTitle->setY(_btnSections.front()->getY() - _txtTitle->getHeight());

		centerAllSurfaces();

		_window->setBackground(_game->getMod()->getSurface("BACK01.SCR"));

		_txtTitle->setBig();
		_txtTitle->setAlign(ALIGN_CENTER);
		_txtTitle->setText(tr("STR_UFOPAEDIA"));
		
		_btnOk->setText(tr("STR_OK"));
		_btnOk->onMouseClick((ActionHandler)&UfopaediaStartState::btnOkClick);
		_btnOk->onKeyboardPress((ActionHandler)&UfopaediaStartState::btnOkClick, Options::keyCancel);
		_btnOk->onKeyboardPress((ActionHandler)&UfopaediaStartState::btnOkClick, Options::keyGeoUfopedia);
	}
开发者ID:DiceMaster,项目名称:OpenXcom,代码行数:51,代码来源:UfopaediaStartState.cpp

示例2:

Dialog::Dialog(std::shared_ptr<DialogData> p) {
	using namespace DialogSettings;
	sizePolicy = WidgetSizePolicy::PREFER;
	layout._setPos(IntPair{borderSz, borderSz});
	layout.setMargins(0, 0, 0, 0);
	layout.setWidgetAlignment(WidgetAlignmentHoriz::LEFT, WidgetAlignmentVert::TOP);
	layout.setSpacing(widgetSpacing);
	// process data
	assert(p);
	data = p;
	assert(!data->title.empty());
	assert(!data->message.empty());
	assert(!data->buttonText.empty());
	TextRenderer* tr = GameData::instance().resources->getDefaultTR();
	WidgetText* textTitle = new WidgetText;
	textTitle->enableBackground(colTitleBg);
	textTitle->setRenderer(tr);
	textTitle->setTextColor(colText);
	textTitle->setText(data->title);
	WidgetText* textMessage = new WidgetText;
	textMessage->setRenderer(tr);
	textMessage->setTextColor(colText);
	textMessage->setText(data->message);
	// add buttons
	HorizontalLayout* hLayout = new HorizontalLayout;
	hLayout->setWidgetAlignment(WidgetAlignmentHoriz::LEFT, WidgetAlignmentVert::TOP);
	hLayout->setSpacing(btnSpacing);
	std::shared_ptr<TextButton::Style> buttonStyle = std::make_shared<TextButton::Style>();
	buttonStyle->tr = tr;
	buttonStyle->outlineSz = 0;
	buttonStyle->colText = colBtnText;
	buttonStyle->colBgOut = colBtnBgOut;
	buttonStyle->colBgOver = colBtnBgOver;
	buttonStyle->colBgDown = colBtnBgDown;
	TextButton* button;
	for (std::size_t i = 0; i < data->buttonText.size(); ++i) {
		button = new TextButton;
		button->setStyle(buttonStyle);
		button->setText(data->buttonText[i]);
		button->setCallback(std::bind(&self_type::buttonCallback, this, i));
		hLayout->add(button);
	}
	// add to layout
	layout.add(textTitle);
	layout.add(textMessage);
	layout.add(hLayout);
	// finalize
	layout._setParent(this);
	_resize(getPrefSize(), WidgetResizeFlag::SELF);
}
开发者ID:wesulee,项目名称:mr,代码行数:50,代码来源:widget_dialog.cpp

示例3: Window

/**
 * Initializes all the elements in the Psi Training screen.
 * @param game Pointer to the core game.
 */
PsiTrainingState::PsiTrainingState()
{
	// Create objects
	_window = new Window(this, 320, 200, 0, 0);
	_txtTitle = new Text(300, 17, 10, 16);
	_btnOk = new TextButton(160, 14, 80, 174);

	// Set palette
	setPalette("PAL_BASESCAPE", 7);

	add(_window);
	add(_btnOk);
	add(_txtTitle);

	// Set up objects
	_window->setColor(Palette::blockOffset(15)+6);
	_window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR"));

	_btnOk->setColor(Palette::blockOffset(13)+10);
	_btnOk->setText(tr("STR_OK"));
	_btnOk->onMouseClick((ActionHandler)&PsiTrainingState::btnOkClick);
	_btnOk->onKeyboardPress((ActionHandler)&PsiTrainingState::btnOkClick, Options::keyCancel);

	_txtTitle->setColor(Palette::blockOffset(13)+10);
	_txtTitle->setBig();
	_txtTitle->setAlign(ALIGN_CENTER);
	_txtTitle->setText(tr("STR_PSIONIC_TRAINING"));

	int buttons = 0;
	for(std::vector<Base*>::const_iterator b = _game->getSavedGame()->getBases()->begin(); b != _game->getSavedGame()->getBases()->end(); ++b)
	{
		if((*b)->getAvailablePsiLabs())
		{
			TextButton *btnBase = new TextButton(160, 14, 80, 40 + 16 * buttons);
			btnBase->setColor(Palette::blockOffset(15) + 6);
			btnBase->onMouseClick((ActionHandler)&PsiTrainingState::btnBaseXClick);
			btnBase->setText((*b)->getName());
			add(btnBase);
			_bases.push_back(*b);
			_btnBases.push_back(btnBase);
			++buttons;
			if (buttons >= 8)
			{
				break;
			}
		}
	}

	centerAllSurfaces();
}
开发者ID:AMDmi3,项目名称:OpenXcom,代码行数:54,代码来源:PsiTrainingState.cpp

示例4: addDisabledTextButton

int InstructionsMenu::addDisabledTextButton(const string &text, int x, int y, bool isHeader)
{
	TextButton *txtBut = new TextButton();
	txtBut->setText(text);	
	txtBut->setX(x);
	txtBut->setY(y);
	txtBut->setEnabled(false);
	txtBut->setTextColor(INSTR_R, INSTR_G, INSTR_B);
	if (isHeader) {
		txtBut->setTextSize(HEADER_TEXT_SIZE);	
	} else {
		txtBut->setTextSize(STANDARD_TEXT_SIZE);
	}
	m_buttons.push_back(txtBut);
	return txtBut->getHeight() + BUTTON_SEP;	
}
开发者ID:firehazard,项目名称:SphereWars,代码行数:16,代码来源:InstructionsMenu.cpp

示例5: init

void InstructionsMenu::init()
{
	TextButton *txtBut;
	int yPos;
	
	setTitle("Controls");
	
	yPos = initControlsDisplay();

	// Init back button.
	txtBut = new TextButton();
	txtBut->setText("Back");
	txtBut->setX(txtBut->getCenteredXPos());
	txtBut->setY(yPos);
	m_buttons.push_back(txtBut);
	yPos += txtBut->getHeight() + BUTTON_SEP;
	
}
开发者ID:firehazard,项目名称:SphereWars,代码行数:18,代码来源:InstructionsMenu.cpp

示例6: State

/**
 * Initializes all the elements in the Multiple Targets window.
 * @param game Pointer to the core game.
 * @param targets List of targets to display.
 * @param craft Pointer to craft to retarget (NULL if none).
 * @param state Pointer to the Geoscape state.
 */
MultipleTargetsState::MultipleTargetsState(Game *game, std::vector<Target*> targets, Craft *craft, GeoscapeState *state) : State(game), _targets(targets), _craft(craft), _state(state)
{
	_screen = false;

	if (_targets.size() > 1)
	{
		int winHeight = BUTTON_HEIGHT * _targets.size() + SPACING * (_targets.size() - 1) + MARGIN * 2;
		int winY = (200 - winHeight) / 2;
		int btnY = winY + MARGIN;

		// Create objects
		_window = new Window(this, 136, winHeight, 60, winY, POPUP_VERTICAL);

		// Set palette
		setPalette("PAL_GEOSCAPE", 7);

		add(_window);

		// Set up objects
		_window->setColor(Palette::blockOffset(8) + 5);
		_window->setBackground(_game->getResourcePack()->getSurface("BACK15.SCR"));

		int y = btnY;
		for (size_t i = 0; i < _targets.size(); ++i)
		{
			TextButton *button = new TextButton(116, BUTTON_HEIGHT, 70, y);
			button->setColor(Palette::blockOffset(8) + 5);
			button->setText(_targets[i]->getName(_game->getLanguage()));
			button->onMouseClick((ActionHandler)&MultipleTargetsState::btnTargetClick);
			add(button);

			_btnTargets.push_back(button);

			y += button->getHeight() + SPACING;
		}
		_btnTargets[0]->onKeyboardPress((ActionHandler)&MultipleTargetsState::btnCancelClick, Options::keyCancel);

		centerAllSurfaces();
	}
}
开发者ID:ArcticPheenix,项目名称:OpenXcom,代码行数:47,代码来源:MultipleTargetsState.cpp

示例7: init

void PauseState::init()
{
    sf::Vector2f window( mGame->getTarget()->getSize().x, mGame->getTarget()->getSize().y );
    sf::Vector2f boxSize( 500.0f, 230.f );
    sf::Vector2f boxPosition( window.x / 2.f - boxSize.x / 2.f, window.y / 2.f - boxSize.y / 2.f );

    TextButton* bg = new TextButton();
    bg->setSize( boxSize );
    bg->setPosition( boxPosition );
    bg->setBackgroundColor( sf::Color::Black );
    bg->setVisible( true );
    mMenu.addItem( "1_BG", bg );

    TextButton* resume = new TextButton();
    resume->setFont( DEFAULT_FONT );
    resume->setText( "Resume" );
    resume->setTextColor( sf::Color::White );
    resume->setHighlightTextColor( sf::Color::Green );
    resume->setPosition( sf::Vector2f( boxPosition.x + 20.f, boxPosition.y + 20.f ) );
    resume->setSize( sf::Vector2f( boxSize.x - 40.f, 50.f ) );
    resume->setBackgroundColor( sf::Color( 50.f, 50.f, 50.f, 200.f ) );
    resume->setVisible( true );
    resume->setClickFunction( []( Menu* menu, Game* game )
    {
        game->popState();
    } );
    mMenu.addItem( "2_Resume", resume );

//    TextButton* restart = new TextButton();
//    restart->setFont( DEFAULT_FONT );
//    restart->setText( "Restart" );
//    restart->setTextColor( sf::Color::White );
//    restart->setHighlightTextColor( sf::Color::Green );
//    restart->setPosition( sf::Vector2f( boxPosition.x + 20.f, boxPosition.y + 90.f ) );
//    restart->setSize( sf::Vector2f( boxSize.x - 40.f, 50.f ) );
//    restart->setBackgroundColor( sf::Color( 50.f, 50.f, 50.f, 200.f ) );
//    restart->setVisible( true );
//    std::string map = mMap;
//    restart->setClickFunction( [map]( Menu* menu, Game* game )
//    {
//        std::cout << map << std::endl;
//        game->popState();
//        game->popState();
//        game->pushState( new PlayState( map ) );
//    } );
//    mMenu.addItem( "3_Restart", restart );

    TextButton* menu = new TextButton();
    menu->setFont( DEFAULT_FONT );
    menu->setText( "Return to menu" );
    menu->setTextColor( sf::Color::White );
    menu->setHighlightTextColor( sf::Color::Green );
    menu->setPosition( sf::Vector2f( boxPosition.x + 20.f, boxPosition.y + 90.f ) );
    menu->setSize( sf::Vector2f( boxSize.x - 40.f, 50.f ) );
    menu->setBackgroundColor( sf::Color( 50.f, 50.f, 50.f, 200.f ) );
    menu->setVisible( true );
    menu->setClickFunction( []( Menu* menu, Game* game )
    {
        game->popState();
        game->popState();
    } );
    mMenu.addItem( "4_Menu", menu );

    TextButton* quit = new TextButton();
    quit->setFont( DEFAULT_FONT );
    quit->setText( "Quit" );
    quit->setTextColor( sf::Color::White );
    quit->setHighlightTextColor( sf::Color::Green );
    quit->setPosition( sf::Vector2f( boxPosition.x + 20.f, boxPosition.y + 160.f ) );
    quit->setSize( sf::Vector2f( boxSize.x - 40.f, 50.f ) );
    quit->setBackgroundColor( sf::Color( 50.f, 50.f, 50.f, 200.f ) );
    quit->setVisible( true );
    quit->setClickFunction( []( Menu* menu, Game* game )
    {
        game->quit();
    } );
    mMenu.addItem( "5_Quit", quit );
}
开发者ID:TheNinthFox,项目名称:icw,代码行数:78,代码来源:PauseState.cpp


注:本文中的TextButton::setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。