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

scrolling-view & clip regions



I'm having quite a time trying to do what should be very simple.

I have a window that is descended from ccl::scrolling-window. The
problem is that ccl::scrolling windows doesn't set the clip region
properly when you resize it (i.e. the invalid region includes the
scroll bars, even after they are redrawn).  All my contained views
draw into the scroll bar area if you make the window too small.

Normally in writing such a routine, the resize-window routines first
erase the bad areas, redraw the scroll bars, then remove the scroll bar
area from the invalid region before calling the methods that draw the 
contents of the window.

I've written the following routine and tried placing it in several
parts of the hiearchy without success.  I've tried placing it as:

window-grow-event-handler (before and after)
set-view-size (before and after)
view-draw-contents (before and after)

but to no avail.  

Where should this routine go?
When does MCL call the routines to draw:
 a) the scroll bars?
 b) the grow icon?
 c) the views?


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Some quick classes and a drawing routine to illustrate the problem
;;

(defclass TScrolling-Window (ccl::scrolling-window)
  nil
  (:documentation "Descended from ccl::scrolling-window"))

(defclass TSquare-View (view)
  nil
  (:documentation "Just so we can see when the above won't draw correctly"))

(defmethod view-draw-contents ((me TSquare-View))
  (with-fore-color *red-color*
    (paint-rect me 0 0 (point-h (view-size me)) (point-v (view-size me)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; A general glue routine
;;

(defun validate-rect (left top right bottom)
  "Invalidates the given rectange in the current view, assumes view is focused"
  (with-macptrs ((theRgn (#_newrgn)))
    (unless (%null-ptr-p theRgn)
      (#_setrectrgn theRgn left top right bottom)
      (#_validrgn theRgn)
      (#_disposergn theRgn))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This is the method that resets the
;; valid region to exclude the scroll bars
;;

(defmethod window-grow-event-handler :after ((me TScrolling-Window) where)
  ;; set the clip region to exclude the scroll bars & grow icon
  ;; should be called from the routine that resizes a window?!
  ;; 

  (let ((v (point-v where))
        (h (point-h where)))
  (print "I'm in here!")
  (with-focused-view me
    (move-to me 0 0)
    (paint-oval me 0 0 10 10)
      
      ;left scroll bar
      (validate-rect (- h 16)
                     0
                     h
                     v)
      ;bottom-scroll-bar
      (validate-rect 0
                     (- v 16)
                     h
                     v))))


(make-instance 'TScrolling-Window
  :window-title "Garbage"
  :view-subviews (list (make-instance 'TSquare-View
                   :view-size #@(400 200))))