28.2 Defining and Creating Application Frames

  • 28.2.1 Specifying the Panes of a Frame
  • application-frame   [Protocol Class]
              

    The protocol class that corresponds to an application frame. If you want to create a new class that behaves like an application frame, it should be a subclass of application-frame. All instantiable subclasses of application-frame must obey the application frame protocol. [annotate]

    All application frame classes are mutable. [annotate]

    [annotate]

    application-frame-p  object [Protocol Predicate]
              

    Returns true if object is an application frame, otherwise returns false. [annotate]

    [annotate]

    :name   [Initarg]
    :pretty-name   [Initarg]
    :command-table   [Initarg]
    :disabled-commands   [Initarg]
    :panes   [Initarg]
    :menu-bar   [Initarg]
    :calling-frame   [Initarg]
    :state   [Initarg]
    :properties   [Initarg]
              

    All subclasses of application-frame must handle these initargs, which are used to specify, respectively, the name, pretty name, command table, initial set of disabled commands, the panes, the menu bar, calling frame, state, and initial properties for the frame. [annotate]

    Note: Which each mean what, exactly? Hyperlinks to specification would help here. [edit]-- Matt Seddon 2020-01-23 23:59Z
     

    [annotate]

    Note: Sure. But you may want to look at some of the hyperlinks below, which are reverse links from places where one of these initargs are mentioned. [edit]-- Gilbert Baumann 2022-06-13 14:58Z
     

    standard-application-frame   [Class]
    define-application-frame  name superclasses slots &rest options [Macro]
              

    Defines a frame and CLOS class named by the symbol name that inherits from superclasses and has state variables specified by slots. superclasses is a list of superclasses that the new class will inherit from (as in defclass). When superclasses is nil, it behaves as though a superclass of standard-application-frame was supplied. slots is a list of additional slot specifiers, whose syntax is the same as the slot specifiers in defclass. Each instance of the frame will have slots as specified by these slot specifiers. These slots will typically hold any per-instance frame state. [annotate]

    options is a list of defclass-style options, and can include the usual defclass options, plus any of the following: [annotate]

    Note: CHANGE-SPACE-REQUIREMENTS also mentions an :resize-frame option which is missing here. [edit]-- Gilbert Baumann 2003-03-16 14:48Z
     

    • :pane form, where form specifies the single pane in the application. The default is nil, meaning that there is no single pane. This is the simplest way to define a pane hierarchy. The :pane option is mutually exclusive with the :panes options. See Section 28.2.1 for a complete description of the :pane option. [annotate]
    • :panes form, where form is an alist that specifies names and panes of the application. The default is nil, meaning that there are no named panes. The :panes and :pane options are mutually exclusive. See Section 28.2.1 for a complete description of the :panes option. [annotate]
    • :layouts form, where form specifies the layout. The default layout is to lay out all of the named panes in horizontal strips. See Section 28.2.1 for a complete description of the :layouts option. [annotate]
    • :command-table name-and-options, where name-and-options is a list consisting of the name of the application frame's command table followed by some keyword-value pairs. The keywords can be :inherit-from or :menu (which are as in define-command-table). The default is to create a command table with the same name as the application frame. [annotate]
    • :command-definer value, where value either nil, t, or another symbol. When it is nil, no command-defining macro is defined. When it is t, a command-defining macro is defined, whose name is of the form define-name-command. When it is another symbol, the symbol names the command-defining macro. The default is t. [annotate]
    • :menu-bar form is used to specify what commands will appear in a "menu bar". It typically specifies the top-level commands of the application. form is either nil, meaning there is no menu bar; t, meaning that the menu from frame's command table (from the :command-table option) should be used; a symbol that names a command table, meaning that that command table's menu should be used; or a list, which is interpreted the same way the :menu option to define-command-table is interpreted. The default is t. [annotate]
    • :disabled-commands commands, where commands is a list of command names that are initially disabled in the application frame. The set of enabled and disabled commands can be modified via (setf command-enabled). [annotate]
    • :top-level form, where form is a list whose first element is the name of a function to be called to execute the top-level loop. The function must take at least one argument, the frame. The rest of the list consists of additional arguments to be passed to the function. The default function is default-frame-top-level. [annotate]
    • :icon pixmap specifies a pixmap to be displayed by the host's window manager when the frame is iconified. [annotate]
    • :geometry plist, where plist is a property list containing the default values for the :left, :top, :right, :bottom, :width, and :height options to make-application-frame. [annotate]

    The name, superclasses, and slots arguments are not evaluated. The values of each of the options are evaluated. [annotate]

    [annotate]

    make-application-frame  frame-name &rest options &key pretty-name frame-manager enable state left top right bottom width height save-under frame-class &allow-other-keys  [Function]
              

    Makes an instance of the application frame of type frame-class. If frame-class is not supplied, it defaults to frame-name. [annotate]

    The size options left, top, right, bottom, width, and height can be used to specify the initial size of the frame. If they are unsupplied and :geometry was supplied to define-application-frame, then these arguments default from the specified geometry. [annotate]

    options are passed as additional arguments to make-instance, after the pretty-name, frame-manager, enable, state, save-under, frame-class, and size options have been removed. [annotate]

    If save-under is true, then the sheets used to implement the user interface of the frame will have the "save under" property, if the host window system supports it. [annotate]

    If frame-manager is provided, then the frame is adopted by the specified frame manager. If the frame is adopted and either of enable or state are provided, the frame is pushed into the given state. [annotate]

    Once a frame has been create, run-frame-top-level can be called to make the frame visible and run its top-level function. [annotate]

    [annotate]

    *application-frame*   [Variable]
              

    The current application frame. The global value is CLIM's default application, which serves only as a repository for whatever internal state is needed by CLIM to operate properly. This variable is typically used in the bodies of command to gain access to the state variables of the application frame, usually in conjunction with with-slots or slot-value. [annotate]

    [annotate]

    with-application-frame  (frame) &body body [Macro]
              

    This macro provides lexical access to the "current" frame for use with commands and the :pane, :panes, and :layouts options. frame is bound to the current frame within the context of one of those options. [annotate]

    frame is a symbol; it is not evaluated. body may have zero or more declarations as its first forms. [annotate]

    [annotate]

    map-over-frames  function &key port frame-manager [Function]
              

    Applies the function function to all of the application frames that "match" port and frame-manager. If neither port nor frame-manager is supplied, all frames are considered to match. If frame-manager is supplied, only those frames that use that frame manager match. If port is supplied, only those frames that use that port match. [annotate]

    function is a function of one argument, the frame. It has dynamic extent. [annotate]

    [annotate]

    destroy-frame  frame [Generic Function]
              

    Destroys the application frame frame. [annotate]

    [annotate]

    raise-frame  frame [Generic Function]
              

    Raises the application frame frame to be on top of all of the other host windows by invoking raise-sheet on the frame's top-level sheet. [annotate]

    [annotate]

    bury-frame  frame [Generic Function]
              

    Buries the application frame frame to be underneath all of the other host windows by invoking bury-sheet on the frame's top-level sheet. [annotate]

    [annotate]

    28.2.1 Specifying the Panes of a Frame

    The panes of a frame can be specified in one of two different ways. If the frame has a single layout and no need of named panes, then the :pane option can be used. Otherwise if named panes or multiple layouts are required, the :panes and :layouts options can be used. Note that the :pane option is mutually exclusive with :panes and :layouts. It is meaningful to define frames that have no panes at all; the frame will simply serve as a repository for state and commands. [annotate]

    Panes and gadgets are discussed in detail in Chapter 29 and Chapter 30. [annotate]

    The value of the :pane option is a form that is used to create a single (albeit arbitrarily complex) pane. For example: [annotate]

    (vertically ()
      (tabling ()
        ((horizontally ()
           (make-pane 'toggle-button)
           (make-pane 'toggle-button)
           (make-pane 'toggle-button))
         (make-pane 'text-field))
        ((make-pane 'push-button :label "a button")
         (make-pane 'slider)))
      (scrolling ()
        (make-pane 'application-pane
                   :display-function 'a-display-function))
      (scrolling ()
        (make-pane 'interactor-pane)))
    

    If the :pane option is not used, a set of named panes can be specified with the :panes option. Optionally, :layouts can also be used to describe different layouts of the set of panes. [annotate]

    The value of the :panes option is a list, each entry of which is of the form (name . body). name is a symbol that names the pane, and body specifies how to create the pane. body is either a list containing a single element that is itself a list, or a list consisting of a symbol followed by zero or more keyword-value pairs. In the first case, the body is a form exactly like the form used in the :pane option. In the second case, body is a pane abbreviation where the initial symbol names the type of pane, and the keyword-value pairs are pane options. For gadgets, the pane type is the class name of the abstract gadget (for example, slider or push-button). For CLIM stream panes, the following abbreviations are defined: [annotate]

    See Chapter 29 and Chapter 30 for more information on the individual pane and gadget classes, and the options they support. [annotate]

    An example of the use of :panes is: [annotate]

    (:panes
      (buttons (horizontally ()
                 (make-pane 'push-button :label "Press me")
                 (make-pane 'push-button :label "Squeeze me")))
      (toggle toggle-button 
              :label "Toggle me")
      (interactor :interactor
                  :width 300 :height 300)
      (application :application
                   :display-function 'another-display-function
                   :incremental-redisplay t))
    

    The value of the :layouts option is a list, each entry of which is of the form (name layout). name is a symbol that names the layout, and layout specifies the layout. layout is a form like the form used in the :pane option, with the extension to the syntax such that the name of a named pane can be used wherever a pane may appear. (This will typically be implemented by using symbol-macrolet for each of the named panes.) For example, assuming a frame that uses the :panes example above, the following layouts could be specified: [annotate]

    (:layouts
      (default 
        (vertically ()
          button toggle 
          (scrolling () application)
          interactor))
      (alternate
        (vertically ()
          (scrolling () application)
          (scrolling () interactor)
          (horizontally ()
            button toggle))))
    

    The syntax for :layouts can be concisely expressed as: [annotate]

    :layouts (layout-name layout-panes) [annotate]
    Note: The example shows a list of (layout-name layout-panes), not just a single one as per the syntax [edit]-- Alan Zimmerman 2021-04-09 14:54Z
     
    layout-name is a symbol. [annotate]
    layout-panes is layout-panes1 or (size-spec layout-panes1). [annotate]
    layout-panes1 is a pane-name, or a layout-macro-form, or layout-code. [annotate]
    layout-code is lisp code that generates a pane, which may include the name of a named pane. [annotate]
    size-spec is a rational number less than 1, or :fill, or :compute. [annotate]
    layout-macro-form is (layout-macro-name (options) . body). [annotate]
    layout-macro-name is one of the layout macros, such as outlining, spacing, labelling, vertically, horizontally, or tabling. [annotate]