/* GNOME DB library
 * Copyright (C) 1999-2002 The GNOME Foundation.
 *
 * AUTHORS:
 *      Rodrigo Moya <rodrigo@gnome-db.org>
 *
 * This Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This Library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined(__gnome_db_grid_h__)
#  define __gnome_db_grid_h__

#include <gtk/gtkvbox.h>
#include <libgda/gda-data-model.h>

G_BEGIN_DECLS

#define GNOME_DB_TYPE_GRID            (gnome_db_grid_get_type())
#define GNOME_DB_GRID(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GNOME_DB_TYPE_GRID, GnomeDbGrid))
#define GNOME_DB_GRID_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GNOME_DB_TYPE_GRID, GnomeDbGridClass))
#define GNOME_DB_IS_GRID(obj)         (G_TYPE_CHECK_INSTANCE_TYPE (obj, GNOME_DB_TYPE_GRID))
#define GNOME_DB_IS_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_DB_TYPE_GRID))

typedef struct _GnomeDbGrid        GnomeDbGrid;
typedef struct _GnomeDbGridClass   GnomeDbGridClass;
typedef struct _GnomeDbGridPrivate GnomeDbGridPrivate;

typedef void (* GnomeDbGridForeachFunc) (GnomeDbGrid *grid, gint row, gpointer user_data);

struct _GnomeDbGrid {
	GtkVBox parent;
	GnomeDbGridPrivate *priv;
};

struct _GnomeDbGridClass {
	GtkVBoxClass parent_class;

	/* signals */
	void (* row_selected) (GnomeDbGrid *grid, gint row);
	void (* selection_cleared) (GnomeDbGrid *grid);
	void (* double_clicked) (GnomeDbGrid *grid, gint row);
	void (* create_popup_menu) (GnomeDbGrid *grid, GtkWidget *menu);
};

GType            gnome_db_grid_get_type (void);
GtkWidget       *gnome_db_grid_new (void);
GtkWidget       *gnome_db_grid_new_with_model (GdaDataModel *model);

const gchar     *gnome_db_grid_get_title (GnomeDbGrid *grid);
void             gnome_db_grid_set_title (GnomeDbGrid *grid, const gchar *title);
void             gnome_db_grid_set_column_title (GnomeDbGrid *grid, gint col, const gchar *title);
const gchar     *gnome_db_grid_get_column_title (GnomeDbGrid *grid, gint col);
gboolean         gnome_db_grid_get_show_title (GnomeDbGrid *grid);
void             gnome_db_grid_set_show_title (GnomeDbGrid *grid, gboolean show);
void             gnome_db_grid_set_title_icon_from_file (GnomeDbGrid *grid, const gchar *file);
void             gnome_db_grid_set_title_icon_from_stock (GnomeDbGrid *grid, const gchar *stock_id, GtkIconSize size);
void             gnome_db_grid_set_show_title_icon (GnomeDbGrid *grid, gboolean show);
gboolean         gnome_db_grid_get_show_title_icon (GnomeDbGrid *grid);

GdaDataModel    *gnome_db_grid_get_model (GnomeDbGrid *grid);
void             gnome_db_grid_set_model (GnomeDbGrid *grid, GdaDataModel *model);
GList           *gnome_db_grid_get_selection (GnomeDbGrid *grid);
void             gnome_db_grid_foreach_selected (GnomeDbGrid *grid,
						 GnomeDbGridForeachFunc foreach_func,
						 gpointer user_data);
void             gnome_db_grid_select_row (GnomeDbGrid *grid, gint row);
void             gnome_db_grid_select_all (GnomeDbGrid *grid);
void             gnome_db_grid_unselect_all (GnomeDbGrid *grid);
GtkSelectionMode gnome_db_grid_get_selection_mode (GnomeDbGrid *grid);
void             gnome_db_grid_set_selection_mode (GnomeDbGrid *grid,
						   GtkSelectionMode mode);

void             gnome_db_grid_set_column_titles_visible (GnomeDbGrid *grid, gboolean visible);
gboolean         gnome_db_grid_get_column_titles_visible (GnomeDbGrid *grid);
#define gnome_db_grid_show_column_titles(grid) \
	(gnome_db_grid_set_column_titles_visible (grid, TRUE))
#define gnome_db_grid_hide_column_titles(grid) \
	(gnome_db_grid_set_column_titles_visible (grid, FALSE))
void             gnome_db_grid_set_column_visible (GnomeDbGrid *grid, gint col, gboolean visible);
gboolean         gnome_db_grid_get_column_visible (GnomeDbGrid *grid, gint col);

gpointer         gnome_db_grid_get_row_data (GnomeDbGrid *grid, gint row);
void             gnome_db_grid_set_row_data (GnomeDbGrid *grid, gint row, gpointer data);
gint             gnome_db_grid_find_row_from_data (GnomeDbGrid *grid, gpointer data);

G_END_DECLS

#endif
