Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl3/gui_string.h File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
gui_string.h File Reference
`#include <SDL3/SDL.h>`
`#include <SDL3_ttf/SDL_ttf.h>`
`#include "fc_types.h"`
`#include "gui_main.h"`

Go to the source code of this file.

## Data Structures

struct | utf8_str

## Macros

#define | SF_CENTER 0x10
#define | SF_CENTER_RIGHT 0x20
#define | FREEUTF8STR(pstr)
#define | create_utf8_from_char(string_in, ptsize)
#define | create_utf8_from_char_fonto(string_in, fonto)

## Typedefs

typedef struct utf8_str | utf8_str

## Enumerations

enum | font_origin { FONTO_DEFAULT , FONTO_DEFAULT_PLUS , FONTO_ATTENTION , FONTO_ATTENTION_PLUS , FONTO_HEADING , FONTO_BIG , FONTO_MAX }

## Functions

utf8_str * | create_utf8_str_fonto (char *in_text, size_t n_alloc, enum font_origin origin)
utf8_str * | create_utf8_str (char *in_text, size_t n_alloc, Uint16 ptsize)
utf8_str * | copy_chars_to_utf8_str (utf8_str *pstr, const char *pchars)
bool | convert_utf8_str_to_const_surface_width (utf8_str *pstr, int width)
int | write_utf8 (SDL_Surface *dest, Sint16 x, Sint16 y, utf8_str *pstr)
SDL_Surface * | create_text_surf_from_utf8 (utf8_str *pstr)
SDL_Surface * | create_text_surf_smaller_than_w (utf8_str *pstr, int w)
void | utf8_str_size (utf8_str *pstr, SDL_Rect *fill)
void | change_ptsize_utf8 (utf8_str *pstr, Uint16 new_ptsize)
void | change_fonto_utf8 (utf8_str *pstr, enum font_origin origin)
void | unload_font (Uint16 ptsize)
void | free_font_system (void)

## Macro Definition Documentation

## ◆ create_utf8_from_char

#define create_utf8_from_char | ( |  | string_in,
|  |  | ptsize
| ) |  |

Value:
(string_in) == NULL ? \
create_utf8_str(NULL, 0, ptsize) : \
copy_chars_to_utf8_str(create_utf8_str(NULL, 0, ptsize), string_in)
incite_cost
char * incite_cost
Definition comments.c:74
create_utf8_str
utf8_str * create_utf8_str(char *in_text, size_t n_alloc, Uint16 ptsize)
Definition gui_string.c:206

Definition at line 98 of file gui_string.h.

## ◆ create_utf8_from_char_fonto

#define create_utf8_from_char_fonto | ( |  | string_in,
|  |  | fonto
| ) |  |

Value:
(string_in) == NULL ? \
create_utf8_str_fonto(NULL, 0, fonto) : \
copy_chars_to_utf8_str(create_utf8_str_fonto(NULL, 0, fonto), string_in)
create_utf8_str_fonto
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
Definition gui_string.c:241

Definition at line 103 of file gui_string.h.

## ◆ FREEUTF8STR

#define FREEUTF8STR | ( |  | pstr | ) |

Value:
do { \
if (pstr != NULL) { \
FC_FREE(pstr->text); \
unload_font(pstr->ptsize); \
free(pstr); \
pstr = NULL; \
} \
} while (FALSE)
FALSE
#define FALSE
Definition support.h:47

Definition at line 88 of file gui_string.h.

## ◆ SF_CENTER

#define SF_CENTER 0x10

Definition at line 35 of file gui_string.h.

## ◆ SF_CENTER_RIGHT

#define SF_CENTER_RIGHT 0x20

Definition at line 36 of file gui_string.h.

## Typedef Documentation

## ◆ utf8_str

typedef struct utf8_str utf8_str

## Enumeration Type Documentation

## ◆ font_origin

enum font_origin

Enumerator
FONTO_DEFAULT |
FONTO_DEFAULT_PLUS |
FONTO_ATTENTION |
FONTO_ATTENTION_PLUS |
FONTO_HEADING |
FONTO_BIG |
FONTO_MAX |

