diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2012-07-31 20:40:14 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2012-07-31 20:40:14 +0100 |
commit | 941a48dabd93323f11ac2b18803289d30e8b3a78 (patch) | |
tree | 0fca5e05f1cabdc457f633853d4c31263581df14 /framebuffer/fbtk | |
parent | 4125a8afdfcbc18fb5e0e60b49d6d5cdd44d008c (diff) | |
download | netsurf-941a48dabd93323f11ac2b18803289d30e8b3a78.tar.gz netsurf-941a48dabd93323f11ac2b18803289d30e8b3a78.tar.bz2 |
When setting fbtk caret, register callback for redrawing caret removal.
Diffstat (limited to 'framebuffer/fbtk')
-rw-r--r-- | framebuffer/fbtk/fbtk.c | 11 | ||||
-rw-r--r-- | framebuffer/fbtk/widget.h | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/framebuffer/fbtk/fbtk.c b/framebuffer/fbtk/fbtk.c index 8e8bc112c..d333d20ff 100644 --- a/framebuffer/fbtk/fbtk.c +++ b/framebuffer/fbtk/fbtk.c @@ -224,21 +224,30 @@ fbtk_set_pos_and_size(fbtk_widget_t *widget, /* exported function docuemnted in fbtk.h */ void fbtk_set_caret(fbtk_widget_t *widget, bool set, - int x, int y, int height) + int x, int y, int height, + void (*remove_caret)(fbtk_widget_t *widget)) { fbtk_widget_t *root; assert(widget != NULL); root = fbtk_get_root_widget(widget); + if (root->u.root.caret.owner != NULL && + root->u.root.caret.remove_cb != NULL) + root->u.root.caret.remove_cb(widget); + if (set) { + assert(remove_caret != NULL); + root->u.root.caret.owner = widget; root->u.root.caret.x = x; root->u.root.caret.y = y; root->u.root.caret.height = height; + root->u.root.caret.remove_cb = remove_caret; } else { root->u.root.caret.owner = NULL; + root->u.root.caret.remove_cb = NULL; } } diff --git a/framebuffer/fbtk/widget.h b/framebuffer/fbtk/widget.h index 3521cc358..5622723ee 100644 --- a/framebuffer/fbtk/widget.h +++ b/framebuffer/fbtk/widget.h @@ -168,6 +168,7 @@ struct fbtk_widget_s { int x; /* relative to owner */ int y; /* relative to owner */ int height; + void (*remove_cb)(fbtk_widget_t *widget); } caret; } root; @@ -182,9 +183,10 @@ struct fbtk_widget_s { bool outline; fbtk_enter_t enter; void *pw; - int idx; - int len; - int width; + int idx; /* caret pos in text */ + int len; /* text length */ + int width; /* text width in px */ + int idx_offset; /* caret pos in pixels */ } text; /* application driven widget */ |