Etk
Main Page Object Hierarchy Data Structures Related Pages
Etk

Etk_Utils


Detailed Description

A set of utility functions and macros.


Defines

#define _(string)   gettext(string)
#define ETK_MAX(v1, v2)   (((v1) > (v2)) ? (v1) : (v2))
#define ETK_MIN(v1, v2)   (((v1) < (v2)) ? (v1) : (v2))
#define ETK_CLAMP(value, left, right)   ((value) < (left) ? (left) : ((value) > (right) ? (right) : (value)))
#define ETK_ROUND(a)   ((a < 0.0) ? (int)(floor(a - 0.5)) : (int)(floor(a + 0.5)))
#define ETK_INSIDE(x, y, xx, yy, ww, hh)   (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy)))
#define ETK_WARNING(format,)   fprintf(stderr, "[Etk-Warning] (%s:%d - %s()):\n" format "\n\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)

Functions

void etk_accumulator_bool_or (void *return_value, const void *value_to_accum, void *data)
 Combines the returned boolean values together by performing an "OR" operation.
void etk_accumulator_bool_and (void *return_value, const void *value_to_accum, void *data)
 Combines the returned boolean values together by performing an "AND" operation.
void etk_accumulator_stopping_bool_or (void *return_value, const void *value_to_accum, void *data)
 Combines the returned boolean values together by performing an "OR" operation.
The accumulator will stop the propagation of the signal as soon as a callback returns ETK_TRUE.
void etk_accumulator_stopping_bool_and (void *return_value, const void *value_to_accum, void *data)
 Combines the returned boolean values together by performing an "AND" operation.
The accumulator will stop the propagation of the signal as soon as a callback returns ETK_FALSE.
void etk_callback_set_null (void *data)
 A utility function to use as a swapped callback. It sets to NULL the pointer located at the adress stored in data.
For example, if you want to set "pointer" to NULL when "button" is clicked, you can do:
etk_signal_connect_swapped(ETK_OBJECT(button), "clicked", ETK_CALLBACK(etk_callback_set_null), &pointer);.
unsigned int etk_current_time_get ()
 Gets the current time, in milliseconds.


Define Documentation

#define _ ( string   )     gettext(string)

Finds a translation of "string" according to the locale settings (use gettext)

#define ETK_MAX ( v1,
v2   )     (((v1) > (v2)) ? (v1) : (v2))

Gets the max of the two values

#define ETK_MIN ( v1,
v2   )     (((v1) < (v2)) ? (v1) : (v2))

Gets the min of the two values

#define ETK_CLAMP ( value,
left,
right   )     ((value) < (left) ? (left) : ((value) > (right) ? (right) : (value)))

Clamps the value against the boudaries

#define ETK_ROUND ( a   )     ((a < 0.0) ? (int)(floor(a - 0.5)) : (int)(floor(a + 0.5)))

Rounds the float value to the nearest integer

#define ETK_INSIDE ( x,
y,
xx,
yy,
ww,
hh   )     (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy)))

Tests if the position (x, y) is inside the rectangle starting at (xx, yy) and of size (ww, hh)

#define ETK_WARNING ( format   )     fprintf(stderr, "[Etk-Warning] (%s:%d - %s()):\n" format "\n\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)

Displays a warning in the output console


Function Documentation

void etk_accumulator_bool_or ( void *  return_value,
const void *  value_to_accum,
void *  data 
)

Combines the returned boolean values together by performing an "OR" operation.

Parameters:
return_value the location where to store the result
value_to_accum the new value to combine
data unused

void etk_accumulator_bool_and ( void *  return_value,
const void *  value_to_accum,
void *  data 
)

Combines the returned boolean values together by performing an "AND" operation.

Parameters:
return_value the location where to store the result
value_to_accum the new value to combine
data unused

void etk_accumulator_stopping_bool_or ( void *  return_value,
const void *  value_to_accum,
void *  data 
)

Combines the returned boolean values together by performing an "OR" operation.
The accumulator will stop the propagation of the signal as soon as a callback returns ETK_TRUE.

Parameters:
return_value the location where to store the result
value_to_accum the new value to combine
data unused

void etk_accumulator_stopping_bool_and ( void *  return_value,
const void *  value_to_accum,
void *  data 
)

Combines the returned boolean values together by performing an "AND" operation.
The accumulator will stop the propagation of the signal as soon as a callback returns ETK_FALSE.

Parameters:
return_value the location where to store the result
value_to_accum the new value to combine
data unused

void etk_callback_set_null ( void *  data  ) 

A utility function to use as a swapped callback. It sets to NULL the pointer located at the adress stored in data.
For example, if you want to set "pointer" to NULL when "button" is clicked, you can do:
etk_signal_connect_swapped(ETK_OBJECT(button), "clicked", ETK_CALLBACK(etk_callback_set_null), &pointer);.

Parameters:
data data stores the location of the pointer to set to NULL

unsigned int etk_current_time_get (  ) 

Gets the current time, in milliseconds.

Returns:
Returns the current time, in milliseconds