Widget* ExpandableProvider::createChildItemWidget(int32_t groupPosition, int32_t childPosition) {
    TextWidget* pItem = new TextWidget(mpPage);
    mWidgetPool.append(pItem);
    pItem->setTextSize(30);
    pItem->setBackgroundColor(0xffd3d3d3);
    return pItem;
}
Exemple #2
0
void PLFO::initialize(PVirtualPort* out, PDimmer* k, PDimmer* range,
                      PDimmer* offset, PSelector* selector)
{
    TextWidget* title = new TextWidget(tr("LFO"), this);
    title->setFont(QFont("Courier", 18, QFont::Bold));

    k->setSize(80, 80);
    range->setSize(80, 80);
    offset->setSize(80, 80);
    selector->setMaximumSize(120, 155);

    // Layout
    bottomArea()->addCornerAnchors(k, Qt::BottomLeftCorner, bottomArea(), Qt::BottomLeftCorner);
    bottomArea()->addCornerAnchors(k, Qt::BottomRightCorner, offset, Qt::BottomLeftCorner);
    bottomArea()->addCornerAnchors(k, Qt::TopRightCorner, range, Qt::BottomLeftCorner);
    bottomArea()->addCornerAnchors(range, Qt::BottomRightCorner, offset, Qt::TopRightCorner);
    bottomArea()->addCornerAnchors(offset, Qt::BottomRightCorner, selector, Qt::BottomLeftCorner);

    bottomArea()->addCornerAnchors(selector, Qt::BottomRightCorner, bottomArea(), Qt::BottomRightCorner);
    bottomArea()->addCornerAnchors(selector, Qt::TopRightCorner, bottomArea(), Qt::TopRightCorner);

    rightArea()->addAnchors(out, rightArea());
    centerArea()->addAnchors(title, centerArea());

    bottomArea()->activate();
    layout()->activate();
}
Exemple #3
0
bool BarkGump::loadData(IDataSource* ids, uint32 version)
{
	if (!ItemRelativeGump::loadData(ids, version)) return false;

	counter = static_cast<sint32>(ids->read4());
	textwidget = ids->read2();
	speechshapenum = ids->read4();
	speechlength = ids->read4();
	totaltextheight = ids->read4();

	uint32 slen = ids->read4();
	if (slen > 0) {
		char* buf = new char[slen+1];
		ids->read(buf, slen);
		buf[slen] = 0;
		barked = buf;
		delete[] buf;
	} else {
		barked = "";
	}


	TextWidget *widget = p_dynamic_cast<TextWidget*>(getGump(textwidget));

	SettingManager::get_instance()->get("textdelay", textdelay);

	// This is just a hack
	Pentagram::Rect d;
	widget->GetDims(d);
	counter = d.h * textdelay;
	dims.h = d.h;
	dims.w = d.w;

	return true;
}
	void init() {
		
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_load");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(0, 0));
			me->clicked = boost::bind(&ChooseLoadOrSaveMenuPage::onClickLoad, this);
			me->m_targetMenu = EDIT_QUEST_LOAD;
			me->m_savegame = SavegameHandle::Invalid;
			addCenter(me, true);
		}
		
		{
			std::string szMenuText = getLocalised( "system_menus_main_editquest_save");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = EDIT_QUEST_SAVE;
			
			if(!ARXMenu_CanResumeGame()) {
				me->SetCheckOff();
				me->lColor = Color(127, 127, 127);
			}
			addCenter(me, true);
		}
		
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 380)), "graph/interface/menus/back");
			cb->m_targetMenu = MAIN;
			cb->SetShortCut(Keyboard::Key_Escape);
			add(cb);
		}
	}
