#ifndef _GTCACA_TREE_H_
#define _GTCACA_TREE_H_
#include <stdint.h>
#include <gtcaca/main.h>
#include <gtcaca/widget.h>
typedef struct gtcaca_tree_model gtcaca_tree_model_t;
struct gtcaca_tree_model {
long (*child_count)(gtcaca_tree_model_t *m, void *node);
void *(*child)(gtcaca_tree_model_t *m, void *node, long index);
void (*label)(gtcaca_tree_model_t *m, void *node, char *buf, int buflen);
int (*has_children)(gtcaca_tree_model_t *m, void *node);
void *userdata;
void (*draw_row)(gtcaca_tree_model_t *m, void *node, int x, int y, int width, int selected);
};
typedef struct _gtcaca_tree_widget_t gtcaca_tree_widget_t;
struct _gtcaca_tree_widget_t {
gtcaca_widget_type_t type;
unsigned int id;
int has_focus;
int is_visible;
int x;
int y;
int width;
int height;
uint8_t color_focus_fg;
uint8_t color_focus_bg;
uint8_t color_nonfocus_fg;
uint8_t color_nonfocus_bg;
gtcaca_widget_t *parent;
gtcaca_widget_t *children;
struct _gtcaca_tree_widget_t *prev;
struct _gtcaca_tree_widget_t *next;
gtcaca_tree_model_t *model;
void *root;
long top;
long sel;
char *title;
uint8_t sel_bg;
};
gtcaca_tree_widget_t *gtcaca_tree_new(gtcaca_widget_t *parent, int x, int y, int width, int height);
void gtcaca_tree_set_model(gtcaca_tree_widget_t *t, gtcaca_tree_model_t *model);
void gtcaca_tree_draw(gtcaca_tree_widget_t *t);
int gtcaca_tree_key(gtcaca_tree_widget_t *t, int key, void *userdata);
long gtcaca_tree_visible_count(gtcaca_tree_widget_t *t);
void *gtcaca_tree_selected_node(gtcaca_tree_widget_t *t);
void gtcaca_tree_select(gtcaca_tree_widget_t *t, void *node);
void gtcaca_tree_reveal(gtcaca_tree_widget_t *t, void *node);
void gtcaca_tree_set_title(gtcaca_tree_widget_t *t, const char *title);
void gtcaca_tree_free(gtcaca_tree_widget_t *t);
#endif