/*****************************************************************************/

/*
 *      keypad.c -- keypad for numeric selections
 *
 *      Copyright (C) 2001 Sigma Designs
 *                    written by Pascal Cannenterre <pascal_cannenterre@sdesigns.com>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*****************************************************************************/
#include "define.h"
#include "gtk_callbacks.h"
#include "interface.h"


GtkWidget *get_keypad_toolbar(GtkWidget *parent, GtkWidget *vbox_parent)
{
  GtkWidget *key0, *key1, *key2, *key3, *key4,
    *key5, *key6, *key7, *key8, *key9;   
  GtkWidget* handlebox;
  GtkWidget *hbox;
  GtkWidget * toolbar;
  
  handlebox = gtk_handle_box_new ();
  gtk_box_pack_end ( GTK_BOX (vbox_parent),
		     handlebox, FALSE, FALSE,0);

  toolbar = gtk_toolbar_new ( GTK_ORIENTATION_HORIZONTAL,
			      GTK_TOOLBAR_TEXT);
  gtk_container_set_border_width ( GTK_CONTAINER ( toolbar ) ,0);
  gtk_toolbar_set_space_size ( GTK_TOOLBAR ( toolbar ), 5 );
  hbox = gtk_hbox_new (FALSE,1);
  gtk_box_pack_start (GTK_BOX(hbox),toolbar, TRUE, TRUE, 0);

  gtk_container_add ( GTK_CONTAINER ( handlebox ) , hbox);
  gtk_widget_show(hbox);
  

  key0 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "0",               /* button label */
			    "0",   /* this button's tooltip */
			    "0",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(0) );
  
  key1 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "1",               /* button label */
			    "1",   /* this button's tooltip */
			    "1",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(1) );

   key2 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "2",               /* button label */
			    "2",   /* this button's tooltip */
			    "2",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(2) );
  
  key3 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "3",               /* button label */
			    "3",   /* this button's tooltip */
			    "3",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(3) );
 
  key4 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "4",               /* button label */
			    "4",   /* this button's tooltip */
			    "4",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(4) );
  
  key5 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "5",               /* button label */
			    "5",   /* this button's tooltip */
			    "5",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(5) );
  
  key6 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "6",               /* button label */
			    "6",   /* this button's tooltip */
			    "6",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(6) );
  
  key7 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "7",               /* button label */
			    "7",   /* this button's tooltip */
			    "7",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(7) ); 
  
  key8 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "8",               /* button label */
			    "8",   /* this button's tooltip */
			    "8",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(8) );
  
  key9 = gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "9",               /* button label */
			    "9",   /* this button's tooltip */
			    "9",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_digit_clicked_cb), /* a signal */
			    GUINT_TO_POINTER(9) );

  gtk_toolbar_append_space ( GTK_TOOLBAR ( toolbar));/* space after item */
  gtk_toolbar_set_space_size(GTK_TOOLBAR ( toolbar), 10);
  
  gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "Del",               /* button label */
			    "Delete",   /* this button's tooltip */
			    "Delete",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_del_clicked_cb), /* a signal */
			    NULL );
  
  gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), /* our toolbar */
			    "Ent",               /* button label */
			    "Enter",   /* this button's tooltip */
			    "Enter",     /* tooltip private info */
			    NULL,                 /* icon widget */
			    GTK_SIGNAL_FUNC (keypad_ent_clicked_cb), /* a signal */
			    NULL );
  init_keypad();
  gtk_widget_show (toolbar);
  
  return (handlebox);
}