Exemple #5
0
void PSampler::initialize(PVirtualPort* in, PVirtualPort* out, PVirtualPort* gate, PDimmer* bpm,
                          PPushButton* record, PPushButton* stop, PPushButton* play)
{
    TextWidget* title = new TextWidget(tr("Sampler"), this);
    title->setFont(QFont("Courier", 18, QFont::Bold));

    bpm->setSize(80, 80);

    record->setIcon(QIcon(":/src/resources/images/record-icon.png"));
    stop->setIcon(QIcon(":/src/resources/images/stop-icon.png"));
    play->setIcon(QIcon(":/src/resources/images/play-icon.png"));

    ProgressBarWidget* progressBar = new ProgressBarWidget(this);
    connect(this, SIGNAL(valueChanged(int)), progressBar, SLOT(setValue(int)));
    connect(this, SIGNAL(lengthChanged(int)), progressBar, SLOT(setMaximum(int)));

    // Layout
    bottomArea()->addCornerAnchors(record, Qt::TopLeftCorner, bottomArea(), Qt::TopLeftCorner);
    bottomArea()->addCornerAnchors(record, Qt::TopRightCorner, stop, Qt::TopLeftCorner);
    bottomArea()->addCornerAnchors(stop, Qt::TopRightCorner, play, Qt::TopLeftCorner);
    bottomArea()->addCornerAnchors(progressBar, Qt::BottomLeftCorner, bottomArea(), Qt::BottomLeftCorner);
    bottomArea()->addCornerAnchors(progressBar, Qt::BottomRightCorner, gate, Qt::BottomLeftCorner);
    bottomArea()->addCornerAnchors(gate, Qt::BottomRightCorner, bpm, Qt::BottomLeftCorner);

    bottomArea()->addCornerAnchors(bpm, Qt::TopRightCorner, bottomArea(), Qt::TopRightCorner);
    bottomArea()->addCornerAnchors(bpm, Qt::BottomRightCorner, bottomArea(), Qt::BottomRightCorner);

    leftArea()->addAnchors(in, leftArea());
    centerArea()->addAnchors(title, centerArea());
    rightArea()->addAnchors(out, rightArea());

    bottomArea()->activate();
    layout()->activate();
}
Exemple #6
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    TextWidget w;
    //w.setWindowFlags(Qt::ToolTip | Qt::CustomizeWindowHint);
    w.show();

    return app.exec();
}
	void init() {
		
		{
			ButtonWidget * cb = new ButtonWidget(Vec2i(0, 0), "graph/interface/icons/menu_main_save");
			cb->SetCheckOff();
			addCenter(cb, true);
		}
		
		{
			std::string szMenuText = getLocalised("system_menu_editquest_newsavegame", "---");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			me->m_savegame = SavegameHandle::Invalid;
			me->eState=EDIT;
			me->ePlace=CENTER;
			addCenter(me, true);
		}
		
		HorizontalPanelWidget * pPanel = new HorizontalPanelWidget;
		
		// Delete button
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_delete");
			TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_DELETE, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = EDIT_QUEST_SAVE;
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(5)));
			me->lOldColor = me->lColor;
			pPanel->AddElementNoCenterIn(me);
			pDeleteButton = me;
		}
		
		// Save button
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_save");
			TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_SAVE, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = MAIN;
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(380)));
			pPanel->AddElementNoCenterIn(me);
		}
		
		// Back button
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 380)), "graph/interface/menus/back");
			cb->m_targetMenu = EDIT_QUEST_SAVE;
			cb->SetShortCut(Keyboard::Key_Escape);
			pPanel->AddElementNoCenterIn(cb);
		}
		
		add(pPanel);
	}
Exemple #8
0
  void UpdateHelp(unsigned index) {
    if (!visible || item_help_callback == nullptr)
      return;

    help_widget->SetText(item_help_callback(index));
    two_widgets->UpdateLayout();
  }
