HexDisplaySDL

Name

HexDisplaySDL -- A Display Widget for HexGrid

Synopsis




struct      HexDisplaySDL;
struct      HexDisplaySDLClass;


HexDisplaySDL* hex_display_sdl_new          (HexGrid *grid,
                                             SDL_Surface *surface,
                                             const SDL_Rect *rect);
void        hex_display_sdl_set_grid        (HexDisplaySDL *disp,
                                             HexGrid *grid);
HexGrid*    hex_display_sdl_get_grid        (HexDisplaySDL *disp);
void        hex_display_sdl_center_hex      (HexDisplaySDL *disp,
                                             guint x,
                                             guint y);
#define     HEX_DISPLAY_SDL_EVENT_MASK
gboolean    hex_display_sdl_handle_event    (SDL_Event *event);

Object Hierarchy


  GObject
   +----HexDisplaySDL

Signal Prototypes


"hex-event" gboolean    user_function      (HexDisplaySDL *hexdisplaysdl,
                                            gpointer arg1,
                                            gint arg2,
                                            gint arg3,
                                            gpointer user_data);

Description

A HexDisplaySDL holds a pointer to an SDL_Surface which displays a HexGrid. Since most of what it does is react to changes in HexGrid, once you've set the grid there's not much hexmap-specific functionallity.

Details

struct HexDisplaySDL

struct HexDisplaySDL;

A display object which shows some or all of a HexGrid


struct HexDisplaySDLClass

struct HexDisplaySDLClass;

The class structure of a HexDisplaySDL


hex_display_sdl_new ()

HexDisplaySDL* hex_display_sdl_new          (HexGrid *grid,
                                             SDL_Surface *surface,
                                             const SDL_Rect *rect);

create a HexDisplaySDL

grid :

the HexGrid to display. Can be NULL

surface :

the SDL_Surface to display grid on

rect :

the area in surface to use. rect will be clipped to fit surface. If rect is NULL, all of surface will be used.

Returns :

the newly created HexDisplaySDL


hex_display_sdl_set_grid ()

void        hex_display_sdl_set_grid        (HexDisplaySDL *disp,
                                             HexGrid *grid);

set which HexGrid to display

disp :

a HexDisplaySDL

grid :

the HexGrid to display. Can be NULL


hex_display_sdl_get_grid ()

HexGrid*    hex_display_sdl_get_grid        (HexDisplaySDL *disp);

get the currently displayed HexGrid

disp :

a HexDisplaySDL

Returns :

the currently displayed HexGrid. Returns NULL if there is no grid


hex_display_sdl_center_hex ()

void        hex_display_sdl_center_hex      (HexDisplaySDL *disp,
                                             guint x,
                                             guint y);

center the display on the hex (x, y)

disp :

a HexDisplaySDL

x :

the x coordinate of a hex

y :

the y coordinate of a hex


HEX_DISPLAY_SDL_EVENT_MASK

#define     HEX_DISPLAY_SDL_EVENT_MASK

A mask which indicates which SDL events should be processed by hex_display_sdl_handle_event().


hex_display_sdl_handle_event ()

gboolean    hex_display_sdl_handle_event    (SDL_Event *event);

Check if a mouse event happened inside any of the existing HexDisplaySDL instances, pass it to the HexObject handlers in the attached HexGrid if applicable.

Most ordinary users will not need to call this function, since it is called automatically by the polling structure set up by hex_sdl_init()/hex_sdl_run()/hex_sdl_quit().

event :

An SDL_Event.

Returns :

TRUE if the event was handled

Signals

The "hex-event" signal

gboolean    user_function                  (HexDisplaySDL *hexdisplaysdl,
                                            gpointer arg1,
                                            gint arg2,
                                            gint arg3,
                                            gpointer user_data);

An event has occured in the hex at (x, y). This function is called after HexObject::event is called for any HexObject in the hex.

hexdisplaysdl :

the object which received the signal.

arg1 :

an SDL_Event

arg2 :

the x coordinate of the hex

arg3 :

the y coordinate of the hex

user_data :

user data set when the signal handler was connected.

Returns :

TRUE to stop propagation of the event