CLIM Title Pane

Robert Swindells rjs at fdy2.co.uk
Sat Oct 3 13:39:06 UTC 2020


Oscar Chappel <oachappel at yahoo.com> wrote:
>I’m experimenting with McClim and CLIM. 
>
>Right now, I’m trying to insert a title pane into an application
>frame. I’m using the “Mini-CAD” example in figure 20 of the CommonLisp
>Interface Manager 2.0 User's Guide - 30 Jul 2004
>When I use the :display-string initialization argument for the title
>pane, I get an error:
>“Invalid initialization argument :DISPLAY-STRING in call for class
>#<STANDARD-CLASS CLIM-CLX::CLX-1255-TITLE-PANE>.”
>
>I have found that using the :display-function results in a similar error.
>
>Can anyone help out with this?

I have the following patch in my tree, sent it to this list a long time
ago but it didn't get committed:

diff --git a/panes.lisp b/panes.lisp
index e26b0dc..7519418 100644
--- a/panes.lisp
+++ b/panes.lisp
@@ -2741,11 +2741,22 @@ to computed distance to scroll in response to mouse wheel events."))
 ;;; TITLE PANE
 
 (defclass title-pane (clim-stream-pane)
-  ()
+  ((display-string :initarg :display-string
+                  :accessor display-string))
   (:default-initargs :display-time t
                      :scroll-bars nil
                      :display-function 'display-title))
 
+(defmethod display-title (frame (pane title-pane))
+  (declare (ignore frame))
+  (let ((a (text-style-ascent (pane-text-style pane) pane))
+       (tw (text-size pane (display-string pane))))
+    (with-bounding-rectangle* (x1 y1 x2 y2) (sheet-region pane)
+      (multiple-value-bind (tx ty)
+         (values (- (/ (- x2 x1) 2) (/ tw 2))
+                 (+ y1 2 a))
+         (draw-text* pane (display-string pane) tx ty)))))
+
 ;;; Pointer Documentation Pane
 
 (defparameter *default-pointer-documentation-background* +black+)



More information about the mcclim-devel mailing list