rofi  1.7.5
widget-internal.h
Go to the documentation of this file.
1 /*
2  * rofi
3  *
4  * MIT/X11 License
5  * Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  */
27 
28 #ifndef WIDGET_INTERNAL_H
29 #define WIDGET_INTERNAL_H
30 
31 #include "theme.h"
32 
34 #define WIDGET_DISTANCE_INIT \
35  (RofiDistance){ \
36  .base = { \
37  .distance = 0, \
38  .type = ROFI_PU_PX, \
39  .modtype = ROFI_DISTANCE_MODIFIER_NONE, \
40  .left = NULL, \
41  .right = NULL, \
42  }, \
43  .style = ROFI_HL_SOLID, \
44  }
45 /* Macro for initializing the RofiPadding struct. */
46 #define WIDGET_PADDING_INIT \
47  (RofiPadding){ \
48  .top = WIDGET_DISTANCE_INIT, \
49  .right = WIDGET_DISTANCE_INIT, \
50  .bottom = WIDGET_DISTANCE_INIT, \
51  .left = WIDGET_DISTANCE_INIT, \
52  }
53 
57 struct _widget {
61  short x;
63  short y;
65  short w;
67  short h;
77 
80 
82  gboolean enabled;
84  gboolean expand;
86  gboolean end;
88  struct _widget *parent;
90  gboolean need_redraw;
92  int (*get_width)(struct _widget *);
94  int (*get_height)(struct _widget *);
96  void (*draw)(struct _widget *widget, cairo_t *draw);
98  void (*resize)(struct _widget *, short, short);
100  void (*update)(struct _widget *);
101 
103  gboolean (*motion_notify)(struct _widget *, gint x, gint y);
104 
105  int (*get_desired_height)(struct _widget *, const int width);
106  int (*get_desired_width)(struct _widget *, const int height);
107 
108  void (*set_state)(struct _widget *, const char *);
109 
116 
118  void (*free)(struct _widget *widget);
119 
121  char *name;
122  const char *state;
123 };
124 
135  const char *name);
136 
143 void widget_set_state(widget *widget, const char *state);
144 
152 int widget_padding_get_left(const widget *wid);
153 
161 int widget_padding_get_right(const widget *wid);
162 
170 int widget_padding_get_top(const widget *wid);
171 
179 int widget_padding_get_bottom(const widget *wid);
180 
213 #endif // WIDGET_INTERNAL_H
struct _widget widget
Definition: widget.h:51
widget *(* widget_find_mouse_target_cb)(widget *widget, WidgetType type, gint x, gint y)
Definition: widget.h:98
WidgetType
Definition: widget.h:56
WidgetTriggerActionResult(* widget_trigger_action_cb)(widget *widget, guint action, gint x, gint y, void *user_data)
Definition: widget.h:113
RofiCursorType
Definition: rofi-types.h:149
void(* free)(struct _widget *widget)
void(* set_state)(struct _widget *, const char *)
gboolean end
const char * state
RofiPadding border
widget_find_mouse_target_cb find_mouse_target
gboolean enabled
gboolean need_redraw
widget_trigger_action_cb trigger_action
void * trigger_action_cb_data
RofiPadding padding
int(* get_desired_width)(struct _widget *, const int height)
int(* get_width)(struct _widget *)
RofiPadding margin
RofiPadding border_radius
RofiPadding def_border_radius
int(* get_height)(struct _widget *)
char * name
int(* get_desired_height)(struct _widget *, const int width)
RofiPadding def_margin
RofiCursorType cursor_type
RofiPadding def_border
struct _widget * parent
void(* update)(struct _widget *)
gboolean expand
RofiPadding def_padding
void(* draw)(struct _widget *widget, cairo_t *draw)
gboolean(* motion_notify)(struct _widget *, gint x, gint y)
void(* resize)(struct _widget *, short, short)
WidgetType type
int widget_padding_get_remaining_width(const widget *wid)
Definition: widget.c:619
void widget_init(widget *wid, widget *parent, WidgetType type, const char *name)
Definition: widget.c:34
void widget_set_state(widget *widget, const char *state)
Definition: widget.c:57
int widget_padding_get_padding_width(const widget *wid)
Definition: widget.c:637
int widget_padding_get_left(const widget *wid)
Definition: widget.c:576
int widget_padding_get_right(const widget *wid)
Definition: widget.c:586
int widget_padding_get_padding_height(const widget *wid)
Definition: widget.c:631
int widget_padding_get_top(const widget *wid)
Definition: widget.c:598
int widget_padding_get_bottom(const widget *wid)
Definition: widget.c:608
int widget_padding_get_remaining_height(const widget *wid)
Definition: widget.c:625