Definition at line 59 of file gui_string.h.

## Function Documentation

## ◆ change_fonto_utf8()

void change_fonto_utf8 | ( | utf8_str * | pstr,
|  | enum font_origin | origin
| ) |  |

Change font size of text to that from given origin.

Definition at line 584 of file gui_string.c.

Referenced by popup_notify_dialog(), popup_races_dialog(), redraw_info_city_dialog(), redraw_tech_info_dlg(), redraw_unit_info_label(), and update_intel_dialog().

## ◆ change_ptsize_utf8()

void change_ptsize_utf8 | ( | utf8_str * | pstr,
|  | Uint16 | new_ptsize
| ) |  |

Change font size of text.

Definition at line 559 of file gui_string.c.

Referenced by change_fonto_utf8(), convert_utf8_str_to_const_surface_width(), and create_text_surf_smaller_than_w().

## ◆ convert_utf8_str_to_const_surface_width()

bool convert_utf8_str_to_const_surface_width | ( | utf8_str * | pstr,
|  | int | width
| ) |  |

Wrap text to make it fit to given screen width.

Definition at line 449 of file gui_string.c.

Referenced by add_to_chat_list(), create_tech_info(), create_text_surf_smaller_than_w(), popup_impr_info(), popup_unit_info(), and real_meswin_dialog_update().

## ◆ copy_chars_to_utf8_str()

utf8_str * copy_chars_to_utf8_str | ( | utf8_str * | pstr,
|  | const char * | pchars
| ) |  |

Convert char array to utf8_str. Pointer to target string is needed as parameter, but also returned for convenience.

Definition at line 251 of file gui_string.c.

