]> git.sur5r.net Git - glabels/commitdiff
Text box refinement.
authorJim Evins <evins@snaught.com>
Thu, 16 Jan 2003 03:49:37 +0000 (03:49 +0000)
committerJim Evins <evins@snaught.com>
Thu, 16 Jan 2003 03:49:37 +0000 (03:49 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@244 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/label-text.c
glabels2/src/label-text.h
glabels2/src/print.c
glabels2/src/view-text.c

index d60c2295ffa098e07388b281843b8dfbc89dd3eb..955738224634413da6d6e7d9239d76ee8707421e 100644 (file)
@@ -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);
 
index f26acce91fa9a91a678d07890bfa967452c51188..45fb818aa5423524eb47efc54a704ad440db4c69 100644 (file)
@@ -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))
index d44661c946eca959599820ba71ea01dcbbdd7267..1807d95983ade828f0638b64aa7dc0e61ae277a5 100644 (file)
@@ -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);
 
index a9d17c1fe95f300ad549c29aecf4a6d1a15a2f58..d887918c9b42f2bfc30ac7e3920b5af5a4c6906b 100644 (file)
@@ -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));