• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TextButton类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add

/**
 * Adds a new child surface for the state to take care of,
 * giving it the game's display palette. Once associated,
 * the state handles all of the surface's behaviour
 * and management automatically.
 * @param surface Child surface.
 * @note Since visible elements can overlap one another,
 * they have to be added in ascending Z-Order to be blitted
 * correctly onto the screen.
 */
void State::add(Surface *surface)
{
	// Set palette
	surface->setPalette(_game->getScreen()->getPalette());

	// Set default fonts
	Text *t = dynamic_cast<Text*>(surface);
	TextButton *tb = dynamic_cast<TextButton*>(surface);
	TextEdit *te = dynamic_cast<TextEdit*>(surface);
	TextList *tl = dynamic_cast<TextList*>(surface);
	if (t)
	{
		t->setFonts(_game->getResourcePack()->getFont("BIGLETS.DAT"), _game->getResourcePack()->getFont("SMALLSET.DAT"));
	}
	else if (tb)
	{
		tb->setFonts(_game->getResourcePack()->getFont("BIGLETS.DAT"), _game->getResourcePack()->getFont("SMALLSET.DAT"));
	}
	else if (te)
	{
		te->setFonts(_game->getResourcePack()->getFont("BIGLETS.DAT"), _game->getResourcePack()->getFont("SMALLSET.DAT"));
	}
	else if (tl)
	{
		tl->setFonts(_game->getResourcePack()->getFont("BIGLETS.DAT"), _game->getResourcePack()->getFont("SMALLSET.DAT"));
	}

	_surfaces.push_back(surface);
}
开发者ID:UnkLegacy,项目名称:OpenXcom,代码行数:39,代码来源:State.cpp


示例2: TextButton

void UI::RenderThreadInitReceipts()
{
	// delay creation of new labels for the rendering thread
	if (m_pendingReceipts.size() > 0)
	{
		for (int index = 0; index < m_pendingReceipts.size(); ++index)
		{
			char buffer[1024];

			//sprintf(buffer, "Copy receipt %s", m_pendingReceipts[index].Identifier.c_str());
			//LOGI(buffer);

			TextButton* txtReceipt = new TextButton();
			OuyaSDK::Receipt* newReceipt = new OuyaSDK::Receipt(m_pendingReceipts[index]);
			txtReceipt->DataContext = newReceipt;

			//sprintf(buffer, "Setting up receipt ui %s", newReceipt->Identifier.c_str());
			//LOGI(buffer);

			sprintf(buffer, NVBF_COLORSTR_GRAY "%s (%.2f)", newReceipt->Identifier.c_str(), newReceipt->LocalPrice);
			txtReceipt->ActiveText = buffer;
			txtReceipt->InactiveText = buffer;

			txtReceipt->Setup(2, 32);

			m_receipts.push_back(txtReceipt);
		}

		m_uiChanged = true;

		m_pendingReceipts.clear();
	}
}
开发者ID:Arg410,项目名称:ouya-sdk-examples,代码行数:33,代码来源:UI.cpp


示例3: String

MainContentComponent::MainContentComponent()
{
    // Create 10 buttons.
    for (int i = 0; i < 10; ++i) {
        // Construct a button name based on the loop counter.
        String buttonName;
        buttonName << "Button " << String (i);
        
        // Create a button.
        TextButton* button = new TextButton (buttonName);
        
        // Listen for button clicks.
        button->addListener (this);
        
        // Add the button to the array.
        buttons.add (button);
        
        // Add the button to this parent component.
        addAndMakeVisible (button);
    }
    
    // Add the label to this parent component.
    addAndMakeVisible (&label);
    
    // Configure the label text display.
    label.setJustificationType (Justification::centred);
    label.setText ("no buttons clicked", dontSendNotification);
    
    setSize (500, 400);
}
开发者ID:bingo2011,项目名称:codes_GettingStartedWithJuce,代码行数:30,代码来源:MainComponent.cpp


示例4: mousePress

/**
 * Sets the button as the pressed button if it's part of a group.
 * @param action Pointer to an action.
 * @param state State that the action handlers belong to.
 */
