2005-01-30 20:58:41 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
|
2005-01-08 02:02:18 -08:00
|
|
|
#include "evas_common.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
#include "Evas.h"
|
|
|
|
|
2005-01-30 06:48:30 -08:00
|
|
|
/* FIXME:
|
|
|
|
*
|
|
|
|
* things to add:
|
|
|
|
*
|
2005-02-05 07:53:58 -08:00
|
|
|
* * finish off current api where it is unfinished
|
2005-02-09 08:10:56 -08:00
|
|
|
* * get native extents
|
2005-01-30 20:10:22 -08:00
|
|
|
* * styles (outline, glow, etxra glow, shadow, soft shadow, etc.)
|
2005-02-06 18:12:36 -08:00
|
|
|
* * if a word (or char) doesnt fit at all do something sensible
|
2005-01-30 06:48:30 -08:00
|
|
|
* * anchors (to query text extents)
|
|
|
|
* * tabs (indents)
|
|
|
|
* * left and right margins
|
2005-01-31 08:16:12 -08:00
|
|
|
* * get all the current format params at any point
|
2005-02-05 07:53:58 -08:00
|
|
|
* * freeze thaw api
|
2005-01-31 08:16:12 -08:00
|
|
|
*
|
|
|
|
* tough ones:
|
2005-01-30 06:48:30 -08:00
|
|
|
* * overflow objects (overflow from this textblock can go into another)
|
|
|
|
* * on change figure out what node the change is in and figure out what line (nodes) it affects and only modify those nodes on that line or maybe others until changes dont happen further down
|
2005-02-02 07:30:53 -08:00
|
|
|
* * obstacle objects to wrap around
|
|
|
|
* * kerning control
|
|
|
|
* * fully justified text (space chars evenly to fit the line)
|
2005-01-30 06:48:30 -08:00
|
|
|
*
|
2005-01-31 08:16:12 -08:00
|
|
|
* really tough ones:
|
2005-02-02 07:30:53 -08:00
|
|
|
* * fix core text code to properly handle unicode codeponts - handle ALL unicode domains properly.
|
|
|
|
* * right to left text
|
2005-02-05 07:53:58 -08:00
|
|
|
* * top down (japanese/chinese) text layout
|
2005-02-02 07:30:53 -08:00
|
|
|
*
|
|
|
|
* insanely tough ones:
|
2005-01-31 08:16:12 -08:00
|
|
|
* * for ultra-huge documents determine paging sections of the text in/out and being able to provide callbacks form the user api that can provide the text
|
|
|
|
*
|
2005-01-30 06:48:30 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* save typing */
|
2005-01-29 08:28:18 -08:00
|
|
|
#define ENFN obj->layer->evas->engine.func
|
|
|
|
#define ENDT obj->layer->evas->engine.data.output
|
|
|
|
|
2005-01-08 02:02:18 -08:00
|
|
|
/* private magic number for textblock objects */
|
|
|
|
static const char o_type[] = "textblock";
|
|
|
|
|
|
|
|
/* private struct for textblock object internal data */
|
|
|
|
typedef struct _Evas_Object_Textblock Evas_Object_Textblock;
|
2005-01-29 08:28:18 -08:00
|
|
|
typedef struct _Layout Layout;
|
|
|
|
typedef struct _Node Node;
|
|
|
|
typedef struct _Layout_Node Layout_Node;
|
|
|
|
|
|
|
|
/* the current state of the formatting */
|
|
|
|
struct _Layout
|
|
|
|
{
|
|
|
|
struct {
|
|
|
|
char *name;
|
|
|
|
char *source;
|
|
|
|
Evas_Font_Size size;
|
|
|
|
void *font;
|
|
|
|
} font;
|
|
|
|
struct {
|
|
|
|
unsigned char r, g, b, a;
|
2005-02-04 18:30:13 -08:00
|
|
|
} color,
|
|
|
|
underline_color,
|
|
|
|
double_underline_color,
|
|
|
|
outline_color,
|
|
|
|
shadow_color,
|
|
|
|
glow_color,
|
|
|
|
outer_glow_color,
|
|
|
|
backing_color,
|
|
|
|
strikethrough_color
|
|
|
|
;
|
2005-01-29 08:28:18 -08:00
|
|
|
struct {
|
2005-02-04 18:30:13 -08:00
|
|
|
int inset, x, y,
|
|
|
|
ascent, descent,
|
2005-02-05 07:53:58 -08:00
|
|
|
mascent, mdescent,
|
|
|
|
advance;
|
2005-01-29 08:28:18 -08:00
|
|
|
} line;
|
2005-01-30 06:19:06 -08:00
|
|
|
double align, valign;
|
2005-01-31 23:17:00 -08:00
|
|
|
unsigned char word_wrap : 1;
|
2005-02-05 07:53:58 -08:00
|
|
|
unsigned char underline : 1;
|
|
|
|
unsigned char second_underline : 1;
|
|
|
|
unsigned char strikethrough : 1;
|
|
|
|
unsigned char backing : 1;
|
2005-01-29 08:28:18 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* a node of formatting data */
|
|
|
|
struct _Node
|
|
|
|
{
|
|
|
|
Evas_Object_List _list_data;
|
|
|
|
|
|
|
|
char *format; /* format data */
|
|
|
|
char *text; /* text data until the next node */
|
|
|
|
int text_len; /* length of the text */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* a node of formatting data */
|
|
|
|
struct _Layout_Node
|
|
|
|
{
|
|
|
|
Evas_Object_List _list_data;
|
|
|
|
|
|
|
|
/* the current state */
|
2005-02-09 08:10:56 -08:00
|
|
|
Layout layout;
|
|
|
|
char *text; /* text data until the next node */
|
|
|
|
int text_pos, text_len;
|
|
|
|
int w, h;
|
|
|
|
Node *source_node;
|
|
|
|
int source_pos;
|
|
|
|
int line;
|
2005-02-04 18:30:13 -08:00
|
|
|
unsigned char line_start : 1;
|
|
|
|
unsigned char line_end : 1;
|
2005-01-29 08:28:18 -08:00
|
|
|
};
|
2005-01-08 02:02:18 -08:00
|
|
|
|
|
|
|
struct _Evas_Object_Textblock
|
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
DATA32 magic;
|
2005-01-08 02:02:18 -08:00
|
|
|
struct {
|
2005-01-29 08:28:18 -08:00
|
|
|
int dummy;
|
2005-01-08 02:02:18 -08:00
|
|
|
} cur, prev;
|
2005-01-29 08:28:18 -08:00
|
|
|
char changed : 1;
|
|
|
|
|
2005-02-09 08:10:56 -08:00
|
|
|
int pos, len, lines;
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Format_Direction format_dir;
|
|
|
|
Node *nodes;
|
|
|
|
Layout_Node *layout_nodes;
|
|
|
|
Evas_Coord last_w, last_h;
|
|
|
|
struct {
|
|
|
|
unsigned char dirty : 1;
|
|
|
|
Evas_Coord w, h;
|
2005-02-06 18:12:36 -08:00
|
|
|
} native, format;
|
2005-01-31 01:32:31 -08:00
|
|
|
Evas_List *font_hold;
|
2005-01-29 08:28:18 -08:00
|
|
|
void *engine_data;
|
2005-01-08 02:02:18 -08:00
|
|
|
};
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
static void
|
|
|
|
evas_object_textblock_layout_init(Layout *layout)
|
|
|
|
{
|
|
|
|
layout->font.name = NULL;
|
|
|
|
layout->font.source = NULL;
|
|
|
|
layout->font.size = 0;
|
|
|
|
layout->font.font = NULL;
|
|
|
|
layout->color.r = 255;
|
|
|
|
layout->color.g = 255;
|
|
|
|
layout->color.b = 255;
|
|
|
|
layout->color.a = 255;
|
2005-02-04 18:30:13 -08:00
|
|
|
layout->underline_color = layout->color;
|
|
|
|
layout->double_underline_color = layout->color;
|
|
|
|
layout->outline_color = layout->color;
|
|
|
|
layout->shadow_color = layout->color;
|
|
|
|
layout->glow_color = layout->color;
|
|
|
|
layout->outer_glow_color = layout->color;
|
2005-02-05 07:53:58 -08:00
|
|
|
layout->backing_color = layout->color;
|
2005-02-04 18:30:13 -08:00
|
|
|
layout->strikethrough_color = layout->color;
|
2005-01-30 06:19:06 -08:00
|
|
|
layout->line.inset = 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
layout->line.x = 0;
|
|
|
|
layout->line.y = 0;
|
|
|
|
layout->line.ascent = 0;
|
|
|
|
layout->line.descent = 0;
|
|
|
|
layout->line.mascent = 0;
|
|
|
|
layout->line.mdescent = 0;
|
2005-02-05 07:53:58 -08:00
|
|
|
layout->line.advance = 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
layout->align = 0.0;
|
2005-01-30 06:19:06 -08:00
|
|
|
layout->valign = -1.0;
|
2005-02-05 07:53:58 -08:00
|
|
|
layout->word_wrap = 0;
|
|
|
|
layout->underline = 0;
|
|
|
|
layout->second_underline = 0;
|
|
|
|
layout->strikethrough = 0;
|
|
|
|
layout->backing = 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
evas_object_textblock_format_merge(char *ofmt, char *fmt)
|
|
|
|
{
|
|
|
|
return strdup(fmt);
|
|
|
|
}
|
|
|
|
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
static int
|
|
|
|
evas_object_textblock_hex_string_get(char ch)
|
|
|
|
{
|
|
|
|
if ((ch >= '0') && (ch <= '9')) return (ch - '0');
|
|
|
|
else if ((ch >= 'A') && (ch <= 'F')) return (ch - 'A' + 10);
|
|
|
|
else if ((ch >= 'a') && (ch <= 'f')) return (ch - 'a' + 10);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_layout_format_apply(Layout *layout, char *key, char *data)
|
|
|
|
{
|
|
|
|
if (!strcmp(key, "font"))
|
|
|
|
{
|
|
|
|
if (layout->font.name) free(layout->font.name);
|
|
|
|
layout->font.name = strdup(data);
|
|
|
|
}
|
2005-01-30 03:41:01 -08:00
|
|
|
else if (!strcmp(key, "font_source"))
|
|
|
|
{
|
2005-01-31 07:03:38 -08:00
|
|
|
if (layout->font.source)
|
|
|
|
{
|
|
|
|
free(layout->font.source);
|
|
|
|
layout->font.source = NULL;
|
|
|
|
}
|
|
|
|
if (!((data[0] == 0) ||
|
|
|
|
(!strcmp(data, "0")) ||
|
|
|
|
(!strcmp(data, "NULL")) ||
|
|
|
|
(!strcmp(data, "null")) ||
|
|
|
|
(!strcmp(data, "(null)"))))
|
|
|
|
layout->font.source = strdup(data);
|
2005-01-30 03:41:01 -08:00
|
|
|
}
|
|
|
|
else if (!strcmp(key, "size"))
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
{
|
|
|
|
layout->font.size = atoi(data);
|
|
|
|
}
|
2005-01-30 06:19:06 -08:00
|
|
|
else if (!strcmp(key, "align"))
|
|
|
|
{
|
|
|
|
if (!strcmp(data, "left")) layout->align = 0.0;
|
|
|
|
else if (!strcmp(data, "middle")) layout->align = 0.5;
|
|
|
|
else if (!strcmp(data, "center")) layout->align = 0.5;
|
|
|
|
else if (!strcmp(data, "right")) layout->align = 1.0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
layout->align = atof(data);
|
|
|
|
if (layout->align < 0.0) layout->align = 0.0;
|
|
|
|
else if (layout->align > 1.0) layout->align = 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "valign"))
|
|
|
|
{
|
|
|
|
if (!strcmp(data, "top")) layout->valign = 0.0;
|
|
|
|
else if (!strcmp(data, "middle")) layout->valign = 0.5;
|
|
|
|
else if (!strcmp(data, "center")) layout->valign = 0.5;
|
|
|
|
else if (!strcmp(data, "bottom")) layout->valign = 1.0;
|
|
|
|
else if (!strcmp(data, "baseline")) layout->valign = -1.0;
|
|
|
|
else if (!strcmp(data, "base")) layout->valign = -1.0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
layout->valign = atof(data);
|
|
|
|
if (layout->valign < 0.0) layout->valign = 0.0;
|
|
|
|
else if (layout->valign > 1.0) layout->valign = 1.0;
|
|
|
|
}
|
|
|
|
}
|
2005-02-05 07:53:58 -08:00
|
|
|
else if ((!strcmp(key, "color")) ||
|
|
|
|
(!strcmp(key, "underline_color")) ||
|
|
|
|
(!strcmp(key, "double_underline_color")) ||
|
|
|
|
(!strcmp(key, "outline_color")) ||
|
|
|
|
(!strcmp(key, "shadow_color")) ||
|
|
|
|
(!strcmp(key, "glow_color")) ||
|
|
|
|
(!strcmp(key, "outer_glow_color")) ||
|
|
|
|
(!strcmp(key, "backing_color")) ||
|
|
|
|
(!strcmp(key, "strikethrough_color")))
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
{
|
|
|
|
/* #RRGGBB[AA] or #RGB[A] */
|
|
|
|
if (data[0] == '#')
|
|
|
|
{
|
|
|
|
int r, g, b, a;
|
|
|
|
|
|
|
|
if (strlen(data) == 7) /* #RRGGBB */
|
|
|
|
{
|
|
|
|
r = (evas_object_textblock_hex_string_get(data[1]) << 4) |
|
|
|
|
(evas_object_textblock_hex_string_get(data[2]));
|
|
|
|
g = (evas_object_textblock_hex_string_get(data[3]) << 4) |
|
|
|
|
(evas_object_textblock_hex_string_get(data[4]));
|
|
|
|
b = (evas_object_textblock_hex_string_get(data[5]) << 4) |
|
|
|
|
(evas_object_textblock_hex_string_get(data[6]));
|
|
|
|
a = 0xff;
|
|
|
|
}
|
|
|
|
else if (strlen(data) == 9) /* #RRGGBBAA */
|
|
|
|
{
|
|
|
|
r = (evas_object_textblock_hex_string_get(data[1]) << 4) |
|
|
|
|
(evas_object_textblock_hex_string_get(data[2]));
|
|
|
|
g = (evas_object_textblock_hex_string_get(data[3]) << 4) |
|
|
|
|
(evas_object_textblock_hex_string_get(data[4]));
|
|
|
|
b = (evas_object_textblock_hex_string_get(data[5]) << 4) |
|
|
|
|
(evas_object_textblock_hex_string_get(data[6]));
|
|
|
|
a = (evas_object_textblock_hex_string_get(data[7]) << 4) |
|
|
|
|
(evas_object_textblock_hex_string_get(data[8]));
|
|
|
|
}
|
|
|
|
else if (strlen(data) == 4) /* #RGB */
|
|
|
|
{
|
|
|
|
r = evas_object_textblock_hex_string_get(data[1]);
|
|
|
|
r = (r << 4) | r;
|
|
|
|
g = evas_object_textblock_hex_string_get(data[2]);
|
|
|
|
g = (g << 4) | g;
|
|
|
|
b = evas_object_textblock_hex_string_get(data[3]);
|
|
|
|
b = (b << 4) | b;
|
2005-01-31 01:32:31 -08:00
|
|
|
a = 0xff;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
}
|
|
|
|
else if (strlen(data) == 5) /* #RGBA */
|
|
|
|
{
|
|
|
|
r = evas_object_textblock_hex_string_get(data[1]);
|
|
|
|
r = (r << 4) | r;
|
|
|
|
g = evas_object_textblock_hex_string_get(data[2]);
|
|
|
|
g = (g << 4) | g;
|
|
|
|
b = evas_object_textblock_hex_string_get(data[3]);
|
|
|
|
b = (b << 4) | b;
|
|
|
|
a = evas_object_textblock_hex_string_get(data[4]);
|
|
|
|
a = (a << 4) | a;
|
|
|
|
}
|
2005-02-05 07:53:58 -08:00
|
|
|
if (!strcmp(key, "color"))
|
|
|
|
{
|
|
|
|
layout->color.r = r;
|
|
|
|
layout->color.g = g;
|
|
|
|
layout->color.b = b;
|
|
|
|
layout->color.a = a;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "underline_color"))
|
|
|
|
{
|
|
|
|
layout->underline_color.r = r;
|
|
|
|
layout->underline_color.g = g;
|
|
|
|
layout->underline_color.b = b;
|
|
|
|
layout->underline_color.a = a;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "double_underline_color"))
|
|
|
|
{
|
|
|
|
layout->double_underline_color.r = r;
|
|
|
|
layout->double_underline_color.g = g;
|
|
|
|
layout->double_underline_color.b = b;
|
|
|
|
layout->double_underline_color.a = a;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "outline_color"))
|
|
|
|
{
|
|
|
|
layout->outline_color.r = r;
|
|
|
|
layout->outline_color.g = g;
|
|
|
|
layout->outline_color.b = b;
|
|
|
|
layout->outline_color.a = a;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "shadow_color"))
|
|
|
|
{
|
|
|
|
layout->shadow_color.r = r;
|
|
|
|
layout->shadow_color.g = g;
|
|
|
|
layout->shadow_color.b = b;
|
|
|
|
layout->shadow_color.a = a;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "glow_color"))
|
|
|
|
{
|
|
|
|
layout->glow_color.r = r;
|
|
|
|
layout->glow_color.g = g;
|
|
|
|
layout->glow_color.b = b;
|
|
|
|
layout->glow_color.a = a;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "outer_glow_color"))
|
|
|
|
{
|
|
|
|
layout->outer_glow_color.r = r;
|
|
|
|
layout->outer_glow_color.g = g;
|
|
|
|
layout->outer_glow_color.b = b;
|
|
|
|
layout->outer_glow_color.a = a;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "backing_color"))
|
|
|
|
{
|
|
|
|
layout->backing_color.r = r;
|
|
|
|
layout->backing_color.g = g;
|
|
|
|
layout->backing_color.b = b;
|
|
|
|
layout->backing_color.a = a;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "strikethrough_color"))
|
|
|
|
{
|
|
|
|
layout->strikethrough_color.r = r;
|
|
|
|
layout->strikethrough_color.g = g;
|
|
|
|
layout->strikethrough_color.b = b;
|
|
|
|
layout->strikethrough_color.a = a;
|
|
|
|
}
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
}
|
|
|
|
}
|
2005-01-31 23:17:00 -08:00
|
|
|
else if (!strcmp(key, "wrap"))
|
|
|
|
{
|
|
|
|
if (!strcmp(data, "word")) layout->word_wrap = 1;
|
|
|
|
else layout->word_wrap = 0;
|
|
|
|
}
|
2005-02-05 07:53:58 -08:00
|
|
|
else if (!strcmp(key, "underline"))
|
|
|
|
{
|
|
|
|
if (!strcmp(data, "off"))
|
|
|
|
{
|
|
|
|
layout->underline = 0;
|
|
|
|
layout->second_underline = 0;
|
|
|
|
}
|
|
|
|
else if ((!strcmp(data, "on")) ||
|
|
|
|
(!strcmp(data, "single")))
|
|
|
|
{
|
|
|
|
layout->underline = 1;
|
|
|
|
layout->second_underline = 0;
|
|
|
|
}
|
|
|
|
else if (!strcmp(data, "double"))
|
|
|
|
{
|
|
|
|
layout->underline = 1;
|
|
|
|
layout->second_underline = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "strikethrough"))
|
|
|
|
{
|
|
|
|
if (!strcmp(data, "off"))
|
|
|
|
layout->strikethrough = 0;
|
|
|
|
else if (!strcmp(data, "on"))
|
|
|
|
layout->strikethrough = 1;
|
|
|
|
}
|
|
|
|
else if (!strcmp(key, "backing"))
|
|
|
|
{
|
|
|
|
if (!strcmp(data, "off"))
|
|
|
|
layout->backing = 0;
|
|
|
|
else if (!strcmp(data, "on"))
|
|
|
|
layout->backing = 1;
|
|
|
|
}
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
}
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
static void
|
|
|
|
evas_object_textblock_layout_format_modify(Layout *layout, const char *format)
|
|
|
|
{
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
const char *p, *k1 = NULL, *k2 = NULL, *d1 = NULL, *d2 = NULL;
|
|
|
|
int inquote = 0, inescape = 0;
|
|
|
|
|
|
|
|
if (!format) return;
|
|
|
|
p = format - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
/* we dont have the start of a key yet */
|
|
|
|
if (!k1)
|
|
|
|
{
|
|
|
|
if (isalnum(*p)) k1 = p;
|
|
|
|
}
|
|
|
|
else if (!k2)
|
|
|
|
{
|
|
|
|
if (*p == '=') k2 = p;
|
|
|
|
}
|
|
|
|
else if (!d1)
|
|
|
|
{
|
|
|
|
if (*p == '\'') inquote = 1;
|
|
|
|
else d1 = p;
|
|
|
|
}
|
|
|
|
else if (!d2)
|
|
|
|
{
|
|
|
|
if (inquote)
|
|
|
|
{
|
|
|
|
if (!inescape)
|
|
|
|
{
|
|
|
|
if (*p == '\\') inescape = 1;
|
|
|
|
else if (*p == '\'') d2 = p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
inescape = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((isblank(*p)) || (*p == 0)) d2 = p;
|
|
|
|
}
|
|
|
|
if (d2)
|
|
|
|
{
|
|
|
|
char *key, *data;
|
|
|
|
|
|
|
|
key = malloc(k2 - k1 + 1);
|
|
|
|
data = malloc(d2 - d1 + 1);
|
|
|
|
strncpy(key, k1, k2 - k1);
|
|
|
|
key[k2 - k1] = 0;
|
|
|
|
if (inquote)
|
|
|
|
{
|
|
|
|
const char *p2;
|
|
|
|
char *dst;
|
|
|
|
|
|
|
|
inescape = 0;
|
|
|
|
p2 = d1;
|
|
|
|
dst = data;
|
|
|
|
while (p2 != d2)
|
|
|
|
{
|
|
|
|
if (!inescape)
|
|
|
|
{
|
|
|
|
if (*p == '\\') inescape = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*dst = *p;
|
|
|
|
dst++;
|
|
|
|
inescape = 0;
|
|
|
|
}
|
|
|
|
p2++;
|
|
|
|
}
|
|
|
|
*dst = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strncpy(data, d1, d2 - d1);
|
|
|
|
data[d2 - d1] = 0;
|
|
|
|
}
|
|
|
|
k1 = k2 = d1 = d2 = NULL;
|
|
|
|
inquote = 0;
|
|
|
|
inescape = 0;
|
|
|
|
evas_object_textblock_layout_format_apply(layout, key, data);
|
|
|
|
free(key);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (*p);
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_layout_copy(Layout *layout, Layout *layout_dst)
|
|
|
|
{
|
|
|
|
*layout_dst = *layout;
|
|
|
|
if (layout->font.name) layout_dst->font.name = strdup(layout->font.name);
|
2005-01-30 03:41:01 -08:00
|
|
|
if (layout->font.source) layout_dst->font.source = strdup(layout->font.source);
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_layout_clear(Evas_Object *obj, Layout *layout)
|
|
|
|
{
|
|
|
|
if (layout->font.name) free(layout->font.name);
|
|
|
|
if (layout->font.source) free(layout->font.source);
|
|
|
|
if (layout->font.font) ENFN->font_free(ENDT, layout->font.font);
|
|
|
|
memset(layout, 0, sizeof(Layout));
|
|
|
|
}
|
|
|
|
|
2005-01-31 01:32:31 -08:00
|
|
|
static void
|
|
|
|
evas_object_textblock_layout_fonts_hold(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Evas_Object_List *l;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
for (l = (Evas_Object_List *)o->layout_nodes; l; l = l->next)
|
|
|
|
{
|
|
|
|
Layout_Node *lnode;
|
|
|
|
|
|
|
|
lnode = (Layout_Node *)l;
|
|
|
|
if (lnode->layout.font.font)
|
|
|
|
{
|
|
|
|
o->font_hold = evas_list_append(o->font_hold,
|
|
|
|
lnode->layout.font.font);
|
|
|
|
lnode->layout.font.font = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_layout_fonts_hold_clean(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
|
|
|
|
while (o->font_hold)
|
|
|
|
{
|
|
|
|
ENFN->font_free(ENDT, o->font_hold->data);
|
|
|
|
o->font_hold = evas_list_remove_list(o->font_hold, o->font_hold);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
static void
|
|
|
|
evas_object_textblock_layout_clean(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
while (o->layout_nodes)
|
|
|
|
{
|
|
|
|
Layout_Node *lnode;
|
|
|
|
|
|
|
|
lnode = (Layout_Node *)o->layout_nodes;
|
|
|
|
o->layout_nodes = evas_object_list_remove(o->layout_nodes, lnode);
|
|
|
|
evas_object_textblock_layout_clear(obj, &lnode->layout);
|
|
|
|
if (lnode->text) free(lnode->text);
|
|
|
|
free(lnode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_contents_clean(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
while (o->nodes)
|
|
|
|
{
|
|
|
|
Node *node;
|
|
|
|
|
|
|
|
node = (Node *)o->nodes;
|
|
|
|
o->nodes = evas_object_list_remove(o->nodes, node);
|
|
|
|
if (node->format) free(node->format);
|
|
|
|
if (node->text) free(node->text);
|
|
|
|
free(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-31 23:17:00 -08:00
|
|
|
static int
|
|
|
|
evas_object_textblock_char_is_white(int c)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* unicode list of whitespace chars
|
|
|
|
*
|
|
|
|
* 0009..000D <control-0009>..<control-000D>
|
|
|
|
* 0020 SPACE
|
|
|
|
* 0085 <control-0085>
|
|
|
|
* 00A0 NO-BREAK SPACE
|
|
|
|
* 1680 OGHAM SPACE MARK
|
|
|
|
* 180E MONGOLIAN VOWEL SEPARATOR
|
|
|
|
* 2000..200A EN QUAD..HAIR SPACE
|
|
|
|
* 2028 LINE SEPARATOR
|
|
|
|
* 2029 PARAGRAPH SEPARATOR
|
|
|
|
* 202F NARROW NO-BREAK SPACE
|
|
|
|
* 205F MEDIUM MATHEMATICAL SPACE
|
|
|
|
* 3000 IDEOGRAPHIC SPACE
|
|
|
|
*/
|
|
|
|
if (
|
|
|
|
(c == 0x20) ||
|
|
|
|
((c >= 0x9) && (c <= 0xd)) ||
|
|
|
|
(c == 0x85) ||
|
|
|
|
(c == 0xa0) ||
|
|
|
|
(c == 0x1680) ||
|
|
|
|
(c == 0x180e) ||
|
|
|
|
((c >= 0x2000) && (c <= 0x200a)) ||
|
|
|
|
(c == 0x2028) ||
|
|
|
|
(c == 0x2029) ||
|
|
|
|
(c == 0x202f) ||
|
|
|
|
(c == 0x205f) ||
|
|
|
|
(c == 0x3000)
|
|
|
|
)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
static void
|
|
|
|
evas_object_textblock_layout(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Layout layout;
|
|
|
|
Evas_Object_List *l, *ll;
|
|
|
|
Evas_Coord w, h;
|
|
|
|
Layout_Node *line_start = NULL;
|
2005-02-09 08:10:56 -08:00
|
|
|
int text_pos = 0, fh = 0, last_mdescent = 0, line = 0, last_line = 0;
|
2005-01-30 03:41:01 -08:00
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
evas_object_textblock_layout_init(&layout);
|
|
|
|
w = obj->cur.geometry.w;
|
|
|
|
h = obj->cur.geometry.h;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
o->last_w = w;
|
|
|
|
o->last_h = h;
|
2005-02-09 08:10:56 -08:00
|
|
|
/* format width is object width */
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
// printf("RE-LAYOUT %ix%i!\n", w, h);
|
2005-01-29 08:28:18 -08:00
|
|
|
for (l = (Evas_Object_List *)o->nodes; l; l = l->next)
|
|
|
|
{
|
|
|
|
Layout_Node *lnode;
|
|
|
|
Node *node;
|
|
|
|
|
2005-02-04 18:30:13 -08:00
|
|
|
/* FIXME: we cant do this - we need to be able to qury text
|
|
|
|
* overflow amounts */
|
|
|
|
/*
|
2005-02-01 05:53:40 -08:00
|
|
|
if (layout.line.y >= h) goto breakout;
|
2005-02-04 18:30:13 -08:00
|
|
|
*/
|
2005-01-29 08:28:18 -08:00
|
|
|
node = (Node *)l;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
// printf("NODE: FMT:\"%s\" TXT:\"%s\"\n", node->format, node->text);
|
2005-01-29 08:28:18 -08:00
|
|
|
if (node->format)
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
{
|
|
|
|
/* first handle newline, tab etc. etc */
|
2005-02-05 07:53:58 -08:00
|
|
|
if (node->format[0] == '\n')
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
{
|
2005-02-04 18:30:13 -08:00
|
|
|
if (lnode)
|
|
|
|
lnode->line_end = 1;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
layout.line.x = 0;
|
2005-02-04 18:30:13 -08:00
|
|
|
if ((layout.line.y + layout.line.mascent + layout.line.mdescent) > h)
|
2005-02-01 00:23:53 -08:00
|
|
|
{
|
|
|
|
/* FIXME: this node would overflow to the next textblock */
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
line++;
|
2005-02-04 18:30:13 -08:00
|
|
|
layout.line.y += layout.line.mascent + layout.line.mdescent;
|
2005-02-09 08:10:56 -08:00
|
|
|
fh = layout.line.y;
|
|
|
|
last_mdescent = 3;
|
2005-02-05 07:53:58 -08:00
|
|
|
line_start = NULL;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
evas_object_textblock_layout_format_modify(&layout, node->format);
|
|
|
|
}
|
2005-01-29 08:28:18 -08:00
|
|
|
if (node->text)
|
|
|
|
{
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
int inset = 0, hadvance = 0, vadvance = 0;
|
|
|
|
int ascent = 0, descent = 0, tw = 0, th = 0;
|
2005-02-01 07:34:37 -08:00
|
|
|
int chrpos = -1, nchrpos = -1, x, y, cx, cy, cw, ch;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
void *font = NULL;
|
2005-01-29 08:28:18 -08:00
|
|
|
char *text;
|
2005-01-30 06:19:06 -08:00
|
|
|
int adj, lastnode;
|
2005-02-04 18:30:13 -08:00
|
|
|
int srcpos = 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
|
|
|
|
text = strdup(node->text);
|
|
|
|
new_node:
|
2005-02-04 18:30:13 -08:00
|
|
|
/* FIXME: we cant do this - we need to be able to qury text
|
|
|
|
* overflow amounts */
|
|
|
|
/*
|
2005-02-01 05:53:40 -08:00
|
|
|
if (layout.line.y >= h)
|
|
|
|
{
|
|
|
|
free(text);
|
|
|
|
goto breakout;
|
|
|
|
}
|
2005-02-04 18:30:13 -08:00
|
|
|
*/
|
2005-01-29 08:28:18 -08:00
|
|
|
lnode = calloc(1, sizeof(Layout_Node));
|
2005-02-04 18:30:13 -08:00
|
|
|
lnode->source_node = node;
|
|
|
|
lnode->source_pos = srcpos;
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode->line = line;
|
|
|
|
last_line = line;
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_layout_copy(&layout, &(lnode->layout));
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if (lnode->layout.font.name)
|
2005-01-31 07:03:38 -08:00
|
|
|
font = evas_font_load(obj->layer->evas, lnode->layout.font.name, lnode->layout.font.source, lnode->layout.font.size);
|
2005-02-01 00:23:53 -08:00
|
|
|
/* if this is at the start of the line... */
|
|
|
|
if (layout.line.x == 0)
|
|
|
|
{
|
|
|
|
if (font) inset = ENFN->font_inset_get(ENDT, font, text);
|
|
|
|
layout.line.inset = inset;
|
|
|
|
layout.line.x = -inset;
|
|
|
|
layout.line.mascent = 0;
|
|
|
|
layout.line.mdescent = 0;
|
|
|
|
line_start = lnode;
|
2005-02-04 18:30:13 -08:00
|
|
|
lnode->line_start = 1;
|
2005-02-01 00:23:53 -08:00
|
|
|
}
|
2005-01-29 08:28:18 -08:00
|
|
|
lnode->layout.font.font = font;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if (font) ascent = ENFN->font_max_ascent_get(ENDT, font);
|
|
|
|
if (font) descent = ENFN->font_max_descent_get(ENDT, font);
|
2005-01-30 06:19:06 -08:00
|
|
|
lnode->layout.line.ascent = ascent;
|
|
|
|
lnode->layout.line.descent = descent;
|
2005-01-29 08:28:18 -08:00
|
|
|
layout.line.ascent = ascent;
|
|
|
|
layout.line.descent = descent;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if (layout.line.mascent < ascent) layout.line.mascent = ascent;
|
2005-01-29 08:28:18 -08:00
|
|
|
if (layout.line.mdescent < descent) layout.line.mdescent = descent;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if (font) chrpos = ENFN->font_char_at_coords_get(ENDT, font, text,
|
|
|
|
w - layout.line.x, 0,
|
|
|
|
&cx, &cy, &cw, &ch);
|
2005-01-29 08:28:18 -08:00
|
|
|
/* if the text fits... just add */
|
|
|
|
if (chrpos < 0)
|
|
|
|
{
|
2005-02-05 07:53:58 -08:00
|
|
|
int more_text_on_line = 0;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if (font) ENFN->font_string_size_get(ENDT, font, text, &tw, &th);
|
2005-01-29 08:28:18 -08:00
|
|
|
lnode->w = tw;
|
|
|
|
lnode->h = th;
|
|
|
|
lnode->text = text;
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode->text_len = strlen(lnode->text);
|
|
|
|
lnode->text_pos = text_pos;
|
|
|
|
text_pos += lnode->text_len;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if (font) hadvance = ENFN->font_h_advance_get(ENDT, font, text);
|
2005-01-29 08:28:18 -08:00
|
|
|
o->layout_nodes = evas_object_list_append(o->layout_nodes, lnode);
|
|
|
|
/* and advance */
|
|
|
|
/* fix up max ascent/descent for the line */
|
2005-01-31 08:16:12 -08:00
|
|
|
adj = (double)(w - (lnode->layout.line.x + tw + layout.line.inset)) * layout.align;
|
|
|
|
adj -= line_start->layout.line.x;
|
2005-02-05 07:53:58 -08:00
|
|
|
layout.line.x += hadvance;
|
|
|
|
lnode->layout.line.advance = hadvance;
|
2005-02-09 08:10:56 -08:00
|
|
|
for (ll = l->next; ll; ll = ll->next)
|
2005-01-29 08:28:18 -08:00
|
|
|
{
|
2005-02-05 07:53:58 -08:00
|
|
|
Node *node2;
|
2005-01-29 08:28:18 -08:00
|
|
|
|
2005-02-05 07:53:58 -08:00
|
|
|
node2 = (Node *)ll;
|
2005-02-09 08:10:56 -08:00
|
|
|
if (node2->text)
|
2005-02-05 07:53:58 -08:00
|
|
|
{
|
|
|
|
more_text_on_line = 1;
|
|
|
|
break;
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
else if ((node2->format) && (node2->format[0] == '\n'))
|
2005-02-05 07:53:58 -08:00
|
|
|
{
|
|
|
|
more_text_on_line = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!more_text_on_line)
|
|
|
|
{
|
|
|
|
for (ll = (Evas_Object_List *)lnode; ll; ll = ll->prev)
|
|
|
|
{
|
|
|
|
Layout_Node *lnode2;
|
|
|
|
|
|
|
|
lnode2 = (Layout_Node *)ll;
|
|
|
|
lnode2->layout.line.x += adj;
|
|
|
|
lnode2->layout.line.mascent = layout.line.mascent;
|
|
|
|
lnode2->layout.line.mdescent = layout.line.mdescent;
|
|
|
|
if (ll == (Evas_Object_List *)line_start) break;
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode->line_end = 1;
|
2005-02-09 17:02:55 -08:00
|
|
|
fh = layout.line.y + layout.line.mascent + layout.line.mdescent;
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* text doesnt fit */
|
|
|
|
else
|
|
|
|
{
|
2005-02-01 07:34:37 -08:00
|
|
|
nchrpos = chrpos;
|
2005-01-31 23:17:00 -08:00
|
|
|
/* handle word wrap */
|
|
|
|
if (layout.word_wrap)
|
|
|
|
{
|
|
|
|
int ppos, pos, chr;
|
|
|
|
|
2005-02-01 07:34:37 -08:00
|
|
|
pos = chrpos;
|
|
|
|
chr = evas_common_font_utf8_get_prev(text, &pos);
|
|
|
|
ppos = pos = chrpos;
|
|
|
|
while ((!evas_object_textblock_char_is_white(chr))
|
|
|
|
&&
|
|
|
|
(pos >= 0) &&
|
|
|
|
(chr > 0))
|
2005-01-31 23:17:00 -08:00
|
|
|
{
|
2005-02-01 07:34:37 -08:00
|
|
|
ppos = pos;
|
|
|
|
chr = evas_common_font_utf8_get_prev(text, &pos);
|
|
|
|
}
|
|
|
|
chr = evas_common_font_utf8_get_next(text, &ppos);
|
|
|
|
if (ppos < 0) ppos = 0;
|
|
|
|
chrpos = ppos;
|
|
|
|
while ((evas_object_textblock_char_is_white(chr))
|
|
|
|
&&
|
|
|
|
(pos >= 0) &&
|
|
|
|
(chr > 0))
|
|
|
|
{
|
|
|
|
ppos = pos;
|
|
|
|
chr = evas_common_font_utf8_get_prev(text, &pos);
|
2005-01-31 23:17:00 -08:00
|
|
|
}
|
2005-02-01 07:34:37 -08:00
|
|
|
chr = evas_common_font_utf8_get_next(text, &ppos);
|
|
|
|
if (ppos < 0) ppos = 0;
|
|
|
|
nchrpos = ppos;
|
2005-01-31 23:17:00 -08:00
|
|
|
}
|
2005-01-29 08:28:18 -08:00
|
|
|
/* if the first char in the line can't fit!!! */
|
|
|
|
if ((chrpos == 0) && (lnode == line_start))
|
|
|
|
{
|
|
|
|
/* the first char can't fit. put it in there anyway */
|
|
|
|
/* FIXME */
|
|
|
|
free(text);
|
2005-01-30 03:41:01 -08:00
|
|
|
if (lnode->text) free(lnode->text);
|
|
|
|
evas_object_textblock_layout_clear(obj, &(lnode->layout));
|
|
|
|
free(lnode);
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *text1, *text2;
|
|
|
|
|
|
|
|
/* byte chrpos is over... so cut there */
|
2005-02-01 07:34:37 -08:00
|
|
|
text1 = malloc(nchrpos + 1);
|
|
|
|
strncpy(text1, text, nchrpos);
|
|
|
|
text1[nchrpos] = 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
text2 = strdup(text + chrpos);
|
|
|
|
lnode->text = text1;
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode->text_len = strlen(lnode->text);
|
|
|
|
lnode->text_pos = text_pos;
|
|
|
|
text_pos += chrpos;
|
2005-01-29 08:28:18 -08:00
|
|
|
free(text);
|
2005-02-04 18:30:13 -08:00
|
|
|
srcpos += chrpos;
|
2005-01-29 08:28:18 -08:00
|
|
|
text = text1;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if (font) ENFN->font_string_size_get(ENDT, font, text, &tw, &th);
|
2005-02-09 08:10:56 -08:00
|
|
|
if (font) hadvance = ENFN->font_h_advance_get(ENDT, font, text);
|
2005-01-29 08:28:18 -08:00
|
|
|
lnode->w = tw;
|
|
|
|
lnode->h = th;
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode->layout.line.advance = hadvance;
|
2005-01-29 08:28:18 -08:00
|
|
|
o->layout_nodes = evas_object_list_append(o->layout_nodes, lnode);
|
2005-01-30 06:19:06 -08:00
|
|
|
adj = (double)(w - (lnode->layout.line.x + tw + layout.line.inset)) * layout.align;
|
|
|
|
adj -= line_start->layout.line.x;
|
2005-01-29 08:28:18 -08:00
|
|
|
for (ll = (Evas_Object_List *)lnode; ll; ll = ll->prev)
|
|
|
|
{
|
|
|
|
Layout_Node *lnode2;
|
|
|
|
|
|
|
|
lnode2 = (Layout_Node *)ll;
|
2005-01-30 06:19:06 -08:00
|
|
|
lnode2->layout.line.x += adj;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
lnode2->layout.line.mascent = layout.line.mascent;
|
|
|
|
lnode2->layout.line.mdescent = layout.line.mdescent;
|
|
|
|
if (ll == (Evas_Object_List *)line_start) break;
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
2005-02-04 18:30:13 -08:00
|
|
|
lnode->line_end = 1;
|
2005-01-30 06:19:06 -08:00
|
|
|
layout.line.inset = 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
layout.line.x = 0;
|
2005-02-04 18:30:13 -08:00
|
|
|
if ((layout.line.y + layout.line.mascent + layout.line.mdescent) > h)
|
2005-02-01 00:23:53 -08:00
|
|
|
{
|
|
|
|
/* FIXME: this node would overflow to the next textblock */
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
line++;
|
2005-02-01 05:53:40 -08:00
|
|
|
layout.line.y += layout.line.mascent + layout.line.mdescent;
|
2005-02-09 08:10:56 -08:00
|
|
|
fh = layout.line.y;
|
2005-02-05 07:53:58 -08:00
|
|
|
line_start = NULL;
|
2005-01-29 08:28:18 -08:00
|
|
|
text = text2;
|
|
|
|
/* still more text to go */
|
2005-02-01 05:53:40 -08:00
|
|
|
if ((layout.line.mascent + layout.line.mdescent) > 0)
|
|
|
|
goto new_node;
|
|
|
|
else
|
|
|
|
free(text);
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-01 05:53:40 -08:00
|
|
|
breakout:
|
2005-01-30 03:41:01 -08:00
|
|
|
evas_object_textblock_layout_clear(obj, &layout);
|
2005-02-09 08:10:56 -08:00
|
|
|
o->lines = last_line + 1;
|
|
|
|
o->format.w = w;
|
|
|
|
if (last_mdescent < 3) fh += 3 - last_mdescent;
|
|
|
|
o->format.h = fh;
|
|
|
|
o->format.dirty = 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
|
|
|
|
2005-02-06 18:12:36 -08:00
|
|
|
static void
|
|
|
|
evas_object_textblock_format_calc(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
2005-02-09 08:10:56 -08:00
|
|
|
evas_object_textblock_layout_fonts_hold(obj);
|
|
|
|
evas_object_textblock_layout_clean(obj);
|
|
|
|
evas_object_textblock_layout(obj);
|
|
|
|
evas_object_textblock_layout_fonts_hold_clean(obj);
|
2005-02-06 18:12:36 -08:00
|
|
|
}
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
static void
|
|
|
|
evas_object_textblock_native_calc(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Layout layout;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
/* FIXME: takes nodes and produce layotu nodes ignoring object size */
|
|
|
|
}
|
|
|
|
|
|
|
|
static Node *
|
|
|
|
evas_object_textblock_node_pos_get(Evas_Object *obj, int pos, int *pstart)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Evas_Object_List *l;
|
|
|
|
int p, ps;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
ps = p = 0;
|
|
|
|
for (l = (Evas_Object_List *)o->nodes; l; l = l->next)
|
|
|
|
{
|
|
|
|
Node *node;
|
|
|
|
|
|
|
|
node = (Node *)l;
|
|
|
|
if (node->text)
|
|
|
|
{
|
|
|
|
ps = p;
|
|
|
|
p += node->text_len;
|
|
|
|
if (p > pos)
|
|
|
|
{
|
|
|
|
*pstart = ps;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-02-09 08:10:56 -08:00
|
|
|
static Layout_Node *
|
|
|
|
evas_object_textblock_layout_node_pos_get(Evas_Object *obj, int pos, int *pstart)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Evas_Object_List *l;
|
|
|
|
int p;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
p = 0;
|
|
|
|
for (l = (Evas_Object_List *)o->layout_nodes; l; l = l->next)
|
|
|
|
{
|
|
|
|
Layout_Node *lnode;
|
|
|
|
|
|
|
|
lnode = (Layout_Node *)l;
|
|
|
|
if (lnode->text)
|
|
|
|
{
|
|
|
|
p = lnode->text_pos + lnode->text_len;
|
|
|
|
if (p > pos)
|
|
|
|
{
|
|
|
|
*pstart = lnode->text_pos;
|
|
|
|
return lnode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Layout_Node *
|
|
|
|
evas_object_textblock_layout_node_line_get(Evas_Object *obj, int line)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Evas_Object_List *l;
|
|
|
|
int p, ps;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
ps = p = 0;
|
|
|
|
for (l = (Evas_Object_List *)o->layout_nodes; l; l = l->next)
|
|
|
|
{
|
|
|
|
Layout_Node *lnode;
|
|
|
|
|
|
|
|
lnode = (Layout_Node *)l;
|
|
|
|
if (lnode->text)
|
|
|
|
{
|
|
|
|
ps = p;
|
|
|
|
p += lnode->text_len;
|
|
|
|
if (lnode->line == line) return lnode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-08 02:02:18 -08:00
|
|
|
/* private methods for textblock objects */
|
|
|
|
static void evas_object_textblock_init(Evas_Object *obj);
|
|
|
|
static void *evas_object_textblock_new(void);
|
|
|
|
static void evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y);
|
|
|
|
static void evas_object_textblock_free(Evas_Object *obj);
|
|
|
|
static void evas_object_textblock_render_pre(Evas_Object *obj);
|
|
|
|
static void evas_object_textblock_render_post(Evas_Object *obj);
|
|
|
|
|
|
|
|
static int evas_object_textblock_is_opaque(Evas_Object *obj);
|
|
|
|
static int evas_object_textblock_was_opaque(Evas_Object *obj);
|
|
|
|
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
static void evas_object_textblock_coords_recalc(Evas_Object *obj);
|
|
|
|
|
2005-01-08 02:02:18 -08:00
|
|
|
static Evas_Object_Func object_func =
|
|
|
|
{
|
|
|
|
/* methods (compulsory) */
|
|
|
|
evas_object_textblock_free,
|
|
|
|
evas_object_textblock_render,
|
|
|
|
evas_object_textblock_render_pre,
|
|
|
|
evas_object_textblock_render_post,
|
|
|
|
/* these are optional. NULL = nothing */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
evas_object_textblock_is_opaque,
|
|
|
|
evas_object_textblock_was_opaque,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
evas_object_textblock_coords_recalc
|
2005-01-08 02:02:18 -08:00
|
|
|
};
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
/* the actual api call to add a textblock */
|
2005-01-08 02:02:18 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a textblock to the given evas.
|
|
|
|
* @param e The given evas.
|
|
|
|
* @return The new textblock object.
|
|
|
|
* @todo Find a documentation group to put this under.
|
|
|
|
*/
|
|
|
|
Evas_Object *
|
|
|
|
evas_object_textblock_add(Evas *e)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
obj = evas_object_new();
|
|
|
|
evas_object_textblock_init(obj);
|
|
|
|
evas_object_inject(obj, e);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2005-01-08 04:47:36 -08:00
|
|
|
void
|
2005-01-19 22:54:45 -08:00
|
|
|
evas_object_textblock_clear(Evas_Object *obj)
|
2005-01-08 04:47:36 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-08 07:25:50 -08:00
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-08 04:47:36 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_contents_clean(obj);
|
|
|
|
evas_object_textblock_layout_clean(obj);
|
|
|
|
o->len = 0;
|
|
|
|
o->pos = 0;
|
2005-02-10 01:48:45 -08:00
|
|
|
o->lines = 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
o->changed = 1;
|
2005-02-10 01:48:45 -08:00
|
|
|
o->native.dirty = 1;
|
|
|
|
o->format.dirty = 1;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
evas_object_change(obj);
|
2005-01-08 04:47:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_textblock_cursor_pos_set(Evas_Object *obj, int pos)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-08 07:25:50 -08:00
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-08 04:47:36 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-29 08:28:18 -08:00
|
|
|
if (pos < 0) pos = 0;
|
|
|
|
else if (pos > o->len) pos = o->len;
|
|
|
|
o->pos = pos;
|
2005-01-08 04:47:36 -08:00
|
|
|
}
|
|
|
|
|
2005-02-09 08:10:56 -08:00
|
|
|
void
|
|
|
|
evas_object_textblock_cursor_pos_next(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
2005-02-10 01:48:45 -08:00
|
|
|
Node *node;
|
|
|
|
int ps = 0;
|
|
|
|
|
2005-02-09 08:10:56 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-02-10 01:48:45 -08:00
|
|
|
node = evas_object_textblock_node_pos_get(obj, o->pos, &ps);
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
int chr;
|
|
|
|
int npos;
|
|
|
|
|
|
|
|
npos = o->pos - ps;
|
|
|
|
chr = evas_common_font_utf8_get_next(node->text, &npos);
|
|
|
|
if ((!chr) || (npos >= node->text_len))
|
|
|
|
{
|
|
|
|
npos = ps + node->text_len;
|
|
|
|
if (node)
|
|
|
|
o->pos = npos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
o->pos = npos + ps;
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_textblock_cursor_pos_prev(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
2005-02-10 01:48:45 -08:00
|
|
|
Node *node;
|
|
|
|
int ps = 0;
|
2005-02-09 08:10:56 -08:00
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-02-10 01:48:45 -08:00
|
|
|
if (o->pos == o->len)
|
|
|
|
{
|
|
|
|
if (o->nodes)
|
|
|
|
{
|
|
|
|
node = (Node *)(((Evas_Object_List *)o->nodes)->last);
|
|
|
|
while ((node) && (!node->text))
|
|
|
|
node = (Node *)(((Evas_Object_List *)node)->prev);
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
int npos;
|
|
|
|
|
|
|
|
npos = evas_common_font_utf8_get_last(node->text, node->text_len);
|
|
|
|
o->pos = o->pos - node->text_len + npos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
node = evas_object_textblock_node_pos_get(obj, o->pos, &ps);
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
int chr;
|
|
|
|
int npos;
|
|
|
|
|
|
|
|
npos = o->pos - ps;
|
|
|
|
if (o->pos > ps)
|
|
|
|
{
|
|
|
|
chr = evas_common_font_utf8_get_prev(node->text, &npos);
|
|
|
|
o->pos = npos + ps;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
node = (Node *)(((Evas_Object_List *)node)->prev);
|
|
|
|
while ((node) && (!node->text))
|
|
|
|
node = (Node *)(((Evas_Object_List *)node)->prev);
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
npos = evas_common_font_utf8_get_last(node->text, node->text_len);
|
|
|
|
o->pos = o->pos - node->text_len + npos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
}
|
|
|
|
|
2005-01-08 04:47:36 -08:00
|
|
|
int
|
|
|
|
evas_object_textblock_cursor_pos_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return 0;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-08 07:25:50 -08:00
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-08 04:47:36 -08:00
|
|
|
return 0;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-29 08:28:18 -08:00
|
|
|
return o->pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
evas_object_textblock_length_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return 0;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-08 04:47:36 -08:00
|
|
|
return 0;
|
2005-01-29 08:28:18 -08:00
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return o->len;
|
2005-01-08 04:47:36 -08:00
|
|
|
}
|
|
|
|
|
2005-02-09 08:10:56 -08:00
|
|
|
int
|
|
|
|
evas_object_textblock_cursor_line_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Layout_Node *lnode;
|
|
|
|
int ps;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return 0;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return 0;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (o->format.dirty)
|
2005-02-10 21:33:44 -08:00
|
|
|
evas_object_textblock_format_calc(obj);
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode = evas_object_textblock_layout_node_pos_get(obj, o->pos, &ps);
|
|
|
|
if (lnode) return lnode->line;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
evas_object_textblock_lines_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return 0;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return 0;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return o->lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
evas_object_textblock_line_start_pos_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Layout_Node *lnode;
|
|
|
|
int ps;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (o->format.dirty)
|
2005-02-10 21:33:44 -08:00
|
|
|
evas_object_textblock_format_calc(obj);
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode = evas_object_textblock_layout_node_pos_get(obj, o->pos, &ps);
|
|
|
|
if (lnode)
|
|
|
|
{
|
|
|
|
Evas_Object_List *l;
|
|
|
|
|
|
|
|
for (l = (Evas_Object_List *)lnode; l; l = l->prev)
|
|
|
|
{
|
|
|
|
lnode = (Layout_Node *)l;
|
|
|
|
if ((lnode->text) && (lnode->line_start))
|
|
|
|
return lnode->text_pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
evas_object_textblock_line_end_pos_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Layout_Node *lnode;
|
|
|
|
int ps;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return 1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (o->format.dirty)
|
2005-02-10 21:33:44 -08:00
|
|
|
evas_object_textblock_format_calc(obj);
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode = evas_object_textblock_layout_node_pos_get(obj, o->pos, &ps);
|
|
|
|
if (lnode)
|
|
|
|
{
|
|
|
|
Evas_Object_List *l;
|
|
|
|
|
|
|
|
for (l = (Evas_Object_List *)lnode; l; l = l->next)
|
|
|
|
{
|
|
|
|
lnode = (Layout_Node *)l;
|
|
|
|
if ((lnode->text) && (lnode->line_end))
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
|
|
|
|
index = evas_common_font_utf8_get_last(lnode->text, lnode->text_len);
|
|
|
|
return lnode->text_pos + index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_textblock_line_get(Evas_Object *obj, int line, Evas_Coord *lx, Evas_Coord *ly, Evas_Coord *lw, Evas_Coord *lh)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Layout_Node *lnode;
|
|
|
|
int ps;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (o->format.dirty)
|
2005-02-10 21:33:44 -08:00
|
|
|
evas_object_textblock_format_calc(obj);
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode = evas_object_textblock_layout_node_pos_get(obj, o->pos, &ps);
|
|
|
|
if (lnode)
|
|
|
|
{
|
|
|
|
Evas_Object_List *l;
|
|
|
|
Layout_Node *lnode_start = NULL, *lnode_end = NULL;
|
|
|
|
|
|
|
|
for (l = (Evas_Object_List *)lnode; l; l = l->prev)
|
|
|
|
{
|
|
|
|
lnode_start = (Layout_Node *)l;
|
|
|
|
if (lnode_start->line_start)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (l = (Evas_Object_List *)lnode; l; l = l->next)
|
|
|
|
{
|
|
|
|
lnode_end = (Layout_Node *)l;
|
|
|
|
if (lnode_end->line_end)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((lnode_start) && (lnode_end))
|
|
|
|
{
|
|
|
|
if (lx) *lx = lnode_start->layout.line.x;
|
|
|
|
if (ly) *ly = lnode_start->layout.line.y;
|
|
|
|
if (lw) *lw = lnode_end->layout.line.x - lnode_start->layout.line.x + lnode_end->layout.line.advance;
|
|
|
|
if (lh) *lh = lnode_start->layout.line.mascent + lnode_start->layout.line.mdescent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_object_textblock_char_pos_get(Evas_Object *obj, int pos, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Layout_Node *lnode;
|
|
|
|
int ps;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (o->format.dirty)
|
2005-02-10 21:33:44 -08:00
|
|
|
evas_object_textblock_format_calc(obj);
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode = evas_object_textblock_layout_node_pos_get(obj, o->pos, &ps);
|
|
|
|
if (lnode)
|
|
|
|
{
|
|
|
|
int ret, x = 0, y = 0, w = 0, h = 0;
|
|
|
|
|
2005-02-10 01:48:45 -08:00
|
|
|
if (lnode->layout.font.font)
|
|
|
|
{
|
|
|
|
ret = ENFN->font_char_coords_get(ENDT, lnode->layout.font.font,
|
|
|
|
lnode->text,
|
|
|
|
pos - lnode->text_pos,
|
|
|
|
&x, &y, &w, &h);
|
|
|
|
y = lnode->layout.line.y;
|
|
|
|
x += lnode->layout.line.x;
|
|
|
|
h = lnode->layout.line.mascent + lnode->layout.line.mdescent;
|
|
|
|
if (cx) *cx = x;
|
|
|
|
if (cy) *cy = y;
|
|
|
|
if (cw) *cw = w;
|
|
|
|
if (ch) *ch = h;
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
evas_object_textblock_char_coords_get(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Layout_Node *lnode;
|
|
|
|
int ps;
|
|
|
|
Evas_Object_List *l;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (o->format.dirty)
|
2005-02-10 21:33:44 -08:00
|
|
|
evas_object_textblock_format_calc(obj);
|
2005-02-09 08:10:56 -08:00
|
|
|
for (l = (Evas_Object_List *)o->layout_nodes; l; l = l->next)
|
|
|
|
{
|
|
|
|
lnode = (Layout_Node *)l;
|
|
|
|
|
|
|
|
if ((lnode->text) &&
|
|
|
|
(x >= lnode->layout.line.x) &&
|
|
|
|
(x < (lnode->layout.line.x + lnode->layout.line.advance)) &&
|
|
|
|
(y >= lnode->layout.line.y) &&
|
|
|
|
(y < (lnode->layout.line.y + lnode->layout.line.mascent + lnode->layout.line.mdescent)))
|
|
|
|
{
|
|
|
|
int ret, rx = 0, ry = 0, rw = 0, rh = 0;
|
|
|
|
|
2005-02-10 01:48:45 -08:00
|
|
|
if (lnode->layout.font.font)
|
2005-02-09 08:10:56 -08:00
|
|
|
{
|
2005-02-10 01:48:45 -08:00
|
|
|
ret = ENFN->font_char_at_coords_get(ENDT, lnode->layout.font.font,
|
|
|
|
lnode->text,
|
|
|
|
x - lnode->layout.line.x,
|
|
|
|
0,
|
|
|
|
&rx, &ry, &rw, &rh);
|
|
|
|
if (ret < 0)
|
2005-02-09 08:10:56 -08:00
|
|
|
{
|
2005-02-10 01:48:45 -08:00
|
|
|
if ((x - lnode->layout.line.x) <
|
|
|
|
(lnode->layout.line.advance / 2))
|
|
|
|
{
|
|
|
|
ret = ENFN->font_char_coords_get(ENDT, lnode->layout.font.font,
|
|
|
|
lnode->text,
|
|
|
|
0,
|
|
|
|
&rx, &ry, &rw, &rh);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
pos = evas_common_font_utf8_get_last(lnode->text, lnode->text_len);
|
|
|
|
ret = ENFN->font_char_coords_get(ENDT, lnode->layout.font.font,
|
|
|
|
lnode->text,
|
|
|
|
pos,
|
|
|
|
&rx, &ry, &rw, &rh);
|
|
|
|
ret = pos;
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
}
|
2005-02-10 01:48:45 -08:00
|
|
|
ry = lnode->layout.line.y;
|
|
|
|
rx += lnode->layout.line.x;
|
|
|
|
rh = lnode->layout.line.mascent + lnode->layout.line.mdescent;
|
|
|
|
if (cx) *cx = rx;
|
|
|
|
if (cy) *cy = ry;
|
|
|
|
if (cw) *cw = rw;
|
|
|
|
if (ch) *ch = rh;
|
|
|
|
return ret + lnode->text_pos;
|
2005-02-09 08:10:56 -08:00
|
|
|
}
|
2005-02-10 01:48:45 -08:00
|
|
|
return -1;
|
2005-02-09 08:10:56 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2005-01-08 04:47:36 -08:00
|
|
|
void
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_text_insert(Evas_Object *obj, const char *text)
|
2005-01-08 04:47:36 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
2005-01-29 08:28:18 -08:00
|
|
|
Node *node;
|
|
|
|
int ps;
|
2005-01-08 04:47:36 -08:00
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-08 07:25:50 -08:00
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-08 04:47:36 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-29 08:28:18 -08:00
|
|
|
if (!text) return;
|
|
|
|
node = evas_object_textblock_node_pos_get(obj, o->pos, &ps);
|
|
|
|
/* at the end - just append */
|
|
|
|
if (!node)
|
|
|
|
{
|
|
|
|
if (!o->nodes)
|
|
|
|
{
|
|
|
|
node = calloc(1, sizeof(Node));
|
|
|
|
node->text = strdup(text);
|
|
|
|
node->text_len = strlen(node->text);
|
|
|
|
o->pos = node->text_len;
|
|
|
|
o->len = node->text_len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *ntext;
|
|
|
|
|
|
|
|
node = (Node *)(((Evas_Object_List *)(o->nodes))->last);
|
|
|
|
len = strlen(text);
|
|
|
|
ntext = malloc(node->text_len + len + 1);
|
|
|
|
if (node->text) strcpy(ntext, node->text);
|
|
|
|
strcpy(ntext + node->text_len, text);
|
|
|
|
if (node->text) free(node->text);
|
|
|
|
node->text = ntext;
|
|
|
|
node->text_len += len;
|
|
|
|
o->pos += len;
|
|
|
|
o->len += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
char *ntext;
|
|
|
|
|
|
|
|
len = strlen(text);
|
|
|
|
ntext = malloc(node->text_len + len + 1);
|
|
|
|
if (node->text) strncpy(ntext, node->text, o->pos - ps);
|
|
|
|
strcpy(ntext + o->pos - ps, text);
|
|
|
|
if (node->text) strcpy(ntext + o->pos - ps + len, node->text + o->pos - ps);
|
|
|
|
if (node->text) free(node->text);
|
|
|
|
node->text = ntext;
|
|
|
|
node->text_len += len;
|
|
|
|
o->pos += len;
|
|
|
|
o->len += len;
|
|
|
|
}
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
o->native.dirty = 1;
|
2005-02-09 08:10:56 -08:00
|
|
|
o->format.dirty = 1;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
o->changed = 1;
|
|
|
|
evas_object_change(obj);
|
2005-01-08 04:47:36 -08:00
|
|
|
}
|
|
|
|
|
2005-01-30 20:58:41 -08:00
|
|
|
/**
|
2005-02-09 08:10:56 -08:00
|
|
|
* Gets length bytes from the textblock from the current cursor position
|
2005-01-30 20:58:41 -08:00
|
|
|
* @param obj The given textblock.
|
|
|
|
* @param len The number of characters to get from the textblock.
|
|
|
|
* @return Returns NULL on failure, or as many of len characters as were
|
|
|
|
* available. The returned memory must be free'd by the caller.
|
|
|
|
*/
|
2005-01-29 08:28:18 -08:00
|
|
|
char *
|
2005-02-09 08:10:56 -08:00
|
|
|
evas_object_textblock_text_get(Evas_Object *obj, int len)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
2005-01-30 20:58:41 -08:00
|
|
|
char *ret = NULL;
|
|
|
|
int my_len = len;
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2005-01-19 22:54:45 -08:00
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-29 08:28:18 -08:00
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-30 20:58:41 -08:00
|
|
|
|
|
|
|
if (len <= 0) return NULL;
|
2005-02-09 08:10:56 -08:00
|
|
|
if (o->pos > o->len) return NULL;
|
|
|
|
if (len > (o->len - o->pos)) my_len = o->len - o->pos;
|
2005-01-30 20:58:41 -08:00
|
|
|
|
2005-02-10 21:33:44 -08:00
|
|
|
/* CHECK */
|
2005-01-30 20:58:41 -08:00
|
|
|
ret = malloc(sizeof(char) * (my_len + 1));
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
Node *node;
|
|
|
|
int ps = 0;
|
|
|
|
|
2005-02-09 08:10:56 -08:00
|
|
|
node = evas_object_textblock_node_pos_get(obj, o->pos, &ps);
|
2005-01-30 20:58:41 -08:00
|
|
|
if (node)
|
|
|
|
{
|
2005-02-09 08:10:56 -08:00
|
|
|
if ((node->text_len - (o->pos - ps)) >= my_len)
|
|
|
|
memcpy(ret, node->text + (o->pos - ps), my_len);
|
2005-01-30 20:58:41 -08:00
|
|
|
else
|
|
|
|
{
|
2005-02-09 08:10:56 -08:00
|
|
|
int remaining = my_len - (node->text_len - (o->pos - ps));
|
|
|
|
int count = (node->text_len - (o->pos - ps));
|
2005-01-30 20:58:41 -08:00
|
|
|
|
2005-02-09 08:10:56 -08:00
|
|
|
memcpy(ret, node->text + (o->pos - ps), node->text_len - (o->pos - ps));
|
2005-01-30 20:58:41 -08:00
|
|
|
|
2005-02-10 21:33:44 -08:00
|
|
|
while (remaining > 0)
|
2005-01-30 20:58:41 -08:00
|
|
|
{
|
2005-02-09 08:10:56 -08:00
|
|
|
node = evas_object_textblock_node_pos_get(obj, o->pos + count, &ps);
|
2005-01-30 20:58:41 -08:00
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
int amt = 0;
|
2005-02-10 21:33:44 -08:00
|
|
|
|
2005-01-30 20:58:41 -08:00
|
|
|
if (node->text_len >= remaining)
|
|
|
|
amt = remaining;
|
|
|
|
else
|
|
|
|
amt = node->text_len;
|
|
|
|
|
|
|
|
memcpy(ret + count, node->text, amt);
|
|
|
|
remaining -= amt;
|
|
|
|
count += amt;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we ran out of nodes ... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-10 21:33:44 -08:00
|
|
|
ret[my_len] = 0;
|
2005-01-30 20:58:41 -08:00
|
|
|
}
|
|
|
|
return ret;
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
2005-01-31 23:58:02 -08:00
|
|
|
/**
|
|
|
|
* Removes length bytes from the textblock from the current cursor position.
|
|
|
|
* @param obj The given textblock.
|
|
|
|
* @param len The number of bytes to remove
|
|
|
|
* @return Returns no value.
|
|
|
|
*/
|
2005-01-19 22:54:45 -08:00
|
|
|
void
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_text_del(Evas_Object *obj, int len)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
2005-01-31 23:58:02 -08:00
|
|
|
Node *node;
|
|
|
|
int my_len, ps = 0;
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-31 23:58:02 -08:00
|
|
|
|
|
|
|
if (len <= 0) return;
|
|
|
|
if (o->pos >= o->len) return;
|
|
|
|
|
|
|
|
/* deleting everything */
|
|
|
|
if ((o->pos == 0) && (len >= o->len))
|
|
|
|
{
|
|
|
|
evas_object_textblock_clear(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure we have enough to remove */
|
|
|
|
my_len = len;
|
|
|
|
if ((o->len - o->pos) < len) my_len = o->len - o->pos;
|
|
|
|
|
|
|
|
node = evas_object_textblock_node_pos_get(obj, o->pos, &ps);
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
int remaining;
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
remaining = my_len;
|
|
|
|
if (remaining <= (node->text_len - (o->pos - ps)))
|
|
|
|
{
|
2005-02-10 21:33:44 -08:00
|
|
|
printf("CASE 1\n");
|
2005-01-31 23:58:02 -08:00
|
|
|
tmp = node->text;
|
|
|
|
node->text = malloc(sizeof(char) * (node->text_len - my_len + 1));
|
|
|
|
|
|
|
|
/* any begining text */
|
|
|
|
if ((o->pos - ps) > 0)
|
|
|
|
strncpy(node->text, tmp, o->pos - ps);
|
2005-02-10 21:33:44 -08:00
|
|
|
node->text[o->pos - ps] = 0;
|
|
|
|
|
2005-01-31 23:58:02 -08:00
|
|
|
/* any ending text */
|
|
|
|
if (((o->pos - ps) + remaining) < node->text_len)
|
2005-02-10 21:33:44 -08:00
|
|
|
strcpy(node->text + (o->pos - ps),
|
|
|
|
tmp + remaining + (o->pos - ps));
|
2005-01-31 23:58:02 -08:00
|
|
|
|
|
|
|
free(tmp);
|
|
|
|
node->text_len -= remaining;
|
|
|
|
o->len -= remaining;
|
|
|
|
|
|
|
|
/* is the node now empty? */
|
2005-02-10 21:33:44 -08:00
|
|
|
if (node->text_len <= 0)
|
2005-01-31 23:58:02 -08:00
|
|
|
{
|
|
|
|
o->nodes = evas_object_list_remove(o->nodes, node);
|
|
|
|
if (node->format) free(node->format);
|
|
|
|
if (node->text) free(node->text);
|
|
|
|
free(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-02-10 21:33:44 -08:00
|
|
|
Evas_List *freenodes = NULL;
|
|
|
|
Node *node_start = NULL, *node_end = NULL;
|
|
|
|
|
|
|
|
printf("CASE 2\n");
|
|
|
|
node_start = node_end = node;
|
2005-01-31 23:58:02 -08:00
|
|
|
tmp = node->text;
|
|
|
|
node->text = malloc(sizeof(char) * (o->pos - ps + 1));
|
|
|
|
|
|
|
|
/* save the start part */
|
|
|
|
strncpy(node->text, tmp, o->pos - ps);
|
2005-02-10 21:33:44 -08:00
|
|
|
node->text[o->pos - ps] = 0;
|
2005-01-31 23:58:02 -08:00
|
|
|
|
|
|
|
o->len -= node->text_len - (o->pos - ps);
|
|
|
|
remaining -= node->text_len - (o->pos - ps);
|
|
|
|
node->text_len = o->pos - ps;
|
|
|
|
free(tmp);
|
|
|
|
ps += node->text_len;
|
2005-02-10 21:33:44 -08:00
|
|
|
|
|
|
|
if (node->text_len <= 0)
|
|
|
|
freenodes = evas_list_append(freenodes, node);
|
|
|
|
|
|
|
|
while (remaining > 0)
|
2005-01-31 23:58:02 -08:00
|
|
|
{
|
2005-02-10 21:33:44 -08:00
|
|
|
/* find next text node */
|
|
|
|
node = (Node *)(((Evas_Object_List *)node)->next);
|
|
|
|
while ((node) && (!node->text))
|
|
|
|
node = (Node *)(((Evas_Object_List *)node)->next);
|
|
|
|
if (!node) break;
|
2005-01-31 23:58:02 -08:00
|
|
|
|
|
|
|
if (remaining < node->text_len)
|
|
|
|
{
|
|
|
|
tmp = node->text;
|
2005-02-10 21:33:44 -08:00
|
|
|
|
2005-01-31 23:58:02 -08:00
|
|
|
node->text = malloc(sizeof(char) * (node->text_len - remaining + 1));
|
2005-02-10 21:33:44 -08:00
|
|
|
strcpy(node->text, tmp + remaining);
|
2005-01-31 23:58:02 -08:00
|
|
|
node->text_len -= remaining;
|
|
|
|
free(tmp);
|
|
|
|
|
|
|
|
o->len -= remaining;
|
|
|
|
remaining -= remaining;
|
2005-02-10 21:33:44 -08:00
|
|
|
node_end = node;
|
2005-01-31 23:58:02 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-02-10 21:33:44 -08:00
|
|
|
node_end = node;
|
|
|
|
freenodes = evas_list_append(freenodes, node);
|
2005-01-31 23:58:02 -08:00
|
|
|
}
|
|
|
|
}
|
2005-02-10 21:33:44 -08:00
|
|
|
/* FIXME: fix up format nodes inbetween node_start and node_end */
|
|
|
|
while (freenodes)
|
|
|
|
{
|
|
|
|
node = freenodes->data;
|
|
|
|
o->len -= node->text_len;
|
|
|
|
freenodes = evas_list_remove_list(freenodes, freenodes);
|
|
|
|
o->nodes = evas_object_list_remove(o->nodes, node);
|
|
|
|
if (node->format) free(node->format);
|
|
|
|
if (node->text) free(node->text);
|
|
|
|
free(node);
|
|
|
|
}
|
2005-01-31 23:58:02 -08:00
|
|
|
}
|
|
|
|
}
|
2005-02-10 21:33:44 -08:00
|
|
|
o->native.dirty = 1;
|
|
|
|
o->format.dirty = 1;
|
|
|
|
o->changed = 1;
|
|
|
|
evas_object_change(obj);
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_format_insert(Evas_Object *obj, const char *format)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
Node *node;
|
|
|
|
int ps;
|
|
|
|
char *nformat;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
node = evas_object_textblock_node_pos_get(obj, o->pos, &ps);
|
|
|
|
/* at the end - just append */
|
|
|
|
if (!node)
|
|
|
|
{
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
nformat = evas_object_textblock_format_merge(NULL, (char *)format);
|
|
|
|
if (nformat)
|
2005-01-29 08:28:18 -08:00
|
|
|
{
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
node = calloc(1, sizeof(Node));
|
|
|
|
node->format = nformat;
|
|
|
|
o->nodes = evas_object_list_append(o->nodes, node);
|
2005-01-29 08:28:18 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
char *ntext1, *ntext2;
|
2005-01-29 08:28:18 -08:00
|
|
|
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
ntext1 = malloc(o->pos - ps + 1);
|
|
|
|
ntext2 = malloc(node->text_len - (o->pos - ps) + 1);
|
|
|
|
strncpy(ntext1, node->text, o->pos - ps);
|
|
|
|
ntext1[o->pos - ps] = 0;
|
|
|
|
strcpy(ntext2, node->text + o->pos - ps);
|
|
|
|
free(node->text);
|
|
|
|
node->text = ntext1;
|
|
|
|
node->text_len = o->pos - ps;
|
|
|
|
nformat = evas_object_textblock_format_merge(NULL, (char *)format);
|
|
|
|
if (nformat)
|
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
node = calloc(1, sizeof(Node));
|
|
|
|
node->format = nformat;
|
|
|
|
o->nodes = evas_object_list_append(o->nodes, node);
|
|
|
|
}
|
|
|
|
}
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
o->native.dirty = 1;
|
2005-02-09 08:10:56 -08:00
|
|
|
o->format.dirty = 1;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
o->changed = 1;
|
|
|
|
evas_object_change(obj);
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
int
|
|
|
|
evas_object_textblock_format_next_pos_get(Evas_Object *obj)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
2005-02-09 08:10:56 -08:00
|
|
|
/* FIXME: DO */
|
2005-01-29 08:28:18 -08:00
|
|
|
return -1;
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
int
|
|
|
|
evas_object_textblock_format_prev_pos_get(Evas_Object *obj)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return -1;
|
|
|
|
MAGIC_CHECK_END();
|
2005-02-09 08:10:56 -08:00
|
|
|
/* FIXME: DO */
|
2005-01-29 08:28:18 -08:00
|
|
|
return -1;
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
char *
|
|
|
|
evas_object_textblock_format_get(Evas_Object *obj)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
2005-02-09 08:10:56 -08:00
|
|
|
/* FIXME: DO */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
evas_object_textblock_current_format_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return NULL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
/* FIXME: DO */
|
2005-01-29 08:28:18 -08:00
|
|
|
return NULL;
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_format_del(Evas_Object *obj)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-02-09 08:10:56 -08:00
|
|
|
/* FIXME: DO */
|
2005-01-29 08:28:18 -08:00
|
|
|
o->native.dirty = 1;
|
2005-02-09 08:10:56 -08:00
|
|
|
o->format.dirty = 1;
|
2005-01-29 08:28:18 -08:00
|
|
|
o->changed = 1;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
evas_object_change(obj);
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_format_direction_set(Evas_Object *obj, Evas_Format_Direction dir)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
if (o->format_dir == dir) return;
|
2005-02-10 01:48:45 -08:00
|
|
|
/* FIXME: DOES NOTHING YET - FUTURE FEATRUE */
|
2005-01-29 08:28:18 -08:00
|
|
|
o->native.dirty = 1;
|
2005-02-09 08:10:56 -08:00
|
|
|
o->format.dirty = 1;
|
2005-01-29 08:28:18 -08:00
|
|
|
o->changed = 1;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
evas_object_change(obj);
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Format_Direction
|
|
|
|
evas_object_textblock_format_direction_get(Evas_Object *obj)
|
2005-01-19 22:54:45 -08:00
|
|
|
{
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
return EVAS_FORMAT_DIRECTION_VERTICAL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
return EVAS_FORMAT_DIRECTION_VERTICAL;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
return o->format_dir;
|
2005-01-19 22:54:45 -08:00
|
|
|
}
|
|
|
|
|
2005-02-06 18:12:36 -08:00
|
|
|
void
|
|
|
|
evas_object_textblock_format_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-02-09 08:10:56 -08:00
|
|
|
if (o->format.dirty)
|
2005-02-10 21:33:44 -08:00
|
|
|
evas_object_textblock_format_calc(obj);
|
2005-02-06 18:12:36 -08:00
|
|
|
if (w) *w = o->format.w;
|
|
|
|
if (h) *h = o->format.h;
|
|
|
|
}
|
|
|
|
|
2005-01-08 04:47:36 -08:00
|
|
|
void
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_native_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
|
2005-01-08 04:47:36 -08:00
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
|
2005-01-29 08:28:18 -08:00
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
2005-01-08 04:47:36 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-08 07:25:50 -08:00
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
2005-01-29 08:28:18 -08:00
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
2005-01-08 04:47:36 -08:00
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
2005-01-29 08:28:18 -08:00
|
|
|
if (o->native.dirty)
|
|
|
|
{
|
2005-02-09 08:10:56 -08:00
|
|
|
/* FIXME: DO */
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_native_calc(obj);
|
|
|
|
o->native.dirty = 0;
|
|
|
|
}
|
|
|
|
if (w) *w = o->native.w;
|
|
|
|
if (h) *h = o->native.h;
|
2005-01-08 04:47:36 -08:00
|
|
|
}
|
|
|
|
|
2005-01-08 02:02:18 -08:00
|
|
|
/* all nice and private */
|
|
|
|
static void
|
|
|
|
evas_object_textblock_init(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
/* alloc image ob, setup methods and default values */
|
|
|
|
obj->object_data = evas_object_textblock_new();
|
|
|
|
/* set up default settings for this kind of object */
|
|
|
|
obj->cur.color.r = 255;
|
|
|
|
obj->cur.color.g = 255;
|
|
|
|
obj->cur.color.b = 255;
|
|
|
|
obj->cur.color.a = 255;
|
|
|
|
obj->cur.geometry.x = 0.0;
|
|
|
|
obj->cur.geometry.y = 0.0;
|
|
|
|
obj->cur.geometry.w = 0.0;
|
|
|
|
obj->cur.geometry.h = 0.0;
|
|
|
|
obj->cur.layer = 0;
|
|
|
|
/* set up object-specific settings */
|
|
|
|
obj->prev = obj->cur;
|
|
|
|
/* set up methods (compulsory) */
|
|
|
|
obj->func = &object_func;
|
|
|
|
obj->type = o_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
evas_object_textblock_new(void)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
/* alloc obj private data */
|
|
|
|
o = calloc(1, sizeof(Evas_Object_Textblock));
|
|
|
|
o->magic = MAGIC_OBJ_TEXTBLOCK;
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_free(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
/* frees private object data. very simple here */
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
MAGIC_CHECK(o, Evas_Object_Textblock, MAGIC_OBJ_TEXTBLOCK);
|
|
|
|
return;
|
|
|
|
MAGIC_CHECK_END();
|
|
|
|
/* free obj */
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_layout_clean(obj);
|
|
|
|
evas_object_textblock_contents_clean(obj);
|
2005-01-08 02:02:18 -08:00
|
|
|
o->magic = 0;
|
|
|
|
free(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_render(Evas_Object *obj, void *output, void *context, void *surface, int x, int y)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
2005-01-29 08:28:18 -08:00
|
|
|
Evas_Object_List *l;
|
2005-02-05 07:53:58 -08:00
|
|
|
int pbackx;
|
2005-01-29 08:28:18 -08:00
|
|
|
|
2005-01-08 02:02:18 -08:00
|
|
|
/* render object to surface with context, and offxet by x,y */
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
obj->layer->evas->engine.func->context_multiplier_unset(output,
|
|
|
|
context);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if (o->changed)
|
|
|
|
{
|
2005-02-10 21:33:44 -08:00
|
|
|
if (o->format.dirty)
|
|
|
|
evas_object_textblock_format_calc(obj);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
o->changed = 0;
|
|
|
|
}
|
2005-02-09 08:10:56 -08:00
|
|
|
#if 0
|
2005-01-30 06:19:06 -08:00
|
|
|
obj->layer->evas->engine.func->context_color_set(output,
|
|
|
|
context,
|
|
|
|
230, 160, 30, 100);
|
|
|
|
obj->layer->evas->engine.func->rectangle_draw(output,
|
|
|
|
context,
|
|
|
|
surface,
|
|
|
|
obj->cur.cache.geometry.x + x,
|
|
|
|
obj->cur.cache.geometry.y + y,
|
|
|
|
obj->cur.cache.geometry.w,
|
|
|
|
obj->cur.cache.geometry.h);
|
2005-02-09 08:10:56 -08:00
|
|
|
#endif
|
2005-01-29 08:28:18 -08:00
|
|
|
for (l = (Evas_Object_List *)o->layout_nodes; l; l = l->next)
|
2005-01-08 02:02:18 -08:00
|
|
|
{
|
2005-02-05 07:53:58 -08:00
|
|
|
Layout_Node *lnode, *nlnode;
|
2005-01-08 02:02:18 -08:00
|
|
|
|
2005-01-29 08:28:18 -08:00
|
|
|
lnode = (Layout_Node *)l;
|
2005-02-05 07:53:58 -08:00
|
|
|
nlnode = (Layout_Node *)(l->next);
|
|
|
|
if (lnode->line_start) pbackx = 0;
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
if ((lnode->layout.font.font) && (lnode->text))
|
2005-01-30 06:19:06 -08:00
|
|
|
{
|
2005-02-09 08:10:56 -08:00
|
|
|
int lin;
|
|
|
|
int inset = 0;
|
|
|
|
|
|
|
|
lin = 0;
|
|
|
|
if (lnode->layout.underline) lin++;
|
|
|
|
if (lnode->layout.second_underline) lin++;
|
|
|
|
if (lnode->layout.strikethrough) lin++;
|
|
|
|
if (lnode->layout.backing) lin++;
|
|
|
|
if (lin > 0)
|
|
|
|
inset = ENFN->font_inset_get(ENDT,
|
|
|
|
lnode->layout.font.font,
|
|
|
|
lnode->text);
|
|
|
|
if (lnode->layout.backing)
|
2005-02-05 07:53:58 -08:00
|
|
|
{
|
2005-02-09 08:10:56 -08:00
|
|
|
int bx;
|
|
|
|
|
2005-02-05 07:53:58 -08:00
|
|
|
ENFN->context_color_set(output,
|
|
|
|
context,
|
2005-02-09 08:10:56 -08:00
|
|
|
(obj->cur.cache.clip.r * lnode->layout.backing_color.r) / 255,
|
|
|
|
(obj->cur.cache.clip.g * lnode->layout.backing_color.g) / 255,
|
|
|
|
(obj->cur.cache.clip.b * lnode->layout.backing_color.b) / 255,
|
|
|
|
(obj->cur.cache.clip.a * lnode->layout.backing_color.a) / 255);
|
|
|
|
bx = lnode->layout.line.x + inset;
|
|
|
|
if (pbackx > 0) bx = pbackx;
|
|
|
|
pbackx = bx + lnode->layout.line.advance;
|
|
|
|
if (((nlnode) && ((nlnode->line_start) ||
|
|
|
|
(!nlnode->layout.backing))) ||
|
|
|
|
(!nlnode))
|
|
|
|
ENFN->rectangle_draw(output,
|
|
|
|
context,
|
|
|
|
surface,
|
|
|
|
obj->cur.cache.geometry.x +
|
|
|
|
bx + x,
|
|
|
|
obj->cur.cache.geometry.y +
|
|
|
|
lnode->layout.line.y + y,
|
|
|
|
lnode->w,
|
|
|
|
lnode->layout.line.mascent + lnode->layout.line.mdescent);
|
|
|
|
else
|
|
|
|
ENFN->rectangle_draw(output,
|
|
|
|
context,
|
|
|
|
surface,
|
|
|
|
obj->cur.cache.geometry.x +
|
|
|
|
bx + x,
|
|
|
|
obj->cur.cache.geometry.y +
|
|
|
|
lnode->layout.line.y + y,
|
|
|
|
lnode->layout.line.advance,
|
|
|
|
lnode->layout.line.mascent + lnode->layout.line.mdescent);
|
2005-02-05 07:53:58 -08:00
|
|
|
}
|
2005-01-30 06:19:06 -08:00
|
|
|
else
|
2005-02-09 08:10:56 -08:00
|
|
|
pbackx = 0;
|
|
|
|
ENFN->context_color_set(output,
|
|
|
|
context,
|
|
|
|
(obj->cur.cache.clip.r * lnode->layout.color.r) / 255,
|
|
|
|
(obj->cur.cache.clip.g * lnode->layout.color.g) / 255,
|
|
|
|
(obj->cur.cache.clip.b * lnode->layout.color.b) / 255,
|
|
|
|
(obj->cur.cache.clip.a * lnode->layout.color.a) / 255);
|
|
|
|
if (lnode->layout.valign < 0.0)
|
|
|
|
ENFN->font_draw(output,
|
|
|
|
context,
|
|
|
|
surface,
|
|
|
|
lnode->layout.font.font,
|
|
|
|
obj->cur.cache.geometry.x +
|
|
|
|
lnode->layout.line.x + x,
|
|
|
|
obj->cur.cache.geometry.y +
|
|
|
|
lnode->layout.line.y + y +
|
|
|
|
lnode->layout.line.mascent,
|
|
|
|
lnode->w,
|
|
|
|
lnode->h,
|
|
|
|
lnode->w,
|
|
|
|
lnode->h,
|
|
|
|
lnode->text);
|
|
|
|
else
|
|
|
|
ENFN->font_draw(output,
|
|
|
|
context,
|
|
|
|
surface,
|
|
|
|
lnode->layout.font.font,
|
|
|
|
obj->cur.cache.geometry.x +
|
|
|
|
lnode->layout.line.x + x,
|
|
|
|
obj->cur.cache.geometry.y +
|
|
|
|
lnode->layout.line.y + y +
|
2005-02-09 17:07:36 -08:00
|
|
|
((double)((lnode->layout.line.mascent +
|
|
|
|
lnode->layout.line.mdescent) -
|
|
|
|
(lnode->layout.line.ascent +
|
|
|
|
lnode->layout.line.descent)) *
|
|
|
|
lnode->layout.valign) +
|
2005-02-09 08:10:56 -08:00
|
|
|
lnode->layout.line.ascent,
|
|
|
|
lnode->w,
|
|
|
|
lnode->h,
|
|
|
|
lnode->w,
|
|
|
|
lnode->h,
|
|
|
|
lnode->text);
|
|
|
|
if (lnode->layout.underline)
|
|
|
|
{
|
|
|
|
ENFN->context_color_set(output,
|
|
|
|
context,
|
|
|
|
(obj->cur.cache.clip.r * lnode->layout.underline_color.r) / 255,
|
|
|
|
(obj->cur.cache.clip.g * lnode->layout.underline_color.g) / 255,
|
|
|
|
(obj->cur.cache.clip.b * lnode->layout.underline_color.b) / 255,
|
|
|
|
(obj->cur.cache.clip.a * lnode->layout.underline_color.a) / 255);
|
|
|
|
ENFN->rectangle_draw(output,
|
|
|
|
context,
|
|
|
|
surface,
|
|
|
|
obj->cur.cache.geometry.x +
|
|
|
|
lnode->layout.line.x + x + inset,
|
|
|
|
obj->cur.cache.geometry.y +
|
|
|
|
lnode->layout.line.y + y +
|
|
|
|
lnode->layout.line.mascent + 1,
|
|
|
|
lnode->w,
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
if (lnode->layout.second_underline)
|
|
|
|
{
|
|
|
|
ENFN->context_color_set(output,
|
|
|
|
context,
|
|
|
|
(obj->cur.cache.clip.r * lnode->layout.double_underline_color.r) / 255,
|
|
|
|
(obj->cur.cache.clip.g * lnode->layout.double_underline_color.g) / 255,
|
|
|
|
(obj->cur.cache.clip.b * lnode->layout.double_underline_color.b) / 255,
|
|
|
|
(obj->cur.cache.clip.a * lnode->layout.double_underline_color.a) / 255);
|
|
|
|
ENFN->rectangle_draw(output,
|
|
|
|
context,
|
|
|
|
surface,
|
|
|
|
obj->cur.cache.geometry.x +
|
|
|
|
lnode->layout.line.x + x + inset,
|
|
|
|
obj->cur.cache.geometry.y +
|
|
|
|
lnode->layout.line.y + y +
|
|
|
|
lnode->layout.line.mascent + 3,
|
|
|
|
lnode->w,
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
if (lnode->layout.strikethrough)
|
2005-02-05 07:53:58 -08:00
|
|
|
{
|
|
|
|
ENFN->context_color_set(output,
|
|
|
|
context,
|
2005-02-09 08:10:56 -08:00
|
|
|
(obj->cur.cache.clip.r * lnode->layout.strikethrough_color.r) / 255,
|
|
|
|
(obj->cur.cache.clip.g * lnode->layout.strikethrough_color.g) / 255,
|
|
|
|
(obj->cur.cache.clip.b * lnode->layout.strikethrough_color.b) / 255,
|
|
|
|
(obj->cur.cache.clip.a * lnode->layout.strikethrough_color.a) / 255);
|
|
|
|
ENFN->rectangle_draw(output,
|
|
|
|
context,
|
|
|
|
surface,
|
|
|
|
obj->cur.cache.geometry.x +
|
|
|
|
lnode->layout.line.x + x + inset,
|
|
|
|
obj->cur.cache.geometry.y +
|
|
|
|
lnode->layout.line.y + y +
|
|
|
|
lnode->layout.line.mascent - ((lnode->layout.line.ascent - lnode->layout.line.descent) / 2),
|
|
|
|
lnode->w,
|
|
|
|
1);
|
2005-02-05 07:53:58 -08:00
|
|
|
}
|
2005-01-30 06:19:06 -08:00
|
|
|
}
|
2005-01-08 02:02:18 -08:00
|
|
|
}
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
/*
|
|
|
|
if (o->engine_data)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
2005-01-08 02:02:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_render_pre(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_List *updates = NULL;
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
int is_v, was_v;
|
|
|
|
|
|
|
|
/* dont pre-render the obj twice! */
|
|
|
|
if (obj->pre_render_done) return;
|
|
|
|
obj->pre_render_done = 1;
|
|
|
|
/* pre-render phase. this does anything an object needs to do just before */
|
|
|
|
/* rendering. this could mean loading the image data, retrieving it from */
|
|
|
|
/* elsewhere, decoding video etc. */
|
|
|
|
/* then when this is done the object needs to figure if it changed and */
|
|
|
|
/* if so what and where and add the appropriate redraw textblocks */
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
/* if someone is clipping this obj - go calculate the clipper */
|
|
|
|
if (obj->cur.clipper)
|
|
|
|
{
|
|
|
|
evas_object_clip_recalc(obj->cur.clipper);
|
|
|
|
obj->cur.clipper->func->render_pre(obj->cur.clipper);
|
|
|
|
}
|
|
|
|
/* now figure what changed and add draw rects */
|
|
|
|
/* if it just became visible or invisible */
|
|
|
|
is_v = evas_object_is_visible(obj);
|
|
|
|
was_v = evas_object_was_visible(obj);
|
|
|
|
if (is_v != was_v)
|
|
|
|
{
|
|
|
|
updates = evas_object_render_pre_visible_change(updates, obj, is_v, was_v);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/* it's not visible - we accounted for it appearing or not so just abort */
|
|
|
|
if (!is_v) goto done;
|
|
|
|
/* clipper changed this is in addition to anything else for obj */
|
|
|
|
updates = evas_object_render_pre_clipper_change(updates, obj);
|
|
|
|
/* if we restacked (layer or just within a layer) and don't clip anyone */
|
|
|
|
if (obj->restack)
|
|
|
|
{
|
|
|
|
updates = evas_object_render_pre_prev_cur_add(updates, obj);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/* if it changed color */
|
|
|
|
if ((obj->cur.color.r != obj->prev.color.r) ||
|
|
|
|
(obj->cur.color.g != obj->prev.color.g) ||
|
|
|
|
(obj->cur.color.b != obj->prev.color.b) ||
|
|
|
|
(obj->cur.color.a != obj->prev.color.a))
|
|
|
|
{
|
|
|
|
updates = evas_object_render_pre_prev_cur_add(updates, obj);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (o->changed)
|
|
|
|
{
|
2005-01-30 03:41:01 -08:00
|
|
|
/*
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
Evas_Rectangle *r;
|
|
|
|
|
|
|
|
r = malloc(sizeof(Evas_Rectangle));
|
|
|
|
r->x = 0; r->y = 0;
|
|
|
|
r->w = obj->cur.geometry.w;
|
|
|
|
r->h = obj->cur.geometry.h;
|
|
|
|
updates = evas_list_append(updates, r);
|
2005-01-30 03:41:01 -08:00
|
|
|
*/
|
|
|
|
updates = evas_object_render_pre_prev_cur_add(updates, obj);
|
2005-01-31 01:32:31 -08:00
|
|
|
evas_object_textblock_layout_fonts_hold(obj);
|
2005-01-29 08:28:18 -08:00
|
|
|
evas_object_textblock_layout_clean(obj);
|
|
|
|
evas_object_textblock_layout(obj);
|
2005-01-31 01:32:31 -08:00
|
|
|
evas_object_textblock_layout_fonts_hold_clean(obj);
|
the textblock actually works.
so far the following works:
o = evas_object_textblock_add(evas);
evas_object_move(o, 10, 40);
evas_object_resize(o, win_w - 20, win_h - 50);
evas_object_textblock_format_insert(o, "color=#000000ff");
evas_object_textblock_format_insert(o, "font=/usr/local/share/expedite/data/Vera.ttf size=10");
evas_object_textblock_text_insert(o, "This is 1 line. ");
evas_object_textblock_text_insert(o, "And some more text. ");
evas_object_textblock_format_insert(o, "size=20");
evas_object_textblock_format_insert(o, "color=#f80");
evas_object_textblock_text_insert(o, "Bigger orange text.");
evas_object_textblock_format_insert(o, "size=8");
evas_object_textblock_format_insert(o, "color=#0000ff88");
evas_object_textblock_format_insert(o, "\n");
evas_object_textblock_text_insert(o, "A second line of transparent blue.");
evas_object_show(o);
i need to implement alignment handling next...
SVN revision: 13135
2005-01-30 02:22:47 -08:00
|
|
|
o->changed = 0;
|
2005-01-08 02:02:18 -08:00
|
|
|
}
|
|
|
|
done:
|
|
|
|
evas_object_render_pre_effect_updates(updates, obj, is_v, was_v);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_render_post(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
/* this moves the current data to the previous state parts of the object */
|
|
|
|
/* in whatever way is safest for the object. also if we don't need object */
|
|
|
|
/* data anymore we can free it if the object deems this is a good idea */
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
/* remove those pesky changes */
|
|
|
|
while (obj->clip.changes)
|
|
|
|
{
|
|
|
|
Evas_Rectangle *r;
|
|
|
|
|
|
|
|
r = (Evas_Rectangle *)obj->clip.changes->data;
|
|
|
|
obj->clip.changes = evas_list_remove(obj->clip.changes, r);
|
|
|
|
free(r);
|
|
|
|
}
|
|
|
|
/* move cur to prev safely for object data */
|
|
|
|
obj->prev = obj->cur;
|
|
|
|
o->prev = o->cur;
|
|
|
|
o->changed = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
evas_object_textblock_is_opaque(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
/* this returns 1 if the internal object data implies that the object is */
|
|
|
|
/* currently fulyl opque over the entire gradient it occupies */
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
evas_object_textblock_was_opaque(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
/* this returns 1 if the internal object data implies that the object was */
|
|
|
|
/* currently fulyl opque over the entire gradient it occupies */
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-01-29 08:28:18 -08:00
|
|
|
|
|
|
|
static void
|
|
|
|
evas_object_textblock_coords_recalc(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object_Textblock *o;
|
|
|
|
|
|
|
|
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
|
|
if ((obj->cur.geometry.w != o->last_w) ||
|
|
|
|
(obj->cur.geometry.h != o->last_h))
|
|
|
|
{
|
2005-02-09 08:10:56 -08:00
|
|
|
o->format.dirty = 1;
|
2005-01-29 08:28:18 -08:00
|
|
|
o->changed = 1;
|
|
|
|
}
|
|
|
|
}
|