/*
 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
 *
 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef _VIKING_TREEVIEW_H
#define _VIKING_TREEVIEW_H

#include "config.h"
#include "uibuilder.h"

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>

G_BEGIN_DECLS

#define VIK_TREEVIEW_TYPE            (vik_treeview_get_type ())
#define VIK_TREEVIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_TREEVIEW_TYPE, VikTreeview))
#define VIK_TREEVIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_TREEVIEW_TYPE, VikTreeviewClass))
#define IS_VIK_TREEVIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIK_TREEVIEW_TYPE))
#define IS_VIK_TREEVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIK_TREEVIEW_TYPE))

typedef struct _VikTreeview VikTreeview;
typedef struct _VikTreeviewClass VikTreeviewClass;

struct _VikTreeviewClass
{
  GtkTreeViewClass vbox_class;
  void (* item_edited) (VikTreeview *vt, GtkTreeIter *iter, const gchar *new_name);
  void (* item_toggled) (VikTreeview *vt,GtkTreeIter *iter);
};

enum {
 VIK_TREEVIEW_TYPE_LAYER = 0,
 VIK_TREEVIEW_TYPE_SUBLAYER
};

GType vik_treeview_get_type ();


VikTreeview *vik_treeview_new ();

GtkWidget *vik_treeview_get_widget ( VikTreeview *vt );

gint vik_treeview_item_get_data ( VikTreeview *vt, GtkTreeIter *iter );
gint vik_treeview_item_get_type ( VikTreeview *vt, GtkTreeIter *iter );
gchar *vik_treeview_item_get_name ( VikTreeview *vt, GtkTreeIter *iter );
gpointer vik_treeview_item_get_pointer ( VikTreeview *vt, GtkTreeIter *iter );
void vik_treeview_item_set_pointer ( VikTreeview *vt, GtkTreeIter *iter, gpointer pointer );
void vik_treeview_item_set_timestamp ( VikTreeview *vt, GtkTreeIter *iter, gdouble timestamp );
void vik_treeview_item_set_number ( VikTreeview *vt, GtkTreeIter *iter, guint number );

gpointer vik_treeview_item_get_parent ( VikTreeview *vt, GtkTreeIter *iter );
gboolean vik_treeview_item_get_visible_tree ( VikTreeview *vt, GtkTreeIter *iter );
void vik_treeview_item_set_visible_tree ( VikTreeview *vt, GtkTreeIter *iter );

void vik_treeview_select_iter ( VikTreeview *vt, GtkTreeIter *iter, gboolean view_all );
gboolean vik_treeview_get_selected_iter ( VikTreeview *vt, GtkTreeIter *iter );
gboolean vik_treeview_get_editing ( VikTreeview *vt );

void vik_treeview_item_set_icon ( VikTreeview *vt, GtkTreeIter *iter, const GdkPixbuf *icon );
void vik_treeview_item_set_name ( VikTreeview *vt, GtkTreeIter *iter, const gchar *to );
void vik_treeview_item_set_visible ( VikTreeview *vt, GtkTreeIter *iter, gboolean to );
void vik_treeview_item_toggle_visible ( VikTreeview *vt, GtkTreeIter *iter );
void vik_treeview_item_delete ( VikTreeview *vt, GtkTreeIter *iter );

gboolean vik_treeview_get_iter_at_pos ( VikTreeview *vt, GtkTreeIter *iter, gint x, gint y );

gboolean vik_treeview_get_iter_from_path_str ( VikTreeview *vt, GtkTreeIter *iter, const gchar *path_str );
gboolean vik_treeview_move_item ( VikTreeview *vt, GtkTreeIter *iter, gboolean up );
void vik_treeview_item_select ( VikTreeview *vt, GtkTreeIter *iter );
void vik_treeview_item_unselect ( VikTreeview *vt, GtkTreeIter *iter );

gboolean vik_treeview_item_get_parent_iter ( VikTreeview *vt, GtkTreeIter *iter,  GtkTreeIter *parent );
void vik_treeview_expand ( VikTreeview *vt, GtkTreeIter *iter );

void vik_treeview_add_layer ( VikTreeview *vt, GtkTreeIter *parent_iter, GtkTreeIter *iter, const gchar *name, gpointer parent, gboolean above,
                              gpointer item, gint data, VikLayerTypeEnum layer_type, gdouble timestamp );
void vik_treeview_insert_layer ( VikTreeview *vt, GtkTreeIter *parent_iter, GtkTreeIter *iter, const gchar *name, gpointer parent, gboolean above,
                              gpointer item, gint data, VikLayerTypeEnum layer_type, GtkTreeIter *sibling, gdouble timestamp );
void vik_treeview_add_sublayer ( VikTreeview *vt, GtkTreeIter *parent_iter, GtkTreeIter *iter, const gchar *name, gpointer parent, gpointer item,
                                 gint data, GdkPixbuf *icon, gboolean editable, gdouble timestamp, guint number );

gboolean vik_treeview_get_iter_with_name ( VikTreeview *vt, GtkTreeIter *iter, GtkTreeIter *parent_iter, const gchar *name );

void vik_treeview_sort_children ( VikTreeview *vt, GtkTreeIter *parent, vik_layer_sort_order_t order );

gboolean vik_treeview_key_press ( VikTreeview *vt, GdkEventKey *event );

G_END_DECLS

#endif
