[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Minor fix to Text-Edit-Dialog-Item
- Subject: Minor fix to Text-Edit-Dialog-Item
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Wed, 14 Jul 1993 09:28:29 -0500
At 3:13 AM 7/14/93 +0000, Wong Joo Fung wrote:
>Hi:
>
>I couldn't get the following text centered (ie, it was always left justified).
>
> (setq test (make-instance 'text-edit-dialog-item
> :dialog-item-text "This text should be justified"
> :text-justification #$teCenter
> :view-position #@(16 16)
> :view-size #@(200 16)))
> (setq foo (make-instance 'dialog))
> (add-subviews foo test)
>
>And so I made a one-line fix (added a #_TESetJust) to the following method in
>Text-Edit-Dialog-Item.lisp.
>
>Best regards,
>JooFung Wong
>Research Scholar
>Institute of Systems Science
>SINGAPORE
>
>P.S. The code for the method follows:
>[...]
Thank you for the bug fix. Your fix is the right idea, but not quite in
the right place. The setting of the TERec justification belongs in the
DIALOG-TE-HANDLE method, not in the VIEW-DRAW-CONTENTS method. I have
changed our sources as follows:
(defmethod dialog-te-handle ((w window) &optional select)
(without-interrupts
(let* ((hTE (get-*te-handle*))
(item *te-handle-dialog-item*)
(current-text (current-key-handler w)))
(cond ((not (typep current-text 'text-edit-dialog-item)) ; ignore fred-dialog-items
(setq *te-handle-dialog-item* nil))
(t (unless (eq current-text item)
(let ((wptr (wptr w))) ; generate error if there is none.
(when item
(setf (slot-value item 'sel-start) (rref hTE TERec.selstart)
(slot-value item 'sel-end) (rref hTE TERec.selend))
(with-focused-view (view-container item)
(#_TEDeactivate hTE)))
(if (null current-text)
(progn
(rset hTE TERec.hText *null-text-handle*)
(rset hTE TERec.inport %temp-port%))
(with-focused-view (view-container current-text)
(rset hTE terec.inport wptr)
(with-slot-values (dialog-item-handle line-height font-ascent
text-justification)
current-text
(rset hTE TERec.Just text-justification) ; JooFung Wong's fix
(rset hTE TERec.hText dialog-item-handle)
(rset hTE TERec.LineHeight line-height)
(rset hTE TERec.FontAscent font-ascent))
(with-item-rect (rect current-text)
;could change this to copy-record for clarity ***
(rset hTE TERec.destrect.topleft (rref rect :rect.topleft))
(rset hTE TERec.destrect.bottomright (rref rect :rect.bottomright))
(rset hTE TERec.viewrect.topleft (rref rect :rect.topleft))
(rset hTE TERec.viewrect.bottomright (rref rect :rect.bottomright)))
(rset hTE TERec.clickloc -1)
(multiple-value-bind (ff ms) (view-font-codes current-text)
(%hput-long hTE ff 74)
(%hput-long hTE ms 78)
(with-font-codes ff ms
(#_TEAutoView t hTE)
(#_TECalText hTE)
(if select
(progn
(rset hTE TERec.selstart 0)
(rset hTE TERec.selend 32000))
(progn
(rset hTE TERec.selstart (slot-value current-text 'sel-start))
(rset hTE TERec.selend (slot-value current-text 'sel-end))))
(if (rref wptr windowrecord.hilited)
(#_TEActivate hTE))))))
(setq *te-handle-dialog-item* current-text)))
hTE)))))