/*
 * Copyright (c)2004 Cat's Eye Technologies.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 
 *   Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * 
 *   Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in
 *   the documentation and/or other materials provided with the
 *   distribution.
 * 
 *   Neither the name of Cat's Eye Technologies nor the names of its
 *   contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission. 
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

/*
 * curses_widget.h
 * $Id: curses_widget.h,v 1.1 2004/07/09 23:25:41 cpressey Exp $
 */

#include "curses_form.h"

#ifndef __CURSES_WIDGET_H
#define __CURSES_WIDGET_H

#define CURSES_LABEL	1
#define CURSES_TEXTBOX	2
#define CURSES_BUTTON	3
#define CURSES_PROGRESS	4
#define CURSES_CHECKBOX	5
#define CURSES_LISTBOX	6

struct curses_widget {
	struct curses_widget *next;	/* chain of widgets in form */
	struct curses_widget *prev;

	struct curses_form *form;	/* form in which widget lives */

	int x;			/* x pos of widget in form, 0 = left edge */
	int y;			/* y pos of widget in form, 0 = top edge */
	int width;		/* width of widget */
	int type;		/* CURSES_* type of widget */
	char *text;		/* for labels, textboxes, buttons */
	int size;		/* for textboxes, allocated size of text */
	int curpos;		/* for textboxes, cursor position */
	int offset;		/* for textboxes, first displayed char */
	int editable;		/* for textboxes, text is editable */
	int obscured;		/* for textboxes, text is ****'ed out */
	int amount;		/* for progress bars, sliders, checkboxes */
	int spin;		/* for progress bars */
	char *tooltip;		/* short help text displayed on statusbar */

	int user_id;		/* misc integer */
	void *userdata;		/* misc pointer */

				/* callback for when widget is clicked */
				/* for buttons */
	int (*click_cb)(struct curses_widget *);
};

struct curses_widget	*curses_widget_new(int, int, int, int, char *, int);
void			 curses_widget_free(struct curses_widget *);
void			 curses_widget_draw(struct curses_widget *);
void			 curses_widget_draw_tooltip(struct curses_widget *);
int			 curses_widget_can_take_focus(struct curses_widget *);
void			 curses_widget_tooltip_set(struct curses_widget *, char *);

int			 curses_textbox_advance_char(struct curses_widget *);
int			 curses_textbox_retreat_char(struct curses_widget *);
int			 curses_textbox_home(struct curses_widget *);
int			 curses_textbox_end(struct curses_widget *);
int			 curses_textbox_insert_char(struct curses_widget *, char);
int			 curses_textbox_backspace_char(struct curses_widget *);
int			 curses_textbox_delete_char(struct curses_widget *);

int			 curses_checkbox_toggle(struct curses_widget *);

int			 curses_button_set_click_cb(struct curses_widget *,
						    int (*)(struct curses_widget *));
int			 curses_button_click(struct curses_widget *);

int			 curses_progress_spin(struct curses_widget *);

#endif /* !__CURSES_WIDGET_H */
