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

Minor fix to Text-Edit-Dialog-Item



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:

(defmethod view-draw-contents :after ((item text-edit-dialog-item)
                                      &aux wp te size)
  (let ((my-dialog (view-window item))
        (item-position (view-position item))
        (item-size (view-size item)))
    (when (installed-item-p item)
      (with-slot-values (dialog-item-handle color-list text-justification)
        item
        (without-interrupts
         (rlet ((rect :rect))
           (rset rect rect.topleft item-position)
           (rset rect rect.bottomright
                 (add-points item-position item-size))
           (setq te (dialog-te-handle my-dialog))
           (setq size (#_GetHandleSize dialog-item-handle))
           (with-fore-color (getf color-list :text nil)
             (if (eq item (current-key-handler my-dialog))
               (progn
                 (%hput-long te (%get-long (setq wp (wptr my-dialog)) 68) 74)
                 (%hput-long te (%get-long wp 72) 78)
                ; (#_EraseRect rect)
                 (#_TESetJust text-justification te)    ; JooFung Wong's fix
                 (#_TEUpdate rect te))
               (with-pointers ((tp dialog-item-handle))
                 (#_TextBox tp size rect text-justification))))))))))