FunctionPackage: cgToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Unrevised from 9.0 to 10.0.
9.0 version

expand-window

Arguments: window

Expands window (if it is shrunken) to fill its previous box. Does nothing if window is already expanded.

The return value of this function is undefined and no meaning should be attributed to the value actually returned. Information about the success or failure of the expansion is not available.

When expand-window is called on a window whose state is :shrunk or :icon, the window is returned to either :normal or :maximized state, depending on which of these two states the window most recently had. If it has not yet had either of these states, then it is put into :normal state. For iconized windows, this emulates clicking on the restore button of the icon.

This operator is now a non-generic function. It calls (setf state), which is a generic function to effect the change in its argument's state. Methods can be added to (setf state) to affect the behavior of this function, as is done in the example below.

Example of a method on (setf state) affecting window expansion

When expand-window is called on a window whose state is :shrunk or :icon, the window is returned to either :normal or :maximized state, depending on which of these two states the window most recently had. If it has not yet had either of these states, then it is put into :normal state. For iconized windows, this emulates clicking on the restore button of the icon. Alternately, the new-state argument to (setf state) can be passed as :expanded to achieve the same result; expand-window itself calls (setf state) in this way. (:expanded is not a true state, so the resulting state of the window will be either :normal or :maximized.)

A (setf state) :around method prevents any other non-:around (setf state) methods from being called if the state would not actually be changed by the call. Therefore any methods added by an application do not need to handle this efficiency consideration. This around method also coerces the special :expanded state to either :normal or :maximized and passes that value to the other (setf state) methods that it calls, so any primary, :before, or :after (setf state) methods added by an application will not receive the :expanded state.

The generic function state returns a new second value for the "expanded state" of the window. This value is always either :normal or :maximized. If the current state of the window is :shrunk or :icon, then the value is the state into which the window will be placed if expand-window is called on it or if (setf state) is called on it with the :expanded state. This is also the most recent expanded state that the window was in, or :normal if it has never been expanded. If the current state of the window is :normal or :maximized, the value is the state to which the window was most recently expanded from :shrunk or :icon state.

Here is an example of an added (setf state) :around method that looks at both the old and new states of any frame-window whose state may be changing, and reports any change. Typically several custom methods on shrink-window, expand-window, and so on could be collapsed into such a single (setf state) method. A simpler :after method could be used instead if the old state is not of interest.

The without-package-locks is needed here in a source code file that's not in the cg package only because it specializes a Common Graphics method on a built-in Common Graphics class; normally an application would specialize on its own subclass instead.

The requested-state argument is ignored because it may be :expanded, and we are interested here in the resulting :normal or :maximized state instead. Similarly, some other (setf state) method could coerce the requested state to something else.

eval-in-listener-thread is used to make sure that the printed output always goes to the selected IDE listener pane (and so this method is suitable only for the IDE and not for a generated application). Otherwise, the message will go to the *terminal-io* of whatever thread changed the window state; for example, clicking the minimize button of an IDE window would iconize the window in the IDE GUI thread, for which *terminal-io* is bound to the console, and so the output would appear there.

The prog1 is used to ensure that this (setf state) method returns whatever the next called method returns, though that would normally be the requested-state.

(without-package-locks
 (defmethod (setf state) :around (requested-state (window frame-window))
   (declare (ignore requested-state))
   (let* ((old-state (state window))
          new-state)
     (prog1 (call-next-method)
       (setq new-state (state window))
       (unless (eq old-state new-state)
         (ide:eval-in-listener-thread
          `(format t "~&State of ~s changed from ~s to ~s.~%"
             (name ,window) ,old-state ,new-state)))))))

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 9.0 page.
Created 2015.5.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
Unrevised from 9.0 to 10.0.
9.0 version