gtans.h 5.07 KB
Newer Older
Yves Combe's avatar
Yves Combe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200


#define AN_none 0
#define AN_move 1
#define AN_rot 2

#define ARON 0.39999

#define mPI 3.14159265356
#define TOUR 65536
#define PASTOUR (mPI/TOUR*2)
#define CL 1.4142135624
#define CC CL/2
#define HT TOUR/8
#define TYPENBR 5    /* nombre de type de pieces */
#define PIECENBR 7   /* nombre de pieces par figure */
#define TRINBRMAX 4  /* nombre de triangle max par piece */
#define PNTNBRMAX 4  /* nombre de points max par piece */
#define TINYNBR 32   /* nombre de tiny triangles */

/* gc (couleur ou (couleur ou texture)) */
#define GRISNBR 8
#define GCPIECENOR  GRISNBR
#define GCPIECEHI   GRISNBR+1
#define GCPIECEBG   GRISNBR+2
#define GCPIECEHLP  GRISNBR+3
#define GCPETITEFG  GRISNBR+4
#define GCPETITEBG  GRISNBR+5
#define GCPETITECHK GRISNBR+6
#define GCPETITEHLP GRISNBR+7

#define GCPIECELAST   GCPIECEHLP
#define GCPETITEFIRST GCPETITEFG
#define GCNBR GCPETITEHLP+1

/* gc (couleur ou texture) */
#define PXNBR      3
#define PXSTART    GCPIECENOR


typedef enum
{
  TAN_PIECENOR=5,
  TAN_PIECEHI,
  TAN_PETITEFG,
  TAN_PETITEHLP
} tanremplis;

typedef enum
{
  TAN_POLYNORMAL=5,
  TAN_POLYBACK,
  TAN_POLYON,
} tanpolytype;

/* polygone (uniquement pour le calcul de la floatfig) */
typedef struct _tanpoly {
  int pntnbr;
  tanpolytype polytype;
  int firstpnt;
} tanpoly;

/* petit (et tiny) triangle */
typedef struct _tansmalltri tantinytri;
typedef struct _tansmalltri {
  double posx;
  double posy;
  int rot;
} tansmalltri;

/* point */
typedef struct _tanfpnt {
  double posx;
  double posy;
} tanfpnt;

/* definition d'une piece */
typedef struct _tanpiecedef {
  double handlex;     /* centre de gravite x */
  double handley;
  int trinbr;         /* nombre de petits triangles */
  tansmalltri tri[TRINBRMAX];
  int pntnbr;         /* nombre de points du polygone */
  tanfpnt pnt[PNTNBRMAX];
} tanpiecedef;

 /* position d'une piece */
typedef struct _tanpiecepos {
  int type;
  int flipped;
  double posx;
  double posy;
  int rot;
} tanpiecepos;

/* figure (jeu de pieces) */
typedef struct _tanfigure {
  double zoom;           /* non utilise */
  double distmax;        /* en principe ==1.0 */
  int drotmax;           /* non utilise */
  gboolean reussi;
  tanpiecepos piecepos[PIECENBR];
} tanfigure;

/* flpiece */
typedef struct _tanflpiece {
  int flpntnbr;
  tanpolytype polytype;
  tanfpnt *flpnts;
} tanflpiece;

/* flfig */
typedef struct _tanflfig {
  tanfigure *figure;
  int flpiecenbr;
  tanflpiece flpieces[PIECENBR];
} tanflfig;



extern GtkWidget *mainwindow;
extern GtkWidget *widgetgrande;        /* widget de la grande drawarea */
extern GtkWidget *widgetpetite;        /* widget de la petite drawarea */
extern GtkStatusbar *widgetstat;       /* widget de la statusbar */
extern GtkSpinButton *spinner;

extern gint statconid;                 /* context id de la statusbar */
extern GdkRectangle selbackrect;       /* rectangle a redessiner pour effacer la piece selected */

extern GdkPixmap *pixmapgrande1,*pixmapgrande2;
extern GdkPixmap *pixmappetite;
extern GdkPixmap *pixmappiece1,*pixmappiece2,*pixmapfond;

extern GtkWidget *colselwin,*filselwin;


extern tanpiecedef piecesdef[];

extern tanfigure figuredebut;

extern tanfigure *figtab;
extern int figtabsize;
extern int figactualnr;
extern char *figfilename;

extern tantinytri tinytabpe[TINYNBR],tinytabgr[TINYNBR];
extern tanfigure figgrande,figpetite;
extern int selectedgrande;
extern int xact,yact,xoth,yoth,xold,yold;
extern int actiongrande;
extern int selpossible;
extern int rotact,rotnew,rotold;

extern int rotstepnbr;            /* nb. de pas de rotation */
extern int initcbgr,initcbpe;     /* init cb deja appellee ? */

extern GdkGC *invertgc;
extern int invx2,invy2;

extern GdkGC *tabgc[GCNBR];
extern GdkColor colortab[GCNBR];
extern GdkPixmap **tabpxpx;
extern char **tabpxnam;

extern gboolean helpoutset;
extern gboolean helptanset;
extern int accuracy;

extern gboolean editmode;


void     tanclampgrandefig (void);
void     tanrecentreout(double oldzoom, double newzoom);
void     tanclearreussinr (int fignr);
void     tansetreussiactual (void);
void     tanreleaseifrot (void);
int      tanangle (double dx, double dy);
void     spesavefig (void);
void     tanend(void);
gboolean tanloadfigtab (char *name);
gboolean tansetpixmapmode(GtkWidget *widget, char *aname, int gcnbr);
void     tansetcolormode(GdkColor *acolor, int gcnbr);
void     tanredrawgrande (void);
void     tanredrawpetite (void);
gboolean tansaveconfig (void);
void     taninitcbgr(void);
void     taninitcbpe(void);
int      tanwichisselect(int x, int y);
void     tansetnewfigurepart2(void);
void     tansetnewfigurepart1(int nrfig);
void     tanunselect (void);
void     tandrawselect(int dx, int dy, int drot);
void     taninitselect(int selected, gboolean necessaire);
void     tantranstinytab (tantinytri *tinys);
void     tanmaketinytabnotr (tanfigure *figure, tantinytri *tinys);
gboolean tantinytabcompare (tantinytri *tinys1, tantinytri *tinys2, int accuracy);
void     tancolle (tanfigure *figure, double seuil);
void     tanstatprov (gchar *msg);
void     tanstatpop (void);
void     tanstatpush (gchar *msg);
201
void     change_figure(gboolean next);
Yves Combe's avatar
Yves Combe committed
202 203 204 205 206 207 208 209 210 211 212 213 214