#include <gtk/gtk.h>

#define NUM_COLUMNS 18
#define NUM_ROWS 1

#define START_WIDTH 50
#define START_HEIGHT 30
#define START_DIFF_WIDTH 20
#define START_DIFF_HEIGHT 15
#define SPACING 5
#define XALIGN_INCR 0.0
#define YALIGN_INCR 0.5

#define RED 255
#define GREEN 0
#define BLUE 0

int
main(int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *fixed;
  GtkWidget *button[NUM_ROWS][NUM_COLUMNS];
  GtkWidget *child[NUM_ROWS][NUM_COLUMNS];
  GdkColor boxcolor;
  int r;
  int c;
  int x = SPACING;
  int y = SPACING;
  gfloat yalign = 0.0;
  gfloat xalign = 0.0;
  GtkWidget *label[NUM_ROWS][NUM_COLUMNS];

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  fixed = gtk_fixed_new ();
  gtk_container_add (GTK_CONTAINER (window), fixed);

  boxcolor.red = RED << 8;
  boxcolor.green = GREEN << 8;
  boxcolor.blue = BLUE << 8;

  for (r = 0; r < NUM_ROWS; r++)
    {
      for (c = 0; c < NUM_COLUMNS; c++)
	{
	  child[r][c] = gtk_event_box_new ();
	  label[r][c] = gtk_label_new ("Hello");

          gtk_container_add (GTK_CONTAINER (child[r][c]), label[r][c]);

	  gtk_widget_set_size_request (child[r][c],
				       START_WIDTH - START_DIFF_WIDTH,
				       START_HEIGHT - START_DIFF_HEIGHT);


	  gtk_widget_modify_bg (child[r][c], GTK_STATE_NORMAL, &boxcolor);

	  button[r][c] = gtk_button_new ();
	  gtk_button_set_alignment (GTK_BUTTON (button[r][c]), xalign, yalign);
	  gtk_widget_set_size_request (button[r][c], START_WIDTH, START_HEIGHT - c * 1);

	  gtk_container_add (GTK_CONTAINER (button[r][c]), child[r][c]);
	  gtk_container_add (GTK_CONTAINER (fixed), button[r][c]);
	  gtk_fixed_move (GTK_FIXED (fixed), button[r][c], x, y);
	  x += START_WIDTH + SPACING;
	}
      xalign += XALIGN_INCR;
      yalign += YALIGN_INCR;
      x = SPACING;
      y += START_HEIGHT + SPACING;
    }

  gtk_window_set_default_size (GTK_WINDOW (window),
                               SPACING + (START_WIDTH + SPACING) * NUM_COLUMNS,
                               SPACING + (START_HEIGHT + SPACING) * NUM_ROWS);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
