summaryrefslogtreecommitdiffstats
path: root/include/widgets/widget-internal.h
blob: e26fb8f223b52afc45499c63ec52b8480c8e8ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#ifndef WIDGET_INTERNAL_H
#define WIDGET_INTERNAL_H

#include "theme.h"
/**
 * 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;
    /** Padding */
    Padding           margin;
    Padding           padding;
    Padding           border;

    /** enabled or not */
    gboolean          enabled;
    /** Expand the widget when packed */
    gboolean          expand;
    /*** The packing index */
    int               index;
    /** Place widget at end of parent */
    gboolean          end;
    /** Parent widget */
    struct _widget    *parent;
    /** Internal */
    gboolean          need_redraw;
    /** get width of widget implementation function */
    int               ( *get_width )( struct _widget * );
    /** get height of widget implementation function */
    int               ( *get_height )( struct _widget * );
    /** draw widget implementation function */
    void              ( *draw )( struct _widget *widget, cairo_t *draw );
    /** resize widget implementation function */
    void              ( *resize )( struct _widget *, short, short );
    /** update widget implementation function */
    void              ( *update )( struct _widget * );

    /** Handle mouse motion, used for dragging */
    gboolean          ( *motion_notify )( struct _widget *, xcb_motion_notify_event_t * );

    int               (*get_desired_height) ( struct _widget * );

    /** widget clicked callback */
    widget_clicked_cb clicked;
    /** user data for clicked callback */
    void              *clicked_cb_data;

    /** Free widget callback */
    void              ( *free )( struct _widget *widget );

    /** Name of widget (used for theming) */
    char *name;
    const char *state;
};

/**
 * @param widget The widget to initialize.
 * @param name The name of the widget.
 *
 * 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.
 */
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