rofi  1.7.0
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 
156 
163 gboolean widget_enabled(widget *widget);
164 
171 void widget_set_enabled(widget *widget, gboolean enabled);
172 
178 static inline void widget_disable(widget *widget) {
179  widget_set_enabled(widget, FALSE);
180 }
186 static inline void widget_enable(widget *widget) {
187  widget_set_enabled(widget, TRUE);
188 }
189 
196 void widget_draw(widget *widget, cairo_t *d);
197 
203 void widget_free(widget *wid);
204 
212 void widget_resize(widget *widget, short w, short h);
213 
220 
227 
234 
241 
249 void widget_xy_to_relative(widget *widget, gint *x, gint *y);
250 
264 void widget_queue_redraw(widget *wid);
270 gboolean widget_need_redraw(widget *wid);
271 
283 
296  gint x, gint y);
297 
306  void *cb_data);
307 
317 gboolean widget_motion_notify(widget *wid, gint x, gint y);
318 
327 
353 #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:551
void widget_queue_redraw(widget *wid)
Definition: widget.c:509
gboolean widget_enabled(widget *widget)
Definition: widget.c:138
int widget_get_width(widget *widget)
Definition: widget.c:468
int widget_get_desired_height(widget *wid)
Definition: widget.c:649
void widget_free(widget *wid)
Definition: widget.c:447
static void widget_disable(widget *widget)
Definition: widget.h:178
int widget_intersect(const widget *widget, int x, int y)
Definition: widget.c:90
int widget_get_height(widget *widget)
Definition: widget.c:459
struct _widget widget
Definition: widget.h:51
void widget_resize(widget *widget, short w, short h)
Definition: widget.c:102
int widget_get_desired_width(widget *wid)
Definition: widget.c:658
WidgetType
Definition: widget.h:56
static void widget_enable(widget *widget)
Definition: widget.h:186
WidgetType widget_type(widget *widget)
Definition: widget.c:131
void widget_set_enabled(widget *widget, gboolean enabled)
Definition: widget.c:145
void widget_update(widget *widget)
Definition: widget.c:499
int widget_get_absolute_ypos(widget *wid)
Definition: widget.c:678
void widget_move(widget *widget, short x, short y)
Definition: widget.c:117
int widget_get_y_pos(widget *widget)
Definition: widget.c:483
int widget_get_absolute_xpos(widget *wid)
Definition: widget.c:668
void widget_draw(widget *widget, cairo_t *d)
Definition: widget.c:157
void widget_xy_to_relative(widget *widget, gint *x, gint *y)
Definition: widget.c:490
WidgetTriggerActionResult
Definition: widget.h:76
widget * widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y)
Definition: widget.c:532
void widget_set_type(widget *widget, WidgetType type)
Definition: widget.c:124
void widget_set_trigger_action_handler(widget *wid, widget_trigger_action_cb cb, void *cb_data)
Definition: widget.c:562
gboolean widget_motion_notify(widget *wid, gint x, gint y)
Definition: widget.c:571
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:522
int widget_get_x_pos(widget *widget)
Definition: widget.c:477
@ 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