示例#1
0
  TranslationSpinRow(View *view, Gtk::TreeView *rfo_tree,
	  const char *box_name) :
    m_inhibit_update(false), m_view(view)
  {
    view->m_builder->get_widget (box_name, m_box);

    for (uint i = 0; i < 3; i++) {
        m_box->add (*new Gtk::Label (axis_names[i]));
        m_xyz[i] = new Gtk::SpinButton();
        m_xyz[i]->set_numeric();
        m_xyz[i]->set_digits (1);
        m_xyz[i]->set_increments (0.5, 10);
        m_xyz[i]->set_range(-500.0, +500.0);
        m_box->add (*m_xyz[i]);
        m_xyz[i]->signal_value_changed().connect
            (sigc::bind(sigc::mem_fun(*this, &TranslationSpinRow::spin_value_changed), (int)i));

        /* Add statusbar message */
        stringstream oss;
        oss << "Move object in " << axis_names[i] << "-direction (mm)";
        m_view->add_statusbar_msg(m_xyz[i], oss.str().c_str());
    }
    selection_changed();
    m_box->show_all();

    rfo_tree->get_selection()->signal_changed().connect
      (sigc::mem_fun(*this, &TranslationSpinRow::selection_changed));
  }
void dialog::operate4(Image imag,std::string filename)
{
    set_default_size(300, 50);
    set_border_width(10);
    set_position(Gtk::WIN_POS_CENTER);
    set_resizable(false);

    Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));
    add(*vbox);

    Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
    vbox->add(*grid);

    Gtk::Label *label = Gtk::manage(new Gtk::Label("File Name :"));
    grid->attach(*label,0,0,1,1);
    Gtk::Entry *bvalue = Gtk::manage(new Gtk::Entry());
    grid->attach(*bvalue, 1, 0, 1, 1);
    Gtk::Label *label2 = Gtk::manage(new Gtk::Label(".bmp"));
    grid->attach(*label2,2,0,1,1);

    set_title("Save As");
    bvalue->set_text("Untitled");
    bvalue->set_max_length(50);

    Gtk::Button *bok = Gtk::manage(new Gtk::Button("OK"));
    bok->signal_clicked().connect(sigc::bind<Gtk::Entry*>(sigc::mem_fun(*this, &dialog::on_bok4_click), bvalue,imag,filename));
    grid->attach(*bok, 2, 2, 1, 1);
    show_all_children();
}
示例#3
0
    Gtk::Widget *SmartChessWindow::createNotificationBar() {
        Gtk::Box* statusbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
        statusbox->set_vexpand(false);
        statusbox->set_hexpand();

        mStatusBar = Gtk::manage(new Gtk::Statusbar());
        mStatusBar->set_vexpand(false);
        mStatusBar->set_hexpand();
        statusbox->add(*mStatusBar);

        Gtk::ProgressBar* progressbar = Gtk::manage(new Gtk::ProgressBar());
        progressbar->set_hexpand(false);
        progressbar->set_vexpand(false);
        statusbox->add(*progressbar);

        return statusbox;
    }
