gtkutil.h 6.21 KB
Newer Older
Jan Djärv's avatar
Jan Djärv committed
1
/* Definitions and headers for GTK widgets.
2

3
Copyright (C) 2003-2014 Free Software Foundation, Inc.
Jan Djärv's avatar
Jan Djärv committed
4 5 6

This file is part of GNU Emacs.

7
GNU Emacs is free software: you can redistribute it and/or modify
Jan Djärv's avatar
Jan Djärv committed
8
it under the terms of the GNU General Public License as published by
9 10
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Jan Djärv's avatar
Jan Djärv committed
11 12 13 14 15 16 17

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
18
along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Djärv's avatar
Jan Djärv committed
19 20 21 22 23 24 25 26

#ifndef GTKUTIL_H
#define GTKUTIL_H


#ifdef USE_GTK

#include <gtk/gtk.h>
27
#include "../lwlib/lwlib-widget.h"
Jan Djärv's avatar
Jan Djärv committed
28
#include "frame.h"
29
#include "xterm.h"
Jan Djärv's avatar
Jan Djärv committed
30 31 32

/* Minimum and maximum values used for GTK scroll bars  */

33
#define XG_SB_MIN 1
Jan Djärv's avatar
Jan Djärv committed
34
#define XG_SB_MAX 10000000
35
#define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN)
Jan Djärv's avatar
Jan Djärv committed
36

37
/* Key for data that is valid for menus and scroll bars in a frame  */
Jan Djärv's avatar
Jan Djärv committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#define XG_FRAME_DATA "emacs_frame"

/* Key for data that menu items hold.  */
#define XG_ITEM_DATA "emacs_menuitem"

/* This is a list node in a generic list implementation.  */
typedef struct xg_list_node_
{
  struct xg_list_node_ *prev;
  struct xg_list_node_ *next;
} xg_list_node;

/* This structure is the callback data that is shared for menu items.
   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.  This structure is kept around as long as
   the menu is.  */
typedef struct xg_menu_cb_data_
{
  xg_list_node  ptrs;
58

Dmitry Antipov's avatar
Dmitry Antipov committed
59
  struct frame  *f;
Jan Djärv's avatar
Jan Djärv committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
  Lisp_Object   menu_bar_vector;
  int           menu_bar_items_used;
  GCallback     highlight_cb;
  int           ref_count;
} xg_menu_cb_data;

/* This structure holds callback information for each individual menu item.  */
typedef struct xg_menu_item_cb_data_
{
  xg_list_node  ptrs;

  gulong        select_id;
  Lisp_Object   help;
  gpointer	call_data;
  xg_menu_cb_data *cl_data;
75

Jan Djärv's avatar
Jan Djärv committed
76 77
} xg_menu_item_cb_data;

78
extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
Jan D's avatar
Jan D committed
79

Dmitry Antipov's avatar
Dmitry Antipov committed
80
extern char *xg_get_file_name (struct frame *f,
Jan D's avatar
Jan D committed
81 82
                               char *prompt,
                               char *default_filename,
83 84
                               bool mustmatch_p,
                               bool only_dir_p);
Jan D's avatar
Jan D committed
85

Dmitry Antipov's avatar
Dmitry Antipov committed
86
extern Lisp_Object xg_get_font (struct frame *f, const char *);
Jan D's avatar
Jan D committed
87

88 89
extern GtkWidget *xg_create_widget (const char *type,
                                    const char *name,
Dmitry Antipov's avatar
Dmitry Antipov committed
90
                                    struct frame *f,
91
                                    struct _widget_value *val,
Jan D's avatar
Jan D committed
92 93
                                    GCallback select_cb,
                                    GCallback deactivate_cb,
Paul Eggert's avatar
Paul Eggert committed
94
                                    GCallback highlight_cb);
Jan D's avatar
Jan D committed
95 96

extern void xg_modify_menubar_widgets (GtkWidget *menubar,
Dmitry Antipov's avatar
Dmitry Antipov committed
97
                                       struct frame *f,
98
                                       struct _widget_value *val,
99
                                       bool deep_p,
Jan D's avatar
Jan D committed
100 101
                                       GCallback select_cb,
                                       GCallback deactivate_cb,
Paul Eggert's avatar
Paul Eggert committed
102
                                       GCallback highlight_cb);
