button.h (2225B)
1 /* 2 * This file is part of the Lumidify ToolKit (LTK) 3 * Copyright (c) 2016, 2017, 2018 lumidify <nobody@lumidify.org> 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * of this software and associated documentation files (the "Software"), to deal 7 * in the Software without restriction, including without limitation the rights 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * copies of the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in all 13 * copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 */ 23 24 #ifndef _LTK_BUTTON_H_ 25 #define _LTK_BUTTON_H_ 26 27 /* Requires the following includes: <X11/Xlib.h>, "ltk.h", "text_buffer.h" */ 28 29 typedef struct { 30 LtkWidget widget; 31 void (*callback) (void *, XEvent, void *); 32 void *data; 33 struct ltk_text_line *tl; 34 XImage *text; 35 XImage *text_hover; 36 XImage *text_pressed; 37 XImage *text_active; 38 XImage *text_disabled; 39 } LtkButton; 40 41 typedef struct LtkButtonTheme { 42 int border_width; 43 /* FIXME: this should actually be uint16_t */ 44 int font_size; 45 XColor text_color; 46 int pad; 47 48 XColor border; 49 XColor fill; 50 51 XColor border_hover; 52 XColor fill_hover; 53 54 XColor border_pressed; 55 XColor fill_pressed; 56 57 XColor border_active; 58 XColor fill_active; 59 60 XColor border_disabled; 61 XColor fill_disabled; 62 } LtkButtonTheme; 63 64 void ltk_button_draw(LtkButton *button); 65 66 LtkButton *ltk_button_create(LtkWindow * window, const char *text, void (*callback) (void *, XEvent, void *), void *data); 67 68 void ltk_button_destroy(LtkButton *button); 69 70 void ltk_button_mouse_release(LtkButton *button, XEvent event); 71 72 #endif