Hexmap Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up |
#include <hexmap.h> struct HexGrid; struct HexGridClass; HexGrid* hex_grid_new (HexData *background_hex, HexColor *grid_line_color, guint width, guint height); void hex_grid_set_size (HexGrid *grid, guint width, guint height); void hex_grid_get_size (HexGrid *grid, guint *width, guint *height); void hex_grid_set_grid_line_color (HexGrid *grid, HexColor *color); gboolean hex_grid_get_grid_line_color (HexGrid *grid, HexColor *color); void hex_grid_set_background_hex (HexGrid *grid, HexData *background_hex); HexData* hex_grid_get_background_hex (HexGrid *grid); guint hex_grid_get_hex_width (HexGrid *grid); void hex_grid_set_tile (HexGrid *grid, gint x, gint y, gint depth, HexTile *tile); HexTile* hex_grid_get_tile (HexGrid *grid, gint x, gint y, gint depth); void hex_grid_clear_list (HexGrid *grid, gint x, gint y); HexList* hex_grid_get_list (HexGrid *grid, gint x, gint y); gboolean hex_grid_foreach_type_topdown (HexGrid *grid, gint x, gint y, GType type, HexEachFunc func, gboolean halt_on, gpointer data); gboolean (*HexEachFunc) (HexTile *tile, gint depth, gpointer data); gpointer hex_grid_get_backend_drawable (HexGrid *grid, HexGridCacheData *disp_info, gint x, gint y, gboolean (*equal_func) (HexGridCacheData*, HexGridCacheData*), HexGridCacheData* (*copy_func) (HexColor*, HexGridCacheData*, GDestroyNotify*), gpointer (*create_func) (HexList*, HexData*, HexColor*, gint,HexGridCacheData*, GDestroyNotify*)); struct HexGridCacheData; |
"background-hex" HexData : Read / Write "grid-height" guint : Read / Write "grid-line-color" gpointer : Write "grid-width" guint : Read / Write |
"hex-changed" void user_function (HexGrid *hexgrid, gint arg1, gint arg2, gpointer user_data); |
A HexGrid is essentially a hexagonal map. Since it is separate from HexDisplay, the map in a particular display widget can be swapped out easily. A HexGrid also performs internal caching of images through the function hex_grid_get_pixmap(), speeding up the drawing routine in HexDisplay.
HexGrid* hex_grid_new (HexData *background_hex, HexColor *grid_line_color, guint width, guint height); |
Creates a new HexGrid.
the HexData to be used as the background of each hex
the color to use when drawing the grid lines. Passing NULL will cause no grid lines to be drawn.
the width of the grid in hexes
the height of the grid in hexes
a newly created HexGrid
void hex_grid_set_size (HexGrid *grid, guint width, guint height); |
Sets the size of the grid.
a HexGrid
the new width of the grid in hexes
the new height of the grid in hexes
void hex_grid_get_size (HexGrid *grid, guint *width, guint *height); |
Gets the size of the grid.
a HexGrid
a location to return the width of the grid in hexes
a location to return the height of the grid in hexes
void hex_grid_set_grid_line_color (HexGrid *grid, HexColor *color); |
Sets the grid line color.
a HexGrid
the new color to use when drawing the grid lines. Passing NULL will cause no grid lines to be drawn.
gboolean hex_grid_get_grid_line_color (HexGrid *grid, HexColor *color); |
Gets the grid line color for a HexGrid.
a HexGrid
a location to return the color to use when drawing the grid lines
TRUE if grid lines are drawn, FALSE if not. color is only set in the TRUE case
void hex_grid_set_background_hex (HexGrid *grid, HexData *background_hex); |
Sets the background hex.
a HexGrid
the HexData to be used as the new background of each hex. The width of this HexData must be the same as that of the old background hex
HexData* hex_grid_get_background_hex (HexGrid *grid); |
Gets the background_hex.
a HexGrid
the HexData to be used as the background of each hex
guint hex_grid_get_hex_width (HexGrid *grid); |
Gets the width of the background hex.
a HexGrid
the width of the background hex in the grid
void hex_grid_set_tile (HexGrid *grid, gint x, gint y, gint depth, HexTile *tile); |
Sets a tile. This function should not be used for HexWalker and types derived from it, which use hex_walker_connect_grid() instead.
a HexGrid
the x position of the tile
the y position of the tile
the depth of the tile
the new HexTile. The width of the tile must match the width of the background hex in the grid. Passing NULL will clear a previous tile in this location
HexTile* hex_grid_get_tile (HexGrid *grid, gint x, gint y, gint depth); |
Gets a tile from the grid.
a HexGrid
the x position of a hex
the y position of a hex
the depth of a tile
the HexTile at (x, y) with depth depth. If there is no such tile, returns NULL.
void hex_grid_clear_list (HexGrid *grid, gint x, gint y); |
Removes tiles of all depths at a given (x, y) location.
a HexGrid
the x location of the list
the y location of the list
HexList* hex_grid_get_list (HexGrid *grid, gint x, gint y); |
Gets a list of tiles from the grid.
a HexGrid
the x position of a hex
the y position of a hex
a HexList containing all the HexTile at (x, y). A return value of NULL indicates an empty list, or a hex outside the range of the grid.
gboolean hex_grid_foreach_type_topdown (HexGrid *grid, gint x, gint y, GType type, HexEachFunc func, gboolean halt_on, gpointer data); |
Calls the function func on each tile which g_type_is_a() type at the location (x, y) in the grid, starting with the highest depth and proceeding to the lowest. If any such function call returns the value matching halt_on, no further function calls are executed and halt_on is returned. Otherwise, !halt_on is returned.
a HexGrid
the x position of a hex
the y position of a hex
the GType of an object descended from HexTile
which return value stops further function calls
data passed to func
halt_on if any function call returns halt_on, otherwise !halt_on
gboolean (*HexEachFunc) (HexTile *tile, gint depth, gpointer data); |
A callback passed to hex_grid_foreach_type_topdown(), which determines what happens to each hex.
a HexTile
the depth the tile is stored at in the HexGrid
user data passed to hex_grid_foreach_type_topdown()
if the return value matches the halt_on parameter passed to hex_grid_foreach_type_topdown(), that function returns immediately and does not call the HexEachFunc on any more tiles.
gpointer hex_grid_get_backend_drawable (HexGrid *grid, HexGridCacheData *disp_info, gint x, gint y, gboolean (*equal_func) (HexGridCacheData*, HexGridCacheData*), HexGridCacheData* (*copy_func) (HexColor*, HexGridCacheData*, GDestroyNotify*), gpointer (*create_func) (HexList*, HexData*, HexColor*, gint,HexGridCacheData*, GDestroyNotify*)); |
This function is for use in writing backends to hexmap. Ordinary users should never use it.
A HexGrid
System dependent information about the object that is requesting the drawable.
The x coordinate of the hex
The y coordinate of the hex
A function to check if the system dependent information matches information already in the cache.
A function to copy the system independent information, for placement in the cache. The third argument of this function should return a pointer to a function to destroy the system dependent information when it is flushed from the cache. This is also a good time to calculate the system dependent form of the grid line color, as the cache is flushed whenever this color is changed.
A function to create a system dependent drawable. The final argument of this function should return a pointer to a function to destroy the drawable.
A drawable of the format returned by create_func.
The HexData used as the background (lowest layer) of the grid. It is recomended that this HexData have no fully or partially transparent pixels.
The height of the grid in hexes
The color of the grid lines. NULL indicates no grid lines.
the width of the grid in hexes
void user_function (HexGrid *hexgrid, gint arg1, gint arg2, gpointer user_data); |
The image for the hex at (arg1, arg2) has changed, and needs to be redrawn. This signal is primarily for the benefit of HexDisplay.
the object which received the signal.
the x coordinate of the hex
the y coordinate of the hex
user data set when the signal handler was connected.