#ifndef __FIGURE_H
#define __FIGURE_H

#include "line.h"
#include "cpos.h"
#include "graph.h"
#include "list/list.h"

enum { STARTPOINT, ENDPOINT };
enum { NOTHING, UPPER, LOWER, LEFT, RIGHT, REALUPPER, REALLOWER, REALRIGHT, REALLEFT };
enum { LOAD_OK,DATEIFEHLER, KEINENSPRITENAMEN, KEINESPRITEKENNUNG, KEINEDBKENNUNG, KEINELINIENANZAHL };

class Figure: public GObject, public Graph
{
  public:
    Figure( Screen* newScreen );
    Figure( Figure& figure ); // Copyconstructor
    virtual ~Figure( void );

    Figure& operator= ( Figure& figure );

    virtual void draw( void );
    virtual void draw1( void );
    virtual void move( int dx, int dy );
    virtual void moveTo( int newX, int newY );
    virtual void saveBackground( void );
    virtual void restoreBackground();
    virtual void set( int x, int y );
    virtual Bool isOver( int x, int y );
    Line* isOverLine( int x, int y );

    virtual void setColor( Color color );

    virtual int save( ofstream& out );
    virtual int save( char* fileName );
    virtual int load( ifstream& out );
//  virtual void load( char* fileName );

    //
    // from class Graph
    //
    virtual void remove( Line* nl );
    virtual void append( Line* nl );
    virtual int  sort( Position startPosition );

// new functions
    void  clearLines( void );
    void  setScale( int dx, int dy );
    void  scale( int newDx, int newDy );
    int   getSize( void );
    char* getName( void );
    void  setName( char* newName );
    int  setStartPos( int p );
    int  setStartPos( Position& p );
    Position  getStartPos( void );
    void  setBlowup( char* blowup );
    LineList* getLineFromPosition( int x, int y );
    int   isOverPoint( int x0, int y0 );
    void  changedLine( Line* );
    void  showStartPoint( int r = 2 );

    void mirror_x( void );
    void mirror_y( void );
    virtual int  North( void );
    virtual int  South( void );
    virtual int  East( void );
    virtual int  West( void );

  protected:
    Position _findStartPosition( int p ); // UPPER, LOWER, ...
    inline int getNextIntPos( char* line, int pos );
    void  getBlowup( char* line );

    Line* lineOver;      // die Zeile die isOver gefunden hat
    int   dx, dy;
    char  name[256];
    Position startPosition;
    char  blowup[200];
    static int number;
    int   north, south, east, west;
};

#endif // __FIGURE_H
