# include <iostream>
#endif
-gboolean on_drawingarea_expose_event(GtkWidget *widget, GdkEventExpose *event,
+gboolean on_drawingarea_expose_event(GtkWidget* widget, GdkEventExpose* event,
gpointer user_data) {
#ifdef DEBUG
std::cerr << "En expose_event." << std::endl;
return FALSE;
}
-void on_button_borrar_clicked(GtkButton *button, gpointer user_data) {
+void on_button_borrar_clicked(GtkButton* button, gpointer user_data) {
#ifdef DEBUG
std::cerr << "En borrar event." << std::endl;
#endif
static_cast<Dibujo*>(user_data)->borrar_todo();
}
-void on_button_graficar_clicked(GtkButton *button, gpointer user_data) {
+void on_button_graficar_clicked(GtkButton* button, gpointer user_data) {
#ifdef DEBUG
std::cerr << "En graficar event." << std::endl;
#endif
gtk_widget_queue_draw(GTK_WIDGET(user_data));
}
-void on_button_salir_clicked(GtkButton *button, gpointer user_data) {
+void on_button_salir_clicked(GtkButton* button, gpointer user_data) {
#ifdef DEBUG
std::cerr << "En salir event." << std::endl;
#endif
gtk_main_quit();
}
-void on_button_agregar_clicked(GtkButton *button, gpointer user_data) {
+void on_button_agregar_clicked(GtkButton* button, gpointer user_data) {
#ifdef DEBUG
std::cerr << "En agregar event." << std::endl;
#endif
// más, tal vez, el drawingarea.
TP5Window* win = static_cast<TP5Window*>(user_data);
Figura* figura = new Circulo(1, 1, Punto(50, 50), "Lala", 50);
- static_cast<Dibujo*>(user_data)->agregar_figura(figura);
- static_cast<Dibujo*>(user_data)->agregar_figura(
- new Linea(1, 2, Punto(50, 50), "", Punto(0, 0), Punto(100, 50)));
- static_cast<Dibujo*>(user_data)->agregar_figura(
- new Rectangulo(2, 1, Punto(100, 100), "", 20, 80));
- static_cast<Dibujo*>(user_data)->agregar_figura(
- new Cuadrado(5, 5, Punto(150, 120), "", 100));
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->radiobutton_linea))) {
+ figura = new Linea(
+ 1, // Color FIXME
+ gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(win->spinbutton_grosor)),
+ Punto(GTK_SPIN_BUTTON(win->spinbutton_centro_x),
+ GTK_SPIN_BUTTON(win->spinbutton_centro_y)),
+ gtk_entry_get_text(GTK_ENTRY(win->entry_nombre)),
+ Punto(GTK_SPIN_BUTTON(win->spinbutton_inicio_x),
+ GTK_SPIN_BUTTON(win->spinbutton_inicio_y)),
+ Punto(GTK_SPIN_BUTTON(win->spinbutton_fin_x),
+ GTK_SPIN_BUTTON(win->spinbutton_fin_y))
+ );
+ } else if (gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(win->radiobutton_cuadrado))) {
+ figura = new Cuadrado(
+ 1, // Color FIXME
+ gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(win->spinbutton_grosor)),
+ Punto(GTK_SPIN_BUTTON(win->spinbutton_centro_x),
+ GTK_SPIN_BUTTON(win->spinbutton_centro_y)),
+ gtk_entry_get_text(GTK_ENTRY(win->entry_nombre)),
+ gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(win->spinbutton_alto))
+ );
+ } else if (gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(win->radiobutton_rectangulo))) {
+ figura = new Rectangulo(
+ 1, // Color FIXME
+ gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(win->spinbutton_grosor)),
+ Punto(GTK_SPIN_BUTTON(win->spinbutton_centro_x),
+ GTK_SPIN_BUTTON(win->spinbutton_centro_y)),
+ gtk_entry_get_text(GTK_ENTRY(win->entry_nombre)),
+ gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(win->spinbutton_alto)),
+ gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(win->spinbutton_ancho))
+ );
+ } else {
+ figura = new Circulo(
+ 1, // Color FIXME
+ gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(win->spinbutton_grosor)),
+ Punto(GTK_SPIN_BUTTON(win->spinbutton_centro_x),
+ GTK_SPIN_BUTTON(win->spinbutton_centro_y)),
+ gtk_entry_get_text(GTK_ENTRY(win->entry_nombre)),
+ gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(win->spinbutton_radio))
+ );
+ }
+ win->dibujo.agregar_figura(figura);
}
-gboolean on_window_delete_event(GtkWidget *widget, GdkEvent *event,
+gboolean on_window_delete_event(GtkWidget* widget, GdkEvent* event,
gpointer user_data) {
#ifdef DEBUG
std::cerr << "En delete_event." << std::endl;
return FALSE;
}
-#include <iostream> // FIXME
-void on_radiobutton_linea_toggled(GtkToggleButton *togglebutton,
+void on_radiobutton_linea_toggled(GtkToggleButton* togglebutton,
gpointer user_data) {
- // TODO
+#ifdef DEBUG
std::cerr << "En linea event." << std::endl;
+#endif
+ // TODO
TP5Window* win = static_cast<TP5Window*>(user_data);
+ gtk_widget_set_sensitive(win->spinbutton_inicio_x, true);
+ gtk_widget_set_sensitive(win->spinbutton_inicio_y, true);
+ gtk_widget_set_sensitive(win->spinbutton_fin_x, true);
+ gtk_widget_set_sensitive(win->spinbutton_fin_y, true);
+ gtk_widget_set_sensitive(win->spinbutton_alto, false);
+ gtk_widget_set_sensitive(win->spinbutton_ancho, false);
+ gtk_widget_set_sensitive(win->spinbutton_radio, false);
}
-void on_radiobutton_cuadrado_toggled(GtkToggleButton *togglebutton,
+void on_radiobutton_cuadrado_toggled(GtkToggleButton* togglebutton,
gpointer user_data) {
- // TODO
+#ifdef DEBUG
std::cerr << "En cuadrado event." << std::endl;
+#endif
+ // TODO
TP5Window* win = static_cast<TP5Window*>(user_data);
+ gtk_widget_set_sensitive(win->spinbutton_inicio_x, false);
+ gtk_widget_set_sensitive(win->spinbutton_inicio_y, false);
+ gtk_widget_set_sensitive(win->spinbutton_fin_x, false);
+ gtk_widget_set_sensitive(win->spinbutton_fin_y, false);
+ gtk_widget_set_sensitive(win->spinbutton_alto, true);
+ gtk_widget_set_sensitive(win->spinbutton_ancho, false);
+ gtk_widget_set_sensitive(win->spinbutton_radio, false);
}
-void on_radiobutton_rectangulo_toggled(GtkToggleButton *togglebutton,
+void on_radiobutton_rectangulo_toggled(GtkToggleButton* togglebutton,
gpointer user_data) {
- // TODO
+#ifdef DEBUG
std::cerr << "En rectangulo event." << std::endl;
+#endif
+ // TODO
TP5Window* win = static_cast<TP5Window*>(user_data);
+ gtk_widget_set_sensitive(win->spinbutton_inicio_x, false);
+ gtk_widget_set_sensitive(win->spinbutton_inicio_y, false);
+ gtk_widget_set_sensitive(win->spinbutton_fin_x, false);
+ gtk_widget_set_sensitive(win->spinbutton_fin_y, false);
+ gtk_widget_set_sensitive(win->spinbutton_alto, true);
+ gtk_widget_set_sensitive(win->spinbutton_ancho, true);
+ gtk_widget_set_sensitive(win->spinbutton_radio, false);
}
-void on_radiobutton_circulo_toggled(GtkToggleButton *togglebutton,
+void on_radiobutton_circulo_toggled(GtkToggleButton* togglebutton,
gpointer user_data) {
- // TODO
+#ifdef DEBUG
std::cerr << "En circulo event." << std::endl;
+#endif
+ // TODO
TP5Window* win = static_cast<TP5Window*>(user_data);
+ gtk_widget_set_sensitive(win->spinbutton_inicio_x, false);
+ gtk_widget_set_sensitive(win->spinbutton_inicio_y, false);
+ gtk_widget_set_sensitive(win->spinbutton_fin_x, false);
+ gtk_widget_set_sensitive(win->spinbutton_fin_y, false);
+ gtk_widget_set_sensitive(win->spinbutton_alto, false);
+ gtk_widget_set_sensitive(win->spinbutton_ancho, false);
+ gtk_widget_set_sensitive(win->spinbutton_radio, true);
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
- gtk_window_set_title (GTK_WINDOW (window), "Trabajo PrÃ\83¡ctico V");
+ gtk_window_set_title (GTK_WINDOW (window), "Trabajo Práctico V");
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
vbox_figura = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame_figura), vbox_figura);
- radiobutton_linea = gtk_radio_button_new_with_mnemonic (NULL, "LÃ\83Ânea");
+ radiobutton_linea = gtk_radio_button_new_with_mnemonic (NULL, "Línea");
gtk_box_pack_start (GTK_BOX (vbox_figura), radiobutton_linea, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_linea), radiobutton_group);
radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_linea));
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_cuadrado), radiobutton_group);
radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_cuadrado));
- radiobutton_rectangulo = gtk_radio_button_new_with_mnemonic (NULL, "_RectÃ\83¡ngulo");
+ radiobutton_rectangulo = gtk_radio_button_new_with_mnemonic (NULL, "_Rectángulo");
gtk_box_pack_start (GTK_BOX (vbox_figura), radiobutton_rectangulo, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_rectangulo), radiobutton_group);
radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_rectangulo));
- radiobutton_circulo = gtk_radio_button_new_with_mnemonic (NULL, "CÃ\83Ârc_ulo");
+ radiobutton_circulo = gtk_radio_button_new_with_mnemonic (NULL, "Círc_ulo");
gtk_box_pack_start (GTK_BOX (vbox_figura), radiobutton_circulo, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_circulo), radiobutton_group);
radiobutton_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_circulo));
NULL);
g_signal_connect((gpointer) drawingarea, "expose_event",
G_CALLBACK (on_drawingarea_expose_event),
- dibujo);
+ &dibujo);
g_signal_connect((gpointer) button_limpiar, "clicked",
G_CALLBACK (on_button_borrar_clicked),
- dibujo);
+ &dibujo);
g_signal_connect((gpointer) button_actualizar, "clicked",
G_CALLBACK (on_button_graficar_clicked),
drawingarea);