void TextButton::mousePress(Action *action, State *state)
{
	if (action->getDetails()->button.button == SDL_BUTTON_LEFT && _group != 0)
	{
		TextButton *old = *_group;
		*_group = this;
		if (old != 0)
			old->draw();
		draw();
	}

	if (isButtonHandled(action->getDetails()->button.button))
	{		
		if (soundPress != 0 && _group == 0 &&
			action->getDetails()->button.button != SDL_BUTTON_WHEELUP && action->getDetails()->button.button != SDL_BUTTON_WHEELDOWN)
		{
			soundPress->play(Mix_GroupAvailable(0));
		}

		if (_comboBox)
		{
			_comboBox->toggle();
		}

		draw();
		//_redraw = true;
	}
	InteractiveSurface::mousePress(action, state);
}
开发者ID:AngledStream,项目名称:OpenXcom,代码行数:34,代码来源:TextButton.cpp


示例5: TextButton

void DirList::add_button(const int i, const std::string& str)
{
    TextButton* t = new TextButton(0, i*20, get_xl(), 20);
    t->set_undraw_color(color[COL_API_M]);
    t->set_text(str);
    buttons.push_back(t);
    add_child(*t);
}
开发者ID:twelvedogs,项目名称:Lix,代码行数:8,代码来源:list_dir.cpp


示例6: TextButton

TextButton* TextButton::Create(Window *parent, float x, float y, const string_t &text, const char *font)
{
	TextButton *res = new TextButton(parent);
	res->Move(x, y);
	res->SetText(text);
	res->SetFont(font);
	return res;
}
开发者ID:Asqwel,项目名称:TZOD-Modified,代码行数:8,代码来源:Button.cpp


示例7: onLoadScene

void CocosBaseComponetTest::onLoadScene()
{
	Language::init("language.xml");

	TextButton* btn = TextButton::create(TYPE_RECT_BLUE, "CBFloatTips", 200);
	this->addChild(btn);
	btn->setPosition(ccp(200, 200));
	btn->setTag(11);
	btn->addEventListener(this, text_button_selector(CocosBaseComponetTest::btnClickHandler));
}
开发者ID:bontey,项目名称:geckosCocos2dxUtils,代码行数:10,代码来源:CocosBaseComponetTest.cpp


示例8: if

	// Refresh the list of files or macros in the Files popup window
	void FileSet::RefreshPopup()
	{
		if (which >= 0)
		{
			FileListIndex& fileIndex = fileIndices[which];
		
			// 1. Sort the file list
			fileIndex.sort(StringGreaterThan);
		
			// 2. Make sure the scroll position is still sensible
			if (scrollOffset < 0)
			{
				scrollOffset = 0;
			}
			else if ((unsigned int)scrollOffset >= fileIndex.size())
			{
				scrollOffset = ((fileIndex.size() - 1)/numFileRows) * numFileRows;
			}
		
			// 3. Display the scroll buttons if needed
			mgr.Show(scrollFilesLeftButton, scrollOffset != 0);
			mgr.Show(scrollFilesRightButton, scrollOffset + (numFileRows * numFileColumns) < fileIndex.size());
			mgr.Show(filesUpButton, IsInSubdir());
		
			// 4. Display the file list
			for (size_t i = 0; i < numDisplayedFiles; ++i)
			{
				TextButton *f = filenameButtons[i];
				if (i + scrollOffset < fileIndex.size())
				{
					const char *text = fileIndex[i + scrollOffset];
					f->SetText(text);
					f->SetEvent(fileEvent, text);
					mgr.Show(f, true);
				}
				else
				{
					f->SetText("");
					mgr.Show(f, false);
				}
			}
			displayedFileSet = this;
		}
		else
		{
			mgr.Show(scrollFilesLeftButton, false);
			mgr.Show(scrollFilesRightButton, false);
			for (size_t i = 0; i < numDisplayedFiles; ++i)
			{
				mgr.Show(filenameButtons[i], false);
			}
		}
	}
开发者ID:ADVALAIN596,项目名称:PanelDue,代码行数:54,代码来源:FileManager.cpp


示例9: 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


示例10: assert

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


示例11: 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


示例12: drawButtonText

