Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/estyle
Dir : e17/libs/estyle/src
Modified Files:
Estyle_private.h estyle.c
Log Message:
Duplicate spaces at the end of a string, this works around the sizing issues
in evas text objects.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/estyle/src/Estyle_private.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- Estyle_private.h 14 Jan 2003 18:50:37 -0000 1.10
+++ Estyle_private.h 4 Aug 2003 17:17:13 -0000 1.11
@@ -67,6 +67,12 @@
int length;
/*
+ * Count of spaces at end of string to determine what was duplicated
+ * for sizing workaround.
+ */
+ int spaces;
+
+ /*
* Callbacks.
*/
Evas_List *callbacks;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/estyle/src/estyle.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- estyle.c 23 Jul 2003 21:54:09 -0000 1.24
+++ estyle.c 4 Aug 2003 17:17:13 -0000 1.25
@@ -49,8 +49,7 @@
* Create the Evas_Object and set the default font and font size.
*/
es->bit = evas_object_text_add(es->evas);
- evas_object_text_font_set(es->bit,DEFAULT_FONT,DEFAULT_SIZE);
- evas_object_text_text_set(es->bit,text);
+ evas_object_text_font_set(es->bit, DEFAULT_FONT, DEFAULT_SIZE);
/*
* Set some default colors, font, and font size.
@@ -66,16 +65,7 @@
if (es->style)
_estyle_style_draw(es, text);
- /*
- * Set length and dimensions.
- */
- es->length = strlen(text);
- __estyle_update_dimensions(es);
-
- /*
- * move to (0,0) by default. (is this necessary? -redalb)
- */
- /* estyle_move(es, 0, 0); */
+ estyle_set_text(es, text);
return es;
}
@@ -326,15 +316,25 @@
*/
char *estyle_get_text(Estyle * es)
{
- const char *ret;
+ int scount, i;
+ const char *text;
+ char *temp = NULL;
CHECK_PARAM_POINTER_RETURN("es", es, NULL);
- ret = evas_object_text_text_get(es->bit);
- if (ret)
- ret = strdup(ret);
+ text = evas_object_text_text_get(es->bit);
+ if (text) {
+ temp = calloc(es->length + 1, sizeof(char));
+ if (temp) {
+ scount = es->length - es->spaces;
+ memmove(temp, text, scount);
+
+ for (i = 0; i < es->spaces; i++)
+ temp[scount + i] = text[scount + (2 * i)];
+ }
+ }
- return (char *)ret;
+ return temp;
}
/**
@@ -347,9 +347,39 @@
*/
void estyle_set_text(Estyle *es, char *text)
{
+ int i, scount;
+ char *temp;
+
CHECK_PARAM_POINTER("es", es);
- evas_object_text_text_set(es->bit, text);
+ /*
+ * Wheee!! what fun, to get the sizing right when spaces end the
+ * string we need to duplicate them. Start by counting the extra
+ * characters needed.
+ */
+ scount = es->length = strlen(text);
+ while (--scount > 0 && isspace(text[scount]));
+
+ scount++;
+ es->spaces = es->length - scount;
+
+ /*
+ * Now copy in the starting string byte-by-byte, followed by the
+ * doubled spaces.
+ */
+ temp = calloc(es->length + es->spaces + 1, sizeof(char));
+ memmove(temp, text, scount);
+ for (i = 0; i < es->spaces; i++) {
+ temp[scount + (2 * i)] = text[scount + i];
+ temp[scount + (2 * i) + 1] = text[scount + i];
+ }
+
+ /*
+ * Null terminate that sucka
+ */
+ temp[scount + (2 * i)] = '\0';
+ evas_object_text_text_set(es->bit, temp);
+ FREE(temp);
/*
* Set the text for the style bits.
@@ -360,7 +390,6 @@
/*
* Set new length and dimensions.
*/
- es->length = strlen(text);
__estyle_update_dimensions(es);
}
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs