teclado_celular.c

   1 /**
   2  * teclado_celular.c
   3  *
   4  * @author Luis Alejandro Bernal Romero
   5  *
   6  * Arma un teclado de celular usando Table.
   7  *
   8  * Para compilar, en línea de comando, digitar:
   9  *
  10  *   gcc -Wall -pedantic -o teclado_celular teclado_celular.c `pkg-config --cflags --libs gtk+-2.0`
  11  */
  12 
  13 #include <gtk/gtk.h>
  14 
  15 int main(int argc, char *argv[]){
  16   GtkWidget *ventana;
  17   GtkWidget *tabla;
  18   GtkWidget *boton[10];
  19   GtkWidget *boton_asterisco;
  20   GtkWidget *boton_numero;
  21   char etiqueta[2 + 1];
  22   int i, j, k;
  23 
  24   gtk_init(&argc, &argv);
  25   ventana = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  26   gtk_window_set_title(GTK_WINDOW(ventana), "Teclado celular");
  27   tabla = gtk_table_new(4, 3, TRUE);
  28   gtk_container_add(GTK_CONTAINER(ventana), tabla);
  29   for(i = 0; i < 10; i++){
  30     sprintf(etiqueta, "%d", i);
  31     boton[i] = gtk_button_new_with_label(etiqueta);
  32   }
  33   boton_asterisco = gtk_button_new_with_label("*");
  34   boton_numero = gtk_button_new_with_label("#");
  35   for(k = 1, i = 0; i < 3; i++){
  36     for(j = 0; j < 3; j++){
  37       gtk_table_attach_defaults(GTK_TABLE(tabla), boton[k], j, j + 1, i, i + 1);
  38       gtk_widget_show(boton[k++]);
  39     }
  40   }
  41   gtk_table_attach_defaults(GTK_TABLE(tabla), boton_asterisco, 0, 1, 3, 4);
  42   gtk_widget_show(boton_asterisco);
  43   gtk_table_attach_defaults(GTK_TABLE(tabla), boton[0], 1, 2, 3, 4);
  44   gtk_widget_show(boton[0]);
  45   gtk_table_attach_defaults(GTK_TABLE(tabla), boton_numero, 2, 3, 3, 4);
  46   gtk_widget_show(boton_numero);
  47   gtk_widget_show(tabla);
  48   gtk_widget_show(ventana);
  49   gtk_main();
  50 
  51   return 0;
  52 }

CategoryLenguajeC | CategoryProgramacion

LenguajeC/Programas/teclado_celular.c (last edited 2008-04-20 14:39:15 by localhost)