3
* This is a plug-in for the GIMP.
5
* Generates clickable image maps.
7
* Copyright (C) 1998-1999 Maurits Rijk lpeek.mrijk@consunet.nl
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
#include "imap_circle.h"
30
#include "imap_file.h"
31
#include "imap_main.h"
32
#include "imap_polygon.h"
33
#include "imap_rectangle.h"
34
#include "imap_string.h"
36
extern int ncsa_lex();
37
extern int ncsa_restart();
38
static void ncsa_error(char* s);
40
static Object_t *current_object;
50
%token<val> RECTANGLE POLYGON CIRCLE DEFAULT
51
%token<val> AUTHOR TITLE DESCRIPTION BEGIN_COMMENT
53
%token<id> LINK COMMENT
57
ncsa_file : comment_lines area_list
60
comment_lines : /* empty */
61
| comment_lines comment_line
64
comment_line : author_line
70
real_comment : BEGIN_COMMENT COMMENT
75
author_line : AUTHOR COMMENT
77
MapInfo_t *info = get_map_info();
78
g_strreplace(&info->author, $2);
82
title_line : TITLE COMMENT
84
MapInfo_t *info = get_map_info();
85
g_strreplace(&info->title, $2);
89
description_line: DESCRIPTION COMMENT
91
MapInfo_t *info = get_map_info();
94
description = g_strconcat(info->description, $2, "\n",
96
g_strreplace(&info->description, description);
100
area_list : /* Empty */
111
default : DEFAULT LINK
113
MapInfo_t *info = get_map_info();
114
g_strreplace(&info->default_url, $2);
119
rectangle : RECTANGLE LINK FLOAT ',' FLOAT FLOAT ',' FLOAT
123
gint width = (gint) fabs($6 - x);
124
gint height = (gint) fabs($8 - y);
125
current_object = create_rectangle(x, y, width, height);
126
object_set_url(current_object, $2);
127
add_shape(current_object);
131
circle : CIRCLE LINK FLOAT ',' FLOAT FLOAT ',' FLOAT
135
gint r = (gint) fabs($8 - $5);
136
current_object = create_circle(x, y, r);
137
object_set_url(current_object, $2);
138
add_shape(current_object);
142
polygon : POLYGON LINK {current_object = create_polygon(NULL);} coord_list
144
object_set_url(current_object, $2);
145
add_shape(current_object);
149
coord_list : /* Empty */
155
coord : FLOAT ',' FLOAT
157
Polygon_t *polygon = ObjectToPolygon(current_object);
158
GdkPoint *point = new_point((gint) $1, (gint) $3);
159
polygon->points = g_list_append(polygon->points,
169
extern FILE *ncsa_in;
170
ncsa_restart(ncsa_in);
174
load_ncsa(const char* filename)
177
extern FILE *ncsa_in;
178
ncsa_in = fopen(filename, "r");
180
status = !ncsa_parse();