[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Displaying LONG lists of items

We are experiencing a problem that users out there have probably 
(possibly) solved.  I'd love some advice...

The problem deals with displaying potentially long lists of orders (under
Symbolics Genera 7.1) that the user will scroll through in the interactive 
scheduling process.  Currently we are using dynamic windows with built-in 
scrolling functions.  The problem is that the software must first write in 
ALL the objects to the underlying window even if the user will only be able 
to see a small number of objects at at time.  Since displaying 1000 objects 
takes ~70 seconds and displaying 10 objects takes under one seconds, we would 
like to write to the window only what the user can see.

Here is how I (naively?) think the problem could be avoided.

Initializing the window:

1.  Tell the window how many elements it will be displaying.  (the size)
2.  Fill the viewport with the first N elements (of a list) that fit.
3.  Update the scroll bar

Telling the window a priori how many elements it would contain would allow
the scroll bar and elevator to accurately reflect the contents of the list.

Updating the display:

1.  Find location of the mouse click
2.  Find the N objects in the list that correspond to the location of the
mouse click.  (i.e. index into the list)
3.  Display those N objects in the viewport.

This approach would allow a window (containing potentially huge number
of elements) to only deal with a small number of objects at a time, yet
still have a properly reflective scroll bar.

Hope all this makes some sense.  If you have any suggestions, comments, or
questions, please send them to me.  Thanks in advance 

	Doug Schuler     (206) 865-3226

Here is sample code to play with...

;;; -*- Mode: LISP; Syntax: Common-lisp; Base: 10; 

;;;Compile the file and try it by executing the form ==> (test 1000)

(defvar *MY-WINDOW*
	(tv:make-window 'dw:dynamic-window
			:edges '(200 200 600 700)
			:end-of-page-mode :truncate
			:blinker-p nil
			  (dw:margin-label :margin :top
					   :string "                   My Window"
					   :style (:sans-serif :bold :large))
			  (dw:margin-whitespace :margin :top :thickness 5)
			  (dw:margin-whitespace :margin :left :thickness 2)
			:default-character-style '(:swiss :bold :normal)))

(defvar *list-of-items* nil)

(defun make-list-of-item (number)
	(let (a-list)
	  (dotimes (x number)
	    (push (string-append "Test Item # " (format nil "~D" x))
	  (reverse a-list)))
(defun test (number)
  (let ((y-display-loc 10)
	(y-display-inc 15))
    (format t "~% ==> Creating display items")
    (setq *list-of-items* (make-list-of-item number))
    (format t "~% ==> Starting to display items - watch run bars to see when it finishes")
    (send *my-window* :clear-history)
    (send *my-window* :expose)
    (dolist (item *list-of-items*)
      (graphics:draw-string item 10 y-display-loc :stream *my-window*)
      (setq y-display-loc (+ y-display-loc y-display-inc)))))

(defflavor test-window ()
	   (tv:text-scroll-window tv:window))