Vector<Widget*> MainPage::createWidgets() {
    RelativeController* plc = NULL;;
    TextWidget* txt = NULL;
    Button* btn = NULL;
    ImageWidget* img = NULL;

    RelativeControllerParams imgParams(ControllerParams::MATCH_PARENT, ControllerParams::MATCH_PARENT);

    RelativeControllerParams button(ControllerParams::WRAP_CONTENT, ControllerParams::WRAP_CONTENT);
    button.setRelation(RelativeControllerParams::ALIGN_PARENT_BOTTOM);
    button.setRelation(RelativeControllerParams::ALIGN_PARENT_LEFT);

    RelativeControllerParams text(ControllerParams::WRAP_CONTENT, ControllerParams::WRAP_CONTENT);
    text.setRelation(RelativeControllerParams::CENTER_IN_PARENT);

    Vector<Widget*> widgets;
    for (size_t i = 0; i < 10; i++) {
        plc = new RelativeController(this);
        mWidgetPool.append(plc);

        img = new ImageWidget(this);
        mWidgetPool.append(img);
        img->setImageResource(gPictures[i]);
        img->setScaleType(ImageWidget::FIT_XY);
        plc->addWidget(img);
        img->setControllerParams(&imgParams);

        txt = new TextWidget(this);
        txt->setControllerParams(&text);
        mWidgetPool.append(txt);
        txt->setText(String::format("this is %d picture.", i + 1));
        txt->setTextColor(0xffff0000);
        plc->addWidget(txt);

        btn = new Button(this);
        btn->setControllerParams(&button);
        mWidgetPool.append(btn);
        btn->setText(String::format("button %d", i+1));
        plc->addWidget(btn);

        widgets.append(plc);
    }
    GLOG(LOG_TAG, LOGINFO, "widgets size %d", widgets.size());
    return widgets;
}
Exemple #10
0
bool BarkGump::NextText()
{
	TextWidget *widget = p_dynamic_cast<TextWidget*>(getGump(textwidget));
	assert(widget);
	if (widget->setupNextText()) {
		// This is just a hack
		Pentagram::Rect d;
		widget->GetDims(d);
		if (speechlength && totaltextheight) {
			counter = (d.h * speechlength) / totaltextheight;
		} else {
			counter = d.h * textdelay;
		}
		dims.h = d.h;
		dims.w = d.w;
		return true;
	}

	return false;
}
Exemple #11
0
void GUI::initWidget(WidgetContext &ctx, TextWidget &widget) {
	if (!ctx.strct->hasField("Obj_Caption"))
		return;

	const Aurora::GFF3Struct &caption = ctx.strct->getStruct("Obj_Caption");

	float r = caption.getDouble("AurString_ColorR", 1.0);
	float g = caption.getDouble("AurString_ColorG", 1.0);
	float b = caption.getDouble("AurString_ColorB", 1.0);
	float a = caption.getDouble("AurString_ColorA", 1.0);

	widget.setColor(r, g, b, a);
}
Exemple #12
0
void PDelay::initialize(PVirtualPort* in, PVirtualPort* out, PDimmer* duration, PDimmer* decay)
{
    TextWidget* title = new TextWidget(tr("Delay"), this);
    title->setFont(QFont("Courier", 18, QFont::Bold));

    duration->setSize(80, 80);
    decay->setSize(80, 80);

    // Layout
    bottomArea()->addCornerAnchors(duration, Qt::TopLeftCorner, bottomArea(), Qt::TopLeftCorner);
    bottomArea()->addCornerAnchors(decay, Qt::TopRightCorner, bottomArea(), Qt::TopRightCorner);
    bottomArea()->addCornerAnchors(duration, Qt::BottomLeftCorner, bottomArea(), Qt::BottomLeftCorner);
    bottomArea()->addCornerAnchors(decay, Qt::BottomRightCorner, bottomArea(), Qt::BottomRightCorner);
    bottomArea()->addAnchor(duration, Qt::AnchorRight, decay, Qt::AnchorLeft);

    leftArea()->addAnchors(in, leftArea());
    rightArea()->addAnchors(out, rightArea());
    centerArea()->addAnchors(title, centerArea());

    bottomArea()->activate();
    layout()->activate();
}
/*
    \req QTOPIA-78

    \groups
    Test case where an interface is implemented by a class which inherits a
    class which implements one other interface.
*/
void tst_QtUiTestWidgets::cast_inherit_single()
{
    QCOMPARE(WidgetObject::constructed, 0);
    QCOMPARE(WidgetObject::destructed, 0);
    QCOMPARE(TextWidgetObject::constructed, 0);
    QCOMPARE(TextWidgetObject::destructed, 0);

    QtUiTestWidgets::instance()->refreshPlugins();

    Widget *w;
    TextWidget *tw;

    {
        QWidget widget;
        QLabel label;

        w  = qtuitest_cast<Widget*>(&widget);
        tw = qtuitest_cast<TextWidget*>(&label);

        QVERIFY(w);
        QVERIFY(tw);
        QCOMPARE(TextWidgetObject::constructed, 1);
        QCOMPARE(TextWidgetObject::destructed, 0);

        /* One or more widget objects may have been constructed while finding
         * the interfaces for QLabel. However there should be exactly 2
         * still existing. */
        QCOMPARE(WidgetObject::constructed - WidgetObject::destructed, 2);

        QCOMPARE(tw->text(), QString());
        label.setText("Hi there");
        QCOMPARE(tw->text(), QString("Hi there"));
    }

    QCOMPARE(TextWidgetObject::constructed, 1);
    QCOMPARE(TextWidgetObject::destructed, 1);
    QCOMPARE(WidgetObject::constructed - WidgetObject::destructed, 0);
}
	void init() {
		
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_confirm");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText);
			me->SetCheckOff();
			addCenter(me, true);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_main_newquest_confirm");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText);
			me->SetCheckOff();
			addCenter(me, true);
		}
		
		HorizontalPanelWidget * pPanel = new HorizontalPanelWidget;
		
		{
			std::string szMenuText = getLocalised("system_yes");
			szMenuText += "   "; // TODO This space can probably go
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText);
			me->clicked = boost::bind(ARXMenu_NewQuest);
			me->SetPos(Vec2i(RATIO_X(m_size.x - (me->m_rect.width() + 10)), 0));
			pPanel->AddElementNoCenterIn(me);
		}
		
		{
			std::string szMenuText = getLocalised("system_no");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(10), 0));
			me->m_targetMenu = MAIN;
			me->SetShortCut(Keyboard::Key_Escape);
			pPanel->AddElementNoCenterIn(me);
		}
		
		pPanel->Move(Vec2i(0, RATIO_Y(380)));
		
		add(pPanel);
	}