void mlrVSTLookAndFeel::drawButtonText (Graphics& g, TextButton& button,
                                        bool /*isMouseOverButton*/, bool isButtonDown)
{
    g.setFont(defaultFont);

    if (isButtonDown)
        g.setColour(button.findColour(TextButton::textColourOnId));
    else
        g.setColour(button.findColour(TextButton::textColourOffId));

    g.drawFittedText (button.getButtonText(), 4, 4,
        button.getWidth() - 2, button.getHeight() - 8,
        Justification::centredLeft, 10);
}
开发者ID:grimtraveller,项目名称:mlrVST,代码行数:14,代码来源:mlrVSTLookAndFeel.cpp


示例13: applyBattlescapeTheme

/**
 * switch all the colours to something a little more battlescape appropriate.
 */
void State::applyBattlescapeTheme()
{
	for (std::vector<Surface*>::iterator i = _surfaces.begin(); i != _surfaces.end(); ++i)
	{
		Window* window = dynamic_cast<Window*>(*i);
		if (window)
		{
			window->setColor(Palette::blockOffset(0)-1);
			window->setHighContrast(true);
			window->setBackground(_game->getResourcePack()->getSurface("TAC00.SCR"));
		}
		Text* text = dynamic_cast<Text*>(*i);
		if (text)
		{
			text->setColor(Palette::blockOffset(0)-1);
			text->setHighContrast(true);
		}
		TextButton* button = dynamic_cast<TextButton*>(*i);
		if (button)
		{
			button->setColor(Palette::blockOffset(0)-1);
			button->setHighContrast(true);
		}
		TextEdit* edit = dynamic_cast<TextEdit*>(*i);
		if (edit)
		{
			edit->setColor(Palette::blockOffset(0)-1);
			edit->setHighContrast(true);
		}
		TextList* list = dynamic_cast<TextList*>(*i);
		if (list)
		{
			list->setColor(Palette::blockOffset(0)-1);
			list->setArrowColor(Palette::blockOffset(0));
			list->setHighContrast(true);
		}
		ArrowButton *arrow = dynamic_cast<ArrowButton*>(*i);
		if (arrow)
		{
			arrow->setColor(Palette::blockOffset(0));
		}
		Slider *slider = dynamic_cast<Slider*>(*i);
		if (slider)
		{
			slider->setColor(Palette::blockOffset(0)-1);
			slider->setHighContrast(true);
		}
	}
}
开发者ID:AngelusEV,项目名称:OpenXcom,代码行数:52,代码来源:State.cpp


示例14: mousePress

/**
 * Sets the button as the pressed button if it's part of a group.
 * @param action Pointer to an action.
 * @param state State that the action handlers belong to.
 */
void TextButton::mousePress(Action *action, State *state)
{
	if (soundPress != 0 && _group == 0)
		soundPress->play();

	if (_group != 0)
	{
		TextButton *old = *_group;
		*_group = this;
		old->draw();
	}

	InteractiveSurface::mousePress(action, state);
	_redraw = true;
}
开发者ID:Devanon,项目名称:OpenXcom,代码行数:20,代码来源:TextButton.cpp


示例15: chaseManager

//==============================================================================
Copier::Copier( ChaseManager* chaseManager ) :
chaseManager( chaseManager )
{
	//create 4 buttons for x1, x2, x4 and x8
	for ( int i = 0; i < 4; i++ )
	{
		TextButton* b = new TextButton( String( i ) );
		b->setButtonText( "x" + String( pow( 2, i ) ) );
		ColourLookAndFeel claf;
		b->setColour( TextButton::buttonColourId, claf.backgroundColour );
		b->addListener( this );
		addAndMakeVisible( b );
		buttons.add( b );
	}
}
开发者ID:jorisdejong,项目名称:Chaser,代码行数:16,代码来源:Copier.cpp


示例16: mousePress

/**
 * Sets the button as the pressed button if it's part of a group.
 * @param action Pointer to an action.
 * @param state State that the action handlers belong to.
 */
void TextButton::mousePress(Action *action, State *state)
{
	if (soundPress != 0 && _group == 0 &&
		action->getDetails()->button.button != SDL_BUTTON_WHEELUP && action->getDetails()->button.button != SDL_BUTTON_WHEELDOWN)
	{
		soundPress->play();
	}

	if (action->getDetails()->button.button == SDL_BUTTON_LEFT && _group != 0)
	{
		TextButton *old = *_group;
		*_group = this;
		if (old != 0)
			old->draw();
	}
	draw();
	InteractiveSurface::mousePress(action, state);
	//_redraw = true;
}
开发者ID:Arthur1994,项目名称:OpenXcom,代码行数:24,代码来源:TextButton.cpp


