# 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);
}