Widget* ExpandableProvider::getChildItemWidget(int32_t groupPosition, int32_t childPosition, bool isLastChild, Widget* convertWidget, Widget* parent) {
    TextWidget* pItem = dynamic_cast<TextWidget*> (convertWidget);
    pItem->setText(String::format("Child %d", childPosition));
    return convertWidget;
}
	void init() {
		
		{
			ButtonWidget * cb = new ButtonWidget(Vec2i(0, 0), "graph/interface/icons/menu_main_load");
			cb->SetCheckOff();
			addCenter(cb, true);
		}
		
		std::string quicksaveName = getLocalised("system_menus_main_quickloadsave", "Quicksave");
		
		// TODO make this list scrollable
		// TODO align the date part to the right!
		
		{
		size_t quicksaveNum = 0;
		
		// Show quicksaves.
		for(size_t i = 0; i < savegames.size(); i++) {
			const SaveGame & save = savegames[i];
			
			if(!save.quicksave) {
				continue;
			}
			
			std::ostringstream text;
			text << quicksaveName << ' ' << ++quicksaveNum << "   " << save.time;
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_LOAD, hFontControls, text.str(), Vec2i(RATIO_X(20), 0));
			e->m_savegame = SavegameHandle(i);
			addCenter(e);
		}
		
		// Show regular saves.
		for(size_t i = 0; i < savegames.size(); i++) {
			const SaveGame & save = savegames[i];
			
			if(save.quicksave) {
				continue;
			}
			
			std::string text = save.name +  "   " + save.time;
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_LOAD, hFontControls, text, Vec2i(RATIO_X(20), 0));
			e->m_savegame = SavegameHandle(i);
			addCenter(e);
		}
		
		{
			TextWidget * confirm = new TextWidget(BUTTON_INVALID, hFontControls, " ", Vec2i(RATIO_X(20), 0));
			confirm->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			confirm->SetCheckOff();
			confirm->m_savegame = SavegameHandle::Invalid;
			addCenter(confirm);
		}
		
		// Delete button
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_delete");
			szMenuText += "   ";
			TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_DELETE_CONFIRM, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = EDIT_QUEST_LOAD;
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(42)));
			me->SetCheckOff();
			me->lOldColor = me->lColor;
			me->lColor = Color::grayb(127);
			add(me);
			pDeleteConfirm = me;
		}
		
		// Load button
		{
			std::string szMenuText = getLocalised("system_menus_main_editquest_load");
			szMenuText += "   ";
			TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_LOAD_CONFIRM, hFontMenu, szMenuText, Vec2i(0, 0));
			me->m_targetMenu = MAIN;
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(380) + RATIO_Y(40)));
			me->SetCheckOff();
			me->lOldColor = me->lColor;
			me->lColor = Color::grayb(127);
			add(me);
			pLoadConfirm = me;
		}
		
		// Back button
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 420)), "graph/interface/menus/back");
			cb->clicked = boost::bind(&LoadMenuPage::onClickBack, this);
			cb->m_targetMenu = EDIT_QUEST;
			cb->SetShortCut(Keyboard::Key_Escape);
			add(cb);
		}
		}
	}
	void init() {
		
		{
			ButtonWidget * cb = new ButtonWidget(Vec2i(RATIO_X(10), 0), "graph/interface/icons/menu_main_save");
			cb->SetCheckOff();
			addCenter(cb, true);
		}
		
		std::string quicksaveName = getLocalised("system_menus_main_quickloadsave", "Quicksave");
		size_t quicksaveNum = 0;
		
		// Show quicksaves.
		for(size_t i = 0; i < savegames.size(); i++) {
			const SaveGame & save = savegames[i];
			
			if(!save.quicksave) {
				continue;
			}
			
			std::ostringstream text;
			text << quicksaveName << ' ' << ++quicksaveNum << "   " << save.time;
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text.str(), Vec2i(RATIO_X(20), 0.f));
			e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			e->setColor(Color::grayb(127));
			e->SetCheckOff();
			e->m_savegame = SavegameHandle(i);
			addCenter(e);
		}
		
		// Show regular saves.
		for(size_t i = 0; i < savegames.size(); i++) {
			const SaveGame & save = savegames[i];
			
			if(save.quicksave) {
				continue;
			}
			
			std::string text = save.name +  "   " + save.time;
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text, Vec2i(RATIO_X(20), 0.f));
			e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			e->m_savegame = SavegameHandle(i);
			addCenter(e);
		}
		
		for(size_t i = savegames.size(); i <= 15; i++) {
			
			std::ostringstream text;
			text << '-' << std::setfill('0') << std::setw(4) << i << '-';
			
			TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text.str(), Vec2i(RATIO_X(20), 0));
			e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			e->m_savegame = SavegameHandle::Invalid;
			addCenter(e);
		}
	
		{
			TextWidget * me01 = new TextWidget(BUTTON_INVALID, hFontControls, " ", Vec2i(RATIO_X(20), 0));
			me01->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM;
			me01->m_savegame = SavegameHandle::Invalid;
			me01->SetCheckOff();
			addCenter(me01);
		}
		
		{
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 420)), "graph/interface/menus/back");
			cb->m_targetMenu = EDIT_QUEST;
			cb->SetShortCut(Keyboard::Key_Escape);
			add(cb);
		}
	}
	void init() {
		
		// Renderer selection
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_options_video_renderer", "Renderer");
			szMenuText += "  ";
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			me->SetCheckOff();
			pc->AddElement(me);
			CycleTextWidget * slider = new CycleTextWidget;
			slider->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedRenderer, this, _1, _2);
			
			{
				TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, "Auto-Select", Vec2i(0, 0));
				slider->AddText(text);
				slider->selectLast();
			}
			
	#if ARX_HAVE_SDL1 || ARX_HAVE_SDL2
			{
				TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, "OpenGL", Vec2i(0, 0));
				slider->AddText(text);
				if(config.window.framework == "SDL") {
					slider->selectLast();
				}
			}
	#endif
			
			float fRatio    = (RATIO_X(m_size.x-9) - slider->m_rect.width());
			slider->Move(Vec2i(checked_range_cast<int>(fRatio), 0));
			pc->AddElement(slider);
			addCenter(pc);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_videos_full_screen");
			if(szMenuText.empty()) {
				// TODO once we ship our own amendmends to the loc files a cleaner
				// fix would be to just define system_menus_options_videos_full_screen
				// for the german version there
				szMenuText = getLocalised("system_menus_options_video_full_screen");
			}
			szMenuText += "  ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0.f));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedFullscreen, this, _1);
			cb->iState = config.video.fullscreen ? 1 : 0;
			addCenter(cb);
			fullscreenCheckbox = cb;
		}
		
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_options_video_resolution");
			szMenuText += "  ";
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0.f));
			me->SetCheckOff();
			pc->AddElement(me);
			pMenuSliderResol = new CycleTextWidget;
			pMenuSliderResol->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedResolution, this, _1, _2);
			
			pMenuSliderResol->setEnabled(config.video.fullscreen);
			
			const RenderWindow::DisplayModes & modes = mainApp->getWindow()->getDisplayModes();
			for(size_t i = 0; i != modes.size(); ++i) {
				
				const DisplayMode & mode = modes[i];
				
				// find the aspect ratio
				unsigned a = mode.resolution.x;
				unsigned b = mode.resolution.y;
				while(b != 0) {
					unsigned t = a % b;
					a = b, b = t;
				}
				Vec2i aspect = mode.resolution / Vec2i(a);
				
				std::stringstream ss;
				ss << mode;
				
				if(aspect.x < 100 && aspect.y < 100) {
					if(aspect == Vec2i(8, 5)) {
						aspect = Vec2i(16, 10);
					}
					ss << " (" << aspect.x << ':' << aspect.y << ')';
				}
				
				pMenuSliderResol->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, ss.str()));
				
				if(mode.resolution == config.video.resolution) {
					pMenuSliderResol->selectLast();
				}
			}
			
			pMenuSliderResol->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, AUTO_RESOLUTION_STRING));
			
			if(config.video.resolution == Vec2i_ZERO) {
				pMenuSliderResol->selectLast();
			}
		
			float fRatio    = (RATIO_X(m_size.x-9) - pMenuSliderResol->m_rect.width()); 
		
			pMenuSliderResol->Move(Vec2i(checked_range_cast<int>(fRatio), 0));
			
			pc->AddElement(pMenuSliderResol);
			addCenter(pc);
		}
		
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_options_detail");
			szMenuText += " ";
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			me->SetCheckOff();
			pc->AddElement(me);
			
			CycleTextWidget * cb = new CycleTextWidget;
			cb->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedQuality, this, _1, _2);
			szMenuText = getLocalised("system_menus_options_video_texture_low");
			cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText));
			szMenuText = getLocalised("system_menus_options_video_texture_med");
			cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText));
			szMenuText = getLocalised("system_menus_options_video_texture_high");
			cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText));
			cb->setValue(config.video.levelOfDetail);
			
			cb->Move(Vec2i(RATIO_X(m_size.x-9) - cb->m_rect.width(), 0));
			pc->AddElement(cb);
			
			addCenter(pc);
		}
		
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_options_video_brouillard");
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0.f));
			me->SetCheckOff();
			pc->AddElement(me);
			SliderWidget * sld = new SliderWidget(Vec2i(RATIO_X(200), 0));
			sld->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedFogDistance, this, _1);
			sld->setValue(config.video.fogDistance);
			pc->AddElement(sld);
			addCenter(pc);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video_crosshair", "Show Crosshair");
			szMenuText += " ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0.f));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedCrosshair, this, _1);
			cb->iState = config.video.showCrosshair ? 1 : 0;
			addCenter(cb);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video_antialiasing", "antialiasing");
			szMenuText += " ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedAntialiasing, this, _1);
			cb->iState = config.video.antialiasing ? 1 : 0;
			addCenter(cb);
		}
		
		ARX_SetAntiAliasing();
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video_vsync", "VSync");
			szMenuText += " ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedVsync, this, _1);
			cb->iState = config.video.vsync ? 1 : 0;
			addCenter(cb);
		}
		
		{
			std::string szMenuText = getLocalised("system_menus_options_video_hud_scale", "Scale Hud");
			szMenuText += " ";
			TextWidget * text = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(20), 0));
			text->SetCheckOff();
			CheckboxWidget * cb = new CheckboxWidget(text);
			cb->stateChanged = boost::bind(&VideoOptionsMenuPage::onChangedHudScale, this, _1);
			cb->iState = config.video.hudScale ? 1 : 0;
			addCenter(cb);
		}
		
		{
			HorizontalPanelWidget * pc = new HorizontalPanelWidget;
			std::string szMenuText = getLocalised("system_menus_video_apply");
			szMenuText += "   ";
			TextWidget * me = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2i(RATIO_X(240), 0));
			me->clicked = boost::bind(&VideoOptionsMenuPage::onClickedApply, this);
			me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(380) + RATIO_Y(40)));
			me->SetCheckOff();
			pc->AddElementNoCenterIn(me);
			pMenuElementApply = me;
			
			ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 420)), "graph/interface/menus/back");
			cb->clicked = boost::bind(&VideoOptionsMenuPage::onClickedBack, this);
			cb->m_targetMenu = OPTIONS;
			cb->SetShortCut(Keyboard::Key_Escape);
			pc->AddElementNoCenterIn(cb);
			
			add(pc);
		}
	}
