2016-10-09 04:13:15 -04:00
|
|
|
#ifndef WIDGET_INTERNAL_H
|
|
|
|
#define WIDGET_INTERNAL_H
|
|
|
|
|
2016-12-27 16:19:15 -05:00
|
|
|
#include "theme.h"
|
2016-10-14 12:56:09 -04:00
|
|
|
/**
|
|
|
|
* Data structure holding the internal state of the Widget
|
|
|
|
*/
|
2016-10-09 04:13:15 -04:00
|
|
|
struct _widget
|
|
|
|
{
|
|
|
|
/** X position relative to parent */
|
|
|
|
short x;
|
|
|
|
/** Y position relative to parent */
|
|
|
|
short y;
|
|
|
|
/** Width of the widget */
|
|
|
|
short w;
|
|
|
|
/** Height of the widget */
|
|
|
|
short h;
|
2016-12-27 16:19:15 -05:00
|
|
|
/** Padding */
|
2017-02-03 09:44:52 -05:00
|
|
|
Padding def_margin;
|
|
|
|
Padding def_padding;
|
|
|
|
Padding def_border;
|
2017-02-06 15:17:56 -05:00
|
|
|
Padding def_border_radius;
|
2017-01-03 17:51:15 -05:00
|
|
|
Padding margin;
|
2017-01-03 09:39:19 -05:00
|
|
|
Padding padding;
|
|
|
|
Padding border;
|
2017-02-06 15:17:56 -05:00
|
|
|
Padding border_radius;
|
2017-01-03 09:39:19 -05:00
|
|
|
|
2016-10-09 04:13:15 -04:00
|
|
|
/** enabled or not */
|
|
|
|
gboolean enabled;
|
2016-10-14 12:56:09 -04:00
|
|
|
/** Expand the widget when packed */
|
2016-10-09 04:13:15 -04:00
|
|
|
gboolean expand;
|
2017-01-06 10:41:23 -05:00
|
|
|
/*** The packing index */
|
|
|
|
int index;
|
2016-10-14 12:56:09 -04:00
|
|
|
/** Place widget at end of parent */
|
2016-10-09 04:13:15 -04:00
|
|
|
gboolean end;
|
2016-10-14 12:56:09 -04:00
|
|
|
/** Parent widget */
|
2016-10-09 04:13:15 -04:00
|
|
|
struct _widget *parent;
|
|
|
|
/** Internal */
|
|
|
|
gboolean need_redraw;
|
2016-10-14 12:56:09 -04:00
|
|
|
/** get width of widget implementation function */
|
2016-10-09 04:13:15 -04:00
|
|
|
int ( *get_width )( struct _widget * );
|
2016-10-14 12:56:09 -04:00
|
|
|
/** get height of widget implementation function */
|
2016-10-09 04:13:15 -04:00
|
|
|
int ( *get_height )( struct _widget * );
|
2016-10-14 12:56:09 -04:00
|
|
|
/** draw widget implementation function */
|
2016-10-09 04:13:15 -04:00
|
|
|
void ( *draw )( struct _widget *widget, cairo_t *draw );
|
2016-10-14 12:56:09 -04:00
|
|
|
/** resize widget implementation function */
|
2016-10-09 04:13:15 -04:00
|
|
|
void ( *resize )( struct _widget *, short, short );
|
2016-10-14 12:56:09 -04:00
|
|
|
/** update widget implementation function */
|
2016-10-09 04:13:15 -04:00
|
|
|
void ( *update )( struct _widget * );
|
|
|
|
|
2016-10-25 16:45:11 -04:00
|
|
|
/** Handle mouse motion, used for dragging */
|
2016-10-26 02:24:34 -04:00
|
|
|
gboolean ( *motion_notify )( struct _widget *, xcb_motion_notify_event_t * );
|
2016-10-25 15:19:39 -04:00
|
|
|
|
2017-01-09 02:32:16 -05:00
|
|
|
int ( *get_desired_height )( struct _widget * );
|
2016-12-30 12:31:30 -05:00
|
|
|
|
2016-10-14 12:56:09 -04:00
|
|
|
/** widget clicked callback */
|
2016-10-09 04:13:15 -04:00
|
|
|
widget_clicked_cb clicked;
|
2016-11-15 15:54:31 -05:00
|
|
|
/** user data for clicked callback */
|
2016-10-09 04:13:15 -04:00
|
|
|
void *clicked_cb_data;
|
|
|
|
|
2016-10-14 12:56:09 -04:00
|
|
|
/** Free widget callback */
|
2016-10-09 04:13:15 -04:00
|
|
|
void ( *free )( struct _widget *widget );
|
2016-12-11 06:19:46 -05:00
|
|
|
|
|
|
|
/** Name of widget (used for theming) */
|
2017-01-08 15:36:06 -05:00
|
|
|
char *name;
|
|
|
|
const char *state;
|
2016-10-09 04:13:15 -04:00
|
|
|
};
|
2016-12-27 16:19:15 -05:00
|
|
|
|
2017-01-01 12:08:49 -05:00
|
|
|
/**
|
|
|
|
* @param widget The widget to initialize.
|
|
|
|
* @param name The name of the widget.
|
|
|
|
*
|
2017-01-01 12:40:49 -05:00
|
|
|
* Initializes the widget structure.
|
2017-01-01 12:08:49 -05:00
|
|
|
*
|
|
|
|
*/
|
2017-01-08 15:36:06 -05:00
|
|
|
void widget_init ( widget *widget, const char *name );
|
2017-01-01 12:08:49 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param widget The widget handle.
|
|
|
|
* @param state The state of the widget.
|
|
|
|
*
|
|
|
|
* Set the state of the widget.
|
|
|
|
*/
|
2016-12-28 06:21:42 -05:00
|
|
|
void widget_set_state ( widget *widget, const char *state );
|
2016-12-28 13:42:14 -05:00
|
|
|
|
2017-01-01 12:08:49 -05:00
|
|
|
/**
|
|
|
|
* @param wid The widget handle.
|
|
|
|
*
|
|
|
|
* Get the left padding of the widget.
|
|
|
|
*
|
|
|
|
* @returns the left padding in pixels.
|
|
|
|
*/
|
2016-12-28 13:42:14 -05:00
|
|
|
int widget_padding_get_left ( const widget *wid );
|
2017-01-01 12:08:49 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param wid The widget handle.
|
|
|
|
*
|
|
|
|
* Get the right padding of the widget.
|
|
|
|
*
|
|
|
|
* @returns the right padding in pixels.
|
|
|
|
*/
|
2016-12-28 13:42:14 -05:00
|
|
|
int widget_padding_get_right ( const widget *wid );
|
2017-01-01 12:08:49 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param wid The widget handle.
|
|
|
|
*
|
|
|
|
* Get the top padding of the widget.
|
|
|
|
*
|
|
|
|
* @returns the top padding in pixels.
|
|
|
|
*/
|
2016-12-28 13:42:14 -05:00
|
|
|
int widget_padding_get_top ( const widget *wid );
|
2017-01-01 12:08:49 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param wid The widget handle.
|
|
|
|
*
|
|
|
|
* Get the bottom padding of the widget.
|
|
|
|
*
|
|
|
|
* @returns the bottom padding in pixels.
|
|
|
|
*/
|
2016-12-28 13:42:14 -05:00
|
|
|
int widget_padding_get_bottom ( const widget *wid );
|
2017-01-01 12:08:49 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param wid The widget handle.
|
|
|
|
*
|
2017-01-08 15:36:06 -05:00
|
|
|
* Get width of the content of the widget
|
2017-01-01 12:08:49 -05:00
|
|
|
*
|
2017-01-08 15:36:06 -05:00
|
|
|
* @returns the widget width, excluding padding.
|
2017-01-01 12:08:49 -05:00
|
|
|
*/
|
2016-12-28 13:42:14 -05:00
|
|
|
int widget_padding_get_remaining_width ( const widget *wid );
|
2017-01-01 12:08:49 -05:00
|
|
|
/**
|
|
|
|
* @param wid The widget handle.
|
|
|
|
*
|
2017-01-08 15:36:06 -05:00
|
|
|
* Get height of the content of the widget
|
2017-01-01 12:08:49 -05:00
|
|
|
*
|
2017-01-08 15:36:06 -05:00
|
|
|
* @returns the widget height, excluding padding.
|
2017-01-01 12:08:49 -05:00
|
|
|
*/
|
2016-12-28 13:42:14 -05:00
|
|
|
int widget_padding_get_remaining_height ( const widget *wid );
|
2017-01-01 12:08:49 -05:00
|
|
|
/**
|
|
|
|
* @param wid The widget handle.
|
|
|
|
*
|
|
|
|
* Get the combined top and bottom padding.
|
|
|
|
*
|
|
|
|
* @returns the top and bottom padding of the widget in pixels.
|
|
|
|
*/
|
2016-12-28 13:42:14 -05:00
|
|
|
int widget_padding_get_padding_height ( const widget *wid );
|
2017-01-01 12:08:49 -05:00
|
|
|
/**
|
|
|
|
* @param wid The widget handle.
|
|
|
|
*
|
|
|
|
* Get the combined left and right padding.
|
|
|
|
*
|
|
|
|
* @returns the left and right padding of the widget in pixels.
|
|
|
|
*/
|
2016-12-28 13:42:14 -05:00
|
|
|
int widget_padding_get_padding_width ( const widget *wid );
|
2016-10-09 04:13:15 -04:00
|
|
|
#endif // WIDGET_INTERNAL_H
|