naev 0.11.5
toolkit.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include "SDL.h"
10#include "font.h"
11#include "opengl.h"
12#include "tk/widget.h"
13
14int toolkit_isOpen (void);
15
16/*
17 * creation
18 */
19unsigned int window_create( const char* name, const char *displayname,
20 const int x, const int y, /* position */
21 const int w, const int h ); /* dimensions */
22unsigned int window_createFlags( const char* name, const char *displayname,
23 const int x, const int y, /* position */
24 const int w, const int h, unsigned int flags ); /* dimensions */
25
26/*
27 * modification
28 */
29/* window */
30void window_setAccept( unsigned int wid, void (*fptr)(unsigned int,const char*) );
31void window_setCancel( unsigned int wid, void (*cancel)(unsigned int,const char*) );
32void window_setOnFocus( unsigned int wid, void (*focus)(unsigned int) );
33void window_setBorder( unsigned int wid, int enable );
34void window_setFocus( unsigned int wid, const char* wgtname );
35void window_handleKeys( unsigned int wid,
36 int (*keyhandler)(unsigned int,SDL_Keycode,SDL_Keymod,int) );
37void window_handleEvents( unsigned int wid,
38 int (*eventhandler)(unsigned int,SDL_Event*) );
39void window_move( unsigned int wid, int x, int y );
40void window_resize( unsigned int wid, int w, int h );
41void window_raise( unsigned int wid );
42void window_lower( unsigned int wid );
43int window_setDisplayname( unsigned int wid, const char *displayname );
44void window_setDynamic( unsigned int wid, int dynamic );
45
46/*
47 * get
48 */
49/* generic */
50int window_exists( const char* wdwname );
51int window_existsID( unsigned int wid );
52int widget_exists( unsigned int wid, const char* wgtname );
53unsigned int window_get( const char* wdwname );
54void window_dimWindow( unsigned int wid, int *w, int *h );
55void window_posWindow( unsigned int wid, int *x, int *y );
56void window_dimWidget( unsigned int wid, const char *name, int *w, int *h );
57char* window_getFocus( unsigned int wid );
58void window_posWidget( unsigned int wid, const char* name, int *x, int *y );
59void window_moveWidget( unsigned int wid, const char* name, int x, int y );
60void window_resizeWidget( unsigned int wid, const char* name, int w, int h );
61void window_canFocusWidget( unsigned int wid, const char* name, int canfocus );
62int window_isTop( unsigned int wid );
63int widget_isCovered( unsigned int wid, const char *name, int x, int y );
64
65/*
66 * destruction
67 */
68void toolkit_closeAll (void);
69void window_close( unsigned int wid, const char* str );
70void window_destroy( unsigned int wid );
71void window_destroyWidget( unsigned int wid, const char* wgtname );
72void window_setParent( unsigned int wid, unsigned int parent );
73unsigned int window_getParent( unsigned int wid );
74void window_onClose( unsigned int wid, void (*fptr)(unsigned int,const char*) );
75
76/*
77 * data
78 */
79void window_setData( unsigned int wid, void *data );
80void* window_getData( unsigned int wid );
81
82/*
83 * render
84 */
85void toolkit_rerender (void);
86void toolkit_render( double dt );
87
88/*
89 * input
90 */
91int toolkit_input( SDL_Event* event );
92void toolkit_update (void);
93void toolkit_clearKey (void);
94
95/*
96 * init/exit
97 */
98int toolkit_init (void);
99void toolkit_exit (void);
100
101/*
102 * hacks
103 */
104void toolkit_resize (void);
105void 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:709
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:691
void window_setOnFocus(unsigned int wid, void(*focus)(unsigned int))
Sets the focus function of the window.
Definition toolkit.c:888
void toolkit_resize(void)
Repositions windows and their children if resolution changes.
Definition toolkit.c:2595
void toolkit_update(void)
Updates the toolkit input for repeating keys.
Definition toolkit.c:2224
void window_dimWidget(unsigned int wid, const char *name, int *w, int *h)
Gets the dimensions of a widget.
Definition toolkit.c:416
void toolkit_exit(void)
Exits the toolkit.
Definition toolkit.c:2665
void window_setDynamic(unsigned int wid, int dynamic)
Sets a window as dynamic, so that it is drawn every frame completely.
Definition toolkit.c:647
unsigned int window_getParent(unsigned int wid)
Gets the window's parent.
Definition toolkit.c:806
void window_setFocus(unsigned int wid, const char *wgtname)
Sets the focused widget in a window.
Definition toolkit.c:2471
void window_setAccept(unsigned int wid, void(*accept)(unsigned int, const char *))
Sets the default accept function of the window.
Definition toolkit.c:847
void window_dimWindow(unsigned int wid, int *w, int *h)
Gets the dimensions of a window.
Definition toolkit.c:371
int toolkit_isOpen(void)
Checks to see if the toolkit is open.
Definition toolkit.c:94
void window_move(unsigned int wid, int x, int y)
Moves a window to the specified coordinates.
Definition toolkit.c:179
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:612
void toolkit_closeAll(void)
Closes all open toolkit windows.
Definition toolkit.c:1014
void window_onClose(unsigned int wid, void(*fptr)(unsigned int, const char *))
Sets the default close function of the window.
Definition toolkit.c:826
void window_canFocusWidget(unsigned int wid, const char *name, int canfocus)
Allows or disallows focusing a widget.
Definition toolkit.c:521
void toolkit_clearKey(void)
Clears the registered keys.
Definition toolkit.c:2036
void window_raise(unsigned int wid)
Raises a window (causes all other windows to appear below it).
Definition toolkit.c:2517
void window_moveWidget(unsigned int wid, const char *name, int x, int y)
Moves a widget.
Definition toolkit.c:465
void window_resize(unsigned int wid, int w, int h)
Resizes the window.
Definition toolkit.c:196
void toolkit_delay(void)
Delays the toolkit purge by an iteration, useful for dialogues.
Definition toolkit.c:106
void window_posWidget(unsigned int wid, const char *name, int *x, int *y)
Gets a widget's position.
Definition toolkit.c:442
int toolkit_init(void)
Initializes the toolkit.
Definition toolkit.c:2647
void window_destroyWidget(unsigned int wid, const char *wgtname)
Destroys a widget in a window.
Definition toolkit.c:1165
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:566
void toolkit_render(double dt)
Renders the windows.
Definition toolkit.c:1593
int window_isTop(unsigned int wid)
Checks to see if a window is at the top.
Definition toolkit.c:549
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:960
unsigned int window_get(const char *wdwname)
Gets the ID of a window.
Definition toolkit.c:666
void window_lower(unsigned int wid)
Lowers a window (causes all other windows to appear above it).
Definition toolkit.c:2560
void window_setBorder(unsigned int wid, int enable)
Sets or removes the border of a window.
Definition toolkit.c:941
int toolkit_input(SDL_Event *event)
Toolkit input handled here.
Definition toolkit.c:1672
void toolkit_rerender(void)
Marks the toolkit for needing a full rerender.
Definition toolkit.c:1661
void window_posWindow(unsigned int wid, int *x, int *y)
Gets the dimensions of a window.
Definition toolkit.c:393
void * window_getData(unsigned int wid)
Gets the custom data of a window.
Definition toolkit.c:922
void window_setParent(unsigned int wid, unsigned int parent)
Sets a window as a window's parent.
Definition toolkit.c:789
void window_setData(unsigned int wid, void *data)
Sets custom data for a window.
Definition toolkit.c:905
void window_resizeWidget(unsigned int wid, const char *name, int w, int h)
Resizes a widget.
Definition toolkit.c:493
int window_exists(const char *wdwname)
Checks to see if a window exists.
Definition toolkit.c:596
int widget_exists(unsigned int wid, const char *wgtname)
Checks to see if a widget exists.
Definition toolkit.c:1142
int window_setDisplayname(unsigned int wid, const char *displayname)
Sets the displayname of a window.
Definition toolkit.c:629
void window_close(unsigned int wid, const char *str)
Helper function to automatically close the window calling it.
Definition toolkit.c:1026
void window_destroy(unsigned int wid)
Kills the window.
Definition toolkit.c:1037
char * window_getFocus(unsigned int wid)
Gets the focused widget in a window (does strdup!!).
Definition toolkit.c:2497
void window_handleEvents(unsigned int wid, int(*eventhandler)(unsigned int, SDL_Event *))
Sets the event handler for the window.
Definition toolkit.c:977