naev 0.10.4
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_setBorder( unsigned int wid, int enable );
33void window_setFocus( unsigned int wid, const char* wgtname );
34void window_handleKeys( unsigned int wid,
35 int (*keyhandler)(unsigned int,SDL_Keycode,SDL_Keymod) );
36void window_handleEvents( unsigned int wid,
37 int (*eventhandler)(unsigned int,SDL_Event*) );
38void window_move( unsigned int wid, int x, int y );
39void window_resize( unsigned int wid, int w, int h );
40void window_raise( unsigned int wid );
41void window_lower( unsigned int wid );
42int window_setDisplayname( unsigned int wid, const char *displayname );
43void window_setFade( unsigned int wid, const SimpleShader *shd, double length );
44
45/*
46 * get
47 */
48/* generic */
49int window_exists( const char* wdwname );
50int window_existsID( unsigned int wid );
51int widget_exists( unsigned int wid, const char* wgtname );
52unsigned int window_get( const char* wdwname );
53void window_dimWindow( unsigned int wid, int *w, int *h );
54void window_posWindow( unsigned int wid, int *x, int *y );
55void window_dimWidget( unsigned int wid, const char *name, int *w, int *h );
56char* window_getFocus( unsigned int wid );
57void window_posWidget( unsigned int wid, const char* name, int *x, int *y );
58void window_moveWidget( unsigned int wid, const char* name, int x, int y );
59void window_resizeWidget( unsigned int wid, const char* name, int w, int h );
60void window_canFocusWidget( unsigned int wid, const char* name, int canfocus );
61int window_isTop( unsigned int wid );
62int widget_isCovered( unsigned int wid, const char *name, int x, int y );
63
64/*
65 * destruction
66 */
67void toolkit_closeAll (void);
68void window_close( unsigned int wid, const char* str );
69void window_destroy( unsigned int wid );
70void window_destroyWidget( unsigned int wid, const char* wgtname );
71void window_setParent( unsigned int wid, unsigned int parent );
72unsigned int window_getParent( unsigned int wid );
73void window_onClose( unsigned int wid, void (*fptr)(unsigned int,const char*) );
74void window_onCleanup( 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_render( double dt );
86
87/*
88 * input
89 */
90int toolkit_input( SDL_Event* event );
91void toolkit_update (void);
92void toolkit_clearKey (void);
93
94/*
95 * init/exit
96 */
97int toolkit_init (void);
98void toolkit_exit (void);
99
100/*
101 * hacks
102 */
103void toolkit_reposition (void);
104void 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:714
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:696
void toolkit_update(void)
Updates the toolkit input for repeating keys.
Definition: toolkit.c:2218
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:2651
void window_setFade(unsigned int wid, const SimpleShader *shd, double length)
Sets the fade-in behaviour of a window.
Definition: toolkit.c:646
unsigned int window_getParent(unsigned int wid)
Gets the window's parent.
Definition: toolkit.c:820
void window_setFocus(unsigned int wid, const char *wgtname)
Sets the focused widget in a window.
Definition: toolkit.c:2460
void window_setAccept(unsigned int wid, void(*accept)(unsigned int, const char *))
Sets the default accept function of the window.
Definition: toolkit.c:879
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:95
void window_move(unsigned int wid, int x, int y)
Moves a window to the specified coordinates.
Definition: toolkit.c:180
void window_setCancel(unsigned int wid, void(*cancel)(unsigned int, const char *))
Sets the default cancel function of the window.
Definition: toolkit.c:900
int window_existsID(unsigned int wid)
Checks to see if a window with a certain ID exists.
Definition: toolkit.c:614
void toolkit_closeAll(void)
Closes all open toolkit windows.
Definition: toolkit.c:1019
void window_onClose(unsigned int wid, void(*fptr)(unsigned int, const char *))
Sets the default close function of the window.
Definition: toolkit.c:840
void window_canFocusWidget(unsigned int wid, const char *name, int canfocus)
Allows or disallows focusing a widget.
Definition: toolkit.c:523
void toolkit_clearKey(void)
Clears the registered keys.
Definition: toolkit.c:2032
void window_raise(unsigned int wid)
Raises a window (causes all other windows to appear below it).
Definition: toolkit.c:2506
void window_moveWidget(unsigned int wid, const char *name, int x, int y)
Moves a widget.
Definition: toolkit.c:467
void window_handleKeys(unsigned int wid, int(*keyhandler)(unsigned int, SDL_Keycode, SDL_Keymod))
Sets the key handler for the window.
Definition: toolkit.c:972
void window_resize(unsigned int wid, int w, int h)
Resizes the window.
Definition: toolkit.c:197
void toolkit_delay(void)
Delays the toolkit purge by an iteration, useful for dialogues.
Definition: toolkit.c:107
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:2633
void window_destroyWidget(unsigned int wid, const char *wgtname)
Destroys a widget in a window.
Definition: toolkit.c:1162
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:568
void toolkit_render(double dt)
Renders the windows.
Definition: toolkit.c:1590
int window_isTop(unsigned int wid)
Checks to see if a window is at the top.
Definition: toolkit.c:551
unsigned int window_get(const char *wdwname)
Gets the ID of a window.
Definition: toolkit.c:671
void window_lower(unsigned int wid)
Lowers a window (causes all other windows to appear above it).
Definition: toolkit.c:2548
void window_setBorder(unsigned int wid, int enable)
Sets or removes the border of a window.
Definition: toolkit.c:953
int toolkit_input(SDL_Event *event)
Toolkit input handled here.
Definition: toolkit.c:1674
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:934
void window_setParent(unsigned int wid, unsigned int parent)
Sets a window as a window's parent.
Definition: toolkit.c:803
void window_setData(unsigned int wid, void *data)
Sets custom data for a window.
Definition: toolkit.c:917
void window_resizeWidget(unsigned int wid, const char *name, int w, int h)
Resizes a widget.
Definition: toolkit.c:495
void window_onCleanup(unsigned int wid, void(*fptr)(unsigned int, const char *))
Sets the cleanup function of the window.
Definition: toolkit.c:858
int window_exists(const char *wdwname)
Checks to see if a window exists.
Definition: toolkit.c:598
int widget_exists(unsigned int wid, const char *wgtname)
Checks to see if a widget exists.
Definition: toolkit.c:1139
int window_setDisplayname(unsigned int wid, const char *displayname)
Sets the displayname of a window.
Definition: toolkit.c:631
void window_close(unsigned int wid, const char *str)
Helper function to automatically close the window calling it.
Definition: toolkit.c:1031
void toolkit_reposition(void)
Repositions windows and their children if resolution changes.
Definition: toolkit.c:2582
void window_destroy(unsigned int wid)
Kills the window.
Definition: toolkit.c:1042
char * window_getFocus(unsigned int wid)
Gets the focused widget in a window (does strdup!!).
Definition: toolkit.c:2486
void window_handleEvents(unsigned int wid, int(*eventhandler)(unsigned int, SDL_Event *))
Sets the event handler for the window.
Definition: toolkit.c:989