56 #ifndef LEGATO_STRING_H 57 #define LEGATO_STRING_H 67 typedef void (*leString_InvalidateCallback)(
const struct leString* str,
void* userData);
69 #define LE_STRING_VTABLE(THIS_TYPE) \ 70 void (*destructor)(THIS_TYPE* _this); \ 71 leFont* (*getFont)(const THIS_TYPE* _this); \ 72 leResult (*setFont)(THIS_TYPE* _this, const leFont* font); \ 73 leResult (*setFromString)(THIS_TYPE* _this, const struct leString* src); \ 74 leResult (*setFromChar)(THIS_TYPE* _this, const leChar* buf, uint32_t size); \ 75 leResult (*setFromCStr)(THIS_TYPE* _this, const char* cstr); \ 76 leChar (*charAt)(const THIS_TYPE* _this, uint32_t idx); \ 77 uint32_t (*length)(const THIS_TYPE* _this); \ 78 leBool (*isEmpty)(const THIS_TYPE* _this); \ 79 int32_t (*compare)(const THIS_TYPE* _this, const struct leString* tgt); \ 80 leResult (*append)(THIS_TYPE* _this, const struct leString* val); \ 81 leResult (*insert)(THIS_TYPE* _this, const struct leString* val, uint32_t idx); \ 82 leResult (*remove)(THIS_TYPE* _this, uint32_t idx, uint32_t count); \ 83 void (*clear)(THIS_TYPE* _this); \ 84 uint32_t (*toChar)(const THIS_TYPE* _this, leChar* buf, uint32_t size); \ 85 leResult (*getRect)(const THIS_TYPE* _this, leRect* rect); \ 86 uint32_t (*getLineCount)(const THIS_TYPE* _this); \ 87 leResult (*getLineRect)(const THIS_TYPE* _this, uint32_t line, leRect* rect); \ 88 leResult (*getLineIndices)(const THIS_TYPE* _this, uint32_t line, uint32_t* start, uint32_t* end); \ 89 leResult (*getCharRect)(const THIS_TYPE* _this, uint32_t idx, leRect* rect); \ 90 leResult (*getCharIndexAtPoint)(const THIS_TYPE* _this, const lePoint* pt, uint32_t* idx); \ 91 leResult (*_draw)(const THIS_TYPE* _this, int32_t x, int32_t y, leHAlignment align, leColor clr, uint32_t a); \ 92 void (*preinvalidate)(THIS_TYPE* _this); \ 93 void (*invalidate)(THIS_TYPE* _this); \ 94 leResult (*setPreInvalidateCallback)(THIS_TYPE* _this, leString_InvalidateCallback, void* userData); \ 95 leResult (*setInvalidateCallback)(THIS_TYPE* _this, leString_InvalidateCallback, void* userData); \ 111 leString_InvalidateCallback preInvCallback;
114 leString_InvalidateCallback invCallback;
136 #define THIS_TYPE struct leWidget 570 leString_InvalidateCallback,
589 leString_InvalidateCallback cb,
virtual uint32_t length(const leString *_this)
Get length of the string.
virtual int32_t compare(const leString *_this, const struct leString *tgt)
Compare string to another string.
virtual leResult insert(leString *_this, const struct leString *val, uint32_t idx)
Insert string at a given index.
Common macros and definitions used by Legato.
Font functions and definitions.
virtual leBool isEmpty(const leString *_this)
Determine if string is empty.
This struct represents a string.
Definition: legato_string.h:107
const leStringVTable * fn
Definition: legato_string.h:109
virtual leResult getCharRect(const leString *_this, uint32_t idx, leRect *rect)
Get rendered rectangle of a string codepoint.
virtual leResult setFont(leString *_this, const leFont *font)
Set font.
virtual leResult append(leString *_this, const struct leString *val)
Append string.
This struct represents a font object.
Definition: legato_font.h:156
virtual uint32_t toChar(const leString *_this, leChar *buf, uint32_t size)
Convert string to a C-style string.
virtual void preinvalidate(leString *_this)
Raise pre-invalidate event.
leResult
This enum represents function call results.
Definition: legato_common.h:123
virtual leResult setFromString(leString *_this, const struct leString *src)
Set string value from another string.
virtual virtual leResult getRect(const leString *_this, leRect *rect)
Get rectangle of the rendered string in pixels.
This struct represents a rectangle.
Definition: legato_common.h:394
Definition: legato_string.h:97
leHAlignment
This enum represents the horizontal alignment mode of objects.
Definition: legato_common.h:195
virtual void invalidate(leString *_this)
Invalidate.
Error functions, macros and definitions.
virtual leResult getLineRect(const leString *_this, uint32_t line, leRect *rect)
Get rectangle of a string line.
virtual leResult setFromCStr(leString *_this, const char *cstr)
Set string value from a C string buffer.
void leString_Delete(leString *str)
Delete string.
Definition: legato_string.c:44
This structure represents a integer Cartesian point.
Definition: legato_common.h:346
virtual void clear(leString *_this)
Clear string.
struct leString leString
This struct represents a string.
virtual leResult setInvalidateCallback(leString *_this, leString_InvalidateCallback cb, void *userData)
Set string invalidate event.
virtual leResult getCharIndexAtPoint(const leString *_this, const lePoint *pt, uint32_t *idx)
Get character index at point.
leBool
This enum represents booleans.
Definition: legato_common.h:146
uint16_t leChar
This typedef represents Legato character.
Definition: legato_common.h:414
virtual leResult setPreInvalidateCallback(leString *_this, leString_InvalidateCallback, void *userData)
Set string invalidate event.
virtual leResult _draw(const leString *_this, int32_t x, int32_t y, leHAlignment align, leColor clr, uint32_t a)
Draw.
virtual leResult getLineIndices(const leString *_this, uint32_t line, uint32_t *start, uint32_t *end)
Get indices of a string line.
virtual leFont * getFont(const leString *_this)
Get font.
void * invCBUserData
Definition: legato_string.h:115
virtual leChar charAt(const leString *_this, uint32_t idx)
Get codepoint at the given index.
virtual void destructor(leString *_this)
Destruct string.
virtual leResult setFromChar(leString *_this, const leChar *buf, uint32_t size)
Set string value from a leChar buffer.
uint32_t getLineCount(const leString *_this)
Get number of lines in the string.
void * preCBUserData
Definition: legato_string.h:112