2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * label_ellipse.c: GLabels label ellipse object
6 * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program 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
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "label-ellipse.h"
29 /*========================================================*/
31 /*========================================================*/
33 struct _glLabelEllipsePrivate {
39 /*========================================================*/
40 /* Private globals. */
41 /*========================================================*/
43 static GObjectClass *parent_class = NULL;
45 static guint instance = 0;
47 /*========================================================*/
48 /* Private function prototypes. */
49 /*========================================================*/
51 static void gl_label_ellipse_class_init (glLabelEllipseClass *klass);
52 static void gl_label_ellipse_instance_init (glLabelEllipse *lellipse);
53 static void gl_label_ellipse_finalize (GObject *object);
56 /*****************************************************************************/
57 /* Boilerplate object stuff. */
58 /*****************************************************************************/
60 gl_label_ellipse_get_type (void)
62 static GType type = 0;
66 sizeof (glLabelEllipseClass),
69 (GClassInitFunc) gl_label_ellipse_class_init,
72 sizeof (glLabelEllipse),
74 (GInstanceInitFunc) gl_label_ellipse_instance_init,
77 type = g_type_register_static (GL_TYPE_LABEL_OBJECT,
78 "glLabelEllipse", &info, 0);
85 gl_label_ellipse_class_init (glLabelEllipseClass *klass)
87 GObjectClass *object_class = (GObjectClass *) klass;
89 parent_class = g_type_class_peek_parent (klass);
91 object_class->finalize = gl_label_ellipse_finalize;
95 gl_label_ellipse_instance_init (glLabelEllipse *lellipse)
97 lellipse->private = g_new0 (glLabelEllipsePrivate, 1);
101 gl_label_ellipse_finalize (GObject *object)
103 glLabelEllipse *lellipse;
105 g_return_if_fail (object && GL_IS_LABEL_ELLIPSE (object));
107 lellipse = GL_LABEL_ELLIPSE (object);
109 g_free (lellipse->private);
111 G_OBJECT_CLASS (parent_class)->finalize (object);
114 /*****************************************************************************/
115 /* NEW label "ellipse" object. */
116 /*****************************************************************************/
118 gl_label_ellipse_new (glLabel *label)
120 glLabelEllipse *lellipse;
122 lellipse = g_object_new (gl_label_ellipse_get_type(), NULL);
124 gl_label_object_set_parent (GL_LABEL_OBJECT(lellipse), label);
126 return G_OBJECT (lellipse);
129 /*****************************************************************************/
130 /* Duplicate object. */
131 /*****************************************************************************/
133 gl_label_ellipse_dup (glLabelEllipse *lellipse,
136 glLabelEllipse *new_lellipse;
137 gdouble x, y, w, h, line_width;
138 guint line_color, fill_color;
140 gl_debug (DEBUG_LABEL, "START");
142 g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
143 g_return_if_fail (label && GL_IS_LABEL (label));
145 new_lellipse = GL_LABEL_ELLIPSE(gl_label_ellipse_new (label));
147 gl_label_object_get_position (GL_LABEL_OBJECT(lellipse), &x, &y);
148 gl_label_object_get_size (GL_LABEL_OBJECT(lellipse), &w, &h);
150 gl_label_object_set_position (GL_LABEL_OBJECT(new_lellipse), x, y);
151 gl_label_object_set_size (GL_LABEL_OBJECT(new_lellipse), w, h);
153 line_width = gl_label_ellipse_get_line_width (lellipse);
154 line_color = gl_label_ellipse_get_line_color (lellipse);
155 fill_color = gl_label_ellipse_get_fill_color (lellipse);
157 gl_label_ellipse_set_line_width (new_lellipse, line_width);
158 gl_label_ellipse_set_line_color (new_lellipse, line_color);
159 gl_label_ellipse_set_fill_color (new_lellipse, fill_color);
161 gl_debug (DEBUG_LABEL, "END");
167 /*****************************************************************************/
168 /* Set object params. */
169 /*****************************************************************************/
171 gl_label_ellipse_set_line_width (glLabelEllipse *lellipse,
174 g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
176 if ( lellipse->private->line_width != line_width ) {
177 lellipse->private->line_width = line_width;
178 gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
183 gl_label_ellipse_set_line_color (glLabelEllipse *lellipse,
186 g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
188 if ( lellipse->private->line_color != line_color ) {
189 lellipse->private->line_color = line_color;
190 gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
195 gl_label_ellipse_set_fill_color (glLabelEllipse *lellipse,
198 g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
200 if ( lellipse->private->fill_color != fill_color ) {
201 lellipse->private->fill_color = fill_color;
202 gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
206 /*****************************************************************************/
207 /* Get object params. */
208 /*****************************************************************************/
210 gl_label_ellipse_get_line_width (glLabelEllipse *lellipse)
212 g_return_val_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse), 0.0);
214 return lellipse->private->line_width;
218 gl_label_ellipse_get_line_color (glLabelEllipse *lellipse)
220 g_return_val_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse), 0);
222 return lellipse->private->line_color;
226 gl_label_ellipse_get_fill_color (glLabelEllipse *lellipse)
228 g_return_val_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse), 0);
230 return lellipse->private->fill_color;