| 1 | /* Definitions and headers for GTK widgets. |
| 2 | |
| 3 | Copyright (C) 2003-2012 Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of GNU Emacs. |
| 6 | |
| 7 | GNU Emacs is free software: you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation, either version 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | GNU Emacs is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | #ifndef GTKUTIL_H |
| 21 | #define GTKUTIL_H |
| 22 | |
| 23 | |
| 24 | #ifdef USE_GTK |
| 25 | |
| 26 | #include <gtk/gtk.h> |
| 27 | #include "frame.h" |
| 28 | |
| 29 | /* Minimum and maximum values used for GTK scroll bars */ |
| 30 | |
| 31 | #define XG_SB_MIN 1 |
| 32 | #define XG_SB_MAX 10000000 |
| 33 | #define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN) |
| 34 | |
| 35 | /* Key for data that is valid for menus and scroll bars in a frame */ |
| 36 | #define XG_FRAME_DATA "emacs_frame" |
| 37 | |
| 38 | /* Key for data that menu items hold. */ |
| 39 | #define XG_ITEM_DATA "emacs_menuitem" |
| 40 | |
| 41 | /* This is a list node in a generic list implementation. */ |
| 42 | typedef struct xg_list_node_ |
| 43 | { |
| 44 | struct xg_list_node_ *prev; |
| 45 | struct xg_list_node_ *next; |
| 46 | } xg_list_node; |
| 47 | |
| 48 | /* This structure is the callback data that is shared for menu items. |
| 49 | We need to keep it separate from the frame structure due to |
| 50 | detachable menus. The data in the frame structure is only valid while |
| 51 | the menu is popped up. This structure is kept around as long as |
| 52 | the menu is. */ |
| 53 | typedef struct xg_menu_cb_data_ |
| 54 | { |
| 55 | xg_list_node ptrs; |
| 56 | |
| 57 | FRAME_PTR f; |
| 58 | Lisp_Object menu_bar_vector; |
| 59 | int menu_bar_items_used; |
| 60 | GCallback highlight_cb; |
| 61 | int ref_count; |
| 62 | } xg_menu_cb_data; |
| 63 | |
| 64 | /* This structure holds callback information for each individual menu item. */ |
| 65 | typedef struct xg_menu_item_cb_data_ |
| 66 | { |
| 67 | xg_list_node ptrs; |
| 68 | |
| 69 | gulong select_id; |
| 70 | Lisp_Object help; |
| 71 | gpointer call_data; |
| 72 | xg_menu_cb_data *cl_data; |
| 73 | |
| 74 | } xg_menu_item_cb_data; |
| 75 | |
| 76 | |
| 77 | #ifdef HAVE_GTK_FILE_SELECTION_NEW |
| 78 | extern int use_old_gtk_file_dialog; |
| 79 | #endif |
| 80 | struct _widget_value; |
| 81 | |
| 82 | extern struct _widget_value *malloc_widget_value (void); |
| 83 | extern void free_widget_value (struct _widget_value *); |
| 84 | |
| 85 | extern int xg_uses_old_file_dialog (void); |
| 86 | |
| 87 | extern char *xg_get_file_name (FRAME_PTR f, |
| 88 | char *prompt, |
| 89 | char *default_filename, |
| 90 | int mustmatch_p, |
| 91 | int only_dir_p); |
| 92 | |
| 93 | extern char *xg_get_font_name (FRAME_PTR f, const char *); |
| 94 | |
| 95 | extern GtkWidget *xg_create_widget (const char *type, |
| 96 | const char *name, |
| 97 | FRAME_PTR f, |
| 98 | struct _widget_value *val, |
| 99 | GCallback select_cb, |
| 100 | GCallback deactivate_cb, |
| 101 | GCallback highlight_cb); |
| 102 | |
| 103 | extern void xg_modify_menubar_widgets (GtkWidget *menubar, |
| 104 | FRAME_PTR f, |
| 105 | struct _widget_value *val, |
| 106 | int deep_p, |
| 107 | GCallback select_cb, |
| 108 | GCallback deactivate_cb, |
| 109 | GCallback highlight_cb); |
| 110 | |
| 111 | extern int xg_update_frame_menubar (FRAME_PTR f); |
| 112 | |
| 113 | extern int xg_event_is_for_menubar (FRAME_PTR f, XEvent *event); |
| 114 | |
| 115 | extern int xg_have_tear_offs (void); |
| 116 | |
| 117 | extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid); |
| 118 | |
| 119 | extern void xg_create_scroll_bar (FRAME_PTR f, |
| 120 | struct scroll_bar *bar, |
| 121 | GCallback scroll_callback, |
| 122 | GCallback end_callback, |
| 123 | const char *scroll_bar_name); |
| 124 | extern void xg_remove_scroll_bar (FRAME_PTR f, ptrdiff_t scrollbar_id); |
| 125 | |
| 126 | extern void xg_update_scrollbar_pos (FRAME_PTR f, |
| 127 | ptrdiff_t scrollbar_id, |
| 128 | int top, |
| 129 | int left, |
| 130 | int width, |
| 131 | int height); |
| 132 | |
| 133 | extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, |
| 134 | int portion, |
| 135 | int position, |
| 136 | int whole); |
| 137 | extern int xg_event_is_for_scrollbar (FRAME_PTR f, XEvent *event); |
| 138 | extern int xg_get_default_scrollbar_width (void); |
| 139 | |
| 140 | extern void update_frame_tool_bar (FRAME_PTR f); |
| 141 | extern void free_frame_tool_bar (FRAME_PTR f); |
| 142 | extern int xg_change_toolbar_position (FRAME_PTR f, Lisp_Object pos); |
| 143 | |
| 144 | extern void xg_frame_resized (FRAME_PTR f, |
| 145 | int pixelwidth, |
| 146 | int pixelheight); |
| 147 | extern void xg_frame_set_char_size (FRAME_PTR f, int cols, int rows); |
| 148 | extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc); |
| 149 | |
| 150 | extern void xg_display_open (char *display_name, Display **dpy); |
| 151 | extern void xg_display_close (Display *dpy); |
| 152 | extern GdkCursor * xg_create_default_cursor (Display *dpy); |
| 153 | |
| 154 | extern int xg_create_frame_widgets (FRAME_PTR f); |
| 155 | extern void xg_free_frame_widgets (FRAME_PTR f); |
| 156 | extern void x_wm_set_size_hint (FRAME_PTR f, |
| 157 | long flags, |
| 158 | int user_position); |
| 159 | extern void xg_set_background_color (FRAME_PTR f, unsigned long bg); |
| 160 | extern int xg_check_special_colors (struct frame *f, |
| 161 | const char *color_name, |
| 162 | XColor *color); |
| 163 | |
| 164 | extern void xg_set_frame_icon (FRAME_PTR f, |
| 165 | Pixmap icon_pixmap, |
| 166 | Pixmap icon_mask); |
| 167 | |
| 168 | extern int xg_prepare_tooltip (FRAME_PTR f, |
| 169 | Lisp_Object string, |
| 170 | int *width, |
| 171 | int *height); |
| 172 | extern void xg_show_tooltip (FRAME_PTR f, int root_x, int root_y); |
| 173 | extern int xg_hide_tooltip (FRAME_PTR f); |
| 174 | |
| 175 | |
| 176 | /* Mark all callback data that are Lisp_object:s during GC. */ |
| 177 | extern void xg_mark_data (void); |
| 178 | |
| 179 | /* Initialize GTK specific parts. */ |
| 180 | extern void xg_initialize (void); |
| 181 | |
| 182 | /* Setting scrollbar values invokes the callback. Use this variable |
| 183 | to indicate that the callback should do nothing. */ |
| 184 | extern int xg_ignore_gtk_scrollbar; |
| 185 | |
| 186 | #endif /* USE_GTK */ |
| 187 | #endif /* GTKUTIL_H */ |