source: trunk/third/gtkhtml3/src/htmlanchor.c @ 21116

Revision 21116, 3.2 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21115, 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) 1997 Martin Jones (mjones@kde.org)
5   Copyright (C) 1997 Torben Weis (weis@kde.org)
6   Copyright (C) 1999, 2000 Helix Code, Inc.
7
8   This library is free software; you can redistribute it and/or
9   modify it under the terms of the GNU Library General Public
10   License as published by the Free Software Foundation; either
11   version 2 of the License, or (at your option) any later version.
12
13   This library is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16   Library General Public License for more details.
17
18   You should have received a copy of the GNU Library General Public License
19   along with this library; see the file COPYING.LIB.  If not, write to
20   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21   Boston, MA 02111-1307, USA.
22*/
23
24#include <config.h>
25#include <string.h> /* strcmp() */
26#include "htmlanchor.h"
27
28
29HTMLAnchorClass html_anchor_class;
30static HTMLObjectClass *parent_class = NULL;
31
32
33/* HTMLObject methods.  */
34
35static void
36destroy (HTMLObject *object)
37{
38        HTMLAnchor *anchor;
39
40        anchor = HTML_ANCHOR (object);
41
42        g_string_free (anchor->name, TRUE);
43
44        HTML_OBJECT_CLASS (parent_class)->destroy (object);
45}
46
47static void
48copy (HTMLObject *self,
49      HTMLObject *dest)
50{
51        (* HTML_OBJECT_CLASS (parent_class)->copy) (self, dest);
52
53        HTML_ANCHOR (dest)->name = g_string_new (HTML_ANCHOR (self)->name->str);
54}
55
56static HTMLAnchor *
57find_anchor (HTMLObject *o, const char *name, gint *x, gint *y)
58{
59        if (strcmp (name, HTML_ANCHOR(o)->name->str) == 0) {
60                *x += o->x;
61                *y += o->y;
62
63                return HTML_ANCHOR (o);
64        }
65        return NULL;
66}
67
68static HTMLObject *
69check_point (HTMLObject *self,
70             HTMLPainter *painter,
71             gint x, gint y,
72             guint *offset_return,
73             gboolean for_cursor)
74{
75        return NULL;
76}
77
78static gboolean
79html_anchor_real_calc_size (HTMLObject *self, HTMLPainter *painter, GList **changed_objs)
80{
81        self->width = 0;
82        self->ascent = 1;
83        self->descent = 0;
84
85        return FALSE;
86}
87
88void
89html_anchor_type_init (void)
90{
91        html_anchor_class_init (&html_anchor_class, HTML_TYPE_ANCHOR, sizeof (HTMLAnchor));
92}
93
94void
95html_anchor_class_init (HTMLAnchorClass *klass,
96                        HTMLType type,
97                        guint object_size)
98{
99        HTMLObjectClass *object_class;
100
101        object_class = HTML_OBJECT_CLASS (klass);
102
103        html_object_class_init (object_class, type, object_size);
104
105        object_class->destroy = destroy;
106        object_class->copy = copy;
107        object_class->find_anchor = find_anchor;
108        object_class->check_point = check_point;
109        object_class->calc_size = html_anchor_real_calc_size;
110
111        parent_class = &html_object_class;
112}
113
114void
115html_anchor_init (HTMLAnchor *anchor,
116                  HTMLAnchorClass *klass,
117                  const gchar *name)
118{
119        html_object_init (HTML_OBJECT (anchor), HTML_OBJECT_CLASS (klass));
120
121        anchor->name = g_string_new (name);
122}
123
124HTMLObject *
125html_anchor_new (const gchar *name)
126{
127        HTMLAnchor *anchor;
128
129        anchor = g_new (HTMLAnchor, 1);
130        html_anchor_init (anchor, &html_anchor_class, name);
131
132        return HTML_OBJECT (anchor);
133}
134
135
136const gchar *
137html_anchor_get_name (HTMLAnchor *anchor)
138{
139        return anchor->name->str;
140}
Note: See TracBrowser for help on using the repository browser.