From: Jim Evins Date: Thu, 16 Jan 2003 03:49:37 +0000 (+0000) Subject: Text box refinement. X-Git-Tag: glabels-2_3_0~644 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=68b7f3520db383f2ca7000533e63c39f3f07f7c7;p=glabels Text box refinement. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@244 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/label-text.c b/glabels2/src/label-text.c index d60c2295..95573822 100644 --- a/glabels2/src/label-text.c +++ b/glabels2/src/label-text.c @@ -377,6 +377,12 @@ get_size (glLabelObject *object, (* parent_class->get_size) (object, &w_parent, &h_parent); + if ( (w_parent != 0.0) || (h_parent != 0.0) ) { + *w = w_parent; + *h = h_parent; + return; + } + font = gnome_font_find_closest_from_weight_slant ( ltext->private->font_family, ltext->private->font_weight, @@ -409,8 +415,9 @@ get_size (glLabelObject *object, if ( *h == 0.0 ) *h = ltext->private->font_size; - if ( *w < w_parent ) *w = w_parent; - if ( *h < h_parent ) *h = h_parent; + *w += 2*GL_LABEL_TEXT_MARGIN; + *h += 2*GL_LABEL_TEXT_MARGIN; + g_strfreev (line); diff --git a/glabels2/src/label-text.h b/glabels2/src/label-text.h index f26acce9..45fb818a 100644 --- a/glabels2/src/label-text.h +++ b/glabels2/src/label-text.h @@ -30,6 +30,8 @@ G_BEGIN_DECLS +#define GL_LABEL_TEXT_MARGIN 3.0 + #define GL_TYPE_LABEL_TEXT (gl_label_text_get_type ()) #define GL_LABEL_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_LABEL_TEXT, glLabelText)) diff --git a/glabels2/src/print.c b/glabels2/src/print.c index d44661c9..1807d959 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -667,21 +667,21 @@ draw_text_object (PrintInfo *pi, switch (just) { case GTK_JUSTIFY_LEFT: - x_offset = 0.0; + x_offset = GL_LABEL_TEXT_MARGIN; break; case GTK_JUSTIFY_CENTER: - x_offset = (object_w - w) / 2.0; + x_offset = (object_w - GL_LABEL_TEXT_MARGIN - w) / 2.0; break; case GTK_JUSTIFY_RIGHT: - x_offset = object_w - w; + x_offset = object_w - GL_LABEL_TEXT_MARGIN - w; break; default: x_offset = 0.0; break; /* shouldn't happen */ } - y_offset = (i + 1) * font_size - + gnome_font_get_descender (font); + y_offset = GL_LABEL_TEXT_MARGIN + (i + 1) * font_size + + gnome_font_get_descender (font); gnome_print_moveto (pi->pc, x_offset, y_offset); diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index a9d17c1f..d887918c 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -758,20 +758,20 @@ draw_hacktext (glViewText *view_text) switch (just) { case GTK_JUSTIFY_LEFT: - x_offset = 0.0; + x_offset = GL_LABEL_TEXT_MARGIN; break; case GTK_JUSTIFY_CENTER: - x_offset = (object_w - w) / 2.0; + x_offset = (object_w - GL_LABEL_TEXT_MARGIN - w) / 2.0; break; case GTK_JUSTIFY_RIGHT: - x_offset = object_w - w; + x_offset = object_w - GL_LABEL_TEXT_MARGIN - w; break; default: x_offset = 0.0; break; /* shouldn't happen */ } - y_offset = + y_offset = GL_LABEL_TEXT_MARGIN + (i + 1) * font_size + gnome_font_get_descender (font); item = gl_view_object_item_new (GL_VIEW_OBJECT(view_text), @@ -868,13 +868,13 @@ draw_cursor (glViewText *view_text) switch (just) { case GTK_JUSTIFY_LEFT: - x_offset = 0.0; + x_offset = GL_LABEL_TEXT_MARGIN; break; case GTK_JUSTIFY_CENTER: - x_offset = (object_w - w) / 2.0; + x_offset = (object_w - GL_LABEL_TEXT_MARGIN - w) / 2.0; break; case GTK_JUSTIFY_RIGHT: - x_offset = object_w - w; + x_offset = object_w - GL_LABEL_TEXT_MARGIN - w; break; default: x_offset = 0.0; @@ -891,9 +891,9 @@ draw_cursor (glViewText *view_text) points = gnome_canvas_points_new (2); points->coords[0] = x_offset; - points->coords[1] = i*font_size; + points->coords[1] = GL_LABEL_TEXT_MARGIN + i*font_size; points->coords[2] = x_offset; - points->coords[3] = (i+1)*font_size; + points->coords[3] = GL_LABEL_TEXT_MARGIN + (i+1)*font_size; if (view_text->private->cursor) { gtk_object_destroy (GTK_OBJECT (view_text->private->cursor));