UnEncodersDialog::UnEncodersDialog(const Glib::RefPtr<Gtk::Builder>& refGlade, MediaElement::ElementsDB& elementsDB) :
		elementsDB(elementsDB){
	refGlade->get_widget("unEncodersDialog", unEncodersDialog);
	refGlade->get_widget("unEncodersText", unEncodersText);
	refGlade->get_widget("unEncoderCheck", unEncodersCheck);
	refGlade->get_widget("showUnEncMenuItem", showUnEncMenuItem);

	changed = false;
	unEncodersDialog->add_button(Gtk::Stock::OK, 0);
	Gdk::RGBA green;
	green.set_rgba(0, 0.5, 0, 1);
	Gdk::RGBA orange;
	orange.set_rgba(1, 0.4, 0, 1);
	Gdk::RGBA red;
	red.set_rgba(0.5, 0, 0, 1);

	greenTag = Gtk::TextBuffer::Tag::create();
	greenTag->property_foreground_rgba() = green;
	greenTag->set_property("size-points", 12);
	orangeTag = Gtk::TextBuffer::Tag::create();
	orangeTag->property_foreground_rgba() = orange;
	orangeTag->set_property("size-points", 12);
	redTag = Gtk::TextBuffer::Tag::create();
	redTag->property_foreground_rgba() = red;
	redTag->set_property("size-points", 12);
	tagTable = Gtk::TextBuffer::TagTable::create();
	tagTable->add(greenTag);
	tagTable->add(orangeTag);
	tagTable->add(redTag);

	unEncodersText->set_buffer(Gtk::TextBuffer::create(tagTable));

	unEncodersCheck->signal_clicked().connect(sigc::mem_fun(*this, &UnEncodersDialog::checkClicked));
	showUnEncMenuItem->signal_activate().connect(sigc::mem_fun(*this, &UnEncodersDialog::show));
}
예제 #2
0
void GridWindow::on_button_solve_clicked()
{
	// Attempt to solve the puzzle

	// Read the contents of the entries
	sudoku sudokuPuzzle;
	sudokuPuzzle.initPuzzle(m_entry);
	bool result = sudokuPuzzle.SolvePuzzle();

	if(result)
	{
		Glib::ustring finalValue;

		Gdk::RGBA solutionColor;
		solutionColor.set_rgba(1.0,0.0,0.0,1.0); 	// red for the solution

		for(unsigned int ii=0;ii<9;ii++)
		{
			for(unsigned int jj=0;jj<9;jj++)
			{
				// Fill in the remaining cells
				if( m_entry[ii][jj].get_text().empty() )
				{
					Glib::ustring finalValue = IntToUString(sudokuPuzzle.getPuzzleValue(jj,ii));
					m_entry[ii][jj].override_color(solutionColor);
					m_entry[ii][jj].set_text(finalValue);
					m_entry[ii][jj].set_editable(false);
				}
			}
		}
	}
	else
	{
		// Input is not solvable
		// Inform the user of the error
		Gtk::MessageDialog dlg("Puzzle cannot be solved. Check the input.");
		dlg.run();
	}

}