annotate src/gtk-xemacs.c @ 733:b1f74adcc1ff

[xemacs-hg @ 2002-01-22 20:40:00 by janv] Fix disabled-command-hook
author janv
date Tue, 22 Jan 2002 20:40:03 +0000
parents 0784d089fdc9
children 8ae895c67ce7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 /* gtk-xemacs.c
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 ** Description: A widget to encapsulate a XEmacs 'text widget'
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5 ** Created by: William M. Perry
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 ** Copyright (c) 2000 William M. Perry <wmperry@gnu.org>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7 **
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
11
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13 #include "console-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14 #include "objects-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15 #include "gtk-xemacs.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16 #include "window.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17 #include "faces.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19 extern Lisp_Object Vmodeline_face;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 extern Lisp_Object Vscrollbar_on_left_p;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22 EXFUN (Fmake_image_instance, 4);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24 static void gtk_xemacs_class_init (GtkXEmacsClass *klass);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25 static void gtk_xemacs_init (GtkXEmacs *xemacs);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26 static void gtk_xemacs_size_allocate (GtkWidget *widget, GtkAllocation *allocaction);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 static void gtk_xemacs_draw (GtkWidget *widget, GdkRectangle *area);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 static void gtk_xemacs_paint (GtkWidget *widget, GdkRectangle *area);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 static void gtk_xemacs_size_request (GtkWidget *widget, GtkRequisition *requisition);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 static void gtk_xemacs_realize (GtkWidget *widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 static void gtk_xemacs_style_set (GtkWidget *widget, GtkStyle *previous_style);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32 static gint gtk_xemacs_expose (GtkWidget *widget, GdkEventExpose *event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
34 guint
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
35 gtk_xemacs_get_type (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 static guint xemacs_type = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39 if (!xemacs_type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 static const GtkTypeInfo xemacs_info =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43 "GtkXEmacs",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 sizeof (GtkXEmacs),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45 sizeof (GtkXEmacsClass),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 (GtkClassInitFunc) gtk_xemacs_class_init,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 (GtkObjectInitFunc) gtk_xemacs_init,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 /* reserved_1 */ NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49 /* reserved_2 */ NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 (GtkClassInitFunc) NULL,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 };
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 xemacs_type = gtk_type_unique (gtk_fixed_get_type (), &xemacs_info);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 return xemacs_type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 static GtkWidgetClass *parent_class;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 extern gint emacs_gtk_button_event_handler(GtkWidget *widget, GdkEventButton *event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 extern gint emacs_gtk_key_event_handler(GtkWidget *widget, GdkEventKey *event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 extern gint emacs_gtk_motion_event_handler(GtkWidget *widget, GdkEventMotion *event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 gtk_xemacs_class_init (GtkXEmacsClass *class)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 GtkWidgetClass *widget_class;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70 widget_class = (GtkWidgetClass*) class;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 parent_class = (GtkWidgetClass *) gtk_type_class (gtk_fixed_get_type ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73 widget_class->size_allocate = gtk_xemacs_size_allocate;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74 widget_class->size_request = gtk_xemacs_size_request;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
75 widget_class->draw = gtk_xemacs_draw;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76 widget_class->expose_event = gtk_xemacs_expose;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 widget_class->realize = gtk_xemacs_realize;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 widget_class->button_press_event = emacs_gtk_button_event_handler;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 widget_class->button_release_event = emacs_gtk_button_event_handler;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 widget_class->key_press_event = emacs_gtk_key_event_handler;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81 widget_class->key_release_event = emacs_gtk_key_event_handler;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82 widget_class->motion_notify_event = emacs_gtk_motion_event_handler;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 widget_class->style_set = gtk_xemacs_style_set;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 gtk_xemacs_init (GtkXEmacs *xemacs)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 GTK_WIDGET_SET_FLAGS (xemacs, GTK_CAN_FOCUS);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 GtkWidget*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 gtk_xemacs_new (struct frame *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 GtkXEmacs *xemacs;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 xemacs = gtk_type_new (gtk_xemacs_get_type ());
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 xemacs->f = f;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100 return GTK_WIDGET (xemacs);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 __nuke_background_items (GtkWidget *widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 /* This bit of voodoo is here to get around the annoying flicker
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 when GDK tries to futz with our background pixmap as well as
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 XEmacs doing it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110 We do NOT set the background of this widget window, that way
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111 there is NO flickering, etc. The downside is the XEmacs frame
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 appears as 'seethru' when XEmacs is too busy to redraw the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 frame.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 Well, wait, we do... otherwise there sre weird 'seethru' areas
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 even when XEmacs does a full redisplay. Most noticable in some
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 areas of the modeline, or in the right-hand-side of the window
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118 between the scrollbar ad n the edge of the window.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 if (widget->window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 gdk_window_set_back_pixmap (widget->window, NULL, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 gdk_window_set_back_pixmap (widget->parent->window, NULL, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 gdk_window_set_background (widget->parent->window,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 &widget->style->bg[GTK_STATE_NORMAL]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 gdk_window_set_background (widget->window,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 &widget->style->bg[GTK_STATE_NORMAL]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 extern Lisp_Object xemacs_gtk_convert_color(GdkColor *c, GtkWidget *w);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 /* From objects-gtk.c */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 extern Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 #define convert_font(f) __get_gtk_font_truename (f, 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 smash_face_fallbacks (struct frame *f, GtkStyle *style)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 #define FROB(face,prop,slot) do { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 Lisp_Object fallback = Qnil; \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 Lisp_Object specifier = Fget (face, prop, Qnil); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 struct Lisp_Specifier *sp = NULL; \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 if (NILP (specifier)) continue; \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 sp = XSPECIFIER (specifier); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 fallback = sp->fallback; \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 if (EQ (Fcar (Fcar (Fcar (fallback))), Qgtk)) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 fallback = XCDR (fallback); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 if (! NILP (slot)) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 fallback = acons (list1 (Qgtk), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152 slot, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 fallback); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 set_specifier_fallback (specifier, fallback); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 } while (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 #define FROB_FACE(face,fg_slot,bg_slot) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 do { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 FROB (face, Qforeground, xemacs_gtk_convert_color (&style->fg_slot[GTK_STATE_NORMAL], FRAME_GTK_SHELL_WIDGET (f))); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159 FROB (face, Qbackground, xemacs_gtk_convert_color (&style->bg_slot[GTK_STATE_NORMAL], FRAME_GTK_SHELL_WIDGET (f))); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160 if (style->rc_style && style->rc_style->bg_pixmap_name[GTK_STATE_NORMAL]) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161 { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162 FROB (Vdefault_face, Qbackground_pixmap, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 Fmake_image_instance (build_string (style->rc_style->bg_pixmap_name[GTK_STATE_NORMAL]), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 f->device, Qnil, make_int (5))); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 } \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 else \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 FROB (Vdefault_face, Qbackground_pixmap, Qnil); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 } \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 } while (0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 FROB (Vdefault_face, Qfont, convert_font (style->font));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 FROB_FACE (Vdefault_face, fg, bg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 FROB_FACE (Vgui_element_face, text, mid);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 #undef FROB
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 #undef FROB_FACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 #ifdef HAVE_SCROLLBARS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 smash_scrollbar_specifiers (struct frame *f, GtkStyle *style)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 Lisp_Object frame;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 int slider_size = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 int hsize, vsize;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 GtkRangeClass *klass;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 XSETFRAME (frame, f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 klass = (GtkRangeClass *) gtk_type_class (GTK_TYPE_SCROLLBAR);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 slider_size = klass->slider_width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 hsize = slider_size + (style->klass->ythickness * 2);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194 vsize = slider_size + (style->klass->xthickness * 2);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 style = gtk_style_attach (style,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 GTK_WIDGET (DEVICE_GTK_APP_SHELL (XDEVICE (FRAME_DEVICE (f))))->window);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 Fadd_spec_to_specifier (Vscrollbar_width, make_int (vsize), frame, Qnil, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 Fadd_spec_to_specifier (Vscrollbar_height, make_int (hsize), frame, Qnil, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203 #define smash_scrollbar_specifiers(x,y)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204 #endif /* HAVE_SCROLLBARS */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 gtk_xemacs_realize (GtkWidget *widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 parent_class->realize (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210 gtk_xemacs_style_set (widget, gtk_widget_get_style (widget));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 gtk_xemacs_style_set (GtkWidget *widget, GtkStyle *previous_style)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216 GtkStyle *new_style = gtk_widget_get_style (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 GtkXEmacs *x = GTK_XEMACS (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 parent_class->style_set (widget, previous_style);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221 if (x->f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 __nuke_background_items (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225 smash_face_fallbacks (x->f, new_style);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 smash_scrollbar_specifiers (x->f, new_style);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
229 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232 gtk_xemacs_size_request (GtkWidget *widget, GtkRequisition *requisition)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
234 GtkXEmacs *x = GTK_XEMACS (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 struct frame *f = GTK_XEMACS_FRAME (x);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 int width, height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 if (f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 char_to_pixel_size (f, FRAME_WIDTH (f), FRAME_HEIGHT (f),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 &width, &height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242 requisition->width = width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243 requisition->height = height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 parent_class->size_request (widget, requisition);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252 gtk_xemacs_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 GtkXEmacs *x = GTK_XEMACS (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 struct frame *f = GTK_XEMACS_FRAME (x);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 int columns, rows;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 parent_class->size_allocate(widget, allocation);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 if (f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 f->pixwidth = allocation->width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 f->pixheight = allocation->height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 pixel_to_char_size (f,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 allocation->width,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 allocation->height, &columns, &rows);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 change_frame_size (f, rows, columns, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 gtk_xemacs_paint (GtkWidget *widget, GdkRectangle *area)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 GtkXEmacs *x = GTK_XEMACS (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 struct frame *f = GTK_XEMACS_FRAME (x);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 gtk_redraw_exposed_area (f, area->x, area->y, area->width, area->height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 gtk_xemacs_draw (GtkWidget *widget, GdkRectangle *area)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 GtkFixed *fixed = GTK_FIXED (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 GtkFixedChild *child;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 GdkRectangle child_area;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 GList *children;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 /* I need to manually iterate over the children instead of just
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 chaining to parent_class->draw() because it calls
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 gtk_fixed_paint() directly, which clears the background window,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292 which causes A LOT of flashing. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 gtk_xemacs_paint (widget, area);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 children = fixed->children;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 while (children)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 child = children->data;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 children = children->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 /* #### This is what causes the scrollbar flickering!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 Evidently the scrollbars pretty much take care of drawing
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 themselves in most cases. Then we come along and tell them
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 to redraw again!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 But if we just leave it out, then they do not get drawn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 correctly the first time!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 Scrollbar flickering has been greatly helped by the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 optimizations in scrollbar-gtk.c /
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 gtk_update_scrollbar_instance_status (), so this is not that
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 big a deal anymore.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 if (gtk_widget_intersect (child->widget, area, &child_area))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 gtk_widget_draw (child->widget, &child_area);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 static gint
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 gtk_xemacs_expose (GtkWidget *widget, GdkEventExpose *event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 GtkXEmacs *x = GTK_XEMACS (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 struct frame *f = GTK_XEMACS_FRAME (x);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 GdkRectangle *a = &event->area;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 /* This takes care of drawing the scrollbars, etc */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 parent_class->expose_event (widget, event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 /* Now draw the actual frame data */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333 if (!check_for_ignored_expose (f, a->x, a->y, a->width, a->height) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 !find_matching_subwindow (f, a->x, a->y, a->width, a->height))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 gtk_redraw_exposed_area (f, a->x, a->y, a->width, a->height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 return (TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 xemacs_gtk_convert_color(GdkColor *c, GtkWidget *w)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 char color_buf[255];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 sprintf (color_buf, "#%04x%04x%04x", c->red, c->green, c->blue);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
346 return (build_string (color_buf));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
347 }