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

Paul Eggert's avatar
Paul Eggert committed
3
Copyright (C) 2003-2015 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)
36 37 38
#define YG_SB_MIN 1
#define YG_SB_MAX 10000000
#define YG_SB_RANGE (YG_SB_MAX-YG_SB_MIN)
Jan Djärv's avatar
Jan Djärv committed
39

40
/* Key for data that is valid for menus and scroll bars in a frame  */
Jan Djärv's avatar
Jan Djärv committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
#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;
61

Dmitry Antipov's avatar
Dmitry Antipov committed
62
  struct frame  *f;
Jan Djärv's avatar
Jan Djärv committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
  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;
78

Jan Djärv's avatar
Jan Djärv committed
79 80
} xg_menu_item_cb_data;

81
extern bool xg_uses_old_file_dialog (void);
Jan D's avatar
Jan D committed
82

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

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

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

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

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

109
extern bool xg_event_is_for_menubar (struct frame *, const XEvent *);
110

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

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

Dmitry Antipov's avatar
Dmitry Antipov committed
125
extern void xg_update_scrollbar_pos (struct frame *f,
126
                                     ptrdiff_t scrollbar_id,
Jan D's avatar
Jan D committed
127 128 129 130
                                     int top,
                                     int left,
                                     int width,
                                     int height);
131 132 133 134 135 136
extern void xg_update_horizontal_scrollbar_pos (struct frame *f,
						ptrdiff_t scrollbar_id,
						int top,
						int left,
						int width,
						int height);
Jan D's avatar
Jan D committed
137 138 139 140 141

extern void xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
                                             int portion,
                                             int position,
                                             int whole);
142 143 144 145
extern void xg_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar,
							int portion,
							int position,
							int whole);
146
extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *);
147
extern int xg_get_default_scrollbar_width (void);
148
extern int xg_get_default_scrollbar_height (void);
Jan D's avatar
Jan D committed
149

Dmitry Antipov's avatar
Dmitry Antipov committed
150 151 152
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
153

154
extern void xg_clear_under_internal_border (struct frame *f);
Dmitry Antipov's avatar
Dmitry Antipov committed
155
extern void xg_frame_resized (struct frame *f,
Jan D's avatar
Jan D committed
156 157
                              int pixelwidth,
                              int pixelheight);
158
extern void xg_frame_set_char_size (struct frame *f, int width, int height);
Jan D's avatar
Jan D committed
159 160 161 162 163 164
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
165 166 167
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);
168 169 170
extern bool xg_check_special_colors (struct frame *f,
				     const char *color_name,
				     XColor *color);
Jan D's avatar
Jan D committed
171

Dmitry Antipov's avatar
Dmitry Antipov committed
172
extern void xg_set_frame_icon (struct frame *f,
Jan D's avatar
Jan D committed
173 174
                               Pixmap icon_pixmap,
                               Pixmap icon_mask);
175

Dmitry Antipov's avatar
Dmitry Antipov committed
176
extern bool xg_prepare_tooltip (struct frame *f,
177 178 179
				Lisp_Object string,
				int *width,
				int *height);
Dmitry Antipov's avatar
Dmitry Antipov committed
180 181
extern void xg_show_tooltip (struct frame *f, int root_x, int root_y);
extern bool xg_hide_tooltip (struct frame *f);
182

Jan Djärv's avatar
Jan Djärv committed
183
/* Mark all callback data that are Lisp_object:s during GC.  */
Jan D's avatar
Jan D committed
184
extern void xg_mark_data (void);
Jan Djärv's avatar
Jan Djärv committed
185 186

/* Initialize GTK specific parts.  */
Jan D's avatar
Jan D committed
187
extern void xg_initialize (void);
Jan Djärv's avatar
Jan Djärv committed
188 189 190

/* Setting scrollbar values invokes the callback.  Use this variable
   to indicate that the callback should do nothing.  */
191
extern bool xg_ignore_gtk_scrollbar;
Jan Djärv's avatar
Jan Djärv committed
192 193 194

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