Referenced by add_target_to_production(), canvas_put_text(), change_nation_label(), change_sex_callback(), combo_menu_item_callback(), convert_playername_callback(), convert_portnr_callback(), convert_servername_callback(), create_tech_tree(), economy_report_dialog_popup(), get_text_size(), gold_callback(), leader_name_edit_callback(), new_name_city_dlg_callback(), newcity_name_edit_callback(), next_name_callback(), notify_goto_dialog_update(), option_widget_update(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_city_cma_dialog(), popup_impr_info(), popup_notify_dialog(), popup_players_dialog(), popup_races_dialog(), popup_tech_info(), popup_unit_info(), popup_worklist_editor(), prev_name_callback(), real_activeunits_report_dialog_update(), real_city_report_dialog_update_city(), real_conn_list_dialog_update(), real_economy_report_dialog_update(), real_info_city_report_dialog_update(), real_menus_update(), real_players_dialog_update(), real_science_report_dialog_update(), real_units_report_dialog_update(), rebuild_citydlg_title_str(), redraw_city_dialog(), redraw_info_city_dialog(), redraw_tech_info_dlg(), redraw_unit_info_label(), refresh_city_names(), refresh_production_label(), refresh_spaceship_dialog(), refresh_worklist_count_label(), rename_worklist_editor_callback(), report_scroll_mouse_motion_handler(), scroll_mouse_motion_handler(), select_random_leader(), set_cma_hscrollbars(), set_indicator_icons(), setup_auxiliary_tech_icons(), spy_steal_popup_shared(), toggle_map_window_callback(), toggle_msg_window_callback(), toggle_unit_info_window_callback(), update_info_label(), update_intel_dialog(), and update_worklist_report_dialog().

## ◆ create_text_surf_from_utf8()

SDL_Surface * create_text_surf_from_utf8 | ( | utf8_str * | pstr | ) |

Generic function to create surface with any kind of text, single line or multiline, drawn.

Definition at line 425 of file gui_string.c.

Referenced by canvas_put_text(), combo_redraw(), create_text_surf_smaller_than_w(), economy_report_dialog_popup(), popup_city_cma_dialog(), popup_diplomacy_dialog(), popup_hurry_production_dialog(), popup_notify_dialog(), popup_players_dialog(), popup_sell_impr_callback(), popup_unit_disband_dlg(), popup_unit_upgrade_dlg(), popup_upgrade_unit_callback(), popup_war_dialog(), popup_worklist_editor(), real_activeunits_report_dialog_update(), real_info_city_report_dialog_update(), real_science_report_dialog_update(), redraw_army_city_dialog(), redraw_city_dialog(), redraw_edit(), redraw_happiness_city_dialog(), redraw_ibutton(), redraw_iconlabel(), redraw_info_city_dialog(), redraw_misc_city_dialog(), redraw_supported_units_city_dialog(), redraw_tech_info_dlg(), redraw_unit_info_label(), redraw_widget_info_label(), redraw_window(), save_cma_callback(), setup_auxiliary_tech_icons(), update_city_cma_dialog(), update_info_label(), update_intel_dialog(), and write_utf8().

## ◆ create_text_surf_smaller_than_w()

SDL_Surface * create_text_surf_smaller_than_w | ( | utf8_str * | pstr,
|  | int | w
| ) |  |

Create surface with text drawn to it. Wrap text as needed to make it fit in given width.

Definition at line 539 of file gui_string.c.

Referenced by create_select_tech_icon(), economy_report_dialog_popup(), nation_button_callback(), popup_impr_info(), popup_races_dialog(), popup_unit_info(), popup_worklist_editor(), and redraw_unit_info_label().

## ◆ create_utf8_str()

utf8_str * create_utf8_str | ( | char * | in_text,
|  | size_t | n_alloc,
|  | Uint16 | ptsize
| ) |  |

Create utf8_str struct with ptsize font. If ptsize is zero, use theme's default font size.

Font will be loaded or aliased with existing font of that size. in_text must be allocated in memory (fc_malloc() / fc_calloc())

Definition at line 206 of file gui_string.c.

Referenced by canvas_put_text(), create_utf8_str_fonto(), get_text_size(), and real_meswin_dialog_update().

## ◆ create_utf8_str_fonto()

utf8_str * create_utf8_str_fonto | ( | char * | in_text,
|  | size_t | n_alloc,
|  | enum font_origin | origin
| ) |  |

Create utf8_str struct with font size from given origin.

Font will be loaded or aliased with existing font of that size. in_text must be allocated in memory (fc_malloc() / fc_calloc())

Definition at line 241 of file gui_string.c.

Referenced by add_to_chat_list(), create_tech_tree(), economy_report_dialog_popup(), popup_change_research_dialog(), popup_change_research_goal_dialog(), popup_city_cma_dialog(), popup_impr_info(), popup_new_user_passwd_dialog(), popup_players_dialog(), popup_races_dialog(), popup_tech_info(), popup_unit_info(), popup_user_passwd_dialog(), popup_worklist_editor(), real_city_dialog_popup(), real_conn_list_dialog_update(), spy_steal_popup_shared(), and update_info_label().

## ◆ free_font_system()

void free_font_system | ( | void |  | ) |

Free all fonts.

Definition at line 698 of file gui_string.c.

Referenced by ui_main().

## ◆ unload_font()

void unload_font | ( | Uint16 | ptsize | ) |

Free font of given pointsize.

Definition at line 653 of file gui_string.c.

Referenced by change_ptsize_utf8().

## ◆ utf8_str_size()

void utf8_str_size | ( | utf8_str * | pstr,
|  | SDL_Rect * | fill
| ) |  |

Adjust font sizes for small screen. Calculate display size of string.

Definition at line 106 of file gui_string.c.

Referenced by combo_new(), convert_utf8_str_to_const_surface_width(), create_edit(), create_icon_button(), create_window_skeleton(), get_text_size(), meswin_dialog_popup(), and remake_label_size().

## ◆ write_utf8()

int write_utf8 | ( | SDL_Surface * | dest,
|  | Sint16 | x,
|  | Sint16 | y,
|  | utf8_str * | pstr
| ) |  |

Blit text to surface.

Definition at line 276 of file gui_string.c.