Freeciv-3.1
Loading...
Searching...
No Matches
widget.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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/***********************************************************************
15 widget.c - description
16 -------------------
17 begin : June 30 2002
18 copyright : (C) 2002 by Rafał Bursig
19 email : Rafał Bursig <bursig@poczta.fm>
20***********************************************************************/
21
22#ifdef HAVE_CONFIG_H
23#include <fc_config.h>
24#endif
25
26/* SDL2 */
27#ifdef SDL2_PLAIN_INCLUDE
28#include <SDL.h>
29#else /* SDL2_PLAIN_INCLUDE */
30#include <SDL2/SDL.h>
31#endif /* SDL2_PLAIN_INCLUDE */
32
33/* utility */
34#include "log.h"
35
36/* gui-sdl2 */
37#include "colors.h"
38#include "graphics.h"
39#include "gui_id.h"
40#include "gui_main.h"
41#include "gui_tilespec.h"
42#include "mapview.h"
43#include "themespec.h"
44
45#include "widget.h"
46#include "widget_p.h"
47
50
52
53/* ================================ Private ============================ */
54
56
58
59/**********************************************************************/
64 int *width, int *height)
65{
66 *width = MAX(*width, 2 * (ptheme->w / adj_size(16)));
67 *height = MAX(*height, 2 * (ptheme->h / adj_size(16)));
68}
69
70/**********************************************************************/
80{
81 bool zoom;
84 int i, j;
85 SDL_Rect src, des;
86 SDL_Surface *background = NULL;
87 int start_y = (ptheme->h / 4) * state;
88
89 tile_width_len_end = ptheme->w / 16;
91
94
95 /* corrections I */
96 if (((tile_count_len_mid *
99 }
100
105
106 /* corrections II */
110 }
111
114 zoom = ((i != width) || (j != height));
115
116 /* now allocate memory */
117 background = create_surf(i, j, SDL_SWSURFACE);
118
119 /* copy left end */
120
121 /* left top */
122 src.x = 0;
123 src.y = start_y;
124 src.w = tile_width_len_end;
125 src.h = tile_width_height_end;
126
127 des.x = 0;
128 des.y = 0;
129 alphablit(ptheme, &src, background, &des, 255);
130
131 /* left middle */
133 src.h = tile_width_height_mid;
134 for (i = 0; i < tile_count_height_mid; i++) {
136 alphablit(ptheme, &src, background, &des, 255);
137 }
138
139 /* left bottom */
140 src.y = start_y + ((ptheme->h / 4) - tile_width_height_end);
141 src.h = tile_width_height_end;
142 des.y = background->h - tile_width_height_end;
143 clear_surface(background, &des);
144 alphablit(ptheme, &src, background, &des, 255);
145
146 /* copy middle parts */
147
148 src.x = tile_width_len_end;
149 src.y = start_y;
150 src.w = tile_width_len_mid;
151
152 for (i = 0; i < tile_count_len_mid; i++) {
153
154 /* middle top */
156 des.y = 0;
157 src.y = start_y;
158 alphablit(ptheme, &src, background, &des, 255);
159
160 /* middle middle */
162 src.h = tile_width_height_mid;
163 for (j = 0; j < tile_count_height_mid; j++) {
165 alphablit(ptheme, &src, background, &des, 255);
166 }
167
168 /* middle bottom */
169 src.y = start_y + ((ptheme->h / 4) - tile_width_height_end);
170 src.h = tile_width_height_end;
171 des.y = background->h - tile_width_height_end;
172 clear_surface(background, &des);
173 alphablit(ptheme, &src, background, &des, 255);
174 }
175
176 /* copy right end */
177
178 /* right top */
179 src.x = ptheme->w - tile_width_len_end;
180 src.y = start_y;
181 src.w = tile_width_len_end;
182
183 des.x = background->w - tile_width_len_end;
184 des.y = 0;
185
186 alphablit(ptheme, &src, background, &des, 255);
187
188 /* right middle */
190 src.h = tile_width_height_mid;
191 for (i = 0; i < tile_count_height_mid; i++) {
193 alphablit(ptheme, &src, background, &des, 255);
194 }
195
196 /* right bottom */
197 src.y = start_y + ((ptheme->h / 4) - tile_width_height_end);
198 src.h = tile_width_height_end;
199 des.y = background->h - tile_width_height_end;
200 clear_surface(background, &des);
201 alphablit(ptheme, &src, background, &des, 255);
202
203 if (zoom) {
204 SDL_Surface *zoomed = resize_surface(background, width, height, 1);
205
206 FREESURFACE(background);
207 background = zoomed;
208 }
209
210 return background;
211}
212
213/* =================================================== */
214/* ===================== WIDGET LIST ==================== */
215/* =================================================== */
216
217/**********************************************************************/
223 int x, int y)
224{
225 SDL_Rect area = {0, 0, 0, 0};
226 struct widget *pwidget;
227
229
230 while (pwidget) {
231 area.x = pwidget->dst->dest_rect.x + pwidget->size.x;
232 area.y = pwidget->dst->dest_rect.y + pwidget->size.y;
233 area.w = pwidget->size.w;
234 area.h = pwidget->size.h;
235 if (is_in_rect_area(x, y, area)
236 && !((get_wflags(pwidget) & WF_HIDDEN) == WF_HIDDEN)) {
237 return (struct widget *) pwidget;
238 }
239 pwidget = pwidget->next;
240 }
241
242 return NULL;
243}
244
245/**********************************************************************/
253{
254 struct widget *pwidget;
255
257
258 key.mod &= ~(KMOD_NUM | KMOD_CAPS);
259 while (pwidget) {
260 if ((pwidget->key == key.sym
261 || (pwidget->key == SDLK_RETURN && key.sym == SDLK_KP_ENTER)
262 || (pwidget->key == SDLK_KP_ENTER && key.sym == SDLK_RETURN))
263 && ((pwidget->mod & key.mod) || (pwidget->mod == key.mod))) {
264 if (!((get_wstate(pwidget) == FC_WS_DISABLED)
265 || ((get_wflags(pwidget) & WF_HIDDEN) == WF_HIDDEN))) {
266 return (struct widget *) pwidget;
267 }
268 }
269 pwidget = pwidget->next;
270 }
271
272 return NULL;
273}
274
275/**********************************************************************/
296{
297 Uint16 id;
298
299 if (!pwidget) {
300 return 0;
301 }
302
304 if (info_area) {
308 }
309
310 switch (get_wtype(pwidget)) {
311 case WT_TI_BUTTON:
312 case WT_I_BUTTON:
313 case WT_ICON:
314 case WT_ICON2:
316 set_wstate(pwidget, FC_WS_PRESSED);
317 widget_redraw(pwidget);
318 widget_mark_dirty(pwidget);
319 flush_dirty();
320 set_wstate(pwidget, FC_WS_SELECTED);
321 SDL_Delay(300);
322 }
323 if (pwidget->action != NULL && pwidget->action(pwidget)) {
324 id = 0;
325 } else {
326 id = pwidget->id;
327 }
328
329 break;
330
331 case WT_EDIT:
332 {
334 bool ret, loop = (get_wflags(pwidget) & WF_EDIT_LOOP);
335 enum edit_return_codes change;
336
337 do {
338 ret = FALSE;
339 change = edit_field(pwidget);
340 if (change != ED_FORCE_EXIT && (!loop || change != ED_RETURN)) {
341 widget_redraw(pwidget);
342 widget_mark_dirty(pwidget);
343 flush_dirty();
344 }
345 if (change != ED_FORCE_EXIT && change != ED_ESC
346 && pwidget->action != NULL) {
347 pwidget->action(pwidget);
348 }
349 if (loop && change == ED_RETURN) {
350 ret = TRUE;
351 }
352 } while (ret);
353 }
354
355 id = 0;
356 break;
357 }
358 case WT_VSCROLLBAR:
359 case WT_HSCROLLBAR:
361 set_wstate(pwidget, FC_WS_PRESSED);
362 widget_redraw(pwidget);
363 widget_mark_dirty(pwidget);
364 flush_dirty();
365 }
366 if (pwidget->action != NULL && pwidget->action(pwidget)) {
367 id = 0;
368 } else {
369 id = pwidget->id;
370 }
371
372 break;
373 case WT_CHECKBOX:
374 case WT_TCHECKBOX:
376 set_wstate(pwidget, FC_WS_PRESSED);
377 widget_redraw(pwidget);
378 widget_mark_dirty(pwidget);
379 flush_dirty();
380 set_wstate(pwidget, FC_WS_SELECTED);
381 toggle_checkbox(pwidget);
382 SDL_Delay(300);
383 }
384 if (pwidget->action != NULL && pwidget->action(pwidget)) {
385 id = 0;
386 } else {
387 id = pwidget->id;
388 }
389
390 break;
391 case WT_COMBO:
393 set_wstate(pwidget, FC_WS_PRESSED);
394 combo_popup(pwidget);
395 } else {
396 combo_popdown(pwidget);
397 }
398
399 id = 0;
400 break;
401 default:
402 if (pwidget->action != NULL && pwidget->action(pwidget)) {
403 id = 0;
404 } else {
405 id = pwidget->id;
406 }
407
408 break;
409 }
410
411 return id;
412}
413
414/**********************************************************************/
418{
421
424
425 /* turn off quick info timer/counter */
427 }
428 }
429
430 if (info_area) {
434 }
435
437}
438
439/**********************************************************************/
442void widget_selected_action(struct widget *pwidget)
443{
444 if (!pwidget || pwidget == selected_widget) {
445 return;
446 }
447
448 if (selected_widget) {
450 }
451
452 set_wstate(pwidget, FC_WS_SELECTED);
453
454 pwidget->select(pwidget);
455
456 selected_widget = pwidget;
457
458 if (get_wflags(pwidget) & WF_WIDGET_HAS_INFO_LABEL) {
460 }
461}
462
463/**********************************************************************/
467{
468 SDL_Surface *text;
471 struct widget *pwidget = selected_widget;
472
473 if (!pwidget || !pwidget->info_label) {
474 return;
475 }
476
477 if (!info_label) {
478 info_area = fc_calloc(1, sizeof(SDL_Rect));
479
480 color = pwidget->info_label->fgcol;
481 pwidget->info_label->style |= TTF_STYLE_BOLD;
483
484 /* create string and bcgd theme */
485 text = create_text_surf_from_utf8(pwidget->info_label);
486
487 pwidget->info_label->fgcol = color;
488
489 info_label = create_filled_surface(text->w + adj_size(10), text->h + adj_size(6),
492
493 /* calculate start position */
494 if ((pwidget->dst->dest_rect.y + pwidget->size.y) - info_label->h - adj_size(6) < 0) {
495 info_area->y = (pwidget->dst->dest_rect.y + pwidget->size.y) + pwidget->size.h + adj_size(3);
496 } else {
497 info_area->y = (pwidget->dst->dest_rect.y + pwidget->size.y) - info_label->h - adj_size(5);
498 }
499
500 if ((pwidget->dst->dest_rect.x + pwidget->size.x) + info_label->w + adj_size(5) > main_window_width()) {
501 info_area->x = (pwidget->dst->dest_rect.x + pwidget->size.x) - info_label->w - adj_size(5);
502 } else {
503 info_area->x = (pwidget->dst->dest_rect.x + pwidget->size.x) + adj_size(3);
504 }
505
506 info_area->w = info_label->w + adj_size(2);
507 info_area->h = info_label->h + adj_size(3);
508
509 /* draw text */
510 dstrect.x = adj_size(6);
511 dstrect.y = adj_size(3);
512
513 alphablit(text, NULL, info_label, &dstrect, 255);
514
515 FREESURFACE(text);
516
517 /* draw frame */
519 0, 0, info_label->w - 1, info_label->h - 1,
521
522 }
523
524 if (rect) {
525 dstrect.x = MAX(rect->x, info_area->x);
526 dstrect.y = MAX(rect->y, info_area->y);
527
528 srcrect.x = dstrect.x - info_area->x;
529 srcrect.y = dstrect.y - info_area->y;
530 srcrect.w = MIN((info_area->x + info_area->w), (rect->x + rect->w)) - dstrect.x;
531 srcrect.h = MIN((info_area->y + info_area->h), (rect->y + rect->h)) - dstrect.y;
532
534 } else {
536 }
537
540#if 0
542 info_area->w, info_area->h);
543#endif /* 0 */
544 }
545}
546
547/**********************************************************************/
552 Uint16 id, enum scan_direction direction)
553{
554 if (direction == SCAN_FORWARD) {
555 while (gui_list) {
556 if (gui_list->id == id) {
557 return (struct widget *) gui_list;
558 }
559 gui_list = gui_list->next;
560 }
561 } else {
562 while (gui_list) {
563 if (gui_list->id == id) {
564 return (struct widget *) gui_list;
565 }
566 gui_list = gui_list->prev;
567 }
568 }
569
570 return NULL;
571}
572
573/**********************************************************************/
581
582/**********************************************************************/
586{
589 gui->id = id;
592 } else {
595 }
596}
597
598/**********************************************************************/
602{
603 new_widget->next = add_dock;
604 new_widget->prev = add_dock->prev;
605 if (add_dock->prev) {
606 add_dock->prev->next = new_widget;
607 }
608 add_dock->prev = new_widget;
611 }
612}
613
614/**********************************************************************/
622{
623 if (!gui) {
624 return;
625 }
626
629 }
630
631 if (gui->prev && gui->next) {
632 gui->prev->next = gui->next;
633 gui->next->prev = gui->prev;
634 } else {
635 if (gui->prev) {
636 gui->prev->next = NULL;
637 }
638
639 if (gui->next) {
640 gui->next->prev = NULL;
641 }
642
643 }
644
645 if (selected_widget == gui) {
647 }
648}
649
650/**********************************************************************/
657{
658 return (begin_main_widget_list == gui);
659}
660
661/**********************************************************************/
667{
668 if (!gui || gui == begin_main_widget_list) {
669 return;
670 }
671
672 /* gui->prev always exists because
673 we don't do this to begin_main_widget_list */
674 if (gui->next) {
675 gui->prev->next = gui->next;
676 gui->next->prev = gui->prev;
677 } else {
678 gui->prev->next = NULL;
679 }
680
684 gui->prev = NULL;
685}
686
687/**********************************************************************/
694
695/**********************************************************************/
699{
700 while (gui_list) {
701 if (gui_list->next) {
702 gui_list = gui_list->next;
703 FREEWIDGET(gui_list->prev);
704 } else {
706 }
707 }
708}
709
710/* ===================================================================== */
711/* ================================ Universal ========================== */
712/* ===================================================================== */
713
714/**********************************************************************/
720 const struct widget *end_group_widget_list,
721 int add_to_update)
722{
723 Uint16 count = 0;
724 struct widget *tmp_widget = (struct widget *) end_group_widget_list;
725
726 while (tmp_widget) {
727
728 if (!(get_wflags(tmp_widget) & WF_HIDDEN)) {
729
731
732 if (add_to_update) {
734 }
735
736 count++;
737 }
738
740 break;
741 }
742
743 tmp_widget = tmp_widget->prev;
744
745 }
746
747 return count;
748}
749
750/**********************************************************************/
755{
757
758 while (tmp_widget) {
761
763 break;
764 }
765
766 tmp_widget = tmp_widget->prev;
767 }
768}
769
770/**********************************************************************/
774 const struct widget *end_group_widget_list,
776{
777 struct widget *tmp_widget = (struct widget *) end_group_widget_list;
778
779 while (tmp_widget) {
780
782 tmp_widget->size.y + Yrel);
783
785 && tmp_widget->private_data.adv_dlg
786 && tmp_widget->private_data.adv_dlg->scroll) {
787 tmp_widget->private_data.adv_dlg->scroll->max += Yrel;
788 tmp_widget->private_data.adv_dlg->scroll->min += Yrel;
789 }
790
792 && tmp_widget->private_data.adv_dlg
793 && tmp_widget->private_data.adv_dlg->scroll) {
794 tmp_widget->private_data.adv_dlg->scroll->max += Xrel;
795 tmp_widget->private_data.adv_dlg->scroll->min += Xrel;
796 }
797
799 break;
800 }
801
802 tmp_widget = tmp_widget->prev;
803 }
804}
805
806/**********************************************************************/
813{
815 struct gui_layer *gui_layer = get_gui_layer(end_group_widget_list->dst->surface);
816
817 /* Widget Pointer Management */
818 while (tmp_widget) {
819
820 prev = tmp_widget->prev;
821
822 /* tmp_widget->prev always exists because we
823 don't do this to begin_main_widget_list */
824 if (tmp_widget->next) {
825 tmp_widget->prev->next = tmp_widget->next;
826 tmp_widget->next->prev = tmp_widget->prev;
827 } else {
828 tmp_widget->prev->next = NULL;
829 }
830
831 tmp_widget->next = begin_main_widget_list;
832 begin_main_widget_list->prev = tmp_widget;
833 begin_main_widget_list = tmp_widget;
835
836 if (tmp_widget == begin_group_widget_list) {
837 break;
838 }
839
840 tmp_widget = prev;
841 }
842
843 /* Window Buffer Management */
844 if (gui_layer) {
845 int i = 0;
846
847 while ((i < main_data.guis_count - 1) && main_data.guis[i]) {
848 if (main_data.guis[i] && main_data.guis[i + 1]
849 && (main_data.guis[i] == gui_layer)) {
850 main_data.guis[i] = main_data.guis[i + 1];
851 main_data.guis[i + 1] = gui_layer;
852 }
853 i++;
854 }
855 }
856}
857
858/**********************************************************************/
862void del_group_of_widgets_from_gui_list(struct widget *begin_group_widget_list,
863 struct widget *end_group_widget_list)
864{
866
868 return;
869 }
870
873 return;
874 }
875
876 tmp_widget = tmp_widget->prev;
877
878 while (tmp_widget) {
879 struct widget *buf_widget = NULL;
880
881 buf_widget = tmp_widget->next;
883
886 break;
887 }
888
889 tmp_widget = tmp_widget->prev;
890 }
891
892}
893
894/**********************************************************************/
898 struct widget *end_group_widget_list, enum widget_state state)
899{
901
902 while (tmp_widget) {
903 set_wstate(tmp_widget, state);
905 break;
906 }
907 tmp_widget = tmp_widget->prev;
908 }
909}
910
911/**********************************************************************/
916{
918
919 while (tmp_widget) {
921
923 break;
924 }
925
926 tmp_widget = tmp_widget->prev;
927 }
928}
929
930/**********************************************************************/
935{
937
938 while (tmp_widget) {
940
942 break;
943 }
944
945 tmp_widget = tmp_widget->prev;
946 }
947}
948
949/**********************************************************************/
955{
956 struct widget *pwidget = end_group_widget_list;
957
958 while (pwidget) {
959 widget_set_area(pwidget, area);
960
961 if (pwidget == begin_group_widget_list) {
962 break;
963 }
964
965 pwidget = pwidget->prev;
966 }
967}
968
969/* ===================================================================== *
970 * =========================== Window Group ============================ *
971 * ===================================================================== */
972
973/*
974 * Window Group - group with 'begin' and 'end' where
975 * windowed type widget is last on list ( 'end' ).
976 */
977
978/**********************************************************************/
992
993/**********************************************************************/
997bool select_window_group_dialog(struct widget *begin_widget_list,
998 struct widget *pwindow)
999{
1000 if (!is_this_widget_first_on_list(begin_widget_list)) {
1001 move_group_to_front_of_gui_list(begin_widget_list, pwindow);
1002
1003 return TRUE;
1004 }
1005
1006 return FALSE;
1007}
1008
1009/**********************************************************************/
1017{
1018 bool ret = FALSE;
1019 Sint16 old_x = end_group_widget_list->size.x, old_y = end_group_widget_list->size.y;
1020
1024 end_group_widget_list->size.x - old_x,
1025 end_group_widget_list->size.y - old_y);
1026 ret = TRUE;
1027 }
1028
1029 return ret;
1030}
1031
1032/**********************************************************************/
1038void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
1039{
1040 if (select_window_group_dialog(begin_widget_list, pwindow)) {
1041 widget_flush(pwindow);
1042 }
1043
1044 move_window_group_dialog(begin_widget_list, pwindow);
1045}
1046
1047/**********************************************************************/
1051 Sint16 start_x, Sint16 start_y,
1052 Uint16 w, Uint16 h,
1053 struct widget *begin, struct widget *end)
1054{
1055 struct widget *buf = end;
1056 register int count = 0;
1057 register int real_start_x = start_x;
1058 int ret = 0;
1059
1060 while (buf) {
1061 buf->size.x = real_start_x;
1062 buf->size.y = start_y;
1063
1064 if (w) {
1065 buf->size.w = w;
1066 }
1067
1068 if (h) {
1069 buf->size.h = h;
1070 }
1071
1072 if (((count + 1) % step) == 0) {
1073 real_start_x = start_x;
1074 start_y += buf->size.h;
1075 if (!(get_wflags(buf) & WF_HIDDEN)) {
1076 ret += buf->size.h;
1077 }
1078 } else {
1079 real_start_x += buf->size.w;
1080 }
1081
1082 if (buf == begin) {
1083 break;
1084 }
1085 count++;
1086 buf = buf->prev;
1087 }
1088
1089 return ret;
1090}
1091
1092/* =================================================== */
1093/* ======================= WINDOWs ==================== */
1094/* =================================================== */
1095
1096/**************************************************************************
1097 Window Manager Mechanism.
1098 Idea is simple each window/dialog has own buffer layer which is draw
1099 on screen during flush operations.
1100 This consume lots of memory but is extremly effecive.
1101
1102 Each widget has own "destination" parm == where ( on what buffer )
1103 will be draw.
1104**************************************************************************/
1105
1106/* =================================================== */
1107/* ======================== MISC ===================== */
1108/* =================================================== */
1109
1110/**********************************************************************/
1114 Uint16 w, Uint16 h)
1115{
1117 resize_surface(current_theme->fr_left, current_theme->fr_left->w, h, 1);
1119 resize_surface(current_theme->fr_right, current_theme->fr_right->w, h, 1);
1121 resize_surface(current_theme->fr_top, w, current_theme->fr_top->h, 1);
1123 resize_surface(current_theme->fr_bottom, w, current_theme->fr_bottom->h, 1);
1124 SDL_Rect tmp,dst = {start_x, start_y, 0, 0};
1125
1126 tmp = dst;
1127 alphablit(tmp_left, NULL, pdest, &tmp, 255);
1128
1129 dst.x += w - tmp_right->w;
1130 tmp = dst;
1131 alphablit(tmp_right, NULL, pdest, &tmp, 255);
1132
1133 dst.x = start_x;
1134 tmp = dst;
1135 alphablit(tmp_top, NULL, pdest, &tmp, 255);
1136
1137 dst.y += h - tmp_bottom->h;
1138 tmp = dst;
1139 alphablit(tmp_bottom, NULL, pdest, &tmp, 255);
1140
1145}
1146
1147/**********************************************************************/
1151{
1152 if (pwidget) {
1153 if (pwidget->gfx && pwidget->gfx->w == pwidget->size.w
1154 && pwidget->gfx->h == pwidget->size.h) {
1155 clear_surface(pwidget->gfx, NULL);
1156 alphablit(pwidget->dst->surface, &pwidget->size, pwidget->gfx, NULL, 255);
1157 } else {
1158 FREESURFACE(pwidget->gfx);
1159 pwidget->gfx = crop_rect_from_surface(pwidget->dst->surface, &pwidget->size);
1160 }
1161 }
1162}
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
int int id
Definition editgui_g.h:28
QString current_theme
Definition fc_client.cpp:65
void flush_dirty(void)
Definition mapview.c:450
SDL_Color * get_theme_color(enum theme_color themecolor)
Definition colors.c:44
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1236
bool is_in_rect_area(int x, int y, SDL_Rect rect)
Definition graphics.c:925
int main_window_width(void)
Definition graphics.c:685
void update_main_screen(void)
Definition graphics.c:669
void remove_gui_layer(struct gui_layer *gui_layer)
Definition graphics.c:148
SDL_Surface * create_filled_surface(Uint16 w, Uint16 h, Uint32 flags, SDL_Color *pcolor)
Definition graphics.c:368
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
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 * get_gui_layer(SDL_Surface *surface)
Definition graphics.c:90
int screen_blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:223
struct sdl2_data main_data
Definition graphics.c:57
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:400
bool correct_rect_region(SDL_Rect *prect)
Definition graphics.c:888
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1347
#define FREESURFACE(ptr)
Definition graphics.h:322
#define adj_size(size)
Definition gui_main.h:138
#define PRESSED_EVENT(event)
Definition gui_main.h:68
void flush_rect(SDL_Rect *rect, bool force_flush)
Definition mapview.c:103
void dirty_sdl_rect(SDL_Rect *Rect)
Definition mapview.c:181
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
Definition gui_string.c:425
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
static mpgui * gui
Definition mpgui_qt.cpp:52
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54
int step
Definition specpq.h:92
Definition colors.h:20
SDL_Surface * surface
Definition graphics.h:229
SDL_Rect dest_rect
Definition graphics.h:228
int guis_count
Definition graphics.h:207
SDL_Event event
Definition graphics.h:217
struct gui_layer ** guis
Definition graphics.h:216
SDL_Window * screen
Definition graphics.h:209
Uint8 style
Definition gui_string.h:53
SDL_Color fgcol
Definition gui_string.h:57
struct widget * next
Definition widget.h:113
void(* unselect)(struct widget *pwidget)
Definition widget.h:168
utf8_str * info_label
Definition widget.h:122
SDL_Keycode key
Definition widget.h:153
void(* select)(struct widget *pwidget)
Definition widget.h:167
struct gui_layer * dst
Definition widget.h:116
SDL_Surface * gfx
Definition widget.h:120
struct widget * prev
Definition widget.h:114
int(* action)(struct widget *)
Definition widget.h:157
struct container * cont
Definition widget.h:127
Uint16 mod
Definition widget.h:154
SDL_Rect area
Definition widget.h:149
Uint16 id
Definition widget.h:155
SDL_Rect size
Definition widget.h:145
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
@ COLOR_THEME_QUICK_INFO_TEXT
Definition themecolors.h:35
@ COLOR_THEME_QUICK_INFO_BG
Definition themecolors.h:33
@ COLOR_THEME_QUICK_INFO_FRAME
Definition themecolors.h:34
static struct widget * begin_main_widget_list
Definition widget.c:55
struct widget * find_next_widget_for_key(struct widget *start_widget, SDL_Keysym key)
Definition widget.c:251
void del_widget_pointer_from_gui_list(struct widget *gui)
Definition widget.c:621
void set_new_group_start_pos(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, Sint16 Xrel, Sint16 Yrel)
Definition widget.c:773
void redraw_widget_info_label(SDL_Rect *rect)
Definition widget.c:466
Uint16 widget_pressed_action(struct widget *pwidget)
Definition widget.c:295
void set_group_state(struct widget *begin_group_widget_list, struct widget *end_group_widget_list, enum widget_state state)
Definition widget.c:897
void move_group_to_front_of_gui_list(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:811
void correct_size_bcgnd_surf(SDL_Surface *ptheme, int *width, int *height)
Definition widget.c:63
static SDL_Surface * info_label
Definition widget.c:57
void add_to_gui_list(Uint16 id, struct widget *gui)
Definition widget.c:585
void widget_selected_action(struct widget *pwidget)
Definition widget.c:442
struct widget * get_widget_pointer_from_main_list(Uint16 id)
Definition widget.c:577
void del_group_of_widgets_from_gui_list(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:862
bool move_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:1015
struct widget * find_next_widget_at_pos(struct widget *start_widget, int x, int y)
Definition widget.c:222
struct widget * selected_widget
Definition widget.c:48
void refresh_widget_background(struct widget *pwidget)
Definition widget.c:1150
void del_gui_list(struct widget *gui_list)
Definition widget.c:698
Uint32 widget_info_counter
Definition gui_main.c:99
void draw_frame(SDL_Surface *pdest, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h)
Definition widget.c:1113
SDL_Rect * info_area
Definition widget.c:49
void show_group(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:933
void unselect_widget_action(void)
Definition widget.c:417
void hide_group(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:914
bool is_this_widget_first_on_list(struct widget *gui)
Definition widget.c:656
struct widget * get_widget_pointer_from_id(const struct widget *gui_list, Uint16 id, enum scan_direction direction)
Definition widget.c:551
void widget_add_as_prev(struct widget *new_widget, struct widget *add_dock)
Definition widget.c:601
void undraw_group(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:753
void del_main_list(void)
Definition widget.c:690
SDL_Surface * create_bcgnd_surf(SDL_Surface *ptheme, enum widget_state state, Uint16 width, Uint16 height)
Definition widget.c:78
bool select_window_group_dialog(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:997
void group_set_area(struct widget *begin_group_widget_list, struct widget *end_group_widget_list, SDL_Rect area)
Definition widget.c:952
int setup_vertical_widgets_position(int step, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h, struct widget *begin, struct widget *end)
Definition widget.c:1050
void move_widget_to_front_of_gui_list(struct widget *gui)
Definition widget.c:666
Uint16 redraw_group(const struct widget *begin_group_widget_list, const struct widget *end_group_widget_list, int add_to_update)
Definition widget.c:719
void popdown_window_group_dialog(struct widget *begin_group_widget_list, struct widget *end_group_widget_list)
Definition widget.c:982
void move_window_group(struct widget *begin_widget_list, struct widget *pwindow)
Definition widget.c:1038
static void widget_set_position(struct widget *pwidget, int x, int y)
Definition widget.h:266
widget_state
Definition widget.h:95
@ FC_WS_DISABLED
Definition widget.h:99
@ FC_WS_NORMAL
Definition widget.h:96
@ FC_WS_PRESSED
Definition widget.h:98
@ FC_WS_SELECTED
Definition widget.h:97
void clear_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:62
scan_direction
Definition widget.h:190
@ SCAN_FORWARD
Definition widget.h:191
static void widget_mark_dirty(struct widget *pwidget)
Definition widget.h:286
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
#define FREEWIDGET(pwidget)
Definition widget.h:305
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
static void widget_undraw(struct widget *pwidget)
Definition widget.h:296
@ WF_EDIT_LOOP
Definition widget.h:91
@ WF_WIDGET_HAS_INFO_LABEL
Definition widget.h:88
@ WF_HIDDEN
Definition widget.h:68
static int widget_redraw(struct widget *pwidget)
Definition widget.h:276
#define del_widget_from_gui_list(__gui)
Definition widget.h:372
static void widget_set_area(struct widget *pwidget, SDL_Rect area)
Definition widget.h:261
enum widget_type get_wtype(const struct widget *pwidget)
Definition widget_core.c:78
void set_wflag(struct widget *pwidget, enum widget_flag flag)
Definition widget_core.c:54
#define del_group(begin_group_widget_list, end_group_widget_list)
Definition widget.h:389
@ WT_TI_BUTTON
Definition widget.h:46
@ WT_VSCROLLBAR
Definition widget.h:50
@ WT_EDIT
Definition widget.h:48
@ WT_HSCROLLBAR
Definition widget.h:51
@ WT_TCHECKBOX
Definition widget.h:59
@ WT_COMBO
Definition widget.h:62
@ WT_CHECKBOX
Definition widget.h:58
@ WT_I_BUTTON
Definition widget.h:44
@ WT_ICON2
Definition widget.h:60
@ WT_ICON
Definition widget.h:49
void toggle_checkbox(struct widget *cbox)
void combo_popup(struct widget *combo)
void combo_popdown(struct widget *combo)
enum edit_return_codes edit_field(struct widget *edit_widget)
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
bool move_window(struct widget *pwindow)