Jan D's avatar
Jan D committed
103

Dmitry Antipov's avatar
Dmitry Antipov committed
104
extern void xg_update_frame_menubar (struct frame *f);
Jan D's avatar
Jan D committed
105

106
extern bool xg_event_is_for_menubar (struct frame *, const XEvent *);
107

108
extern bool xg_have_tear_offs (struct frame *f);
Jan D's avatar
Jan D committed
109

110
extern ptrdiff_t xg_get_scroll_id_for_window (Display *dpy, Window wid);
Jan D's avatar
Jan D committed
111

Dmitry Antipov's avatar
Dmitry Antipov committed
112
extern void xg_create_scroll_bar (struct frame *f,
Jan D's avatar
Jan D committed
113 114 115
                                  struct scroll_bar *bar,
                                  GCallback scroll_callback,
                                  GCallback end_callback,
116
                                  const char *scroll_bar_name);
Dmitry Antipov's avatar
Dmitry Antipov committed
117
extern void xg_remove_scroll_bar (struct frame *f, ptrdiff_t scrollbar_id);
Jan D's avatar
Jan D committed
118

Dmitry Antipov's avatar
Dmitry Antipov committed
119
extern void xg_update_scrollbar_pos (struct frame *f,
120
                                     ptrdiff_t scrollbar_id,
Jan D's avatar
Jan D committed
121 122 123 124 125 126 127 128 129
                                     int top,
                                     int left,
                                     int width,
                                     int height);

extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
                                             int portion,
                                             int position,
                                             int whole);
130
extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *);
131
extern int xg_get_default_scrollbar_width (void);
Jan D's avatar
Jan D committed
132

Dmitry Antipov's avatar
Dmitry Antipov committed
133 134 135
extern void update_frame_tool_bar (struct frame *f);
extern void free_frame_tool_bar (struct frame *f);
extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
Jan D's avatar
Jan D committed
136

Dmitry Antipov's avatar
Dmitry Antipov committed
137
extern void xg_frame_resized (struct frame *f,
Jan D's avatar
Jan D committed
138 139
                              int pixelwidth,
                              int pixelheight);
140
extern void xg_frame_set_char_size (struct frame *f, int width, int height);
Jan D's avatar
Jan D committed
141 142 143 144 145 146
extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);

extern void xg_display_open (char *display_name, Display **dpy);
extern void xg_display_close (Display *dpy);
extern GdkCursor * xg_create_default_cursor (Display *dpy);

Dmitry Antipov's avatar
Dmitry Antipov committed
147 148 149
extern bool xg_create_frame_widgets (struct frame *f);
extern void xg_free_frame_widgets (struct frame *f);
extern void xg_set_background_color (struct frame *f, unsigned long bg);
150 151 152
extern bool xg_check_special_colors (struct frame *f,
				     const char *color_name,
				     XColor *color);
Jan D's avatar
Jan D committed
153

Dmitry Antipov's avatar
Dmitry Antipov committed
154
extern void xg_set_frame_icon (struct frame *f,
Jan D's avatar
Jan D committed
155 156
                               Pixmap icon_pixmap,
                               Pixmap icon_mask);
157

Dmitry Antipov's avatar
Dmitry Antipov committed
158
extern bool xg_prepare_tooltip (struct frame *f,
159 160 161
				Lisp_Object string,
				int *width,
				int *height);
Dmitry Antipov's avatar
Dmitry Antipov committed
162 163
extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
extern bool xg_hide_tooltip (struct frame *f);
164 165


Jan Djärv's avatar
Jan Djärv committed
166
/* Mark all callback data that are Lisp_object:s during GC.  */
Jan D's avatar
Jan D committed
167
extern void xg_mark_data (void);
Jan Djärv's avatar
Jan Djärv committed
168 169

/* Initialize GTK specific parts.  */
Jan D's avatar
Jan D committed
170
extern void xg_initialize (void);
Jan Djärv's avatar
Jan Djärv committed
171 172 173

/* Setting scrollbar values invokes the callback.  Use this variable
   to indicate that the callback should do nothing.  */
174
extern bool xg_ignore_gtk_scrollbar;
Jan Djärv's avatar
Jan Djärv committed
175 176 177

#endif /* USE_GTK */
#endif /* GTKUTIL_H */