示例#4
0
int main(int argc, char *argv[])
{

    // make window
    Glib::RefPtr<Gtk::Application> app =
        Gtk::Application::create(argc, argv,
                                 "tutorial2");

    Gtk::Window window;

    window.set_default_size(400,200);
    window.set_title("Tutorial 2");

    // This creates a vertical box container with 0 padding
    Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));
    window.add(*vbox);

    // creates menu bar
    Gtk::MenuBar *menubar = Gtk::manage(new Gtk::MenuBar());
    vbox->pack_start(*menubar, Gtk::PACK_SHRINK, 0);

    // create menu items
    Gtk::MenuItem *menuitem_file = Gtk::manage(new Gtk::MenuItem("_File", true));
    menubar->append(*menuitem_file);
    Gtk::Menu *filemenu = Gtk::manage(new Gtk::Menu());
    menuitem_file->set_submenu(*filemenu);
    Gtk::MenuItem *menuitem_quit = Gtk::manage(new Gtk::MenuItem("_Quit", true));
    filemenu->append(*menuitem_quit);

    // create grid container with border width 10
    // and add it to the new cell of the vertical box
    Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
    grid->set_border_width(10);
    vbox->add(*grid);

    // create button
    Gtk::Button *b1 = Gtk::manage(new Gtk::Button("Button 1"));
    b1->set_hexpand(true);		//  take up all unused space horizontally
    b1->set_vexpand(true);		//  take up all unused space vertically
    // possition 0(x), 0(y), span 1 cell wide and 2 cells down
    grid->attach(*b1, 0, 0, 1, 2);

    Gtk::Button *b2 = Gtk::manage(new Gtk::Button("Button 2"));
    grid->attach(*b2, 1, 0, 1, 1);

    Gtk::Button *b3 = Gtk::manage(new Gtk::Button("Button 3"));
    grid->attach(*b3, 1, 1, 1, 1);

    vbox->show_all();

    return app->run(window);
}
示例#5
0
myWindow::myWindow()
{
	set_default_size(400, 200);
	set_title("Tutorial 3");

	Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));
	add(*vbox);

	Gtk::MenuBar *menubar = Gtk::manage(new Gtk::MenuBar());
	vbox->pack_start(*menubar, Gtk::PACK_SHRINK, 0);

	Gtk::MenuItem *menuitem_file = Gtk::manage(new Gtk::MenuItem("_File", true));
	menubar->append(*menuitem_file);
	Gtk::Menu *filemenu = Gtk::manage(new Gtk::Menu());
	menuitem_file->set_submenu(*filemenu);
	Gtk::MenuItem *menuitem_quit = Gtk::manage(new Gtk::MenuItem("_Quit", true));
	menuitem_quit->signal_activate().connect(sigc::mem_fun(*this, &myWindow::on_quit_click));
	filemenu->append(*menuitem_quit);

	Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
	grid->set_border_width(10);
	vbox->add(*grid);

	Gtk::Button *b1 = Gtk::manage(new Gtk::Button("Big Button 1"));
    b1->set_hexpand(true);
    b1->set_vexpand(true);
    b1->signal_clicked().connect(sigc::mem_fun(*this, &myWindow::on_big_button1_click));
    grid->attach(*b1, 0, 0, 1, 2);

    Gtk::Button *b2 = Gtk::manage(new Gtk::Button("Button 2"));
    b2->signal_clicked().connect(sigc::mem_fun(*this, &myWindow::on_button2_click));
    grid->attach(*b2, 1, 0, 1, 1);

    Gtk::Button *b3 = Gtk::manage(new Gtk::Button("Button 3"));
    b3->signal_clicked().connect(sigc::mem_fun(*this, &myWindow::on_button3_click));
    grid->attach(*b3, 1, 1, 1, 1);

    vbox->show_all();
}
示例#6
0
View::View(BaseObjectType* cobject,
	   const Glib::RefPtr<Gtk::Builder>& builder)
  : Gtk::Window(cobject), m_builder(builder)
{
  // Menus
  connect_action ("OpenStl",         sigc::mem_fun(*this, &View::load_stl) );
  connect_action ("OpenGCode",       sigc::mem_fun(*this, &View::load_gcode) );
  connect_action ("Quit",            sigc::ptr_fun(&Gtk::Main::quit));
  connect_action ("About",           sigc::mem_fun(*this, &View::about_dialog) );

  connect_action ("PreferencesDialog", sigc::bind(sigc::mem_fun(*this, &View::show_dialog),
						  "preferences_dlg"));
  connect_action ("LoadSettings",    sigc::mem_fun(*this, &View::load_settings));
  connect_action ("SaveSettings",    sigc::mem_fun(*this, &View::save_settings));
  connect_action ("SaveSettingsAs",  sigc::mem_fun(*this, &View::save_settings_as));

#if 0
  // Simple tab
  connect_button ("s_load_stl",      sigc::mem_fun(*this, &View::load_stl) );
  connect_button ("s_convert_gcode", sigc::mem_fun(*this, &View::ConvertToGCode) );
  connect_button ("s_load_gcode",    sigc::mem_fun(*this, &View::load_gcode) );
  connect_button ("s_print",         sigc::mem_fun(*this, &View::SimplePrint) );
#endif

  // View tab
  connect_button ("m_load_stl",      sigc::mem_fun(*this, &View::load_stl) );
  connect_button ("m_save_stl",      sigc::mem_fun(*this, &View::save_stl) );
  connect_button ("m_delete",        sigc::mem_fun(*this, &View::delete_selected_stl) );
  connect_button ("m_duplicate",     sigc::mem_fun(*this, &View::duplicate_selected_stl) );
  connect_button ("m_auto_rotate",   sigc::mem_fun(*this, &View::auto_rotate) );
  connect_button ("m_rot_x",         sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(1,0,0, M_PI/2)));
  connect_button ("m_rot_y",         sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(0,1,0, M_PI/2)));
  connect_button ("m_rot_z",         sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(0,0,1, M_PI/2)));
  m_builder->get_widget ("m_rfo_tree", m_rfo_tree);

  m_translation_row = new TranslationSpinRow (this, m_rfo_tree, "m_box_translate");

  Gtk::HScale *scale_slider;
  m_builder->get_widget("m_scale_slider", scale_slider);
  scale_slider->set_range(0.01, 5.0);
  scale_slider->set_value(1.0);
  m_rfo_tree->get_selection()->signal_changed().connect
      (sigc::mem_fun(*this, &View::update_scale_slider));
  scale_slider->signal_value_changed().connect
      (sigc::mem_fun(*this, &View::scale_object));

  add_statusbar_msg("m_scale_event_box", "Scale the selected object");

  // GCode tab
  m_builder->get_widget ("g_gcode", m_gcode_entry);
  m_gcode_entry->set_activates_default();
  m_gcode_entry->signal_activate().connect (sigc::mem_fun(*this, &View::send_gcode));;

  connect_button ("g_load_gcode",    sigc::mem_fun(*this, &View::load_gcode) );
  connect_button ("g_convert_gcode", sigc::mem_fun(*this, &View::convert_to_gcode) );
  connect_button ("g_save_gcode",    sigc::mem_fun(*this, &View::save_gcode) );
  connect_button ("g_send_gcode",    sigc::mem_fun(*this, &View::send_gcode) );

  // Print tab
  connect_button ("p_kick",          sigc::mem_fun(*this, &View::kick_clicked) );
  m_builder->get_widget ("p_power", m_power_button);
  m_power_button->signal_toggled().connect    (sigc::mem_fun(*this, &View::power_toggled));
  m_builder->get_widget ("p_print", m_print_button);
  m_print_button->signal_clicked().connect    (sigc::mem_fun(*this, &View::print_clicked) );
  m_builder->get_widget ("p_pause", m_continue_button);
  m_continue_button->signal_clicked().connect (sigc::mem_fun(*this, &View::continue_clicked));

  // Interactive tab
  connect_button ("i_home_all",        sigc::mem_fun(*this, &View::home_all));
  connect_toggled ("Misc.FileLoggingEnabled", sigc::mem_fun(*this, &View::enable_logging_toggled));
  connect_button ("i_clear_logs",      sigc::mem_fun(*this, &View::clear_logs) );
  m_builder->get_widget ("i_reverse", m_extruder_reverse);
  m_builder->get_widget ("i_ex_speed", m_extruder_speed);
  m_extruder_speed->set_range(100.0, 10000.0);
  m_extruder_speed->set_increments (100, 500);
  m_extruder_speed->set_value (3000.0);
  m_builder->get_widget ("i_ex_length", m_extruder_length);
  m_extruder_length->set_range(0.0, 1000.0);
  m_extruder_length->set_increments (5, 20);
  m_extruder_length->set_value (150.0);
  // FIXME: connect i_update_interval (etc.)
  connect_toggled ("i_fan_enabled", sigc::mem_fun(*this, &View::fan_enabled_toggled));
  m_builder->get_widget ("i_fan_voltage", m_fan_voltage);
  m_fan_voltage->set_range(0.0, 25.0);
  m_fan_voltage->set_increments (1, 2);
  m_fan_voltage->set_value (5.0);

  connect_button ("i_extrude_length", sigc::mem_fun(*this, &View::run_extruder) );

  // 3D preview of the bed
  Gtk::Box *pBox = NULL;
  m_builder->get_widget("viewarea", pBox);
  if (!pBox)
    std::cerr << "missing box!";
  else {
    m_renderer = new Render (this, m_rfo_tree->get_selection());
    pBox->add (*m_renderer);
  }
  showAllWidgets();
}
示例#7
0
GenericAssistant::GenericAssistant
(
	std::string assistantTitle,
	std::vector<std::string> assistantLabels,
	std::vector<std::string> assistantPlaceholders,
	bool assistantModalMode
)
{
	set_title(assistantTitle);
	set_default_size (323, 200);
	set_modal(assistantModalMode);
	
	container = manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL,(2*assistantLabels.size())-1));
	
	for (unsigned int i=0;i<assistantLabels.size();i++) 
	{
		
		Gtk::Box * b = manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL,3));
		Gtk::Label * l = manage(new Gtk::Label(assistantLabels.at(i)));
		b->add(*l);
		Gtk::AspectFrame * af = manage(new Gtk::AspectFrame());
		b->add(*af);
		// entry and placeholder....
		Gtk::Entry * e = manage(new Gtk::Entry());
		e->set_placeholder_text(assistantPlaceholders.at(i).c_str());
		b->add(*e);
		// record the entry's content
		Entry.push_back(e);
		// show_children
		b->show_all_children();
		// add
		container->add(*b);
		if (assistantLabels.size()-1 != i) 
		{
			Gtk::AspectFrame * af = manage(new Gtk::AspectFrame());
			container->add(*af);	
		} 
	}
	container->show_all_children();
	// set assistant pages and config it
	append_page(*container);
	set_page_complete(*container, true);	
	set_page_type(*container, Gtk::ASSISTANT_PAGE_CONFIRM);
	show_all_children();
	// close or cancel the assistant
	signal_cancel().connect
	(
		sigc::mem_fun
		(
			*this,
			&GenericAssistant::on_assistant_cancel
		)
	);
	signal_close().connect
	(
		sigc::mem_fun
		(
			*this,
			&GenericAssistant::on_assistant_close
		)
	);

}
void dialog::operate3(Image* imag,Gtk::Image *m_image1,int imagestatus1,Gtk::Label* pixlabel)
{
    label =pixlabel;
    im=imag;
    imagestatus=imagestatus1;
    if(imagestatus)
    {
        m_image=m_image1;
    }
    set_default_size(300, 50);
    set_border_width(10);
    set_position(Gtk::WIN_POS_CENTER);
    set_resizable(false);

    Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));
    add(*vbox);

    Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
    vbox->add(*grid);

    set_title("Coordinates of bounding rectangle");
    Gtk::Label *label1 = Gtk::manage(new Gtk::Label("Enter coordinates of initial point  "));
    grid->attach(*label1,0,0,1,1);
    Gtk::Label *label2 = Gtk::manage(new Gtk::Label("Enter coordinates of final point  "));
    grid->attach(*label2,0,1,1,1);
    Gtk::Label *lx1 = Gtk::manage(new Gtk::Label("x:"));
    grid->attach(*lx1,1,0,1,1);
    Gtk::Label *lx2 = Gtk::manage(new Gtk::Label("x:"));
    grid->attach(*lx2,1,1,1,1);
    Gtk::Label *ly1 = Gtk::manage(new Gtk::Label("y:"));
    grid->attach(*ly1,3,0,1,1);
    Gtk::Label *ly2 = Gtk::manage(new Gtk::Label("y:"));
    grid->attach(*ly2,3,1,1,1);

    Gtk::Entry *bx1 = Gtk::manage(new Gtk::Entry());
    grid->attach(*bx1, 2, 0, 1, 1);
    bx1->set_max_length(5);
    bx1->set_text("0");
    Gtk::Entry *bx2 = Gtk::manage(new Gtk::Entry());
    grid->attach(*bx2, 2, 1, 1, 1);
    bx2->set_max_length(5);
    Gtk::Entry *by1 = Gtk::manage(new Gtk::Entry());
    grid->attach(*by1, 4, 0, 1, 1);
    by1->set_max_length(5);
    by1->set_text("0");
    Gtk::Entry *by2 = Gtk::manage(new Gtk::Entry());
    grid->attach(*by2, 4, 1, 1, 1);
    by2->set_max_length(5);

    char c[10];
    sprintf(c,"%d",im->width);
    Glib::ustring s(c);
    bx2->set_text(s);
    sprintf(c,"%d",im->height);
    s=c;
    by2->set_text(s);

    Gtk::Button *bok = Gtk::manage(new Gtk::Button("OK"));
    bok->signal_clicked().connect(sigc::bind<Gtk::Entry*, Gtk::Entry*,Gtk::Entry*,Gtk::Entry*>(sigc::mem_fun(*this, &dialog::on_bok3_click), bx1,bx2,by1,by2));
    grid->attach(*bok, 4, 2, 1, 1);

    show_all_children();
}
void dialog::operate(Image* imag,int i,Gtk::Image *m_image1,int imagestatus1,Gtk::Label* pixlabel)
{
    label=pixlabel;
    im=imag;
    imagestatus=imagestatus1;
    if(imagestatus)
    {
        m_image=m_image1;
    }
    set_default_size(500, 50);
    set_border_width(10);
    set_position(Gtk::WIN_POS_CENTER);
    set_resizable(false);

    Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));
    add(*vbox);

    Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
    vbox->add(*grid);

    Gtk::Label *label = Gtk::manage(new Gtk::Label());
    grid->attach(*label,0,0,2,1);
    Gtk::Entry *bvalue = Gtk::manage(new Gtk::Entry());
    grid->attach(*bvalue, 2, 0, 2, 1);

    Gtk::Button *rotatec = Gtk::manage(new Gtk::Button("Rotate Clockwise 90"));
    Gtk::Button *rotatea = Gtk::manage(new Gtk::Button("Rotate AntiClockwise 90"));
    rotatec->signal_clicked().connect(sigc::mem_fun(*this,&dialog::on_click_rotatec_button));
    rotatea->signal_clicked().connect(sigc::mem_fun(*this,&dialog::on_click_rotatea_button));

    switch(i)
    {
        case 1: set_title("Give Brightness Value between -255 and 255");
                label->set_text("Brightness Value Change By : ");
                bvalue->set_text("10");
                bvalue->set_max_length(4);
                break;
        case 2: set_title("Give index value for blur between 1 and 20");
                label->set_text("Index value of blur :                    ");
                bvalue->set_text("10");
                bvalue->set_max_length(2);
                break;
        case 3: set_title("Give Rotation Angle Value between -360 and 360");
                label->set_text("Rotate Image By (in degrees) :                                   ");
                bvalue->set_text("30");
                bvalue->set_max_length(9);
                grid->attach(*rotatec, 1 ,1, 1, 1);
                grid->attach(*rotatea, 0 ,1, 1, 1);
                break;
        case 4: set_title("Give number of colours between 4 and 16");
                label->set_text("No. of colours in poster :          ");
                bvalue->set_text("4");
                bvalue->set_max_length(2);
                break;
    }
    Gtk::Button *bok = Gtk::manage(new Gtk::Button("OK"));
    bok->signal_clicked().connect(sigc::bind<Gtk::Entry*>(sigc::mem_fun(*this, &dialog::on_bok_click), bvalue,i));
    grid->attach(*bok, 2, 2, 1, 1);

    show_all_children();
}