widget_internal.h (3789B)
1 /* 2 * Copyright (c) 2024 lumidify <nobody@lumidify.org> 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef LTK_WIDGET_INTERNAL_H 18 #define LTK_WIDGET_INTERNAL_H 19 20 #include <stddef.h> 21 22 #include "array.h" 23 #include "config.h" 24 #include "window.h" 25 #include "graphics.h" 26 27 void ltk_window_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 28 void ltk_button_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 29 void ltk_checkbutton_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 30 void ltk_radiobutton_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 31 void ltk_label_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 32 void ltk_menu_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 33 void ltk_menuentry_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 34 void ltk_submenu_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 35 void ltk_submenuentry_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 36 void ltk_scrollbar_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 37 38 void ltk_combobox_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 39 void ltk_combobox_cleanup(void); 40 void ltk_combobox_get_keybinding_parseinfo( 41 ltk_keybinding_cb **press_cbs_ret, size_t *press_len_ret, 42 ltk_keybinding_cb **release_cbs_ret, size_t *release_len_ret, 43 ltk_array(keypress) **presses_ret, ltk_array(keyrelease) **releases_ret 44 ); 45 46 void ltk_entry_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 47 void ltk_entry_cleanup(void); 48 void ltk_entry_get_keybinding_parseinfo( 49 ltk_keybinding_cb **press_cbs_ret, size_t *press_len_ret, 50 ltk_keybinding_cb **release_cbs_ret, size_t *release_len_ret, 51 ltk_array(keypress) **presses_ret, ltk_array(keyrelease) **releases_ret 52 ); 53 54 void ltk_window_get_theme_parseinfo(ltk_theme_parseinfo **p, size_t *len); 55 ltk_window *ltk_window_create_intern(ltk_renderdata *data, const char *title, int x, int y, unsigned int w, unsigned int h); 56 void ltk_window_destroy_intern(ltk_window *window); 57 void ltk_window_cleanup(void); 58 void ltk_window_get_keybinding_parseinfo( 59 ltk_keybinding_cb **press_cbs_ret, size_t *press_len_ret, 60 ltk_keybinding_cb **release_cbs_ret, size_t *release_len_ret, 61 ltk_array(keypress) **presses_ret, ltk_array(keyrelease) **releases_ret 62 ); 63 64 /* FIXME: how to avoid bad things happening while external program open? maybe store cmd widget somewhere (but could be multiple!) and check if widget to destroy is one of those 65 -> alternative: store all widgets in array and only give out IDs, then when returning from cmd, widget is already destroyed and can be ignored 66 -> first option maybe just set callback, etc. of current cmd to NULL so widget can still be destroyed */ 67 int ltk_call_cmd(ltk_widget *caller, ltk_array(cmd) *cmd, const char *text, size_t textlen); 68 69 int ltk_widget_handle_keypress_bindings(ltk_widget *widget, ltk_key_event *event, ltk_array(keypress) *keypresses, int handled); 70 int ltk_widget_handle_keyrelease_bindings(ltk_widget *widget, ltk_key_event *event, ltk_array(keyrelease) *keyreleases, int handled); 71 72 #endif /* LTK_WIDGET_INTERNAL_H */