#ifndef EXCELSIOR_TYPES_H
#define EXCELSIOR_TYPES_H

#include "ge-support.h"

typedef unsigned char boolean;
typedef unsigned char uint8;
typedef struct _excelsiorStyleFunctions excelsiorStyleFunctions;

typedef enum
{
	XCL_STYLE_CLASSIC = 0,
	XCL_NUM_STYLES = 1
} excelsiorStyles;

typedef enum
{
	XCL_STATE_NORMAL,
	XCL_STATE_ACTIVE,
	XCL_STATE_SELECTED,
	XCL_STATE_INSENSITIVE
} excelsiorStateType;

typedef enum
{
	XCL_JUNCTION_NONE      = 0,
	XCL_JUNCTION_BEGIN     = 1,
	XCL_JUNCTION_END       = 2
} excelsiorJunction;

typedef enum
{
	XCL_STEPPER_UNKNOWN    = 0,
	XCL_STEPPER_A          = 1,
	XCL_STEPPER_B          = 2,
	XCL_STEPPER_C          = 4,
	XCL_STEPPER_D          = 8
} excelsiorStepper;

typedef enum
{
	XCL_ORDER_FIRST,
	XCL_ORDER_MIDDLE,
	XCL_ORDER_LAST
} excelsiorOrder;

typedef enum
{
	XCL_CONT_NONE       = 0,
	XCL_CONT_LEFT       = 1 << 0,
	XCL_CONT_RIGHT      = 1 << 1
} excelsiorContinue;

typedef enum
{
	XCL_ORIENTATION_LEFT_TO_RIGHT,
	XCL_ORIENTATION_RIGHT_TO_LEFT,
	XCL_ORIENTATION_BOTTOM_TO_TOP,
	XCL_ORIENTATION_TOP_TO_BOTTOM
} excelsiorOrientation;

typedef enum
{
	XCL_GAP_LEFT,
	XCL_GAP_RIGHT,
	XCL_GAP_TOP,
	XCL_GAP_BOTTOM
} excelsiorGapSide;

typedef enum
{
	XCL_SHADOW_NONE,
	XCL_SHADOW_IN,
	XCL_SHADOW_OUT,
	XCL_SHADOW_ETCHED_IN,
	XCL_SHADOW_ETCHED_OUT
} excelsiorShadowType;

typedef enum
{
	XCL_HANDLE_TOOLBAR,
	XCL_HANDLE_SPLITTER
} excelsiorHandleType;

typedef enum
{
	XCL_ARROW_NORMAL,
	XCL_ARROW_COMBO
} excelsiorArrowType;

typedef enum
{
	XCL_FOCUS_BUTTON,
	XCL_FOCUS_BUTTON_FLAT,
	XCL_FOCUS_LABEL,
	XCL_FOCUS_TREEVIEW,
	XCL_FOCUS_TREEVIEW_HEADER,
	XCL_FOCUS_TREEVIEW_ROW,
	XCL_FOCUS_TREEVIEW_DND,
	XCL_FOCUS_SCALE,
	XCL_FOCUS_TAB,
	XCL_FOCUS_COLOR_WHEEL_DARK,
	XCL_FOCUS_COLOR_WHEEL_LIGHT,
	XCL_FOCUS_UNKNOWN
} excelsiorFocusType;


typedef enum
{
	XCL_DIRECTION_UP,
	XCL_DIRECTION_DOWN,
	XCL_DIRECTION_LEFT,
	XCL_DIRECTION_RIGHT
} excelsiorDirection;

typedef enum
{
	XCL_PROGRESSBAR_CONTINUOUS,
	XCL_PROGRESSBAR_DISCRETE
} excelsiorProgressBarStyle;

typedef enum
{
	XCL_WINDOW_EDGE_NORTH_WEST,
	XCL_WINDOW_EDGE_NORTH,
	XCL_WINDOW_EDGE_NORTH_EAST,
	XCL_WINDOW_EDGE_WEST,
	XCL_WINDOW_EDGE_EAST,
	XCL_WINDOW_EDGE_SOUTH_WEST,
	XCL_WINDOW_EDGE_SOUTH,
	XCL_WINDOW_EDGE_SOUTH_EAST
} excelsiorWindowEdge;

typedef struct
{
	double x;
	double y;
	double width;
	double height;
} excelsiorRectangle;

typedef struct
{
	CairoColor fg[5];
	CairoColor bg[5];
	CairoColor base[5];
	CairoColor text[5];

	CairoColor shade[9];
	CairoColor spot[3];
} excelsiorColors;

typedef struct
{
	boolean active;
	boolean prelight;
	boolean disabled;
	boolean focus;
	boolean is_default;
	boolean ltr;
	boolean enable_shadow;
	guint8  random_effect;
	guint8  entry_ib_ever;
	guint8  random_style;
	gfloat  random_opacity;
	guint8  mw_gradient;
	guint8  aqua_tabs;
	guint8  button_style;
	guint8  pellucid_scales;
	guint8  old_scales;
	gfloat  arrow_size;
	guint8  swoosh_effect;
	guint8  swoosh_strength;
	guint8  scale_trough_size;
	guint8  tooltip_style;

	gfloat  radius;

	excelsiorStateType state_type;

	uint8 corners;
	uint8 xthickness;
	uint8 ythickness;

	CairoColor parentbg;

	excelsiorStyleFunctions *style_functions;
} WidgetParameters;

typedef struct
{
	excelsiorFocusType type;
	excelsiorContinue  continue_side;
	CairoColor          color;
	boolean             has_color;
	guint8              focus_line_width;
	gint                padding;
	guint8*             dash_list;
	boolean             interior;
} FocusParameters;

typedef struct
{
	boolean lower;
	boolean horizontal;
	boolean fill_level;
} SliderParameters;

