image: Remove some code duplication
[awesome.git] / widget.h
blobd424dd584ed124a00f667b12ef7a4e06bee85b8d
1 /*
2 * widget.h - widget managing header
4 * Copyright © 2007-2009 Julien Danjou <julien@danjou.info>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef AWESOME_WIDGET_H
23 #define AWESOME_WIDGET_H
25 #include "button.h"
26 #include "common/tokenize.h"
28 typedef widget_t *(widget_constructor_t)(widget_t *);
29 typedef void (widget_destructor_t)(widget_t *);
31 /** Widget */
32 struct widget_t
34 /** Lua references */
35 luaA_ref_array_t refs;
36 /** Widget type is constructor */
37 widget_constructor_t *type;
38 /** Widget destructor */
39 widget_destructor_t *destructor;
40 /** Geometry function for drawing */
41 area_t (*geometry)(widget_t *, screen_t *, int, int);
42 /** Extents function */
43 area_t (*extents)(lua_State *, widget_t *);
44 /** Draw function */
45 void (*draw)(widget_t *, draw_context_t *, area_t, wibox_t *);
46 /** Index function */
47 int (*index)(lua_State *, awesome_token_t);
48 /** Newindex function */
49 int (*newindex)(lua_State *, awesome_token_t);
50 /** Mouse over event handler */
51 luaA_ref mouse_enter, mouse_leave;
52 /** Alignement */
53 alignment_t align;
54 /** Supported alignment */
55 alignment_t align_supported;
56 /** Misc private data */
57 void *data;
58 /** Button bindings */
59 button_array_t buttons;
60 /** True if the widget is visible */
61 bool isvisible;
64 LUA_OBJECT_FUNCS(widget_t, widget, "widget");
66 struct widget_node_t
68 /** The widget object */
69 widget_t *widget;
70 /** The geometry where the widget was drawn */
71 area_t geometry;
74 widget_t *widget_getbycoords(orientation_t, widget_node_array_t *, int, int, int16_t *, int16_t *);
75 void widget_render(wibox_t *);
77 void luaA_table2widgets(lua_State *, widget_node_array_t *);
79 void widget_invalidate_bywidget(widget_t *);
80 void widget_invalidate_bytype(widget_constructor_t *);
82 widget_constructor_t widget_textbox;
83 widget_constructor_t widget_progressbar;
84 widget_constructor_t widget_graph;
85 widget_constructor_t widget_systray;
86 widget_constructor_t widget_imagebox;
88 void widget_node_delete(widget_node_t *);
89 ARRAY_FUNCS(widget_node_t, widget_node, widget_node_delete)
91 #endif
93 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80