Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-gtk-4.0/canvas.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Macros | Functions | Variables
canvas.c File Reference
`#include "colors.h"`
`#include "gui_main.h"`
`#include "mapview.h"`
`#include "canvas.h"`

Go to the source code of this file.

## Macros

#define | FONT(font) (*fonts[font].styles)

## Functions

struct canvas * | canvas_create (int width, int height)
void | canvas_free (struct canvas *store)
void | canvas_set_zoom (struct canvas *store, float zoom)
bool | has_zoom_support (void)
void | canvas_mapview_init (struct canvas *store)
void | canvas_copy (struct canvas *dest, struct canvas *src, int src_x, int src_y, int dest_x, int dest_y, int width, int height)
void | canvas_put_sprite (struct canvas *pcanvas, int canvas_x, int canvas_y, struct sprite *sprite, int offset_x, int offset_y, int width, int height)
void | canvas_put_sprite_full (struct canvas *pcanvas, int canvas_x, int canvas_y, struct sprite *sprite)
void | canvas_put_sprite_full_scaled (struct canvas *pcanvas, int canvas_x, int canvas_y, int canvas_w, int canvas_h, struct sprite *sprite)
void | canvas_put_sprite_fogged (struct canvas *pcanvas, int canvas_x, int canvas_y, struct sprite *psprite, bool fog, int fog_x, int fog_y)
void | canvas_put_rectangle (struct canvas *pcanvas, struct color *pcolor, int canvas_x, int canvas_y, int width, int height)
void | canvas_fill_sprite_area (struct canvas *pcanvas, struct sprite *psprite, struct color *pcolor, int canvas_x, int canvas_y)
void | canvas_put_line (struct canvas *pcanvas, struct color *pcolor, enum line_type ltype, int start_x, int start_y, int dx, int dy)
void | canvas_put_curved_line (struct canvas *pcanvas, struct color *pcolor, enum line_type ltype, int start_x, int start_y, int dx, int dy)
void | get_text_size (int *width, int *height, enum client_font font, const char *text)
void | canvas_put_text (struct canvas *pcanvas, int canvas_x, int canvas_y, enum client_font font, struct color *pcolor, const char *text)
void | surface_put_text (cairo_t *cr, int x, int y, float zoom, enum client_font font, struct color *pcolor, const char *text)

## Variables

static PangoLayout * | layout
struct { |
PangoFontDescription ** styles |
bool shadowed |
} | fonts [FONT_COUNT] |

## Macro Definition Documentation

## ◆ FONT

#define FONT | ( |  | font | ) | (*fonts[font].styles)

Definition at line 338 of file canvas.c.

## Function Documentation

## ◆ canvas_copy()

void canvas_copy | ( | struct canvas * | dest,
|  | struct canvas * | src,
|  | int | src_x,
|  | int | src_y,
|  | int | dest_x,
|  | int | dest_y,
|  | int | width,
|  | int | height
| ) |  |

Copies an area from the source canvas to the destination canvas.

Definition at line 76 of file canvas.c.

## ◆ canvas_create()

struct canvas * canvas_create | ( | int | width,
|  | int | height
| ) |  |

Create a canvas of the given size.

Definition at line 28 of file canvas.c.

## ◆ canvas_fill_sprite_area()

void canvas_fill_sprite_area | ( | struct canvas * | pcanvas,
|  | struct sprite * | psprite,
|  | struct color * | pcolor,
|  | int | canvas_x,
|  | int | canvas_y
| ) |  |

Fill the area covered by the sprite with the given color.

Definition at line 211 of file canvas.c.

## ◆ canvas_free()

void canvas_free | ( | struct canvas * | store | ) |

Free any resources associated with this canvas and the canvas struct itself.

Definition at line 44 of file canvas.c.

## ◆ canvas_mapview_init()

void canvas_mapview_init | ( | struct canvas * | store | ) |

Initialize canvas as mapview.

Definition at line 69 of file canvas.c.

## ◆ canvas_put_curved_line()

void canvas_put_curved_line | ( | struct canvas * | pcanvas,
|  | struct color * | pcolor,
|  | enum line_type | ltype,
|  | int | start_x,
|  | int | start_y,
|  | int | dx,
|  | int | dy
| ) |  |

Draw a colored curved line for the Technology Tree connectors A curved line is: 1 horizontal line, 2 arcs, 1 horizontal line

Definition at line 276 of file canvas.c.

## ◆ canvas_put_line()

