rofi/include/widgets/widget-internal.h

150 lines
3.9 KiB
C
Raw Normal View History

#ifndef WIDGET_INTERNAL_H
#define WIDGET_INTERNAL_H
2016-12-27 21:19:15 +00:00
#include "theme.h"
2016-10-14 16:56:09 +00:00
/**
* Data structure holding the internal state of the Widget
*/
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 21:19:15 +00:00
/** Padding */
2017-01-03 22:51:15 +00:00
Padding margin;
Padding padding;
Padding border;
/** enabled or not */
gboolean enabled;
2016-10-14 16:56:09 +00:00
/** Expand the widget when packed */
gboolean expand;
/*** The packing index */
int index;
2016-10-14 16:56:09 +00:00
/** Place widget at end of parent */
gboolean end;
2016-10-14 16:56:09 +00:00
/** Parent widget */
struct _widget *parent;
/** Internal */
gboolean need_redraw;
2016-10-14 16:56:09 +00:00
/** get width of widget implementation function */
int ( *get_width )( struct _widget * );
2016-10-14 16:56:09 +00:00
/** get height of widget implementation function */
int ( *get_height )( struct _widget * );
2016-10-14 16:56:09 +00:00
/** draw widget implementation function */
void ( *draw )( struct _widget *widget, cairo_t *draw );
2016-10-14 16:56:09 +00:00
/** resize widget implementation function */
void ( *resize )( struct _widget *, short, short );
2016-10-14 16:56:09 +00:00
/** update widget implementation function */
void ( *update )( struct _widget * );
/** Handle mouse motion, used for dragging */
2016-10-26 06:24:34 +00:00
gboolean ( *motion_notify )( struct _widget *, xcb_motion_notify_event_t * );
2016-12-30 17:31:30 +00:00
int (*get_desired_height) ( struct _widget * );
2016-10-14 16:56:09 +00:00
/** widget clicked callback */
widget_clicked_cb clicked;
2016-11-15 20:54:31 +00:00
/** user data for clicked callback */
void *clicked_cb_data;
2016-10-14 16:56:09 +00:00
/** Free widget callback */
void ( *free )( struct _widget *widget );
2016-12-11 11:19:46 +00:00
/** Name of widget (used for theming) */
char *name;
2016-12-28 11:21:42 +00:00
const char *state;
};
2016-12-27 21:19:15 +00:00
/**
* @param widget The widget to initialize.
* @param name The name of the widget.
*
2017-01-01 17:40:49 +00:00
* Initializes the widget structure.
*
*/
void widget_init ( widget *widget , const char *name );
/**
* @param widget The widget handle.
* @param state The state of the widget.
*
* Set the state of the widget.
*/
2016-12-28 11:21:42 +00:00
void widget_set_state ( widget *widget, const char *state );
/**
* @param wid The widget handle.
*
* Get the left padding of the widget.
*
* @returns the left padding in pixels.
*/
int widget_padding_get_left ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the right padding of the widget.
*
* @returns the right padding in pixels.
*/
int widget_padding_get_right ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the top padding of the widget.
*
* @returns the top padding in pixels.
*/
int widget_padding_get_top ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the bottom padding of the widget.
*
* @returns the bottom padding in pixels.
*/
int widget_padding_get_bottom ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get width of the content of the widget
*
* @returns the widget width, excluding padding.
*/
int widget_padding_get_remaining_width ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get height of the content of the widget
*
* @returns the widget height, excluding padding.
*/
int widget_padding_get_remaining_height ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the combined top and bottom padding.
*
* @returns the top and bottom padding of the widget in pixels.
*/
int widget_padding_get_padding_height ( const widget *wid );
/**
* @param wid The widget handle.
*
* Get the combined left and right padding.
*
* @returns the left and right padding of the widget in pixels.
*/
int widget_padding_get_padding_width ( const widget *wid );
#endif // WIDGET_INTERNAL_H