SANDAL2
A SDL2 Wrapper in C
Classes | Macros | Typedefs | Functions | Variables
Window.h File Reference

Contains all structures related to windows but only those unrelated to Elements. More...

#include <string.h>
#include <stdlib.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_image.h>
Include dependency graph for Window.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EventWindow
 Behaviors of a window to events. More...
 
struct  Window
 SANDAL2 window. More...
 
struct  ListWindow
 list of windows More...
 

Macros

#define absolu(a)   ((a>0)?a:-a)
 Get the absolute value of a variable.
 
#define PFREE(p)
 free p if it is not NULL More...
 

Typedefs

typedef struct Window Window
 

Functions

int resizeWindow (unsigned width, unsigned height)
 Resize the current window. More...
 
int setDisplayCodeWindow (int displayCode)
 Change the display code of the current window. More...
 
Uint32 initIteratorWindow ()
 Initialise the iterator of the windows' list. More...
 
Uint32 nextWindow ()
 Go to the next window. More...
 
int getDimensionWindow (int *w, int *h)
 Put the width of the current window in w (if not NULL) and its height in h (if not NULL) More...
 
int getDisplayCodeWindow (int *d)
 Put the display code of the current window in d (if not NULL) More...
 
int getColorWindow (int color[4])
 Put the background color of the current window in color. More...
 
int setColorWindow (const int color[4])
 Change the background color of the current window. More...
 
int getCoordWindow (int *x, int *y)
 Getter for the current window position. More...
 
int setCoordWindow (int x, int y)
 Set for the current window position. More...
 
