566 lines
21 KiB
Plaintext
566 lines
21 KiB
Plaintext
import efl_text_types;
|
|
|
|
class @beta Efl.Canvas.Textblock extends Efl.Canvas.Object implements Efl.Text,
|
|
Efl.Canvas.Filter.Internal, Efl.Text_Font,
|
|
Efl.Text_Style, Efl.Text_Format,
|
|
Efl.Text_Markup, Efl.Ui.I18n
|
|
{
|
|
[[This is the Canvas-level text class. This class only takes care of rendering text,
|
|
if you need user interaction consider the classes in $Efl.Ui.]]
|
|
methods {
|
|
@property is_empty {
|
|
[[Whether the object is empty (no text) or not.
|
|
]]
|
|
get {
|
|
}
|
|
values {
|
|
is_empty: bool; [[$true if empty.]]
|
|
}
|
|
}
|
|
cursor_add {
|
|
[[Adds an existing cursor to the text object.
|
|
If the cursor already belonged to another text object it will be reassigned to the new one.
|
|
It is typically more convenient to obtain a cursor directly from the text object using @.cursor_create.
|
|
]]
|
|
params {
|
|
cursor: Efl.Text.Cursor; [[The text cursor to use.]]
|
|
}
|
|
}
|
|
cursor_create {
|
|
[[Creates a new cursor and adds it to the text object.
|
|
This cursor can be used to manipulate and iterate the content of the text object.
|
|
]]
|
|
return: Efl.Text.Cursor @move; [[The created text cursor.]]
|
|
}
|
|
visible_range_get {
|
|
[[Returns the currently visible range.
|
|
|
|
The given $start and $end cursors are output variables:
|
|
they are set to the positions of the start and the end of the
|
|
visible range in the text, respectively.
|
|
]]
|
|
return: bool; [[$true on success.]]
|
|
params {
|
|
@in start: Efl.Text.Cursor; [[Range start position.]]
|
|
@in end: Efl.Text.Cursor; [[Range end position.]]
|
|
}
|
|
}
|
|
@property style_insets {
|
|
[[Gets the left, right, top and bottom insets of the text.
|
|
|
|
The inset is any applied padding on the text.
|
|
]]
|
|
get {}
|
|
values {
|
|
l: int; [[Left padding.]]
|
|
r: int; [[Right padding.]]
|
|
t: int; [[Top padding.]]
|
|
b: int; [[Bottom padding.]]
|
|
}
|
|
}
|
|
@property bidi_delimiters {
|
|
[[BiDi delimiters are used for in-paragraph separation of bidirectional
|
|
segments. This is useful, for example, in the recipient fields of
|
|
e-mail clients where bidi oddities can occur when mixing RTL (right-to-left)
|
|
and LTR (left-to-right) text.
|
|
]]
|
|
set {}
|
|
get {}
|
|
values {
|
|
delim: string; [[A null terminated string of delimiters, e.g ",|" or $null if empty.]]
|
|
}
|
|
}
|
|
@property newline_as_paragraph_separator {
|
|
[[When $true, the newline character will behave as a paragraph separator.
|
|
]]
|
|
set {}
|
|
get {}
|
|
values {
|
|
mode: bool; [[$true for legacy mode, $false otherwise.]]
|
|
}
|
|
}
|
|
style_apply {
|
|
[[Applies a style to the text object. Applied style attributes override old ones, leaving other attributes
|
|
unaffected.
|
|
This is similar to setting individual style attributes using properties like @Efl.Text_Font.font_slant or
|
|
@Efl.Text_Format.wrap.
|
|
|
|
The style can be set as "attribute"="Value".
|
|
Multible attribute can be set at once separated by space.
|
|
|
|
The following styling attributes are accepted:
|
|
|
|
- Font
|
|
- Font fallback
|
|
- Font size
|
|
- Font source
|
|
- Font weight
|
|
- Font style
|
|
- Font width
|
|
- Language
|
|
- Color
|
|
- Underline Color
|
|
- Second Underline Color
|
|
- Underline Dash Color
|
|
- Outline Color
|
|
- Shadow Color
|
|
- First Glow Color
|
|
- Second Glow Color
|
|
- Backing Color
|
|
- Strikethrough Color
|
|
- Horizontal Align
|
|
- Vertical Align
|
|
- Wrap
|
|
- Left margin
|
|
- Right margin
|
|
- Underline
|
|
- Strikethrough
|
|
- Backing
|
|
- Style
|
|
- Tabstops
|
|
- Line size
|
|
- Relative line size
|
|
- Line gap
|
|
- Relative line gap
|
|
- Item
|
|
- Line fill
|
|
- Ellipsis
|
|
- Password
|
|
- Underline dash width
|
|
- Underline dash gap
|
|
- Underline height
|
|
|
|
Font
|
|
This sets the name of the font to be used.
|
|
font=<font name>
|
|
|
|
Font fallback
|
|
A comma delimited list of fonts to try if finding the primary font fails.
|
|
font_fallbacks=<font names>
|
|
|
|
Font size
|
|
This sets the the size of font in points to be used.
|
|
font_size=<size>
|
|
|
|
Font source
|
|
Specify source from which to search for the font.
|
|
font_source=<source>
|
|
|
|
Font weight
|
|
Sets the weight of the font. The value must be one of:
|
|
"normal"
|
|
"thin"
|
|
"ultralight"
|
|
"extralight"
|
|
"light"
|
|
"book"
|
|
"medium"
|
|
"semibold"
|
|
"bold"
|
|
"ultrabold"
|
|
"extrabold"
|
|
"black"
|
|
"extrablack"
|
|
font_weight=<weight>
|
|
|
|
Font style
|
|
Sets the style of the font. The value must be one of:
|
|
"normal"
|
|
"oblique"
|
|
"italic"
|
|
font_style=<style>
|
|
|
|
Font width
|
|
Sets the width of the font. The value must be one of:
|
|
"normal"
|
|
"ultracondensed"
|
|
"extracondensed"
|
|
"condensed"
|
|
"semicondensed"
|
|
"semiexpanded"
|
|
"expanded"
|
|
"extraexpanded"
|
|
"ultraexpanded"
|
|
font_width=<width>
|
|
|
|
Language
|
|
Overrides the language defined in font. For example, lang=he.
|
|
The value can either be a language text or one of presets:
|
|
"auto" - Respects system locale settings as language
|
|
"none" - Disable language support
|
|
lang=<language>
|
|
|
|
Color Commands <color>:
|
|
The following formats are accepted:
|
|
"#RRGGBB"
|
|
"#RRGGBBAA"
|
|
"#RGB"
|
|
"#RGBA"
|
|
"rgb(r,g,b)"
|
|
"rgba(r,g,b,a)"
|
|
"color_name" like "red" (X11 color names)
|
|
|
|
Color
|
|
Sets the color of the text.
|
|
color=<color>
|
|
|
|
Underline Color
|
|
Sets the color of the underline.
|
|
underline_color=<color>
|
|
|
|
Second Underline Color
|
|
Sets the color of the second line of underline(when using underline mode "double").
|
|
underline2_color=<color>
|
|
|
|
Underline Dash Color
|
|
Sets the color of dashed underline.
|
|
underline_dash_color=<color>
|
|
|
|
Outline Color
|
|
Sets the color of the outline of the text.
|
|
outline_color=<color>
|
|
|
|
Shadow Color
|
|
Sets the color of the shadow of the text.
|
|
shadow_color=<color>
|
|
|
|
First Glow Color
|
|
Sets the first color of the glow of text.
|
|
glow_color=<color>
|
|
|
|
Second Glow Color
|
|
Sets the second color of the glow of text.
|
|
glow2_color=<color>
|
|
|
|
Backing Color
|
|
Sets a background color for text.
|
|
backing_color=<color>
|
|
|
|
Strikethrough Color
|
|
Sets the color of text that is striked through.
|
|
strikethrough_color=<color>
|
|
|
|
Horizontal Align
|
|
Sets the horizontal alignment of the text. The value can either be a number, a percentage or one of several presets:
|
|
"auto" - Respects LTR/RTL settings
|
|
"locale" - Respects locale(language) direction settings
|
|
"center" - Centers the text in the line
|
|
"middle" - Alias for "center"
|
|
"left" - Puts the text at the left of the line
|
|
"right" - Puts the text at the right of the line
|
|
"start" - Respects LTR/RTL settings. It is same with "auto"
|
|
"end" - Puts the text at the opposite side of LTR/RTL settings
|
|
<number> - A number between 0.0 and 1.0 where 0.0 represents "left" and 1.0 represents "right"
|
|
<number>% - A percentage between 0% and 100% where 0% represents "left" and 100% represents "right"
|
|
align=<value or preset>
|
|
|
|
Vertical Align
|
|
Sets the vertical alignment of the text.
|
|
The value can either be a number or one of the following presets:
|
|
"top" - Puts text at the top of the line
|
|
"center" - Centers the text in the line
|
|
"middle" - Alias for "center"
|
|
"bottom" - Puts the text at the bottom of the line
|
|
"baseline" - Baseline
|
|
"base" - Alias for "baseline"
|
|
<number> - A number between 0.0 and 1.0 where 0.0 represents "top" and 1.0 represents "bottom"
|
|
<number>% - A percentage between 0% and 100% where 0% represents "top" and 100% represents "bottom"
|
|
valign=<value or preset>
|
|
See explanation of baseline at: https://en.wikipedia.org/wiki/Baseline_%28typography%29
|
|
|
|
Wrap
|
|
Sets the wrap policy of the text. The value must be one of the following:
|
|
"word" - Only wraps lines at word boundaries
|
|
"char" - Wraps at any character
|
|
"mixed" - Wrap at words if possible, if not at any character
|
|
"hyphenation" - Hyphenate if possible, if not wrap at words if possible, if not at any character
|
|
"" - Don't wrap
|
|
wrap=<value or preset>
|
|
|
|
Left margin
|
|
Sets the left margin of the text (in pixel). The value can be a number, an increment, decrement or "reset":
|
|
+<number> - Increments existing left margin by <number>
|
|
-<number> - Decrements existing left margin by <number>
|
|
<number> - Sets left margin to <number>
|
|
"reset" - Sets left margin to 0
|
|
left_margin=<value or reset>
|
|
|
|
Right margin
|
|
Sets the right margin of the text (in pixel). The value can be a number, an increment, decrement or "reset":
|
|
+<number> - Increments existing right margin by <number>
|
|
-<number> - Decrements existing right margin by <number>
|
|
<number> - Sets left margin to <number>
|
|
"reset" - Sets left margin to 0
|
|
right_margin=<value or reset>
|
|
|
|
Underline
|
|
Sets if and how a text will be underlined. The value must be one of the following:
|
|
"off" - No underlining
|
|
"single" - A single line under the text
|
|
"on" - Alias for "single"
|
|
"double" - Two lines under the text
|
|
"dashed" - A dashed line under the text
|
|
underline=off/single/on/double/dashed
|
|
|
|
Strikethrough
|
|
Sets if the text will be striked through. The value must be one of the following:
|
|
"off" - No strikethrough
|
|
"on" - Strikethrough
|
|
strikethrough=on/off
|
|
|
|
Backing
|
|
Sets if the text will have background color enabled or disabled. The value must be one of the following:
|
|
"off" - No backing
|
|
"on" - Backing
|
|
backing=on/off
|
|
|
|
Style
|
|
Sets the style of the text. The value must be a string composed of two comma separated parts.
|
|
The first part of the value sets the appearance of the text, the second the position.
|
|
The first part may be any of the following values:
|
|
"plain"
|
|
"off" - Alias for "plain"
|
|
"none" - Alias for "plain"
|
|
"shadow"
|
|
"outline"
|
|
"soft_outline"
|
|
"outline_shadow"
|
|
"outline_soft_shadow"
|
|
"glow"
|
|
"far_shadow"
|
|
"soft_shadow"
|
|
"far_soft_shadow" The second part may be any of the following values:
|
|
"bottom_right"
|
|
"bottom"
|
|
"bottom_left"
|
|
"left"
|
|
"top_left"
|
|
"top"
|
|
"top_right"
|
|
"right"
|
|
style=<appearance>,<position>
|
|
|
|
Tabstops
|
|
Sets the size (in pixel) of the tab character. The value must be a number greater than one.
|
|
tabstops=<number>
|
|
|
|
Line size
|
|
Sets the size (in pixel) of line of text. The value should be a number.
|
|
Setting this value sets linerelsize to 0%!
|
|
linesize=<number>
|
|
|
|
Relative line size
|
|
Percentage indicating the wanted size of the line relative to the calculated size.
|
|
Setting this value sets linesize to 0!
|
|
linerelsize=<number>%
|
|
|
|
Line gap
|
|
Sets the size (in pixel) of the line gap in text (distance between lines). The value should be a number.
|
|
Setting this value sets linerelgap to 0%!
|
|
linegap=<number>
|
|
|
|
Relative line gap
|
|
Sets the relative size of the line gap in text based calculated size. The value must be a percentage.
|
|
Setting this value sets linegap to 0!
|
|
linerelgap=<number>%
|
|
|
|
Line fill
|
|
Sets the size of the line fill in text. The value must be a percentage (how much line fill its canvas).
|
|
For example setting value to 100%, means the one line will fill it canvas.
|
|
linefill=<number>%
|
|
|
|
Ellipsis
|
|
Sets ellipsis mode. The value should be a number.
|
|
Any value smaller than 0.0 or greater than 1.0 disables ellipsis.
|
|
A value of 0 means ellipsizing the leftmost portion of the text first, 1 on the other hand the rightmost portion.
|
|
ellipsis=<number>
|
|
|
|
Password
|
|
Sets if the text is being used for passwords.
|
|
Enabling this causes all characters to be substituted for '*'. Value must be one of the following:
|
|
"on" - Enable
|
|
"off" - Disable
|
|
password=on/off
|
|
|
|
Underline dash width
|
|
Sets the width of the underline dash (in pixel). The value should be a number.
|
|
underline_dash_width=<number>
|
|
|
|
Underline dash gap
|
|
Sets the gap of the underline dash (in pixel). The value should be a number.
|
|
underline_dash_gap=<number>
|
|
|
|
Underline height
|
|
Sets the height of the single underline (in pixel). The value should be a floating number.
|
|
underline_height=<floatingnumber>
|
|
|
|
Gfx Filter
|
|
Experimental filter, see efl_gfx_filter for more information.
|
|
gfx_filter='filter name'
|
|
]]
|
|
|
|
params {
|
|
@in style: string; [[A whitespace-separated list of $[property=value] pairs, for example, $[font=sans font_size=30].]]
|
|
}
|
|
}
|
|
@property all_styles {
|
|
[[A string representing the complete set of styles applied to this text object.
|
|
This includes the default attributes plus any additional style applied with @.style_apply
|
|
or individual style properties like @Efl.Text_Font.font_slant or @Efl.Text_Format.wrap.]]
|
|
get {}
|
|
values {
|
|
style: string; [[A whitespace-separated list of $[property=value] pairs, for example,
|
|
$[font=sans size=30]. Do not free.]]
|
|
}
|
|
}
|
|
@property size_formatted {
|
|
[[The formatted width and height of this text block.
|
|
|
|
This calculates the actual size after restricting the
|
|
text block to the current size of the object.
|
|
|
|
The main difference between this and @.size_native
|
|
is that the "native" function does not take wrapping into account:
|
|
it just calculates the real width of the object as if it was
|
|
placed on an infinite canvas, while @.size_formatted gives the
|
|
size after wrapping text according to the size restrictions of the
|
|
object.
|
|
|
|
For example a text block containing the text:
|
|
"You shall not pass!" with no margins or padding and assuming
|
|
a monospace font and a size of 7x10 char widths (for simplicity)
|
|
has a native size of 19x1 and a formatted size of 5x4.
|
|
]]
|
|
get {}
|
|
values {
|
|
size: Eina.Size2D; [[The formatted size of the object (after wrapping).]]
|
|
}
|
|
}
|
|
@property size_native {
|
|
[[The native width and height of this text block.
|
|
|
|
This calculates the actual size without taking account the
|
|
current size of the object.
|
|
|
|
The main difference between this and @.size_formatted
|
|
is that the "native" function does not take wrapping into account:
|
|
it just calculates the real width of the object as if it was
|
|
placed on an infinite canvas, while @.size_formatted gives the
|
|
size after wrapping text according to the size restrictions of the
|
|
object.
|
|
|
|
For example a text block containing the text:
|
|
"You shall not pass!" with no margins or padding and assuming
|
|
a monospace font and a size of 7x10 char widths (for simplicity)
|
|
has a native size of 19x1 and a formatted size of 5x4.
|
|
]]
|
|
get {}
|
|
values {
|
|
size: Eina.Size2D; [[The native size of the object (without wrapping).]]
|
|
}
|
|
}
|
|
// Obstacles
|
|
obstacle_add {
|
|
[[Add obstacle evas object $eo_obs to be observed during layout
|
|
of text.
|
|
|
|
The textblock does the layout of the text according to the
|
|
position of the obstacle.
|
|
]]
|
|
params {
|
|
@in eo_obs: Efl.Canvas.Object; [[Obstacle object.]]
|
|
}
|
|
return: bool; [[$true on success.]]
|
|
}
|
|
obstacle_del {
|
|
[[Removes $eo_obs from observation during text layout.
|
|
]]
|
|
params {
|
|
@in eo_obs: Efl.Canvas.Object; [[Obstacle object.]]
|
|
}
|
|
return: bool; [[$true on success.]]
|
|
}
|
|
obstacles_update {
|
|
[[Triggers for relayout due to obstacles' state change.
|
|
|
|
The obstacles alone don't affect the layout, until this is
|
|
called. Use this after doing changes (moving, positioning etc.)
|
|
in the obstacles that you would like to be considered in the
|
|
layout.
|
|
|
|
For example: if you have just repositioned the obstacles to
|
|
different coordinates relative to the text block, you need to
|
|
call this so it will consider this new state and will relayout
|
|
the text.
|
|
]]
|
|
}
|
|
async_layout {
|
|
[[Requests to layout the text off the mainloop.
|
|
|
|
Once layout is complete, the result is returned as @Eina.Rect,
|
|
with the $w and $h fields set.
|
|
]]
|
|
return: future<Eina.Rect>; [[Future for layout result.]]
|
|
}
|
|
}
|
|
implements {
|
|
Efl.Object.constructor;
|
|
Efl.Object.destructor;
|
|
Efl.Canvas.Object.paragraph_direction { get; set; }
|
|
Efl.Text.text { get; set; }
|
|
Efl.Gfx.Filter.filter_program { get; set; }
|
|
Efl.Gfx.Filter.filter_data { get; set; }
|
|
Efl.Gfx.Filter.filter_source { get; set; }
|
|
Efl.Canvas.Filter.Internal.filter_dirty;
|
|
Efl.Canvas.Filter.Internal.filter_input_render;
|
|
Efl.Canvas.Filter.Internal.filter_state_prepare;
|
|
Efl.Text_Font.font_family { get; set; }
|
|
Efl.Text_Font.font_size { get; set; }
|
|
Efl.Text_Font.font_source { get; set; }
|
|
Efl.Text_Font.font_fallbacks { get; set; }
|
|
Efl.Text_Font.font_lang { get; set; }
|
|
Efl.Text_Font.font_weight { get; set; }
|
|
Efl.Text_Font.font_slant { get; set; }
|
|
Efl.Text_Font.font_width { get; set; }
|
|
Efl.Text_Font.font_bitmap_scalable { get; set; }
|
|
Efl.Text_Style.normal_color { get; set; }
|
|
Efl.Text_Style.backing_type { get; set; }
|
|
Efl.Text_Style.backing_color { get; set; }
|
|
Efl.Text_Style.underline_type { get; set; }
|
|
Efl.Text_Style.underline_color { get; set; }
|
|
Efl.Text_Style.underline_height { get; set; }
|
|
Efl.Text_Style.underline_dashed_color { get; set; }
|
|
Efl.Text_Style.underline_dashed_width { get; set; }
|
|
Efl.Text_Style.underline_dashed_gap { get; set; }
|
|
Efl.Text_Style.underline2_color { get; set; }
|
|
Efl.Text_Style.strikethrough_type { get; set; }
|
|
Efl.Text_Style.strikethrough_color { get; set; }
|
|
Efl.Text_Style.effect_type { get; set; }
|
|
Efl.Text_Style.outline_color { get; set; }
|
|
Efl.Text_Style.shadow_direction { get; set; }
|
|
Efl.Text_Style.shadow_color { get; set; }
|
|
Efl.Text_Style.glow_color { get; set; }
|
|
Efl.Text_Style.glow2_color { get; set; }
|
|
Efl.Text_Style.gfx_filter { get; set; }
|
|
Efl.Text_Format.ellipsis { get; set; }
|
|
Efl.Text_Format.wrap { get; set; }
|
|
Efl.Text_Format.multiline { get; set; }
|
|
Efl.Text_Format.horizontal_align { get; set; }
|
|
Efl.Text_Format.horizontal_align_auto_type { get; set; }
|
|
Efl.Text_Format.vertical_align { get; set; }
|
|
Efl.Text_Format.linegap { get; set; }
|
|
Efl.Text_Format.linerelgap { get; set; }
|
|
Efl.Text_Format.tabstops { get; set; }
|
|
Efl.Text_Format.password { get; set; }
|
|
Efl.Text_Format.replacement_char { get; set; }
|
|
Efl.Text_Markup.markup { set; get; }
|
|
Efl.Gfx.Entity.scale { set; }
|
|
}
|
|
events {
|
|
changed: void; [[Called when canvas text changed ]]
|
|
attributes,changed: void; [[Called when attributes change]]
|
|
layout,finished: void; [[Called when the object has been layed out]]
|
|
style_insets,changed: void; [[Called when the property @.style_insets changed.]]
|
|
}
|
|
}
|