/* Definitions and headers for GTK widgets. Copyright (C) 2002 Free Software Foundation, Inc. This file is part of GNU Emacs. GNU Emacs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef GTKUTIL_H #define GTKUTIL_H #ifdef USE_GTK #include #include "frame.h" /* Minimum and maximum values used for GTK scroll bars */ #define GTK_SB_MIN 0 #define GTK_SB_MAX 10000000 #define GTK_SB_RANGE (GTK_SB_MAX - GTK_SB_MIN) /* Key for data that is the frame pointer */ #define G_FRAME_DATA "emacs_frame" /* Key for data that is the last scrollbar value */ #define G_LAST_SB_DATA "emacs_last_sb_value" /* Button types in menus. */ enum button_type { BUTTON_TYPE_NONE, BUTTON_TYPE_TOGGLE, BUTTON_TYPE_RADIO }; /* This structure is the callback data for menus. We need to keep it separate from the frame structure due to detachable menus. The data in the frame structure is only valid while the menu is popped up. */ struct menu_gtk_data { FRAME_PTR f; Lisp_Object menu_bar_vector; int menu_bar_items_used; int ref_count; struct menu_gtk_data *next; struct menu_gtk_data *prev; }; /* Used to specify menus and dialogs. This is an adaption from lwlib for Gtk so we can use more of the same code as lwlib in xmenu.c. */ typedef struct _widget_value { /* name of widget */ char* name; /* value (meaning depend on widget type) */ char* value; /* keyboard equivalent. no implications for XtTranslations */ char* key; /* Help string or nil if none. GC finds this string through the frame's menu_bar_vector or through menu_items. */ Lisp_Object help; /* true if enabled */ gint enabled; /* true if selected */ gint selected; /* The type of a button. */ enum button_type button_type; /* Contents of the sub-widgets, also selected slot for checkbox */ struct _widget_value* contents; /* data passed to callback */ gpointer call_data; /* next one in the list */ struct _widget_value* next; /* we resource the widget_value structures; this points to the next one on the free list if this one has been deallocated. */ struct _widget_value *free_list; } widget_value; extern widget_value *malloc_widget_value (); extern void free_widget_value __P ((widget_value *)); extern GtkWidget *xg_create_widget __P ((char* type, char* name, FRAME_PTR f, widget_value* val, int pop_up_p, GCallback activate_cb, GCallback select_cb, GCallback deactivate_cb, GCallback help_cb)); extern void xg_modify_menubar_widgets __P ((GtkWidget *menubar, FRAME_PTR f, widget_value* val, int deep_p, GCallback activate_cb, GCallback select_cb, GCallback deactivate_cb, GCallback help_cb)); extern int xg_update_frame_menubar __P ((FRAME_PTR f)); extern void xg_free_frame_menubar __P ((FRAME_PTR f)); extern void xg_resize_widgets __P ((FRAME_PTR f, int pixelwidth, int pixelheight)); extern void xg_frame_set_char_size __P ((FRAME_PTR f, int cols, int rows)); extern GtkWidget* xg_win_to_widget __P ((Window)); extern int xg_create_frame_widgets __P ((FRAME_PTR f)); extern void xg_set_wm_size_hints __P ((FRAME_PTR f, long flags, int user_position)); extern void xg_create_scroll_bar __P ((FRAME_PTR f, struct scroll_bar *bar, GCallback scroll_callback, char *scroll_bar_name)); extern void xg_show_scroll_bar __P ((int scrollbar_id)); extern void xg_remove_scroll_bar __P ((FRAME_PTR f, int scrollbar_id)); extern void xg_update_scrollbar_pos __P ((FRAME_PTR f, int scrollbar_id, int top, int left, int width, int height)); extern void xg_set_toolkit_scroll_bar_thumb __P ((struct scroll_bar *bar, int portion, int position, int whole)); /* Set this to non-zero to skip Emacs event processing. For dialogs and popups. */ extern int xg_pass_through_events; /* Setting scrollbar values invokes the callback. Use this variable to indicate that the callback should do nothing. */ extern int xg_ignore_gtk_scrollbar; /* After we send a scroll bar event, x_set_toolkit_scroll_bar_thumb will be called. For some reason that needs to be debugged, it gets called with bad values. Thus, we set this variable to ignore those calls. */ extern int xg_ignore_next_thumb; /* Mark all callback data that are Lisp_object:s during GC. */ extern void xg_mark_data (); #endif /* USE_GTK */ #endif /* GTKUTIL_H */