rofi  1.6.1
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 <glib.h>
31 #include <cairo.h>
32 #include <xcb/xcb.h>
33 #include <xcb/xproto.h>
34 #include "keyb.h"
51 typedef struct _widget widget;
52 
56 typedef enum
57 {
72 } WidgetType;
73 
77 typedef enum
78 {
88 
99 typedef widget * ( *widget_find_mouse_target_cb )( widget *widget, WidgetType type, gint x, gint y );
100 
112 typedef WidgetTriggerActionResult ( *widget_trigger_action_cb )( widget *widget, guint action, gint x, gint y, void *user_data );
113 
115 #define WIDGET( a ) ( (widget *) ( a ) )
116 
126 int widget_intersect ( const widget *widget, int x, int y );
127 
135 void widget_move ( widget *widget, short x, short y );
136 
144 
152 
159 gboolean widget_enabled ( widget *widget );
160 
167 void widget_set_enabled ( widget *widget, gboolean enabled );
168 
174 static inline
176 {
177  widget_set_enabled ( widget, FALSE );
178 }
184 static inline
186 {
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 
257 void widget_update ( widget *widget );
264 void widget_queue_redraw ( widget *wid );
270 gboolean widget_need_redraw ( widget *wid );
271 
282 widget *widget_find_mouse_target ( widget *wid, WidgetType type, gint x, gint y );
283 
295 WidgetTriggerActionResult widget_trigger_action ( widget *wid, guint action, gint x, gint y );
296 
304 void widget_set_trigger_action_handler ( widget *wid, widget_trigger_action_cb cb, void *cb_data );
305 
315 gboolean widget_motion_notify ( widget *wid, gint x, gint y );
316 
324 int widget_get_desired_height ( widget *wid );
325 
333 int widget_get_desired_width ( widget *wid );
341 int widget_get_absolute_xpos ( widget *wid );
349 int widget_get_absolute_ypos ( widget *wid );
350 
352 #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:451
void widget_queue_redraw(widget *wid)
Definition: widget.c:408
gboolean widget_enabled(widget *widget)
Definition: widget.c:164
int widget_get_width(widget *widget)
Definition: widget.c:362
int widget_get_desired_height(widget *wid)
Definition: widget.c:552
void widget_free(widget *wid)
Definition: widget.c:339
static void widget_disable(widget *widget)
Definition: widget.h:175
int widget_intersect(const widget *widget, int x, int y)
Definition: widget.c:110
int widget_get_height(widget *widget)
Definition: widget.c:352
struct _widget widget
Definition: widget.h:51
void widget_resize(widget *widget, short w, short h)
Definition: widget.c:123
int widget_get_desired_width(widget *wid)
Definition: widget.c:562
WidgetType
Definition: widget.h:57
static void widget_enable(widget *widget)
Definition: widget.h:185
WidgetType widget_type(widget *widget)
Definition: widget.c:156
void widget_set_enabled(widget *widget, gboolean enabled)
Definition: widget.c:172
WidgetTriggerActionResult(* widget_trigger_action_cb)(widget *widget, guint action, gint x, gint y, void *user_data)
Definition: widget.h:112
void widget_update(widget *widget)
Definition: widget.c:397
int widget_get_absolute_ypos(widget *wid)
Definition: widget.c:584
void widget_move(widget *widget, short x, short y)
Definition: widget.c:140
int widget_get_y_pos(widget *widget)
Definition: widget.c:379
int widget_get_absolute_xpos(widget *wid)
Definition: widget.c:573
void widget_draw(widget *widget, cairo_t *d)
Definition: widget.c:185
void widget_xy_to_relative(widget *widget, gint *x, gint *y)
Definition: widget.c:387
WidgetTriggerActionResult
Definition: widget.h:78
widget * widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y)
Definition: widget.c:433
void widget_set_type(widget *widget, WidgetType type)
Definition: widget.c:148
void widget_set_trigger_action_handler(widget *wid, widget_trigger_action_cb cb, void *cb_data)
Definition: widget.c:462
gboolean widget_motion_notify(widget *wid, gint x, gint y)
Definition: widget.c:471
gboolean widget_need_redraw(widget *wid)
Definition: widget.c:422
int widget_get_x_pos(widget *widget)
Definition: widget.c:372
@ WIDGET_TYPE_UNKNOWN
Definition: widget.h:59
@ WIDGET_TYPE_LISTVIEW_ELEMENT
Definition: widget.h:63
@ WIDGET_TYPE_TEXTBOX_TEXT
Definition: widget.h:71
@ WIDGET_TYPE_SCROLLBAR
Definition: widget.h:67
@ WIDGET_TYPE_MODE_SWITCHER
Definition: widget.h:69
@ WIDGET_TYPE_EDITBOX
Definition: widget.h:65
@ WIDGET_TYPE_LISTVIEW
Definition: widget.h:61
@ WIDGET_TRIGGER_ACTION_RESULT_HANDLED
Definition: widget.h:82
@ WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END
Definition: widget.h:86
@ WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN
Definition: widget.h:84
@ WIDGET_TRIGGER_ACTION_RESULT_IGNORED
Definition: widget.h:80
gboolean enabled
WidgetType type