void canvas_put_line | ( | struct canvas * | pcanvas,
|  | struct color * | pcolor,
|  | enum line_type | ltype,
|  | int | start_x,
|  | int | start_y,
|  | int | dx,
|  | int | dy
| ) |  |

Draw a colored line onto the mapview or citydialog canvas. XXX: unlike other canvas_put functions, supplied x/y are not prior to any canvas zoom.

Definition at line 225 of file canvas.c.

## ◆ canvas_put_rectangle()

void canvas_put_rectangle | ( | struct canvas * | pcanvas,
|  | struct color * | pcolor,
|  | int | canvas_x,
|  | int | canvas_y,
|  | int | width,
|  | int | height
| ) |  |

Draw a filled-in colored rectangle onto the mapview or citydialog canvas. Supplied coordinates are prior to any canvas zoom.

Definition at line 183 of file canvas.c.

## ◆ canvas_put_sprite()

void canvas_put_sprite | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | struct sprite * | sprite,
|  | int | offset_x,
|  | int | offset_y,
|  | int | width,
|  | int | height
| ) |  |

Draw some or all of a sprite onto the mapview or citydialog canvas. Supplied coordinates are prior to any canvas zoom.

Definition at line 109 of file canvas.c.

## ◆ canvas_put_sprite_fogged()

void canvas_put_sprite_fogged | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | struct sprite * | psprite,
|  | bool | fog,
|  | int | fog_x,
|  | int | fog_y
| ) |  |

Draw a full sprite onto the canvas. If "fog" is specified draw it with fog.

Definition at line 170 of file canvas.c.

## ◆ canvas_put_sprite_full()

void canvas_put_sprite_full | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | struct sprite * | sprite
| ) |  |

Draw a full sprite onto the mapview or citydialog canvas. Supplied canvas_x/y are prior to any canvas zoom.

Definition at line 144 of file canvas.c.

## ◆ canvas_put_sprite_full_scaled()

void canvas_put_sprite_full_scaled | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | int | canvas_w,
|  | int | canvas_h,
|  | struct sprite * | sprite
| ) |  |

Draw a full sprite onto the canvas, scaled to the canvas size.

Definition at line 157 of file canvas.c.

## ◆ canvas_put_text()

void canvas_put_text | ( | struct canvas * | pcanvas,
|  | int | canvas_x,
|  | int | canvas_y,
|  | enum client_font | font,
|  | struct color * | pcolor,
|  | const char * | text
| ) |  |

Draw the text onto the canvas in the given color and font. The canvas position does not account for the ascent of the text; this function must take care of this manually. The text will not be NULL but may be empty. Supplied canvas_x/y are prior to any canvas zoom.

Definition at line 372 of file canvas.c.

## ◆ canvas_set_zoom()

void canvas_set_zoom | ( | struct canvas * | store,
|  | float | zoom
| ) |  |

Set canvas zoom for future drawing operations.

Definition at line 53 of file canvas.c.

## ◆ get_text_size()

void get_text_size | ( | int * | width,
|  | int * | height,
|  | enum client_font | font,
|  | const char * | text
| ) |  |

Return the size of the given text in the given font. This size should include the ascent and descent of the text. Either of width or height may be NULL in which case those values simply shouldn't be filled out.

Definition at line 345 of file canvas.c.

## ◆ has_zoom_support()

bool has_zoom_support | ( | void |  | ) |

This gui has zoom support.

Definition at line 61 of file canvas.c.

## ◆ surface_put_text()

void surface_put_text | ( | cairo_t * | cr,
|  | int | x,
|  | int | y,
|  | float | zoom,
|  | enum client_font | font,
|  | struct color * | pcolor,
|  | const char * | text
| ) |  |

Draw the text onto the surface in the given color and font. The position does not account for the ascent of the text; this function must take care of this manually. The text may not be NULL but may be empty.

Definition at line 400 of file canvas.c.

## Variable Documentation

## ◆ [struct]

struct { ... } fonts[FONT_COUNT]

Initial value:
= {
{&city_names_style, TRUE},
{&city_productions_style, TRUE},
{&reqtree_text_style, FALSE}
}
city_productions_style
PangoFontDescription * city_productions_style
Definition gui_main.c:134
city_names_style
PangoFontDescription * city_names_style
Definition gui_main.c:133
reqtree_text_style
PangoFontDescription * reqtree_text_style
Definition gui_main.c:135
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47

## ◆ layout

PangoLayout* layout

static

Definition at line 329 of file canvas.c.

## ◆ shadowed

bool shadowed

Definition at line 332 of file canvas.c.

## ◆ styles

PangoFontDescription** styles

Definition at line 331 of file canvas.c.