int getRealDimensionWindow (int *width, int *height)
 Getter for the real dimension of the current window (do not use this function to calculate elements' size or coordinates, use getDimensionWindow instead) More...
 
int getIDWindow (Uint32 *ID)
 Getter for the currently displaied window ID. More...
 
int getIDCurrentWindow (Uint32 *ID)
 Getter for the current window ID. More...
 
int setIconWindow (const char *icon_path)
 Set the current window's icon. More...
 
int setActionWindow (void(*action)(void))
 set the continuous behaviour of the current window More...
 
int setKeyPressedWindow (void(*keyPress)(SDL_Keycode c))
 set the behaviour of the current window when a key is pressed More...
 
int setKeyReleasedWindow (void(*keyReleased)(SDL_Keycode c))
 set the behaviour of the current window when a key is released More...
 
int setOnClickWindow (void(*onCLick)(int))
 set the behaviour of the current window when it is clicked More...
 
int setUnClickWindow (void(*unCLick)(int))
 set the behaviour of the current window when it is unclicked More...
 
int setOnWheelWindow (void(*onWheel)(int))
 set behavior of window when a wheel event occure More...
 
int setOnMouseMotionWindow (void(*onMouseMotion)(int, int))
 set behavior of window when a wheel event occure More...
 
int setOnFocusedWindow (void(*onFocus)(void))
 set behavior of window when the window gain focus More...
 
int setUnFocusedWindow (void(*unFocus)(void))
 set behavior of window when the window lose focus More...
 
int getOriginWindow (int *x, int *y)
 get the origin point of the current window More...
 
int setOriginWindow (int x, int y)
 set the origin point of the current window More...
 
int setXOriginWindow (int x)
 set the x coordinate of the origin point of the current window More...
 
int setYOriginWindow (int y)
 set the y coordinate of the origin point of the current window More...
 
int setDataWindow (void *data)
 set the data package of a window More...
 
int getDataWindow (void **data)
 get the data package of a window More...
 
int setDisplayWindow (Uint32 windowID)
 set the window to be displaied and the current window More...
 

Variables

ListWindow_windows_SANDAL2
 list of windows WARNING : do not touch this variable, never ... trust me More...
 

Detailed Description

Contains all structures related to windows but only those unrelated to Elements.

Author
Baptiste PRUNIER (KLEVH)

Macro Definition Documentation

◆ PFREE

#define PFREE (   p)
Value:
{ \
if(p){ \
free(p); \
} \
}

free p if it is not NULL

Function Documentation

◆ getColorWindow()

int getColorWindow ( int  color[4])

Put the background color of the current window in color.

Parameters
color: where the background color of the current window should be store
Returns
1 if there was an error, 0 if not

◆ getCoordWindow()

int getCoordWindow ( int *  x,
int *  y 
)

Getter for the current window position.

Parameters
x: where the abscissa coordinate of the window will be store
y: where the ordinate coordinate of the window will be store
Returns
1 if there was an error, 0 if not

◆ getDataWindow()

int getDataWindow ( void **  data)

get the data package of a window

Parameters
data: where to store the package of the window
Returns
0 if it was possible, 1 if not

◆ getDimensionWindow()

int getDimensionWindow ( int *  w,
int *  h 
)

Put the width of the current window in w (if not NULL) and its height in h (if not NULL)

Parameters
w: where the width of the current window should be store
h: where the height of the current window should be store
Returns
1 if there was an error, 0 if not

◆ getDisplayCodeWindow()

int getDisplayCodeWindow ( int *  d)

Put the display code of the current window in d (if not NULL)

Parameters
d: where the display code of the current window should be store
Returns
1 if there was an error, 0 if not

◆ getIDCurrentWindow()

int getIDCurrentWindow ( Uint32 *  ID)

Getter for the current window ID.

Parameters
ID: where to store the ID
Returns
1 if there was an error, 0 if not

◆ getIDWindow()

int getIDWindow ( Uint32 *  ID)

Getter for the currently displaied window ID.

Parameters
ID: where to store the ID
Returns
1 if there was an error, 0 if not

◆ getOriginWindow()

int getOriginWindow ( int *  x,
int *  y 
)

get the origin point of the current window

Parameters
x: where to store the x coordinate
y: where to store the y coordinate
Returns
1 if it was impossible, 0 if not

◆ getRealDimensionWindow()

int getRealDimensionWindow ( int *  width,
int *  height 
)

Getter for the real dimension of the current window (do not use this function to calculate elements' size or coordinates, use getDimensionWindow instead)

Parameters
width: where the real width of the window will be store
height: where the real height of the window will be store
Returns
1 if there was an error, 0 if not

◆ initIteratorWindow()

Uint32 initIteratorWindow ( )

Initialise the iterator of the windows' list.

Returns
0 if the iterator could not be initialised, the window ID if it could

◆ nextWindow()

Uint32 nextWindow ( )

Go to the next window.

Returns
the window ID if it was possible, 0 if not

◆ resizeWindow()

int resizeWindow ( unsigned  width,
unsigned  height 
)

Resize the current window.

Parameters
width: new width of the current window
height: new height of the current window
Returns
0 if it was possible, 1 if not

◆ setActionWindow()

int setActionWindow ( void(*)(void)  action)

set the continuous behaviour of the current window

Parameters
action: function to be called on each update call
Returns
1 if it was impossible, 0 if not

◆ setColorWindow()

int setColorWindow ( const int  color[4])

Change the background color of the current window.

Parameters
color: new color of the background of the current window
Returns
1 if there was an error, 0 if not

◆ setCoordWindow()

int setCoordWindow ( int  x,
int  y 
)

Set for the current window position.

Parameters
x: new abscissa coordinate of the window
y: new ordinate coordinate of the window
Returns
1 if there was an error, 0 if not

◆ setDataWindow()

int setDataWindow ( void *  data)

set the data package of a window

Parameters
data: new package of the window
Returns
0 if it was possible, 1 if not

◆ setDisplayCodeWindow()

int setDisplayCodeWindow ( int  displayCode)

Change the display code of the current window.

Parameters
displayCode: new display code of the current window
Returns
0 if it was possible, 1 if not

◆ setDisplayWindow()

int setDisplayWindow ( Uint32  windowID)

set the window to be displaied and the current window

Parameters
windowID: ID of the window to be displaied and to become current
Returns
0 if it was possible, 1 if not

◆ setIconWindow()

int setIconWindow ( const char *  icon_path)

Set the current window's icon.

Parameters
icon_path: path of the image to be used
Returns
1 if there was an error, 0 if not

◆ setKeyPressedWindow()

int setKeyPressedWindow ( void(*)(SDL_Keycode c)  keyPress)

set the behaviour of the current window when a key is pressed

Parameters
keyPress: function to be called when a key is pressed
Returns
1 if it was impossible, 0 if not

◆ setKeyReleasedWindow()

int setKeyReleasedWindow ( void(*)(SDL_Keycode c)  keyReleased)

set the behaviour of the current window when a key is released

Parameters
keyReleased: function to be called when a key is released
Returns
1 if it was impossible, 0 if not

◆ setOnClickWindow()

int setOnClickWindow ( void(*)(int)  onCLick)

set the behaviour of the current window when it is clicked

Parameters
onCLick: function to be called when it is clicked
Returns
1 if it was impossible, 0 if not

◆ setOnFocusedWindow()

int setOnFocusedWindow ( void(*)(void)  onFocus)

set behavior of window when the window gain focus

Parameters
onFocus: function to be called
Returns
1 if it failed, 0 if not

◆ setOnMouseMotionWindow()

int setOnMouseMotionWindow ( void(*)(int, int)  onMouseMotion)

set behavior of window when a wheel event occure

Parameters
wheel: function to be called
Returns
1 if it failed, 0 if not

◆ setOnWheelWindow()

int setOnWheelWindow ( void(*)(int)  onWheel)

set behavior of window when a wheel event occure

Parameters
onWheel: function to be called when a wheel event occure
Returns
1 if it failed, 0 if not

◆ setOriginWindow()

int setOriginWindow ( int  x,
int  y 
)

set the origin point of the current window

Parameters
x: new x coordinate
y: new y coordinate
Returns
1 if it was impossible, 0 if not

◆ setUnClickWindow()

int setUnClickWindow ( void(*)(int)  unCLick)

set the behaviour of the current window when it is unclicked

Parameters
unCLick: function to be called when it is unclicked
Returns
1 if it was impossible, 0 if not

◆ setUnFocusedWindow()

int setUnFocusedWindow ( void(*)(void)  unFocus)

set behavior of window when the window lose focus

Parameters
unFocus: function to be called
Returns
1 if it failed, 0 if not

◆ setXOriginWindow()

int setXOriginWindow ( int  x)

set the x coordinate of the origin point of the current window

Parameters
x: new x coordinate
Returns
1 if it was impossible, 0 if not

◆ setYOriginWindow()

int setYOriginWindow ( int  y)

set the y coordinate of the origin point of the current window

Parameters
y: new y coordinate
Returns
1 if it was impossible, 0 if not

Variable Documentation

◆ _windows_SANDAL2

ListWindow* _windows_SANDAL2

list of windows WARNING : do not touch this variable, never ... trust me

list of windows WARNING : do not touch this variable, never ... trust me

List of the windows WARNING : do not touch it ... trust me.