typedef struct
{
	excelsiorOrientation orientation;
	boolean pulsing;
	float value;
	guint8 progbar_style;
	guint8 progbar_to_left;
} ProgressBarParameters;

typedef struct
{
	int linepos;
} OptionMenuParameters;

typedef struct
{
	excelsiorShadowType shadow;
	excelsiorGapSide gap_side;
	int gap_x;
	int gap_width;
	const CairoColor *border; /* maybe changes this to some other hint ... */
} FrameParameters;

typedef struct
{
	excelsiorGapSide gap_side;
	FocusParameters   focus;
} TabParameters;

typedef struct
{
	CairoCorners    corners;
	excelsiorShadowType shadow;
} ShadowParameters;

typedef struct
{
	boolean horizontal;
} SeparatorParameters;

typedef struct
{
	excelsiorOrder order; /* XXX: rename to position */
	boolean         resizable;
} ListViewHeaderParameters;

typedef struct
{
	excelsiorJunction junction; /* On which sides the slider junctions */
	boolean            horizontal;
	int                style;
} ScrollBarParameters;

typedef struct
{
	excelsiorHandleType type;
	boolean              horizontal;
} HandleParameters;

typedef struct
{
	excelsiorStepper stepper;  /* Which stepper to draw */
} ScrollBarStepperParameters;

typedef struct
{
	excelsiorWindowEdge edge;
} ResizeGripParameters;

typedef struct
{
	int style;
} MenuBarParameters;

typedef struct
{
	excelsiorShadowType shadow_type;
	boolean              in_cell;
	boolean              in_menu;
} CheckboxParameters;

typedef struct
{
	excelsiorArrowType type;
	excelsiorDirection direction;
} ArrowParameters;

typedef struct
{
	int      style;
	boolean  topmost;
} ToolbarParameters;

struct _excelsiorStyleFunctions
{
	void (*draw_button)           (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height,
	                               double grip_opacity);

	void (*draw_scale_trough)     (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const SliderParameters *slider,
	                               int x, int y, int width, int height);

	void (*draw_progressbar_trough) (cairo_t 	*cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_progressbar_fill) (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const ProgressBarParameters	*progressbar,
	                               int x, int y, int width, int height, gint offset);

	void (*draw_slider_button)    (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const SliderParameters *slider,
	                               int x, int y, int width, int height);

	void (*draw_entry)            (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_mw_gradient)            (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_spinbutton)       (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_spinbutton_down)  (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_optionmenu)       (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const OptionMenuParameters *optionmenu,
	                               int x, int y, int width, int height);

	void (*draw_inset)            (cairo_t *cr,
	                                const CairoColor *bg_color,
	                                double x, double y, double w, double h,
	                                double radius, uint8 corners);

	void (*draw_menubar)          (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const MenuBarParameters *menubar,
	                               int x, int y, int width, int height);

	void (*draw_tab)              (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const TabParameters *tab,
	                               int x, int y, int width, int height);

	void (*draw_frame)            (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const FrameParameters *frame,
	                               int x, int y, int width, int height);

	void (*draw_separator)        (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const SeparatorParameters *separator,
	                               int x, int y, int width, int height);

	void (*draw_menu_item_separator) (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const SeparatorParameters *separator,
	                               int x, int y, int width, int height);

	void (*draw_list_view_header) (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const ListViewHeaderParameters *header,
	                               int x, int y, int width, int height);

	void (*draw_toolbar)          (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const ToolbarParameters *toolbar,
	                               int x, int y, int width, int height);

	void (*draw_menuitem)         (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_menubaritem)      (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_selected_cell)    (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_scrollbar_stepper) (cairo_t *cr,
	                                const excelsiorColors	*colors,
	                                const WidgetParameters	*widget,
	                                const ScrollBarParameters *scrollbar,
	                                const ScrollBarStepperParameters *stepper,
	                                int x, int y, int width, int height);

	void (*draw_scrollbar_slider) (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const ScrollBarParameters	*scrollbar,
	                               int x, int y, int width, int height);

	void (*draw_scrollbar_trough) (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const ScrollBarParameters	*scrollbar,
	                               int x, int y, int width, int height);

	void (*draw_statusbar)        (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_menu_frame)       (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_tooltip)          (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_handle)           (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const HandleParameters *handle,
	                               int x, int y, int width, int height);

	void (*draw_resize_grip)      (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const ResizeGripParameters	*grip,
	                               int x, int y, int width, int height);

	void (*draw_arrow)            (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const ArrowParameters *arrow,
	                               int x, int y, int width, int height);

	void (*draw_focus)            (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const FocusParameters *focus,
	                               int x, int y, int width, int height);

	void (*draw_checkbox)         (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const CheckboxParameters	*checkbox,
	                               int x, int y, int width, int height);

	void (*draw_radiobutton)      (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               const CheckboxParameters	*checkbox,
	                               int x, int y, int width, int height);

	/* Style internal functions */
	/* XXX: Only used by slider_button, inline it? */
	void (*draw_shadow)           (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               gfloat radius, int width, int height);

	void (*draw_slider)           (cairo_t *cr,
	                               const excelsiorColors *colors,
	                               const WidgetParameters *widget,
	                               int x, int y, int width, int height);

	void (*draw_gripdots)         (cairo_t *cr,
	                               const excelsiorColors *colors, int x, int y,
	                               int width, int height, int xr, int yr,
	                               float contrast);
};


#define EXCELSIOR_RECTANGLE_SET(rect, _x, _y, _w, _h) rect.x      = _x; \
                                                       rect.y      = _y; \
                                                       rect.width  = _w; \
                                                       rect.height = _h;

#endif /* EXCELSIOR_TYPES_H */
