source: trunk/third/gtkhtml3/src/htmlmap.c @ 19539

Revision 19539, 1.8 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r19538, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* This file is part of the GtkHTML library.
3   
4   Copyright (C) 2001, Ximian, Inc.
5
6   This library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Library General Public
8   License as published by the Free Software Foundation; either
9   version 2 of the License, or (at your option) any later version.
10
11   This library is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   Library General Public License for more details.
15
16   You should have received a copy of the GNU Library General Public License
17   along with this library; see the file COPYING.LIB.  If not, write to
18   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19   Boston, MA 02111-1307, USA.
20*/
21
22
23#include <config.h>
24#include <string.h>
25#include <glib.h>
26#include "htmlmap.h"
27#include "htmlshape.h"
28
29void
30html_map_destroy (HTMLMap *map)
31{
32        gint i;
33
34        for (i = 0; i < map->shapes->len; i++)
35                html_shape_destroy (g_ptr_array_index (map->shapes, i));
36       
37        g_ptr_array_free (map->shapes, FALSE);
38        map->shapes = NULL;
39
40        g_free (map->name);
41        g_free (map);
42}
43
44void
45html_map_add_shape (HTMLMap *map, HTMLShape *shape)
46{
47        g_return_if_fail (shape != NULL);
48
49        g_ptr_array_add (map->shapes, shape);
50}
51
52char *
53html_map_calc_point (HTMLMap *map, gint x, gint y)
54{
55        int i;
56
57        for (i = 0; i < map->shapes->len; i++) {
58                HTMLShape *shape;
59                shape = g_ptr_array_index (map->shapes, i);
60
61                if (html_shape_point (shape, x, y)) {
62                        return html_shape_get_url (shape);
63                }               
64        }
65        return NULL;
66}
67
68HTMLMap *
69html_map_new (const gchar *name)
70{
71        HTMLMap *map;
72
73        map = g_new (HTMLMap, 1);
74        map->shapes = g_ptr_array_new ();
75        map->name = g_strdup (name);
76
77        return map;
78}
Note: See TracBrowser for help on using the repository browser.