CLIM mail archive
[Prev][Next][Index][Thread]
Resizing Dialogs Query
-
To: ncramer@BBN.COM
-
Subject: Resizing Dialogs Query
-
From: Scott McKay <swm@harlequin.com>
-
Date: Tue, 19 Jul 94 17:38:24 EDT
-
Cc: clim@BBN.COM
-
In-Reply-To: Nichael Cramer's message of Thu, 14 Jul 94 12:04:33 EDT <16250.199407141627@hilly.harlequin.com>
Date: Thu, 14 Jul 94 12:04:33 EDT
From: Nichael Cramer <ncramer@BBN.COM>
[ALLEGRO/CLIM2/SPARC]
I have some pop-up dialogs that I would to resize to a reasonable size
after they draw themselves. Basically, they consist of a simple frame with
a single (scrollable) display pane.
What I'm doing is using the
:RESIZE-FRAME T
option when I build the frame and then calling
(CLIM:SIZE-FRAME-FROM-CONTENTS PANE)
after I've drawn the display pane.
This works for most cases except that I can find no way to *limit* the size
to which the frame can grow. That is, if there is enough output in the
display-pane, the frame will grow until it fills the entire visible
screen before it starts to scroll[*].
CLIM:SIZE-FRAME-FROM-CONTENTS takes a WIDTH and HEIGHT argument; however
these seem to behave as MIN-WIDTH and MIN-HEIGHT; i.e. the frame will
always be at least this big (growing bigger if it wants to).
Yup, so far so good.
Likewise, the function also takes a SIZE-SETTER argument. This seems to
default to WINDOW-SET-INSIDE-SIZE. However, this seems to have the same
problem, i.e. the frame will grow bigger than some explicitly set limiting
WIDTH/HEIGHT value.
Finally, attempts to set HEIGHT/MAX-HEIGHT/MIN-HEIGHT on the pane
definitions have no effect.
Any suggestions/hints/etc on how to do this?
Try the following, which adds :MAX-WIDTH and :MAX-HEIGHT args to
SIZE-FRAME-FROM-CONTENTS. Be warned that Allegro CLIM might do
something quite different with this kludgy function these days.
(in-package :clim-internals)
(defun size-frame-from-contents (stream
&key width height
max-width max-height
(right-margin 10) (bottom-margin 10)
(size-setter #'window-set-inside-size))
(declare (values width height))
(with-slots (output-record) stream
(with-bounding-rectangle* (left top right bottom) output-record
(let* ((graft (or (graft stream)
(find-graft))) ;--- is this right?
(gw (bounding-rectangle-width (sheet-region graft)))
(gh (bounding-rectangle-height (sheet-region graft)))
;;--- Does this need to account for the size of window decorations?
(max-width (if max-width (min gw max-width) gw))
(max-height (if max-height (min gh max-height) gh))
(width (min max-width (+ (or width (- right left)) right-margin)))
(height (min max-height (+ (or height (- bottom top)) bottom-margin))))
;; The size-setter will typically resize the entire frame
(funcall size-setter stream width height)
(window-set-viewport-position stream left top)
(values width height)))))
Main Index |
Thread Index