コード例 #1
0
ファイル: State.cpp プロジェクト: UnkLegacy/OpenXcom
/**
 * 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);
}
コード例 #2
0
ファイル: UI.cpp プロジェクト: Arg410/ouya-sdk-examples
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();
	}
}
コード例 #3
0
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);
}
コード例 #4
0
ファイル: CameraDemo.cpp プロジェクト: bacchus/JUCE
    void buttonClicked (Button* b) override
    {
        if (cameraDevice != nullptr)
        {
            if (b == &recordMovieButton)
            {
                // The user has clicked the record movie button..
                if (! recordingMovie)
                {
                    // Start recording to a file on the user's desktop..
                    recordingMovie = true;

                    File file (File::getSpecialLocation (File::userDesktopDirectory)
                               .getNonexistentChildFile ("JuceCameraDemo",
                                                         CameraDevice::getFileExtension()));

                    cameraDevice->startRecordingToFile (file);
                    recordMovieButton.setButtonText ("Stop Recording");
                }
                else
                {
                    // Already recording, so stop...
                    recordingMovie = false;
                    cameraDevice->stopRecording();
                    recordMovieButton.setButtonText ("Start recording (to a file on your desktop)");
                }
            }
            else
            {
                // When the user clicks the snapshot button, we'll attach ourselves to
                // the camera as a listener, and wait for an image to arrive...
                cameraDevice->addListener (this);
            }
        }
    }
コード例 #5
0
ファイル: TextButton.cpp プロジェクト: AngledStream/OpenXcom
/**
 * 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);
}
コード例 #6
0
ファイル: list_dir.cpp プロジェクト: twelvedogs/Lix
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);
}
コード例 #7
0
ファイル: Button.cpp プロジェクト: Asqwel/TZOD-Modified
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;
}
コード例 #8
0
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));
}
コード例 #9
0
ファイル: FileManager.cpp プロジェクト: ADVALAIN596/PanelDue
	// 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);
			}
		}
	}
コード例 #10
0
ファイル: TextEditor.cpp プロジェクト: josephzizys/CM
void FindAndReplaceDialog::resized()
{
  label1->setBounds (8, 8, 56, 24);
  textEditor1->setBounds (72, 8, 336, 24);
  label2->setBounds (8, 40, 56, 24);
  textEditor2->setBounds (72, 40, 336, 24);
  textButton1->setBounds (8, 72, 80, 24);
  textButton2->setBounds (88, 72, 80, 24);
  textButton3->setBounds (168, 72, 96, 24);
  textButton4->setBounds (264, 72, 64, 24);
  textButton5->setBounds (328, 72, 80, 24);
}
コード例 #11
0
	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);
	}
コード例 #12
0
ファイル: widget_dialog.cpp プロジェクト: wesulee/mr
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);
}
コード例 #13
0
ファイル: UI.cpp プロジェクト: Arg410/ouya-sdk-examples
void UI::RenderThreadInitProducts()
{
	// delay creation of new labels for the rendering thread
	if (m_pendingProducts.size() > 0)
	{
		for (int index = 0; index < m_pendingProducts.size(); ++index)
		{
			char buffer[1024];

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

			TextButton* txtProduct = new TextButton();
			OuyaSDK::Product* newProduct = new OuyaSDK::Product(m_pendingProducts[index]);
			txtProduct->DataContext = newProduct;

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

			sprintf(buffer, NVBF_COLORSTR_WHITE "--> %s (%.2f)", newProduct->Identifier.c_str(), newProduct->LocalPrice);
			txtProduct->ActiveText = buffer;

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

			txtProduct->Setup(2, 32);

			txtProduct->Right = &m_uiRequestPurchase;

			m_products.push_back(txtProduct);

			if (index == 0)
			{
				m_selectedProduct = m_products[0];
				m_products[0]->SetActive(true);
				m_uiRequestProducts.Left = m_selectedProduct;
				m_uiRequestPurchase.Left = m_selectedProduct;
			}
			else
			{
				m_products[index-1]->Down = m_products[index];
				m_products[index]->Up = m_products[index-1];
			}
		}

		m_uiChanged = true;

		m_pendingProducts.clear();
	}
}
コード例 #14
0
ファイル: PsiTrainingState.cpp プロジェクト: AMDmi3/OpenXcom
/**
 * 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();
}
コード例 #15
0
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);
}
コード例 #16
0
ファイル: State.cpp プロジェクト: AngelusEV/OpenXcom
/**
 * 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);
		}
	}
}
コード例 #17
0
ファイル: TextButton.cpp プロジェクト: Devanon/OpenXcom
/**
 * 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;
}
コード例 #18
0
ファイル: Copier.cpp プロジェクト: jorisdejong/Chaser
//==============================================================================
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 );
	}
}
コード例 #19
0
ファイル: LiveConstantDemo.cpp プロジェクト: Xaetrz/AddSyn
    void buttonClicked (Button*) override
    {
        startButton.setVisible (false);
        demoComp.setVisible (true);

        descriptionLabel.setText ("Tweak some of the colours and values in the pop-up window to see what "
                                  "the effect of your changes would be on the component below...",
                                  dontSendNotification);
    }
コード例 #20
0
ファイル: TextButton.cpp プロジェクト: Arthur1994/OpenXcom
/**
 * 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;
}
コード例 #21
0
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;	
}
コード例 #22
0
ファイル: LookAndFeelDemo.cpp プロジェクト: Neknail/JUCE
    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);
    }
コード例 #23
0
ファイル: CameraDemo.cpp プロジェクト: bacchus/JUCE
    void comboBoxChanged (ComboBox*) override
    {
        // This is called when the user chooses a camera from the drop-down list.
        cameraDevice = nullptr;
        cameraPreviewComp = nullptr;
        recordingMovie = false;

        if (cameraSelectorComboBox.getSelectedId() > 1)
        {
            // Try to open the user's choice of camera..
            cameraDevice = CameraDevice::openDevice (cameraSelectorComboBox.getSelectedId() - 2);

            // and if it worked, create a preview component for it..
            if (cameraDevice != nullptr)
                addAndMakeVisible (cameraPreviewComp = cameraDevice->createViewerComponent());
        }

        snapshotButton.setEnabled (cameraDevice != nullptr);
        recordMovieButton.setEnabled (cameraDevice != nullptr);
        resized();
    }
コード例 #24
0
/**
 * 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();
	}
}
コード例 #25
0
ファイル: State.cpp プロジェクト: Gilligan-MN/OpenXcom
/**
 * 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);
}
コード例 #26
0
ファイル: main.cpp プロジェクト: Rachels-Courses/CPP-Course
int main()
{
    Label label;
    label.SetText( "This is a label" );

    Button button;
    button.SetDimensions( 10, 5 );

    TextButton textButton;
    textButton.SetText( "Click Me" );
    textButton.SetDimensions( 10, 5 );

    cout << endl << endl << "LABEL" << endl;
    label.Draw();

    cout << endl << endl << "BUTTON" << endl;
    button.Draw();

    cout << endl << endl << "TEXT BUTTON" << endl;
    textButton.Draw();

    return 0;
}
コード例 #27
0
ファイル: DialogsDemo.cpp プロジェクト: mmgeddie/seniordesign
    DialogsDemo()
    {
        setOpaque (true);

        addAndMakeVisible (nativeButton);
        nativeButton.setButtonText ("Use Native Windows");
        nativeButton.addListener (this);

        static const char* windowNames[] =
        {
            "Plain Alert Window",
            "Alert Window With Warning Icon",
            "Alert Window With Info Icon",
            "Alert Window With Question Icon",
            "OK Cancel Alert Window",
            "Alert Window With Extra Components",
            "CalloutBox",
            "Thread With Progress Window",
            "'Load' File Browser",
            "'Load' File Browser With Image Preview",
            "'Choose Directory' File Browser",
            "'Save' File Browser"
        };

        // warn in case we add any windows
        jassert (numElementsInArray (windowNames) == numDialogs);

        for (int i = 0; i < numDialogs; ++i)
        {
            TextButton* newButton = new TextButton();
            windowButtons.add (newButton);
            addAndMakeVisible (newButton);
            newButton->setButtonText (windowNames[i]);
            newButton->addListener (this);
        }
    }
コード例 #28
0
void ProjucerLookAndFeel::drawButtonText (Graphics& g, TextButton& button, bool isMouseOverButton, bool isButtonDown)
{
    ignoreUnused (isMouseOverButton, isButtonDown);

    g.setFont (getTextButtonFont (button, button.getHeight()));

    g.setColour (button.findColour (button.getToggleState() ? TextButton::textColourOnId
                                                            : TextButton::textColourOffId)
                                   .withMultipliedAlpha (button.isEnabled() ? 1.0f
                                                                            : 0.5f));

    auto xIndent = jmin (8, button.getWidth() / 10);
    auto yIndent = jmin (3,  button.getHeight() / 6);

    auto textBounds = button.getLocalBounds().reduced (xIndent, yIndent);

    g.drawFittedText (button.getButtonText(), textBounds, Justification::centred, 3, 1.0f);
}
コード例 #29
0
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;
	
}
コード例 #30
0
//==============================================================================
PagePickerComponent::PagePickerComponent (int page_)
    : page (page_)
{
    for (int n=0 ; n < 24 ; n++)
    {
        TextButton* button = new TextButton();
        addAndMakeVisible (button);
        button->setButtonText (String (n + 1));
        button->setWantsKeyboardFocus (false);
        
        if (n == page)
        {
            button->setColour (TextButton::buttonColourId, Colours::lightblue);
        }
        else
        {
            button->setColour (TextButton::buttonColourId, Colours::blue);
            button->setColour (TextButton::textColourOffId, Colours::white);
        }
        button->addListener (this);
        buttons.add(button);
    }
}