[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Another highlighting questi
- To: "MCL list" <info-mcl@cambridge.apple.com>
- Subject: Another highlighting questi
- From: "Rodney Daughtrey" <rodney%proact@uunet.UU.NET>
- Date: 4 May 1994 19:44:38 -0600
Subject: Another highlighting question
Thanks again to Bill St. Clair for answering my first question.
Now another: I'm trying to add highlighting/selection behavior to some views
which inherit from ccl:view. I've gotten the code to work when the highlighting
color is black (using ccl:invert-rect, etc), but I'm having problems with other
colors where you don't want to invert the (usually black) text. I've written a
simple mixin (see below) for the highlighting colors other than black that
works, but it has the disadvantage of having to redraw the view each time the
view is selected/deselected. In the simple example below the redraw is hardly
noticeable, but for more complex views it flickers. What I'd really like is a
version which, when a view is selected/deselected, draws/undraws the colored
selection rectangle over the view without disturbing the foreground pixels of
the text or graphics. I've tried using the :pator pen pattern in conjunction w/
ccl:paint-rect, etc, but could not get this to work. Also, using dialog items
and their colorable parts aren't applicable for our needs.
The example below illustrates the behavior I'm after, minus the need to
redisplay each time. Does anyone have any suggestions/code that implements something
like this? Are there Macintosh traps that implement some/all of this for me?
Thanks very much!
--------------------- Code follows --------------------
;; Select mixin that works, but requires redisplay of the view every time
;; the view is selected or deselected
(defclass select-mixin ()
((selected-p
:initform nil
:accessor selected-p)))
(defmethod ccl:view-click-event-handler ((view select-mixin) where)
"Toggles selection on and off for testing"
(declare (ignore where))
(setf (selected-p view) (not (selected-p view)))
(ccl:view-draw-contents view))
(defmethod ccl:view-draw-contents :before ((view select-mixin))
(if (selected-p view)
(with-fore-color (rgb-to-color (%int-to-ptr #$hilitergb))
(ccl:paint-rect view #@(0 0) (ccl:view-size view)))
(with-fore-color ccl:*white-color*
(ccl:paint-rect view #@(0 0) (ccl:view-size view)))))
;; Now use the mixin
(defclass some-view (select-mixin ccl:view) ())
(defmethod ccl:view-draw-contents ((view some-view))
(ccl:move-to view #@(5 10))
(format view "Hello"))
;; Run (test) and click on the text to see it highlight/unhighlight
(defun test ()
(make-instance 'ccl:window
:color-p t
:view-subviews (list (make-instance 'some-view
:view-position #@(50 50)
:view-size #@(100 20)))))
---------------------
Rodney Daughtrey Domain: rodney@pro-solution.com
Proactive Solutions Inc. UUCP: uunet!proact!rodney
5314 S. Yale Ave., Suite 402 Voice: 918.492.5199
Tulsa, OK 74135 FAX: 918.492.5193