UIPainter.st
changeset 765 27936ff059d3
parent 755 cfbbec0a33c6
child 774 5ca0853de0bc
equal deleted inserted replaced
764:5722b94330ef 765:27936ff059d3
     1 "
     1 "
     2  COPYRIGHT (c) 1995 by eXept Software AG
     2  COPYRIGHT (c) 1995-1998 by eXept Software AG
     3               All Rights Reserved
     3               All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 
    13 
    14 ToolApplicationModel subclass:#UIPainter
    14 ToolApplicationModel subclass:#UIPainter
    15 	instanceVariableNames:'treeView selectionPanel tabSelection specClass specSelector
    15 	instanceVariableNames:'specClass specSelector specSuperclass aspects treeView specCanvas
    16 		specSuperclass aspects layoutCanvas helpCanvas specCanvas
    16 		selectionPanel tabSelection layoutCanvas helpCanvas modified'
    17 		transcript modified'
       
    18 	classVariableNames:''
    17 	classVariableNames:''
    19 	poolDictionaries:''
    18 	poolDictionaries:''
    20 	category:'Interface-UIPainter'
    19 	category:'Interface-UIPainter'
    21 !
    20 !
    22 
    21 
    29 
    28 
    30 !UIPainter class methodsFor:'documentation'!
    29 !UIPainter class methodsFor:'documentation'!
    31 
    30 
    32 copyright
    31 copyright
    33 "
    32 "
    34  COPYRIGHT (c) 1995 by eXept Software AG
    33  COPYRIGHT (c) 1995-1998 by eXept Software AG
    35               All Rights Reserved
    34               All Rights Reserved
    36 
    35 
    37  This software is furnished under a license and may be used
    36  This software is furnished under a license and may be used
    38  only in accordance with the terms of that license and with the
    37  only in accordance with the terms of that license and with the
    39  inclusion of the above copyright notice.   This software may not
    38  inclusion of the above copyright notice.   This software may not
    44 
    43 
    45 !
    44 !
    46 
    45 
    47 documentation
    46 documentation
    48 "
    47 "
    49     The GUI Painter allows the user to build its own applications providing a graphical
    48     The GUI Painter provides the user with a graphical user interface for building own 
    50     user interface to building components and to define the behavior of the components
    49     interfaces by interactively assembling widgets and defining the behavior of the widgets.
    51     during runtime. The resulting specifications can be installed as methods on 
    50     The resulting interface specifications can be saved as methods on the application
    52     classes, typically subclasses of an ApplicationModel. These specifications
    51     classes, typically subclasses of the class ApplicationModel. These specifications
    53     are used by the UIBuilder to generate the application window and its component
    52     are used by the UIBuilder to generate the application window and its widgets when 
    54     structues when open the application.
    53     opening the application.
    55 
    54 
    56     [start with:]
    55     [start with:]
    57         UIPainter open
    56         UIPainter open
    58 
    57 
    59     [author:]
    58     [author:]
    60         Claus Gittinger, eXept Software AG
    59         Claus Gittinger, eXept Software AG
    61         Claus Atzkern, eXept Software AG
    60         Claus Atzkern, eXept Software AG
       
    61         Thomas Zwick, eXept Software AG
    62 
    62 
    63     [see also:]
    63     [see also:]
    64         UIBuilder
    64         UIBuilder
    65         ApplicationModel
    65         ApplicationModel
    66         UISpecification
    66         UISpecification
    72 
    72 
    73 openOnClass:aClass andSelector:aSelector
    73 openOnClass:aClass andSelector:aSelector
    74     "open a GUI Painter on aClass and (windowSpec) aSelector
    74     "open a GUI Painter on aClass and (windowSpec) aSelector
    75     "
    75     "
    76     ^ self new openOnClass:aClass andSelector:aSelector
    76     ^ self new openOnClass:aClass andSelector:aSelector
    77 !
       
    78 
       
    79 painter:aBuilderView
       
    80     "set the painter
       
    81     "
       
    82     |application|
       
    83 
       
    84     application := self new.
       
    85     application painter:aBuilderView.
       
    86   ^ application open
       
    87 ! !
    77 ! !
    88 
    78 
    89 !UIPainter class methodsFor:'ST-80 queries'!
    79 !UIPainter class methodsFor:'ST-80 queries'!
    90 
    80 
    91 preferenceFor:aSymbol
    81 preferenceFor:aSymbol
    94     ^ false
    84     ^ false
    95 
    85 
    96 
    86 
    97 ! !
    87 ! !
    98 
    88 
    99 !UIPainter class methodsFor:'accessing-defaults'!
    89 !UIPainter class methodsFor:'accessing'!
   100 
    90 
   101 defaultNameOfCanvas
    91 defaultNameOfCanvas
   102     "returns the default name (id) of the application
    92     "returns the default name of the application"
   103     "
    93 
   104     ^'NewApplication'
    94     ^'NewApplication'
   105 
    95 
   106 ! !
    96 ! !
   107 
    97 
   108 !UIPainter class methodsFor:'help specs'!
    98 !UIPainter class methodsFor:'help specs'!
   464 
   454 
   465 dialogSpecForDefiningClassAndSelector
   455 dialogSpecForDefiningClassAndSelector
   466     "This resource specification was automatically generated
   456     "This resource specification was automatically generated
   467      by the UIPainter of ST/X."
   457      by the UIPainter of ST/X."
   468 
   458 
   469     "Do not manually edit this. If it is corrupted,
   459     "Do not manually edit this!! If it is corrupted,
   470      the UIPainter may not be able to read the specification."
   460      the UIPainter may not be able to read the specification."
   471 
   461 
   472     "
   462     "
   473      UIPainter new openOnClass:UIPainter andSelector:#dialogSpecForDefiningClassAndSelector
   463      UIPainter new openOnClass:UIPainter andSelector:#dialogSpecForDefiningClassAndSelector
   474      UIPainter new openInterface:#dialogSpecForDefiningClassAndSelector
   464      UIPainter new openInterface:#dialogSpecForDefiningClassAndSelector
   480      
   470      
   481        #(#FullSpec
   471        #(#FullSpec
   482           #window: 
   472           #window: 
   483            #(#WindowSpec
   473            #(#WindowSpec
   484               #name: 'GUI Painter'
   474               #name: 'GUI Painter'
   485               #layout: #(#LayoutFrame 575 0 296 0 921 0 455 0)
   475               #layout: #(#LayoutFrame 240 0 345 0 586 0 504 0)
   486               #label: 'GUI Painter'
   476               #label: 'GUI Painter'
   487               #min: #(#Point 10 10)
   477               #min: #(#Point 350 160)
   488               #max: #(#Point 1152 900)
   478               #max: #(#Point 500 160)
   489               #bounds: #(#Rectangle 575 296 922 456)
   479               #bounds: #(#Rectangle 240 345 587 505)
   490               #usePreferredExtent: false
   480               #usePreferredExtent: false
   491           )
   481           )
   492           #component: 
   482           #component: 
   493            #(#SpecCollection
   483            #(#SpecCollection
   494               #collection: 
   484               #collection: 
   558 
   548 
   559 dialogSpecForDefiningGridParameters
   549 dialogSpecForDefiningGridParameters
   560     "This resource specification was automatically generated
   550     "This resource specification was automatically generated
   561      by the UIPainter of ST/X."
   551      by the UIPainter of ST/X."
   562 
   552 
   563     "Do not manually edit this. If it is corrupted,
   553     "Do not manually edit this!! If it is corrupted,
   564      the UIPainter may not be able to read the specification."
   554      the UIPainter may not be able to read the specification."
   565 
   555 
   566     "
   556     "
   567      UIPainter new openOnClass:UIPainter andSelector:#dialogSpecForDefiningGridParameters
   557      UIPainter new openOnClass:UIPainter andSelector:#dialogSpecForDefiningGridParameters
   568      UIPainter new openInterface:#dialogSpecForDefiningGridParameters
   558      UIPainter new openInterface:#dialogSpecForDefiningGridParameters
   574      
   564      
   575        #(#FullSpec
   565        #(#FullSpec
   576           #window: 
   566           #window: 
   577            #(#WindowSpec
   567            #(#WindowSpec
   578               #name: 'GUI Painter'
   568               #name: 'GUI Painter'
   579               #layout: #(#LayoutFrame 575 0 296 0 856 0 493 0)
   569               #layout: #(#LayoutFrame 240 0 345 0 521 0 542 0)
   580               #label: 'GUI Painter'
   570               #label: 'GUI Painter'
   581               #min: #(#Point 10 10)
   571               #min: #(#Point 300 200)
   582               #max: #(#Point 1280 1024)
   572               #max: #(#Point 300 200)
   583               #bounds: #(#Rectangle 575 296 857 494)
   573               #bounds: #(#Rectangle 240 345 522 543)
   584               #usePreferredExtent: false
   574               #usePreferredExtent: false
   585           )
   575           )
   586           #component: 
   576           #component: 
   587            #(#SpecCollection
   577            #(#SpecCollection
   588               #collection: 
   578               #collection: 
   667      
   657      
   668        #(#FullSpec
   658        #(#FullSpec
   669           #window: 
   659           #window: 
   670            #(#WindowSpec
   660            #(#WindowSpec
   671               #name: 'GUI Painter'
   661               #name: 'GUI Painter'
   672               #layout: #(#LayoutFrame 123 0 269 0 662 0 743 0)
   662               #layout: #(#LayoutFrame 106 0 256 0 625 0 730 0)
   673               #label: 'GUI Painter'
   663               #label: 'GUI Painter'
   674               #min: #(#Point 540 490)
   664               #min: #(#Point 560 460)
   675               #max: #(#Point 1160 870)
   665               #max: #(#Point 1160 870)
   676               #bounds: #(#Rectangle 123 269 663 744)
   666               #bounds: #(#Rectangle 106 256 626 731)
   677               #menu: #menu
   667               #menu: #menu
   678               #usePreferredExtent: false
   668               #usePreferredExtent: false
   679           )
   669           )
   680           #component: 
   670           #component: 
   681            #(#SpecCollection
   671            #(#SpecCollection
   783                                         #name: 'openWidgetDocumentationButton'
   773                                         #name: 'openWidgetDocumentationButton'
   784                                         #layout: #(#LayoutFrame -32 1 -1 0 0 1 31 0)
   774                                         #layout: #(#LayoutFrame -32 1 -1 0 0 1 31 0)
   785                                         #activeHelpKey: #editOpenSpecDocumentation
   775                                         #activeHelpKey: #editOpenSpecDocumentation
   786                                         #hasCharacterOrientedLabel: false
   776                                         #hasCharacterOrientedLabel: false
   787                                         #label: 'helpIcon'
   777                                         #label: 'helpIcon'
   788                                         #model: #openWidgetDocumentation
   778                                         #model: #doOpenWidgetDocumentation
   789                                     )
   779                                     )
   790                                      #(#ActionButtonSpec
   780                                      #(#ActionButtonSpec
   791                                         #name: 'cancelButton'
   781                                         #name: 'cancelButton'
   792                                         #layout: #(#LayoutFrame 2 0 -26 1 -1 0.5 -2 1)
   782                                         #layout: #(#LayoutFrame 2 0 -26 1 -1 0.5 -2 1)
   793                                         #activeHelpKey: #commitCancel
   783                                         #activeHelpKey: #commitCancel
   821                     #minorKey: #windowSpecForInfoBar
   811                     #minorKey: #windowSpecForInfoBar
   822                 )
   812                 )
   823               )
   813               )
   824           )
   814           )
   825       )
   815       )
   826 !
       
   827 
       
   828 windowSpecWithTranscriptHelp
       
   829     "This resource specification was automatically generated
       
   830      by the UIPainter of ST/X."
       
   831 
       
   832     "Do not manually edit this!! If it is corrupted,
       
   833      the UIPainter may not be able to read the specification."
       
   834 
       
   835     "
       
   836      UIPainter new openOnClass:UIPainter andSelector:#windowSpecWithTranscriptHelp
       
   837      UIPainter new openInterface:#windowSpecWithTranscriptHelp
       
   838     "
       
   839 
       
   840     <resource: #canvas>
       
   841 
       
   842     ^
       
   843      
       
   844        #(#FullSpec
       
   845           #window: 
       
   846            #(#WindowSpec
       
   847               #name: 'GUI Painter'
       
   848               #layout: #(#LayoutFrame 177 0 249 0 716 0 723 0)
       
   849               #label: 'GUI Painter'
       
   850               #min: #(#Point 10 10)
       
   851               #max: #(#Point 1160 870)
       
   852               #bounds: #(#Rectangle 177 249 717 724)
       
   853               #menu: #menu
       
   854               #usePreferredExtent: false
       
   855           )
       
   856           #component: 
       
   857            #(#SpecCollection
       
   858               #collection: 
       
   859                #(
       
   860                  #(#MenuPanelSpec
       
   861                     #name: 'menuToolbarView'
       
   862                     #layout: #(#LayoutFrame -1 0.0 0 0 -1 1.0 32 0)
       
   863                     #tabable: true
       
   864                     #menu: #menuToolbar
       
   865                 )
       
   866                  #(#VariableVerticalPanelSpec
       
   867                     #name: 'vpanel'
       
   868                     #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
       
   869                     #component: 
       
   870                      #(#SpecCollection
       
   871                         #collection: 
       
   872                          #(
       
   873                            #(#VariableHorizontalPanelSpec
       
   874                               #name: 'hpanel'
       
   875                               #component: 
       
   876                                #(#SpecCollection
       
   877                                   #collection: 
       
   878                                    #(
       
   879                                      #(#ArbitraryComponentSpec
       
   880                                         #name: 'treeView'
       
   881                                         #tabable: true
       
   882                                         #menu: #menuEdit
       
   883                                         #hasHorizontalScrollBar: true
       
   884                                         #hasVerticalScrollBar: true
       
   885                                         #miniScrollerHorizontal: true
       
   886                                         #miniScrollerVertical: true
       
   887                                         #component: #treeView
       
   888                                         #hasBorder: false
       
   889                                     )
       
   890                                      #(#ViewSpec
       
   891                                         #name: 'specHolderView'
       
   892                                         #component: 
       
   893                                          #(#SpecCollection
       
   894                                             #collection: 
       
   895                                              #(
       
   896                                                #(#MenuPanelSpec
       
   897                                                   #name: 'menuToolbar2View'
       
   898                                                   #layout: #(#LayoutFrame -1 0.0 -2 0 -1 1.0 30 0)
       
   899                                                   #enableChannel: #canMoveOrAlignSelection
       
   900                                                   #tabable: true
       
   901                                                   #menu: #menuToolbar2
       
   902                                               )
       
   903                                                #(#NoteBookViewSpec
       
   904                                                   #name: 'noteBook'
       
   905                                                   #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -30 1.0)
       
   906                                                   #enableChannel: #enableChannel
       
   907                                                   #tabable: true
       
   908                                                   #model: #tabModel
       
   909                                                   #menu: #tabList
       
   910                                                   #style: #(#FontDescription #helvetica #medium #roman 10)
       
   911                                                   #canvas: #noteBookView
       
   912                                               )
       
   913                                                #(#HorizontalPanelViewSpec
       
   914                                                   #name: 'horizontalPanelView1'
       
   915                                                   #layout: #(#LayoutFrame -128 1 -1 0 0 1.0 31 0)
       
   916                                                   #component: 
       
   917                                                    #(#SpecCollection
       
   918                                                       #collection: 
       
   919                                                        #(
       
   920                                                          #(#ArrowButtonSpec
       
   921                                                             #name: 'MoveLeftButton'
       
   922                                                             #activeHelpKey: #changePositionLeft
       
   923                                                             #tabable: true
       
   924                                                             #model: #moveSelectionLeft
       
   925                                                             #enableChannel: #canMoveOrAlignSelection
       
   926                                                             #isTriggerOnDown: true
       
   927                                                             #direction: #left
       
   928                                                             #extent: #(#Point 32 32)
       
   929                                                         )
       
   930                                                          #(#ArrowButtonSpec
       
   931                                                             #name: 'MoveRightButton'
       
   932                                                             #activeHelpKey: #changePositionRight
       
   933                                                             #model: #moveSelectionRight
       
   934                                                             #enableChannel: #canMoveOrAlignSelection
       
   935                                                             #isTriggerOnDown: true
       
   936                                                             #direction: #right
       
   937                                                             #extent: #(#Point 32 32)
       
   938                                                         )
       
   939                                                          #(#ArrowButtonSpec
       
   940                                                             #name: 'MoveDownButton'
       
   941                                                             #activeHelpKey: #changePositionDown
       
   942                                                             #model: #moveSelectionDown
       
   943                                                             #enableChannel: #canMoveOrAlignSelection
       
   944                                                             #isTriggerOnDown: true
       
   945                                                             #direction: #down
       
   946                                                             #extent: #(#Point 32 32)
       
   947                                                         )
       
   948                                                          #(#ArrowButtonSpec
       
   949                                                             #name: 'MoveUpButton'
       
   950                                                             #activeHelpKey: #changePositionUp
       
   951                                                             #model: #moveSelectionUp
       
   952                                                             #enableChannel: #canMoveOrAlignSelection
       
   953                                                             #isTriggerOnDown: true
       
   954                                                             #direction: #up
       
   955                                                             #extent: #(#Point 32 32)
       
   956                                                         )
       
   957                                                       )
       
   958                                                   )
       
   959                                                   #horizontalLayout: #fit
       
   960                                                   #verticalLayout: #fit
       
   961                                                   #horizontalSpace: 0
       
   962                                                   #verticalSpace: 0
       
   963                                               )
       
   964                                                #(#HorizontalPanelViewSpec
       
   965                                                   #name: 'modifyPanel'
       
   966                                                   #layout: #(#LayoutFrame 0 0.0 -30 1.0 0 1.0 0 1.0)
       
   967                                                   #component: 
       
   968                                                    #(#SpecCollection
       
   969                                                       #collection: 
       
   970                                                        #(
       
   971                                                          #(#ActionButtonSpec
       
   972                                                             #name: 'cancelButton'
       
   973                                                             #activeHelpKey: #cancel
       
   974                                                             #label: 'Cancel'
       
   975                                                             #tabable: true
       
   976                                                             #model: #cancel
       
   977                                                             #enableChannel: #modifiedChannel
       
   978                                                             #extent: #(#Point 178 24)
       
   979                                                         )
       
   980                                                          #(#ActionButtonSpec
       
   981                                                             #name: 'acceptButton'
       
   982                                                             #activeHelpKey: #accept
       
   983                                                             #label: 'OK'
       
   984                                                             #tabable: true
       
   985                                                             #model: #accept
       
   986                                                             #enableChannel: #modifiedChannel
       
   987                                                             #extent: #(#Point 179 24)
       
   988                                                         )
       
   989                                                       )
       
   990                                                   )
       
   991                                                   #horizontalLayout: #fitSpace
       
   992                                                   #verticalLayout: #fitSpace
       
   993                                                   #horizontalSpace: 3
       
   994                                                   #verticalSpace: 3
       
   995                                               )
       
   996                                             )
       
   997                                         )
       
   998                                         #borderWidth: 1
       
   999                                     )
       
  1000                                   )
       
  1001                               )
       
  1002                               #level: 1
       
  1003                               #handles: #(#Any 0.318264 1.0)
       
  1004                           )
       
  1005                            #(#TextEditorSpec
       
  1006                               #name: 'HelpTranscript'
       
  1007                               #hasHorizontalScrollBar: true
       
  1008                               #hasVerticalScrollBar: true
       
  1009                               #miniScrollerHorizontal: true
       
  1010                               #miniScrollerVertical: true
       
  1011                               #isReadOnly: true
       
  1012                           )
       
  1013                         )
       
  1014                     )
       
  1015                     #handles: #(#Any 0.880597 1.0)
       
  1016                 )
       
  1017                  #(#UISubSpecification
       
  1018                     #name: 'infoBarSubSpec'
       
  1019                     #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
       
  1020                     #majorKey: #ToolApplicationModel
       
  1021                     #minorKey: #windowSpecForInfoBar
       
  1022                 )
       
  1023               )
       
  1024           )
       
  1025       )
       
  1026 ! !
   816 ! !
  1027 
   817 
  1028 !UIPainter class methodsFor:'menu specs'!
   818 !UIPainter class methodsFor:'menu specs'!
  1029 
   819 
  1030 menu
   820 menu
  1214                           #activeHelpKey: #settingsRedefineAspectMethods
  1004                           #activeHelpKey: #settingsRedefineAspectMethods
  1215                           #enabled: #hasSpecClass
  1005                           #enabled: #hasSpecClass
  1216                           #indication: #redefineAspectMethods:
  1006                           #indication: #redefineAspectMethods:
  1217                       )
  1007                       )
  1218                        #(#MenuItem
  1008                        #(#MenuItem
  1219                           #label: 'Transcript Help'
       
  1220                           #activeHelpKey: #settingsTranscriptHelp
       
  1221                           #indication: #transcriptHelp:
       
  1222                       )
       
  1223                        #(#MenuItem
       
  1224                           #label: '-'
  1009                           #label: '-'
  1225                       )
  1010                       )
  1226                        #(#MenuItem
  1011                        #(#MenuItem
  1227                           #label: 'Fonts'
  1012                           #label: 'Fonts'
  1228                           #submenuChannel: #menuFont
  1013                           #submenuChannel: #menuFont
  1578              #(#MenuItem
  1363              #(#MenuItem
  1579                 #label: '-'
  1364                 #label: '-'
  1580             )
  1365             )
  1581              #(#MenuItem
  1366              #(#MenuItem
  1582                 #label: 'Open Widget Documentation'
  1367                 #label: 'Open Widget Documentation'
  1583                 #value: #openWidgetDocumentation
  1368                 #value: #doOpenWidgetDocumentation
  1584                 #activeHelpKey: #editOpenSpecDocumentation
  1369                 #activeHelpKey: #editOpenSpecDocumentation
  1585             )
  1370             )
  1586              #(#MenuItem
  1371              #(#MenuItem
  1587                 #label: '-'
  1372                 #label: '-'
  1588             )
  1373             )
  1589              #(#MenuItem
  1374              #(#MenuItem
  1590                 #label: 'Inspect View'
  1375                 #label: 'Inspect View'
  1591                 #value: #inspectView
  1376                 #value: #doInspectView
  1592                 #activeHelpKey: #editInspectView
  1377                 #activeHelpKey: #editInspectView
  1593                 #enabled: #hasOneSelectionOtherThanCanvas
  1378                 #enabled: #hasOneSelectionOtherThanCanvas
  1594             )
  1379             )
  1595              #(#MenuItem
  1380              #(#MenuItem
  1596                 #label: 'Inspect Spec'
  1381                 #label: 'Inspect Spec'
  1597                 #value: #inspectSpec
  1382                 #value: #doInspectSpec
  1598                 #activeHelpKey: #editInspectSpec
  1383                 #activeHelpKey: #editInspectSpec
  1599             )
  1384             )
  1600           ) nil
  1385           ) nil
  1601           nil
  1386           nil
  1602       )
  1387       )
  1859           ) nil
  1644           ) nil
  1860           nil
  1645           nil
  1861       )
  1646       )
  1862 ! !
  1647 ! !
  1863 
  1648 
  1864 !UIPainter methodsFor:'accessing'!
  1649 !UIPainter methodsFor:'aspects'!
       
  1650 
       
  1651 aspectFor:aKey
       
  1652     "returns the aspect for aKey"
       
  1653 
       
  1654     ^aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
       
  1655 !
       
  1656 
       
  1657 canChangeOrderInContainer
       
  1658     "returns a boolean value holder which is true if the widget order can be changed 
       
  1659      within their container"
       
  1660 
       
  1661     ^ builder booleanValueAspectFor:#canChangeOrderInContainer
       
  1662 !
       
  1663 
       
  1664 canMoveOrAlignSelection
       
  1665     "returns a boolean value holder which is true in case that any selection exists
       
  1666      and all widgets in the selection can change its layout through to a move or
       
  1667      align operation"
       
  1668 
       
  1669     ^ builder booleanValueAspectFor:#canMoveOrAlignSelection
       
  1670 !
       
  1671 
       
  1672 canMoveSelection
       
  1673 
       
  1674     ^self canChangeOrderInContainer value or: [ 
       
  1675      self canMoveSelectionOutOfContainer value or: [
       
  1676      self canMoveSelectionOutOfContainer value]]
       
  1677 !
       
  1678 
       
  1679 canMoveSelectionIntoContainer
       
  1680     "returns a boolean value holder which is true in case that one widget is selected
       
  1681      and can change its container widget to the next element in the list which will have
       
  1682      the same container"
       
  1683 
       
  1684     ^ builder booleanValueAspectFor:#canMoveSelectionIntoContainer
       
  1685 !
       
  1686 
       
  1687 canMoveSelectionOutOfContainer
       
  1688     "returns a boolean value holder which is true in case that one widget is selected
       
  1689      which is contained within another component"
       
  1690 
       
  1691     ^ builder booleanValueAspectFor:#canMoveSelectionOutOfContainer
       
  1692 !
       
  1693 
       
  1694 enableChannel
       
  1695     "true if modifications are allowed otherwise running test"
       
  1696 
       
  1697     ^ self painter enableChannel
       
  1698 !
       
  1699 
       
  1700 galleryShown
       
  1701     "returns a boolean value holder which is set to true if the gallery is shown"
       
  1702 
       
  1703     |holder|
       
  1704 
       
  1705     (holder := builder bindingAt:#galleryShown) isNil ifTrue:[
       
  1706         builder aspectAt:#galleryShown put:(holder :=  true asValue).
       
  1707         holder addDependent:self
       
  1708     ].
       
  1709     ^ holder
       
  1710 
       
  1711 !
       
  1712 
       
  1713 hasOneSelectionOtherThanCanvas
       
  1714     "returns a value holder which is true in case that one widget is selected
       
  1715      other than the root"
       
  1716 
       
  1717     ^ builder booleanValueAspectFor:#hasOneSelectionOtherThanCanvas
       
  1718 !
       
  1719 
       
  1720 modifiedChannel
       
  1721     "returns a boolean value holder which is set to true if something is modified
       
  1722      and not accepted"
       
  1723 
       
  1724     ^ builder booleanValueAspectFor:#modifiedChannel
       
  1725 !
       
  1726 
       
  1727 noteBookView
       
  1728     "returns the notebook view; initialize the tools embedded in the notebook"
       
  1729 
       
  1730     |noteBook channel helpTool layoutTool specTool|
       
  1731 
       
  1732     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
       
  1733         noteBook   := View new.
       
  1734         layoutTool := UILayoutTool new.
       
  1735         helpTool   := UIHelpTool   new.
       
  1736         helpTool buildFromClass:specClass.
       
  1737         specTool   := UISpecificationTool new.
       
  1738         channel    := self modifiedChannel.
       
  1739 
       
  1740         layoutTool masterApplication:self.
       
  1741         specTool   masterApplication:self.
       
  1742         helpTool   masterApplication:self.
       
  1743 
       
  1744         layoutCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
       
  1745         helpCanvas   := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
       
  1746         specCanvas   := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
       
  1747 
       
  1748         layoutCanvas client:layoutTool.
       
  1749         helpCanvas   client:helpTool.
       
  1750         specTool builder:(specCanvas client:specTool).
       
  1751 
       
  1752         layoutTool masterApplication:self.
       
  1753         specTool   masterApplication:self.
       
  1754         helpTool   masterApplication:self.
       
  1755 
       
  1756         layoutTool modifiedHolder:channel.
       
  1757         helpTool   modifiedHolder:channel.
       
  1758         specTool   modifiedHolder:channel.
       
  1759 
       
  1760         builder aspectAt:#noteBookView put:noteBook.
       
  1761     ].
       
  1762     ^ noteBook
       
  1763 !
       
  1764 
       
  1765 painterShown
       
  1766     "returns a boolean value holder which is set to true if the painter is shown"
       
  1767 
       
  1768     |holder|
       
  1769 
       
  1770     (holder := builder bindingAt:#painterShown) isNil ifTrue:[
       
  1771         builder aspectAt:#painterShown put:(holder :=  true asValue).
       
  1772         holder addDependent:self
       
  1773     ].
       
  1774     ^ holder
       
  1775 
       
  1776 !
       
  1777 
       
  1778 tabList
       
  1779     "returns a value holder which keeps a list of the section labels in the notebook"
       
  1780 
       
  1781     |holder|
       
  1782 
       
  1783     (holder := builder bindingAt:#tabList) isNil ifTrue:[
       
  1784         builder aspectAt:#tabList put:(holder :=  #(Basics Details Layout) asValue).
       
  1785     ].
       
  1786     ^ holder
       
  1787 !
       
  1788 
       
  1789 tabModel
       
  1790     "returns a value holder which keeps the label of the current section in the notebook"
       
  1791 
       
  1792     |holder|
       
  1793 
       
  1794     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
       
  1795         holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
       
  1796         builder aspectAt:#tabModel put:holder.
       
  1797     ].
       
  1798     ^ holder
       
  1799 !
       
  1800 
       
  1801 treeView
       
  1802     "returns the tree view which holds all widget"
       
  1803 
       
  1804     ^ treeView
       
  1805 !
       
  1806 
       
  1807 valueOfCanPasteWithKeepingLayout
       
  1808 
       
  1809     |holder|
       
  1810     (holder := builder bindingAt:#valueOfCanPasteWithKeepingLayout) isNil ifTrue:[
       
  1811         builder aspectAt:#valueOfCanPasteWithKeepingLayout put:(holder :=  false asValue).
       
  1812     ].
       
  1813     ^ holder
       
  1814 
       
  1815 
       
  1816 
       
  1817 ! !
       
  1818 
       
  1819 !UIPainter methodsFor:'building editors'!
       
  1820 
       
  1821 openDataSetColumnEditor
       
  1822     "opens a Table Column Editor on current widget"
       
  1823 
       
  1824     |editor|
       
  1825 
       
  1826     (self resolveName:specClass) isNil ifTrue:[
       
  1827         ^ self information:'No application class defined yet!!'
       
  1828     ].
       
  1829 
       
  1830     editor := DataSetBuilder new.
       
  1831     editor masterApplication:self.
       
  1832     editor columns:self specTool specification columns fromView:(self layoutTool layoutView).
       
  1833     editor rowClassName:(self specTool specification rowClassName).
       
  1834     editor openModal.
       
  1835 
       
  1836     editor hasChanged ifTrue:[
       
  1837         self specTool specification columns:(editor columns).
       
  1838         self specTool specification rowClassName:(editor rowClassName).
       
  1839         self modifiedChannel value:true.
       
  1840     ].
       
  1841 !
       
  1842 
       
  1843 openEditMenu
       
  1844     "opens a Menu Editor on current widget"
       
  1845 
       
  1846     |cls selectorOrMenu editor selectedSpec|
       
  1847 
       
  1848     (cls := self resolveName:specClass) isNil ifTrue:[
       
  1849         ^ self warn:'No application class defined yet!!'
       
  1850     ].
       
  1851 
       
  1852     cls notNil ifTrue:[
       
  1853         (selectorOrMenu := self specTool specification menuSelector) notNil ifTrue:[
       
  1854             selectorOrMenu := selectorOrMenu asSymbol
       
  1855         ] ifFalse:[
       
  1856             "/ cg: q&d hack ...
       
  1857 
       
  1858             (selectedSpec := treeView propertySelected) notNil ifTrue:[
       
  1859                 Object errorSignal handle:[:ex |
       
  1860                     selectorOrMenu := nil.
       
  1861                 ] do:[
       
  1862                     selectorOrMenu := selectedSpec view asMenu.
       
  1863                 ]
       
  1864             ].
       
  1865         ].
       
  1866 
       
  1867         editor := MenuEditor new.
       
  1868         editor masterApplication:self.
       
  1869         editor specClass: cls.
       
  1870         editor useHelpTool: self helpTool. 
       
  1871         selectorOrMenu class ~~ Menu
       
  1872             ifTrue:  [editor openModalOnClass:cls andSelector:selectorOrMenu]
       
  1873             ifFalse: [editor openModalOnMenu:selectorOrMenu].
       
  1874         self helpTool updateList.
       
  1875 
       
  1876         editor specSelector ~= selectorOrMenu ifTrue:[
       
  1877             editor hasSaved ifTrue:[
       
  1878                 self specTool specification menuSelector:editor specSelector.
       
  1879                 self modifiedChannel value:true.
       
  1880                 self accept
       
  1881             ]
       
  1882         ].
       
  1883     ]
       
  1884 
       
  1885     "Modified: 31.7.1997 / 14:26:13 / cg"
       
  1886 !
       
  1887 
       
  1888 openHierarchicalListEditor
       
  1889     "opens a Hierarchical List Editor on current widget"
       
  1890 
       
  1891     |selector editor|
       
  1892 
       
  1893     (self resolveName:specClass) isNil ifTrue:[
       
  1894         ^ self information:'No application class defined yet!!'
       
  1895     ].
       
  1896 
       
  1897     (selector := self specTool specification hierarchicalList) notNil ifTrue:[
       
  1898         selector := selector asSymbol
       
  1899     ].
       
  1900 
       
  1901     editor := HierarchicalListEditor new.
       
  1902     editor masterApplication:self.
       
  1903     editor openModalOnClass:specClass andSelector:selector.
       
  1904 
       
  1905     editor specSelector ~= selector ifTrue:[
       
  1906         editor hasSaved ifTrue:[
       
  1907             self specTool specification hierarchicalList:editor specSelector.
       
  1908             self modifiedChannel value:true.
       
  1909             self accept
       
  1910         ]
       
  1911     ]
       
  1912 !
       
  1913 
       
  1914 openSubSpecGUIPainter
       
  1915     "opens a GUI Painter on the current subspecification"
       
  1916 
       
  1917     |spec cls meta sel|
       
  1918 
       
  1919     spec := self specTool specification.
       
  1920     cls := spec majorKey.
       
  1921     cls isNil ifTrue:[
       
  1922         cls := specClass.
       
  1923     ].
       
  1924     (cls isNil or:[(cls := self resolveName:cls) isNil]) ifTrue:[
       
  1925         spec majorKey isNil ifTrue:[
       
  1926             ^ self warn:'Cannot find class (no majorKey specified)'.
       
  1927         ].
       
  1928         ^ self warn:'Cannot find class ', spec majorKey asBoldText, '!!'.
       
  1929     ].
       
  1930     sel := spec minorKey.
       
  1931     meta := cls class whichClassIncludesSelector:sel.
       
  1932     meta isNil ifTrue:[
       
  1933         ^ self warn:'Cannot find selector #', (sel ? '') asBoldText, ' in class ', cls name asBoldText, '!!'
       
  1934     ].
       
  1935 
       
  1936     self class openOnClass:meta soleInstance andSelector:spec minorKey.
       
  1937 
       
  1938 !
       
  1939 
       
  1940 openTabListEditor
       
  1941     "opens a Tab List Editor on current widget"
       
  1942 
       
  1943     |selector editor|
       
  1944 
       
  1945     (self resolveName:specClass) isNil ifTrue:[
       
  1946         ^ self information:'No application class defined yet!!'
       
  1947     ].
       
  1948 
       
  1949     selector := self specTool specification listSelector.
       
  1950 
       
  1951     editor := TabListEditor new.
       
  1952     editor masterApplication:self.
       
  1953     editor openModalOnClass:specClass andSelector:selector.
       
  1954 
       
  1955     editor specSelector ~= selector ifTrue:[
       
  1956         editor hasSaved ifTrue:[
       
  1957             self specTool specification listSelector:editor specSelector.
       
  1958             self modifiedChannel value:true.
       
  1959             self accept.
       
  1960         ]
       
  1961     ]
       
  1962 ! !
       
  1963 
       
  1964 !UIPainter methodsFor:'change & update'!
       
  1965 
       
  1966 layoutChanged
       
  1967     "called by the painter/canvas whenever the layout of the current selected
       
  1968      widget has changed"
       
  1969 
       
  1970     self isModified ifFalse:[
       
  1971         self layoutTool update.
       
  1972         self modifiedChannel value:false
       
  1973     ]
       
  1974 !
       
  1975 
       
  1976 propertyChanged
       
  1977     "called by the painter/canvas whenever the property of the current selected
       
  1978      widget has changed"
       
  1979 
       
  1980     |property|
       
  1981 
       
  1982     (property := treeView propertySelected) notNil ifTrue:[
       
  1983         self specTool specification:(property spec copy).
       
  1984         self setViewInLayoutTool:(property view).
       
  1985         self modifiedChannel value:false
       
  1986     ] ifFalse:[
       
  1987         self layoutTool layoutView notNil ifTrue:[
       
  1988             self modifiedChannel value:false.
       
  1989             self treeSelection
       
  1990         ]
       
  1991     ]
       
  1992 !
       
  1993 
       
  1994 update:something with:aParameter from:someObject
       
  1995     "catches change notifications"
       
  1996 
       
  1997     someObject == treeView model ifTrue:[
       
  1998         (something == #selection
       
  1999         or:[something == #selectionIndex]) ifTrue:[self treeSelection].
       
  2000       ^ self
       
  2001     ].
       
  2002 
       
  2003     self galleryShown == someObject ifTrue:[
       
  2004         (self galleryShown value) ifTrue:[
       
  2005             self raiseUIView:(selectionPanel window)
       
  2006         ] ifFalse:[
       
  2007             self hideUIView:(selectionPanel window)
       
  2008         ].
       
  2009       ^ self
       
  2010     ].
       
  2011 
       
  2012     self painterShown == someObject ifTrue:[
       
  2013         (self painterShown value) ifTrue:[
       
  2014             self raiseUIView:(self painter topView)
       
  2015         ] ifFalse:[
       
  2016             self hideUIView:(self painter topView)
       
  2017         ].
       
  2018       ^ self
       
  2019     ].
       
  2020 
       
  2021     "Modified: / 29.10.1997 / 17:48:19 / cg"
       
  2022 ! !
       
  2023 
       
  2024 !UIPainter methodsFor:'event handling'!
       
  2025 
       
  2026 doesNotUnderstand:aMessage
       
  2027     "if does not understand incoming messages, detour them to painter"
       
  2028 
       
  2029     |painter|
       
  2030 
       
  2031     painter := self painter.
       
  2032 
       
  2033     (painter respondsTo:(aMessage selector)) ifTrue:[
       
  2034         ^ aMessage sendTo:painter
       
  2035     ].
       
  2036     super doesNotUnderstand:aMessage
       
  2037 
       
  2038 ! !
       
  2039 
       
  2040 !UIPainter methodsFor:'help'!
       
  2041 
       
  2042 defaultInfoLabel
       
  2043     "returns the default info label"
       
  2044 
       
  2045     specClass isNil ifTrue: [^'No class and selector defined.'].
       
  2046     ^specClass printString, ' >> ', specSelector
       
  2047 ! !
       
  2048 
       
  2049 !UIPainter methodsFor:'private'!
       
  2050 
       
  2051 askForModification
       
  2052     "asks for window spec modification"
       
  2053 
       
  2054     self askForSectionModification.    
       
  2055 
       
  2056     (modified or: [self painter isModified or: [self helpTool modified]])
       
  2057     ifTrue:
       
  2058     [
       
  2059         ((YesNoBox title:'Window Spec was modified!!')        
       
  2060             noText:'Cancel';
       
  2061             yesText:'Waste it and proceed';
       
  2062             showAtPointer;
       
  2063             accepted) ifFalse: [^false].
       
  2064         modified := false.
       
  2065         self painter resetModification
       
  2066     ].
       
  2067     ^true
       
  2068 !
       
  2069 
       
  2070 askForSectionModification
       
  2071     "asks for section modification in the notebook"
       
  2072 
       
  2073     self isModified ifTrue:[
       
  2074         (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[
       
  2075             self accept
       
  2076         ] ifFalse: [
       
  2077             self cancel
       
  2078         ]
       
  2079     ]
       
  2080 !
       
  2081 
       
  2082 checkClassAndSelector
       
  2083     "checks for class & superclass"
       
  2084 
       
  2085     |superclass cls|
       
  2086 
       
  2087     specClass isNil ifTrue:[^ false].
       
  2088 
       
  2089     cls := self resolveName:specClass.
       
  2090 
       
  2091     cls isNil ifTrue:[
       
  2092         superclass := self resolveName:specSuperclass.
       
  2093 
       
  2094         superclass isNil ifTrue:[
       
  2095             self warn:'No class named ' , specSuperclass , ' exists!!'.
       
  2096             ^ false.
       
  2097         ].
       
  2098         (self confirm:'Create class ' , specClass asBoldText, '?') ifTrue:[
       
  2099             superclass subclass:(specClass asSymbol)
       
  2100                        instanceVariableNames:''
       
  2101                        classVariableNames:''
       
  2102                        poolDictionaries:''
       
  2103                        category:'Applications'.
       
  2104             ^ true.
       
  2105         ].
       
  2106         ^ false.
       
  2107     ].
       
  2108     cls isBehavior ifFalse:[
       
  2109         self warn:'A global named ' , specClass , ' exists, but it is no class.'.
       
  2110         ^ false.
       
  2111     ].
       
  2112 
       
  2113     specSuperclass isBehavior ifFalse:[
       
  2114         specSuperclass isEmpty ifFalse:[
       
  2115             superclass := self resolveName:specSuperclass
       
  2116         ] ifTrue:[
       
  2117             specSuperclass := nil.
       
  2118         ]
       
  2119     ] ifTrue:[
       
  2120         superclass := specSuperclass
       
  2121     ].
       
  2122 
       
  2123     specSuperclass notNil ifTrue:[
       
  2124         superclass isNil ifTrue:[
       
  2125             self warn:'No class named ' , specSuperclass , ' exists!!'.
       
  2126             ^ false.
       
  2127         ].
       
  2128 
       
  2129         (cls isSubclassOf:superclass) ifFalse:[
       
  2130             self information:('A global named ' , specClass , ' exists,\' ,
       
  2131                               'but is not a subclass of ' , superclass name , '.\\' ,
       
  2132                               'Check and try again if that is not what you want.') withCRs.
       
  2133         ]
       
  2134     ].
       
  2135 
       
  2136     superclass isNil ifTrue:[
       
  2137         cls notNil ifTrue:[
       
  2138             specSuperclass := cls superclass name
       
  2139         ]
       
  2140     ].
       
  2141 
       
  2142     ^ true
       
  2143 
       
  2144     "Modified: 12.8.1997 / 23:39:10 / cg"
       
  2145 !
       
  2146 
       
  2147 hideUIView:aView
       
  2148     "hides the view which is an application or top view"
       
  2149 
       
  2150     aView beIndependent.
       
  2151     aView unmap.
       
  2152 !
       
  2153 
       
  2154 raiseTabView
       
  2155 
       
  2156     self isLayoutToolSelected ifTrue:[
       
  2157         layoutCanvas raise
       
  2158     ] ifFalse:[
       
  2159         self isHelpToolSelected ifTrue:[
       
  2160             helpCanvas raise
       
  2161         ] ifFalse:[
       
  2162             self specTool selection:tabSelection.
       
  2163             specCanvas raise
       
  2164         ]
       
  2165     ]
       
  2166 !
       
  2167 
       
  2168 raiseUIView:aView
       
  2169     "raise the view which is an application or top view"
       
  2170 
       
  2171     aView map.
       
  2172     aView bePartner.
       
  2173 !
       
  2174 
       
  2175 resourceMessage: aString
       
  2176     "reads the specClass and the specSelector by evaluating aString"
       
  2177 
       
  2178     (aString notNil and: [self askForModification]) 
       
  2179     ifTrue:
       
  2180     [            
       
  2181         |msg cls sel|
       
  2182         msg := aString asCollectionOfWords.
       
  2183         (msg size == 2 and:
       
  2184         [(cls := self resolveName:(msg at:1)) notNil])
       
  2185         ifTrue:
       
  2186         [
       
  2187             self specClass:cls.
       
  2188             specSuperclass := cls superclass name.
       
  2189             specSelector := (msg at: 2) asSymbol.
       
  2190             ^true
       
  2191         ]
       
  2192     ].
       
  2193     ^false
       
  2194 !
       
  2195 
       
  2196 setClass:cls selector:selector
       
  2197     "sets the specClass and the specSelector under which the window spec should be saved"
       
  2198 
       
  2199     |clsName superClassName|
       
  2200 
       
  2201     clsName := cls name.
       
  2202     superClassName := cls superclass name.
       
  2203 
       
  2204     (self aspectFor:#classNameChannel) value:clsName.
       
  2205     (self aspectFor:#methodNameChannel) value:(selector ? '').
       
  2206     (self aspectFor:#superclassNameChannel) value:superClassName.
       
  2207 
       
  2208     self painter 
       
  2209             className:clsName 
       
  2210             superclassName:superClassName
       
  2211             selector:(selector ? '').
       
  2212 
       
  2213     self specClass:clsName.
       
  2214     specSelector := (selector ? '').
       
  2215     specSuperclass := superClassName.
       
  2216 
       
  2217     specClass notNil & selector notNil ifTrue:[
       
  2218         self addToHistory: (specClass, ' ', specSelector) -> #loadFromMessage:.
       
  2219         self updateInfoLabel
       
  2220     ].
       
  2221 
       
  2222     "Modified: / 5.2.1998 / 09:44:58 / stefan"
       
  2223 !
       
  2224 
       
  2225 setViewInLayoutTool:aView
       
  2226     "sets view for layout tool"
       
  2227 
       
  2228     |type|
       
  2229 
       
  2230     self painter topView == aView ifTrue:[
       
  2231         type := #Extent
       
  2232     ].
       
  2233     self layoutTool layoutView:aView type:type
       
  2234 
       
  2235 !
       
  2236 
       
  2237 specClass:aClass
       
  2238     "sets the specClass and updates the Help Tool"
       
  2239 
       
  2240     specClass := aClass isBehavior ifTrue:[aClass name]
       
  2241                                    ifFalse:[aClass].
       
  2242 
       
  2243     self helpTool buildFromClass:specClass.    
       
  2244     self helpTool updateList.
       
  2245     self modifiedChannel value: false. 
       
  2246 
       
  2247 ! !
       
  2248 
       
  2249 !UIPainter methodsFor:'private tools'!
       
  2250 
       
  2251 helpTool
       
  2252     "returns the help tool"
       
  2253 
       
  2254     helpCanvas isNil ifTrue:[
       
  2255         self noteBookView
       
  2256     ].
       
  2257     ^ helpCanvas application
       
  2258 !
       
  2259 
       
  2260 layoutTool
       
  2261     "returns the layout tool"
       
  2262 
       
  2263     layoutCanvas isNil ifTrue:[
       
  2264         self noteBookView
       
  2265     ].
       
  2266     ^ layoutCanvas application
       
  2267 !
       
  2268 
       
  2269 painter
       
  2270     "returns the canvas view"
       
  2271 
       
  2272     ^ treeView canvas
       
  2273 !
       
  2274 
       
  2275 specTool
       
  2276     "returns the spec tool"
       
  2277 
       
  2278     specCanvas isNil ifTrue:[
       
  2279         self noteBookView
       
  2280     ].
       
  2281     ^ specCanvas application
       
  2282 ! !
       
  2283 
       
  2284 !UIPainter methodsFor:'queries'!
       
  2285 
       
  2286 hasSpecClass
       
  2287     "answers whether an application class is defined"
       
  2288 
       
  2289     ^ (self resolveName:specClass) notNil
       
  2290 !
       
  2291 
       
  2292 hasSpecClassAndSelector
       
  2293     "answers whether an application class and a selector under which
       
  2294      the window spec is stored is defined"
       
  2295 
       
  2296     specSelector size > 1 ifTrue:[
       
  2297         ^ self hasSpecClass
       
  2298     ].
       
  2299     ^ false
       
  2300 !
       
  2301 
       
  2302 isHelpToolSelected
       
  2303     "answers whether the current selected section in the noteBook is the Help Tool"
       
  2304 
       
  2305     ^ tabSelection = UIHelpTool label
       
  2306 !
       
  2307 
       
  2308 isLayoutToolSelected
       
  2309     "answers whether the current selected section in the noteBook is the Layout Tool"
       
  2310 
       
  2311     ^ tabSelection = UILayoutTool label
       
  2312 !
       
  2313 
       
  2314 isModified
       
  2315     "answers whether the current window spec or a layout is modified"
       
  2316 
       
  2317     ^ self modifiedChannel value
       
  2318 !
       
  2319 
       
  2320 isPainterEnabled
       
  2321     "answers whether I am running in test mode"
       
  2322 
       
  2323     ^ self painter enabled
       
  2324 ! !
       
  2325 
       
  2326 !UIPainter methodsFor:'selection'!
       
  2327 
       
  2328 tabSelection
       
  2329     "returns the label of the current section in the notebook"
       
  2330 
       
  2331     ^ tabSelection
       
  2332 !
       
  2333 
       
  2334 tabSelection:something
       
  2335     "called whenever the section of the notebook has changed"
       
  2336 
       
  2337     |whatToDo|
       
  2338 
       
  2339     (something isNil or:[tabSelection = something]) ifTrue:[
       
  2340         ^ self
       
  2341     ].
       
  2342 
       
  2343     self isModified ifTrue:[
       
  2344         whatToDo := DialogBox 
       
  2345                         confirmWithCancel:'Accept modifications in section ' , tabSelection printString asBoldText, '?'
       
  2346                         labels:#('Cancel' 'Ignore' 'Accept')
       
  2347                         default:3.
       
  2348         whatToDo isNil ifTrue:[^self].
       
  2349         whatToDo == true ifTrue:[
       
  2350             self accept
       
  2351         ] ifFalse:[
       
  2352             self cancel
       
  2353         ]
       
  2354     ].
       
  2355 
       
  2356     tabSelection := something.
       
  2357     self raiseTabView.
       
  2358     self cancel.
       
  2359 
       
  2360 !
       
  2361 
       
  2362 treeSelection
       
  2363     "called whenever the selection of the treeview has changed"
       
  2364 
       
  2365     |view list spec slices size property tabComponent canCutOrCopy canPaste clipboard sel|
       
  2366 
       
  2367     self isModified ifTrue:[
       
  2368         (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[
       
  2369             self accept
       
  2370         ]
       
  2371     ].
       
  2372 
       
  2373     self canMoveOrAlignSelection        value:(treeView canMoveOrAlignSelection).
       
  2374     self canChangeOrderInContainer      value:(treeView canChangeOrderInContainer).
       
  2375     self canMoveSelectionIntoContainer  value:(treeView canMoveSelectionIntoContainer).
       
  2376     self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
       
  2377     self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
       
  2378 
       
  2379     treeView isCanvasSelected ifTrue:[
       
  2380         spec := treeView canvasSpec.
       
  2381         view := self painter topView.
       
  2382     ] ifFalse:[
       
  2383         (property := treeView propertySelected) notNil ifTrue:[
       
  2384             treeView canResizeSelectedWidget ifTrue:[
       
  2385                 view := property view.
       
  2386             ].
       
  2387             spec := property spec copy.
       
  2388         ]
       
  2389     ].
       
  2390     tabComponent := builder componentAt:#noteBook.
       
  2391     self setViewInLayoutTool:view.
       
  2392     self specTool specification:spec.
       
  2393 
       
  2394     spec notNil ifTrue:[
       
  2395         self helpTool helpKey:(spec activeHelpKey).
       
  2396         slices := spec class slices.
       
  2397         size   := slices size.
       
  2398 
       
  2399         view notNil ifTrue:[
       
  2400             self treeView isCanvasSelected 
       
  2401             ifFalse:
       
  2402             [
       
  2403                 list := Array new:(size + 2).
       
  2404                 list at:(size + 2) put:(UILayoutTool label).
       
  2405             ]
       
  2406             ifTrue:
       
  2407             [
       
  2408                 list := Array new:(size + 1).
       
  2409                 list at:(size + 1) put:(UILayoutTool label).
       
  2410             ].
       
  2411         ] ifFalse:[
       
  2412             list := Array new:(size + 1).
       
  2413         ].
       
  2414 
       
  2415         1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
       
  2416         self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)].
       
  2417 
       
  2418         self tabList value:list.
       
  2419         self showHelp:spec class name for:self.
       
  2420         tabComponent enabled:true.
       
  2421 
       
  2422         (tabSelection := tabComponent selection) isNil ifTrue:[
       
  2423             tabComponent setSelection:(tabSelection := list first)
       
  2424         ].
       
  2425         self raiseTabView
       
  2426     ] ifFalse:[
       
  2427         self helpTool helpKey:nil.
       
  2428         tabComponent enabled:false.
       
  2429         self defaultInfoLabel.
       
  2430     ].
       
  2431     self modifiedChannel value:false.
       
  2432 
       
  2433     treeView notNil
       
  2434     ifTrue:
       
  2435     [
       
  2436         canCutOrCopy := treeView selection size >= 1 and:[treeView selection first ~~ 1].
       
  2437         clipboard := self getSelection.
       
  2438 
       
  2439         clipboard isCollection ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]]
       
  2440                               ifFalse:[sel := clipboard].
       
  2441 
       
  2442         canPaste := (sel isKindOf:UISpecification) and: 
       
  2443                     [treeView selection size  = 1 
       
  2444                     and:[treeView selection first == 1 
       
  2445                     or: [self canPasteInto: treeView selectedNode contents view]]]
       
  2446     ].
       
  2447 
       
  2448     self valueOfCanCut value: canCutOrCopy.
       
  2449     self valueOfCanCopy value: canCutOrCopy.
       
  2450     self valueOfCanPaste value: canPaste.            
       
  2451     self valueOfCanPasteWithKeepingLayout value: (canPaste &  self canKeepLayoutInSelection).
       
  2452 
       
  2453 
       
  2454 ! !
       
  2455 
       
  2456 !UIPainter methodsFor:'settings'!
  1865 
  2457 
  1866 redefineAspectMethods
  2458 redefineAspectMethods
  1867     "redefine methods yes or no. If a method is defined in super class
  2459     "redefine methods yes or no. If a method is defined in super class
  1868      should the message be reinstalled ?
  2460      should the message be reinstalled ?
  1869     "
  2461     "
  1877      should the message be reinstalled ?
  2469      should the message be reinstalled ?
  1878     "
  2470     "
  1879     UIPainterView redefineAspectMethods:aBoolean
  2471     UIPainterView redefineAspectMethods:aBoolean
  1880 
  2472 
  1881 
  2473 
  1882 !
       
  1883 
       
  1884 transcriptHelp
       
  1885     "answer whether the help transcript is turned on/off
       
  1886     "
       
  1887     ^self class settings at: #TranscriptHelp 
       
  1888         ifAbsent: [self class settings at: #TranscriptHelp put: false]
       
  1889 !
       
  1890 
       
  1891 transcriptHelp:aBoolean
       
  1892     "turn on/off the help transcript
       
  1893     "
       
  1894     self class settings at: #TranscriptHelp put: aBoolean
       
  1895 
       
  1896 ! !
  2474 ! !
  1897 
  2475 
  1898 !UIPainter methodsFor:'actions'!
  2476 !UIPainter methodsFor:'startup / release'!
       
  2477 
       
  2478 closeRequest
       
  2479     "close request"
       
  2480 
       
  2481     self askForModification ifFalse:[^self].
       
  2482 
       
  2483     treeView model removeDependent:self.
       
  2484     self painter release.
       
  2485 
       
  2486     selectionPanel notNil ifTrue:[
       
  2487         selectionPanel masterApplication:nil.
       
  2488         selectionPanel closeRequest
       
  2489     ].
       
  2490     selectionPanel := nil.
       
  2491     treeView       := nil.
       
  2492 
       
  2493     super closeRequest.
       
  2494 
       
  2495 !
       
  2496 
       
  2497 closeRequestFor:aTopView
       
  2498     "handles a close request for a specific view"
       
  2499 
       
  2500     |topView|
       
  2501 
       
  2502     (topView := self window) == aTopView ifTrue:[
       
  2503         super closeRequestFor:aTopView
       
  2504     ] ifFalse:[
       
  2505         aTopView = selectionPanel window ifTrue:[
       
  2506             self galleryShown value:false
       
  2507         ] ifFalse:[
       
  2508             aTopView == (self painter topView) ifTrue:[
       
  2509                 self painterShown value:false
       
  2510             ] ifFalse:[
       
  2511                 aTopView closeRequest
       
  2512             ]
       
  2513         ].
       
  2514         topView raise.
       
  2515     ].
       
  2516 !
       
  2517 
       
  2518 loadFromMessage: aMessage
       
  2519     "loads a window spec by evaluating aMessage"
       
  2520 
       
  2521     ((aMessage size > 0) and: [self askForModification])
       
  2522     ifTrue:
       
  2523     [
       
  2524         |readStream aClass aSelector|
       
  2525         readStream := aMessage readStream.
       
  2526         (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil
       
  2527         ifTrue:
       
  2528         [
       
  2529             aSelector :=  readStream upToEnd asSymbol.
       
  2530             self setClass: aClass selector: aSelector.    
       
  2531             (aClass respondsTo:aSelector) 
       
  2532             ifTrue:
       
  2533             [
       
  2534                 self painter setupFromSpec:(aClass perform:aSelector).
       
  2535                 treeView selection: #(1). 
       
  2536             ]
       
  2537         ]
       
  2538     ]
       
  2539 !
       
  2540 
       
  2541 openInterface:aSymbol
       
  2542     "opens the interface on the selector aSymbol"
       
  2543 
       
  2544     |cls painterView painter topView|
       
  2545 
       
  2546     modified := false.
       
  2547 
       
  2548     aspects := IdentityDictionary new.
       
  2549 
       
  2550     aspects at:#classNameChannel put:(
       
  2551         (specClass notNil ifTrue:[specClass]
       
  2552                          ifFalse:['NewApplication']) asValue
       
  2553     ).
       
  2554     specSuperclass isNil ifTrue:[
       
  2555         specClass notNil ifTrue:[
       
  2556             (cls := self resolveName:specClass) notNil ifTrue:[
       
  2557                 specSuperclass := cls superclass name.
       
  2558             ]
       
  2559         ]
       
  2560     ].
       
  2561     aspects at:#superclassNameChannel put:(
       
  2562         (specSuperclass notNil ifTrue:[specSuperclass]
       
  2563                          ifFalse:['ApplicationModel']) asValue
       
  2564     ).
       
  2565     aspects at:#superclassNameDefaults put:#('ApplicationModel' 'SimpleDialog') asValue.
       
  2566     aspects at:#methodNameChannel put:(
       
  2567         (specSelector notNil ifTrue:[specSelector asValue]
       
  2568                             ifFalse:[#windowSpec]) asValue
       
  2569     ).
       
  2570 
       
  2571     treeView    := TreeView new.
       
  2572     painterView := StandardSystemView new.
       
  2573     painterView name: self class defaultNameOfCanvas.
       
  2574     painterView label: self class defaultNameOfCanvas.
       
  2575     painterView extent:300@300.
       
  2576 
       
  2577     painter := UIPainterView in:painterView.
       
  2578     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
       
  2579 
       
  2580     treeView := treeView canvas:painter.
       
  2581     painter treeView:treeView.
       
  2582     treeView model addDependent:self.
       
  2583 
       
  2584     super openInterface:aSymbol.
       
  2585 
       
  2586     topView := self window.
       
  2587 
       
  2588     topView label:'GUI Painter'.
       
  2589 
       
  2590     "take care for those who do close very quickly after launching"
       
  2591     Object errorSignal handle: [:ex|] do: 
       
  2592     [
       
  2593         painterView openInGroup:(topView windowGroup).
       
  2594         painterView open.
       
  2595         painterView application:self.     
       
  2596 
       
  2597         painterView application:self.
       
  2598         selectionPanel := UISelectionPanel new.
       
  2599         selectionPanel allButOpenInterface:#windowSpec.
       
  2600         selectionPanel window openInGroup:(topView windowGroup).
       
  2601 
       
  2602         selectionPanel openWindow.
       
  2603         selectionPanel masterApplication:self.
       
  2604 
       
  2605         topView iconLabel:'GUI Painter'.
       
  2606         topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  2607 
       
  2608         painterView iconLabel:'GUI Painter'.
       
  2609         painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  2610 
       
  2611         topView bePartner.
       
  2612         painterView bePartner.
       
  2613         selectionPanel window bePartner.
       
  2614 
       
  2615         selectionPanel window iconLabel:'GUI Painter'.
       
  2616         selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  2617     ]
       
  2618 !
       
  2619 
       
  2620 openOnClass:aClass
       
  2621     "opens the GUI Painter on aClass and #windowSpec"
       
  2622 
       
  2623     self openOnClass:aClass andSelector:#windowSpec
       
  2624 !
       
  2625 
       
  2626 openOnClass:aClass andSelector:aSelector
       
  2627     "opens the GUI Painter on aClass and aSelector"
       
  2628 
       
  2629     |painter|
       
  2630 
       
  2631     aClass isNil ifTrue:[
       
  2632         (self confirm:'No class given to the GUI Painter (class was probably renamed?)\\Open anyway (to create a new window spec) ?' withCRs)
       
  2633         ifFalse:[^ nil].
       
  2634     ].
       
  2635 
       
  2636     self openInterface.
       
  2637 
       
  2638     "take care for those who do close very quickly after launching"
       
  2639     Object errorSignal handle: [:ex|] do: 
       
  2640     [
       
  2641         aClass notNil ifTrue:[
       
  2642             painter := self painter.
       
  2643             self setClass:aClass selector:aSelector.
       
  2644             (aClass respondsTo:aSelector) ifTrue:[
       
  2645                 painter setupFromSpec:(aClass perform:aSelector).
       
  2646                 treeView selection: #(1)
       
  2647             ]
       
  2648         ]
       
  2649     ]
       
  2650 !
       
  2651 
       
  2652 postOpenWith: aBuilder
       
  2653     "sets the root of the tree view as first selection;
       
  2654      sets the grid parameters, if defined"
       
  2655 
       
  2656     |painter settings gridPara hspace vspace|
       
  2657 
       
  2658     super postOpenWith: aBuilder.
       
  2659 
       
  2660     "take care for those who do close very quickly after launching"
       
  2661     Object errorSignal handle: [:ex|] do: 
       
  2662     [
       
  2663         treeView selection: (Array with: 1).
       
  2664 
       
  2665         painter  := self painter.
       
  2666         settings := self class settings.
       
  2667         gridPara := painter gridParameters copy.
       
  2668         hspace   := settings at: #HGridSpace ifAbsent: [10].
       
  2669         vspace   := settings at: #VGridSpace ifAbsent: [10].
       
  2670         gridPara at:1 put:hspace; at:2 put:vspace; at:5 put:hspace; at:6 put:vspace.
       
  2671         painter gridParameters:gridPara.
       
  2672         painter gridShown: (settings at: #GridShown ifAbsent: [false]).
       
  2673         painter gridAlign: (settings at: #GridAlign ifAbsent: [false]).
       
  2674         painter clear.
       
  2675     ]
       
  2676 
       
  2677 ! !
       
  2678 
       
  2679 !UIPainter methodsFor:'user actions'!
  1899 
  2680 
  1900 accept
  2681 accept
  1901     "accept changes done to the specification. The component assigned to the
  2682     "accepts all modifications done to the attributes of the current section"
  1902      specification will change immediately dependant on the attributes derived
  2683 
  1903      from the specification.
  2684     |painter layout spec prop key layoutTool|
  1904     "
  2685 
  1905     |layout spec prop key layoutTool|
  2686     painter := self painter.
  1906 
  2687 
  1907     self isLayoutToolSelected ifTrue:[
  2688     self isLayoutToolSelected ifTrue:[
  1908         layoutTool := self layoutTool.
  2689         layoutTool := self layoutTool.
  1909 
  2690 
  1910         (layout := layoutTool layout) notNil ifTrue:[
  2691         (layout := layoutTool layout) notNil ifTrue:[
  1911             layoutTool layoutType == #Extent ifTrue:[
  2692             layoutTool layoutType == #Extent ifTrue:[
  1912                 layoutTool layoutView == self painter topView ifTrue:[
  2693                 layoutTool layoutView == painter topView ifTrue:[
  1913                     layoutTool layoutView extent:layout
  2694                     layoutTool layoutView extent:layout
  1914                 ] ifFalse:[
  2695                 ] ifFalse:[
  1915                     self painter setExtent:layout
  2696                     painter setExtent:layout
  1916                 ]
  2697                 ]
  1917             ] ifFalse:[
  2698             ] ifFalse:[
  1918                 self painter setLayout:layout
  2699                 painter setLayout:layout
  1919             ]
  2700             ]
  1920         ]
  2701         ]
  1921     ] ifFalse:[
  2702     ] ifFalse:[
  1922         spec := self specTool specification.
  2703         spec := self specTool specification.
  1923 
  2704 
  1929             prop notNil ifTrue:[
  2710             prop notNil ifTrue:[
  1930                 prop spec activeHelpKey:key
  2711                 prop spec activeHelpKey:key
  1931             ].
  2712             ].
  1932             spec activeHelpKey:key.
  2713             spec activeHelpKey:key.
  1933         ] ifFalse:[
  2714         ] ifFalse:[
  1934             self painter updateFromSpec:spec.
  2715             painter updateFromSpec:spec.
  1935         ]
  2716         ]
  1936     ].             
  2717     ].             
  1937     self modifiedChannel value:false.
  2718     self modifiedChannel value:false.
  1938     modified := true.
  2719     modified := true.
  1939 !
  2720 !
  1940 
  2721 
  1941 addWidget: aSpecClass
  2722 addWidget: aSpecClass
       
  2723     "adds a widget from aSpecClass to the current widget"
  1942 
  2724 
  1943     self addWidgetOfSpec: (Array with: (Smalltalk at: aSpecClass) new)
  2725     self addWidgetOfSpec: (Array with: (Smalltalk at: aSpecClass) new)
  1944 
  2726 
  1945 !
  2727 !
  1946 
  2728 
  1947 addWidgetOfSpec: aSpec
  2729 addWidgetOfSpec: aSpec
       
  2730     "adds a widget from aSpec to the current widget"
  1948 
  2731 
  1949     |newSel|  
  2732     |newSel|  
  1950     (newSel := self pasteSpecifications:aSpec keepLayout:false at:0@0) notNil
  2733     (newSel := self pasteSpecifications:aSpec keepLayout:false at:0@0) notNil
  1951     ifTrue:
  2734     ifTrue:
  1952     [
  2735     [
  1967     ]
  2750     ]
  1968 
  2751 
  1969 !
  2752 !
  1970 
  2753 
  1971 cancel
  2754 cancel
  1972     "cancel all changes done to the specification; reread attributes from the
  2755     "cancels all modifications done to the attributes of the current section; 
  1973      assigned component
  2756      reread the old attributes"
  1974     "
  2757 
  1975     |spec key view|
  2758     |spec key view|
  1976 
  2759 
  1977     self isModified ifTrue:[
  2760     self isModified ifTrue:[
  1978         (spec := self painter specForSelection) notNil ifTrue:[
  2761         (spec := self painter specForSelection) notNil ifTrue:[
  1979             key := spec activeHelpKey.
  2762             key := spec activeHelpKey.
  1993         self modifiedChannel value:false.
  2776         self modifiedChannel value:false.
  1994         modified := false
  2777         modified := false
  1995     ]
  2778     ]
  1996 !
  2779 !
  1997 
  2780 
  1998 inspectSpec
       
  1999     "inspect the selected specification"
       
  2000 
       
  2001     |spec|
       
  2002 
       
  2003     (spec := self specForSelection) isNil ifTrue:[
       
  2004         treeView isCanvasSelected ifTrue:[
       
  2005             spec := treeView canvasSpec.
       
  2006         ]
       
  2007     ].
       
  2008     spec notNil ifTrue:[
       
  2009         spec inspect
       
  2010     ]
       
  2011 
       
  2012 
       
  2013 !
       
  2014 
       
  2015 inspectView
       
  2016     "inspect the view of the selected specification"
       
  2017 
       
  2018     |selection view|
       
  2019 
       
  2020     ((selection := self painter selection) isCollection and: [selection size >= 1]) ifTrue:[
       
  2021         selection first inspect
       
  2022     ] ifFalse: [
       
  2023         selection inspect
       
  2024     ]
       
  2025 
       
  2026 !
       
  2027 
       
  2028 moveSelectionDown
       
  2029     "move selected components down
       
  2030     "
       
  2031     self painter moveSelectionDown
       
  2032 !
       
  2033 
       
  2034 moveSelectionLeft
       
  2035     "move selected components left
       
  2036     "
       
  2037     self painter moveSelectionLeft
       
  2038 
       
  2039 !
       
  2040 
       
  2041 moveSelectionRight
       
  2042     "move selected components right
       
  2043     "
       
  2044     self painter moveSelectionRight
       
  2045 
       
  2046 !
       
  2047 
       
  2048 moveSelectionUp
       
  2049     "move selected components up
       
  2050     "
       
  2051     self painter moveSelectionUp
       
  2052 
       
  2053 !
       
  2054 
       
  2055 openWidgetDocumentation
       
  2056     "open documentation for the selected widget"
       
  2057 
       
  2058     |spec document|
       
  2059 
       
  2060     (spec := self specForSelection) isNil ifTrue:[
       
  2061         treeView isCanvasSelected ifTrue:[
       
  2062             spec := nil
       
  2063         ]
       
  2064     ].
       
  2065     spec notNil ifTrue:[
       
  2066         document := 'tools/uipainter/Widgets/', spec userFriendlyName,'.html'
       
  2067     ] ifFalse: [
       
  2068         document := 'tools/uipainter/TOP.html#THEWIDGETSANDHOWDOTHEYWORK'
       
  2069     ].
       
  2070     HTMLDocumentView openFullOnDocumentationFile: document 
       
  2071 
       
  2072 
       
  2073 ! !
       
  2074 
       
  2075 !UIPainter methodsFor:'aspects'!
       
  2076 
       
  2077 aspectFor:aKey
       
  2078     "aspect for a key
       
  2079     "
       
  2080   ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
       
  2081 !
       
  2082 
       
  2083 canChangeOrderInContainer
       
  2084     "returns a boolean value holder which is true if the component order can be changed within their container.
       
  2085     "
       
  2086     ^ builder booleanValueAspectFor:#canChangeOrderInContainer
       
  2087 !
       
  2088 
       
  2089 canMoveOrAlignSelection
       
  2090     "returns a boolean value holder which is true in case that any selection exists
       
  2091      and all widgets in the selection can change its layout through to a move or
       
  2092      align operation
       
  2093     "
       
  2094     ^ builder booleanValueAspectFor:#canMoveOrAlignSelection
       
  2095 !
       
  2096 
       
  2097 canMoveSelection
       
  2098 
       
  2099     ^self canChangeOrderInContainer value | 
       
  2100      self canMoveSelectionOutOfContainer value |
       
  2101      self canMoveSelectionOutOfContainer value
       
  2102 !
       
  2103 
       
  2104 canMoveSelectionIntoContainer
       
  2105     "returns a boolean value holder which is true in case that one component is selected
       
  2106      and can change its container widget to the next element in the list which will have
       
  2107      the same container.
       
  2108     "
       
  2109     ^ builder booleanValueAspectFor:#canMoveSelectionIntoContainer
       
  2110 !
       
  2111 
       
  2112 canMoveSelectionOutOfContainer
       
  2113     "returns a boolean value holder which is true in case that one component is selected
       
  2114      which is contained within another component
       
  2115     "
       
  2116     ^ builder booleanValueAspectFor:#canMoveSelectionOutOfContainer
       
  2117 !
       
  2118 
       
  2119 enableChannel
       
  2120     "true if modifications are allowed otherwise running test
       
  2121     "
       
  2122   ^ self painter enableChannel
       
  2123 !
       
  2124 
       
  2125 galleryShown
       
  2126     "returns a boolean value holder which is set to true if the gallery is shown
       
  2127     "
       
  2128     |holder|
       
  2129 
       
  2130     (holder := builder bindingAt:#galleryShown) isNil ifTrue:[
       
  2131         builder aspectAt:#galleryShown put:(holder :=  true asValue).
       
  2132         holder addDependent:self
       
  2133     ].
       
  2134     ^ holder
       
  2135 
       
  2136 !
       
  2137 
       
  2138 hasOneSelectionOtherThanCanvas
       
  2139     "returns a value holder which is true in case that one component is selected
       
  2140      other than the canvas.
       
  2141     "               
       
  2142     ^ builder booleanValueAspectFor:#hasOneSelectionOtherThanCanvas
       
  2143 !
       
  2144 
       
  2145 modifiedChannel
       
  2146     "returns a boolean value holder which is set to true if something is modified
       
  2147      and not accepted
       
  2148     "
       
  2149     ^ builder booleanValueAspectFor:#modifiedChannel
       
  2150 !
       
  2151 
       
  2152 noteBookView
       
  2153     "returns the notebook view; initialize components within the notebook
       
  2154     "
       
  2155     |noteBook channel helpTool layoutTool specTool|
       
  2156 
       
  2157     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
       
  2158         noteBook   := View new.
       
  2159         layoutTool := UILayoutTool new.
       
  2160         helpTool   := UIHelpTool   new.
       
  2161         helpTool buildFromClass:specClass.
       
  2162         specTool   := UISpecificationTool new.
       
  2163         channel    := self modifiedChannel.
       
  2164 
       
  2165         layoutTool masterApplication:self.
       
  2166         specTool   masterApplication:self.
       
  2167         helpTool   masterApplication:self.
       
  2168 
       
  2169         layoutCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
       
  2170         helpCanvas   := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
       
  2171         specCanvas   := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
       
  2172 
       
  2173         layoutCanvas client:layoutTool.
       
  2174         helpCanvas   client:helpTool.
       
  2175         specTool builder:(specCanvas client:specTool).
       
  2176 
       
  2177         layoutTool masterApplication:self.
       
  2178         specTool   masterApplication:self.
       
  2179         helpTool   masterApplication:self.
       
  2180 
       
  2181         layoutTool modifiedHolder:channel.
       
  2182         helpTool   modifiedHolder:channel.
       
  2183         specTool   modifiedHolder:channel.
       
  2184 
       
  2185         builder aspectAt:#noteBookView put:noteBook.
       
  2186     ].
       
  2187     ^ noteBook
       
  2188 !
       
  2189 
       
  2190 painterShown
       
  2191     "returns a boolean value holder which is set to true if the painter is shown
       
  2192     "
       
  2193     |holder|
       
  2194 
       
  2195     (holder := builder bindingAt:#painterShown) isNil ifTrue:[
       
  2196         builder aspectAt:#painterShown put:(holder :=  true asValue).
       
  2197         holder addDependent:self
       
  2198     ].
       
  2199     ^ holder
       
  2200 
       
  2201 !
       
  2202 
       
  2203 tabList
       
  2204     "returns a value holder which keeps a list of labels assigned to the tabs
       
  2205     "
       
  2206     |holder|
       
  2207 
       
  2208     (holder := builder bindingAt:#tabList) isNil ifTrue:[
       
  2209         builder aspectAt:#tabList put:(holder :=  #(Basics Details Layout) asValue).
       
  2210     ].
       
  2211     ^ holder
       
  2212 !
       
  2213 
       
  2214 tabModel
       
  2215     "returns a value holder which keeps the current name of the tab selected
       
  2216     "
       
  2217     |holder|
       
  2218 
       
  2219     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
       
  2220         holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
       
  2221         builder aspectAt:#tabModel put:holder.
       
  2222     ].
       
  2223     ^ holder
       
  2224 !
       
  2225 
       
  2226 treeView
       
  2227     "returns the selection tree view which holds all widget identifiers
       
  2228     "
       
  2229     ^ treeView
       
  2230 !
       
  2231 
       
  2232 valueOfCanPasteWithKeepingLayout
       
  2233 
       
  2234     |holder|
       
  2235     (holder := builder bindingAt:#valueOfCanPasteWithKeepingLayout) isNil ifTrue:[
       
  2236         builder aspectAt:#valueOfCanPasteWithKeepingLayout put:(holder :=  false asValue).
       
  2237     ].
       
  2238     ^ holder
       
  2239 
       
  2240 
       
  2241 
       
  2242 ! !
       
  2243 
       
  2244 !UIPainter methodsFor:'building editors'!
       
  2245 
       
  2246 openDataSetColumnEditor
       
  2247     "opens a column editor
       
  2248     "
       
  2249     |cls aspect editor columns|
       
  2250 
       
  2251     cls := self resolveName:specClass.
       
  2252 
       
  2253     cls isNil ifTrue:[
       
  2254         ^ self information:'No application class defined yet!!'
       
  2255     ].
       
  2256     aspect := self specTool specification columns.
       
  2257 
       
  2258     editor := DataSetBuilder new.
       
  2259     editor masterApplication:self.
       
  2260     editor columns:aspect fromView:(self layoutTool layoutView).
       
  2261     editor rowClassName:(self specTool specification rowClassName).
       
  2262     editor openModal.
       
  2263 
       
  2264     editor hasChanged ifTrue:[
       
  2265         self specTool specification columns:(editor columns).
       
  2266         self specTool specification rowClassName:(editor rowClassName).
       
  2267         self modifiedChannel value:true.
       
  2268     ].
       
  2269 !
       
  2270 
       
  2271 openEditMenu
       
  2272     "opens a menu editor on current widget
       
  2273     "
       
  2274     |cls selectorOrMenu editor selectedSpec|
       
  2275 
       
  2276     cls := self resolveName:specClass.
       
  2277 
       
  2278     cls isNil ifTrue:[
       
  2279         ^ self warn:'No application class defined yet!!'
       
  2280     ].
       
  2281 
       
  2282     cls notNil ifTrue:[
       
  2283         (selectorOrMenu := self specTool specification menuSelector) notNil ifTrue:[
       
  2284             selectorOrMenu := selectorOrMenu asSymbol
       
  2285         ] ifFalse:[
       
  2286             "/ cg: q&d hack ...
       
  2287 
       
  2288             (selectedSpec := treeView propertySelected) notNil ifTrue:[
       
  2289                 Object errorSignal handle:[:ex |
       
  2290                     selectorOrMenu := nil.
       
  2291                 ] do:[
       
  2292                     selectorOrMenu := selectedSpec view asMenu.
       
  2293                 ]
       
  2294             ].
       
  2295         ].
       
  2296 
       
  2297         editor := MenuEditor new.
       
  2298         editor masterApplication:self.
       
  2299         editor specClass: cls.
       
  2300         editor useHelpTool: self helpTool. 
       
  2301         selectorOrMenu class ~~ Menu
       
  2302             ifTrue:  [editor openModalOnClass:cls andSelector:selectorOrMenu]
       
  2303             ifFalse: [editor openModalOnMenu:selectorOrMenu].
       
  2304         self helpTool updateList.
       
  2305 
       
  2306         editor specSelector ~= selectorOrMenu ifTrue:[
       
  2307             editor hasSaved ifTrue:[
       
  2308                 self specTool specification menuSelector:editor specSelector.
       
  2309                 self modifiedChannel value:true.
       
  2310                 self accept
       
  2311             ]
       
  2312         ].
       
  2313     ]
       
  2314 
       
  2315     "Modified: 31.7.1997 / 14:26:13 / cg"
       
  2316 !
       
  2317 
       
  2318 openHierarchicalListEditor
       
  2319     "opens a hierarchical list editor editor on current widget
       
  2320     "
       
  2321     |cls aspect editor|
       
  2322 
       
  2323     cls := self resolveName:specClass.
       
  2324 
       
  2325     cls isNil ifTrue:[
       
  2326         ^ self information:'No application class defined yet!!'
       
  2327     ].
       
  2328 
       
  2329     (aspect := self specTool specification hierarchicalList) notNil ifTrue:[
       
  2330         aspect := aspect asSymbol
       
  2331     ].
       
  2332 
       
  2333     editor := HierarchicalListEditor new.
       
  2334     editor masterApplication:self.
       
  2335     editor openModalOnClass:cls andSelector:aspect.
       
  2336 
       
  2337     editor specSelector ~= aspect ifTrue:[
       
  2338         editor hasSaved ifTrue:[
       
  2339             self specTool specification hierarchicalList:editor specSelector.
       
  2340             self modifiedChannel value:true.
       
  2341             self accept
       
  2342         ]
       
  2343     ]
       
  2344 !
       
  2345 
       
  2346 openSubSpecGUIPainter
       
  2347     "opens a GUI Painter on the current subspecification"
       
  2348 
       
  2349     |spec cls meta sel|
       
  2350 
       
  2351     spec := self specTool specification.
       
  2352     cls := spec majorKey.
       
  2353     cls isNil ifTrue:[
       
  2354         cls := specClass.
       
  2355     ].
       
  2356     (cls isNil or:[(cls := self resolveName:cls) isNil]) ifTrue:[
       
  2357         spec majorKey isNil ifTrue:[
       
  2358             ^ self warn:'Cannot find class (no majorKey specified)'.
       
  2359         ].
       
  2360         ^ self warn:'Cannot find class ', spec majorKey asBoldText, '!!'.
       
  2361     ].
       
  2362     sel := spec minorKey.
       
  2363     meta := cls class whichClassIncludesSelector:sel.
       
  2364     meta isNil ifTrue:[
       
  2365         ^ self warn:'Cannot find selector #', (sel ? '') asBoldText, ' in class ', cls name asBoldText, '!!'
       
  2366     ].
       
  2367 
       
  2368     self class openOnClass:meta soleInstance andSelector:spec minorKey.
       
  2369 
       
  2370     "Created: / 6.2.1998 / 13:03:59 / stefan"
       
  2371     "Modified: / 6.2.1998 / 13:59:30 / stefan"
       
  2372 !
       
  2373 
       
  2374 openTabListEditor
       
  2375     "open a TabListEditor
       
  2376     "
       
  2377     |cls aspect editor columns|
       
  2378 
       
  2379     cls := self resolveName:specClass.
       
  2380 
       
  2381     cls isNil ifTrue:[
       
  2382         ^ self information:'No application class defined yet!!'
       
  2383     ].
       
  2384     aspect := self specTool specification listSelector.
       
  2385 
       
  2386     editor := TabListEditor new.
       
  2387     editor masterApplication:self.
       
  2388     editor openModalOnClass:cls andSelector:aspect.
       
  2389 
       
  2390     editor specSelector ~= aspect ifTrue:[
       
  2391         editor hasSaved ifTrue:[
       
  2392             self specTool specification listSelector:(editor specSelector).
       
  2393             self modifiedChannel value:true.
       
  2394             self accept.
       
  2395         ]
       
  2396     ]
       
  2397 ! !
       
  2398 
       
  2399 !UIPainter methodsFor:'change & update'!
       
  2400 
       
  2401 layoutChanged
       
  2402     "called by the painter/canvas whenever the layout of the current selected
       
  2403      widget changed
       
  2404     "
       
  2405     self isModified ifFalse:[
       
  2406         self layoutTool update.
       
  2407         self modifiedChannel value:false
       
  2408     ]
       
  2409 !
       
  2410 
       
  2411 propertyChanged
       
  2412     "called by the painter/canvas whenever the property of the current selected
       
  2413      widget changed
       
  2414     "
       
  2415     |p|
       
  2416 
       
  2417     (p := treeView propertySelected) notNil ifTrue:[
       
  2418         self specTool specification:(p spec copy).
       
  2419         self setViewInLayoutTool:(p view).
       
  2420         self modifiedChannel value:false
       
  2421     ] ifFalse:[
       
  2422         self layoutTool layoutView notNil ifTrue:[
       
  2423             self modifiedChannel value:false.
       
  2424             self treeSelection
       
  2425         ]
       
  2426     ]
       
  2427 !
       
  2428 
       
  2429 update:something with:aParameter from:someObject
       
  2430     "catch change notifications
       
  2431     "
       
  2432     someObject == treeView model ifTrue:[
       
  2433         (something == #selection
       
  2434         or:[something == #selectionIndex]) ifTrue:[self treeSelection].
       
  2435       ^ self
       
  2436     ].
       
  2437 
       
  2438     self galleryShown == someObject ifTrue:[
       
  2439         (self galleryShown value) ifTrue:[
       
  2440             self raiseUIView:(selectionPanel window)
       
  2441         ] ifFalse:[
       
  2442             self hideUIView:(selectionPanel window)
       
  2443         ].
       
  2444       ^ self
       
  2445     ].
       
  2446 
       
  2447     self painterShown == someObject ifTrue:[
       
  2448         (self painterShown value) ifTrue:[
       
  2449             self raiseUIView:(self painter topView)
       
  2450         ] ifFalse:[
       
  2451             self hideUIView:(self painter topView)
       
  2452         ].
       
  2453       ^ self
       
  2454     ].
       
  2455 
       
  2456     "Modified: / 29.10.1997 / 17:48:19 / cg"
       
  2457 ! !
       
  2458 
       
  2459 !UIPainter methodsFor:'event handling'!
       
  2460 
       
  2461 doesNotUnderstand:aMessage
       
  2462 
       
  2463     |painter|
       
  2464 
       
  2465     painter := self painter.
       
  2466 
       
  2467     (painter respondsTo:(aMessage selector)) ifTrue:[
       
  2468         ^ aMessage sendTo:painter
       
  2469     ].
       
  2470     super doesNotUnderstand:aMessage
       
  2471 
       
  2472 ! !
       
  2473 
       
  2474 !UIPainter methodsFor:'help'!
       
  2475 
       
  2476 defaultInfoLabel
       
  2477 
       
  2478     specClass isNil ifTrue: [^'No class and selector defined.'].
       
  2479     ^specClass printString, ' >> ', specSelector
       
  2480 !
       
  2481 
       
  2482 show:aHelpText
       
  2483 
       
  2484     (self transcriptHelp and: [transcript notNil])
       
  2485     ifFalse:
       
  2486     [
       
  2487         super showHelp:aHelpText for:self
       
  2488     ]
       
  2489     ifTrue:
       
  2490     [
       
  2491         transcript hideCursor; contents:aHelpText
       
  2492     ]    
       
  2493 !
       
  2494 
       
  2495 showHelp:aHelpText for:view
       
  2496     "display active help texts in my own info area."
       
  2497 
       
  2498     (self transcriptHelp and: [transcript notNil])
       
  2499     ifFalse:
       
  2500     [
       
  2501         ^super showHelp:aHelpText for:view.
       
  2502     ]
       
  2503     ifTrue:
       
  2504     [
       
  2505         |txt|
       
  2506         aHelpText isNil ifTrue:[
       
  2507             txt := nil
       
  2508         ] ifFalse:[
       
  2509             txt := self class 
       
  2510                     convertString:(aHelpText asString)
       
  2511                     maxLineSize:(transcript width // transcript font width)
       
  2512                     skipLineFeed:true
       
  2513         ].
       
  2514         transcript hideCursor; contents:txt.
       
  2515         ^true
       
  2516     ]
       
  2517 ! !
       
  2518 
       
  2519 !UIPainter methodsFor:'private'!
       
  2520 
       
  2521 askForModification
       
  2522     "check interface modification
       
  2523     " 
       
  2524 
       
  2525     self treeSelection. "accept modifications"    
       
  2526 
       
  2527     (modified or: [self painter isModified or: [self helpTool modified]])
       
  2528     ifTrue:
       
  2529     [
       
  2530         ((YesNoBox title:'Window Spec was modified!!')        
       
  2531             noText:'Cancel';
       
  2532             yesText:'Waste it and proceed';
       
  2533             showAtPointer;
       
  2534             accepted) ifFalse: [^false].
       
  2535         modified := false.
       
  2536         self painter resetModification
       
  2537     ].
       
  2538     ^true
       
  2539 !
       
  2540 
       
  2541 checkClassAndSelector
       
  2542     "check for class & superclass"
       
  2543 
       
  2544     |superclass cls|
       
  2545 
       
  2546     specClass isNil ifTrue:[^ false].
       
  2547 
       
  2548     cls := self resolveName:specClass.
       
  2549 
       
  2550     cls isNil ifTrue:[
       
  2551         superclass := self resolveName:specSuperclass.
       
  2552 
       
  2553         superclass isNil ifTrue:[
       
  2554             self warn:'No class named ' , specSuperclass , ' exists!!'.
       
  2555             ^ false.
       
  2556         ].
       
  2557         (self confirm:'Create class ' , specClass asBoldText, '?') ifTrue:[
       
  2558             superclass subclass:(specClass asSymbol)
       
  2559                        instanceVariableNames:''
       
  2560                        classVariableNames:''
       
  2561                        poolDictionaries:''
       
  2562                        category:'Applications'.
       
  2563             ^ true.
       
  2564         ].
       
  2565         ^ false.
       
  2566     ].
       
  2567     cls isBehavior ifFalse:[
       
  2568         self warn:'A global named ' , specClass , ' exists, but it is no class.'.
       
  2569         ^ false.
       
  2570     ].
       
  2571 
       
  2572     specSuperclass isBehavior ifFalse:[
       
  2573         specSuperclass isEmpty ifFalse:[
       
  2574             superclass := self resolveName:specSuperclass
       
  2575         ] ifTrue:[
       
  2576             specSuperclass := nil.
       
  2577         ]
       
  2578     ] ifTrue:[
       
  2579         superclass := specSuperclass
       
  2580     ].
       
  2581 
       
  2582     specSuperclass notNil ifTrue:[
       
  2583         superclass isNil ifTrue:[
       
  2584             self warn:'No class named ' , specSuperclass , ' exists!!'.
       
  2585             ^ false.
       
  2586         ].
       
  2587 
       
  2588         (cls isSubclassOf:superclass) ifFalse:[
       
  2589             self information:('A global named ' , specClass , ' exists,\' ,
       
  2590                               'but is not a subclass of ' , superclass name , '.\\' ,
       
  2591                               'Check and try again if that is not what you want.') withCRs.
       
  2592         ]
       
  2593     ].
       
  2594 
       
  2595     superclass isNil ifTrue:[
       
  2596         cls notNil ifTrue:[
       
  2597             specSuperclass := cls superclass name
       
  2598         ]
       
  2599     ].
       
  2600 
       
  2601     ^ true
       
  2602 
       
  2603     "Modified: 12.8.1997 / 23:39:10 / cg"
       
  2604 !
       
  2605 
       
  2606 checkModified
       
  2607     "check interface modification
       
  2608     "               
       
  2609     (self isModified and: [self isModified or: [self helpTool modified]])
       
  2610     ifTrue:
       
  2611     [
       
  2612         ((YesNoBox title:'Window Spec was modified!!')        
       
  2613             noText:'Cancel';
       
  2614             yesText:'Waste it and proceed';
       
  2615             showAtPointer;
       
  2616             accepted) ifFalse: [^false].
       
  2617         self painter resetModification
       
  2618     ].
       
  2619     ^true
       
  2620 !
       
  2621 
       
  2622 hideUIView:aView
       
  2623     "hide the view which is an application or top view
       
  2624     "
       
  2625     aView beIndependent.
       
  2626     aView unmap.
       
  2627 !
       
  2628 
       
  2629 raiseTabView
       
  2630 
       
  2631     self isLayoutToolSelected ifTrue:[
       
  2632         layoutCanvas raise
       
  2633     ] ifFalse:[
       
  2634         self isHelpToolSelected ifTrue:[
       
  2635             helpCanvas raise
       
  2636         ] ifFalse:[
       
  2637             self specTool selection:tabSelection.
       
  2638             specCanvas raise
       
  2639         ]
       
  2640     ]
       
  2641 !
       
  2642 
       
  2643 raiseUIView:aView
       
  2644     "raise the view which is an application or top view
       
  2645     "
       
  2646     aView map.
       
  2647     aView bePartner.
       
  2648 !
       
  2649 
       
  2650 resourceMessage: aString
       
  2651 
       
  2652     (aString notNil and: [self askForModification]) 
       
  2653     ifTrue:
       
  2654     [            
       
  2655         |msg cls sel|
       
  2656         msg := aString asCollectionOfWords.
       
  2657         (msg size == 2 and:
       
  2658         [(cls := self resolveName:(msg at:1)) notNil])
       
  2659         ifTrue:
       
  2660         [
       
  2661             self specClass:cls.
       
  2662             specSuperclass := cls superclass name.
       
  2663             specSelector := (msg at: 2) asSymbol.
       
  2664             ^true
       
  2665         ]
       
  2666     ].
       
  2667     ^false
       
  2668 !
       
  2669 
       
  2670 setClass:cls selector:selector
       
  2671     "set the application class and the selector under which the
       
  2672      window specification should be stored
       
  2673     "
       
  2674     |clsName superClassName|
       
  2675 
       
  2676     clsName := cls name.
       
  2677     superClassName := cls superclass name.
       
  2678 
       
  2679     (self aspectFor:#classNameChannel) value:clsName.
       
  2680     (self aspectFor:#methodNameChannel) value:(selector ? '').
       
  2681     (self aspectFor:#superclassNameChannel) value:superClassName.
       
  2682 
       
  2683     self painter 
       
  2684             className:clsName 
       
  2685             superclassName:superClassName
       
  2686             selector:(selector ? '').
       
  2687 
       
  2688     self specClass:clsName.
       
  2689     specSelector := (selector ? '').
       
  2690     specSuperclass := superClassName.
       
  2691 
       
  2692     specClass notNil & selector notNil ifTrue:[
       
  2693         self addToHistory: (specClass, ' ', specSelector) -> #loadFromMessage:.
       
  2694         self updateInfoLabel
       
  2695     ].
       
  2696 
       
  2697     "Modified: / 5.2.1998 / 09:44:58 / stefan"
       
  2698 !
       
  2699 
       
  2700 setViewInLayoutTool:aView
       
  2701     "set view for layout tool
       
  2702     "
       
  2703     |type|
       
  2704 
       
  2705     self painter topView == aView ifTrue:[
       
  2706         type := #Extent
       
  2707     ].
       
  2708     self layoutTool layoutView:aView type:type
       
  2709 
       
  2710 !
       
  2711 
       
  2712 specClass:aClass
       
  2713 
       
  2714     specClass := aClass isBehavior ifTrue:[aClass name]
       
  2715                                    ifFalse:[aClass].
       
  2716 
       
  2717     self helpTool buildFromClass:specClass.    
       
  2718     self helpTool updateList.
       
  2719     self modifiedChannel value: false. 
       
  2720 
       
  2721 ! !
       
  2722 
       
  2723 !UIPainter methodsFor:'private tools'!
       
  2724 
       
  2725 helpTool
       
  2726     "returns the help tool
       
  2727     "
       
  2728     helpCanvas isNil ifTrue:[
       
  2729         self noteBookView
       
  2730     ].
       
  2731     ^ helpCanvas application
       
  2732 !
       
  2733 
       
  2734 layoutTool
       
  2735     "returns the layout tool
       
  2736     "
       
  2737     layoutCanvas isNil ifTrue:[
       
  2738         self noteBookView
       
  2739     ].
       
  2740     ^ layoutCanvas application
       
  2741 !
       
  2742 
       
  2743 painter
       
  2744     "returns the painter/canvas view
       
  2745     "
       
  2746     ^ treeView canvas
       
  2747 !
       
  2748 
       
  2749 specTool
       
  2750     "returns the spec tool
       
  2751     "
       
  2752     specCanvas isNil ifTrue:[
       
  2753         self noteBookView
       
  2754     ].
       
  2755     ^ specCanvas application
       
  2756 ! !
       
  2757 
       
  2758 !UIPainter methodsFor:'queries'!
       
  2759 
       
  2760 hasSpecClass
       
  2761     "checks whether an application class is defined
       
  2762     "
       
  2763     ^ (self resolveName:specClass) notNil
       
  2764 !
       
  2765 
       
  2766 hasSpecClassAndSelector
       
  2767     "checks whether an application class and a selector under which
       
  2768      the window specification is stored is defined.
       
  2769     "
       
  2770     specSelector size > 1 ifTrue:[
       
  2771         ^ self hasSpecClass
       
  2772     ].
       
  2773   ^ false
       
  2774 !
       
  2775 
       
  2776 isHelpToolSelected
       
  2777     "returns true if current selected tab in the noteBook is assigned
       
  2778      to the 'Help' tool
       
  2779     "
       
  2780     ^ tabSelection = UIHelpTool label
       
  2781 
       
  2782 !
       
  2783 
       
  2784 isLayoutToolSelected
       
  2785     "returns true if current selected tab in the noteBook is assigned
       
  2786      to the 'Layout' tool
       
  2787     "
       
  2788     ^ tabSelection = UILayoutTool label
       
  2789 !
       
  2790 
       
  2791 isModified
       
  2792     "return true if current specification or layout is modified
       
  2793     "
       
  2794     ^ self modifiedChannel value
       
  2795 !
       
  2796 
       
  2797 isPainterEnabled
       
  2798     "returns true if not running in test mode
       
  2799     "
       
  2800     ^ self painter enabled
       
  2801 ! !
       
  2802 
       
  2803 !UIPainter methodsFor:'selection'!
       
  2804 
       
  2805 tabSelection
       
  2806     "returns name of current selected tab in the notebook.
       
  2807     "
       
  2808     ^ tabSelection
       
  2809 !
       
  2810 
       
  2811 tabSelection:something
       
  2812     "the tab selection of the notebook changed
       
  2813     "
       
  2814 
       
  2815     |whatToDo|
       
  2816 
       
  2817     (something isNil or:[tabSelection = something]) ifTrue:[
       
  2818         ^ self
       
  2819     ].
       
  2820 
       
  2821     self isModified ifTrue:[
       
  2822         whatToDo := DialogBox 
       
  2823                         confirmWithCancel:'Accept modifications in section ' , tabSelection printString , '?'
       
  2824                         labels:#('Cancel' 'Ignore' 'Accept')
       
  2825                         default:3.
       
  2826         whatToDo isNil ifTrue:[^self].
       
  2827         whatToDo == true ifTrue:[
       
  2828             self accept
       
  2829         ] ifFalse:[
       
  2830             self cancel
       
  2831         ]
       
  2832     ].
       
  2833 
       
  2834     tabSelection := something.
       
  2835     self raiseTabView.
       
  2836     self cancel.
       
  2837 
       
  2838 !
       
  2839 
       
  2840 treeSelection
       
  2841     "called whenever the selection of the treeview changed
       
  2842     "
       
  2843     |view list spec slices size property tabComponent canCutOrCopy canPaste clipboard sel|
       
  2844 
       
  2845     self isModified ifTrue:[
       
  2846         (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[
       
  2847             self accept
       
  2848         ]
       
  2849     ].
       
  2850 
       
  2851     self canMoveOrAlignSelection        value:(treeView canMoveOrAlignSelection).
       
  2852     self canChangeOrderInContainer      value:(treeView canChangeOrderInContainer).
       
  2853     self canMoveSelectionIntoContainer  value:(treeView canMoveSelectionIntoContainer).
       
  2854     self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
       
  2855     self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
       
  2856 
       
  2857     treeView isCanvasSelected ifTrue:[
       
  2858         spec := treeView canvasSpec.
       
  2859         view := self painter topView.
       
  2860     ] ifFalse:[
       
  2861         (property := treeView propertySelected) notNil ifTrue:[
       
  2862             treeView canResizeSelectedWidget ifTrue:[
       
  2863                 view := property view.
       
  2864             ].
       
  2865             spec := property spec copy.
       
  2866         ]
       
  2867     ].
       
  2868     tabComponent := builder componentAt:#noteBook.
       
  2869     self setViewInLayoutTool:view.
       
  2870     self specTool specification:spec.
       
  2871 
       
  2872     spec notNil ifTrue:[
       
  2873         self helpTool helpKey:(spec activeHelpKey).
       
  2874         slices := spec class slices.
       
  2875         size   := slices size.
       
  2876 
       
  2877         view notNil ifTrue:[
       
  2878             self treeView isCanvasSelected 
       
  2879             ifFalse:
       
  2880             [
       
  2881                 list := Array new:(size + 2).
       
  2882                 list at:(size + 2) put:(UILayoutTool label).
       
  2883             ]
       
  2884             ifTrue:
       
  2885             [
       
  2886                 list := Array new:(size + 1).
       
  2887                 list at:(size + 1) put:(UILayoutTool label).
       
  2888             ].
       
  2889         ] ifFalse:[
       
  2890             list := Array new:(size + 1).
       
  2891         ].
       
  2892 
       
  2893         1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
       
  2894         self treeView isCanvasSelected ifFalse: [list at:(size + 1) put:(UIHelpTool label)].
       
  2895 
       
  2896         self tabList value:list.
       
  2897         self show:(spec class name).
       
  2898         tabComponent enabled:true.
       
  2899 
       
  2900         (tabSelection := tabComponent selection) isNil ifTrue:[
       
  2901             tabComponent setSelection:(tabSelection := list first)
       
  2902         ].
       
  2903         self raiseTabView
       
  2904     ] ifFalse:[
       
  2905         self helpTool helpKey:nil.
       
  2906         tabComponent enabled:false.
       
  2907         self show:nil.
       
  2908     ].
       
  2909     self modifiedChannel value:false.
       
  2910 
       
  2911     treeView notNil
       
  2912     ifTrue:
       
  2913     [
       
  2914         canCutOrCopy := treeView selection size >= 1 and:[treeView selection first ~~ 1].
       
  2915         clipboard := self getSelection.
       
  2916 
       
  2917         clipboard isCollection ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]]
       
  2918                               ifFalse:[sel := clipboard].
       
  2919 
       
  2920         canPaste := (sel isKindOf:UISpecification) and: 
       
  2921                     [treeView selection size  = 1 
       
  2922                     and:[treeView selection first == 1 
       
  2923                     or: [self canPasteInto: treeView selectedNode contents view]]]
       
  2924     ].
       
  2925 
       
  2926     self valueOfCanCut value: canCutOrCopy.
       
  2927     self valueOfCanCopy value: canCutOrCopy.
       
  2928     self valueOfCanPaste value: canPaste.            
       
  2929     self valueOfCanPasteWithKeepingLayout value: (canPaste &  self canKeepLayoutInSelection).
       
  2930 
       
  2931 
       
  2932 ! !
       
  2933 
       
  2934 !UIPainter methodsFor:'startup / release'!
       
  2935 
       
  2936 closeRequest
       
  2937     "close all windows open by builder
       
  2938     "
       
  2939 
       
  2940     self askForModification ifFalse:[^self].
       
  2941 
       
  2942     treeView model removeDependent:self.
       
  2943     self painter release.
       
  2944     ColorMenu releaseResources.
       
  2945 
       
  2946     selectionPanel notNil ifTrue:[
       
  2947         selectionPanel masterApplication:nil.
       
  2948         selectionPanel closeRequest
       
  2949     ].
       
  2950     selectionPanel := nil.
       
  2951     treeView       := nil.
       
  2952 
       
  2953     ActiveHelp stopFor:self.
       
  2954 
       
  2955     super closeRequest.
       
  2956 
       
  2957     "Modified: / 27.10.1997 / 00:01:30 / cg"
       
  2958 !
       
  2959 
       
  2960 closeRequestFor:aTopView
       
  2961     "handle a close request for a specific view
       
  2962     "
       
  2963     |topView|
       
  2964 
       
  2965     topView := self window.
       
  2966 
       
  2967     topView == aTopView ifTrue:[
       
  2968         super closeRequestFor:aTopView
       
  2969     ] ifFalse:[
       
  2970         aTopView = selectionPanel window ifTrue:[
       
  2971             self galleryShown value:false
       
  2972         ] ifFalse:[
       
  2973             aTopView == (self painter topView) ifTrue:[
       
  2974                 self painterShown value:false
       
  2975             ] ifFalse:[
       
  2976                 aTopView closeRequest
       
  2977             ]
       
  2978         ].
       
  2979         topView raise.
       
  2980     ].
       
  2981 !
       
  2982 
       
  2983 loadFromMessage: aMessage
       
  2984 
       
  2985     ((aMessage size > 0) and: [self askForModification])
       
  2986     ifTrue:
       
  2987     [
       
  2988         |readStream aClass aSelector|
       
  2989         readStream := aMessage readStream.
       
  2990         (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil
       
  2991         ifTrue:
       
  2992         [
       
  2993             aSelector :=  readStream upToEnd asSymbol.
       
  2994             self setClass: aClass selector: aSelector.    
       
  2995             (aClass respondsTo:aSelector) 
       
  2996             ifTrue:
       
  2997             [
       
  2998                 self painter setupFromSpec:(aClass perform:aSelector).
       
  2999                 treeView selection: #(1). 
       
  3000             ]
       
  3001         ]
       
  3002     ]
       
  3003 !
       
  3004 
       
  3005 openInterface:aSymbol
       
  3006     "open interfaces
       
  3007     "
       
  3008     |painterView painter cls topView|
       
  3009 
       
  3010     modified := false.
       
  3011 
       
  3012     aspects := IdentityDictionary new.
       
  3013 
       
  3014     aspects at:#classNameChannel put:(
       
  3015         (specClass notNil ifTrue:[specClass]
       
  3016                          ifFalse:['NewApplication']) asValue
       
  3017     ).
       
  3018     specSuperclass isNil ifTrue:[
       
  3019         specClass notNil ifTrue:[
       
  3020             (cls := self resolveName:specClass) notNil ifTrue:[
       
  3021                 specSuperclass := cls superclass name.
       
  3022             ]
       
  3023         ]
       
  3024     ].
       
  3025     aspects at:#superclassNameChannel put:(
       
  3026         (specSuperclass notNil ifTrue:[specSuperclass]
       
  3027                          ifFalse:['ApplicationModel']) asValue
       
  3028     ).
       
  3029     aspects at:#superclassNameDefaults put:#('ApplicationModel' 'SimpleDialog') asValue.
       
  3030     aspects at:#methodNameChannel put:(
       
  3031         (specSelector notNil ifTrue:[specSelector asValue]
       
  3032                             ifFalse:[#windowSpec]) asValue
       
  3033     ).
       
  3034 
       
  3035     treeView    := TreeView new.
       
  3036     painterView := StandardSystemView new.
       
  3037     painterView name: self class defaultNameOfCanvas.
       
  3038     painterView label: self class defaultNameOfCanvas.
       
  3039     painterView extent:300@300.
       
  3040 
       
  3041     painter := UIPainterView in:painterView.
       
  3042     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
       
  3043 
       
  3044     treeView := treeView canvas:painter.
       
  3045     painter treeView:treeView.
       
  3046     treeView model addDependent:self.
       
  3047 
       
  3048     self transcriptHelp
       
  3049     ifFalse:
       
  3050     [
       
  3051         super openInterface:aSymbol.
       
  3052     ]
       
  3053     ifTrue:
       
  3054     [
       
  3055         super openInterface:#windowSpecWithTranscriptHelp.
       
  3056         transcript := (self builder componentAt:#HelpTranscript) scrolledView.
       
  3057     ].
       
  3058 
       
  3059     topView := self window.
       
  3060 
       
  3061     topView label:'GUI Painter'.
       
  3062 
       
  3063     painterView openInGroup:(topView windowGroup).
       
  3064     painterView open.
       
  3065     painterView application:self.     
       
  3066 
       
  3067     painterView application:self.
       
  3068     selectionPanel := UISelectionPanel new.
       
  3069     selectionPanel allButOpenInterface:#windowSpec.
       
  3070     selectionPanel window openInGroup:(topView windowGroup).
       
  3071 
       
  3072     selectionPanel openWindow.
       
  3073     selectionPanel masterApplication:self.
       
  3074 
       
  3075     topView iconLabel:'GUI Painter'.
       
  3076     topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  3077 
       
  3078     painterView iconLabel:'GUI Painter'.
       
  3079     painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  3080 
       
  3081     topView bePartner.
       
  3082     painterView bePartner.
       
  3083     selectionPanel window bePartner.
       
  3084 
       
  3085     selectionPanel window iconLabel:'GUI Painter'.
       
  3086     selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).
       
  3087 
       
  3088 !
       
  3089 
       
  3090 openOnClass:aClass
       
  3091     "open up an interface builder
       
  3092     "
       
  3093     self openOnClass:aClass andSelector:#windowSpec
       
  3094 !
       
  3095 
       
  3096 openOnClass:aClass andSelector:aSelector
       
  3097     "open up an interface builder, fetching a spec from someClass
       
  3098      via some selector
       
  3099     "
       
  3100     |painter|
       
  3101 
       
  3102     aClass isNil ifTrue:[
       
  3103         (self confirm:'No class given to the GUI Painter (class was probably renamed?)\\Open anyway (to create a new window spec) ?' withCRs)
       
  3104         ifFalse:[^ nil].
       
  3105     ].
       
  3106 
       
  3107     self openInterface.
       
  3108 
       
  3109     aClass notNil ifTrue:[
       
  3110         painter := self painter.
       
  3111         self setClass:aClass selector:aSelector.
       
  3112         (aClass respondsTo:aSelector) ifTrue:[
       
  3113             "take care for those who do close very quickly"
       
  3114             Object errorSignal handle: [:ex|] do: 
       
  3115             [
       
  3116                 painter setupFromSpec:(aClass perform:aSelector).
       
  3117                 treeView selection: #(1)
       
  3118             ].
       
  3119         ]
       
  3120     ]
       
  3121 
       
  3122     "Modified: / 25.10.1997 / 19:11:51 / cg"
       
  3123     "Modified: / 5.2.1998 / 09:48:15 / stefan"
       
  3124 !
       
  3125 
       
  3126 postOpenWith: aBuilder
       
  3127 
       
  3128     |painter settings gridPara hspace vspace|
       
  3129 
       
  3130     super postOpenWith: aBuilder.
       
  3131 
       
  3132     treeView selection: (Array with: 1).
       
  3133     self treeSelection.   
       
  3134 
       
  3135     painter  := self painter.
       
  3136     settings := self class settings.
       
  3137     gridPara := painter gridParameters copy.
       
  3138     hspace   := settings at: #HGridSpace ifAbsent: [10].
       
  3139     vspace   := settings at: #VGridSpace ifAbsent: [10].
       
  3140     gridPara at:1 put:hspace; at:2 put:vspace; at:5 put:hspace; at:6 put:vspace.
       
  3141     painter gridParameters:gridPara.
       
  3142     painter gridShown: (settings at: #GridShown ifAbsent: [false]).
       
  3143     painter gridAlign: (settings at: #GridAlign ifAbsent: [false]).
       
  3144     painter clear.
       
  3145 
       
  3146 
       
  3147 ! !
       
  3148 
       
  3149 !UIPainter methodsFor:'user actions'!
       
  3150 
       
  3151 doBrowseAspectMethods
  2781 doBrowseAspectMethods
  3152     "open a browser on the aspect methods"
  2782     "opens a browser on the aspect methods"
  3153 
  2783 
  3154     |cls methods|
  2784     |methods|
  3155 
  2785 
  3156     self painter isModified ifTrue:[
  2786     self painter isModified ifTrue:[
  3157         self warn:'The current window spec has not yet been saved!!\\The System Browser may show the code of the old aspect methods.' withCRs.
  2787         self warn:'The current window spec has not yet been saved!!\\The System Browser may show the code of the old aspect methods.' withCRs.
  3158     ].
  2788     ].
  3159     cls := self resolveName:specClass.
  2789 
  3160 
  2790     (methods := self painter aspectMethods) isEmpty ifTrue:[
  3161     cls notNil ifTrue:[
  2791         self warn:'No aspect methods found!!'.
  3162         methods := self painter aspectMethods.
  2792         ^ self.
  3163         methods isEmpty ifTrue:[
  2793     ].
  3164             self warn:'No aspect methods have been saved yet!!'.
  2794     SystemBrowser browseMethods:methods title:'Aspect methods'.
  3165             ^ self.
  2795 
  3166         ].
       
  3167         SystemBrowser browseMethods:methods title:'Aspect methods'.
       
  3168     ] ifFalse:[
       
  3169         self information:'No class defined!!'.
       
  3170     ].
       
  3171 
       
  3172     "Created: / 25.10.1997 / 19:07:55 / cg"
       
  3173 !
  2796 !
  3174 
  2797 
  3175 doBrowseClass
  2798 doBrowseClass
  3176     "open a System Browser on the class"
  2799     "opens a System Browser on the specClass"
  3177 
       
  3178     |cls|
       
  3179 
  2800 
  3180     self painter isModified ifTrue:[
  2801     self painter isModified ifTrue:[
  3181         self warn:'The current window spec has not yet been saved!!\\The System Browser will show the code of the old window spec.' withCRs.
  2802         self warn:'The current window spec has not yet been saved!!\\The System Browser will show the code of the old window spec.' withCRs.
  3182     ].
  2803     ].
  3183     cls := self resolveName:specClass.
  2804 
  3184 
  2805     SystemBrowser openInClass:(self resolveName:specClass)
  3185     cls notNil ifTrue:[
  2806     
  3186         SystemBrowser openInClass:cls
       
  3187     ] ifFalse:[
       
  3188         self information:'No class defined!!'.
       
  3189     ].
       
  3190 
       
  3191 !
       
  3192 
       
  3193 doChooseTreeViewFont
       
  3194 
       
  3195     |font|
       
  3196     (font := FontPanel 
       
  3197         fontFromUserInitial: treeView class defaultFont
       
  3198         title: 'Choose Tree View Font') notNil
       
  3199     ifTrue:
       
  3200     [
       
  3201         treeView class defaultFont: (font on: device).
       
  3202         treeView font: treeView class defaultFont
       
  3203     ]
       
  3204 !
  2807 !
  3205 
  2808 
  3206 doDefineClassAndSelector
  2809 doDefineClassAndSelector
  3207     "launch a dialog to define class, superclass, and selector"
  2810     "launches a dialog for defining class, superclass, and selector of the application"
  3208 
  2811 
  3209     |again tmp helpDict helpKey|
  2812     |again tmp helpDict helpKey|
  3210 
  2813 
  3211     [
  2814     [
  3212         again := false.
  2815         again := false.
  3249     self helpTool dictionary declareAllFrom: helpDict.
  2852     self helpTool dictionary declareAllFrom: helpDict.
  3250     self helpTool updateList.
  2853     self helpTool updateList.
  3251     self helpTool helpKey: helpKey.
  2854     self helpTool helpKey: helpKey.
  3252     self modifiedChannel value: false.
  2855     self modifiedChannel value: false.
  3253     self helpTool modified: true.
  2856     self helpTool modified: true.
       
  2857 
       
  2858     self updateInfoLabel
  3254 !
  2859 !
  3255 
  2860 
  3256 doDefineGrid
  2861 doDefineGrid
  3257     "open a dialog for grip parameters configuration
  2862     "opens a dialog for the grid parameters"
  3258     "
  2863 
  3259     |hspace vspace bindings painter gridPara settings|
  2864     |hspace vspace bindings painter gridPara settings|
  3260 
  2865 
  3261     painter  := self painter.
  2866     painter  := self painter.
  3262     bindings := IdentityDictionary new.
  2867     bindings := IdentityDictionary new.
  3263     gridPara := painter gridParameters copy.
  2868     gridPara := painter gridParameters copy.
  3292     painter clear.
  2897     painter clear.
  3293 
  2898 
  3294 !
  2899 !
  3295 
  2900 
  3296 doGenerateAspectMethods
  2901 doGenerateAspectMethods
  3297     "generate aspect and action methods
  2902     "generates aspect and action methods for the application class"
  3298     "
  2903 
  3299     |code|
  2904     self askForSectionModification.
  3300 
  2905 
  3301     self treeSelection. "accept modifications"
  2906     (ReadStream on:self painter generateAspectMethods) fileIn.
  3302 
       
  3303     self hasSpecClassAndSelector ifFalse:[
       
  3304         self doDefineClassAndSelector
       
  3305     ].
       
  3306 
       
  3307     self checkClassAndSelector ifFalse:[
       
  3308         ^ self
       
  3309     ].
       
  3310 
       
  3311     self painter className:specClass
       
  3312         superclassName:specSuperclass
       
  3313               selector:specSelector.
       
  3314 
       
  3315     code := self painter generateAspectMethods.
       
  3316     (ReadStream on:code) fileIn.
       
  3317 
  2907 
  3318 !
  2908 !
  3319 
  2909 
  3320 doGenerateHookMethods
  2910 doGenerateHookMethods
  3321     "generate hook methods for the application class
  2911     "generates hook methods for the application class"
  3322     "
  2912 
  3323     |code|
  2913     self askForSectionModification.
  3324 
  2914 
  3325     self treeSelection. "accept modifications"
  2915     (ReadStream on:self painter generateHookMethods) fileIn.
  3326 
  2916 
  3327     self hasSpecClassAndSelector ifFalse:[
  2917 !
  3328         self doDefineClassAndSelector
  2918 
  3329     ].
  2919 doInspectSpec
  3330 
  2920     "opens an inspector on the spec of the selected widget"
  3331     self checkClassAndSelector ifFalse:[
  2921 
  3332         ^ self
  2922     |spec|
  3333     ].
  2923 
  3334 
  2924     (spec := self specForSelection) isNil ifTrue:[
  3335     self painter className:specClass
  2925         treeView isCanvasSelected ifTrue:[
  3336         superclassName:specSuperclass
  2926             spec := treeView canvasSpec.
  3337               selector:specSelector.
  2927         ]
  3338 
  2928     ].
  3339     code := self painter generateHookMethods.
  2929     spec notNil ifTrue:[
  3340     (ReadStream on:code) fileIn.
  2930         spec inspect
  3341 
  2931     ]
  3342     "Created: / 31.10.1997 / 17:37:54 / cg"
  2932 
       
  2933 
       
  2934 !
       
  2935 
       
  2936 doInspectView
       
  2937     "opens an inspector on the view of the selected widget"
       
  2938 
       
  2939     |selection|
       
  2940 
       
  2941     ((selection := self painter selection) isCollection and: [selection size >= 1]) ifTrue:[
       
  2942         selection first inspect
       
  2943     ] ifFalse: [
       
  2944         selection inspect
       
  2945     ]
       
  2946 
  3343 !
  2947 !
  3344 
  2948 
  3345 doLoad
  2949 doLoad
       
  2950     "opens a ResourceSelectionBrowser for loading a window spec from a class"
  3346 
  2951 
  3347     self askForModification ifFalse: [^nil].
  2952     self askForModification ifFalse: [^nil].
  3348 
  2953 
  3349     self loadFromMessage: 
  2954     self loadFromMessage: 
  3350         (ResourceSelectionBrowser
  2955         (ResourceSelectionBrowser
  3354             andSelector: specSelector ? #windowSpec
  2959             andSelector: specSelector ? #windowSpec
  3355             withResourceTypes: #(canvas))
  2960             withResourceTypes: #(canvas))
  3356 !
  2961 !
  3357 
  2962 
  3358 doLoadSubspec
  2963 doLoadSubspec
       
  2964     "opens a ResourceSelectionBrowser for loading a sub spec from a class"
  3359 
  2965 
  3360     |subSpecMessage|
  2966     |subSpecMessage|
  3361 
  2967 
  3362     self treeSelection. "ask for modification"
  2968     self askForSectionModification.
  3363 
  2969 
  3364     (subSpecMessage := ResourceSelectionBrowser
  2970     (subSpecMessage := ResourceSelectionBrowser
  3365             request: 'Load Subspec From Class'
  2971             request: 'Load Subspec From Class'
  3366             onSuperclass: nil
  2972             onSuperclass: nil
  3367             andClass: specClass
  2973             andClass: specClass
  3384         ]
  2990         ]
  3385     ]
  2991     ]
  3386 !
  2992 !
  3387 
  2993 
  3388 doNew
  2994 doNew
  3389     "remove all components and associated resources
  2995     "removes all widgets, specClass, and specSelector"
  3390     "
       
  3391 
  2996 
  3392     self askForModification ifFalse: [^nil].
  2997     self askForModification ifFalse: [^nil].
  3393     specClass := specSelector := nil.
  2998     specClass := specSelector := nil.
  3394     self painter removeAll.
  2999     self painter removeAll.
  3395     treeView canvas topView name:  UIPainter defaultNameOfCanvas.
  3000     treeView canvas topView name:  UIPainter defaultNameOfCanvas.
  3396     treeView canvas topView label: UIPainter defaultNameOfCanvas.
  3001     treeView canvas topView label: UIPainter defaultNameOfCanvas.
  3397     self helpTool doNew.
  3002     self helpTool doNew.
  3398     treeView selection:#(1).
  3003     treeView selection:#(1).
  3399     self treeSelection.
       
  3400     self updateInfoLabel.
  3004     self updateInfoLabel.
  3401 !
  3005 !
  3402 
  3006 
       
  3007 doOpenWidgetDocumentation
       
  3008     "opens documentation for the selected widget"
       
  3009 
       
  3010     |spec document|
       
  3011 
       
  3012     (spec := self specForSelection) isNil ifTrue:[
       
  3013         treeView isCanvasSelected ifTrue:[
       
  3014             spec := nil
       
  3015         ]
       
  3016     ].
       
  3017     spec notNil ifTrue:[
       
  3018         document := 'tools/uipainter/', spec userFriendlyName,'.html'
       
  3019     ] ifFalse: [
       
  3020         document := 'tools/uipainter/TOP.html#THEWIDGETSANDHOWDOTHEYWORK'
       
  3021     ].
       
  3022     HTMLDocumentView openFullOnDocumentationFile: document 
       
  3023 
       
  3024 
       
  3025 !
       
  3026 
  3403 doPickAView
  3027 doPickAView
  3404     "pick a view and setup specifications
  3028     "changes the cursor for picking a view and builds a window spec from it"
  3405     "
  3029 
  3406     |painter view cls spec app|
  3030     |view|
  3407 
  3031 
  3408     self askForModification ifFalse: [^nil].
  3032     self askForModification ifFalse: [^nil].
  3409 
  3033 
  3410     (view := Screen current viewFromUser) notNil ifTrue:[
  3034     (view := Screen current viewFromUser) notNil ifTrue:[
  3411         view == Screen current rootView ifFalse:[
  3035         view == Screen current rootView ifFalse:[
  3412             painter := self painter.
  3036             self painter setupFromSpec:(UISpecification fromView:view topView).
  3413             spec    := UISpecification fromView:view topView.
       
  3414 
       
  3415          "/ ok, got it
       
  3416 
       
  3417          "   (app := view application) notNil ifTrue:[
       
  3418                 cls := app class
       
  3419             ] ifFalse:[
       
  3420                 cls := view class
       
  3421             ].            
       
  3422             self setClass:cls selector:nil.
       
  3423          "
       
  3424             painter setupFromSpec:spec.
       
  3425         ]
  3037         ]
  3426     ].
  3038     ].
  3427 
  3039 
  3428     self updateInfoLabel
  3040     self updateInfoLabel
  3429 
  3041 
  3430 !
  3042 !
  3431 
  3043 
  3432 doSave
  3044 doSave
  3433     "install window spec
  3045     "saves the window spec"
  3434     "
  3046 
  3435     |code painter|
  3047     |code painter|
  3436 
  3048 
  3437     self treeSelection. "ask for modification"
  3049     self askForSectionModification.
  3438 
  3050 
  3439     self hasSpecClassAndSelector ifFalse:[
  3051     self hasSpecClassAndSelector ifFalse:[
  3440          (self doDefineClassAndSelector) isNil ifTrue: [^nil]
  3052         self doDefineClassAndSelector isNil ifTrue: [^nil]
  3441     ].
  3053     ].
  3442 
  3054 
  3443     (specClass notNil and: [(Smalltalk at: specClass asSymbol) isClass])
  3055     (specClass notNil and: [(Smalltalk at: specClass asSymbol) isClass])
  3444     ifFalse: 
  3056     ifFalse: 
  3445     [   
  3057     [   
  3446         ^nil
  3058         ^nil
  3447     ].
  3059     ].
  3448 
  3060 
  3449     self isModified ifTrue:[
       
  3450         (self confirm:'Accept modifications in section ' , tabSelection printString , '?') ifTrue:[
       
  3451             self accept
       
  3452         ] ifFalse:[
       
  3453             (self confirm:'Load old window spec?') ifFalse:[
       
  3454                 ^ self
       
  3455             ]
       
  3456         ]
       
  3457     ].
       
  3458 
       
  3459     painter := self painter.
  3061     painter := self painter.
  3460 
  3062 
  3461     painter className:specClass
  3063     painter className:specClass
  3462        superclassName:specSuperclass
  3064        superclassName:specSuperclass
  3463              selector:specSelector.
  3065              selector:specSelector.
  3480 
  3082 
  3481 
  3083 
  3482 !
  3084 !
  3483 
  3085 
  3484 doSaveAs
  3086 doSaveAs
  3485     "launch a dialog to define class, superclass and method"
  3087     "opens a ResourceSelectionBrowser for saving the window spec on a class"
  3486 
  3088 
  3487     |resourceMessage|
  3089     |resourceMessage|
  3488 
  3090 
  3489     self treeSelection. "ask for modification"
  3091     self askForSectionModification.
  3490 
  3092 
  3491     (resourceMessage := ResourceSelectionBrowser
  3093     (resourceMessage := ResourceSelectionBrowser
  3492             request: 'Save Window Spec In Class'
  3094             request: 'Save Window Spec In Class'
  3493             onSuperclass: #Object
  3095             onSuperclass: #Object
  3494             andClass: (specClass ? #ApplicationModel) asSymbol
  3096             andClass: (specClass ? #ApplicationModel) asSymbol
  3507     ]
  3109     ]
  3508 
  3110 
  3509 !
  3111 !
  3510 
  3112 
  3511 doStartApplication
  3113 doStartApplication
  3512     "start current edited application
  3114     "starts the application on the editing window spec"
  3513     "
  3115 
  3514     |cls app infoMessage|
  3116     |application|
  3515 
  3117 
  3516     self treeSelection. "accept modifications"
  3118     self hasSpecClassAndSelector ifFalse:[
  3517 
  3119         self doSave isNil ifTrue: [^nil].
  3518     (specClass isNil or:[specSelector size < 2]) ifTrue:[
  3120     ] ifTrue: [
  3519         self painter isModified ifTrue:[
  3121         self askForSectionModification.    
  3520             infoMessage := 'Class and selector must be defined,\and the window spec must be saved first!!' withCRs.
  3122         (modified or: [self painter isModified or: [self helpTool modified]])
  3521         ] ifFalse:[
  3123         ifTrue:
  3522             infoMessage := 'No class and selector defined!!'.
  3124         [
       
  3125             ((YesNoBox title:'Window Spec was modified!!')        
       
  3126                 noText:'Cancel';
       
  3127                 yesText:'Save it and start';
       
  3128                 showAtPointer;
       
  3129                 accepted) ifFalse: [^nil].
       
  3130             self doSave isNil ifTrue: [^nil]
  3523         ]
  3131         ]
  3524     ] ifFalse:[
  3132     ].
  3525         cls := self resolveName:specClass.
  3133 
  3526 
  3134     ((application := (self resolveName:specClass) new) respondsTo:#openInterface:) ifFalse:[
  3527         cls isNil ifTrue:[
       
  3528             infoMessage := 'Class does not exist!!'.
       
  3529         ] ifFalse:[
       
  3530             (cls respondsTo:specSelector) ifFalse:[
       
  3531                 infoMessage := ('No method for: #' 
       
  3532                                 , specSelector , ' in ' , cls name
       
  3533                                 , '\\(did you save the window spec?)') withCRs.
       
  3534             ]
       
  3535         ]
       
  3536     ].
       
  3537 
       
  3538     infoMessage notNil ifTrue:[
       
  3539         ^ self information:infoMessage
       
  3540     ].
       
  3541 
       
  3542     self isModified ifTrue:[
       
  3543         (self confirm:'Accept modifications in section ' , tabSelection printString asBoldText, '?') ifTrue:[
       
  3544             self accept.
       
  3545             "/  "XXX must be fixed - canvas changes are not recorded in the history
       
  3546             "/  so isModified returns false here
       
  3547             "/
       
  3548             "/ self painter isModified ifTrue:[
       
  3549             "/
       
  3550             (self confirm:'Save the new window spec?' withCRs) ifTrue:[
       
  3551                 self doSave
       
  3552             ]
       
  3553         ]
       
  3554     ].
       
  3555 
       
  3556     self painter isModified ifTrue:[
       
  3557         (self confirm:'The current window spec has not yet been saved!!\\Start anyway (based upon the previous window spec)?' withCRs) ifFalse:[
       
  3558                 ^ self
       
  3559         ]
       
  3560     ].
       
  3561 
       
  3562     ((app := cls new) respondsTo:#openInterface:) ifFalse:[
       
  3563         ^ self warn:('The application does not respond to the ''openInterface:'' message.\\(maybe its supposed to be used as subApplication/subCanvas)') withCRs.
  3135         ^ self warn:('The application does not respond to the ''openInterface:'' message.\\(maybe its supposed to be used as subApplication/subCanvas)') withCRs.
  3564     ].        
  3136     ].        
  3565     app openInterface:specSelector
  3137     application openInterface:specSelector
  3566 !
  3138 !
  3567 
  3139 
  3568 doStepDown
  3140 doStepDown
  3569     "move selected component after the next component in the hierarchy of
  3141     "moves the selected widget one step down in the hierarchy"
  3570      its container widget
  3142 
  3571     "
       
  3572     treeView doStepOver:1
  3143     treeView doStepOver:1
  3573 !
  3144 !
  3574 
  3145 
  3575 doStepIn
  3146 doStepIn
  3576     "change the container of the selected widget
  3147     "moves the selected widget into the next widget as child"
  3577     "
  3148 
  3578     treeView doStepIn
  3149     treeView doStepIn
  3579 !
  3150 !
  3580 
  3151 
  3581 doStepOut
  3152 doStepOut
  3582     "change the container of the selected widget
  3153     "moves the selected widget out of the parent widget"
  3583     "
  3154 
  3584     treeView doStepOut
  3155     treeView doStepOut
  3585 !
  3156 !
  3586 
  3157 
  3587 doStepUp
  3158 doStepUp
  3588     "move selected component before the previous component in the hierarchy of
  3159     "moves the selected widget one step up in the hierarchy"
  3589      its container widget
  3160 
  3590     "
       
  3591     treeView doStepOver:-1
  3161     treeView doStepOver:-1
  3592 !
  3162 !
  3593 
  3163 
  3594 doWindowSpec
  3164 doWindowSpec
  3595    "create the window specification but do not write to application; instead
  3165     "opens a code view with the contents of the window spec"
  3596     open a view
  3166 
  3597    "
  3167     self askForSectionModification.
  3598    |code v|
  3168 
  3599 
  3169     CodeView 
  3600    self treeSelection. "accept modifications"
  3170         openWith: self painter generateWindowSpecMethodSource 
  3601 
  3171         title: 'Window Spec'
  3602    code := self painter generateWindowSpecMethodSource.
       
  3603 
       
  3604    v := CodeView open.
       
  3605    v contents:code.
       
  3606    v label:'windowSpec'.
       
  3607 
  3172 
  3608 ! !
  3173 ! !
  3609 
  3174 
  3610 !UIPainter::TreeView class methodsFor:'documentation'!
  3175 !UIPainter::TreeView class methodsFor:'documentation'!
  3611 
  3176 
  3627 ! !
  3192 ! !
  3628 
  3193 
  3629 !UIPainter::TreeView methodsFor:'accessing'!
  3194 !UIPainter::TreeView methodsFor:'accessing'!
  3630 
  3195 
  3631 canvas
  3196 canvas
  3632     "returns the canvas( UIPainter )
  3197     "returns the canvas (UIPainterView)"
  3633     "
  3198 
  3634   ^ model root contents view
  3199     ^ model root contents view
  3635 
  3200 
  3636 
  3201 
  3637 !
  3202 !
  3638 
  3203 
  3639 canvas:aCanvas
  3204 canvas:aCanvas
  3640     "install canvas( UIPainter )
  3205     "install canvas (UIPainterView)"
  3641     "
  3206 
  3642     |props|
  3207     |props|
  3643 
  3208 
  3644     props := UIPainterView::ViewProperty new.
  3209     props := UIPainterView::ViewProperty new.
  3645     props view:aCanvas.
  3210     props view:aCanvas.
  3646     model root:(TreeItem name: UIPainter defaultNameOfCanvas asBoldText contents:props).
  3211     model root:(TreeItem name: UIPainter defaultNameOfCanvas asBoldText contents:props).
  3648     self enableChannel:(aCanvas enableChannel).
  3213     self enableChannel:(aCanvas enableChannel).
  3649 
  3214 
  3650 !
  3215 !
  3651 
  3216 
  3652 canvasSpec
  3217 canvasSpec
  3653     "returns spec assigned to canvas
  3218     "returns spec assigned to canvas"
  3654     "
  3219 
  3655     |spec|
  3220     |spec|
  3656 
  3221 
  3657     spec := WindowSpec new.
  3222     spec := WindowSpec new.
  3658 
  3223 
  3659     spec fromView:(self canvas topView) callBack:nil.
  3224     spec fromView:(self canvas topView) callBack:nil.
  3660     windowSpec notNil ifTrue:[
  3225     windowSpec notNil ifTrue:[
  3661         spec copyValuesFromSpec:windowSpec
  3226         spec copyValuesFromSpec:windowSpec
  3662     ].
  3227     ].
  3663     ^ spec
  3228     ^ spec
  3664 
  3229 
  3665     "Modified: / 29.10.1997 / 18:06:44 / cg"
       
  3666 !
  3230 !
  3667 
  3231 
  3668 canvasSpec:aSpec
  3232 canvasSpec:aSpec
  3669     "update canvas from spec
  3233     "update canvas from spec"
  3670     "
  3234 
  3671     |spec|
  3235     |spec|
  3672 
  3236 
  3673     self setAttributesFromWindowSpec:aSpec.
  3237     self setAttributesFromWindowSpec:aSpec.
  3674     spec := aSpec copy.
  3238     spec := aSpec copy.
  3675     spec  menu:nil.
  3239     spec  menu:nil.
  3677 
  3241 
  3678     spec setAttributesIn:(self canvas topView) with:(UIBuilder new isEditing:true).
  3242     spec setAttributesIn:(self canvas topView) with:(UIBuilder new isEditing:true).
  3679 !
  3243 !
  3680 
  3244 
  3681 itemOfView:aView
  3245 itemOfView:aView
  3682     "returns item assigned to view or nil
  3246     "returns item assigned to view or nil"
  3683     "
  3247 
  3684     aView notNil ifTrue:[
  3248     aView notNil ifTrue:[
  3685         self allItemsDo:[:anItem|
  3249         self allItemsDo:[:anItem|
  3686             (anItem contents view == aView) ifTrue:[^ anItem]
  3250             (anItem contents view == aView) ifTrue:[^ anItem]
  3687         ]
  3251         ]
  3688     ].
  3252     ].
  3689   ^ nil
  3253     ^ nil
  3690 
  3254 
  3691 
  3255 
  3692 !
  3256 !
  3693 
  3257 
  3694 lastDrawnMaster
  3258 lastDrawnMaster
  3695     "returns the lastDrawnMaster
  3259     "returns the lastDrawnMaster"
  3696     "
  3260 
  3697   ^ lastDrawnMaster
  3261     ^ lastDrawnMaster
  3698 
  3262 
  3699 
  3263 
  3700 ! !
  3264 ! !
  3701 
  3265 
  3702 !UIPainter::TreeView methodsFor:'accessing property'!
  3266 !UIPainter::TreeView methodsFor:'accessing property'!
  3703 
  3267 
  3704 propertiesDo:aOneArgBlock
  3268 propertiesDo:aOneArgBlock
  3705     "evaluate the argument a block on each property
  3269     "evaluates the argument a block on each property"
  3706     "
  3270 
  3707     self allItemsDo:[:anItem| aOneArgBlock value:(anItem contents)]
  3271     self allItemsDo:[:anItem| aOneArgBlock value:(anItem contents)]
  3708 
  3272 
  3709 
  3273 
  3710 !
  3274 !
  3711 
  3275 
  3712 propertyDetect:aOneArgBlock
  3276 propertyDetect:aOneArgBlock
  3713     "evaluate the block on each property
  3277     "evaluates the block on each property"
  3714     "
  3278 
  3715     self allItemsDo:[:anItem|
  3279     self allItemsDo:[:anItem|
  3716         (aOneArgBlock value:(anItem contents)) ifTrue:[^ anItem contents]
  3280         (aOneArgBlock value:(anItem contents)) ifTrue:[^ anItem contents]
  3717     ].
  3281     ].
  3718   ^ nil
  3282     ^ nil
  3719 
  3283 
  3720 !
  3284 !
  3721 
  3285 
  3722 propertySelected
  3286 propertySelected
  3723     "returns current selected property or nil in case of multi selection
  3287     "returns current selected property or nil in case of multi selection
  3724      or empty selection
  3288      or empty selection "
  3725     "
  3289 
  3726     |idx|
  3290     |idx|
  3727 
  3291 
  3728     selection size == 1 ifTrue:[
  3292     selection size == 1 ifTrue:[
  3729         (idx := selection first) ~~ 1 ifTrue:[          "canvas: not yet supported"
  3293         (idx := selection first) ~~ 1 ifTrue:[          "canvas: not yet supported"
  3730             ^ (listOfNodes at:idx) contents
  3294             ^ (listOfNodes at:idx) contents
  3731         ]
  3295         ]
  3732     ].
  3296     ].
  3733   ^ nil
  3297     ^ nil
  3734 
  3298 
  3735 ! !
  3299 ! !
  3736 
  3300 
  3737 !UIPainter::TreeView methodsFor:'adding & removing'!
  3301 !UIPainter::TreeView methodsFor:'adding & removing'!
  3738 
  3302 
  3739 addProperty:aProperty
  3303 addProperty:aProperty
  3740     "add a new item
  3304     "adds a new item"
  3741     "
  3305 
  3742     |parent| 
  3306     |parent| 
  3743 
  3307 
  3744     parent := self detectItemRespondsToView:(aProperty view superView).
  3308     parent := self detectItemRespondsToView:(aProperty view superView).
  3745 
  3309 
  3746     parent notNil ifTrue:[
  3310     parent notNil ifTrue:[
  3748     ]
  3312     ]
  3749 
  3313 
  3750 !
  3314 !
  3751 
  3315 
  3752 removeAll
  3316 removeAll
  3753     "remove all items other than canvas
  3317     "removes all items other than canvas"
  3754     "
  3318 
  3755     lastDrawnMaster := nil.
  3319     lastDrawnMaster := nil.
  3756     windowSpec := nil.
  3320     windowSpec := nil.
  3757 
  3321 
  3758     self canvas subViews copy do:[:aView|
  3322     self canvas subViews copy do:[:aView|
  3759         (aView isKindOf:InputView) ifFalse:[aView destroy]
  3323         (aView isKindOf:InputView) ifFalse:[aView destroy]
  3763     model recomputeList.                
  3327     model recomputeList.                
  3764 
  3328 
  3765 !
  3329 !
  3766 
  3330 
  3767 removeView:aView
  3331 removeView:aView
  3768     "remove a view
  3332     "removes a view"
  3769     "
  3333 
  3770     |item prnt|
  3334     |item prnt|
  3771 
  3335 
  3772     ((item := self itemOfView:aView) notNil and:[(prnt := item parent) notNil]) ifTrue:[
  3336     ((item := self itemOfView:aView) notNil and:[(prnt := item parent) notNil]) ifTrue:[
  3773         aView destroy.
  3337         aView destroy.
  3774         prnt contents view sizeChanged:nil.
  3338         prnt contents view sizeChanged:nil.
  3779 ! !
  3343 ! !
  3780 
  3344 
  3781 !UIPainter::TreeView methodsFor:'building'!
  3345 !UIPainter::TreeView methodsFor:'building'!
  3782 
  3346 
  3783 generateFullSpecForComponents:aSpecArray
  3347 generateFullSpecForComponents:aSpecArray
  3784     "generates a full spec for components
  3348     "generates a full spec from aSpecArray"
  3785     "
  3349 
  3786     |fullSpec winSpec|
  3350     |fullSpec winSpec|
  3787 
  3351 
  3788     fullSpec := FullSpec new.
  3352     fullSpec := FullSpec new.
  3789 
  3353 
  3790     fullSpec fromBuilder:(self canvas topView)
  3354     fullSpec fromBuilder:(self canvas topView)
  3795         winSpec copyValuesFromSpec:windowSpec.
  3359         winSpec copyValuesFromSpec:windowSpec.
  3796         winSpec name: winSpec label.
  3360         winSpec name: winSpec label.
  3797     ].    
  3361     ].    
  3798     ^ fullSpec literalArrayEncoding.
  3362     ^ fullSpec literalArrayEncoding.
  3799 
  3363 
  3800     "Modified: / 29.10.1997 / 18:05:58 / cg"
       
  3801 !
  3364 !
  3802 
  3365 
  3803 setAttributesFromWindowSpec:aWindowSpec
  3366 setAttributesFromWindowSpec:aWindowSpec
  3804     "set windowSpec from argument a WindowSpec
  3367     "sets a window spec from aWindowSpec"
  3805     "                           
  3368 
  3806     windowSpec := WindowSpec new copyValuesFromSpec:aWindowSpec.
  3369     windowSpec := WindowSpec new copyValuesFromSpec:aWindowSpec.
  3807     self canvasNameChanged:aWindowSpec name.
  3370     self canvasNameChanged:aWindowSpec name.
  3808 
  3371 
  3809     "Modified: / 29.10.1997 / 18:06:56 / cg"
       
  3810 ! !
  3372 ! !
  3811 
  3373 
  3812 !UIPainter::TreeView methodsFor:'canvas selection'!
  3374 !UIPainter::TreeView methodsFor:'canvas selection'!
  3813 
  3375 
  3814 cvsSelection:aSelection
  3376 cvsSelection:aSelection
  3974 ! !
  3536 ! !
  3975 
  3537 
  3976 !UIPainter::TreeView methodsFor:'drag & drop'!
  3538 !UIPainter::TreeView methodsFor:'drag & drop'!
  3977 
  3539 
  3978 canDrop:anObjectOrCollection
  3540 canDrop:anObjectOrCollection
  3979     "can drop ? delegate to canvas
  3541     "can drop ? delegate to canvas"
  3980     "
  3542 
  3981   ^ self canvas canDrop:anObjectOrCollection
  3543     ^ self canvas canDrop:anObjectOrCollection
  3982 !
  3544 !
  3983 
  3545 
  3984 drop:anObjectOrCollection at:aPoint
  3546 drop:anObjectOrCollection at:aPoint
  3985     "drop objects ? delegate to canvas
  3547     "drop objects ? delegate to canvas"
  3986     "
  3548 
  3987     self canvas drop:anObjectOrCollection at:aPoint
  3549     self canvas drop:anObjectOrCollection at:aPoint
  3988 ! !
  3550 ! !
  3989 
  3551 
  3990 !UIPainter::TreeView methodsFor:'enumerating'!
  3552 !UIPainter::TreeView methodsFor:'enumerating'!
  3991 
  3553 
  3992 allItemsDo:aOneArgBlock
  3554 allItemsDo:aOneArgBlock
  3993     "evaluate the argument a block on each item other than the canvas
  3555     "evaluates the argument a block on each item other than the canvas"
  3994     "
  3556 
  3995     model root allChildrenDo:aOneArgBlock
  3557     model root allChildrenDo:aOneArgBlock
  3996 
  3558 
  3997 
  3559 
  3998 ! !
  3560 ! !
  3999 
  3561 
  4000 !UIPainter::TreeView methodsFor:'event processing'!
  3562 !UIPainter::TreeView methodsFor:'event processing'!
  4001 
  3563 
  4002 cvsEventsDisabledDo:aBlock
  3564 cvsEventsDisabledDo:aBlock
  4003     "evaluate the block without raising selection changed notifications
  3565     "evaluates the block without raising selection changed notifications
  4004      to canvas
  3566      to canvas"
  4005     "
  3567 
  4006     |restoreCvsEvents|
  3568     |restoreCvsEvents|
  4007 
  3569 
  4008     restoreCvsEvents  := cvsEventsDisabled.
  3570     restoreCvsEvents  := cvsEventsDisabled.
  4009     cvsEventsDisabled := true.
  3571     cvsEventsDisabled := true.
  4010     aBlock value.
  3572     aBlock value.
  4012 
  3574 
  4013 
  3575 
  4014 !
  3576 !
  4015 
  3577 
  4016 cvsSetupListDo:aBlock
  3578 cvsSetupListDo:aBlock
  4017     "evaluate block without handling notifications from model; after evaluation
  3579     "evaluates block without handling notifications from model; after evaluation
  4018      the new list will be recomputed
  3580      the new list will be recomputed"
  4019     "
  3581 
  4020     model removeDependent:self.
  3582     model removeDependent:self.
  4021 
  3583 
  4022     self cvsEventsDisabledDo:[
  3584     self cvsEventsDisabledDo:[
  4023         self selection:nil.
  3585         self selection:nil.
  4024         aBlock value
  3586         aBlock value
  4027     model recomputeList.
  3589     model recomputeList.
  4028 
  3590 
  4029 !
  3591 !
  4030 
  3592 
  4031 doubleClicked
  3593 doubleClicked
  4032     "disable collapse of canvas item
  3594     "disables collapsing of the root item"
  4033     "
  3595 
  4034     self selectedNode == model root ifFalse:[
  3596     self selectedNode == model root ifFalse:[
  4035         super doubleClicked
  3597         super doubleClicked
  4036     ]
  3598     ]
  4037 
  3599 
  4038 
  3600 
  4039 ! !
  3601 ! !
  4040 
  3602 
  4041 !UIPainter::TreeView methodsFor:'initialization'!
  3603 !UIPainter::TreeView methodsFor:'initialization'!
  4042 
  3604 
  4043 initialize
  3605 initialize
  4044     "initialization; set multiple select and model
  3606     "initialize the tree view; multiple select and tree item actions"
  4045     "
  3607 
  4046     super initialize.
  3608     super initialize.
  4047 
  3609 
  4048     self multipleSelectOk:true.
  3610     self multipleSelectOk:true.
  4049     cvsEventsDisabled := false.
  3611     cvsEventsDisabled := false.
  4050     self showDirectoryIndicator: true.
  3612     self showDirectoryIndicator: true.
  4082 ! !
  3644 ! !
  4083 
  3645 
  4084 !UIPainter::TreeView methodsFor:'private'!
  3646 !UIPainter::TreeView methodsFor:'private'!
  4085 
  3647 
  4086 nameForSpecInList:aSpec
  3648 nameForSpecInList:aSpec
       
  3649     "returns the tree item label for aSpec"
       
  3650 
  4087      ^ aSpec name asBoldText, ': [', aSpec viewClass name , ']' 
  3651      ^ aSpec name asBoldText, ': [', aSpec viewClass name , ']' 
  4088 !
  3652 !
  4089 
  3653 
  4090 selectionChangedFrom:oldSelection
  3654 selectionChangedFrom:oldSelection
  4091     "selection has changed. update master selection and raise notification
  3655     "selection has changed. update master selection and raise notification
  4121 
  3685 
  4122 !UIPainter::TreeView methodsFor:'queries'!
  3686 !UIPainter::TreeView methodsFor:'queries'!
  4123 
  3687 
  4124 canChangeOrderInContainer
  3688 canChangeOrderInContainer
  4125     "returns true if any selection exists and all widgets in the selection
  3689     "returns true if any selection exists and all widgets in the selection
  4126      can change their layout through to a move or align operation.
  3690      can change their layout through to a move or align operation"
  4127     "
       
  4128     |canvas|
       
  4129 
  3691 
  4130     ((selection size ~~ 1) or: [(selection at: 1) == 1]) ifTrue:[
  3692     ((selection size ~~ 1) or: [(selection at: 1) == 1]) ifTrue:[
  4131         ^ false
  3693         ^ false
  4132     ].
  3694     ].
  4133     ^ true
  3695     ^ true
  4134 !
  3696 !
  4135 
  3697 
  4136 canMoveOrAlignSelection
  3698 canMoveOrAlignSelection
  4137     "returns true if any selection exists and all widgets in the selection
  3699     "returns true if any selection exists and all widgets in the selection
  4138      can change their layout through to a move or align operation.
  3700      can change their layout through to a move or align operation"
  4139     "
       
  4140     |canvas|
       
  4141 
  3701 
  4142     selection size == 0 ifTrue:[
  3702     selection size == 0 ifTrue:[
  4143         ^ false
  3703         ^ false
  4144     ].
  3704     ].
  4145     canvas := self canvas.
       
  4146 
  3705 
  4147     selection do:[:i|
  3706     selection do:[:i|
  4148         i == 1 ifTrue:[^ false].
  3707         i == 1 ifTrue:[^ false].
  4149 
  3708 
  4150         (canvas canChangeLayoutOfView:((listOfNodes at:i) contents view)) ifFalse:[
  3709         (self canvas canChangeLayoutOfView:((listOfNodes at:i) contents view)) ifFalse:[
  4151             ^ false
  3710             ^ false
  4152         ]
  3711         ]
  4153     ].
  3712     ].
  4154     ^ true
  3713     ^ true
  4155 !
  3714 !
  4156 
  3715 
  4157 canMoveSelectionIntoContainer
  3716 canMoveSelectionIntoContainer
  4158     "returns true in case that one component is selected and can change its container
  3717     "returns true in case that one widget is selected and can change its container
  4159      widget to the next element in the list which will have the same container.
  3718      widget to the next element in the list which will have the same container"
  4160     "
  3719 
  4161     |item prnt|
  3720     |item prnt|
  4162 
  3721 
  4163     (     (item := self selectedNode) isNil
  3722     (     (item := self selectedNode) isNil
  4164       or:[(prnt := item parent) isNil
  3723       or:[(prnt := item parent) isNil
  4165       or:[(prnt := prnt childAt:((prnt indexOfChild:item) + 1)) isNil
  3724       or:[(prnt := prnt childAt:((prnt indexOfChild:item) + 1)) isNil
  4166       or:[prnt contents spec class supportsSubComponents not]]]
  3725       or:[prnt contents spec class supportsSubComponents not]]]
  4167     ) ifTrue:[
  3726     ) ifTrue:[
  4168         ^ false
  3727         ^ false
  4169     ].
  3728     ].
  4170   ^ true
  3729     ^ true
  4171 !
  3730 !
  4172 
  3731 
  4173 canMoveSelectionOutOfContainer
  3732 canMoveSelectionOutOfContainer
  4174     "returns true in case that one component is selected which is contained within
  3733     "returns true in case that one widget is selected which is contained within
  4175      another component.
  3734      another widget"
  4176     "
  3735 
  4177     |item prnt|
  3736     |item prnt|
  4178 
  3737 
  4179     (     (item := self selectedNode) isNil
  3738     (     (item := self selectedNode) isNil
  4180       or:[(prnt := item parent) isNil
  3739       or:[(prnt := item parent) isNil
  4181       or:[prnt parent isNil]]
  3740       or:[prnt parent isNil]]
  4182     ) ifTrue:[
  3741     ) ifTrue:[
  4183         ^ false
  3742         ^ false
  4184     ].
  3743     ].
  4185   ^ true
  3744     ^ true
  4186 !
  3745 !
  4187 
  3746 
  4188 canResizeSelectedWidget
  3747 canResizeSelectedWidget
  4189     "returns true in case of one widget selected and is contained
  3748     "returns true in case of one widget selected and is contained
  4190      within a widget which allows to resize sub components
  3749      within a widget which allows to resize sub components"
  4191     "
  3750 
  4192     |n|
  3751     |selectedNode|
  4193 
  3752 
  4194     (n := self selectedNode) notNil ifTrue:[
  3753     (selectedNode := self selectedNode) notNil ifTrue:[
  4195         (n := n parent) notNil ifTrue:[
  3754         (selectedNode := selectedNode parent) notNil ifTrue:[
  4196             ^ (n parent isNil or:[n contents spec class canResizeSubComponents])
  3755             ^ (selectedNode parent isNil or:[selectedNode contents spec class canResizeSubComponents])
  4197         ]
  3756         ]
  4198     ].
  3757     ].
  4199     ^ false
  3758     ^ false
  4200 !
  3759 !
  4201 
  3760 
  4202 hasOneSelectionOtherThanCanvas
  3761 hasOneSelectionOtherThanCanvas
  4203     "returns true in case that one selection exists other than the canvas
  3762     "returns true in case that one selection exists other than the canvas"
  4204     "
  3763 
  4205     ^ (selection size == 1 and:[selection first ~~ 1])
  3764     ^ selection size == 1 and:[selection first ~~ 1]
  4206 !
  3765 !
  4207 
  3766 
  4208 isCanvasSelected
  3767 isCanvasSelected
  4209     "returns true in case of a single selection and the
  3768     "returns true in case of a single selection and the
  4210      selection is the canvas (index 1)
  3769      selection is the canvas (index 1)"
  4211     "
  3770 
  4212     ^ (selection size == 1 and:[self isInSelection:1])
  3771     ^ selection size == 1 and:[self isInSelection:1]
  4213 ! !
  3772 ! !
  4214 
  3773 
  4215 !UIPainter::TreeView methodsFor:'seraching'!
  3774 !UIPainter::TreeView methodsFor:'searching'!
  4216 
  3775 
  4217 detectItemRespondsToView:aView
  3776 detectItemRespondsToView:aView
  4218     "detect the item responding to the view. The item of the view or the first
  3777     "detects the item responding to the view. The item of the view or the first
  4219      subview providing the item is returned. If no property is detected nil is
  3778      subview providing the item is returned. If no property is detected nil is
  4220      returned
  3779      returned"
  4221     "
  3780 
  4222     |view item|
  3781     |view item|
  4223 
  3782 
  4224     (view := aView) notNil ifTrue:[
  3783     (view := aView) notNil ifTrue:[
  4225         [(item := self itemOfView:view) isNil] whileTrue:[
  3784         [(item := self itemOfView:view) isNil] whileTrue:[
  4226             (view := view superView) isNil ifTrue:[^ listOfNodes at:1]
  3785             (view := view superView) isNil ifTrue:[^ listOfNodes at:1]
  4264     canvas pasteWithLayout.
  3823     canvas pasteWithLayout.
  4265 
  3824 
  4266 !
  3825 !
  4267 
  3826 
  4268 doStepOver:anIndex
  3827 doStepOver:anIndex
  4269     "move child 'anOffset' forward or backward in list of children
  3828     "moves child 'anOffset' forward or backward in list of children"
  4270     "
  3829 
  4271     |item idx size prnt spVw view canvas|
  3830     |item idx size prnt spVw view canvas|
  4272 
  3831 
  4273     (    (item := self selectedNode) isNil
  3832     (    (item := self selectedNode) isNil
  4274      or:[(prnt := item parent) isNil
  3833      or:[(prnt := item parent) isNil
  4275      or:[(size := prnt children size) < 2
  3834      or:[(size := prnt children size) < 2