/*  Copyright (C) 2008--2009 Joshua Judson Rosen <rozzin@geekspace.com>.

    This program 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 3
    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 Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program; see the file COPYING. If not, see
    <http://www.gnu.org/licenses/> or write to:

        The Free Software Foundation, inc.
        51 Franklin Street, Fifth Floor
        Boston, MA 02110-1301
        USA
*/

#ifndef VISUALID_GRAPHICS_H
#define VISUALID_GRAPHICS_H

#include <virand/generator.h>
#include <libvisualid/generator.h>


typedef struct _VisualID_Glyph VisualID_Glyph;
typedef struct _VisualID_GlyphClass VisualID_GlyphClass;


typedef void (visualid_render_fn) (VisualID_Glyph *glyph, cairo_t *cr);
typedef VisualID_Glyph * (visualid_mutation_fn) (VisualID_Glyph *base,
                                                 double amount);
typedef int (visualid_complexity_fn) (VisualID_Glyph *glyph, int recurse);

struct _VisualID_Glyph {
  GInitiallyUnowned parent_instance;

  VisualID_Glyph *parent_glyph;
  VisualID_Generator *generator;
  int recursion_level;
};

VisualID_Glyph *visualid_glyph_new (VisualID_Generator *generator);
VisualID_Glyph *visualid_glyph_spawn (VisualID_Glyph *parent,
                                      const char *attachment);
gboolean visualid_glyph_extend (VisualID_Glyph *glyph, int level);

void visualid_draw_path (VisualID_Glyph *glyph, cairo_t *cr);

void visualid_draw (VisualID_Glyph *gen, cairo_t *cr,
                    double width, double height,
                    double linewidth);

int visualid_glyph_complexity (VisualID_Glyph *glyph, int recurse);


#define VISUALID_TYPE_GLYPH            (visualid_glyph_get_type ())
#define VISUALID_GLYPH(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VISUALID_TYPE_GLYPH, VisualID_Glyph))
#define VISUALID_IS_GLYPH(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VISUALID_TYPE_GLYPH))
#define VISUALID_GLYPH_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), VISUALID_TYPE_GLYPH, VisualID_GlyphClass))
#define VISUALID_IS_GLYPH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VISUALID_TYPE_GLYPH))
#define VISUALID_GLYPH_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), VISUALID_TYPE_GLYPH, VisualID_GlyphClass))

struct _VisualID_GlyphClass
{
  GInitiallyUnownedClass parent_class;

  gboolean (*extend) (VisualID_Glyph *glyph, int level);

  visualid_render_fn *render;
  visualid_mutation_fn *mutate;
  visualid_complexity_fn *complexity_fn;
};

GType visualid_glyph_get_type (void);


/* The following procedures are for use only in implementing new
   glyph-types:
*/

void visualid_glyph_take_child (VisualID_Glyph *glyph, VisualID_Glyph *orphan,
                                VisualID_Glyph **attachment);
void visualid_glyph_unparent (VisualID_Glyph *child);

/* void visualid_group ( */
#endif