Exemple #19
0
void BarkGump::InitGump(Gump* newparent, bool take_focus)
{
	// OK, this is a bit of a hack, but it's how it has to be
	int	fontnum;
	if (owner == 1) fontnum = 6;
	else if (owner > 256) fontnum = 8;
	else switch (owner%3) {
		case 1:
			fontnum = 5;
			break;
			
		case 2:
			fontnum = 7;
			break;

		default:
			fontnum = 0;
			break;
	}

	// This is a hack. We init the gump twice...
	ItemRelativeGump::InitGump(newparent, take_focus);

	// Create the TextWidget
	TextWidget *widget = new TextWidget(0,0,barked,true,fontnum,194,55);
	widget->InitGump(this);

	textwidget = widget->getObjId();

	// see if we need to play speech
	AudioProcess *ap = AudioProcess::get_instance();
	speechlength = 0;
	if (speechshapenum && ap) {
		if (ap->playSpeech(barked, speechshapenum, owner)) {
			speechlength = ap->getSpeechLength(barked, speechshapenum) / 33;
			if (speechlength == 0) speechlength = 1;

			// We're playing speech, so need to sync the text with the speech.
			// First we count the total height of all text blocks.
			Pentagram::Rect d;
			widget->GetDims(d);
			totaltextheight = d.h;
			while (widget->setupNextText()) {
				widget->GetDims(d);
				totaltextheight += d.h;
			}
			widget->rewind();
		}
	}

	// This is just a hack
	Pentagram::Rect d;
	widget->GetDims(d);
	if (speechlength && totaltextheight) {
		counter = (d.h * speechlength) / totaltextheight;
	} else {
		counter = d.h * textdelay;
	}
	dims.h = d.h;
	dims.w = d.w;

	// Wait with ItemRelativeGump initialization until we calculated our size.
	ItemRelativeGump::InitGump(newparent, take_focus);
}
Resource* CreateTextWidget( XMLIterator i, XMLCreatorEnv *env )
{
    XMLCreatorEnv ch_env;
    XMLAttributes attributes;
    XMLStyle      branch_style;
    CascadeStyles( i, env, attributes, branch_style, ch_env );

    std::string font = get_attribute( attributes, "font" );

    int bodyAsLink = 0;
    try_attribute_i( attributes, "body_as_link", &bodyAsLink );
    Text text;
    if ( bodyAsLink )
        text = QueryText( make_string( (*i)._value ));
    else
        text = MakeText(to_chars( (*i)._value ));


    Widget *ptr;
    XMLIterator ch_i = i;
    int line_spacing = 0;
    std::string alignment;

    bool adv_text = try_attribute_i( attributes, "spacing", &line_spacing );
    adv_text |= try_attribute( attributes, "align", &alignment );

    // create DualText
    if ( !!ch_i.StepInto() )
    {
        int shift = 2;
        try_attribute_i( attributes, "shift", &shift );

        std::wstring left, right;
        for ( ; !!ch_i; ++ch_i )
        {
            if ( (*ch_i)._name == "left" )
                left = to_chars( (*ch_i)._value );
            else
                if ( (*ch_i)._name == "right" )
                    right = to_chars( (*ch_i)._value );
        }
        
        int bodyAsLink = 0;
        try_attribute_i( attributes, "body_as_link", &bodyAsLink );
        Text leftT, rightT;
        if ( bodyAsLink )
        {
            leftT  = QueryText( make_string( left ));
            rightT = QueryText( make_string( right ));
        }
        else
        {
            leftT  = MakeText(left);
            rightT = MakeText(right);
        }

        DualTextWidget *p_dual;
        ptr = p_dual = new DualTextWidget( 100, QueryFont(font), leftT, rightT, shift );

        std::string dotcode;
        if ( try_attribute( attributes, "dot", &dotcode ) )
            p_dual->SetDotCode( ( dotcode.size()>0 ? dotcode[0] : ' ' ) );    
    }
    else
    if ( adv_text )
    {
        int align = 0;
        if ( alignment == "left"   ) { align = 0; } else
        if ( alignment == "right"  ) { align = 1; } else
        if ( alignment == "center" ) { align = 2; }

        if ( (*i)._name == "activetext" )
        {
            ptr = new ActiveText( QueryFont(font), text, line_spacing, align );
        }
        else
        {
            ptr = new AdvTextWidget( QueryFont(font), text, line_spacing, align );
        }
    }   
    else
    {
         TextWidget *ptrTW = new TextWidget( QueryFont(font), text );
         ptr = ptrTW;
         ptrTW->SetText( text );
    }

    InsertChildWidget( ptr, attributes, env);
    return new AnyResource<Widget*>( ptr );
}
Exemple #21
0
int main( int argc, char **argv )
{
  int i;
  QString m1,n1,o1;
  struct args pargs;
  QApplication *a;
  InitWidget *b;
  ScreenWidget *c; 
  TextWidget *textOut;
  QProgressDialog *qProg;
  QPixmap *qpxMeshIcon=NULL;
  struct model_error model1,model2;
  int rcode;
  struct outbuf *log;
  struct prog_reporter pr;

  /* Initialize application */
  a = NULL;
  b = NULL;
  c = NULL;
  qProg = NULL;
  memset(&model1,0,sizeof(model1));
  memset(&model2,0,sizeof(model2));
  memset(&pr,0,sizeof(pr));
  log = NULL;
  i = 0;
  while (i<argc) {
    if (strcmp(argv[i],"-t") == 0) /* text version requested */
      break; 
    if (strcmp(argv[i],"-h") == 0) /* just asked for command line help */
      break; 
    i++;
  }
  if (i == argc) { /* no text version requested, initialize QT */
    a = new QApplication( argc, argv );
    /* Load pixmap for icon */
    qpxMeshIcon = new QPixmap((const char**)meshIcon);
    if (a != NULL) a->connect( a, SIGNAL(lastWindowClosed()), 
			       a, SLOT(quit()) );
  } else {
    a = NULL; /* No QT app needed */
  }

  /* Parse arguments */
  parse_args(argc,argv,&pargs);

  /* Display starting dialog if insufficient arguments */
  if (pargs.m1_fname != NULL || pargs.m2_fname != NULL) {
    if (pargs.m1_fname == NULL || pargs.m2_fname == NULL) {
      fprintf(stderr,"ERROR: missing file name(s) in command line\n");
      exit(1);
    }
    if (!pargs.do_wlog) {
      log = outbuf_new(stdio_puts,stdout);
    }
    else {
      textOut = new TextWidget();
      textOut->setIcon(*qpxMeshIcon);
      log = outbuf_new(TextWidget_puts,textOut);
      textOut->show();
    }
    if (pargs.no_gui) {
      pr.prog = stdio_prog;
      pr.cb_out = stdout;
    } else {
      qProg = new QProgressDialog("Calculating distance",0,100);
      qProg->setIcon(*qpxMeshIcon);
      qProg->setMinimumDuration(1500);
      pr.prog = QT_prog;
      pr.cb_out = qProg;
    }

    mesh_run(&pargs, &model1, &model2, log, &pr);
  } else {
    b = new InitWidget(pargs, &model1, &model2);
    b->setIcon(*qpxMeshIcon);
    b->show(); 
  }
  if (a != NULL) {
    if (pargs.m1_fname != NULL || pargs.m2_fname != NULL) {
      c = new ScreenWidget(&model1, &model2, &pargs);
      c->setIcon(*qpxMeshIcon);
      a->setMainWidget(c);
      c->show(); 
    }
    rcode = a->exec();
  } else {
    rcode = 0;
  }
  /* Free widgets */
  outbuf_delete(log);
  delete qProg;
  delete qpxMeshIcon;
  delete b;
  delete c;
  delete a; // QApplication must be last QT thing to delete
  /* Free model data */
  if (model1.mesh != NULL) __free_raw_model(model1.mesh);
  free(model1.verror);
  free(model1.info);
  free_face_error(model1.fe);
  if (model2.mesh != NULL) __free_raw_model(model2.mesh);
  free(model2.verror);
  free(model2.info);
  /* Return exit code */
  return rcode;
}
/*
    \req QTOPIA-78

    \groups
    Test casting of a widget class which implements its own interfaces.
*/
void tst_QtUiTestWidgets::cast_self()
{
    QtUiTestWidgets::instance()->clear();

    QCOMPARE( TestableCheckBox::constructed, 0 );
    QCOMPARE( TestableCheckBox::destructed, 0 );

    Widget *w;
    TextWidget *tw;
    CheckWidget *cw;

    {
        TestableCheckBox tcb;
        QCheckBox *cb = &tcb;

        QCOMPARE( TestableCheckBox::constructed, 1 );
        QCOMPARE( TestableCheckBox::destructed, 0 );

        /* Doesn't need to be registered before cast. */
        QVERIFY( w  = qtuitest_cast<Widget*>(&tcb) );
        QVERIFY( tw = qtuitest_cast<TextWidget*>(&tcb) );
        QVERIFY( cw = qtuitest_cast<CheckWidget*>(&tcb) );

        QCOMPARE( w, &tcb );
        QCOMPARE( tw, &tcb );
        QCOMPARE( cw, &tcb );

        /* However, should still work when other classes are registered...*/
        QtUiTestWidgets::instance()->refreshPlugins();
        QCOMPARE( qtuitest_cast<Widget*>(&tcb), w );
        QCOMPARE( qtuitest_cast<TextWidget*>(&tcb), tw );
        QCOMPARE( qtuitest_cast<CheckWidget*>(&tcb), cw );
        QCOMPARE( WidgetObject::constructed, 0 );
        QCOMPARE( WidgetObject::destructed, 0 );

        QCOMPARE( TestableCheckBox::constructed, 1 );
        QCOMPARE( TestableCheckBox::destructed, 0 );

        /* Use it a bit and make sure it works as expected. */
        QCOMPARE( w->geometry(), tcb.geometry() );

        tcb.setText("Walk the Dog");
        QCOMPARE( tw->text(), tcb.text() );

        tcb.setTristate(true);
        cb->setCheckState(Qt::PartiallyChecked);
        QCOMPARE( cw->isTristate(), tcb.isTristate() );
        QCOMPARE( cw->checkState(), tcb.checkState() );
    }

    /* Ensure we didn't double-delete */
    QCOMPARE( TestableCheckBox::constructed, 1 );
    QCOMPARE( TestableCheckBox::destructed, 1 );

    /* Ensure we can make another one with no problems */
    {
        TestableCheckBox tcb;

        QCOMPARE( TestableCheckBox::constructed, 2 );
        QCOMPARE( TestableCheckBox::destructed, 1 );

        QVERIFY( w  = qtuitest_cast<Widget*>(&tcb) );
        QVERIFY( tw = qtuitest_cast<TextWidget*>(&tcb) );
        QVERIFY( cw = qtuitest_cast<CheckWidget*>(&tcb) );

        QCOMPARE( w, &tcb );
        QCOMPARE( tw, &tcb );
        QCOMPARE( cw, &tcb );
    }
    QCOMPARE( TestableCheckBox::constructed, 2 );
    QCOMPARE( TestableCheckBox::destructed, 2 );

    /* Ensure casting a null pointer has no ill effects */
    w = qtuitest_cast<Widget*>( static_cast<TestableCheckBox*>(0) );
    QVERIFY( !w );

    QCOMPARE( TestableCheckBox::constructed, 2 );
    QCOMPARE( TestableCheckBox::destructed, 2 );

    QCOMPARE( WidgetObject::constructed, 0 );
    QCOMPARE( WidgetObject::destructed, 0 );
}
Exemple #23
0
// true: block les zones de checks
bool TextWidget::OnMouseClick() {
	
	if(!enabled) {
		return false;
	}
	
	if(clicked) {
		clicked(this);
	}
	
	switch(eState) {
		case EDIT:
			eState=EDIT_TIME;
			return true;
		case GETTOUCH:
			eState=GETTOUCH_TIME;
			lOldColor=lColorHighlight;
			return true;
		default: break;
	}
	
	switch(m_id) {
		// MENULOADQUEST
		case BUTTON_MENUEDITQUEST_LOAD: {
			if(pWindowMenu) {
				pLoadConfirm->SetCheckOn();
				pLoadConfirm->lColor = pLoadConfirm->lOldColor;
				pDeleteConfirm->SetCheckOn();
				pDeleteConfirm->lColor = pDeleteConfirm->lOldColor;
				
				for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) {
					MenuPage * page = pWindowMenu->m_pages[i];
					
					if(page->eMenuState == EDIT_QUEST_LOAD) {
						page->m_savegame = m_savegame;
						
						for(size_t j = 0; j < page->m_children.m_widgets.size(); j++) {
							Widget * widget = page->m_children.m_widgets[j];
							
							if(widget->m_id == BUTTON_MENUEDITQUEST_LOAD) {
								((TextWidget *)widget)->bSelected = false;
							}
						}
						bSelected = true;
					}
				}
			}
		}
		break;
		case BUTTON_MENUEDITQUEST_LOAD_CONFIRM: {
			if(pWindowMenu) {
				for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) {
					MenuPage * page = pWindowMenu->m_pages[i];
		
					if(page->eMenuState == EDIT_QUEST_LOAD) {
						
						m_savegame = page->m_savegame;
						if(m_savegame != SavegameHandle()) {
							m_targetMenu = MAIN;
							GRenderer->Clear(Renderer::DepthBuffer);
							ARXMenu_LoadQuest(m_savegame);
							bNoMenu=true;
							if(pTextManage) {
								pTextManage->Clear();
							}
							break;
						}
					}
				}
				
				pLoadConfirm->SetCheckOff();
				pLoadConfirm->lColor = Color::grayb(127);
				pDeleteConfirm->SetCheckOff();
				pDeleteConfirm->lColor = Color::grayb(127);
			}
		}
		break;
		// MENUSAVEQUEST
		case BUTTON_MENUEDITQUEST_SAVE: {
			if(pWindowMenu)
			for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) {
				MenuPage * page = pWindowMenu->m_pages[i];
				
				if(page->eMenuState == EDIT_QUEST_SAVE_CONFIRM) {
					page->m_savegame = m_savegame;
					TextWidget * me = (TextWidget *) page->m_children.m_widgets[1];
					
					if(me) {
						m_targetMenu = MAIN;
						ARXMenu_SaveQuest(me->m_text, me->m_savegame);
						break;
					}
				}
			}
		}
		break;
		
		// Delete save from the load menu
		case BUTTON_MENUEDITQUEST_DELETE_CONFIRM: {
			if(pWindowMenu) {
				for(size_t i = 0 ; i < pWindowMenu->m_pages.size(); i++) {
					MenuPage * page = pWindowMenu->m_pages[i];
					if(page->eMenuState == EDIT_QUEST_LOAD) {
						m_savegame = page->m_savegame;
						if(m_savegame != SavegameHandle()) {
							m_targetMenu = EDIT_QUEST_LOAD;
							mainMenu->bReInitAll = true;
							savegames.remove(m_savegame);
							break;
						}
					}
				}
			}
			pLoadConfirm->SetCheckOff();
			pLoadConfirm->lColor = Color::grayb(127);
			pDeleteConfirm->SetCheckOff();
			pDeleteConfirm->lColor = Color::grayb(127);
			break;
		}
			
		// Delete save from the save menu
		case BUTTON_MENUEDITQUEST_DELETE: {
			if(pWindowMenu) {
				for(size_t i = 0 ; i < pWindowMenu->m_pages.size(); i++) {
					MenuPage * page = pWindowMenu->m_pages[i];
					if(page->eMenuState == EDIT_QUEST_SAVE_CONFIRM) {
						page->m_savegame = m_savegame;
						TextWidget * me = (TextWidget *) page->m_children.m_widgets[1];
						if(me) {
							m_targetMenu = EDIT_QUEST_SAVE;
							mainMenu->bReInitAll = true;
							savegames.remove(me->m_savegame);
							break;
						}
					}
				}
			}
			break;
		}
		default:
			break;
	}

	if(m_targetMenu == EDIT_QUEST_SAVE_CONFIRM) {
		for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) {
			MenuPage * page = pWindowMenu->m_pages[i];

			if(page->eMenuState == m_targetMenu) {
				page->m_savegame = m_savegame;
				TextWidget * me = (TextWidget *) page->m_children.m_widgets[1];

				if(me) {
					me->m_savegame = m_savegame;
					
					if(m_savegame != SavegameHandle()) {
						me->SetText(savegames[m_savegame.handleData()].name);
						pDeleteButton->lColor = pDeleteButton->lOldColor;
						pDeleteButton->SetCheckOn();
					} else {
						pDeleteButton->lColor = Color::grayb(127);
						pDeleteButton->SetCheckOff();
						me->SetText(getLocalised("system_menu_editquest_newsavegame"));
					}
					
					page->AlignElementCenter(me);
				}
			}
		}
	}
	
	ARX_SOUND_PlayMenu(SND_MENU_CLICK);
	
	return false;
}