comparison src/scrollbar.c @ 5495:1f0b15040456

Merge.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 01 May 2011 18:44:03 +0100
parents 308d34e9f07d
children 56144c8593a8
comparison
equal deleted inserted replaced
5494:861f2601a38b 5495:1f0b15040456
1 /* Generic scrollbar implementation. 1 /* Generic scrollbar implementation.
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3 Copyright (C) 1995 Free Software Foundation, Inc. 3 Copyright (C) 1995 Free Software Foundation, Inc.
4 Copyright (C) 1995 Sun Microsystems, Inc. 4 Copyright (C) 1995 Sun Microsystems, Inc.
5 Copyright (C) 1995 Darrell Kindred <dkindred+@cmu.edu>. 5 Copyright (C) 1995 Darrell Kindred <dkindred+@cmu.edu>.
6 Copyright (C) 2003 Ben Wing. 6 Copyright (C) 2003, 2010 Ben Wing.
7 7
8 This file is part of XEmacs. 8 This file is part of XEmacs.
9 9
10 XEmacs is free software; you can redistribute it and/or modify it 10 XEmacs is free software: you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by the 11 under the terms of the GNU General Public License as published by the
12 Free Software Foundation; either version 2, or (at your option) any 12 Free Software Foundation, either version 3 of the License, or (at your
13 later version. 13 option) any later version.
14 14
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT 15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 for more details. 18 for more details.
19 19
20 You should have received a copy of the GNU General Public License 20 You should have received a copy of the GNU General Public License
21 along with XEmacs; see the file COPYING. If not, write to 21 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24 22
25 /* Synched up with: Not in FSF. */ 23 /* Synched up with: Not in FSF. */
26 24
27 /* This file has been Mule-ized. */ 25 /* This file has been Mule-ized. */
28 26
94 return wrap_scrollbar_instance (data->next); 92 return wrap_scrollbar_instance (data->next);
95 else 93 else
96 return Qnil; 94 return Qnil;
97 } 95 }
98 96
99 DEFINE_LRECORD_IMPLEMENTATION ("scrollbar-instance", scrollbar_instance, 97 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("scrollbar-instance", scrollbar_instance,
100 0, /*dumpable-flag*/ 98 mark_scrollbar_instance,
101 mark_scrollbar_instance, 99 scrollbar_instance_description,
102 internal_object_printer, 0, 0, 0, 100 struct scrollbar_instance);
103 scrollbar_instance_description,
104 struct scrollbar_instance);
105 101
106 static void 102 static void
107 free_scrollbar_instance (struct scrollbar_instance *instance, 103 free_scrollbar_instance (struct scrollbar_instance *instance,
108 struct frame *frame) 104 struct frame *frame)
109 { 105 {
112 else 108 else
113 { 109 {
114 struct device *d = XDEVICE (frame->device); 110 struct device *d = XDEVICE (frame->device);
115 111
116 MAYBE_DEVMETH (d, free_scrollbar_instance, (instance)); 112 MAYBE_DEVMETH (d, free_scrollbar_instance, (instance));
117 /* not worth calling free_managed_lcrecord() -- scrollbar instances 113 /* not worth calling free_normal_lisp_object() -- scrollbar instances
118 are not created that frequently and it's dangerous. */ 114 are not created that frequently and it's dangerous. */
119 } 115 }
120 } 116 }
121 117
122 static void 118 static void
196 192
197 static struct scrollbar_instance * 193 static struct scrollbar_instance *
198 create_scrollbar_instance (struct frame *f, int vertical) 194 create_scrollbar_instance (struct frame *f, int vertical)
199 { 195 {
200 struct device *d = XDEVICE (f->device); 196 struct device *d = XDEVICE (f->device);
201 struct scrollbar_instance *instance = 197 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (scrollbar_instance);
202 ALLOC_LCRECORD_TYPE (struct scrollbar_instance, 198 struct scrollbar_instance *instance = XSCROLLBAR_INSTANCE (obj);
203 &lrecord_scrollbar_instance);
204 199
205 MAYBE_DEVMETH (d, create_scrollbar_instance, (f, vertical, instance)); 200 MAYBE_DEVMETH (d, create_scrollbar_instance, (f, vertical, instance));
206 201
207 return instance; 202 return instance;
208 } 203 }
258 } 253 }
259 #undef RELEASE_SCROLLBAR_INSTANCE_INTERNAL 254 #undef RELEASE_SCROLLBAR_INSTANCE_INTERNAL
260 255
261 #ifdef MEMORY_USAGE_STATS 256 #ifdef MEMORY_USAGE_STATS
262 257
263 int 258 struct scrollbar_instance_stats
264 compute_scrollbar_instance_usage (struct device *d, 259 {
265 struct scrollbar_instance *inst, 260 struct usage_stats u;
266 struct overhead_stats *ovstats) 261 Bytecount device_data;
267 { 262 };
268 int total = 0; 263
269 264 Bytecount
270 if (HAS_DEVMETH_P(d, compute_scrollbar_instance_usage)) 265 compute_all_scrollbar_instance_usage (struct scrollbar_instance *inst)
271 total += DEVMETH (d, compute_scrollbar_instance_usage, (d, inst, ovstats)); 266 {
267 Bytecount total = 0;
272 268
273 while (inst) 269 while (inst)
274 { 270 {
275 total += LISPOBJ_STORAGE_SIZE (inst, sizeof (*inst), ovstats); 271 total += lisp_object_memory_usage (wrap_scrollbar_instance (inst));
276 inst = inst->next; 272 inst = inst->next;
277 } 273 }
278 274
279 return total; 275 return total;
276 }
277
278 static void
279 scrollbar_instance_memory_usage (Lisp_Object scrollbar_instance,
280 struct generic_usage_stats *gustats)
281 {
282 struct scrollbar_instance_stats *stats =
283 (struct scrollbar_instance_stats *) gustats;
284 struct scrollbar_instance *inst = XSCROLLBAR_INSTANCE (scrollbar_instance);
285 struct device *d = FRAME_XDEVICE (inst->mirror->frame);
286 Bytecount total = 0;
287
288 if (HAS_DEVMETH_P (d, compute_scrollbar_instance_usage))
289 total += DEVMETH (d, compute_scrollbar_instance_usage, (d, inst,
290 &gustats->u));
291
292 stats->device_data = total;
280 } 293 }
281 294
282 #endif /* MEMORY_USAGE_STATS */ 295 #endif /* MEMORY_USAGE_STATS */
283 296
284 void 297 void
924 /************************************************************************/ 937 /************************************************************************/
925 /* initialization */ 938 /* initialization */
926 /************************************************************************/ 939 /************************************************************************/
927 940
928 void 941 void
942 scrollbar_objects_create (void)
943 {
944 #ifdef MEMORY_USAGE_STATS
945 OBJECT_HAS_METHOD (scrollbar_instance, memory_usage);
946 #endif
947 }
948 void
929 syms_of_scrollbar (void) 949 syms_of_scrollbar (void)
930 { 950 {
931 INIT_LRECORD_IMPLEMENTATION (scrollbar_instance); 951 INIT_LISP_OBJECT (scrollbar_instance);
932 952
933 DEFSYMBOL (Qscrollbar_line_up); 953 DEFSYMBOL (Qscrollbar_line_up);
934 DEFSYMBOL (Qscrollbar_line_down); 954 DEFSYMBOL (Qscrollbar_line_down);
935 DEFSYMBOL (Qscrollbar_page_up); 955 DEFSYMBOL (Qscrollbar_page_up);
936 DEFSYMBOL (Qscrollbar_page_down); 956 DEFSYMBOL (Qscrollbar_page_down);
962 } 982 }
963 983
964 void 984 void
965 vars_of_scrollbar (void) 985 vars_of_scrollbar (void)
966 { 986 {
987 #ifdef MEMORY_USAGE_STATS
988 OBJECT_HAS_PROPERTY
989 (scrollbar_instance, memusage_stats_list,
990 list1 (intern ("device-data")));
991 #endif /* MEMORY_USAGE_STATS */
992
967 DEFVAR_LISP ("scrollbar-pointer-glyph", &Vscrollbar_pointer_glyph /* 993 DEFVAR_LISP ("scrollbar-pointer-glyph", &Vscrollbar_pointer_glyph /*
968 *The shape of the mouse-pointer when over a scrollbar. 994 *The shape of the mouse-pointer when over a scrollbar.
969 This is a glyph; use `set-glyph-image' to change it. 995 This is a glyph; use `set-glyph-image' to change it.
970 If unspecified in a particular domain, the window-system-provided 996 If unspecified in a particular domain, the window-system-provided
971 default pointer is used. 997 default pointer is used.