Freeciv-3.3
Loading...
Searching...
No Matches
widget_edit.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2006 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* SDL2 */
19#ifdef SDL2_PLAIN_INCLUDE
20#include <SDL.h>
21#else /* SDL2_PLAIN_INCLUDE */
22#include <SDL2/SDL.h>
23#endif /* SDL2_PLAIN_INCLUDE */
24
25/* gui-sdl2 */
26#include "colors.h"
27#include "graphics.h"
28#include "gui_id.h"
29#include "gui_tilespec.h"
30#include "mapview.h"
31#include "themespec.h"
32#include "utf8string.h"
33#include "widget.h"
34#include "widget_p.h"
35
36struct utf8_char {
37 struct utf8_char *next;
38 struct utf8_char *prev;
39 int bytes;
40 char chr[7];
42};
43
55
56static size_t chainlen(const struct utf8_char *chain);
57static void del_chain(struct utf8_char *chain);
58static struct utf8_char *text2chain(const char *text_in);
59static char *chain2text(const struct utf8_char *in_chain, size_t len, size_t *size);
60
61static int (*baseclass_redraw)(struct widget *pwidget);
62
63/**********************************************************************/
66static int redraw_edit_chain(struct text_edit *edt)
67{
69 SDL_Rect dest, dest_copy = {0, 0, 0, 0};
70 int start_mod_x;
71 int ret;
72
73 dest_copy.x = edt->pwidget->size.x;
74 dest_copy.y = edt->pwidget->size.y;
75
76 ret = (*baseclass_redraw)(edt->pwidget);
77 if (ret != 0) {
78 return ret;
79 }
80
81 /* blit theme */
82 dest = dest_copy;
83
84 alphablit(edt->bg, NULL, edt->pwidget->dst->surface, &dest, 255);
85
86 /* set start parameters */
87 input_chain_tmp = edt->begin_text_chain;
88 start_mod_x = 0;
89
90 dest_copy.y += (edt->bg->h - input_chain_tmp->tsurf->h) / 2;
91 dest_copy.x += edt->start_x;
92
93 /* draw loop */
94 while (input_chain_tmp) {
96 /* check if we draw inside of edit rect */
97 if (dest_copy.x > edt->pwidget->size.x + edt->bg->w - 4) {
98 break;
99 }
100
101 if (dest_copy.x > edt->pwidget->size.x) {
102 dest = dest_copy;
103 alphablit(input_chain_tmp->tsurf, NULL, edt->pwidget->dst->surface, &dest,
104 255);
105 }
106
107 start_mod_x = input_chain_tmp->tsurf->w;
108
109 /* draw cursor */
110 if (input_chain_tmp == edt->input_chain) {
111 dest = dest_copy;
112
113 create_line(edt->pwidget->dst->surface,
114 dest.x - 1, dest.y + (edt->bg->h / 8),
115 dest.x - 1, dest.y + edt->bg->h - (edt->bg->h / 4),
117 /* save active element position */
118 edt->input_chain_x = dest_copy.x;
119 }
120
122 } /* while - draw loop */
123
124 widget_flush(edt->pwidget);
125
126 return 0;
127}
128
129/**********************************************************************/
142static int redraw_edit(struct widget *edit_widget)
143{
145 return redraw_edit_chain((struct text_edit *)edit_widget->data.ptr);
146 } else {
147 int ret;
148 SDL_Rect rdest = {edit_widget->size.x, edit_widget->size.y, 0, 0};
149 SDL_Surface *pedit = NULL;
150 SDL_Surface *text;
151
152 ret = (*baseclass_redraw)(edit_widget);
153 if (ret != 0) {
154 return ret;
155 }
156
157 if (edit_widget->string_utf8->text != NULL
159 char *backup = edit_widget->string_utf8->text;
160 size_t len = strlen(backup) + 1;
161 char *cbuf = fc_calloc(1, len);
162
163 memset(cbuf, '*', len - 1);
164 cbuf[len - 1] = '\0';
165 edit_widget->string_utf8->text = cbuf;
166 text = create_text_surf_from_utf8(edit_widget->string_utf8);
167 FC_FREE(cbuf);
168 edit_widget->string_utf8->text = backup;
169 } else {
170 text = create_text_surf_from_utf8(edit_widget->string_utf8);
171 }
172
174 edit_widget->size.w, edit_widget->size.h);
175
176 if (!pedit) {
177 return -1;
178 }
179
180 /* blit theme */
181 alphablit(pedit, NULL, edit_widget->dst->surface, &rdest, 255);
182
183 /* set position and blit text */
184 if (text) {
185 rdest.y += (pedit->h - text->h) / 2;
186 /* blit centred text to botton */
187 if (edit_widget->string_utf8->style & SF_CENTER) {
188 rdest.x += (pedit->w - text->w) / 2;
189 } else {
190 if (edit_widget->string_utf8->style & SF_CENTER_RIGHT) {
191 rdest.x += pedit->w - text->w - adj_size(5);
192 } else {
193 rdest.x += adj_size(5); /* center left */
194 }
195 }
196
197 alphablit(text, NULL, edit_widget->dst->surface, &rdest, 255);
198 }
199 /* text */
200 ret = pedit->h;
201
202 /* Free memory */
203 FREESURFACE(text);
204 FREESURFACE(pedit);
205
206 return ret;
207 }
208
209 return 0;
210}
211
212/**********************************************************************/
217static size_t chainlen(const struct utf8_char *chain)
218{
219 size_t length = 0;
220
221 if (chain) {
222 while (TRUE) {
223 length++;
224 if (chain->next == NULL) {
225 break;
226 }
227 chain = chain->next;
228 }
229 }
230
231 return length;
232}
233
234/**********************************************************************/
237static void del_chain(struct utf8_char *chain)
238{
239 int i, len = 0;
240
241 if (!chain) {
242 return;
243 }
244
245 len = chainlen(chain);
246
247 if (len > 1) {
248 chain = chain->next;
249 for (i = 0; i < len - 1; i++) {
250 FREESURFACE(chain->prev->tsurf);
251 FC_FREE(chain->prev);
252 chain = chain->next;
253 }
254 }
255
256 FC_FREE(chain);
257}
258
259/**********************************************************************/
263static struct utf8_char *text2chain(const char *text_in)
264{
265 int i, len;
266 struct utf8_char *out_chain = NULL;
267 struct utf8_char *chr_tmp = NULL;
268 int j;
269
270 if (text_in == NULL) {
271 return NULL;
272 }
273
274 len = strlen(text_in);
275
276 if (len == 0) {
277 return NULL;
278 }
279
280 out_chain = fc_calloc(1, sizeof(struct utf8_char));
281 out_chain->chr[0] = text_in[0];
282 for (j = 1; (text_in[j] & (128 + 64)) == 128; j++) {
283 out_chain->chr[j] = text_in[j];
284 }
285 out_chain->bytes = j;
287
288 for (i = 1; i < len; i += j) {
289 chr_tmp->next = fc_calloc(1, sizeof(struct utf8_char));
290 chr_tmp->next->chr[0] = text_in[i];
291 for (j = 1; (text_in[i + j] & (128 + 64)) == 128; j++) {
292 chr_tmp->next->chr[j] = text_in[i + j];
293 }
294 chr_tmp->next->bytes = j;
295 chr_tmp->next->prev = chr_tmp;
296 chr_tmp = chr_tmp->next;
297 }
298
299 return out_chain;
300}
301
302/**********************************************************************/
306static char *chain2text(const struct utf8_char *in_chain, size_t len,
307 size_t *size)
308{
309 int i;
310 char *out_text = NULL;
311 int oi = 0;
312 int total_size = 0;
313
314 if (!(len && in_chain)) {
315 return out_text;
316 }
317
318 out_text = fc_calloc(8, len + 1);
319 for (i = 0; i < len; i++) {
320 int j;
321
322 for (j = 0; j < in_chain->bytes && i < len; j++) {
323 out_text[oi++] = in_chain->chr[j];
324 }
325
326 total_size += in_chain->bytes;
327 in_chain = in_chain->next;
328 }
329
330 *size = total_size;
331
332 return out_text;
333}
334
335/* =================================================== */
336
337/**********************************************************************/
350struct widget *create_edit(SDL_Surface *background, struct gui_layer *pdest,
351 utf8_str *pstr, int length, Uint32 flags)
352{
353 SDL_Rect buf = {0, 0, 0, 0};
354 struct widget *pedit = widget_new();
355
356 pedit->theme = current_theme->edit;
357 pedit->theme2 = background; /* FIXME: make somewhere use of it */
358 pedit->string_utf8 = pstr;
359 set_wflag(pedit, (WF_FREE_STRING | WF_FREE_GFX | flags));
361 set_wtype(pedit, WT_EDIT);
362 pedit->mod = KMOD_NONE;
363
364 baseclass_redraw = pedit->redraw;
365 pedit->redraw = redraw_edit;
366
367 if (pstr != NULL) {
368 pedit->string_utf8->style |= SF_CENTER;
370 buf.h += adj_size(4);
371 }
372
373 length = MAX(length, buf.w + adj_size(10));
374
375 correct_size_bcgnd_surf(current_theme->edit, &length, &buf.h);
376
377 pedit->size.w = length;
378 pedit->size.h = buf.h;
379
380 if (pdest) {
381 pedit->dst = pdest;
382 } else {
383 pedit->dst = add_gui_layer(pedit->size.w, pedit->size.h);
384 }
385
386 return pedit;
387}
388
389/**********************************************************************/
392int draw_edit(struct widget *pedit, Sint16 start_x, Sint16 start_y)
393{
394 pedit->size.x = start_x;
395 pedit->size.y = start_y;
396
397 if (get_wflags(pedit) & WF_RESTORE_BACKGROUND) {
399 }
400
401 return redraw_edit(pedit);
402}
403
404/**********************************************************************/
424{
425 struct text_edit *edt = (struct text_edit *)data;
427 bool redraw = FALSE;
428
429 /* find which key is pressed */
430 switch (key.sym) {
431 case SDLK_ESCAPE:
432 /* exit from loop without changes */
433 return ED_ESC;
434 case SDLK_RETURN:
435 case SDLK_KP_ENTER:
436 /* exit from loop */
437 return ED_RETURN;
438 /*
439 case SDLK_KP6:
440 if (key.mod & KMOD_NUM) {
441 goto INPUT;
442 }
443 */
444 case SDLK_RIGHT:
445 {
446 /* move cursor right */
447 if (edt->input_chain->next) {
448 if (edt->input_chain_x >= (edt->pwidget->size.x + edt->bg->w - adj_size(10))) {
449 edt->start_x -= edt->input_chain->tsurf->w -
450 (edt->pwidget->size.x + edt->bg->w - adj_size(5) - edt->input_chain_x);
451 }
452
453 edt->input_chain = edt->input_chain->next;
454 redraw = TRUE;
455 }
456 }
457 break;
458 /*
459 case SDLK_KP4:
460 if (key.mod & KMOD_NUM) {
461 goto INPUT;
462 }
463 */
464 case SDLK_LEFT:
465 {
466 /* move cursor left */
467 if (edt->input_chain->prev) {
468 edt->input_chain = edt->input_chain->prev;
469 if ((edt->input_chain_x <=
470 (edt->pwidget->size.x + adj_size(9))) && (edt->start_x != adj_size(5))) {
471 if (edt->input_chain_x != (edt->pwidget->size.x + adj_size(5))) {
472 edt->start_x += (edt->pwidget->size.x - edt->input_chain_x + adj_size(5));
473 }
474
475 edt->start_x += (edt->input_chain->tsurf->w);
476 }
477 redraw = TRUE;
478 }
479 }
480 break;
481 /*
482 case SDLK_KP7:
483 if (key.mod & KMOD_NUM) {
484 goto INPUT;
485 }
486 */
487 case SDLK_HOME:
488 {
489 /* move cursor to begin of chain (and edit field) */
490 edt->input_chain = edt->begin_text_chain;
491 redraw = TRUE;
492 edt->start_x = adj_size(5);
493 }
494 break;
495 /*
496 case SDLK_KP1:
497 if (key.mod & KMOD_NUM) {
498 goto INPUT;
499 }
500 */
501 case SDLK_END:
502 {
503 /* move cursor to end of chain (and edit field) */
504 edt->input_chain = edt->end_text_chain;
505 redraw = TRUE;
506
507 if (edt->pwidget->size.w - edt->true_length < 0) {
508 edt->start_x = edt->pwidget->size.w - edt->true_length - adj_size(5);
509 }
510 }
511 break;
512 case SDLK_BACKSPACE:
513 {
514 /* del element of chain (and move cursor left) */
515 if (edt->input_chain->prev) {
516 if ((edt->input_chain_x <=
517 (edt->pwidget->size.x + adj_size(9))) && (edt->start_x != adj_size(5))) {
518 if (edt->input_chain_x != (edt->pwidget->size.x + adj_size(5))) {
519 edt->start_x += (edt->pwidget->size.x - edt->input_chain_x + adj_size(5));
520 }
521 edt->start_x += (edt->input_chain->prev->tsurf->w);
522 }
523
524 if (edt->input_chain->prev->prev) {
525 edt->input_chain->prev->prev->next = edt->input_chain;
526 input_chain_tmp = edt->input_chain->prev->prev;
527 edt->true_length -= edt->input_chain->prev->tsurf->w;
528 FREESURFACE(edt->input_chain->prev->tsurf);
529 FC_FREE(edt->input_chain->prev);
530 edt->input_chain->prev = input_chain_tmp;
531 } else {
532 edt->true_length -= edt->input_chain->prev->tsurf->w;
533 FREESURFACE(edt->input_chain->prev->tsurf);
534 FC_FREE(edt->input_chain->prev);
535 edt->begin_text_chain = edt->input_chain;
536 }
537
538 edt->chain_len--;
539 redraw = TRUE;
540 }
541 }
542 break;
543 /*
544 case SDLK_KP_PERIOD:
545 if (key.mod & KMOD_NUM) {
546 goto INPUT;
547 }
548 */
549 case SDLK_DELETE:
550 {
551 /* del element of chain */
552 if (edt->input_chain->next && edt->input_chain->prev) {
553 edt->input_chain->prev->next = edt->input_chain->next;
554 edt->input_chain->next->prev = edt->input_chain->prev;
555 input_chain_tmp = edt->input_chain->next;
556 edt->true_length -= edt->input_chain->tsurf->w;
557 FREESURFACE(edt->input_chain->tsurf);
558 FC_FREE(edt->input_chain);
559 edt->input_chain = input_chain_tmp;
560 edt->chain_len--;
561 redraw = TRUE;
562 }
563
564 if (edt->input_chain->next && !edt->input_chain->prev) {
565 edt->input_chain = edt->input_chain->next;
566 edt->true_length -= edt->input_chain->prev->tsurf->w;
567 FREESURFACE(edt->input_chain->prev->tsurf);
568 FC_FREE(edt->input_chain->prev);
569 edt->begin_text_chain = edt->input_chain;
570 edt->chain_len--;
571 redraw = TRUE;
572 }
573 }
574 break;
575 default:
576 break;
577 } /* key pressed switch */
578
579 if (redraw) {
581 }
582
583 return ID_ERROR;
584}
585
586/**********************************************************************/
589static Uint16 edit_textinput(const char *text, void *data)
590{
591 struct text_edit *edt = (struct text_edit *)data;
593 int i;
594
595 for (i = 0; text[i] != '\0';) {
596 int charlen = 1;
597 unsigned char leading = text[i++];
598 int sum = 128 + 64;
599 int addition = 32;
600
601 /* Add new element of chain (and move cursor right) */
602 if (edt->input_chain != edt->begin_text_chain) {
603 input_chain_tmp = edt->input_chain->prev;
604 edt->input_chain->prev = fc_calloc(1, sizeof(struct utf8_char));
605 edt->input_chain->prev->next = edt->input_chain;
606 edt->input_chain->prev->prev = input_chain_tmp;
607 input_chain_tmp->next = edt->input_chain->prev;
608 } else {
609 edt->input_chain->prev = fc_calloc(1, sizeof(struct utf8_char));
610 edt->input_chain->prev->next = edt->input_chain;
611 edt->begin_text_chain = edt->input_chain->prev;
612 }
613
614 edt->input_chain->prev->chr[0] = leading;
615 /* UTF-8 multibyte handling */
616 while (leading >= sum) {
617 edt->input_chain->prev->chr[charlen++] = text[i++];
618 sum += addition;
619 addition /= 2;
620 }
621 edt->input_chain->prev->chr[charlen] = '\0';
622 edt->input_chain->prev->bytes = charlen;
623
624 if (get_wflags(edt->pwidget) & WF_PASSWD_EDIT) {
625 char passwd_chr[2] = {'*', '\0'};
626
627 edt->input_chain->prev->tsurf =
628 TTF_RenderUTF8_Blended(edt->pwidget->string_utf8->font,
630 edt->pwidget->string_utf8->fgcol);
631 } else {
632 edt->input_chain->prev->tsurf =
633 TTF_RenderUTF8_Blended(edt->pwidget->string_utf8->font,
634 edt->input_chain->prev->chr,
635 edt->pwidget->string_utf8->fgcol);
636 }
637 edt->true_length += edt->input_chain->prev->tsurf->w;
638
639 if (edt->input_chain_x >= edt->pwidget->size.x + edt->bg->w - adj_size(10)) {
640 if (edt->input_chain == edt->end_text_chain) {
641 edt->start_x = edt->bg->w - adj_size(5) - edt->true_length;
642 } else {
643 edt->start_x -= edt->input_chain->prev->tsurf->w -
644 (edt->pwidget->size.x + edt->bg->w - adj_size(5) - edt->input_chain_x);
645 }
646 }
647
648 edt->chain_len++;
649 }
650
652
653 return ID_ERROR;
654}
655
656/**********************************************************************/
660 void *data)
661{
662 struct text_edit *edt = (struct text_edit *)data;
663
664 if (button_event->button == SDL_BUTTON_LEFT) {
665 if (!(button_event->x >= edt->pwidget->size.x
666 && button_event->x < edt->pwidget->size.x + edt->bg->w
667 && button_event->y >= edt->pwidget->size.y
668 && button_event->y < edt->pwidget->size.y + edt->bg->h)) {
669 /* exit from loop */
670 return (Uint16)ED_MOUSE;
671 }
672 }
673
674 return (Uint16)ID_ERROR;
675}
676
677/**********************************************************************/
682{
683 struct text_edit edt;
684 struct utf8_char ___last;
687 void *backup = edit_widget->data.ptr;
688
689 edt.pwidget = edit_widget;
690 edt.chain_len = 0;
691 edt.true_length = 0;
692 edt.start_x = adj_size(5);
693 edt.input_chain_x = 0;
694
695 edit_widget->data.ptr = (void *)&edt;
696
697#if 0
700#endif /* 0 */
701
703 edit_widget->size.w, edit_widget->size.h);
704
705 /* Creating Chain */
706 edt.begin_text_chain = text2chain(edit_widget->string_utf8->text);
707
708 /* Creating Empty (Last) pice of Chain */
709 edt.input_chain = &___last;
710 edt.end_text_chain = edt.input_chain;
711 edt.end_text_chain->chr[0] = 32; /* spacebar */
712 edt.end_text_chain->chr[1] = 0; /* spacebar */
713 edt.end_text_chain->next = NULL;
714 edt.end_text_chain->prev = NULL;
715
716 /* set font style (if any ) */
717 if (!((edit_widget->string_utf8->style & 0x0F) & TTF_STYLE_NORMAL)) {
718 TTF_SetFontStyle(edit_widget->string_utf8->font,
719 (edit_widget->string_utf8->style & 0x0F));
720 }
721
722 edt.end_text_chain->tsurf =
723 TTF_RenderUTF8_Blended(edit_widget->string_utf8->font,
724 edt.end_text_chain->chr,
725 edit_widget->string_utf8->fgcol);
726
727 /* create surface for each font in chain and find chain length */
728 if (edt.begin_text_chain) {
729 input_chain_tmp = edt.begin_text_chain;
730
731 while (TRUE) {
732 edt.chain_len++;
733
735 const char passwd_chr[2] = {'*', '\0'};
736
737 input_chain_tmp->tsurf =
738 TTF_RenderUTF8_Blended(edit_widget->string_utf8->font,
740 edit_widget->string_utf8->fgcol);
741 } else {
742 input_chain_tmp->tsurf =
743 TTF_RenderUTF8_Blended(edit_widget->string_utf8->font,
744 input_chain_tmp->chr,
745 edit_widget->string_utf8->fgcol);
746 }
747
748 edt.true_length += input_chain_tmp->tsurf->w;
749
750 if (input_chain_tmp->next == NULL) {
751 break;
752 }
753
755 }
756 /* set terminator of list */
757 input_chain_tmp->next = edt.input_chain;
758 edt.input_chain->prev = input_chain_tmp;
760 } else {
761 edt.begin_text_chain = edt.input_chain;
762 }
763
765
767 {
768 /* Local loop */
769 Uint16 rety = gui_event_loop((void *)&edt, NULL,
772
773 if (edt.begin_text_chain == edt.end_text_chain) {
774 edt.begin_text_chain = NULL;
775 }
776
777 if (rety == MAX_ID) {
779 } else {
780 ret = (enum edit_return_codes) rety;
781
782 /* This is here because we have no knowledge that edit_widget exist
783 or nor in force exit mode from gui loop */
784
785 /* Reset font settings */
786 if (!((edit_widget->string_utf8->style & 0x0F) & TTF_STYLE_NORMAL)) {
787 TTF_SetFontStyle(edit_widget->string_utf8->font, TTF_STYLE_NORMAL);
788 }
789
790 if (ret != ED_ESC) {
791 size_t len = 0;
792
793 FC_FREE(edit_widget->string_utf8->text);
794 edit_widget->string_utf8->text =
795 chain2text(edt.begin_text_chain, edt.chain_len, &len);
796 edit_widget->string_utf8->n_alloc = len + 1;
797 }
798
799 edit_widget->data.ptr = backup;
801 }
802 }
803
804 FREESURFACE(edt.end_text_chain->tsurf);
805
806 del_chain(edt.begin_text_chain);
807
808 FREESURFACE(edt.bg);
809
810 /* Disable repeat key */
811
812#if 0
814
815 /* Disable Unicode */
817#endif /* 0 */
818
819 return ret;
820}
char * incite_cost
Definition comments.c:76
QString current_theme
Definition fc_client.cpp:64
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:47
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1381
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct gui_layer * add_gui_layer(int width, int height)
Definition graphics.c:112
#define FREESURFACE(ptr)
Definition graphics.h:322
@ ID_ERROR
Definition gui_id.h:26
Uint16 gui_event_loop(void *data, void(*loop_action)(void *data), Uint16(*key_down_handler)(SDL_Keysym key, void *data), Uint16(*key_up_handler)(SDL_Keysym key, void *data), Uint16(*textinput_handler)(const char *text, void *data), Uint16(*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*finger_motion_handler)(SDL_TouchFingerEvent *touch_event, void *data), Uint16(*mouse_button_down_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_button_up_handler)(SDL_MouseButtonEvent *button_event, void *data), Uint16(*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event, void *data))
Definition gui_main.c:603
#define adj_size(size)
Definition gui_main.h:141
void utf8_str_size(utf8_str *pstr, SDL_Rect *fill)
Definition gui_string.c:106
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
#define SF_CENTER
Definition gui_string.h:40
#define SF_CENTER_RIGHT
Definition gui_string.h:41
@ COLOR_THEME_EDITFIELD_CARET
Definition themecolors.h:32
void correct_size_bcgnd_surf(SDL_Surface *ptheme, int *width, int *height)
Definition widget.c:63
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1151
SDL_Surface * create_bcgnd_surf(SDL_Surface *ptheme, enum widget_state state, Uint16 width, Uint16 height)
Definition widget.c:78
#define MAX_ID
Definition widget.h:38
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_PRESSED
Definition widget.h:98
static void widget_flush(struct widget *pwidget)
Definition widget.h:291
enum widget_flag get_wflags(const struct widget *pwidget)
Definition widget_core.c:86
void set_wstate(struct widget *pwidget, enum widget_state state)
Definition widget_core.c:36
enum widget_state get_wstate(const struct widget *pwidget)
Definition widget_core.c:70
@ WF_FREE_GFX
Definition widget.h:70
@ WF_PASSWD_EDIT
Definition widget.h:90
@ WF_FREE_STRING
Definition widget.h:76
@ WF_RESTORE_BACKGROUND
Definition widget.h:85
void set_wtype(struct widget *pwidget, enum widget_type type)
Definition widget_core.c:45
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
@ WT_EDIT
Definition widget.h:48
struct widget * widget_new(void)
static struct utf8_char * text2chain(const char *text_in)
static int redraw_edit_chain(struct text_edit *edt)
Definition widget_edit.c:66
static char * chain2text(const struct utf8_char *in_chain, size_t len, size_t *size)
static size_t chainlen(const struct utf8_char *chain)
struct widget * create_edit(SDL_Surface *background, struct gui_layer *pdest, utf8_str *pstr, int length, Uint32 flags)
enum edit_return_codes edit_field(struct widget *edit_widget)
static Uint16 edit_mouse_button_down(SDL_MouseButtonEvent *button_event, void *data)
static int(* baseclass_redraw)(struct widget *pwidget)
Definition widget_edit.c:61
static void del_chain(struct utf8_char *chain)
static int redraw_edit(struct widget *edit_widget)
static Uint16 edit_textinput(const char *text, void *data)
static Uint16 edit_key_down(SDL_Keysym key, void *data)
int draw_edit(struct widget *pedit, Sint16 start_x, Sint16 start_y)
edit_return_codes
Definition widget_edit.h:17
@ ED_FORCE_EXIT
Definition widget_edit.h:21
@ ED_ESC
Definition widget_edit.h:19
@ ED_RETURN
Definition widget_edit.h:18
@ ED_MOUSE
Definition widget_edit.h:20
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
int len
Definition packhand.c:127
#define MAX(x, y)
Definition shared.h:54
size_t size
Definition specvec.h:72
struct widget * pwidget
Definition widget_edit.c:49
int true_length
Definition widget_edit.c:52
int input_chain_x
Definition widget_edit.c:53
struct utf8_char * begin_text_chain
Definition widget_edit.c:45
struct utf8_char * end_text_chain
Definition widget_edit.c:46
SDL_Surface * bg
Definition widget_edit.c:48
struct utf8_char * input_chain
Definition widget_edit.c:47
int chain_len
Definition widget_edit.c:50
struct utf8_char * next
Definition widget_edit.c:37
struct utf8_char * prev
Definition widget_edit.c:38
SDL_Surface * tsurf
Definition widget_edit.c:41
char chr[7]
Definition widget_edit.c:40
Uint8 style
Definition gui_string.h:53
SDL_Keycode key
Definition widget.h:153
SDL_Surface * theme
Definition widget.h:118
union widget::@223 data
SDL_Surface * theme2
Definition widget.h:119
int(* redraw)(struct widget *pwidget)
Definition widget.h:163
struct gui_layer * dst
Definition widget.h:116
Uint16 mod
Definition widget.h:154
utf8_str * string_utf8
Definition widget.h:121
SDL_Rect size
Definition widget.h:145
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47