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);
55 static void copy (glLabelObject *dst_object,
56 glLabelObject *src_object);
58 static void set_fill_color (glLabelObject *object,
61 static void set_line_color (glLabelObject *object,
64 static void set_line_width (glLabelObject *object,
67 static guint get_fill_color (glLabelObject *object);
69 static guint get_line_color (glLabelObject *object);
71 static gdouble get_line_width (glLabelObject *object);
75 /*****************************************************************************/
76 /* Boilerplate object stuff. */
77 /*****************************************************************************/
79 gl_label_ellipse_get_type (void)
81 static GType type = 0;
85 sizeof (glLabelEllipseClass),
88 (GClassInitFunc) gl_label_ellipse_class_init,
91 sizeof (glLabelEllipse),
93 (GInstanceInitFunc) gl_label_ellipse_instance_init,
96 type = g_type_register_static (GL_TYPE_LABEL_OBJECT,
97 "glLabelEllipse", &info, 0);
104 gl_label_ellipse_class_init (glLabelEllipseClass *klass)
106 GObjectClass *object_class = (GObjectClass *) klass;
107 glLabelObjectClass *label_object_class = (glLabelObjectClass *) klass;
109 parent_class = g_type_class_peek_parent (klass);
111 label_object_class->copy = copy;
112 label_object_class->set_fill_color = set_fill_color;
113 label_object_class->set_line_color = set_line_color;
114 label_object_class->set_line_width = set_line_width;
115 label_object_class->get_fill_color = get_fill_color;
116 label_object_class->get_line_color = get_line_color;
117 label_object_class->get_line_width = get_line_width;
119 object_class->finalize = gl_label_ellipse_finalize;
123 gl_label_ellipse_instance_init (glLabelEllipse *lellipse)
125 lellipse->private = g_new0 (glLabelEllipsePrivate, 1);
129 gl_label_ellipse_finalize (GObject *object)
131 glLabelEllipse *lellipse;
133 g_return_if_fail (object && GL_IS_LABEL_ELLIPSE (object));
135 lellipse = GL_LABEL_ELLIPSE (object);
137 g_free (lellipse->private);
139 G_OBJECT_CLASS (parent_class)->finalize (object);
142 /*****************************************************************************/
143 /* NEW label "ellipse" object. */
144 /*****************************************************************************/
146 gl_label_ellipse_new (glLabel *label)
148 glLabelEllipse *lellipse;
150 lellipse = g_object_new (gl_label_ellipse_get_type(), NULL);
152 gl_label_object_set_parent (GL_LABEL_OBJECT(lellipse), label);
154 return G_OBJECT (lellipse);
157 /*****************************************************************************/
158 /* Copy object contents. */
159 /*****************************************************************************/
161 copy (glLabelObject *dst_object,
162 glLabelObject *src_object)
164 glLabelEllipse *lellipse = (glLabelEllipse *)src_object;
165 glLabelEllipse *new_lellipse = (glLabelEllipse *)dst_object;
167 guint line_color, fill_color;
169 gl_debug (DEBUG_LABEL, "START");
171 g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
172 g_return_if_fail (new_lellipse && GL_IS_LABEL_ELLIPSE (new_lellipse));
174 line_width = get_line_width (src_object);
175 line_color = get_line_color (src_object);
176 fill_color = get_fill_color (src_object);
178 set_line_width (dst_object, line_width);
179 set_line_color (dst_object, line_color);
180 set_fill_color (dst_object, fill_color);
182 gl_debug (DEBUG_LABEL, "END");
186 /*---------------------------------------------------------------------------*/
187 /* PRIVATE. Set fill color method. */
188 /*---------------------------------------------------------------------------*/
190 set_fill_color (glLabelObject *object,
193 glLabelEllipse *lellipse = (glLabelEllipse *)object;
195 g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
197 if ( lellipse->private->fill_color != fill_color ) {
198 lellipse->private->fill_color = fill_color;
199 gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
203 /*---------------------------------------------------------------------------*/
204 /* PRIVATE. Set line color method. */
205 /*---------------------------------------------------------------------------*/
207 set_line_color (glLabelObject *object,
210 glLabelEllipse *lellipse = (glLabelEllipse *)object;
212 g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
214 if ( lellipse->private->line_color != line_color ) {
215 lellipse->private->line_color = line_color;
216 gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
220 /*---------------------------------------------------------------------------*/
221 /* PRIVATE. Set line width method. */
222 /*---------------------------------------------------------------------------*/
224 set_line_width (glLabelObject *object,
227 glLabelEllipse *lellipse = (glLabelEllipse *)object;
229 g_return_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse));
231 if ( lellipse->private->line_width != line_width ) {
232 lellipse->private->line_width = line_width;
233 gl_label_object_emit_changed (GL_LABEL_OBJECT(lellipse));
238 /*---------------------------------------------------------------------------*/
239 /* PRIVATE. Get fill color method. */
240 /*---------------------------------------------------------------------------*/
242 get_line_width (glLabelObject *object)
244 glLabelEllipse *lellipse = (glLabelEllipse *)object;
246 g_return_val_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse), 0.0);
248 return lellipse->private->line_width;
251 /*---------------------------------------------------------------------------*/
252 /* PRIVATE. Get line color method. */
253 /*---------------------------------------------------------------------------*/
255 get_line_color (glLabelObject *object)
257 glLabelEllipse *lellipse = (glLabelEllipse *)object;
259 g_return_val_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse), 0);
261 return lellipse->private->line_color;
264 /*---------------------------------------------------------------------------*/
265 /* PRIVATE. Get line width method. */
266 /*---------------------------------------------------------------------------*/
268 get_fill_color (glLabelObject *object)
270 glLabelEllipse *lellipse = (glLabelEllipse *)object;
272 g_return_val_if_fail (lellipse && GL_IS_LABEL_ELLIPSE (lellipse), 0);
274 return lellipse->private->fill_color;