rofi 2.0.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>
44
49typedef struct _widget widget;
50
70
84
96typedef widget *(*widget_find_mouse_target_cb)(widget *wid, WidgetType type,
97 gint x, gint y);
98
112 guint action,
113 gint x, gint y,
114 void *user_data);
115
117#define WIDGET(a) ((widget *)(a))
118
128int widget_intersect(const widget *wid, int x, int y);
129
137void widget_move(widget *wid, short x, short y);
138
146
153gboolean widget_enabled(widget *wid);
154
161void widget_set_enabled(widget *wid, gboolean enabled);
162
168static inline void widget_disable(widget *wid) {
169 widget_set_enabled(wid, FALSE);
170}
171
176static inline void widget_enable(widget *wid) { widget_set_enabled(wid, TRUE); }
177
184void widget_draw(widget *wid, cairo_t *d);
185
191void widget_free(widget *wid);
192
200void widget_resize(widget *wid, short w, short h);
201
207int widget_get_height(widget *wid);
208
214int widget_get_width(widget *wid);
215
221int widget_get_y_pos(widget *wid);
222
228int widget_get_x_pos(widget *wid);
229
237void widget_xy_to_relative(widget *wid, gint *x, gint *y);
238
245void widget_update(widget *wid);
252void widget_queue_redraw(widget *wid);
258gboolean widget_need_redraw(widget *wid);
259
271
284 G_GNUC_UNUSED guint action,
285 G_GNUC_UNUSED gint x,
286 G_GNUC_UNUSED gint y);
287
300 gint x, gint y);
301
310 void *cb_data);
311
321gboolean widget_motion_notify(widget *wid, gint x, gint y);
322
331int widget_get_desired_height(widget *wid, const int width);
332
341int widget_get_desired_width(widget *wid, const int height);
359#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:546
void widget_queue_redraw(widget *wid)
Definition widget.c:487
void widget_move(widget *wid, short x, short y)
Definition widget.c:107
static void widget_enable(widget *wid)
Definition widget.h:176
void widget_free(widget *wid)
Definition widget.c:425
void widget_draw(widget *wid, cairo_t *d)
Definition widget.c:140
int widget_get_width(widget *wid)
Definition widget.c:446
int widget_get_height(widget *wid)
Definition widget.c:437
struct _widget widget
Definition widget.h:49
int widget_get_y_pos(widget *wid)
Definition widget.c:461
void widget_update(widget *wid)
Definition widget.c:477
void widget_set_type(widget *wid, WidgetType type)
Definition widget.c:114
WidgetType
Definition widget.h:54
void widget_set_enabled(widget *wid, gboolean enabled)
Definition widget.c:128
int widget_get_desired_width(widget *wid, const int height)
Definition widget.c:653
int widget_get_absolute_ypos(widget *wid)
Definition widget.c:673
int widget_get_x_pos(widget *wid)
Definition widget.c:455
WidgetTriggerActionResult(* widget_trigger_action_cb)(widget *wid, guint action, gint x, gint y, void *user_data)
Definition widget.h:111
int widget_get_absolute_xpos(widget *wid)
Definition widget.c:663
void widget_resize(widget *wid, short w, short h)
Definition widget.c:92
static void widget_disable(widget *wid)
Definition widget.h:168
WidgetTriggerActionResult
Definition widget.h:74
WidgetTriggerActionResult widget_check_action(widget *wid, G_GNUC_UNUSED guint action, G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y)
Definition widget.c:529
void widget_set_trigger_action_handler(widget *wid, widget_trigger_action_cb cb, void *cb_data)
Definition widget.c:557
int widget_get_desired_height(widget *wid, const int width)
Definition widget.c:644
gboolean widget_motion_notify(widget *wid, gint x, gint y)
Definition widget.c:566
void widget_xy_to_relative(widget *wid, gint *x, gint *y)
Definition widget.c:468
gboolean widget_need_redraw(widget *wid)
Definition widget.c:500
gboolean widget_enabled(widget *wid)
Definition widget.c:121
int widget_intersect(const widget *wid, int x, int y)
Definition widget.c:80
widget * widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y)
Definition widget.c:510
@ WIDGET_TYPE_UNKNOWN
Definition widget.h:56
@ WIDGET_TYPE_LISTVIEW_ELEMENT
Definition widget.h:60
@ WIDGET_TYPE_TEXTBOX_TEXT
Definition widget.h:68
@ WIDGET_TYPE_SCROLLBAR
Definition widget.h:64
@ WIDGET_TYPE_MODE_SWITCHER
Definition widget.h:66
@ WIDGET_TYPE_EDITBOX
Definition widget.h:62
@ WIDGET_TYPE_LISTVIEW
Definition widget.h:58
@ WIDGET_TRIGGER_ACTION_RESULT_HANDLED
Definition widget.h:78
@ WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END
Definition widget.h:82
@ WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN
Definition widget.h:80
@ WIDGET_TRIGGER_ACTION_RESULT_IGNORED
Definition widget.h:76
gboolean enabled
WidgetType type