Пример #1
0
void c_SelectPointsDlg::InitControls(bool hasAutoBtn)
{
    m_ImgView.signal_ImageAreaBtnPress().connect(sigc::mem_fun(*this, &c_SelectPointsDlg::OnImageBtnPress));

    m_ImgView.signal_DrawImageArea().connect(sigc::slot<bool, const Cairo::RefPtr<Cairo::Context>&>(
        [this](const Cairo::RefPtr<Cairo::Context> &cr)
        {
            for (auto &pt: m_Points)
                Utils::DrawAnchorPoint(cr,
                                       m_ImgView.GetZoomPercentVal() * pt.x / 100,
                                       m_ImgView.GetZoomPercentVal() * pt.y / 100);

            return false;
        }
    ));
    m_ImgView.show();

    Gtk::Button *btnRemovePts = Gtk::manage(new Gtk::Button(_("Remove points")));
    btnRemovePts->signal_clicked().connect(sigc::mem_fun(*this, &c_SelectPointsDlg::OnRemoveClick));
    btnRemovePts->show();

    Gtk::Button *btnAuto = 0;
    if (hasAutoBtn)
    {
        btnAuto = Gtk::manage(new Gtk::Button(_("Automatic")));
        btnAuto->signal_clicked().connect(sigc::mem_fun(*this, &c_SelectPointsDlg::OnAutoClick));
        btnAuto->show();
    }

    Gtk::HButtonBox *btnBox = Gtk::manage(new Gtk::HButtonBox());
    btnBox->set_layout(Gtk::ButtonBoxStyle::BUTTONBOX_START);
    btnBox->pack_start(*btnRemovePts, Gtk::PackOptions::PACK_SHRINK);
    if (hasAutoBtn)
    {
        btnBox->pack_start(*btnAuto, Gtk::PackOptions::PACK_SHRINK);
    }
    btnBox->show();
    get_content_area()->pack_start(*btnBox, Gtk::PackOptions::PACK_SHRINK, Utils::Const::widgetPaddingInPixels);

    get_content_area()->pack_start(m_ImgView, Gtk::PackOptions::PACK_EXPAND_WIDGET, Utils::Const::widgetPaddingInPixels);

    m_InfoText.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER);
    m_InfoText.set_ellipsize(Pango::EllipsizeMode::ELLIPSIZE_END);
    m_InfoText.set_lines(2);
    get_content_area()->pack_start(m_InfoText, Gtk::PackOptions::PACK_SHRINK, Utils::Const::widgetPaddingInPixels);

    auto separator = Gtk::manage(new Gtk::Separator());
    separator->show();
    get_content_area()->pack_end(*separator, Gtk::PackOptions::PACK_SHRINK, Utils::Const::widgetPaddingInPixels);

    add_button(_("OK"), Gtk::RESPONSE_OK);
    add_button(_("Cancel"), Gtk::RESPONSE_CANCEL);
}
Пример #2
0
PanelMundo::PanelMundo() {
	pathFileMundos = RUTA_CARPETA_MUNDOS;
	pathFileMundos += "mundos.xml";
	set_size_request(ANCHO_WIZARD, ALTO_WIZARD);
	cargarNombreMundos();
	// Widgets con funcionalidad
	botonEditar = new Gtk::Button("Editar mundo seleccionado");
	botonCrear = new Gtk::Button("Crear mundo nuevo");
	selector = new SelectorMundos(nombreMundos);
	creador = new CreadorMundo(nombreMundos);
	// Contenedores
	Gtk::VBox* cajaVertical = manage(new Gtk::VBox(true, 30));
	Gtk::HBox* cajaHorizontalUno = manage(new Gtk::HBox(false, 20));
	Gtk::HBox* cajaHorizontalDos = manage(new Gtk::HBox(false, 20));
	Gtk::Frame* cuadroEditar = manage(new Gtk::Frame("Edite un mundo existente"));
	Gtk::Frame* cuadroCrear = manage(new Gtk::Frame("Cree un mundo nuevo"));
	cajaHorizontalUno->pack_start(*selector);
	Gtk::HButtonBox* cajaAuxiliarUno = manage(new Gtk::HButtonBox());
	cajaAuxiliarUno->set_layout(Gtk::BUTTONBOX_CENTER);
	cajaAuxiliarUno->pack_start(*botonEditar, Gtk::PACK_SHRINK);
	cajaHorizontalUno->pack_start(*cajaAuxiliarUno, Gtk::PACK_SHRINK);
	cajaHorizontalDos->pack_start(*creador);
	Gtk::HButtonBox* cajaAuxiliarDos = manage(new Gtk::HButtonBox());
	cajaAuxiliarDos->set_layout(Gtk::BUTTONBOX_CENTER);
	cajaAuxiliarDos->pack_start(*botonCrear, Gtk::PACK_SHRINK);
	cajaHorizontalDos->pack_start(*cajaAuxiliarDos, Gtk::PACK_SHRINK);
	cuadroEditar->add(*cajaHorizontalUno);
	cuadroCrear->add(*cajaHorizontalDos);
	cajaVertical->pack_start(*cuadroEditar);
	cajaVertical->pack_start(*cuadroCrear);
	add(*cajaVertical);
	// Seniales
	botonEditar->signal_clicked().connect(sigc::mem_fun(*this,
											&PanelMundo::botonEditarClickeado));
	botonCrear->signal_clicked().connect(sigc::mem_fun(*this,
											&PanelMundo::botonCrearClickeado));
}