1360
LispWorks® for Windows® CAPI User Guide and Reference Manual Version 7.1

LispWorks® for Windows® CAPI User Guide and …ftp.lispworks.com/pub/software_tools/reference/lw71/capi-w-7-1.pdf · LispWorks® for Windows® CAPI User Guide and Reference Manual

  • Upload
    lydien

  • View
    241

  • Download
    3

Embed Size (px)

Citation preview

  • LispWorks for Windows

    CAPI User Guide and Reference ManualVersion 7.1

  • Copyright and TrademarksCAPI User Guide and Reference Manual (Windows version)

    Version 7.1

    August 2017

    Copyright 2017 by LispWorks Ltd.

    All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of LispWorks Ltd.

    The information in this publication is provided for information only, is subject to change without notice, and should not be construed as a commitment by LispWorks Ltd. LispWorks Ltd assumes no responsibility or liability for any errors or inaccuracies that may appear in this publication. The software described in this book is furnished under license and may only be used or copied in accordance with the terms of that license.

    LispWorks and KnowledgeWorks are registered trademarks of LispWorks Ltd.

    Adobe and PostScript are registered trademarks of Adobe Systems Incorporated. Other brand or product names are the registered trade-marks or trademarks of their respective holders.

    The code for walker.lisp and compute-combination-points is excerpted with permission from PCL, Copyright 1985, 1986, 1987, 1988 Xerox Corporation.

    The XP Pretty Printer bears the following copyright notice, which applies to the parts of LispWorks derived therefrom:Copyright 1989 by the Massachusetts Institute of Technology, Cambridge, Massachusetts.Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, pro-vided that this copyright and permission notice appear in all copies and supporting documentation, and that the name of M.I.T. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. M.I.T. makes no representa-tion about the suitability of this software for any purpose. It is provided as is without express or implied warranty. M.I.T. disclaims all war-ranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall M.I.T. be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of con-tract, negligence or other tortious action, arising out of or in connection with the use or performance of this software.

    LispWorks contains part of ICU software obtained from http://source.icu-project.org and which bears the following copyright and permis-sion notice:ICU License - ICU 1.8.1 and laterCOPYRIGHT AND PERMISSION NOTICECopyright 1995-2006 International Business Machines Corporation and others. All rights reserved.Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Soft-ware"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIM-ITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. All trademarks and registered trademarks men-tioned herein are the property of their respective owners.

    US Government Restricted RightsThe LispWorks Software is a commercial computer software program developed at private expense and is provided with restricted rights. The LispWorks Software may not be used, reproduced, or disclosed by the Government except as set forth in the accompanying End User License Agreement and as provided in DFARS 227.7202-1(a), 227.7202-3(a) (1995), FAR 12.212(a)(1995), FAR 52.227-19, and/or FAR 52.227-14 Alt III, as applicable. Rights reserved under the copyright laws of the United States.

    Address

    LispWorks LtdSt. Johns Innovation CentreCowley RoadCambridgeCB4 0WSEngland

    Telephone

    From North America: 877 759 8839 (toll-free)

    From elsewhere: +44 1223 421860

    FaxFrom North America: 617 812 8283From elsewhere: +44 870 2206189

    www.lispworks.com

    http://www.lispworks.com

  • Contents

    Preface xxv

    1 Introduction to the CAPI 1

    What is the CAPI? 1The CAPI model 2The history of the CAPI 3

    2 Getting Started 5

    Using the CAPI package 5Creating a window 6Linking code into CAPI elements 8

    3 General Properties of CAPI Panes 11

    Generic properties 11Base classes 16Specifying titles 17Callbacks 19Displaying and entering text 20Displaying rich text 27Hierarchy of panes 27Accessing pane geometry 28Special kinds of windows 28Button elements 31Adding a toolbar to an interface 34

    1

  • Contents

    2

    Tooltips 35Screens 36

    4 General Considerations 39

    The correct thread for CAPI operations 39Redisplay 40Support for multiple monitors 41

    5 Choices - panes with items 43

    Items 44Button panel classes 44List panels 48Trees 54Stacked trees 55Graph panes 55Option panes 60Text input choice 61Menu components 62General properties of choices 62Operations on collections (choices) and their items 66

    6 Laying Out CAPI Panes 69

    Organizing panes in columns and rows 72Other types of layout 76Combining different layouts 77Specifying geometry hints 78Constraining the size of layouts 84Other pane layouts 86Changing layouts and panes within a layout 94

    7 Programming with CAPI Windows 95

    Initialization 95Resizing and positioning 96Geometric queries 97Scrolling 98Updating pane contents 100Edit actions on the active element 102

  • Contents

    Manipulating top-level windows 103

    8 Creating Menus 107

    Creating a menu 108Presenting menus 109Grouping menu items together 109Creating individual menu items 112The CAPI menu hierarchy 113Mnemonics in menus 115Accelerators in menus 117Alternative menu items 117Disabling menu items 118Menus with images 120Popup menus for panes 120Displaying menus programmatically 121

    9 Adding Toolbars 123

    Creating a toolbar button 124Creating a toolbar with several buttons 124Specifying the image for a toolbar button 126Specifying toolbar callbacks 127Specifying tooltips for toolbar buttons 128Modifying toolbars 129Advanced toolbar features 131Disabling toolbar items 132Non-standard toolbars 132

    10 Defining Interface Classes - top level windows 135

    The define-interface macro 136An example interface 137Adapting the example 139Connecting an interface to an application 145Controlling the appearance of the top level window 148Querying and modifying interface geometry 149

    11 Dialogs: Prompting for Input 151

    Some simple dialogs 152

    3

  • Contents

    4

    Prompting for values 154Window-modal Cocoa dialogs 159Dialog Owners 160Creating your own dialogs 161In-place completion 165

    12 Creating Panes with Your Own Drawing and Input 171

    Displaying graphics 171Receiving input from the user 174Creating graphical objects 184output-pane scrolling 196Transient display on output-pane and subclasses 202

    13 Drawing - Graphics Ports 205

    Introduction 205Features 209Graphics state 211Drawing functions 212How to draw to an on-screen port 213Graphics state transforms 213Combining source and target pixels 215Pixmap graphics ports 216Portable font descriptions 217Working with images 219

    14 Graphic Tools drawing objects 229

    Lower level - drawing objects and objects displayers 229Higher level - drawing graphs and bar charts 236

    15 The Color System 241

    Color specs 242Color aliases 243Color models 245Loading the color database 247Defining new color models 247

    16 Printing from the CAPIthe Hardcopy API 251

  • Contents

    Printers 251Print jobs 252Handling pagespage on demand printing 252Handling pagespage sequential printing 252Printing a page 253Other printing functions 254Printing on Motif 254

    17 Drag and Drop 257

    Overview of drag and drop 257Dragging 258Dropping 261Limitations of CAPI drag and drop 264

    18 Miscellaneous functionality 265

    Development functions 265Sounds 266Modifier keys state 266Restoring display while debugging 266Object properties and name 267Clipboard 267Handles 267Setting the font and colors for specific panes in specific interfaces. 268

    19 Host Window System-specific issues 269

    Microsoft Windows-specific issues 269Cocoa-specific issues 270GTK+-specific issues 270Motif-specific issues 272CAPI communication with host window system - libraries 274

    20 Self-contained examples 277

    Output pane examples 277Graphics examples 279Pinboard examples 280Examples using timers to implement "animation" 281Drag and Drop examples 281

    5

  • Contents

    6

    Graph examples 282Cocoa-specific examples 282Examples of complete CAPI applications 282Choice examples 283Examples of dialogs and prompts 284editor-pane examples 285Menu examples 285Miscellaneous examples 285GTK+ specific examples 286Motif specific examples 286Layout examples 286Tooltip examples 287Examples illustrating other pane classes 287Printing examples 288Graphic Tools examples 289

    21 CAPI Reference Entries 291

    abort-callback 291abort-dialog 292abort-exit-confirmer 293accepts-focus-p 294activate-pane 295active-pane-copy 296active-pane-copy-p 296active-pane-cut 296active-pane-cut-p 296active-pane-deselect-all 296active-pane-deselect-all-p 296active-pane-paste 296active-pane-paste-p 296active-pane-select-all 296active-pane-select-all-p 296active-pane-undo 296active-pane-undo-p 296append-items 297apply-in-pane-process 298apply-in-pane-process-if-alive 300apply-in-pane-process-wait-single 300apply-in-pane-process-wait-multiple 300

  • Contents

    arrow-pinboard-object 302attach-interface-for-callback 303attach-simple-sink 304attach-sink 305beep-pane 306browser-pane 307browser-pane-available-p 315browser-pane-busy 316browser-pane-go-forward 316browser-pane-go-back 316browser-pane-navigate 316browser-pane-refresh 316browser-pane-set-content 316browser-pane-stop 316browser-pane-property-get 318browser-pane-property-put 318button 319button-panel 324calculate-constraints 329calculate-layout 331call-editor 331callbacks 332can-use-metafile-p 335capi-object 336capi-object-property 337check-button 338check-button-panel 339choice 340choice-selected-item 344choice-selected-item-p 346choice-selected-items 347choice-update-item 348clipboard 349clipboard-empty 351clone 352cocoa-default-application-interface 352cocoa-view-pane 356cocoa-view-pane-view 358collect-interfaces 359collection 360

    7

  • Contents

    8

    collection-find-next-string 364collection-find-string 365collection-last-search 365collection-search 366collector-pane 367color-screen 368column-layout 368component-name 371confirm-quit 371confirm-yes-or-no 373confirmer-pane 373contain 374convert-relative-position 376convert-to-screen 377count-collection-items 380create-dummy-graphics-port 381current-dialog-handle 382current-document 383current-pointer-position 383current-popup 384current-printer 385*default-editor-pane-line-wrap-marker* 386default-library 386*default-non-focus-message-timeout* 387*default-non-focus-message-timeout-extension* 387define-command 388define-interface 390define-layout 397define-menu 398define-ole-control-component 399destroy 401destroy-dependent-object 402detach-simple-sink 403detach-sink 404display 405display-dialog 407display-errors 410display-message 410display-message-for-pane 411display-non-focus-message 412

  • Contents

    display-pane 415display-pane-selected-text 416display-pane-selection 417display-pane-selection-p 417display-popup-menu 418display-replacable-dialog 419display-tooltip 420docking-layout 421docking-layout-pane-docked-p 425docking-layout-pane-visible-p 426document-container 427document-frame 427double-headed-arrow-pinboard-object 428double-list-panel 429drag-pane-object 432draw-metafile 434draw-metafile-to-image 435draw-pinboard-layout-objects 437draw-pinboard-object 438draw-pinboard-object-highlighted 439drawn-pinboard-object 440drop-object-allows-drop-effect-p 441drop-object-collection-index 442drop-object-collection-item 443drop-object-drop-effect 444drop-object-get-object 445drop-object-pane-x 446drop-object-pane-y 446drop-object-provides-format 447*echo-area-cursor-inactive-style* 448echo-area-pane 448*editor-cursor-active-style* 449*editor-cursor-color* 449*editor-cursor-drag-style* 450*editor-cursor-inactive-style* 450editor-pane 451editor-pane-blink-rate 460editor-pane-buffer 461*editor-pane-composition-selected-range-face-plist* 462editor-pane-default-composition-callback 462

    9

  • Contents

    10

    *editor-pane-default-composition-face* 464editor-pane-native-blink-rate 465editor-pane-selected-text 465editor-pane-selected-text-p 466editor-pane-stream 466editor-window 467element 467element-container 473element-interface-for-callback 473element-screen 474ellipse 474ensure-area-visible 475ensure-interface-screen 475execute-with-interface 476execute-with-interface-if-alive 477exit-confirmer 479exit-dialog 480expandable-item-pinboard-object 481extended-selection-tree-view 481filtering-layout 482filtering-layout-match-object-and-exclude-p 487find-graph-edge 487find-graph-node 488find-interface 489find-string-in-collection 490force-screen-update 490force-update-all-screens 491foreign-owned-interface 491form-layout 492free-metafile 493free-sound 494get-collection-item 494get-constraints 495get-horizontal-scroll-parameters 496get-page-area 498get-printer-metrics 499get-scroll-position 499get-vertical-scroll-parameters 500graph-edge 501graph-node 502

  • Contents

    graph-node-children 502graph-object 503graph-pane 504graph-pane-add-graph-node 509graph-pane-delete-object 509graph-pane-delete-objects 510graph-pane-delete-selected-objects 510graph-pane-direction 511graph-pane-edges 512graph-pane-nodes 512graph-pane-object-at-position 513graph-pane-select-graph-nodes 514graph-pane-update-moved-objects 514grid-layout 515hide-interface 520hide-pane 521highlight-pinboard-object 521image-list 522image-locator 523image-pinboard-object 524image-set 525install-postscript-printer 526installed-libraries 528interactive-pane 529interactive-pane-execute-command 531interface 532interface-customize-toolbar 552interface-display 552interface-display-title 554interface-document-modified-p 554interface-editor-pane 555interface-extend-title 556interface-geometry 557interface-iconified-p 557interface-keys-style 558interface-match-p 560interface-menu-groups 561interface-preserve-state 562interface-preserving-state-p 563interface-reuse-p 564

    11

  • Contents

    12

    interface-toolbar-state 565interface-visible-p 567interpret-description 568invalidate-pane-constraints 569invoke-command 570invoke-untranslated-command 570item 571item-pane-interface-copy-object 573item-pinboard-object 574itemp 575labelled-arrow-pinboard-object 575labelled-line-pinboard-object 576layout 577line-pinboard-object 579line-pinboard-object-coordinates 580list-panel 581list-panel-enabled 593list-panel-filter-state 593list-panel-items-and-filter 594list-panel-search-with-function 595list-panel-unfiltered-items 597list-view 598listener-pane 604listener-pane-insert-value 604load-cursor 605load-sound 609locate-interface 610lower-interface 611make-container 612make-docking-layout-controller 613make-foreign-owned-interface 613make-general-image-set 615make-icon-resource-image-set 616make-image-locator 617make-menu-for-pane 617make-pane-popup-menu 619make-resource-image-set 621make-scaled-general-image-set 622make-scaled-image-set 623make-sorting-description 624

  • Contents

    manipulate-pinboard 626map-collection-items 629map-pane-children 630map-pane-descendant-children 633map-typeout 634*maximum-moving-objects-to-track-edges* 634menu 635menu-component 640menu-item 642menu-object 648merge-menu-bars 652message-pane 654metafile-port 654modify-editor-pane-buffer 655modify-multi-column-list-panel-columns 655modify-stacked-tree 657mono-screen 658move-line 658multi-column-list-panel 659multi-line-text-input-pane 664non-focus-list-add-filter 665non-focus-list-remove-filter 665non-focus-list-toggle-filter 665non-focus-list-interface 666non-focus-list-toggle-enable-filter 666non-focus-maybe-capture-gesture 667non-focus-terminate 668non-focus-update 669ole-control-add-verbs 670ole-control-close-object 670ole-control-component 671ole-control-doc 673ole-control-frame 674ole-control-i-dispatch 675ole-control-insert-object 675ole-control-ole-object 676ole-control-pane 677ole-control-pane-frame 679ole-control-pane-simple-sink 680ole-control-user-component 681

    13

  • Contents

    14

    option-pane 682output-pane 687output-pane-cache-display 699output-pane-cached-display-user-info 700output-pane-draw-from-cached-display 701output-pane-free-cached-display 702output-pane-resize 703output-pane-stop-composition 704over-pinboard-object-p 705page-setup-dialog 706pane-adjusted-offset 707pane-adjusted-position 708pane-can-restore-display-p 710pane-close-display 710pane-descendant-child-with-focus 711pane-got-focus 712pane-has-focus-p 712pane-initial-focus 713pane-interface-copy-object 714pane-interface-copy-p 714pane-interface-cut-object 714pane-interface-cut-p 714pane-interface-deselect-all 714pane-interface-deselect-all-p 714pane-interface-paste-object 714pane-interface-paste-p 714pane-interface-select-all 714pane-interface-select-all-p 714pane-interface-undo 714pane-interface-undo-p 714pane-modifiers-state 715pane-popup-menu-items 717pane-restore-display 720pane-screen-internal-geometry 720pane-string 722pane-supports-menus-with-images 723parse-layout-descriptor 723password-pane 725pinboard-layout 726pinboard-layout-display 730

  • Contents

    pinboard-object 731pinboard-object-at-position 737pinboard-object-graphics-arg 738pinboard-object-highlighted-p 739pinboard-object-overlap-p 740pinboard-pane-position 740pinboard-pane-size 742play-sound 743popup-confirmer 743popup-menu-button 754popup-menu-force-popdown 755*ppd-directory* 756print-capi-button 756print-collection-item 757print-dialog 758print-editor-buffer 760print-file 760print-rich-text-pane 761print-text 762printer-configuration-dialog 763printer-metrics 764printer-port 765printer-port-handle 766printer-port-supports-p 767*printer-search-path* 767process-pending-messages 768progress-bar 769prompt-for-color 770prompt-for-confirmation 771prompt-for-directory 772prompt-for-file 774prompt-for-files 778prompt-for-font 779prompt-for-form 780prompt-for-forms 782prompt-for-integer 783prompt-for-items-from-list 785prompt-for-number 786prompt-for-string 786prompt-for-symbol 788

    15

  • Contents

    16

    prompt-for-value 790prompt-with-list 791prompt-with-list-non-focus 794prompt-with-message 800push-button 801push-button-panel 803quit-interface 804radio-button 806radio-button-panel 807raise-interface 808range-pane 809range-set-sizes 810read-sound-file 811record-dependent-object 812unrecord-dependent-object 812rectangle 813redisplay-collection-item 813redisplay-interface 814redisplay-menu-bar 815redraw-drawing-with-cached-display 816redraw-pinboard-layout 816redraw-pinboard-object 817reinitialize-interface 817remove-capi-object-property 818remove-items 819replace-dialog 820replace-items 820report-active-component-failure 822reuse-interfaces-p 823rich-text-pane 824rich-text-pane-character-format 826rich-text-pane-operation 827rich-text-pane-paragraph-format 832rich-text-version 832right-angle-line-pinboard-object 833row-layout 834screen 836screen-active-interface 838screen-active-p 838screen-internal-geometries 839

  • Contents

    screen-internal-geometry 840screen-logical-resolution 842screen-monitor-geometries 842screens 843scroll 844scroll-bar 846scroll-if-not-visible-p 848search-for-item 849selection 850selection-empty 851set-application-interface 852set-button-panel-enabled-items 853set-clipboard 854set-composition-placement 855set-confirm-quit-flag 856set-default-editor-pane-blink-rate 857set-default-interface-prefix-suffix 858set-default-use-native-input-method 860set-display-pane-selection 860set-drop-object-supported-formats 861set-editor-parenthesis-colors 863set-geometric-hint 864set-hint-table 864set-horizontal-scroll-parameters 865set-interactive-break-gestures 866set-interface-pane-name-appearance 867set-interface-pane-type-appearance 867set-list-panel-keyboard-search-reset-time 871set-object-automatic-resize 872set-pane-focus 876set-printer-metrics 877set-printer-options 878set-rich-text-pane-character-format 879set-rich-text-pane-paragraph-format 882set-selection 884set-text-input-pane-selection 885set-top-level-interface-geometry 886set-vertical-scroll-parameters 887shell-pane 889show-interface 890

    17

  • Contents

    18

    show-pane 891simple-layout 891simple-network-pane 892simple-pane 893simple-pane-handle 905simple-pane-visible-height 905simple-pane-visible-size 906simple-pane-visible-width 907simple-pinboard-layout 907simple-print-port 908slider 910sort-object-items-by 913sorted-object 913sorted-object-sort-by 914sorted-object-sorted-by 915stacked-tree 916stacked-tree-decrease-font-height 925stacked-tree-increase-font-height 925stacked-tree-default-color-function 926stacked-tree-history-forward 927stacked-tree-history-backward 927stacked-tree-item-at-point 928stacked-tree-width-ratio 929stacked-tree-zoom-by-factor 930start-drawing-with-cached-display 931start-gc-monitor 933start-pane-drag-operation 934pane-drag-operation-update 934end-pane-drag-operation 934static-layout 936static-layout-child-geometry 937static-layout-child-position 938static-layout-child-size 939stop-gc-monitor 940stop-sound 941switchable-layout 941switchable-layout-switchable-children 943tab-layout 944tab-layout-panes 948tab-layout-visible-child 949

  • Contents

    text-input-choice 949text-input-pane 951text-input-pane-append-recent-items 967text-input-pane-delete-recent-items 967text-input-pane-prepend-recent-items 967text-input-pane-replace-recent-items 967text-input-pane-complete-text 968text-input-pane-copy 969text-input-pane-cut 970text-input-pane-delete 970text-input-pane-in-place-complete 971text-input-pane-paste 971text-input-pane-recent-items 972text-input-pane-selected-text 973text-input-pane-selection 973text-input-pane-selection-p 974text-input-pane-set-recent-items 975text-input-range 976title-pane 978titled-menu-object 980titled-object 980titled-pinboard-object 984toolbar 986toolbar-button 989toolbar-component 994toolbar-object 997top-level-interface 998top-level-interface-display-state 998top-level-interface-geometry 1000top-level-interface-geometry-key 1001top-level-interface-p 1003top-level-interface-save-geometry-p 1003tracking-pinboard-layout 1004tree-view 1004tree-view-ensure-visible 1016tree-view-expanded-p 1016tree-view-item-checkbox-status 1017tree-view-item-children-checkbox-status 1018tree-view-update-an-item 1019tree-view-update-item 1019

    19

  • Contents

    20

    undefine-menu 1020unhighlight-pinboard-object 1020uninstall-postscript-printer 1021unmap-typeout 1022update-all-interface-titles 1022update-drawing-with-cached-display 1023update-drawing-with-cached-display-from-points 1023update-interface-title 1025update-internal-scroll-parameters 1026update-pinboard-object 1027update-screen-interface-titles 1028*update-screen-interfaces-hooks* 1028update-toolbar 1029virtual-screen-geometry 1030with-atomic-redisplay 1030with-busy-interface 1031with-dialog-results 1032with-document-pages 1035with-external-metafile 1036with-geometry 1039with-internal-metafile 1042with-output-to-printer 1044with-page 1045with-page-transform 1046with-print-job 1047with-random-typeout 1049wrap-text 1049wrap-text-for-pane 1050x-y-adjustable-layout 1051

    22 GRAPHICS-PORTS Reference Entries 1053

    2pi 1053analyze-external-image 1054apply-rotation 1054apply-rotation-around-point 1055apply-scale 1056apply-translation 1057augment-font-description 1058clear-external-image-conversions 1059

  • Contents

    clear-graphics-port 1059clear-graphics-port-state 1060clear-rectangle 1060compress-external-image 1061compute-char-extents 1062convert-external-image 1063convert-to-font-description 1063copy-area 1064copy-external-image 1066copy-pixels 1066copy-transform 1068create-pixmap-port 1068*default-image-translation-table* 1070define-font-alias 1070destroy-pixmap-port 1071dither-color-spec 1071draw-arc 1072draw-arcs 1073draw-character 1074draw-circle 1075draw-ellipse 1076draw-image 1077draw-line 1080draw-lines 1081draw-path 1081draw-point 1085draw-points 1086draw-polygon 1087draw-polygons 1088draw-rectangle 1089draw-rectangles 1090draw-string 1091ensure-gdiplus 1092external-image 1094external-image-color-table 1095external-image-color-table 1095externalize-and-write-image 1096externalize-image 1098f2pi 1100find-best-font 1100

    21

  • Contents

    22

    find-matching-fonts 1101font 1102font-description 1103font-description 1104font-description-attribute-value 1105font-description-attributes 1105font-dual-width-p 1106font-fixed-width-p 1106font-single-width-p 1107fpi 1108fpi-by-2 1108free-image 1108free-image-access 1109get-bounds 1109get-char-ascent 1110get-char-descent 1111get-char-width 1111get-character-extent 1112get-enclosing-rectangle 1113get-font-ascent 1113get-font-average-width 1114get-font-descent 1114get-font-height 1115get-font-width 1115get-graphics-state 1116get-origin 1116get-string-extent 1117get-transform-scale 1118graphics-port-background 1119graphics-port-font 1119graphics-port-foreground 1119graphics-port-transform 1119graphics-port-mixin 1120graphics-state 1120image 1129image-access-height 1129image-access-width 1129image-access-pixel 1130image-access-pixels-from-bgra 1132image-access-pixels-to-bgra 1133

  • Contents

    image-access-transfer-from-image 1134image-access-transfer-to-image 1135image-freed-p 1136image-loader 1136image-translation 1137initialize-dithers 1138inset-rectangle 1138inside-rectangle 1139invalidate-rectangle 1140invalidate-rectangle-from-points 1141invert-transform 1142list-all-font-names 1143list-known-image-formats 1143load-icon-image 1144load-image 1146make-dither 1148make-font-description 1149make-graphics-state 1150make-image 1151make-image-access 1151make-image-from-port 1153make-scaled-sub-image 1153make-sub-image 1155make-transform 1156merge-font-descriptions 1157offset-rectangle 1157ordered-rectangle-union 1158pi-by-2 1159pixblt 1159pixmap-port 1160port-drawing-mode-quality-p 1161port-graphics-state 1161port-height 1162port-owner 1162port-string-height 1163port-string-width 1163port-width 1164postmultiply-transforms 1165premultiply-transforms 1165read-and-convert-external-image 1166

    23

  • Contents

    24

    read-external-image 1167rect-bind 1168rectangle-bind 1169rectangle-bottom 1169rectangle-height 1170rectangle-left 1170rectangle-right 1171rectangle-top 1171rectangle-union 1172rectangle-width 1173register-image-load-function 1173register-image-translation 1174reset-image-translation-table 1175separation 1176set-default-image-load-function 1176set-graphics-port-coordinates 1177set-graphics-state 1178transform 1179transform-area 1179transform-distance 1180transform-distances 1181transform-is-rotated 1181transform-point 1182transform-points 1182transform-rect 1183undefine-font-alias 1184union-rectangle 1184*unit-transform* 1185unit-transform-p 1185unless-empty-rect-bind 1186untransform-distance 1187untransform-distances 1187untransform-point 1188untransform-points 1189validate-rectangle 1189with-dither 1190with-graphics-mask 1191with-graphics-post-translation 1193with-graphics-rotation 1194with-graphics-scale 1194

  • Contents

    with-graphics-translation 1194with-graphics-state 1195with-graphics-transform 1197with-graphics-transform-reset 1198with-inverse-graphics 1199with-pixmap-graphics-port 1199with-transformed-area 1201with-transformed-point 1202with-transformed-points 1203with-transformed-rect 1203without-relative-drawing 1204write-external-image 1205

    23 LW-GT Reference Entries 1207

    apply-drawing-object 1208basic-graph-spec 1209compound-drawing-object 1210compute-drawing-object-from-data 1211recurse-compute-drawing-object 1211drawing-object 1213fit-object 1215make-absolute-drawing 1215make-absolute-drawing* 1215position-object 1215position-and-fit-object 1215rotate-object 1215force-objects-redraw 1219generate-bar-chart 1220generate-graph-from-pairs 1223generate-grid-lines 1224generate-labels 1229geometry-drawing-object 1231make-a-drawing-call 1232make-draw-arc 1232make-draw-circle 1232make-draw-ellipse 1232make-draw-line 1232make-draw-lines 1232make-draw-polygon 1232

    25

  • Contents

    26

    make-draw-rectangle 1232make-basic-graph-spec 1235basic-graph-spec-p 1235copy-basic-graph-spec 1235generate-graph-from-graph-spec 1235make-draw-string 1237make-pinboard-objects-displayer 1239objects-displayer 1240pinboard-objects-displayer 1243string-drawing-object 1244

    24 COLOR Reference Entries 1245

    apropos-color-alias-names 1245apropos-color-names 1246apropos-color-spec-names 1247color-alpha 1248color-blue 1249color-green 1249color-red 1249color-hue 1249color-saturation 1249color-value 1249*color-database* 1250color-from-premultiplied 1250color-to-premultiplied 1251color-level 1252color-model 1253color-with-alpha 1254colors= 1255convert-color 1255define-color-alias 1256define-color-models 1258delete-color-translation 1259ensure-color 1259ensure-model-color 1260ensure-rgb 1261ensure-hsv 1261ensure-gray 1261get-all-color-names 1262

  • Contents

    get-color-alias-translation 1263get-color-spec 1264load-color-database 1265make-gray 1266make-hsv 1267make-rgb 1268read-color-db 1269unconvert-color 1270

    Index 1271

    27

  • Contents

    28

  • Preface

    This preface contains information you need when using the rest of the CAPI documentation. It discusses the purpose of this manual, the typographical conventions used, and gives a brief description of the rest of the contents.

    About this manual

    This manual contains a user guide section (previously published separately as the CAPI User Guide) and a reference section (previously the LispWorks CAPI Reference Manual).

    Assumptions

    The CAPI documentation assumes that you are familiar with:

    LispWorks.

    Common Lisp and CLOS, the Common Lisp Object System.

    The Microsoft Windows environment.

    Illustrations in this manual show the CAPI running on Microsoft Windows XP with the default Windows XP theme, so if you use a different Windows ver-sion or theme you should expect some variation from the figures depicted here.

    Unless otherwise stated, examples given in this document assume that the current package has CAPI on its package-use-list.

    xxv

  • xxvi

    Conventions used in the manual

    Throughout this manual, certain typographical conventions have been adopted to aid readability.

    1. Whenever an instruction is given, it is numbered and printed like this.

    Text which you should enter explicitly is printed like this.

    Exported symbols and example code are printed like-this. The package qualifier is often omitted, as if the current package is capi (or graphics-ports or color.)

    Variable arguments, slots and return values are italicised. They look like-this in the main text.

    User Guide section

    The user guide section of this manual forms an introductory course in devel-oping applications using the CAPI. Please note that, like the rest of the Lisp-Works documentation, it does assume knowledge of Common Lisp.

    Chapter 1, Introduction to the CAPI, introduces the principles behind the CAPI, some of its fundamental concepts, and what it sets out to achieve.

    Chapter 2, Getting Started, presents a series of simple examples to familiarize you with some of the most important elements and functions.

    Chapter 3, General Properties of CAPI Panes, introduces more of the fundamen-tal CAPI elements and common themes. These elements are explained in greater detail in the remainder of the manual.

    Chapter 4, General Considerations, covers some general issues that you should be aware of when using CAPI, including information about multiple displays.

    Chapter 5, Choices - panes with items, explains the key CAPI concept of the choice. A choice groups CLOS objects together and provides the notion of there being a selected object amongst that group of objects. Button panels and list panels are examples of choices.

    Chapter 6, Laying Out CAPI Panes introduces the idea of layouts. These let you combine different CAPI elements inside a single window.

  • Chapter 7, Programming with CAPI Windows, outlines basic techniques for modifying existing windows.

    Chapter 8, Creating Menus, shows you how to implement menus.

    Chapter 9, Adding Toolbars, shows you how to add toolbars to a window.

    Chapter 10, Defining Interface Classes - top level windows, introduces the macro define-interface. This macro can be used to define interface classes com-posed of CAPI elements, including the predefined elements described in this manual and also elements which you define.

    Chapter 11, Dialogs: Prompting for Input, discusses the ways in which dialogs may be used to prompt the user for input.

    Chapter 12, Creating Panes with Your Own Drawing and Input, shows you how you can define your own classes when the elements provided by the CAPI are not sufficient for your needs.

    Chapter 13, Drawing - Graphics Ports, describes the Graphics Ports API which provides a selection of drawing and image transformation functions. Although not part of the CAPI package, and therefore not strictly part of the CAPI, the Graphics Ports functions are used in conjunction with CAPI panes, and are therefore documented in this manual. See also Chapter 22, GRAPH-ICS-PORTS Reference Entries.

    Chapter 14, Graphic Tools drawing objects, describes the Graphic Tools API which provides a way to create more complex drawings, including graphs and bar charts. Graphic Tools are built with Graphics Ports and CAPI pin-boards, and are therefore documented in this manual. See also Chapter 23, LW-GT Reference Entries.

    Chapter 15, The Color System, allows applications to use keyword symbols as aliases for colors in Graphics Ports drawing functions. They can also be used for backgrounds and foregrounds of windows and CAPI objects. See also Chapter 24, COLOR Reference Entries.

    Chapter 16, Printing from the CAPIthe Hardcopy API, describes the programmatic printing of Graphics Ports.

    Chapter 17, Drag and Drop, describes how you can implement drag and drop in your CAPI application.

    xxvii

  • xxviii

    Chapter 19, Host Window System-specific issues, describes how to configure the appearance of CAPI windows on the various supported host window sys-tems.

    Chapter 20, Self-contained examples, enumerates the CAPI example files avail-able in the LispWorks library.

    Reference section

    The reference section contains reference entries for the symbols in the capi, graphics-ports, lw-gt and color packages.

    Within each chapter, the symbols are organized alphabetically (ignoring non-alphanumeric characters that are common in Lisp symbols, such as *). The typographical conventions used are similar to those used in Common Lisp: the Language (2nd Edition). Further details on the conventions used are given below. The chapters are:

    Chapter 21, CAPI Reference Entries, describes the external symbols of the capi package.

    Chapter 22, GRAPHICS-PORTS Reference Entries, describes the external sym-bols of the graphics-ports package.

    Chapter 23, LW-GT Reference Entries, describes the external symbols of the lw-gt package.

    Chapter 24, COLOR Reference Entries, describes the external symbols of the color package.

    Note: Although the graphics-ports and color packages are not strictly part of the CAPI, they are included in this manual because the functionality is usu-ally called from CAPI elements such as output panes. lw-gt is also included here since it is built on top of graphics-ports and capi. Chapter 13, Draw-ing - Graphics Ports and Chapter 15, The Color System shows you how to use the graphics-ports and color packages respectively; the remainder of the User Guide section shows you how to use the capi package.

  • Conventions used for reference entries

    Each entry is headed by the symbol name and type, followed by a number of fields providing further details. These fields consist of a subset of the follow-ing: Summary, Package, Signature, Method signatures, Argu-ments, Values, Initial value, Superclasses, Subclasses, Initargs, Accessors, Readers, Description, Notes, Compatibility notes, Examples and See also.

    Some symbols with closely-related functionality are coalesced into a single reference entry.

    Entries with a long Description section usually have as their first field a short Summary providing a quick overview of the symbols purpose.

    The Package section shows the package from which the symbol is exported.

    The Signature section shows the arguments and return values of functions and macros, and the parameters of types.

    In a Generic Function entry there may be a Method signatures section show-ing system-defined method signatures.

    The Arguments and "Values" sections show types of the arguments and return values.

    In a Variable entry, the Initial value section shows the initial value.

    In a Class entry the Subclasses section of lists the external subclasses, though not subclasses of those, and the Superclasses section lists the exter-nal superclasses, though not superclasses of those. The Initargs section describes the initialization arguments of the class, though note that initargs of superclasses are also valid. There may be an Accessors section listing acces-sor functions which are both readers and writers, and/or a Readers section listing accessor functions which are only readers. Accessor functions access the slot with matching name.

    The Description section contains the detail of what the symbol does, how each argument is interpreted (and its default value if applicable), and how each return value is derived. More incidental information may be shown in a Notes section.

    xxix

  • xxx

    A few entries have a Compatibility notes section describing changes in the symbols functionality relative to other LispWorks versions.

    Examples are given under the Examples heading. Short examples are shown directly. Longer examples are supplied as source files in your Lisp-Works installation directory under examples/capi/. The convenience func-tion lw:example-edit-file allows you to open these files in the LispWorks editor.

    Note that the example code is written with explicit package qualifiers such as capi:interface, so that it can be run as-is, regardless of the current package.

    Finally, the See also section provides links to other related symbols and user guide sections.

    Viewing example files

    This manual often refers to example files in the LispWorks library via a Lisp form like this:

    (example-edit-file "capi/choice/drag-and-drop")

    These examples are Lisp source files in your LispWorks installation under lib/7-1-0-0/examples/. You can simply evaluate the given form to view the example source file.

    Example files contain instructions about how to use them at the start of the file.

    The examples files are in a read-only directory and therefore you should com-pile them inside the IDE (by the Editor command Compile Buffer or the toolbar button or by choosing Buffer > Compile from the context menu), so it does not try to write a fasl file.

    If you want to manipulate an example file or compile it on the disk rather than in the IDE, then you need first to copy the file elsewhere (most easily by using the Editor command Write File or by choosing File > Save As from the con-text menu).

    The LispWorks manuals

    The LispWorks manual set also includes the following books:

  • The LispWorks User Guide and Reference Manual describes the main lan-guage-level features and tools available in LispWorks, along with refer-ence pages.

    The LispWorks IDE User Guide describes the LispWorks IDE, the user interface for LispWorks. This is a set of windowing tools that help you to develop and test Common Lisp programs.

    The LispWorks Editor User Guide describes the keyboard commands and programming interface to the LispWorks IDE editor tool.

    The LispWorks Foreign Language Interface User Guide and Reference Manual explains how you can use C source code in applications developed using LispWorks.

    The LispWorks Delivery User Guide describes how you can deliver work-ing, standalone versions of your LispWorks applications for distribution to your customers.

    Developing Component Software with CORBA describes how LispWorks can interoperate with other CORBA-compliant systems.

    The LispWorks COM/Automation User Guide and Reference Manual describes a toolkit for using Microsoft COM and Automation in Lisp-Works for Windows.

    The LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual describes APIs for interfacing to Objective-C and Cocoa in Lisp-Works for Macintosh.

    The KnowledgeWorks and Prolog User Guide describes the LispWorks tool-kit for building knowledge-based systems. Prolog is a logic program-ming system within Common Lisp.

    The Common Lisp Interface Manager 2.0 Users Guide describes the porta-ble Lisp-based GUI toolkit.

    The LispWorks Release Notes and Installation Guide which contains notes explaining how to install LispWorks and get it running. It also contains a set of release notes which lists new features and any last minute issues that could not be included in the main manual set.

    xxxi

  • xxxii

    These books are provided in both HTML and PDF formats, and may also be found at www.lispworks.com/documentation.

    Commands in the Help menu of any of the LispWorks IDE tools give you direct access to your local copy of the HTML format manuals. Details of how to use these commands can be found in the LispWorks IDE User Guide.

    You can use Adobe Reader to browse the PDF documentation. Adobe Reader is available from Adobes web site, http://www.adobe.com/.

    Please let us know at [email protected] if you find any mistakes in the LispWorks documentation, or if you have any suggestions for improve-ments.

    mailto:[email protected]://www.lispworks.com/documentation

  • 1

    1 Introduction to the CAPI

    1.1 What is the CAPI?The CAPI (Common Application Programmers Interface) is a library for implementing portable window-based application interfaces. It is a conceptually simple, CLOS-based model of interface elements and their interaction. It provides a standard set of these elements and their behaviors, as well as giving you the opportunity to define elements of your own.

    The CAPIs model of window-based user interfaces is an abstraction of the concepts that are shared between all contemporary window systems, such that you do not need to consider the details of a particular system. These hidden details are taken care of by a back end library written for that system alone.

    An advantage of making this abstraction is that each of the system-specific libraries can be highly specialized, concentrating on getting things right for that particular window system. Furthermore, because the implementation libraries and the CAPI model are completely separate, libraries can be written for new window systems without affecting either the CAPI model or the applications you have written with it.

    The CAPI currently runs under X Window System with either GTK+ or Motif, Microsoft Windows and Mac OS X. Using CAPI with Motif is deprecated.

    1

  • 1 Introduction to the CAPI

    2

    1.2 The CAPI modelThe CAPI provides an abstract hierarchy of classes which represent different sorts of window interface elements, along with functions for interacting with them. Instances of these classes represent window objects in an application, with their slots representing different aspects of the object, such as the text on a button, or the items on a menu. These instances are not actual window objects but provide a convenient representation of them for you. When you ask the CAPI to display your object, it creates a real window system object to represent it. This means that if you display a CAPI button, a real Windows button is created for it when running on Microsoft Windows, a real GTK+ but-ton when running on GTK+, and a real Cocoa button when running on Cocoa.

    The CAPIs approach makes the production of the screen objects the responsibility of the native window system, so it always produces the correct look and feel. Furthermore, the CAPIs use of the real interface to the window system means that it does not need to be upgraded to account for look and feel changes, and anything written with it is upwardly compatible, just like any well-written application.

    1.2.1 CAPI elements

    There are five types of elements in the CAPI model: interface, menu, pane, layout and pinboard-object.

    Everything that the CAPI displays is contained within an interface (an instance of the class interface). When an interface is displayed a window appears containing all the menus and panes you have specified for it. Top level windows in an application are normally defined as an interface sub-class, by using define-interface.

    An interface can contain a number of menus collected together on a menu bar, and context menus can also appear elsewhere. Each menu can contain menu items or other menus (that is, submenus). Items can be grouped together visu-ally and functionally inside menu components. Menus, menu items, and menu components are, respectively, instances of the classes menu, menu-item, and menu-component.

    Panes are window objects such as buttons and lists. They can be positioned anywhere in an interface. The CAPI provides many different kinds of pane

  • 1.3 The history of the CAPI

    class, among them push-button, list-panel, text-input-pane, editor-pane, tree-view and graph-pane.

    The positions of panes are controlled by a layout, which allows objects to be collected together and positioned either regularly (with instances of the classes column-layout, row-layout or grid-layout) or arbitrarily using a pinboard-layout. Layouts themselves can be laid out by other layouts for example, a row of buttons can be laid out above a list by placing both the row-layout and the list in a column-layout.

    pinboard-objects are lightweight elements that you can use to create com-plex display and user interaction. They must be used inside a pinboard-lay-out.

    Note that layouts and interfaces are actually panes too (interface and lay-out are subclasses of simple-pane), and in most of the cases can be used where panes are used. They are listed separately because of their special role in the layout of windows.

    1.3 The history of the CAPIWindow-based applications written with LispWorks 3 and previous used CLX, CLUE, and the LispWorks Toolkit. Such applications are restricted to running under X Windows. Because we and our customers wanted a way to write portable window code, we developed a new system for this purpose: the CAPI.

    Part of this portability exercise was undertaken before the development of the CAPI, for graphics ports, the generic graphics library. This includes the porta-ble color, font, and image systems in LispWorks. The CAPI is built on top of this technology, and has been implemented for Motif, Microsoft Windows, Cocoa and GTK+.

    All Lisp-based environment and application development in LispWorks Ltd now uses the CAPI. We recommend that you use the CAPI for window-based application development in preference to the systems mentioned earlier.

    3

  • 1 Introduction to the CAPI

    4

  • 2

    2 Getting Started

    This chapter introduces some of the most basic CAPI elements and functions. The intention is simply that you should become familiar with the most useful elements available, before learning how you can use them constructively.

    You should work through the examples in this chapter. For extended example code, see:

    (example-edit-file "capi/elements/")

    A CAPI application consists of a hierarchy of CAPI objects. CAPI objects are created using make-instance, and although they are standard CLOS objects, CAPI slots should generally be accessed using the documented accessors, and not using the CLOS slot-value function. You should not rely on slot-value because the implementation of the CAPI classes may evolve.

    Once an instance of a CAPI object has been created in an interface, it can be displayed on your screen using the function display.

    2.1 Using the CAPI packageAll symbols in this manual are exported from either the CAPI or COMMON-LISP packages unless explicitly stated otherwise. To access CAPI symbols, you

    5

  • 2 Getting Started

    6

    could qualify them all explicitly in your code, for example capi:output-pane.

    However it is more convenient to create a package which has CAPI on its package-use-list:

    (defpackage "MY-PACKAGE"(:add-use-defaults t)(:use "CAPI")

    )

    This creates a package in which all the CAPI symbols are accessible. To run the examples in this guide, first evaluate

    (in-package "MY-PACKAGE")

    2.2 Creating a windowThis section shows how easy it is to create a simple window, and how to include CAPI elements, such as panes, in your window.

    1. Enter the following in a listener

    (setq interface (make-instance 'interface :visible-min-width 200 :title "My Interface"))

    (display interface)

    Figure 2.1 Creating a simple window

    A small window appears on your screen, called "My Interface". This is the most simple type of window that can be created with the CAPI.

    Note: By default, if you do not use MDI mode, this window has a menu bar with the Works menu. The Works menu gives you access to a variety of Lisp-Works tools, just like the Works menu of any window in the LispWorks IDE. It

  • 2.2 Creating a window

    is automatically provided by default for any interface you create. You can omit it by passing :auto-menus nil.

    The usual way to display an instance of a CAPI window is display. However, another function, contain, is provided to help you during the course of development.

    Notice that the "My Interface" window cannot be made smaller than the mini-mum width specified. All CAPI geometry values (window size and position) are integers and represent pixel values relative to the topmost/leftmost visible pixel of the primary monitor.

    Only a top level CAPI element is shown by display that is, an instance of an interface. To display other CAPI elements (for example, buttons, editor panes, and so on), you must provide information about how they are to be arranged in the window. Such an arrangement is called a layout you will learn more about layouts in Chapter 6.

    On the other hand, contain automatically provides a default layout for any CAPI element you specify, and subsequently displays it. During development, it can be useful for displaying individual elements of interest on your screen, without having to create an interface for them explicitly. However, contain is only provided as a development tool, and should not be used for the final implementation of a CAPI element. See Chapter 10, Defining Interface Classes - top level windows on how to display CAPI elements in an interface.

    Note that a displayed CAPI element should only be accessed in its own thread. See The correct thread for CAPI operations on page 39 for more information about this.

    This is how you can create and display a button using contain.

    1. Enter the following into a listener:

    7

  • 2 Getting Started

    8

    (setq button (make-instance 'push-button :data "Button"))

    (contain button)

    Figure 2.2 Creating a push-button interface

    This creates an interface which contains a single push-button, with a label specified by the :data keyword. Notice that you could have performed the same example using display, but you would also have had to create a layout so that the button could have been placed in an interface and displayed.

    You can click on the button, and it will respond in the way you would expect (it will depress). However, no code will be run which performs an action asso-ciated with the button. How to link code to window items is the topic of the next section.

    2.3 Linking code into CAPI elementsGetting a CAPI element to perform an action is done by specifying a callback. This is a function which is performed whenever you change the state of a CAPI element. It calls a piece of code whenever a choice is made in a window.

    Note that the result of the callback function is ignored, and that its usefulness is in its side-effects.

    1. Try the following:

  • 2.3 Linking code into CAPI elements

    (setq push-button (make-instance 'push-button :data "Hello" :callback #'(lambda (&rest args) (display-message "Hello World"))))(contain push-button)

    Figure 2.3 Specifying a callback

    2. Click on the Hello button.

    A dialog appears containing the message Hello World.

    Figure 2.4 A dialog displayed by a callback.

    The CAPI provides the function display-message to allow you to pop up a dialog box containing a message and a Confirm button. This is one of many pre-defined facilities that the CAPI offers.

    Note: When you develop CAPI applications, your application windows are run in the same Window system event loop as the LispWorks IDE. This - and the fact that in Common Lisp user code exists in the same global namespace as

    9

  • 2 Getting Started

    10

    the Common Lisp implementation - means that a CAPI application running in the LispWorks IDE can modify the same values as you can concurrently mod-ify from one of the the LispWorks IDE programming tools.

    For example, your CAPI application might have a button that, when pressed, sets a slot in a particular object that you could also set by hand in the Listener. Such introspection can be useful but can also lead to unexpected values and behavior while testing your application code.

  • 3

    3 General Properties of CAPI Panes

    This chapter contains information that does not belong in the more specific sections that follow, including functionality common to several (or most) pane classes. It also introduces classes allowing you to create more common win-dowing elements, beyond the few mentioned in Chapter 2, Getting Started.

    Before trying out the examples in this chapter, define the functions test-callback and hello in your Listener. The first displays the list of arguments it is given, and returns nil. The second just displays a message.

    (defun test-callback (data interface) (display-message "Data ~S in interface ~S" data interface))

    (defun hello (data interface) (declare (ignore data interface)) (display-message "Hello World"))

    We will use these callbacks in the examples that follow.

    3.1 Generic propertiesBecause CAPI elements are just like CLOS classes, many elements share a common set of properties. The remainder of this section describes the proper-ties that all the classes described in this chapter inherit.

    11

  • 3 General Properties of CAPI Panes

    12

    3.1.1 Scroll bars

    The CAPI lets you specify horizontal or vertical scroll bars for any subclass of the simple-pane element (including all of the classes described in this chapter).

    Horizontal and vertical scroll bars can be specified using the keywords :horizontal-scroll and :vertical-scroll. By default, both :vertical-scroll and :horizontal-scroll are nil.

    3.1.2 Background and foreground colors

    All subclasses of the simple pane element can have different foreground and background colors, using the :background and :foreground initargs of simple-pane. For example, including

    :background :blue:foreground :yellow

    in the make-instance of a text pane would result in a pane with a blue back-ground and yellow text.

    3.1.3 Fonts

    The CAPI interface supports the use of other fonts for text in title panes and other CAPI objects, such as buttons, through the use of the :font initarg of simple-pane.. If the CAPI cannot find the specified font it reverts to the default font. The :font keyword applies to data following the :text key-word. The value is a graphics ports font-description object specifying vari-ous attributes of the font.

    On systems running X Windows, the xlsfonts command can be used to list which fonts are available. The X logical font descriptor can be explicitly passed as a string to the :font initarg, which will convert them.

    Here is an example of a title-pane with an explicit font:

  • 3.1 Generic properties

    (contain (make-instance 'title-pane :text "A title pane" :font (gp:make-font-description :family "Times" :size 12 :weight :medium :slant :roman)))

    Here is an example of using :font to produce a title pane with larger letter-ing. Note that the CAPI automatically resized the pane to fit around the text.

    (contain (make-instance 'title-pane :text "A large piece of text" :font (gp:make-font-description :family "Times" :size 34 :weight :medium :slant :roman)))

    Figure 3.1 An example of the use of font descriptions

    3.1.4 Mnemonics

    This section applies to Microsoft Windows and GTK+ only.

    Underlined letters in menus, titles and buttons are called mnemonics. The user can select the element by pressing the corresponding key.

    3.1.4.1 Controlling Mnemonics

    For individual buttons, menus, menu items and title panes, you can use the :mnemonic initarg to control them. For example:

    13

  • 3 General Properties of CAPI Panes

    14

    (capi:contain (make-instance 'capi:push-button :data "FooBar" :mnemonic #\B))

    For more information on mnemonics in buttons, see Mnemonics in buttons on page 34.

    For information on controlling mnemonics in button panels, see Mnemonics in button panels on page 46. For information on controlling mnemonics in menus, see Mnemonics in menus on page 115.

    The initarg :mnemonic-title allows you to specify the mnemonic in the title for many pane classes including list-panel, text-input-pane and option-pane. Also grid-layout supports mnemonic-title when has-title-column-p is true. For the details see titled-object.

    3.1.4.2 Mnemonics on Microsoft Windows

    On Microsoft Windows the user can make the mnemonics visible by holding down the Alt key.

    Windows can hide mnemonics when the user is not using the keyboard. This is controlled in Windows 8 by

    Control Panel > Ease of Access > Ease of Access Center > Make the keyboard eas-ier to use > Underline keyboard shortcuts and access keys

    and in Windows XP by

    Control Panel > Display > Appearance > Effects > Hide underlined letters...

    3.1.5 Focus

    The focus is where keyboard gestures are sent.

    You can specify that a pane should or should not get the focus by using the initarg :accepts-focus-p (defined for element). By default interactive ele-ments except menus accept focus, and non-interactive elements do not accept focus, so normally you do not need to use :accepts-focus-p.

  • 3.1 Generic properties

    3.1.5.1 Initial focus

    By default, when a window first appears the focus is in the top-left pane that accepts focus. You can override this by using the initarg :initial-focus or using the accessor pane-initial-focus on interfaces and layouts, and using the initarg :initial-focus-item for choices (check-button-panel for example).

    3.1.5.2 Querying the focus

    The function pane-descendant-child-with-focus can find a child pane that has the focus, when given as argument a pane with children such as a layout, an interface, or certain choices including a button-panel and toolbar.

    The function pane-has-focus-p can be used to determine if a specific pane has the focus.

    3.1.5.3 Setting the focus dynamically

    The function set-pane-focus can be used to set the focus to a pane inside an active window. If you need to ensure that the window is active, you can use activate-pane, which activates the window and sets the focus. For panes that have children (as described in Querying the focus on page 15) the actual pane that receives the focus is the "initial focus", as described Initial focus on page 15.

    When set-pane-focus is called, just before it actually sets the focus, it calls the generic function pane-got-focus with the interface and the pane. You can define your own method (specialized on your own interface class) to per-form any processing that may be required.

    3.1.6 Mouse cursor

    The mouse cursor of a pane can be specified by the initarg :cursor or acces-sor simple-pane-cursor. The cursor to be used needs to be a result of a call to load-cursor.

    It is possible to set an "override" cursor in an interface, which sets the cursors in all its panes. That is typically used to temporarily set the cursor while the

    15

  • 3 General Properties of CAPI Panes

    16

    interface is in a different input state from the normal state. This feature does not work on Cocoa.

    3.2 Base classesMost CAPI classes inherit from capi-object, which has a plist and a name. The subclasses of capi-object are:

    element The class of all elements that corresponding to an underlying window system element. element defines geometry functionality including geometry hints (see Specifying geometry hints on page 78), and a few other basic properties. Note however that not all sub-classes of element correspond to an underlying ele-ment: some of them are a composition of several elements, and some of them are layout elements.

    Subclasses of element are menu for menus (chapter 8), and simple-pane for all other display elements. The subclasses contain layout (Chapter 6, Laying Out CAPI Panes), which is used to arrange CAPI elements, and interface (Chapter 10, Defining Interface Classes - top level windows), which represents a window, and classes that correspond to specific display elements like but-ton (Button elements on page 31).

    callbacks A mixin class for active elements that need to respond to user input, defining various callbacks (Callbacks on page 19). item, collection and menu-object (par-ent of menu and menu-component) inherit from call-backs.

    item A mixin class for elements that have a single piece of text like menu-item and button. It can also be used as a way of making individual items in collections/choices (Chapter 5, Choices - panes with items) have their own callbacks and properties. item inherits from call-backs.

    pinboard-object

  • 3.3 Specifying titles

    The superclass of pinboard objects, are lightweight graphical objects which are displayed inside pinboard-layout (Creating graphical objects on page 184).

    collection and subclass choice

    Choice is the mixin class for all elements that have items (Chapter 5, Choices - panes with items). collec-tion (and hence choice) inherits from callbacks. The subclasses of choice that can be displayed inherit from simple-pane too.

    3.3 Specifying titlesIt is possible to specify a title for a window, or part of a window. Several of the examples that you have already seen have used titles. There are two ways that you can create titles:

    Use the title-pane class, or

    Specify a title directly to any subclass of titled-object.

    3.3.1 Title panes

    A title-pane is a blank pane into which text can be placed in order to form a title.

    (setq title (make-instance 'title-pane :visible-min-width 200 :text "Title"))

    (contain title)

    Figure 3.2 A title pane

    17

  • 3 General Properties of CAPI Panes

    18

    3.3.2 Specifying titles directly

    You can specify a title directly to all CAPI panes, using the :title keyword. This is much easier than using title-panes, since it does not necessitate using a layout to group two elements together.

    Any class that is a subclass of titled-object supports the :title keyword. All of the standard CAPI panes inherit from this class. You can find all the subclasses of titled-object by using the Class Browser tool in the Lisp-Works IDE.

    3.3.2.1 Window titles

    Specify a title for a CAPI window by supplying the :title initarg for the interface, and access it with interface-title.

    Further control over the title of your application windows can be achieved by using set-default-interface-prefix-suffix and/or specializing inter-face-extend-title as illustrated in Controlling the interface title on page 148.

    You can call interface-display-title to get the string that is actually dis-played (or would be displayed if the interface was displayed).

    3.3.2.2 Titles for elements

    The position of any title can be specified by using the :title-position key-word. Most panes default their title-position to :top, although some use :left.

    You can place the title in a frame (like a groupbox) around its element by specifying :title-position :frame.

    You may specify the font used in the title via the keyword :title-font.

    The title of a titled-object, and its font, may be changed interactively with the use of setf, if you wish.

    1. Create a push button by evaluating the code below:

  • 3.4 Callbacks

    (setq button (make-instance 'push-button :text "Hello" :title "Press: " :title-position :left :callback 'hello))

    (contain button)

    2. Now evaluate the following:

    (apply-in-pane-process button #'(setf titled-object-title) "Press here: " button)

    As soon as the form is evaluated, the title of the pane you just created changes.

    3. Lastly evaluate the following:

    (apply-in-pane-process button #'(setf titled-object-title-font) (gp:merge-font-descriptions (gp:make-font-description :size 42) (gp:convert-to-font-description button (titled-object-title-font button))) button)

    Notice how the window automatically resizes in steps 2 and 3, to make allow-ance for the new size of the title.

    3.4 CallbacksThe class callbacks is the superclass of all the CAPI objects that receive call-back calls in response to user gestures, excluding output panes. This includes collections and choices, buttons, menus, menu components, menu items and item-pinboard-object. The actual interaction depends on the specific class.

    The arguments that callbacks are called with can be specified by the initarg :callback-type. When the argument contain the interface, the actual inter-face can be specified to be another interface by using attach-interface-for-callback. The function element-interface-for-callback can be used to find which interface is going to be used in a callback.

    Callbacks can be aborted using abort-callback.

    There is more detail about the callbacks available in choices in Callbacks in choices on page 63.

    19

  • 3 General Properties of CAPI Panes

    20

    Note: output-pane and its subclasses implement callback calls by the input-model mechanism.

    3.5 Displaying and entering textThere are a variety of ways in which an application can display text, accept text input or allow editing of text by the user:

    Display panes

    Show non-editable text.

    Text input panes

    Used for entering short pieces of text.

    Editor panes

    Used for dealing with large amounts of text such as files. Also offer full configurable editor functionality.

    Rich text panes

    Support formatted text. Available on Cocoa and Microsoft Windows only.

    3.5.1 Display panes

    You can use a display-pane to display text messages on the screen. The text in these messages cannot be edited, so they can be used by the application to present a message to the user. The :text initarg can be used to specify the message that is to appear in the pane.

    1. Create a display pane by evaluating the code below:

  • 3.5 Displaying and entering text

    (setq display (make-instance 'display-pane :text "This is a message"))

    (contain display)

    Figure 3.3 A display pane

    Note that the window title, which defaults to "Container" for windows created by contain, may appear truncated.

    You can access the text (get and set) of a display-pane by the accessor dis-play-pane-text. You can access the selection by display-pane-selection-p, display-pane-selection, set-display-pane-selection and display-pane-selected-text.

    3.5.2 Text input panes

    When you want the user to enter a line of text, such as a search string, use a text-input-pane.

    (setq text (make-instance 'text-input-pane :title "Search: " :callback 'test-callback))

    (contain text)

    Figure 3.4 A text input pane

    Notice that the default title position for text input panes is :left.

    21

  • 3 General Properties of CAPI Panes

    22

    You can place text programmatically in the text input pane by supplying a string for the :text initarg, or later by calling (setf text-input-pane-text) in the appropriate process.

    You can use set-text-input-pane-selection to control the selection in the text input pane:

    (setq tip (make-instance 'capi:text-input-pane :title "Search: " :text "Foo Bar Baz"))

    (capi:set-text-input-pane-selection tip (length "Foo ") (+ (length "Foo ") (length "Bar")))

    (capi:contain tip)

    text-input-pane has many callbacks which allow the program to perform various tasks as the user changes the text, the selection or the caret position, or enters/leaves the pane. It is possible to respond to specific keyboard gestures, characters or otherwise (like Up arrow). text-input-pane has also options for performing completion on the user input.

    You can add toolbar buttons for easier user input in a text-input-pane via the :buttons initarg. This example allows the user to enter the filename of an existing Lisp source file, either directly or by selecting the file in a dialog raised by the Browse File button. There is also a Cancel button, but the default OK button is not displayed:

    (capi:contain (make-instance 'capi:text-input-pane :buttons (list :cancel t :ok nil :browse-file (list :operation :open :filter "*.LISP;*.LSP"))))

    For a larger quantity of text use multi-line-text-input-pane.

    On Cocoa, text-input-pane can also be made to look like a search field, using the initarg :search-field and related initargs.

  • 3.5 Displaying and entering text

    For entering passwords use the subclass password-pane, which does not dis-play the actual characters that the user types.

    3.5.3 Editor panes

    An editor-pane is a pane which displays text and allows the user to edit it. The text is held and manipulated in a separate module, the Editor, which is implemented in the "EDITOR" package.

    The Editor is optimized to deal with large amounts of text, whether that is because a single document contains large amount of text or because the user wants to edit many texts at the same time. It has a large set of commands that the user can invoke to perform a variety of tasks, including many kinds of editing and search operations, integration with the LispWorks IDE, and vari-ous other tasks. It also has a programmatic interface to manipulate the text, which is exported from the package "EDITOR". The user interface and the pro-grammatic interface are both documented in the LispWorks Editor User Guide, and the LispWorks IDE uses editor-pane for editing.

    The interaction of the Editor emulates either Emacs style or the native style of Mac OS X, Microsoft Windows or KDE/Gnome as appropriate. There is a glo-bal default setting (native on Windows, Emacs elsewhere), which can be set in a runtime image by the Delivery keyword :editor-style. In particular, you fix the style for editor-pane in your interfaces by defining your method for interface-keys-style. See the chapter "Emulation" in the LispWorks Editor User Guide for more detail about the different styles.

    From the CAPI side you can access the editor structures that hold the text by using editor-pane-buffer, which returns an editor:buffer object which holds the text. You can then use the programmatic Editor interface to access and manipulate the text.

    For example, the following code inserts the string "foo" in the end of the edi-tor pane (really in the end of the buffer):

    (let ((buffer (capi:editor-pane-buffer editor-pane))) (let ((point (editor:buffers-end buffer))) (editor:insert-string point "foo")))

    Above, point is an editor:point object.

    23

  • 3 General Properties of CAPI Panes

    24

    Alternatively, editor commands can be executed by passing the name of an editor command to call-editor.

    Note that the editor objects can be accessed from any process (as opposed to the CAPI elements), because they use locks. Programmers can use the locks to group several editor operations so that they happen "atomically".

    It is possible to specify that an editor-pane has an attached Echo Area which is where non-editing interactions (for example entering a command name or filename) occur. To add an Echo Area, use the :echo-area initarg. Otherwise, a special window pops up when such interaction needs to occur.

    The variables *editor-cursor-active-style*, *editor-cursor-color*, *editor-cursor-drag-style* and *editor-cursor-inactive-style* can be used to control the appearance of the cursor. When adding an echo area, the inactive cursor style can be controlled separately by *editor-cur-sor-inactive-style*.

    An editor-pane can have input callbacks (before and after) and a change callback. These are described in Editor pane callbacks on page 24.

    On the CAPI side there are few additional functions that can be used on an editor-pane. These are described in Additional editor-pane functions on page 26.

    3.5.3.1 Editor pane callbacks

    You can use the initarg :change-callback to specify a function which is called whenever the editor buffer under the editor-pane changes. The value change-callback can be set either by:

    (make-instance 'capi:editor-pane :change-callback ...)

    or

    (setf capi:editor-pane-change-callback)

    The current value can be queried by the accessor editor-pane-change-callback.

    The change-callback function must have signature:

    change-callback pane point old-length new-length

  • 3.5 Displaying and entering text

    pane is the editor-pane itself.

    point is an editor:point object where the modification to the underlying buffer starts. point is a temporary point, and is not valid outside the scope of the change callback. For more information about editor:point objects, see "Points" in the LispWorks Editor User Guide.

    old-length is the length of the affected text following point, prior to the modifi-cation.

    new-length is the length of the affected text following point, after the modifica-tion has occurred.

    Typical calls to the change-callback occur on insertion of text (when old-length is 0) and on deletion of text (when new-length is 0). There can be other combina-tions, for example, after executing the Uppercase Region editor command, change-callback be called with both old-length and new-length being the length of the region. The same is true for changing editor text properties.

    The change-callback is always executed in the process of pane (as if by apply-in-pane-process).

    The change-callback is permitted to modify the buffer of pane, and other editor buffers. The callback is disabled inside the dynamic scope of the call, so there are no recursive calls to the change-callback of pane. However, changes done by the callback may trigger change-callback calls on other editor-panes, whether in the same process or in another process.

    There is an example illustrating the use of change-callback in:

    (example-edit-file "capi/editor/change-callback")

    You can use the initargs :before-input-callback and :after-input-callback to add input callbacks which are called when call-editor is called. Note that the default input-model also generates calls to call-editor, so unless you override the default input-model these input callbacks are called for all keyboard and mouse gestures (other than gestures that are processed by a non-focus completer window).

    In both cases (before-input-callback and after-input-callback) the argument is a function that takes two arguments: the editor pane itself and the input gesture (the second argument to call-editor).

    25

  • 3 General Properties of CAPI Panes

    26

    call-editor may redirect gestures to another pane. For example, gestures to an editor-pane are redirected to the echo area while it is used. In this case before-input-callback is called more than once for the same gesture, but after-input-callback is called only once for each gesture, on the pane that actually processed the gesture.

    3.5.3.2 Additional editor-pane functions

    The contents of the buffer can be retrieved and set by editor-pane-text and (setf editor-pane-text).

    modify-editor-pane-buffer can be used to change the text and the filling at the same time.

    editor-pane-line-wrap-marker, editor-pane-line-wrap-face and *default-editor-pane-line-wrap-marker* control the appearance of the marker that indicates wrapping of lines that are too long.

    The function editor-pane-selected-text returns the selected text (if any), and editor-pane-selected-text-p checks if there is a selection.

    You can call set-default-editor-pane-blink-rate to set the default blink rate of the cursor on all editor panes. You can specialize editor-pane-blink-rate to control the blink rate of specific panes, and use editor-pane-native-blink-rate to query the blink rate of the underlying GUI system. Note that the underlying system will normally allow the user to change this value.

    The function print-editor-buffer can be used to print the contents of the editor buffer.

    The function set-editor-parenthesis-colors can be used to control parenthesis coloring in Lisp mode.

    Editor panes support composition of characters using input methods (see com-position-callback in output-pane) by having a default callback editor-pane-default-composition-callback, which handles it mostly right. You can specify your own callback, which can also call editor-pane-default-com-position-callback to do the actual work.

    The editor-pane is geared towards editing files, and in particular it tries to guard against loss of work by keeping backup files and auto-save files, and

  • 3.6 Displaying rich text

    asking the user before closing an unsaved buffer. When you use an editor-pane for other purposes, and therefore do not need all of this functionality, you should use temporary buffers. Create a temporary buffer by supplying the initarg :buffer-name :temp, or create your own temporary buffer explic-itly by (editor:make-buffer ... :temporary t).

    You can make an editor-pane be non-editable by users by supplying the ini-targ :enabled :read-only, or completely disable it with :enabled nil.

    3.6 Displaying rich textOn Microsoft Windows and Cocoa, rich-text-pane allows you to display and edit rich text. It supports character attributes such as font, size and color, and paragraph attributes such as alignment and tab-stops.

    See this example:

    (example-edit-file "capi/applications/rich-text-editor")

    3.7 Hierarchy of panesEvery element that is displayed has a parent, which you can find by the ele-ment accessor element-parent. The ultimate ancestor is a screen, which you can find by element-screen. The element is inside some window which is associated with a CAPI interface instance (that is, an instance of subclass of interface) which is called the "top level interface" and can be found by by top-level-interface. Note that inside MDI on Microsoft Windows the top level interface is the one inside the MDI, rather than the enclosing MDI win-dow. You can test whether an object is a top level interface by top-level-interface-p. The function element-container returns the parent of the top level interface, that is the screen outside the MDI, but the document-frame inside the MDI.

    Some elements have children. You can operate on the children of an element by using map-pane-children or map-pane-descendant-children. These functions will work on any element, and they will do nothing for elements without children.

    The implementation of the panes you specify may internally involve generat-ing more panes, and element-parent, map-pane-children and map-pane-

    27

  • 3 General Properties of CAPI Panes

    28

    descendant-children will find these. Thus when using these functions you cannot assume that you know the hierarchy, and you need to check if the pane that you got is the right one. For example, if you create a layout like this:

    (setq layout (make-instance 'capi:row-layout :description(list (make-instance 'capi:list-panel))))

    then doing something like:

    (capi:map-pane-children layout #'(lambda (pane) (setf (capi:collection-items pane) nil)

    may not work, because the list panel may not be a direct child of the layout. In most cases it is best to record the actual panes so you know where to access them (most commonly in a slot in the interface). Alternatively you can use map-pane-descendant-children with a function that checks each child pane before operating on it.

    Note that all these functions give useful results only for displayed elements.

    3.8 Accessing pane geometryThe functions simple-pane-visible-height, simple-pane-visible-width, and simple-pane-visible-size can be used to read the visible geometry of a pane. Other geometrical properties of a pane can be accessed by with-geometry, which binds variables to the various geometrical properties of the pane.

    3.9 Special kinds of windows

    3.9.1 Browser pane

    On Microsoft Windows and Cocoa, browser-pane implements embedding of a basic web browser. It allows you to display HTML, navigate, refresh, handle errors, redirect to another URL, and so on.

  • 3.9 Special kinds of windows

    3.9.2 OLE embedding and control

    On Microsoft Windows ole-control-pane implements embedding of OLE control components. You can also embed CAPI windows inside other applica-tions using ole-control-component. You define an OLE control component (an Automation class that implements OLE Control protocols) using define-ole-control-component, and other (non-LispWorks) applications can use it.

    3.9.3 Cocoa views and application interfaces

    On Cocoa, you can use cocoa-view-pane to display an arbitrary Cocoa View. You can specify the name of the Cocoa view class to create, and a function that is called to initialize it. The function cocoa-view-pane-view can be used to access the Cocoa view after it has been created.

    The class cocoa-default-application-interface is a special class for defining application interfaces, which gives you control of application-wide properties which are not associated with specific windows. This includes the Application menu and default menu bar items, Dock context menu, applica-tion message processing and display state of the whole application.

    3.9.4 Slider, Progress bar and Scroll bar

    The classes slider and scroll-bar implement panes that show the value of some quantity and allow the user to change it interactively.

    slider is intended to be used in general for any pseudo-continuous quantity that the user should be able to manipulate.

    scroll-bar is intended to be used for scrolling. Normally a scroll bar is spec-ified simply by supplying the :vertical-scroll or :horizontal-scroll initarg when making the pane that needs scrolling, but in some circumstances an explicit scroll bar may be useful.

    The class progress-bar implements a pane that shows the value of some quantity and is used to indicate progress in performing some task.

    All of these classes inherit from range-pane, which defines the various values that are used and the orientation. In addition to the range-pane accessors, there is also the function range-set-sizes which you can use to set several values at the same time.

    29

  • 3 General Properties of CAPI Panes

    30

    3.9.5 Text input range

    text-input-range is a special pane for entering numeric values, allowing the user to either type the number or use buttons to adjust the value.

    3.9.6 Stream panes

    There are three subclasses of editor-pane which handle Common Lisp streams.

    3.9.6.1 Collector panes

    A collector-pane displays anything printed to the stream associated with it. Background output windows, for instance, are examples of collector panes.

    (setq collector (make-instance 'collector-pane :title "Example collector pane:"))

    (contain collector)

    (princ "abc" (collector-pane-stream collector))

    The collector-pane has a mechanism to temporarily make it the child of a parent switchable-layout, so the user can see the output printed into it. The functions map-typeout and unmap-typeout do the switch, and the macro with-random-typeout can be used to do both switches and to also bind a variable to the stream of the collector-pane. This mechanism is used in the LispWorks IDE to show the output of Compile Buffer and other operations.

    3.9.6.2 Interactive panes

    An interactive-pane is the building block on which listener-pane is built.

    (contain (make-instance 'interactive-pane :title "Interactive pane"))

    You can simulate user input into an interactive-pane by interactive-pane-execute-command.

  • 3.10 Button elements

    Note: interactive-pane is probably too difficult to use, due to the complexi-ties involved with the interaction with the Editor. However, for its subclass listener-pane, the system deals with all these issues.

    3.9.6.3 Listener panes

    The listener-pane class is a subclass of interactive-pane, and allows you to create interactive Common Lisp sessions. You may occasionally want to include a listener pane in a tool (as, for instance, in the LispWorks IDE Debug-ger).

    (contain (make-instance 'listener-pane :title "Listener"))