rofi  1.7.3
widget.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 ROFI_WIDGET_H
29 #define ROFI_WIDGET_H
30 #include "keyb.h"
31 #include <cairo.h>
32 #include <glib.h>
33 #include <xcb/xcb.h>
34 #include <xcb/xproto.h>
51 typedef struct _widget widget;
52 
56 typedef enum {
71 } WidgetType;
72 
76 typedef enum {
86 
98 typedef widget *(*widget_find_mouse_target_cb)(widget *widget, WidgetType type,
99  gint x, gint y);
100 
114  guint action,
115  gint x, gint y,
116  void *user_data);
117 
119 #define WIDGET(a) ((widget *)(a))
120 
130 int widget_intersect(const widget *widget, int x, int y);
131 
139 void widget_move(widget *widget, short x, short y);
140 
148 
155 gboolean widget_enabled(widget *widget);
156 
163 void widget_set_enabled(widget *widget, gboolean enabled);
164 
170 static inline void widget_disable(widget *widget) {
171  widget_set_enabled(widget, FALSE);
172 }
178 static inline void widget_enable(widget *widget) {
179  widget_set_enabled(widget, TRUE);
180 }
181 
188 void widget_draw(widget *widget, cairo_t *d);
189 
195 void widget_free(widget *wid);
196 
204 void widget_resize(widget *widget, short w, short h);
205 
212 
219 
226 
233 
241 void widget_xy_to_relative(widget *widget, gint *x, gint *y);
242 
256 void widget_queue_redraw(widget *wid);
262 gboolean widget_need_redraw(widget *wid);
263 
275 
287 WidgetTriggerActionResult widget_check_action(widget *wid, guint action, gint x,
288  gint y);
289 
302  gint x, gint y);
303 
312  void *cb_data);
313 
323 gboolean widget_motion_notify(widget *wid, gint x, gint y);
324 
333 int widget_get_desired_height(widget *wid, const int width);
334 
343 int widget_get_desired_width(widget *wid, const int height);
361 #endif // ROFI_WIDGET_H
@ SCOPE_MOUSE_LISTVIEW_ELEMENT
Definition: keyb.h:46
@ SCOPE_MOUSE_EDITBOX
Definition: keyb.h:49
@ SCOPE_MOUSE_LISTVIEW
Definition: keyb.h:45
@ SCOPE_MOUSE_SCROLLBAR
Definition: keyb.h:50
@ SCOPE_MOUSE_MODE_SWITCHER
Definition: keyb.h:51
WidgetTriggerActionResult widget_trigger_action(widget *wid, guint action, gint x, gint y)
Definition: widget.c:544
void widget_queue_redraw(widget *wid)
Definition: widget.c:487
gboolean widget_enabled(widget *widget)
Definition: widget.c:116
int widget_get_width(widget *widget)
Definition: widget.c:446
void widget_free(widget *wid)
Definition: widget.c:425
static void widget_disable(widget *widget)
Definition: widget.h:170
int widget_intersect(const widget *widget, int x, int y)
Definition: widget.c:75
int widget_get_height(widget *widget)
Definition: widget.c:437
struct _widget widget
Definition: widget.h:51
void widget_resize(widget *widget, short w, short h)
Definition: widget.c:87
WidgetType
Definition: widget.h:56
static void widget_enable(widget *widget)
Definition: widget.h:178
void widget_set_enabled(widget *widget, gboolean enabled)
Definition: widget.c:123
WidgetTriggerActionResult widget_check_action(widget *wid, guint action, gint x, gint y)
Definition: widget.c:529
void widget_update(widget *widget)
Definition: widget.c:477
int widget_get_desired_width(widget *wid, const int height)
Definition: widget.c:651
int widget_get_absolute_ypos(widget *wid)
Definition: widget.c:671
void widget_move(widget *widget, short x, short y)
Definition: widget.c:102
int widget_get_y_pos(widget *widget)
Definition: widget.c:461
int widget_get_absolute_xpos(widget *wid)
Definition: widget.c:661
void widget_draw(widget *widget, cairo_t *d)
Definition: widget.c:135
void widget_xy_to_relative(widget *widget, gint *x, gint *y)
Definition: widget.c:468
WidgetTriggerActionResult
Definition: widget.h:76
widget * widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y)
Definition: widget.c:510
void widget_set_type(widget *widget, WidgetType type)
Definition: widget.c:109
void widget_set_trigger_action_handler(widget *wid, widget_trigger_action_cb cb, void *cb_data)
Definition: widget.c:555
int widget_get_desired_height(widget *wid, const int width)
Definition: widget.c:642
gboolean widget_motion_notify(widget *wid, gint x, gint y)
Definition: widget.c:564
WidgetTriggerActionResult(* widget_trigger_action_cb)(widget *widget, guint action, gint x, gint y, void *user_data)
Definition: widget.h:113
gboolean widget_need_redraw(widget *wid)
Definition: widget.c:500
int widget_get_x_pos(widget *widget)
Definition: widget.c:455
@ WIDGET_TYPE_UNKNOWN
Definition: widget.h:58
@ WIDGET_TYPE_LISTVIEW_ELEMENT
Definition: widget.h:62
@ WIDGET_TYPE_TEXTBOX_TEXT
Definition: widget.h:70
@ WIDGET_TYPE_SCROLLBAR
Definition: widget.h:66
@ WIDGET_TYPE_MODE_SWITCHER
Definition: widget.h:68
@ WIDGET_TYPE_EDITBOX
Definition: widget.h:64
@ WIDGET_TYPE_LISTVIEW
Definition: widget.h:60
@ WIDGET_TRIGGER_ACTION_RESULT_HANDLED
Definition: widget.h:80
@ WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END
Definition: widget.h:84
@ WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN
Definition: widget.h:82
@ WIDGET_TRIGGER_ACTION_RESULT_IGNORED
Definition: widget.h:78
gboolean enabled
WidgetType type