naev 0.12.6
toolkit.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include "SDL_events.h"
9
10#include "tk/widget.h" // IWYU pragma: export
11
12int toolkit_isOpen( void );
13
14/*
15 * creation
16 */
17unsigned int window_create( const char *name, const char *displayname,
18 const int x, const int y, /* position */
19 const int w, const int h ); /* dimensions */
20unsigned int window_createFlags( const char *name, const char *displayname,
21 const int x, const int y, /* position */
22 const int w, const int h,
23 unsigned int flags ); /* dimensions */
24
25/*
26 * modification
27 */
28/* window */
29void window_setAccept( unsigned int wid,
30 void ( *fptr )( unsigned int, const char * ) );
31void window_setCancel( unsigned int wid,
32 void ( *cancel )( unsigned int, const char * ) );
33void window_setOnFocus( unsigned int wid, void ( *focus )( unsigned int ) );
34void window_setBorder( unsigned int wid, int enable );
35void window_setFocus( unsigned int wid, const char *wgtname );
36void window_handleKeys( unsigned int wid,
37 int ( *keyhandler )( unsigned int, SDL_Keycode,
38 SDL_Keymod, int ) );
39void window_handleEvents( unsigned int wid,
40 int ( *eventhandler )( unsigned int, SDL_Event * ) );
41void window_move( unsigned int wid, int x, int y );
42void window_resize( unsigned int wid, int w, int h );
43void window_raise( unsigned int wid );
44void window_lower( unsigned int wid );
45int window_setDisplayname( unsigned int wid, const char *displayname );
46void window_setDynamic( unsigned int wid, int dynamic );
47
48/*
49 * get
50 */
51/* generic */
52int window_exists( const char *wdwname );
53int window_existsID( unsigned int wid );
54int widget_exists( unsigned int wid, const char *wgtname );
55unsigned int window_get( const char *wdwname );
56void window_dimWindow( unsigned int wid, int *w, int *h );
57void window_posWindow( unsigned int wid, int *x, int *y );
58void window_dimWidget( unsigned int wid, const char *name, int *w, int *h );
59char *window_getFocus( unsigned int wid );
60void window_posWidget( unsigned int wid, const char *name, int *x, int *y );
61void window_moveWidget( unsigned int wid, const char *name, int x, int y );
62void window_resizeWidget( unsigned int wid, const char *name, int w, int h );
63void window_canFocusWidget( unsigned int wid, const char *name, int canfocus );
64int window_isTop( unsigned int wid );
65int widget_isCovered( unsigned int wid, const char *name, int x, int y );
66
67/*
68 * destruction
69 */
70void toolkit_closeAll( void );
71void window_close( unsigned int wid, const char *str );
72void window_destroy( unsigned int wid );
73void window_destroyWidget( unsigned int wid, const char *wgtname );
74void window_clearWidgets( unsigned int wid );
75void window_setParent( unsigned int wid, unsigned int parent );
76unsigned int window_getParent( unsigned int wid );
77void window_onClose( unsigned int wid,
78 void ( *fptr )( unsigned int, const char *) );
79
80/*
81 * data
82 */
83void window_setData( unsigned int wid, void *data );
84void *window_getData( unsigned int wid );
85
86/*
87 * render
88 */
89void toolkit_rerender( void );
90void toolkit_render( double dt );
91
92/*
93 * input
94 */
95int toolkit_input( SDL_Event *event );
96void toolkit_update( void );
97void toolkit_clearKey( void );
98
99/*
100 * init/exit
101 */
102int toolkit_init( void );
103void toolkit_exit( void );
104
105/*
106 * hacks
107 */
108void toolkit_resize( void );
109void toolkit_delay( void );
unsigned int window_createFlags(const char *name, const char *displayname, const int x, const int y, const int w, const int h, unsigned int flags)
Creates a window.
Definition toolkit.c:706
unsigned int window_create(const char *name, const char *displayname, const int x, const int y, const int w, const int h)
Creates a window.
Definition toolkit.c:688
void window_setOnFocus(unsigned int wid, void(*focus)(unsigned int))
Sets the focus function of the window.
Definition toolkit.c:889
void toolkit_resize(void)
Repositions windows and their children if resolution changes.
Definition toolkit.c:2612
void toolkit_update(void)
Updates the toolkit input for repeating keys.
Definition toolkit.c:2241
void window_dimWidget(unsigned int wid, const char *name, int *w, int *h)
Gets the dimensions of a widget.
Definition toolkit.c:415
void toolkit_exit(void)
Exits the toolkit.
Definition toolkit.c:2682
void window_setDynamic(unsigned int wid, int dynamic)
Sets a window as dynamic, so that it is drawn every frame completely.
Definition toolkit.c:643
unsigned int window_getParent(unsigned int wid)
Gets the window's parent.
Definition toolkit.c:804
void window_setFocus(unsigned int wid, const char *wgtname)
Sets the focused widget in a window.
Definition toolkit.c:2488
void window_setAccept(unsigned int wid, void(*accept)(unsigned int, const char *))
Sets the default accept function of the window.
Definition toolkit.c:846
void window_dimWindow(unsigned int wid, int *w, int *h)
Gets the dimensions of a window.
Definition toolkit.c:370
int toolkit_isOpen(void)
Checks to see if the toolkit is open.
Definition toolkit.c:93
void window_move(unsigned int wid, int x, int y)
Moves a window to the specified coordinates.
Definition toolkit.c:176
void window_setCancel(unsigned int wid, void(*cancel)(unsigned int, const char *))
Sets the default cancel function of the window.
Definition toolkit.c:868
int window_existsID(unsigned int wid)
Checks to see if a window with a certain ID exists.
Definition toolkit.c:608
void toolkit_closeAll(void)
Closes all open toolkit windows.
Definition toolkit.c:1016
void window_onClose(unsigned int wid, void(*fptr)(unsigned int, const char *))
Sets the default close function of the window.
Definition toolkit.c:824
void window_canFocusWidget(unsigned int wid, const char *name, int canfocus)
Allows or disallows focusing a widget.
Definition toolkit.c:517
void toolkit_clearKey(void)
Clears the registered keys.
Definition toolkit.c:2051
void window_raise(unsigned int wid)
Raises a window (causes all other windows to appear below it).
Definition toolkit.c:2534
void window_moveWidget(unsigned int wid, const char *name, int x, int y)
Moves a widget.
Definition toolkit.c:463
void window_resize(unsigned int wid, int w, int h)
Resizes the window.
Definition toolkit.c:193
void toolkit_delay(void)
Delays the toolkit purge by an iteration, useful for dialogues.
Definition toolkit.c:105
void window_posWidget(unsigned int wid, const char *name, int *x, int *y)
Gets a widget's position.
Definition toolkit.c:441
int toolkit_init(void)
Initializes the toolkit.
Definition toolkit.c:2664
void window_destroyWidget(unsigned int wid, const char *wgtname)
Destroys a widget in a window.
Definition toolkit.c:1167
int widget_isCovered(unsigned int wid, const char *name, int x, int y)
Checks to see if a widget is covered or not.
Definition toolkit.c:561
void toolkit_render(double dt)
Renders the windows.
Definition toolkit.c:1625
int window_isTop(unsigned int wid)
Checks to see if a window is at the top.
Definition toolkit.c:544
void window_handleKeys(unsigned int wid, int(*keyhandler)(unsigned int, SDL_Keycode, SDL_Keymod, int))
Sets the key handler for the window.
Definition toolkit.c:961
unsigned int window_get(const char *wdwname)
Gets the ID of a window.
Definition toolkit.c:662
void window_lower(unsigned int wid)
Lowers a window (causes all other windows to appear above it).
Definition toolkit.c:2577
void window_setBorder(unsigned int wid, int enable)
Sets or removes the border of a window.
Definition toolkit.c:942
int toolkit_input(SDL_Event *event)
Toolkit input handled here.
Definition toolkit.c:1686
void toolkit_rerender(void)
Marks the toolkit for needing a full rerender.
Definition toolkit.c:1675
void window_posWindow(unsigned int wid, int *x, int *y)
Gets the dimensions of a window.
Definition toolkit.c:392
void * window_getData(unsigned int wid)
Gets the custom data of a window.
Definition toolkit.c:923
void window_setParent(unsigned int wid, unsigned int parent)
Sets a window as a window's parent.
Definition toolkit.c:787
void window_setData(unsigned int wid, void *data)
Sets custom data for a window.
Definition toolkit.c:906
void window_resizeWidget(unsigned int wid, const char *name, int w, int h)
Resizes a widget.
Definition toolkit.c:490
int window_exists(const char *wdwname)
Checks to see if a window exists.
Definition toolkit.c:591
int widget_exists(unsigned int wid, const char *wgtname)
Checks to see if a widget exists.
Definition toolkit.c:1144
int window_setDisplayname(unsigned int wid, const char *displayname)
Sets the displayname of a window.
Definition toolkit.c:625
void window_close(unsigned int wid, const char *str)
Helper function to automatically close the window calling it.
Definition toolkit.c:1028
void window_destroy(unsigned int wid)
Kills the window.
Definition toolkit.c:1039
char * window_getFocus(unsigned int wid)
Gets the focused widget in a window (does strdup!!).
Definition toolkit.c:2514
void window_handleEvents(unsigned int wid, int(*eventhandler)(unsigned int, SDL_Event *))
Sets the event handler for the window.
Definition toolkit.c:979