示例17: TextButton

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


示例18: LookAndFeelDemoComponent

    LookAndFeelDemoComponent()
    {
        addAndMakeVisible (rotarySlider);
        rotarySlider.setSliderStyle (Slider::RotaryHorizontalVerticalDrag);
        rotarySlider.setTextBoxStyle (Slider::NoTextBox, false, 0, 0);
        rotarySlider.setValue (2.5);

        addAndMakeVisible (verticalSlider);
        verticalSlider.setSliderStyle (Slider::LinearVertical);
        verticalSlider.setTextBoxStyle (Slider::NoTextBox, false, 90, 20);
        verticalSlider.setValue (6.2);

        addAndMakeVisible (barSlider);
        barSlider.setSliderStyle (Slider::LinearBar);
        barSlider.setValue (4.5);

        addAndMakeVisible (incDecSlider);
        incDecSlider.setSliderStyle (Slider::IncDecButtons);
        incDecSlider.setRange (0.0, 10.0, 1.0);
        incDecSlider.setIncDecButtonsMode (Slider::incDecButtonsDraggable_Horizontal);
        incDecSlider.setTextBoxStyle (Slider::TextBoxBelow, false, 90, 20);

        addAndMakeVisible (button1);
        button1.setButtonText ("Hello World!");

        addAndMakeVisible (button2);
        button2.setButtonText ("Hello World!");
        button2.setClickingTogglesState (true);
        button2.setToggleState (true, dontSendNotification);

        addAndMakeVisible (button3);
        button3.setButtonText ("Hello World!");

        addAndMakeVisible (button4);
        button4.setButtonText ("Toggle Me");
        button4.setToggleState (true, dontSendNotification);

        for (int i = 0; i < 3; ++i)
        {
            TextButton* b = radioButtons.add (new TextButton());
            addAndMakeVisible (b);
            b->setRadioGroupId (42);
            b->setClickingTogglesState (true);
            b->setButtonText ("Button " + String (i + 1));

            switch (i)
            {
                case 0:     b->setConnectedEdges (Button::ConnectedOnRight);                            break;
                case 1:     b->setConnectedEdges (Button::ConnectedOnRight + Button::ConnectedOnLeft);  break;
                case 2:     b->setConnectedEdges (Button::ConnectedOnLeft);                             break;
                default:    break;
            }
        }

        radioButtons.getUnchecked (2)->setToggleState (true, dontSendNotification);
    }
开发者ID:Neknail,项目名称:JUCE,代码行数:56,代码来源:LookAndFeelDemo.cpp


示例19: 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


示例20: add

/**
 * Adds a new child surface for the state to take care of,
 * giving it the game's display palette. Once associated,
 * the state handles all of the surface's behaviour
 * and management automatically.
 * @param surface Child surface.
 * @note Since visible elements can overlap one another,
 * they have to be added in ascending Z-Order to be blitted
 * correctly onto the screen.
 */
void State::add(Surface *surface)
{
	// Set palette
	surface->setPalette(_game->getScreen()->getPalette());

	// Set default fonts
	Text *t = dynamic_cast<Text*>(surface);
	TextButton *tb = dynamic_cast<TextButton*>(surface);
	TextEdit *te = dynamic_cast<TextEdit*>(surface);
	TextList *tl = dynamic_cast<TextList*>(surface);
	WarningMessage *wm = dynamic_cast<WarningMessage*>(surface);
	BaseView *bv = dynamic_cast<BaseView*>(surface);
	if (t)
	{
		t->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt"));
	}
	else if (tb)
	{
		tb->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt"));
	}
	else if (te)
	{
		te->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt"));
	}
	else if (tl)
	{
		tl->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt"));
	}
	else if (bv)
	{
		bv->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt"));
	}
	else if (wm)
	{
		wm->setFonts(_game->getResourcePack()->getFont("Big.fnt"), _game->getResourcePack()->getFont("Small.fnt"));
	}

	_surfaces.push_back(surface);
}
开发者ID:Gilligan-MN,项目名称:OpenXcom,代码行数:49,代码来源:State.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TextCheckerClient类代码示例发布时间:2022-05-31
下一篇:
C++ TextBreakIterator类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap