comparison src/scrollbar.c @ 5178:97eb4942aec8

merge
author Ben Wing <ben@xemacs.org>
date Mon, 29 Mar 2010 21:28:13 -0500
parents 5ddbab03b0e6
children 308d34e9f07d
comparison
equal deleted inserted replaced
5177:b785049378e3 5178:97eb4942aec8
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
94 return wrap_scrollbar_instance (data->next); 94 return wrap_scrollbar_instance (data->next);
95 else 95 else
96 return Qnil; 96 return Qnil;
97 } 97 }
98 98
99 DEFINE_LRECORD_IMPLEMENTATION ("scrollbar-instance", scrollbar_instance, 99 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("scrollbar-instance", scrollbar_instance,
100 0, /*dumpable-flag*/ 100 mark_scrollbar_instance,
101 mark_scrollbar_instance, 101 scrollbar_instance_description,
102 internal_object_printer, 0, 0, 0, 102 struct scrollbar_instance);
103 scrollbar_instance_description,
104 struct scrollbar_instance);
105 103
106 static void 104 static void
107 free_scrollbar_instance (struct scrollbar_instance *instance, 105 free_scrollbar_instance (struct scrollbar_instance *instance,
108 struct frame *frame) 106 struct frame *frame)
109 { 107 {
112 else 110 else
113 { 111 {
114 struct device *d = XDEVICE (frame->device); 112 struct device *d = XDEVICE (frame->device);
115 113
116 MAYBE_DEVMETH (d, free_scrollbar_instance, (instance)); 114 MAYBE_DEVMETH (d, free_scrollbar_instance, (instance));
117 /* not worth calling free_managed_lcrecord() -- scrollbar instances 115 /* not worth calling free_normal_lisp_object() -- scrollbar instances
118 are not created that frequently and it's dangerous. */ 116 are not created that frequently and it's dangerous. */
119 } 117 }
120 } 118 }
121 119
122 static void 120 static void
196 194
197 static struct scrollbar_instance * 195 static struct scrollbar_instance *
198 create_scrollbar_instance (struct frame *f, int vertical) 196 create_scrollbar_instance (struct frame *f, int vertical)
199 { 197 {
200 struct device *d = XDEVICE (f->device); 198 struct device *d = XDEVICE (f->device);
201 struct scrollbar_instance *instance = 199 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (scrollbar_instance);
202 ALLOC_LCRECORD_TYPE (struct scrollbar_instance, 200 struct scrollbar_instance *instance = XSCROLLBAR_INSTANCE (obj);
203 &lrecord_scrollbar_instance);
204 201
205 MAYBE_DEVMETH (d, create_scrollbar_instance, (f, vertical, instance)); 202 MAYBE_DEVMETH (d, create_scrollbar_instance, (f, vertical, instance));
206 203
207 return instance; 204 return instance;
208 } 205 }
258 } 255 }
259 #undef RELEASE_SCROLLBAR_INSTANCE_INTERNAL 256 #undef RELEASE_SCROLLBAR_INSTANCE_INTERNAL
260 257
261 #ifdef MEMORY_USAGE_STATS 258 #ifdef MEMORY_USAGE_STATS
262 259
263 int 260 struct scrollbar_instance_stats
264 compute_scrollbar_instance_usage (struct device *d, 261 {
265 struct scrollbar_instance *inst, 262 struct usage_stats u;
266 struct overhead_stats *ovstats) 263 Bytecount device_data;
267 { 264 };
268 int total = 0; 265
269 266 Bytecount
270 if (HAS_DEVMETH_P(d, compute_scrollbar_instance_usage)) 267 compute_all_scrollbar_instance_usage (struct scrollbar_instance *inst)
271 total += DEVMETH (d, compute_scrollbar_instance_usage, (d, inst, ovstats)); 268 {
269 Bytecount total = 0;
272 270
273 while (inst) 271 while (inst)
274 { 272 {
275 total += LISPOBJ_STORAGE_SIZE (inst, sizeof (*inst), ovstats); 273 total += lisp_object_memory_usage (wrap_scrollbar_instance (inst));
276 inst = inst->next; 274 inst = inst->next;
277 } 275 }
278 276
279 return total; 277 return total;
278 }
279
280 static void
281 scrollbar_instance_memory_usage (Lisp_Object scrollbar_instance,
282 struct generic_usage_stats *gustats)
283 {
284 struct scrollbar_instance_stats *stats =
285 (struct scrollbar_instance_stats *) gustats;
286 struct scrollbar_instance *inst = XSCROLLBAR_INSTANCE (scrollbar_instance);
287 struct device *d = FRAME_XDEVICE (inst->mirror->frame);
288 Bytecount total = 0;
289
290 if (HAS_DEVMETH_P (d, compute_scrollbar_instance_usage))
291 total += DEVMETH (d, compute_scrollbar_instance_usage, (d, inst,
292 &gustats->u));
293
294 stats->device_data = total;
280 } 295 }
281 296
282 #endif /* MEMORY_USAGE_STATS */ 297 #endif /* MEMORY_USAGE_STATS */
283 298
284 void 299 void
924 /************************************************************************/ 939 /************************************************************************/
925 /* initialization */ 940 /* initialization */
926 /************************************************************************/ 941 /************************************************************************/
927 942
928 void 943 void
944 scrollbar_objects_create (void)
945 {
946 #ifdef MEMORY_USAGE_STATS
947 OBJECT_HAS_METHOD (scrollbar_instance, memory_usage);
948 #endif
949 }
950 void
929 syms_of_scrollbar (void) 951 syms_of_scrollbar (void)
930 { 952 {
931 INIT_LRECORD_IMPLEMENTATION (scrollbar_instance); 953 INIT_LISP_OBJECT (scrollbar_instance);
932 954
933 DEFSYMBOL (Qscrollbar_line_up); 955 DEFSYMBOL (Qscrollbar_line_up);
934 DEFSYMBOL (Qscrollbar_line_down); 956 DEFSYMBOL (Qscrollbar_line_down);
935 DEFSYMBOL (Qscrollbar_page_up); 957 DEFSYMBOL (Qscrollbar_page_up);
936 DEFSYMBOL (Qscrollbar_page_down); 958 DEFSYMBOL (Qscrollbar_page_down);
962 } 984 }
963 985
964 void 986 void
965 vars_of_scrollbar (void) 987 vars_of_scrollbar (void)
966 { 988 {
989 #ifdef MEMORY_USAGE_STATS
990 OBJECT_HAS_PROPERTY
991 (scrollbar_instance, memusage_stats_list,
992 list1 (intern ("device-data")));
993 #endif /* MEMORY_USAGE_STATS */
994
967 DEFVAR_LISP ("scrollbar-pointer-glyph", &Vscrollbar_pointer_glyph /* 995 DEFVAR_LISP ("scrollbar-pointer-glyph", &Vscrollbar_pointer_glyph /*
968 *The shape of the mouse-pointer when over a scrollbar. 996 *The shape of the mouse-pointer when over a scrollbar.
969 This is a glyph; use `set-glyph-image' to change it. 997 This is a glyph; use `set-glyph-image' to change it.
970 If unspecified in a particular domain, the window-system-provided 998 If unspecified in a particular domain, the window-system-provided
971 default pointer is used. 999 default pointer is used.