NetSurf
text.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 Vincent Sanders <vince@simtec.co.uk>
3 *
4 * Framebuffer windowing toolkit scrollbar widgets.
5 *
6 * This file is part of NetSurf, http://www.netsurf-browser.org/
7 *
8 * NetSurf is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * NetSurf is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <stdbool.h>
22#include <stdlib.h>
23#include <string.h>
24
25#include <libnsfb.h>
26#include <libnsfb_plot.h>
27#include <libnsfb_plot_util.h>
28#include <libnsfb_event.h>
29
30#include "utils/log.h"
32#include "netsurf/plotters.h"
33
34#include "framebuffer/gui.h"
35#include "framebuffer/fbtk.h"
36#include "framebuffer/font.h"
39
40#include "widget.h"
41
42//#define TEXT_WIDGET_BORDER 3 /**< The pixel border round a text widget. */
43
44/* Lighten a colour by taking seven eights of each channel's intensity
45 * and adding a full eighth
46 */
47#define brighten_colour(c1) \
48 (((((7 * ((c1 >> 16) & 0xff)) >> 3) + 32) << 16) | \
49 ((((7 * ((c1 >> 8) & 0xff)) >> 3) + 32) << 8) | \
50 ((((7 * (c1 & 0xff)) >> 3) + 32) << 0))
51
52/* Convert pixels to points, assuming a DPI of 90 */
53#define px_to_pt(x) (((x) * 72) / FBTK_DPI)
54
55/* Get a font style for a text input */
56static inline void
57fb_text_font_style(fbtk_widget_t *widget, int *font_height, int *padding,
58 plot_font_style_t *font_style)
59{
60 if (widget->u.text.outline)
61 *padding = 1;
62 else
63 *padding = 0;
64
65#ifdef FB_USE_FREETYPE
66 *padding += widget->height / 6;
67 *font_height = widget->height - *padding - *padding;
68#else
69 *font_height = FB_FONT_HEIGHT;
70 *padding = (widget->height - *padding - *font_height) / 2;
71#endif
72
74 font_style->size = px_to_pt(*font_height * PLOT_STYLE_SCALE);
75 font_style->weight = 400;
76 font_style->flags = FONTF_NONE;
77 font_style->background = widget->bg;
78 font_style->foreground = widget->fg;
79}
80
81/** Text redraw callback.
82 *
83 * Called when a text widget requires redrawing.
84 *
85 * @param widget The widget to be redrawn.
86 * @param cbi The callback parameters.
87 * @return The callback result.
88 */
89static int
91{
92 nsfb_bbox_t bbox;
93 nsfb_bbox_t rect;
95 plot_font_style_t font_style;
96 int caret_x, caret_y, caret_h;
97 int fh;
98 int padding;
99 int scroll = 0;
100 bool caret = false;
101 struct redraw_context ctx = {
102 .interactive = true,
103 .background_images = true,
104 .plot = &fb_plotters
105 };
106
107 fb_text_font_style(widget, &fh, &padding, &font_style);
108
109 if (fbtk_get_caret(widget, &caret_x, &caret_y, &caret_h)) {
110 caret = true;
111 }
112
113 root = fbtk_get_root_widget(widget);
114
115 fbtk_get_bbox(widget, &bbox);
116
117 rect = bbox;
118
119 nsfb_claim(root->u.root.fb, &bbox);
120
121 /* clear background */
122 if ((widget->bg & 0xFF000000) != 0) {
123 /* transparent polygon filling isnt working so fake it */
124 nsfb_plot_rectangle_fill(root->u.root.fb, &bbox, widget->bg);
125 }
126
127 /* widget can have a single pixel outline border */
128 if (widget->u.text.outline) {
129 rect.x1--;
130 rect.y1--;
131 nsfb_plot_rectangle(root->u.root.fb, &rect, 1,
132 0x00000000, false, false);
133 }
134
135 if (widget->u.text.text != NULL) {
136 int x = bbox.x0 + padding;
137 int y = bbox.y0 + ((fh * 3 + 2) / 4) + padding;
138
139#ifdef FB_USE_FREETYPE
140 /* Freetype renders text higher */
141 y += 1;
142#endif
143
144 if (caret && widget->width - padding - padding < caret_x) {
145 scroll = (widget->width - padding - padding) - caret_x;
146 x += scroll;
147 }
148
149 /* Call the fb text plotting, baseline is 3/4 down the font */
150 ctx.plot->text(&ctx,
151 &font_style,
152 x, y,
153 widget->u.text.text,
154 widget->u.text.len);
155 }
156
157 if (caret) {
158 /* This widget has caret, so render it */
159 nsfb_t *nsfb = fbtk_get_nsfb(widget);
160 nsfb_bbox_t line;
161 nsfb_plot_pen_t pen;
162
163 line.x0 = bbox.x0 + caret_x + scroll;
164 line.y0 = bbox.y0 + caret_y;
165 line.x1 = bbox.x0 + caret_x + scroll;
166 line.y1 = bbox.y0 + caret_y + caret_h;
167
168 pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
169 pen.stroke_width = 1;
170 pen.stroke_colour = 0xFF0000FF;
171
172 nsfb_plot_line(nsfb, &line, &pen);
173 }
174
175 nsfb_update(root->u.root.fb, &bbox);
176
177 return 0;
178}
179
180/** Text destroy callback.
181 *
182 * Called when a text widget is destroyed.
183 *
184 * @param widget The widget being destroyed.
185 * @param cbi The callback parameters.
186 * @return The callback result.
187 */
189{
190 if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_TEXT)) {
191 return 0;
192 }
193
194 if (widget->u.text.text != NULL) {
195 free(widget->u.text.text);
196 }
197
198 return 0;
199}
200
201/** Text button redraw callback.
202 *
203 * Called when a text widget requires redrawing.
204 *
205 * @param widget The widget to be redrawn.
206 * @param cbi The callback parameters.
207 * @return The callback result.
208 */
209static int
211{
212 nsfb_bbox_t bbox;
213 nsfb_bbox_t rect;
214 nsfb_bbox_t line;
215 nsfb_plot_pen_t pen;
216 plot_font_style_t font_style;
217 int fh;
218 int border;
220 struct redraw_context ctx = {
221 .interactive = true,
222 .background_images = true,
223 .plot = &fb_plotters
224 };
225
226 fb_text_font_style(widget, &fh, &border, &font_style);
227
228 pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;
229 pen.stroke_width = 1;
230 pen.stroke_colour = brighten_colour(widget->bg);
231
232 fbtk_get_bbox(widget, &bbox);
233
234 rect = bbox;
235 rect.x1--;
236 rect.y1--;
237
238 nsfb_claim(root->u.root.fb, &bbox);
239
240 /* clear background */
241 if ((widget->bg & 0xFF000000) != 0) {
242 /* transparent polygon filling isnt working so fake it */
243 nsfb_plot_rectangle_fill(root->u.root.fb, &rect, widget->bg);
244 }
245
246 if (widget->u.text.outline) {
247 line.x0 = rect.x0;
248 line.y0 = rect.y0;
249 line.x1 = rect.x0;
250 line.y1 = rect.y1;
251 nsfb_plot_line(root->u.root.fb, &line, &pen);
252 line.x0 = rect.x0;
253 line.y0 = rect.y0;
254 line.x1 = rect.x1;
255 line.y1 = rect.y0;
256 nsfb_plot_line(root->u.root.fb, &line, &pen);
257 pen.stroke_colour = darken_colour(widget->bg);
258 line.x0 = rect.x0;
259 line.y0 = rect.y1;
260 line.x1 = rect.x1;
261 line.y1 = rect.y1;
262 nsfb_plot_line(root->u.root.fb, &line, &pen);
263 line.x0 = rect.x1;
264 line.y0 = rect.y0;
265 line.x1 = rect.x1;
266 line.y1 = rect.y1;
267 nsfb_plot_line(root->u.root.fb, &line, &pen);
268 }
269
270 if (widget->u.text.text != NULL) {
271 /* Call the fb text plotting, baseline is 3/4 down the font */
272 ctx.plot->text(&ctx,
273 &font_style,
274 bbox.x0 + border,
275 bbox.y0 + ((fh * 3) / 4) + border,
276 widget->u.text.text,
277 widget->u.text.len);
278 }
279
280 nsfb_update(root->u.root.fb, &bbox);
281
282 return 0;
283}
284
285static void
287{
288 int c_x, c_y, c_h;
289
290 if (fbtk_get_caret(widget, &c_x, &c_y, &c_h)) {
291 fbtk_request_redraw(widget);
292 }
293}
294
295/** Routine called when text events occour in writeable widget.
296 *
297 * @param widget The widget reciving input events.
298 * @param cbi The callback parameters.
299 * @return The callback result.
300 */
301static int
303{
304 int value;
305 static fbtk_modifier_type modifier = FBTK_MOD_CLEAR;
306 char *temp;
307 plot_font_style_t font_style;
308 int fh;
309 int border;
310 bool caret_moved = false;
311
312 fb_text_font_style(widget, &fh, &border, &font_style);
313
314 if (cbi->event == NULL) {
315 /* gain focus */
316 if (widget->u.text.text == NULL)
317 widget->u.text.text = calloc(1,1);
318
319 return 0;
320 }
321
322 value = cbi->event->value.keycode;
323
324 if (cbi->event->type != NSFB_EVENT_KEY_DOWN) {
325 switch (value) {
326 case NSFB_KEY_RSHIFT:
327 modifier &= ~FBTK_MOD_RSHIFT;
328 break;
329
330 case NSFB_KEY_LSHIFT:
331 modifier &= ~FBTK_MOD_LSHIFT;
332 break;
333
334 case NSFB_KEY_RCTRL:
335 modifier &= ~FBTK_MOD_RCTRL;
336 break;
337
338 case NSFB_KEY_LCTRL:
339 modifier &= ~FBTK_MOD_LCTRL;
340 break;
341
342 default:
343 break;
344 }
345 return 0;
346 }
347
348 switch (value) {
349 case NSFB_KEY_BACKSPACE:
350 if (widget->u.text.idx <= 0)
351 break;
352 memmove(widget->u.text.text + widget->u.text.idx - 1,
353 widget->u.text.text + widget->u.text.idx,
354 widget->u.text.len - widget->u.text.idx);
355 widget->u.text.idx--;
356 widget->u.text.len--;
357 widget->u.text.text[widget->u.text.len] = 0;
358
359 fb_font_width(&font_style, widget->u.text.text,
360 widget->u.text.len, &widget->u.text.width);
361
362 caret_moved = true;
363 break;
364
365 case NSFB_KEY_RETURN:
366 widget->u.text.enter(widget->u.text.pw, widget->u.text.text);
367 break;
368
369 case NSFB_KEY_RIGHT:
370 if (widget->u.text.idx < widget->u.text.len) {
371 if (modifier == FBTK_MOD_CLEAR)
372 widget->u.text.idx++;
373 else
374 widget->u.text.idx = widget->u.text.len;
375
376 caret_moved = true;
377 }
378 break;
379
380 case NSFB_KEY_LEFT:
381 if (widget->u.text.idx > 0) {
382 if (modifier == FBTK_MOD_CLEAR)
383 widget->u.text.idx--;
384 else
385 widget->u.text.idx = 0;
386
387 caret_moved = true;
388 }
389 break;
390
391 case NSFB_KEY_HOME:
392 if (widget->u.text.idx > 0) {
393 widget->u.text.idx = 0;
394
395 caret_moved = true;
396 }
397 break;
398
399 case NSFB_KEY_END:
400 if (widget->u.text.idx < widget->u.text.len) {
401 widget->u.text.idx = widget->u.text.len;
402
403 caret_moved = true;
404 }
405 break;
406
407 case NSFB_KEY_PAGEUP:
408 case NSFB_KEY_PAGEDOWN:
409 case NSFB_KEY_UP:
410 case NSFB_KEY_DOWN:
411 /* Not handling any of these correctly yet, but avoid putting
412 * charcters in the text widget when they're pressed. */
413 break;
414
415 case NSFB_KEY_RSHIFT:
416 modifier |= FBTK_MOD_RSHIFT;
417 break;
418
419 case NSFB_KEY_LSHIFT:
420 modifier |= FBTK_MOD_LSHIFT;
421 break;
422
423 case NSFB_KEY_RCTRL:
424 modifier |= FBTK_MOD_RCTRL;
425 break;
426
427 case NSFB_KEY_LCTRL:
428 modifier |= FBTK_MOD_LCTRL;
429 break;
430
431 default:
432 if (modifier & FBTK_MOD_LCTRL || modifier & FBTK_MOD_RCTRL) {
433 /* CTRL pressed, don't enter any text */
434 if (value == NSFB_KEY_u) {
435 /* CTRL+U: clear writable */
436 widget->u.text.idx = 0;
437 widget->u.text.len = 0;
438 widget->u.text.text[widget->u.text.len] = '\0';
439 widget->u.text.width = 0;
440 caret_moved = true;
441 }
442 break;
443 }
444
445 /* allow for new character and null */
446 temp = realloc(widget->u.text.text, widget->u.text.len + 2);
447 if (temp == NULL) {
448 break;
449 }
450
451 widget->u.text.text = temp;
452 memmove(widget->u.text.text + widget->u.text.idx + 1,
453 widget->u.text.text + widget->u.text.idx,
454 widget->u.text.len - widget->u.text.idx);
455 widget->u.text.text[widget->u.text.idx] =
456 fbtk_keycode_to_ucs4(value, modifier);
457 widget->u.text.idx++;
458 widget->u.text.len++;
459 widget->u.text.text[widget->u.text.len] = '\0';
460
461 fb_font_width(&font_style, widget->u.text.text,
462 widget->u.text.len, &widget->u.text.width);
463 caret_moved = true;
464 break;
465 }
466
467 if (caret_moved) {
468 fb_font_width(&font_style, widget->u.text.text,
469 widget->u.text.idx, &widget->u.text.idx_offset);
470 fbtk_set_caret(widget, true,
471 widget->u.text.idx_offset + border,
472 border,
473 widget->height - border - border,
475 }
476
477 fbtk_request_redraw(widget);
478
479 return 0;
480}
481
482/** Routine called when click events occour in writeable widget.
483 *
484 * @param widget The widget reciving click events.
485 * @param cbi The callback parameters.
486 * @return The callback result.
487 */
488static int
490{
491 plot_font_style_t font_style;
492 int fh;
493 int border;
494 size_t idx;
495
496 fb_text_font_style(widget, &fh, &border, &font_style);
497
498 widget->u.text.idx = widget->u.text.len;
499
500 fb_font_position(&font_style, widget->u.text.text,
501 widget->u.text.len, cbi->x - border,
502 &idx,
503 &widget->u.text.idx_offset);
504 widget->u.text.idx = idx;
505 fbtk_set_caret(widget, true,
506 widget->u.text.idx_offset + border,
507 border,
508 widget->height - border - border,
510
511 fbtk_request_redraw(widget);
512
513 return 0;
514}
515
516/** Routine called when "stripped of focus" event occours for writeable widget.
517 *
518 * @param widget The widget reciving "stripped of focus" event.
519 * @param cbi The callback parameters.
520 * @return The callback result.
521 */
522static int
524{
525 fbtk_set_caret(widget, false, 0, 0, 0, NULL);
526
527 return 0;
528}
529
530/* exported function documented in fbtk.h */
531void
533{
534 widget->u.text.enter = enter;
535 widget->u.text.pw = pw;
536
538}
539
540/* exported function documented in fbtk.h */
541void
542fbtk_set_text(fbtk_widget_t *widget, const char *text)
543{
544 plot_font_style_t font_style;
545 int c_x, c_y, c_h;
546 int fh;
547 int border;
548
549 if ((widget == NULL) || (widget->type != FB_WIDGET_TYPE_TEXT))
550 return;
551 if (widget->u.text.text != NULL) {
552 if (strcmp(widget->u.text.text, text) == 0)
553 return; /* text is being set to the same thing */
554 free(widget->u.text.text);
555 }
556 widget->u.text.text = strdup(text);
557 widget->u.text.len = strlen(text);
558 widget->u.text.idx = widget->u.text.len;
559
560
561 fb_text_font_style(widget, &fh, &border, &font_style);
562 fb_font_width(&font_style, widget->u.text.text,
563 widget->u.text.len, &widget->u.text.width);
564 fb_font_width(&font_style, widget->u.text.text,
565 widget->u.text.idx, &widget->u.text.idx_offset);
566
567 if (fbtk_get_caret(widget, &c_x, &c_y, &c_h)) {
568 /* Widget has caret; move it to end of new string */
569 fbtk_set_caret(widget, true,
570 widget->u.text.idx_offset + border,
571 border,
572 widget->height - border - border,
574 }
575
576 fbtk_request_redraw(widget);
577}
578
579/* exported function documented in fbtk.h */
582 int x,
583 int y,
584 int width,
585 int height,
586 colour bg,
587 colour fg,
588 bool outline)
589{
590 fbtk_widget_t *neww;
591
593 neww->fg = fg;
594 neww->bg = bg;
595 neww->mapped = true;
596 neww->u.text.outline = outline;
597
600
601 return neww;
602}
603
604/* exported function documented in fbtk.h */
607 int x,
608 int y,
609 int width,
610 int height,
611 colour bg,
612 colour fg,
613 bool outline,
614 fbtk_enter_t enter,
615 void *pw)
616{
617 fbtk_widget_t *neww;
618
620 neww->fg = fg;
621 neww->bg = bg;
622 neww->mapped = true;
623
624 neww->u.text.outline = outline;
625 neww->u.text.enter = enter;
626 neww->u.text.pw = pw;
627
633
634 return neww;
635}
636
637/* exported function documented in fbtk.h */
640 int x,
641 int y,
642 int width,
643 int height,
644 colour bg,
645 colour fg,
646 fbtk_callback click,
647 void *pw)
648{
649 fbtk_widget_t *neww;
650
652 neww->fg = fg;
653 neww->bg = bg;
654 neww->mapped = true;
655
656 neww->u.text.outline = true;
657
660 fbtk_set_handler(neww, FBTK_CBT_CLICK, click, pw);
662
663 return neww;
664}
665
666/*
667 * Local Variables:
668 * c-basic-offset:8
669 * End:
670 */
Browser window creation and manipulation interface.
wimp_w parent
Definition: dialog.c:88
int fbtk_set_ptr(fbtk_widget_t *widget, fbtk_callback_info *cbi)
set pointer to bitmap in context.
Definition: fbtk.c:393
fbtk_widget_t * fbtk_widget_new(fbtk_widget_t *parent, enum fbtk_widgettype_e type, int x, int y, int width, int height)
creates a new widget and insert it into to hierachy.
Definition: fbtk.c:546
fbtk_widget_t * fbtk_get_root_widget(fbtk_widget_t *widget)
find the root widget from any widget in the toolkit hierarchy.
Definition: fbtk.c:412
fbtk_callback fbtk_set_handler(fbtk_widget_t *widget, fbtk_callback_type cbt, fbtk_callback cb, void *pw)
Set a callback handler.
Definition: fbtk.c:693
@ FBTK_CBT_INPUT
Definition: fbtk.h:40
@ FBTK_CBT_REDRAW
Definition: fbtk.h:44
@ FBTK_CBT_POINTERENTER
Definition: fbtk.h:43
@ FBTK_CBT_DESTROY
Definition: fbtk.h:45
@ FBTK_CBT_CLICK
Definition: fbtk.h:39
@ FBTK_CBT_STRIP_FOCUS
Definition: fbtk.h:47
void fbtk_request_redraw(fbtk_widget_t *widget)
Indicate a widget should be redrawn.
Definition: fbtk.c:82
fbtk_modifier_type
Key modifier status.
Definition: fbtk.h:75
@ FBTK_MOD_LSHIFT
Definition: fbtk.h:77
@ FBTK_MOD_RCTRL
Definition: fbtk.h:80
@ FBTK_MOD_RSHIFT
Definition: fbtk.h:78
@ FBTK_MOD_LCTRL
Definition: fbtk.h:79
@ FBTK_MOD_CLEAR
Definition: fbtk.h:76
bool fbtk_get_bbox(fbtk_widget_t *widget, struct nsfb_bbox_s *bbox)
Get a widget's bounding box in absolute screen co-ordinates.
int fbtk_keycode_to_ucs4(int code, fbtk_modifier_type mods)
Convert a framebuffer keycode to ucs4.
Definition: event.c:301
int(* fbtk_enter_t)(void *pw, char *text)
Definition: fbtk.h:86
void fbtk_set_caret(fbtk_widget_t *widget, bool set, int x, int y, int height, void(*remove_caret)(fbtk_widget_t *widget))
Set caret owner and position.
Definition: fbtk.c:252
nsfb_t * fbtk_get_nsfb(fbtk_widget_t *widget)
Retrieve the framebuffer library handle from toolkit widget.
Definition: fbtk.c:802
bool fbtk_get_caret(fbtk_widget_t *widget, int *x, int *y, int *height)
Get a widget caret pos, if it owns caret.
Definition: fbtk.c:494
int(* fbtk_callback)(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Definition: fbtk.h:83
static struct directory * root
Definition: filename.c:55
#define FB_FONT_HEIGHT
Definition: font_internal.h:30
const struct plotter_table fb_plotters
framebuffer plot operation table
Definition: framebuffer.c:525
static nsfb_t * nsfb
Definition: framebuffer.c:45
framebuffer interface.
nserror fb_font_position(const struct plot_font_style *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
Find the position in a string where an x coordinate falls.
nserror fb_font_width(const struct plot_font_style *fstyle, const char *string, size_t length, int *width)
Measure the width of a string.
struct fbtk_bitmap hand_image
Target independent plotting interface.
#define darken_colour(c1)
Definition: plot_style.h:133
@ FONTF_NONE
Definition: plot_style.h:102
@ PLOT_FONT_FAMILY_SANS_SERIF
Definition: plot_style.h:89
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
Definition: plot_style.h:45
int width
Definition: gui.c:160
int height
Definition: gui.c:161
Interface to utility string handling.
Container for border values during table border calculations.
Definition: table.c:42
widget callback information
Definition: fbtk.h:52
nsfb_event_t * event
Definition: fbtk.h:55
Widget description.
Definition: widget.h:120
enum fbtk_widgettype_e type
The type of the widget.
Definition: widget.h:154
bool mapped
The widget is mapped/visible .
Definition: widget.h:130
char * text
Definition: widget.h:182
colour bg
Definition: widget.h:137
int height
Definition: widget.h:136
union fbtk_widget_s::@35 u
colour fg
Definition: widget.h:138
Font style for plotting.
Definition: plot_style.h:111
plot_font_generic_family_t family
Generic family to plot with.
Definition: plot_style.h:118
colour foreground
Colour of text.
Definition: plot_style.h:123
plot_font_flags_t flags
Font flags.
Definition: plot_style.h:121
plot_style_fixed size
Font size, in pt.
Definition: plot_style.h:119
colour background
Background colour to blend to, if appropriate.
Definition: plot_style.h:122
int weight
Font weight: value in range [100,900] as per CSS.
Definition: plot_style.h:120
nserror(* text)(const struct redraw_context *ctx, const plot_font_style_t *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plotters.h:278
Rectangle coordinates.
Definition: types.h:40
int x0
Definition: types.h:41
int y0
Top left.
Definition: types.h:41
int x1
Definition: types.h:42
int y1
Bottom right.
Definition: types.h:42
Redraw context.
Definition: plotters.h:51
const struct plotter_table * plot
Current plot operation table.
Definition: plotters.h:73
bool interactive
Redraw to show interactive features.
Definition: plotters.h:59
static int text_input_strip_focus(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Routine called when "stripped of focus" event occours for writeable widget.
Definition: text.c:523
static int text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Routine called when text events occour in writeable widget.
Definition: text.c:302
static int text_input_click(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Routine called when click events occour in writeable widget.
Definition: text.c:489
fbtk_widget_t * fbtk_create_text(fbtk_widget_t *parent, int x, int y, int width, int height, colour bg, colour fg, bool outline)
Create a text widget.
Definition: text.c:581
void fbtk_writable_text(fbtk_widget_t *widget, fbtk_enter_t enter, void *pw)
Alter a text widget to be writable.
Definition: text.c:532
static void fb_text_font_style(fbtk_widget_t *widget, int *font_height, int *padding, plot_font_style_t *font_style)
Definition: text.c:57
#define brighten_colour(c1)
Definition: text.c:47
void fbtk_set_text(fbtk_widget_t *widget, const char *text)
Change the text of a text widget.
Definition: text.c:542
fbtk_widget_t * fbtk_create_writable_text(fbtk_widget_t *parent, int x, int y, int width, int height, colour bg, colour fg, bool outline, fbtk_enter_t enter, void *pw)
Create a writable text widget.
Definition: text.c:606
fbtk_widget_t * fbtk_create_text_button(fbtk_widget_t *parent, int x, int y, int width, int height, colour bg, colour fg, fbtk_callback click, void *pw)
Create a button with text.
Definition: text.c:639
#define px_to_pt(x)
Definition: text.c:53
static void fb_text_input_remove_caret_cb(fbtk_widget_t *widget)
Definition: text.c:286
static int fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Text redraw callback.
Definition: text.c:90
static int fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Text button redraw callback.
Definition: text.c:210
static int fb_destroy_text(fbtk_widget_t *widget, fbtk_callback_info *cbi)
Text destroy callback.
Definition: text.c:188
uint32_t colour
Colour type: XBGR.
Definition: types.h:35
struct rect rect
Rectangle coordinates.
@ FB_WIDGET_TYPE_TEXT
Definition: widget.h:29
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: plot.c:579
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978