/*
    GDAM - Geoff & Dave's Audio Mixer
    Copyright (C) 1999    Dave Benson, Geoff Matters.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

    Contact:
        daveb@ffem.org <Dave Benson>
        geoff@ugcs.caltech.edu <Geoff Matters>
*/
#ifndef __GDAM_PIX_FONT_H_
#define __GDAM_PIX_FONT_H_


/* GdamPixFont:  cached fonts stored as a big pixmap containing
 *               all the glyphs. */

typedef struct _GdamPixFont GdamPixFont;
typedef struct _GdamPixFontClass GdamPixFontClass;
typedef struct _GdamPixFontElement GdamPixFontElement;
typedef struct _GdamPixFontType GdamPixFontType;

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include <gdk/gdk.h>
#include <gtk/gtkobject.h>

/* 
 * GdamPixFontType: represents a class of fonts [each class fixes the layout
 *                  of the characters in the pixmap].
 */
struct _GdamPixFontType {
	char*		name;
	int		num_horizontal;
	int		num_vertical;
	int		max_character;
	char**		character_layout;
};
GdamPixFontType* gdam_pix_font_type_stock   (const char*       layout_name);

/* internal use mostly! */
void             gdam_pix_font_type_register(const char*       type, 
                                             int               num_horizontal,
			                     int               num_vertical,
			                     const char*       text);

GtkType gdam_pix_font_get_type();
#define GDAM_TYPE_PIX_FONT			(gdam_pix_font_get_type ())
#define GDAM_PIX_FONT(obj)              (GTK_CHECK_CAST ((obj), GDAM_TYPE_PIX_FONT, GdamPixFont))
#define GDAM_PIX_FONT_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GDAM_TYPE_PIX_FONT, GdamPixFontClass))
#define GDAM_IS_PIX_FONT(obj)           (GTK_CHECK_TYPE ((obj), GDAM_TYPE_PIX_FONT))
#define GDAM_IS_PIX_FONT_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GDAM_TYPE_PIX_FONT))

struct _GdamPixFontClass {
	GtkObjectClass		object_class;
};

/*
 * GdamPixFontElement: helper class containing information about
 *                     the location of a single glyph within
 *                     the GdamPixFont's pixmap.
 */
struct _GdamPixFontElement {
	int			character;
	int			image_left;
	int			image_top;
	int			image_width;
	int			image_height;
};

/*
 * GdamPixFont: the public class
 */
struct _GdamPixFont {
	GtkObject		object;

	GdamPixFontType*	font_type;
	char*			pixmap_name;
	GdkPixmap*		pixmap;
	int			pixmap_width;
	int			pixmap_height;

	gboolean		is_registered;

	int			num_elements;
	GdamPixFontElement**	font_elements;
};


/* public interface */
GdamPixFont* gdam_pix_font_new_cached     (GdkWindow*       window,
                                           const char*      image_name,
                                           GdamPixFontType* pix_font_type);
void         gdam_pix_font_get_string_size(GdamPixFont*     pix_font,
                                           const char*      string,
				           int*             width_out,
				           int*             height_out);
void         gdam_pix_font_draw_string    (GdamPixFont*     pix_font,
				           GdkDrawable*     destination,
				           GdkGC*           gc,
				           int              dest_left,
				           int              dest_top,
                                           const char*      string);

/* private */
gboolean     gdam_pix_font_construct      (GdamPixFont*     pix_font,
                                           GdkWindow*       window,
				           const char*      image_name,
                                           GdamPixFontType* pix_font_type);
#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif
