2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * label_box.c: GLabels label box 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-box.h"
29 /*========================================================*/
31 /*========================================================*/
33 struct _glLabelBoxPrivate {
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_box_class_init (glLabelBoxClass *klass);
52 static void gl_label_box_instance_init (glLabelBox *lbox);
53 static void gl_label_box_finalize (GObject *object);
56 /*****************************************************************************/
57 /* Boilerplate object stuff. */
58 /*****************************************************************************/
60 gl_label_box_get_type (void)
62 static GType type = 0;
66 sizeof (glLabelBoxClass),
69 (GClassInitFunc) gl_label_box_class_init,
74 (GInstanceInitFunc) gl_label_box_instance_init,
77 type = g_type_register_static (GL_TYPE_LABEL_OBJECT,
78 "glLabelBox", &info, 0);
85 gl_label_box_class_init (glLabelBoxClass *klass)
87 GObjectClass *object_class = (GObjectClass *) klass;
89 parent_class = g_type_class_peek_parent (klass);
91 object_class->finalize = gl_label_box_finalize;
95 gl_label_box_instance_init (glLabelBox *lbox)
97 lbox->private = g_new0 (glLabelBoxPrivate, 1);
101 gl_label_box_finalize (GObject *object)
105 g_return_if_fail (object && GL_IS_LABEL_BOX (object));
107 lbox = GL_LABEL_BOX (object);
109 g_free (lbox->private);
111 G_OBJECT_CLASS (parent_class)->finalize (object);
114 /*****************************************************************************/
115 /* NEW label "box" object. */
116 /*****************************************************************************/
118 gl_label_box_new (glLabel *label)
122 lbox = g_object_new (gl_label_box_get_type(), NULL);
124 gl_label_object_set_parent (GL_LABEL_OBJECT(lbox), label);
126 return G_OBJECT (lbox);
129 /*****************************************************************************/
130 /* Duplicate object. */
131 /*****************************************************************************/
133 gl_label_box_dup (glLabelBox *lbox,
136 glLabelBox *new_lbox;
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 (lbox && GL_IS_LABEL_BOX (lbox));
143 g_return_if_fail (label && GL_IS_LABEL (label));
145 new_lbox = GL_LABEL_BOX(gl_label_box_new (label));
147 gl_label_object_get_position (GL_LABEL_OBJECT(lbox), &x, &y);
148 gl_label_object_get_size (GL_LABEL_OBJECT(lbox), &w, &h);
150 gl_label_object_set_position (GL_LABEL_OBJECT(new_lbox), x, y);
151 gl_label_object_set_size (GL_LABEL_OBJECT(new_lbox), w, h);
153 line_width = gl_label_box_get_line_width (lbox);
154 line_color = gl_label_box_get_line_color (lbox);
155 fill_color = gl_label_box_get_fill_color (lbox);
157 gl_label_box_set_line_width (new_lbox, line_width);
158 gl_label_box_set_line_color (new_lbox, line_color);
159 gl_label_box_set_fill_color (new_lbox, fill_color);
162 gl_debug (DEBUG_LABEL, "END");
168 /*****************************************************************************/
169 /* Set object params. */
170 /*****************************************************************************/
172 gl_label_box_set_line_width (glLabelBox *lbox,
175 g_return_if_fail (lbox && GL_IS_LABEL_BOX (lbox));
177 if ( lbox->private->line_width != line_width ) {
178 lbox->private->line_width = line_width;
179 gl_label_object_emit_changed (GL_LABEL_OBJECT(lbox));
184 gl_label_box_set_line_color (glLabelBox *lbox,
187 g_return_if_fail (lbox && GL_IS_LABEL_BOX (lbox));
189 if ( lbox->private->line_color != line_color ) {
190 lbox->private->line_color = line_color;
191 gl_label_object_emit_changed (GL_LABEL_OBJECT(lbox));
196 gl_label_box_set_fill_color (glLabelBox *lbox,
199 g_return_if_fail (lbox && GL_IS_LABEL_BOX (lbox));
201 if ( lbox->private->fill_color != fill_color ) {
202 lbox->private->fill_color = fill_color;
203 gl_label_object_emit_changed (GL_LABEL_OBJECT(lbox));
207 /*****************************************************************************/
208 /* Get object params. */
209 /*****************************************************************************/
211 gl_label_box_get_line_width (glLabelBox *lbox)
213 g_return_val_if_fail (lbox && GL_IS_LABEL_BOX (lbox), 0.0);
215 return lbox->private->line_width;
219 gl_label_box_get_line_color (glLabelBox *lbox)
221 g_return_val_if_fail (lbox && GL_IS_LABEL_BOX (lbox), 0);
223 return lbox->private->line_color;
227 gl_label_box_get_fill_color (glLabelBox *lbox)
229 g_return_val_if_fail (lbox && GL_IS_LABEL_BOX (lbox), 0);
231 return lbox->private->fill_color;