UIPainter.st
changeset 109 0b53bd128667
parent 101 8d674e606a94
child 114 93cd25c62a68
equal deleted inserted replaced
108:9078a793fd8e 109:0b53bd128667
     1 "
       
     2  COPYRIGHT (c) 1995 by Claus Gittinger
       
     3 	      All Rights Reserved
       
     4 
       
     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
       
     7  inclusion of the above copyright notice.   This software may not
       
     8  be provided or otherwise made available to, or used by, any
       
     9  other person.  No title to or ownership of the software is
       
    10  hereby transferred.
       
    11 "
       
    12 
       
    13 ApplicationModel subclass:#UIPainter
     1 ApplicationModel subclass:#UIPainter
    14 	instanceVariableNames:'topView workView propertyView treeView elementMenu fileName
     2 	instanceVariableNames:'objectList currentView selectionPanel tabSelection lastSlice
    15 		specClass specSelector specSuperclass aspects'
     3 		specView layoutTool emptyView fileName specClass specSelector
       
     4 		specSuperclass aspects'
    16 	classVariableNames:''
     5 	classVariableNames:''
    17 	poolDictionaries:''
     6 	poolDictionaries:''
    18 	category:'Interface-UIPainter'
     7 	category:'Interface-UIPainter'
    19 !
     8 !
    20 
     9 
    21 HorizontalPanelView subclass:#ButtonPanel
       
    22 	instanceVariableNames:'receiver argumentToSelector'
       
    23 	classVariableNames:''
       
    24 	poolDictionaries:''
       
    25 	privateIn:UIPainter
       
    26 !
       
    27 
       
    28 !UIPainter class methodsFor:'documentation'!
    10 !UIPainter class methodsFor:'documentation'!
    29 
       
    30 copyright
       
    31 "
       
    32  COPYRIGHT (c) 1995 by Claus Gittinger
       
    33 	      All Rights Reserved
       
    34 
       
    35  This software is furnished under a license and may be used
       
    36  only in accordance with the terms of that license and with the
       
    37  inclusion of the above copyright notice.   This software may not
       
    38  be provided or otherwise made available to, or used by, any
       
    39  other person.  No title to or ownership of the software is
       
    40  hereby transferred.
       
    41 "
       
    42 !
       
    43 
    11 
    44 documentation
    12 documentation
    45 "
    13 "
    46     not yet finished, not yet published, not yet released.
    14     not yet finished, not yet published, not yet released.
    47 
    15 
    48     [start with:]
    16     [start with:]
    49         UIPainter open
    17         UIPainter open
    50 "
    18 "
       
    19 
       
    20 ! !
       
    21 
       
    22 !UIPainter class methodsFor:'instance creation'!
       
    23 
       
    24 listHolder:aListHolder
       
    25     |application|
       
    26 
       
    27     application := self new.
       
    28     application objectList:aListHolder.
       
    29   ^ application open
       
    30 !
       
    31 
       
    32 painter:aBuilderView
       
    33     |application|
       
    34 
       
    35     application := self new.
       
    36     application painter:aBuilderView.
       
    37   ^ application open
    51 ! !
    38 ! !
    52 
    39 
    53 !UIPainter class methodsFor:'ST-80 queries'!
    40 !UIPainter class methodsFor:'ST-80 queries'!
    54 
    41 
    55 preferenceFor:aSymbol
    42 preferenceFor:aSymbol
    56     ^ false
    43     ^ false
       
    44 
       
    45 
       
    46 ! !
       
    47 
       
    48 !UIPainter class methodsFor:'constants'!
       
    49 
       
    50 titleOfLayoutMenu
       
    51     ^ 'Dimension'
    57 ! !
    52 ! !
    58 
    53 
    59 !UIPainter class methodsFor:'interface specs'!
    54 !UIPainter class methodsFor:'interface specs'!
       
    55 
       
    56 menuSpec
       
    57     ^ #(#Menu #(
       
    58         #(#MenuItem
       
    59                 #'label:' 'file'
       
    60                 #'nameKey:' #file
       
    61                 #'submenu:'
       
    62                         #(#Menu #(
       
    63                                  #(#MenuItem
       
    64                                         #'label:' 'new'
       
    65                                         #'nameKey:' #removeAll
       
    66                                   )
       
    67                                  #(#MenuItem
       
    68                                         #'label:' 'from class ...'
       
    69                                         #'nameKey:' #doFromClass
       
    70                                   )
       
    71                                  #(#MenuItem
       
    72                                         #'label:' 'pick a view '
       
    73                                         #'nameKey:' #doPickAView
       
    74                                   )
       
    75                                  #(#MenuItem
       
    76                                         #'label:' 'load'
       
    77                                         #'nameKey:' #doOpen
       
    78                                   )
       
    79                                  #(#MenuItem
       
    80                                         #'label:' 'save'
       
    81                                         #'nameKey:' #doSave
       
    82                                   )
       
    83                                  #(#MenuItem
       
    84                                         #'label:' 'save as ...'
       
    85                                         #'nameKey:' #doSaveAs
       
    86                                   )
       
    87                                  #(#MenuItem
       
    88                                         #'label:' 'raise'
       
    89                                         #'nameKey:' #doRaise
       
    90                                   )
       
    91                                  #(#MenuItem
       
    92                                         #'label:' 'quit'
       
    93                                         #'nameKey:' #closeRequest
       
    94                                   )
       
    95                                  )
       
    96                                 #(3 3 1)
       
    97                                 nil
       
    98                        )
       
    99          )
       
   100         #(#MenuItem
       
   101                 #'label:' 'font'
       
   102                 #'nameKey:' #font
       
   103                 #'submenu:' 
       
   104                         #(#Menu #(
       
   105                                  #(#MenuItem
       
   106                                         #'label:' 'larger'
       
   107                                         #'nameKey:' #largerFont
       
   108                                   )
       
   109                                  #(#MenuItem
       
   110                                         #'label:' 'smaller'
       
   111                                         #'nameKey:' #smallerFont
       
   112                                   )
       
   113                                  #(#MenuItem
       
   114                                         #'label:' 'normal'
       
   115                                         #'nameKey:' #normalFont
       
   116                                   )
       
   117                                  #(#MenuItem
       
   118                                         #'label:' 'bold'
       
   119                                         #'nameKey:' #boldFont
       
   120                                   )
       
   121                                  #(#MenuItem
       
   122                                         #'label:' 'italic'
       
   123                                         #'nameKey:' #italicFont
       
   124                                   )
       
   125                                  #(#MenuItem
       
   126                                         #'label:' 'bold italic'
       
   127                                         #'nameKey:' #boldItalicFont
       
   128                                   )
       
   129                                  #(#MenuItem
       
   130                                         #'label:' 'font panel'
       
   131                                         #'nameKey:' #showFontPanel
       
   132                                  )
       
   133                                 )
       
   134                                 #(2 4)
       
   135                                 nil
       
   136                         )
       
   137          )
       
   138         #(#MenuItem
       
   139                 #'label:' 'special'
       
   140                 #'nameKey:' #special
       
   141                 #'submenu:' 
       
   142                         #(#Menu #(
       
   143                                 #(#MenuItem
       
   144                                         #'label:' 'group radioButtons'
       
   145                                         #'nameKey:' #groupRadioButtons
       
   146                                  ) 
       
   147                                 #(#MenuItem
       
   148                                         #'label:' 'group enterFields'
       
   149                                         #'nameKey:' #groupEnterFields
       
   150                                  )
       
   151                                 )
       
   152                                 nil
       
   153                                 nil
       
   154                         )
       
   155          )
       
   156         #(#MenuItem
       
   157                 #'label:' 'misc'
       
   158                 #'nameKey:' #misc
       
   159                 #'submenu:'
       
   160                         #(#Menu #(
       
   161                                 #(#MenuItem
       
   162                                         #'label:' 'grid'
       
   163                                         #'nameKey:' #grid
       
   164                                         #'submenu:'
       
   165                                                 #(#Menu #(
       
   166                                                         #(#MenuItem
       
   167                                                                 #'label:' '\c show'
       
   168                                                                 #'nameKey:' #gridShown
       
   169                                                          )
       
   170                                                         #(#MenuItem
       
   171                                                                 #'label:' '\c align'
       
   172                                                                 #'nameKey:' #gridAlign
       
   173                                                          )
       
   174                                                         )
       
   175                                                         nil
       
   176                                                         nil
       
   177                                                  )
       
   178                                  )
       
   179                                 #(#MenuItem
       
   180                                         #'label:' 'undo'
       
   181                                         #'nameKey:' #undo
       
   182                                         #'submenu:'
       
   183                                                 #(#Menu #(
       
   184                                                         #(#MenuItem
       
   185                                                                 #'label:' 'last'
       
   186                                                                 #'nameKey:' #undoLast
       
   187                                                          )
       
   188                                                         #(#MenuItem
       
   189                                                                 #'label:' 'menu'
       
   190                                                                 #'nameKey:' #openUndoMenu
       
   191                                                          )
       
   192                                                         #(#MenuItem
       
   193                                                                 #'label:' 'delete'
       
   194                                                                 #'nameKey:' #removeUndoHistory
       
   195                                                          )
       
   196                                                         )
       
   197                                                         #(2)
       
   198                                                         nil
       
   199                                                  )
       
   200                                   )
       
   201                                 )
       
   202                                 nil
       
   203                                 nil
       
   204                                )
       
   205          )
       
   206         #(#MenuItem
       
   207                 #'label:' 'code'
       
   208                 #'nameKey:' #code
       
   209                 #'submenu:'
       
   210                         #(#Menu #(
       
   211                                 #(#MenuItem
       
   212                                         #'label:' 'class & method'
       
   213                                         #'nameKey:' #defineClassAndSelector
       
   214                                  )
       
   215                                  #(#MenuItem
       
   216                                         #'label:' 'install spec'
       
   217                                         #'nameKey:' #doInstallSpec
       
   218                                   )
       
   219                                  #(#MenuItem
       
   220                                         #'label:' 'install aspects'
       
   221                                         #'nameKey:' #doInstallAspects
       
   222                                   )
       
   223                                  #(#MenuItem
       
   224                                         #'label:' 'windowSpec'
       
   225                                         #'nameKey:' #doWindowSpec
       
   226                                    )
       
   227                                 )
       
   228                                 #( 1 2 )
       
   229                                 nil
       
   230                           )
       
   231          )
       
   232         #(#MenuItem
       
   233                 #'label:' 'test'
       
   234                 #'nameKey:' #test
       
   235                 #'submenu:'
       
   236                         #(#Menu #(
       
   237                                 #(#MenuItem
       
   238                                         #'label:' '\c test mode'
       
   239                                         #'nameKey:' #testMode
       
   240                                  )
       
   241                                 )
       
   242                                 nil
       
   243                                 nil
       
   244                           )
       
   245          )
       
   246         )
       
   247         nil
       
   248         nil
       
   249       )
       
   250 
       
   251 !
    60 
   252 
    61 nameAndSelectorSpec
   253 nameAndSelectorSpec
    62     "this window spec was automatically generated by the ST/X UIPainter"
   254     "this window spec was automatically generated by the ST/X UIPainter"
    63 
   255 
    64     "do not manually edit this - the painter/builder may not be able to
   256     "do not manually edit this - the painter/builder may not be able to
    70     "
   262     "
    71 
   263 
    72     <resource: #canvas>
   264     <resource: #canvas>
    73 
   265 
    74     ^
   266     ^
    75      
   267 
    76        #(#FullSpec
   268        #(#FullSpec
    77           #'window:' 
   269           #'window:' 
    78            #(#WindowSpec
   270            #(#WindowSpec
    79               #'name:' 'uIPainterView'
   271               #'name:' 'uIPainterView'
    80               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   272               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   194                 )
   386                 )
   195               )
   387               )
   196           )
   388           )
   197       )
   389       )
   198 
   390 
   199     "Modified: 3.4.1997 / 20:14:32 / cg"
   391 !
   200 ! !
   392 
   201 
   393 windowSpec
   202 !UIPainter methodsFor:'BuilderView interface'!
   394     "this window spec was automatically generated by the ST/X UIPainter"
   203 
   395 
   204 update:what
   396     "do not manually edit this - the painter/builder may not be able to
   205 
   397      handle the specification if its corrupted."
   206     elementMenu deselect.
   398 
   207     treeView     builderViewChanged:what.
   399     "
   208     propertyView builderViewChanged:what.
   400      UIPainter new openOnClass:UIPainter andSelector:#windowSpec
       
   401      UIPainter new openInterface:#windowSpec
       
   402     "
       
   403     "UIPainter open"
       
   404 
       
   405     <resource: #canvas>
       
   406 
       
   407     ^
       
   408      
       
   409        #(#FullSpec
       
   410           #'window:' 
       
   411            #(#WindowSpec
       
   412               #'name:' 'uIPainterView'
       
   413               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   414               #'label:' 'Tree-View'
       
   415               #'bounds:' #(#Rectangle 0 0 460 390)
       
   416           )
       
   417           #'component:' 
       
   418            #(#SpecCollection
       
   419               #'collection:' 
       
   420                #(
       
   421                  #(#ViewSpec
       
   422                     #'name:' 'view1'
       
   423                     #'layout:' #(#LayoutFrame 0 0.0 29 0.0 0 1.0 0 1.0)
       
   424                     #'component:' 
       
   425                      #(#SpecCollection
       
   426                         #'collection:' 
       
   427                          #(
       
   428                            #(#SequenceViewSpec
       
   429                               #'name:' 'selectionInList'
       
   430                               #'layout:' #(#LayoutFrame 0 0.0 40 0.0 0 0.35 0 1.0)
       
   431                               #'enableChannel:' #canModify
       
   432                               #'menu:' #objectListMenu
       
   433                               #'model:' #objectList
       
   434                               #'callbacksSpec:' 
       
   435                                #(#UIEventCallbackSubSpec
       
   436                                   #'doubleClickSelector:' #doubleClick
       
   437                               )
       
   438                               #'hasHorizontalScrollBar:' true
       
   439                               #'hasVerticalScrollBar:' true
       
   440                               #'miniScrollerHorizontal:' false
       
   441                               #'miniScrollerVertical:' false
       
   442                               #'isMultiSelect:' true
       
   443                           )
       
   444                            #(#PanelViewSpec
       
   445                               #'name:' 'panelViewButtons'
       
   446                               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 40 0.0)
       
   447                               #'component:' 
       
   448                                #(#SpecCollection
       
   449                                   #'collection:' 
       
   450                                    #(
       
   451                                      #(#HorizontalPanelViewSpec
       
   452                                         #'name:' 'hrzPanelViewAlignH'
       
   453                                         #'component:' 
       
   454                                          #(#SpecCollection
       
   455                                             #'collection:' 
       
   456                                              #(
       
   457                                                #(#ActionButtonSpec
       
   458                                                   #'name:' 'alignLeft'
       
   459                                                   #'label:' ''
       
   460                                                   #'translateLabel:' true
       
   461                                                   #'labelChannel:' #'LABELb_alignL.xbm'
       
   462                                                   #'defaultable:' true
       
   463                                                   #'model:' #alignSelectionLeft
       
   464                                                   #'hasCharacterOrientedLabel:' false
       
   465                                                   #'isTriggerOnDown:' false
       
   466                                                   #'enableChannel:' #canModify
       
   467                                                   #'autoRepeat:' false
       
   468                                                   #'extent:' #(#Point 24 24)
       
   469                                               )
       
   470                                                #(#ActionButtonSpec
       
   471                                                   #'name:' 'alignRight'
       
   472                                                   #'label:' ''
       
   473                                                   #'translateLabel:' true
       
   474                                                   #'labelChannel:' #'LABELb_alignR.xbm'
       
   475                                                   #'defaultable:' true
       
   476                                                   #'model:' #alignSelectionRight
       
   477                                                   #'hasCharacterOrientedLabel:' false
       
   478                                                   #'isTriggerOnDown:' false
       
   479                                                   #'enableChannel:' #canModify
       
   480                                                   #'autoRepeat:' false
       
   481                                                   #'extent:' #(#Point 24 24)
       
   482                                               )
       
   483                                                #(#ActionButtonSpec
       
   484                                                   #'name:' 'alignHorizontal'
       
   485                                                   #'label:' ''
       
   486                                                   #'translateLabel:' true
       
   487                                                   #'labelChannel:' #'LABELb_alignLR.xbm'
       
   488                                                   #'defaultable:' true
       
   489                                                   #'model:' #alignSelectionLeftAndRight
       
   490                                                   #'hasCharacterOrientedLabel:' false
       
   491                                                   #'isTriggerOnDown:' false
       
   492                                                   #'enableChannel:' #canModify
       
   493                                                   #'autoRepeat:' false
       
   494                                                   #'extent:' #(#Point 24 24)
       
   495                                               )
       
   496                                             )
       
   497                                         )
       
   498                                         #'level:' 0
       
   499                                         #'horizontalLayout:' #center
       
   500                                         #'verticalLayout:' #center
       
   501                                         #'horizontalSpace:' 3
       
   502                                         #'verticalSpace:' 3
       
   503                                         #'extent:' #(#Point 84 30)
       
   504                                     )
       
   505                                      #(#HorizontalPanelViewSpec
       
   506                                         #'name:' 'hrzPanelViewAlignV'
       
   507                                         #'component:' 
       
   508                                          #(#SpecCollection
       
   509                                             #'collection:' 
       
   510                                              #(
       
   511                                                #(#ActionButtonSpec
       
   512                                                   #'name:' 'alignBottom'
       
   513                                                   #'label:' ''
       
   514                                                   #'translateLabel:' true
       
   515                                                   #'labelChannel:' #'LABELb_alignB.xbm'
       
   516                                                   #'defaultable:' true
       
   517                                                   #'model:' #alignSelectionBottom
       
   518                                                   #'isTriggerOnDown:' false
       
   519                                                   #'enableChannel:' #canModify
       
   520                                                   #'autoRepeat:' false
       
   521                                                   #'extent:' #(#Point 24 24)
       
   522                                               )
       
   523                                                #(#ActionButtonSpec
       
   524                                                   #'name:' 'alignTop'
       
   525                                                   #'label:' ''
       
   526                                                   #'translateLabel:' true
       
   527                                                   #'labelChannel:' #'LABELb_alignT.xbm'
       
   528                                                   #'defaultable:' true
       
   529                                                   #'model:' #alignSelectionTop
       
   530                                                   #'isTriggerOnDown:' false
       
   531                                                   #'enableChannel:' #canModify
       
   532                                                   #'autoRepeat:' false
       
   533                                                   #'extent:' #(#Point 24 24)
       
   534                                               )
       
   535                                                #(#ActionButtonSpec
       
   536                                                   #'name:' 'alignVertical'
       
   537                                                   #'label:' ''
       
   538                                                   #'translateLabel:' true
       
   539                                                   #'labelChannel:' #'LABELb_alignTB.xbm'
       
   540                                                   #'defaultable:' true
       
   541                                                   #'model:' #alignSelectionTopAndBottom
       
   542                                                   #'isTriggerOnDown:' false
       
   543                                                   #'enableChannel:' #canModify
       
   544                                                   #'autoRepeat:' false
       
   545                                                   #'extent:' #(#Point 24 24)
       
   546                                               )
       
   547                                             )
       
   548                                         )
       
   549                                         #'level:' 0
       
   550                                         #'horizontalLayout:' #center
       
   551                                         #'verticalLayout:' #center
       
   552                                         #'horizontalSpace:' 3
       
   553                                         #'verticalSpace:' 3
       
   554                                         #'extent:' #(#Point 84 30)
       
   555                                     )
       
   556                                      #(#HorizontalPanelViewSpec
       
   557                                         #'name:' 'hrzPanelViewCenter'
       
   558                                         #'component:' 
       
   559                                          #(#SpecCollection
       
   560                                             #'collection:' 
       
   561                                              #(
       
   562                                                #(#ActionButtonSpec
       
   563                                                   #'name:' 'centerHorizontal'
       
   564                                                   #'label:' ''
       
   565                                                   #'translateLabel:' true
       
   566                                                   #'labelChannel:' #'LABELb_alignCH.xbm'
       
   567                                                   #'defaultable:' true
       
   568                                                   #'model:' #alignSelectionCenterHor
       
   569                                                   #'isTriggerOnDown:' false
       
   570                                                   #'enableChannel:' #canModify
       
   571                                                   #'autoRepeat:' false
       
   572                                                   #'extent:' #(#Point 25 24)
       
   573                                               )
       
   574                                                #(#ActionButtonSpec
       
   575                                                   #'name:' 'centerVertical'
       
   576                                                   #'label:' ''
       
   577                                                   #'translateLabel:' true
       
   578                                                   #'labelChannel:' #'LABELb_alignCV.xbm'
       
   579                                                   #'defaultable:' true
       
   580                                                   #'model:' #alignSelectionCenterVer
       
   581                                                   #'isTriggerOnDown:' false
       
   582                                                   #'enableChannel:' #canModify
       
   583                                                   #'autoRepeat:' false
       
   584                                                   #'extent:' #(#Point 25 24)
       
   585                                               )
       
   586                                             )
       
   587                                         )
       
   588                                         #'level:' 0
       
   589                                         #'horizontalLayout:' #center
       
   590                                         #'verticalLayout:' #center
       
   591                                         #'horizontalSpace:' 3
       
   592                                         #'verticalSpace:' 3
       
   593                                         #'extent:' #(#Point 59 30)
       
   594                                     )
       
   595                                      #(#HorizontalPanelViewSpec
       
   596                                         #'name:' 'hrzPanelViewMove'
       
   597                                         #'component:' 
       
   598                                          #(#SpecCollection
       
   599                                             #'collection:' 
       
   600                                              #(
       
   601                                                #(#ActionButtonSpec
       
   602                                                   #'name:' 'moveLeft'
       
   603                                                   #'label:' ''
       
   604                                                   #'translateLabel:' true
       
   605                                                   #'labelChannel:' #'LABELb_moveLeft.xbm'
       
   606                                                   #'defaultable:' true
       
   607                                                   #'model:' #moveSelectionLeft
       
   608                                                   #'isTriggerOnDown:' true
       
   609                                                   #'enableChannel:' #canModify
       
   610                                                   #'autoRepeat:' true
       
   611                                                   #'extent:' #(#Point 26 24)
       
   612                                               )
       
   613                                                #(#ActionButtonSpec
       
   614                                                   #'name:' 'moveRight'
       
   615                                                   #'label:' ''
       
   616                                                   #'translateLabel:' true
       
   617                                                   #'labelChannel:' #'LABELb_moveRight.xbm'
       
   618                                                   #'defaultable:' true
       
   619                                                   #'model:' #moveSelectionRight
       
   620                                                   #'isTriggerOnDown:' true
       
   621                                                   #'enableChannel:' #canModify
       
   622                                                   #'autoRepeat:' true
       
   623                                                   #'extent:' #(#Point 26 24)
       
   624                                               )
       
   625                                                #(#ActionButtonSpec
       
   626                                                   #'name:' 'moveUp'
       
   627                                                   #'label:' ''
       
   628                                                   #'translateLabel:' true
       
   629                                                   #'labelChannel:' #'LABELb_moveUp.xbm'
       
   630                                                   #'defaultable:' true
       
   631                                                   #'model:' #moveSelectionUp
       
   632                                                   #'isTriggerOnDown:' true
       
   633                                                   #'enableChannel:' #canModify
       
   634                                                   #'autoRepeat:' true
       
   635                                                   #'extent:' #(#Point 26 24)
       
   636                                               )
       
   637                                                #(#ActionButtonSpec
       
   638                                                   #'name:' 'moveDown'
       
   639                                                   #'label:' ''
       
   640                                                   #'translateLabel:' true
       
   641                                                   #'labelChannel:' #'LABELb_moveDown.xbm'
       
   642                                                   #'defaultable:' true
       
   643                                                   #'model:' #moveSelectionDown
       
   644                                                   #'isTriggerOnDown:' true
       
   645                                                   #'enableChannel:' #canModify
       
   646                                                   #'autoRepeat:' true
       
   647                                                   #'extent:' #(#Point 26 24)
       
   648                                               )
       
   649                                             )
       
   650                                         )
       
   651                                         #'level:' 0
       
   652                                         #'horizontalLayout:' #center
       
   653                                         #'verticalLayout:' #center
       
   654                                         #'horizontalSpace:' 3
       
   655                                         #'verticalSpace:' 3
       
   656                                         #'extent:' #(#Point 119 30)
       
   657                                     )
       
   658                                   )
       
   659                               )
       
   660                               #'level:' 1
       
   661                               #'horizontalLayout:' #fitSpace
       
   662                               #'verticalLayout:' #fitSpace
       
   663                               #'horizontalSpace:' 4
       
   664                               #'verticalSpace:' 4
       
   665                           )
       
   666                            #(#NoteBookViewSpec
       
   667                               #'name:' 'propertyView'
       
   668                               #'layout:' #(#LayoutFrame 0 0.35 40 0.0 0 1.0 -30 1.0)
       
   669                               #'model:' #tabModel
       
   670                               #'menu:' #tabList
       
   671                               #'tabWidget:' #Window
       
   672                               #'direction:' #top
       
   673                               #'useIndex:' false
       
   674                               #'fitLastRow:' true
       
   675                               #'moveSelectedRow:' true
       
   676                               #'enableChannel:' #canModify
       
   677                               #'level:' 0
       
   678                               #'canvas:' #noteBookView
       
   679                           )
       
   680                            #(#HorizontalPanelViewSpec
       
   681                               #'name:' 'hrzPanelViewOk'
       
   682                               #'layout:' #(#LayoutFrame 0 0.35 -30 1.0 0 1.0 0 1.0)
       
   683                               #'component:' 
       
   684                                #(#SpecCollection
       
   685                                   #'collection:' 
       
   686                                    #(
       
   687                                      #(#ActionButtonSpec
       
   688                                         #'name:' 'cancelButton'
       
   689                                         #'label:' 'cancel'
       
   690                                         #'model:' #cancel
       
   691                                         #'isTriggerOnDown:' false
       
   692                                         #'enableChannel:' #modifiedChannel
       
   693                                         #'autoRepeat:' false
       
   694                                         #'extent:' #(#Point 145 24)
       
   695                                     )
       
   696                                      #(#ActionButtonSpec
       
   697                                         #'name:' 'acceptButton'
       
   698                                         #'label:' 'ok'
       
   699                                         #'model:' #accept
       
   700                                         #'isTriggerOnDown:' false
       
   701                                         #'enableChannel:' #modifiedChannel
       
   702                                         #'autoRepeat:' false
       
   703                                         #'extent:' #(#Point 145 24)
       
   704                                     )
       
   705                                   )
       
   706                               )
       
   707                               #'level:' 0
       
   708                               #'horizontalLayout:' #fitSpace
       
   709                               #'verticalLayout:' #fitSpace
       
   710                               #'horizontalSpace:' 3
       
   711                               #'verticalSpace:' 3
       
   712                           )
       
   713                         )
       
   714                     )
       
   715                 )
       
   716                  #(#MenuPanelSpec
       
   717                     #'name:' 'menuBar1'
       
   718                     #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 29 0)
       
   719                     #'menu:' #pullDownMenu
       
   720                 )
       
   721               )
       
   722           )
       
   723       )
       
   724 ! !
       
   725 
       
   726 !UIPainter methodsFor:'actions'!
       
   727 
       
   728 accept
       
   729     "automatically generated by UIPainter ..."
       
   730     |layout|
       
   731 
       
   732     currentView notNil ifTrue:[
       
   733         tabSelection = 'Dimension' ifTrue:[
       
   734             (layout := layoutTool layout) notNil ifTrue:[
       
   735                 layoutTool layoutType == #Extent ifTrue:[
       
   736                     self painter setExtent:layout
       
   737                 ] ifFalse:[
       
   738                     self painter setDimension:layout
       
   739                 ]
       
   740             ]
       
   741         ] ifFalse:[
       
   742             self painter updateFromSpec:(specView specEdited).
       
   743         ].
       
   744         self cancel
       
   745     ]
       
   746 
       
   747 !
       
   748 
       
   749 cancel
       
   750     "cancel all changes and read back attributes from current view
       
   751     "
       
   752     specView specEdited:(self painter specFor:currentView).
       
   753     layoutTool forView:currentView.
       
   754     self modifiedChannel value:false.
   209 ! !
   755 ! !
   210 
   756 
   211 !UIPainter methodsFor:'aspects'!
   757 !UIPainter methodsFor:'aspects'!
   212 
   758 
       
   759 canModify
       
   760     "automatically generated by UIPainter ..."
       
   761 
       
   762     |holder|
       
   763 
       
   764     (holder := builder bindingAt:#canModify) isNil ifTrue:[
       
   765         holder := AspectAdaptor new subject:(self painter); forAspect:#canModify.
       
   766         builder aspectAt:#canModify put:holder.
       
   767     ].
       
   768     ^ holder
       
   769 
       
   770 
       
   771 
       
   772 !
       
   773 
       
   774 doubleClick
       
   775     objectList selectGroup
       
   776 !
       
   777 
       
   778 modifiedChannel
       
   779 
       
   780     |holder|
       
   781 
       
   782     (holder := builder bindingAt:#modifiedChannel) isNil ifTrue:[
       
   783         builder aspectAt:#modifiedChannel put:(holder :=  false asValue).
       
   784     ].
       
   785     ^ holder
       
   786 !
       
   787 
       
   788 noteBookView
       
   789     "automatically generated by UIPainter ..."
       
   790 
       
   791     |noteBook channel|
       
   792 
       
   793     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
       
   794         noteBook   := View origin:0.0 @0.0 corner:1.0@1.0.
       
   795         layoutTool := UIPropertyView for:#Dimension     in:noteBook.
       
   796         specView   := UIPropertyView for:#Specification in:noteBook.
       
   797         emptyView  := View origin:0.0 @0.0 corner:1.0@1.0 in:noteBook.
       
   798 
       
   799         channel := self modifiedChannel.
       
   800         layoutTool modifiedHolder:channel.
       
   801         specView   modifiedHolder:channel.
       
   802         specView   viewBackground:(layoutTool viewBackground).
       
   803         emptyView  viewBackground:(layoutTool viewBackground).
       
   804         builder aspectAt:#noteBookView put:noteBook.
       
   805     ].
       
   806     ^ noteBook
       
   807 !
       
   808 
       
   809 objectList
       
   810     ^ objectList
       
   811 !
       
   812 
       
   813 objectListMenu
       
   814     "returns a block which returns the menu
       
   815     "
       
   816     ^ [self painter menu]
       
   817 
       
   818 
       
   819 
       
   820 !
       
   821 
       
   822 pullDownMenu
       
   823     |menu painter|
       
   824 
       
   825     menu := Menu new.
       
   826     menu fromLiteralArrayEncoding:(self class menuSpec).
       
   827     menu receiver:self.
       
   828   ^ menu
       
   829 !
       
   830 
       
   831 tabList
       
   832     "automatically generated by UIPainter ..."
       
   833 
       
   834     |holder|
       
   835 
       
   836     (holder := builder bindingAt:#tabList) isNil ifTrue:[
       
   837         builder aspectAt:#tabList put:(holder :=  ValueHolder new).
       
   838     ].
       
   839     ^ holder
       
   840 !
       
   841 
       
   842 tabModel
       
   843     "automatically generated by UIPainter ..."
       
   844 
       
   845     |holder|
       
   846 
       
   847     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
       
   848         lastSlice := 'Basics'.
       
   849         holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
       
   850         builder aspectAt:#tabModel put:holder.
       
   851     ].
       
   852     ^ holder
       
   853 ! !
       
   854 
       
   855 !UIPainter methodsFor:'binding access'!
       
   856 
   213 aspectFor:aKey
   857 aspectFor:aKey
   214     ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
   858     "check wether aspect is assigned to a label icon
   215 
   859     "
   216 ! !
   860     (aKey startsWith:'LABEL') ifFalse:[
   217 
   861         ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
   218 !UIPainter methodsFor:'filein & fileout'!
   862     ].
       
   863   ^ Image fromFile:(aKey copyFrom:(('LABEL' size) + 1))
       
   864 ! !
       
   865 
       
   866 !UIPainter methodsFor:'change & update'!
       
   867 
       
   868 update:something with:aParameter from:someObject
       
   869 
       
   870     (someObject == objectList and:[something ~~ #list]) ifTrue:[
       
   871         something ~~ #layout ifTrue:[
       
   872             self objectListChanged
       
   873         ] ifFalse:[
       
   874             (self modifiedChannel value) ifFalse:[
       
   875                 layoutTool forView:currentView
       
   876             ]
       
   877         ]
       
   878     ]
       
   879 ! !
       
   880 
       
   881 !UIPainter methodsFor:'event handling'!
       
   882 
       
   883 doesNotUnderstand:aMessage
       
   884    |painter|
       
   885 
       
   886    painter := self painter.
       
   887 
       
   888    (painter respondsTo:(aMessage selector)) ifTrue:[
       
   889         ^ aMessage sendTo:painter
       
   890    ].
       
   891    self error
       
   892 
       
   893 !
       
   894 
       
   895 objectListChanged
       
   896     "something changed in the painter view
       
   897     "
       
   898     |setSel slices list spec props|
       
   899 
       
   900     props := objectList selectedProperty.
       
   901     tabSelection := nil.
       
   902 
       
   903     props isNil ifFalse:[
       
   904         currentView := props view.
       
   905         layoutTool forView:currentView.
       
   906 
       
   907         spec   := props spec copy.
       
   908         slices := spec class slices.
       
   909         list   := slices collect:[:slice| slice first asString ].
       
   910         list add:'Dimension'.
       
   911         (self tabList) value:list.
       
   912 
       
   913         (list findFirst:[:aName| aName = lastSlice]) ~~ 0 ifTrue:[
       
   914             setSel := lastSlice
       
   915         ]
       
   916     ].
       
   917 
       
   918     specView specEdited:spec.
       
   919     self tabModel value:setSel.
       
   920 ! !
       
   921 
       
   922 !UIPainter methodsFor:'file access'!
   219 
   923 
   220 openFile:aFileName
   924 openFile:aFileName
   221     |aStream |
   925     |aStream |
   222 
   926 
   223     aStream := FileStream readonlyFileNamed:aFileName.
   927     aStream := FileStream readonlyFileNamed:aFileName.
   224 
   928 
   225     aStream notNil ifTrue:[
   929     aStream notNil ifTrue:[
   226         workView fileInContentsFrom:aStream.
   930         self painter fileInContentsFrom:aStream.
   227         aStream close.
   931         aStream close.
   228         fileName := aFileName
   932         fileName := aFileName
   229     ]
   933     ]
   230 
   934 
       
   935 
   231 !
   936 !
   232 
   937 
   233 saveAs:aFileName
   938 saveAs:aFileName
   234     |aStream|
   939     |aStream|
   235 
   940 
   236     aStream := FileStream newFileNamed:aFileName.
   941     aStream := FileStream newFileNamed:aFileName.
   237 
   942 
   238     aStream notNil ifTrue:[
   943     aStream notNil ifTrue:[
   239         workView storeContentsOn:aStream.
   944         self painter storeContentsOn:aStream.
   240         aStream close.
   945         aStream close.
   241         fileName := aFileName
   946         fileName := aFileName
   242     ].
   947     ].
   243 
   948 
   244 ! !
   949 ! !
   245 
   950 
   246 !UIPainter methodsFor:'help'!
   951 !UIPainter methodsFor:'private'!
   247 
   952 
   248 helpTextFor:aComponent
   953 painter
   249     |sel|
   954     ^ objectList painter
   250 
   955 !
   251     (aComponent isKindOf:Button) ifTrue:[
   956 
   252 	(sel := aComponent changeMessage) notNil ifTrue:[
   957 workView
   253 	    "/ take the buttons change symbol as resource-key
   958     ^ self painter
   254 	    ^ resources string:(sel asString)
   959 ! !
   255 	]
   960 
   256     ].
   961 !UIPainter methodsFor:'selection'!
   257     ^ nil
   962 
   258 
   963 tabSelection
   259     "Modified: 31.8.1995 / 20:49:58 / claus"
   964     ^ tabSelection
   260 ! !
   965 !
   261 
   966 
   262 !UIPainter methodsFor:'initialization'!
   967 tabSelection:something
   263 
   968     |specEdited slices spec idx|
   264 createCanvas 
   969 
       
   970     (tabSelection := something) notNil ifTrue:[
       
   971         (specEdited := specView specEdited) notNil ifTrue:[
       
   972             slices    := specEdited class slices.
       
   973             lastSlice := tabSelection.
       
   974 
       
   975             idx:= slices findFirst:[:aSlice| aSlice first = tabSelection ].
       
   976             idx == 0 ifTrue:[
       
   977                 layoutTool forView:currentView.
       
   978               ^ layoutTool raise.
       
   979             ].
       
   980             spec := specEdited class perform:((slices at:idx) last).
       
   981         ]
       
   982     ].
       
   983     specEdited isNil ifTrue:[
       
   984         emptyView raise
       
   985     ] ifFalse:[
       
   986         specView raise.
       
   987         specView buildFromSpec:spec
       
   988     ]
       
   989 ! !
       
   990 
       
   991 !UIPainter methodsFor:'startup / release'!
       
   992 
       
   993 closeRequest
       
   994     "close all windows open by builder
       
   995     "
       
   996     objectList removeDependent:self.
       
   997     objectList painter release.
       
   998     objectList := nil.
       
   999 
       
  1000     selectionPanel notNil ifTrue:[
       
  1001         selectionPanel closeRequest
       
  1002     ].
       
  1003     super closeRequest.
       
  1004 
       
  1005 !
       
  1006 
       
  1007 closeRequestFor:aTopView
       
  1008     "handle a close request for a specific view
       
  1009     "
   265     |topView|
  1010     |topView|
   266 
  1011 
   267     super initialize.
  1012     topView := self window.
   268 
  1013 
   269     topView := StandardSystemView new.
  1014     topView == aTopView ifTrue:[
   270     topView label:'unnamed'.
  1015         super closeRequestFor:aTopView
   271     topView extent:300@300.
  1016     ] ifFalse:[
   272     topView application:self.
  1017         aTopView == selectionPanel window ifTrue:[
   273 
  1018             aTopView application:nil.
   274     workView := UIPainterView in:topView.
  1019             aTopView terminate.
   275     workView layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  1020             selectionPanel := nil.
   276 
  1021         ] ifFalse:[
   277     ^ workView.
  1022             topView raise.
   278 
  1023             topView device beep
   279     "Builder new createCanvas open"
  1024         ]
   280 !
  1025     ].
   281 
  1026 !
   282 initChannels
  1027 
   283     |cls|
  1028 openInterface
       
  1029     "open interfaces
       
  1030     "
       
  1031     |painterView painter cls topView|
   284 
  1032 
   285     aspects := IdentityDictionary new.
  1033     aspects := IdentityDictionary new.
   286 
  1034 
   287     aspects at:#classNameChannel put:(
  1035     aspects at:#classNameChannel put:(
   288         (specClass notNil ifTrue:[specClass]
  1036         (specClass notNil ifTrue:[specClass]
   301     ).
  1049     ).
   302     aspects at:#methodNameChannel put:(
  1050     aspects at:#methodNameChannel put:(
   303         (specSelector notNil ifTrue:[specSelector]
  1051         (specSelector notNil ifTrue:[specSelector]
   304                             ifFalse:[#windowSpec]) asValue
  1052                             ifFalse:[#windowSpec]) asValue
   305     ).
  1053     ).
   306 !
  1054 
   307 
  1055     painterView := StandardSystemView new.
   308 initPullDownMenu:aMenu
  1056     painterView label:'unnamed'.
   309     aMenu labels:(resources  array:#(
  1057     painterView extent:300@300.
   310                                     'file'
  1058 
   311                                     'font'
  1059     painter := UIPainterView in:painterView.
   312                                     'type'
  1060     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
   313                                     'align'
  1061 
   314                                     'dimension'
  1062     objectList := painter listHolder.
   315                                     'special'
  1063     objectList addDependent:self.
   316                                     'misc'
  1064 
   317                                     'code'
  1065     super openInterface.
   318                                     'test'
  1066 
   319                                  )).
  1067     topView := self window.
   320 
       
   321     aMenu selectors:#(#file
       
   322                      #font
       
   323                      #type
       
   324                      #align 
       
   325                      #dimension 
       
   326                      #special
       
   327                      #misc
       
   328                      #code
       
   329                      #test
       
   330                     ).
       
   331 
       
   332     aMenu at:#file 
       
   333             putLabels:(resources  array:
       
   334                       #('new'
       
   335                         'from class ...' 
       
   336                         'pick a view ' 
       
   337                         '-'
       
   338                         'load'
       
   339                         'save' 
       
   340                         'save as ...' 
       
   341                         '-'
       
   342                         'install spec' 
       
   343                         'install aspects' 
       
   344                         '-'
       
   345 "/                        'source' 
       
   346                         'windowSpec' 
       
   347                         'inspect me'
       
   348                         'raise'
       
   349                         '-'
       
   350                         'print'
       
   351                         '-'
       
   352                         'quit'
       
   353                        ))
       
   354             selectors:#(doNew 
       
   355                         doFromClass
       
   356                         doPickAView
       
   357                         nil
       
   358                         doOpen
       
   359                         doSave 
       
   360                         doSaveAs
       
   361                         nil 
       
   362                         doInstallSpec 
       
   363                         doInstallAspects 
       
   364                         nil 
       
   365 "/                        doSource 
       
   366                         doWindowSpec 
       
   367                         inspect
       
   368                         doRaise
       
   369                         nil 
       
   370                         doPrint
       
   371                         nil 
       
   372                         doFinish
       
   373                        )
       
   374              receiver:self.
       
   375 
       
   376     aMenu at:#font putMenu:(workView subMenuFont menuView).
       
   377 
       
   378     aMenu at:#type 
       
   379             putLabels:(resources  array:#(
       
   380                         'basic widgets' 
       
   381                         'layout'
       
   382                         'text'
       
   383                         'interactors'
       
   384                         'modal'
       
   385                         'other'
       
   386                         '-'
       
   387                         'all'
       
   388                        ) )
       
   389             selectors:#(showBasicWidgets 
       
   390                         showLayoutWidgets
       
   391                         showTextWidgets
       
   392                         showInteractorWidgets
       
   393                         showModalWidgets
       
   394                         showOtherWidgets
       
   395                         nil
       
   396                         showAllWidgets
       
   397                        )
       
   398              receiver:self.
       
   399 
       
   400     aMenu at:#align     putMenu:(workView subMenuAlign menuView).
       
   401     aMenu at:#dimension putMenu:(workView subMenuDimension menuView).
       
   402 
       
   403     aMenu at:#special 
       
   404             putLabels:(resources  array:#(
       
   405                         'group radioButtons' 
       
   406                         'group enterFields'
       
   407                        ) )
       
   408             selectors:#(
       
   409                         groupRadioButtons 
       
   410                         groupEnterFields
       
   411                        )
       
   412              receiver:workView.
       
   413 
       
   414     aMenu at:#code 
       
   415             putLabels:(resources  array:#(
       
   416                         'class & method' 
       
   417                        ) )
       
   418             selectors:#(
       
   419                         defineClassAndSelector
       
   420                        )
       
   421              receiver:self.
       
   422 
       
   423     aMenu at:#misc putMenu:(self menuMisc).
       
   424 
       
   425     aMenu at:#test 
       
   426             putLabels:(resources array:#(
       
   427                         '\c test mode' 
       
   428                        ) )
       
   429             selectors:#(doToggleTest 
       
   430                        )
       
   431              receiver:self.
       
   432 
       
   433      (aMenu menuAt:#test) checkToggleAt:#doToggleTest put:(workView testMode).
       
   434 !
       
   435 
       
   436 openInterface 
       
   437     |inset panel menu|
       
   438 
       
   439     self  initChannels.
       
   440     workView := self createCanvas.
       
   441 
       
   442     topView := StandardSystemView new.
       
   443     topView label:'Interface Builder'.
  1068     topView label:'Interface Builder'.
   444     topView icon:(Image fromFile:'bitmaps/Builder.xbm' resolution:100).
  1069     topView icon:(Image fromFile:'bitmaps/Builder.xbm' resolution:100).
   445     topView extent:(600 @ 400).
  1070 
   446 
  1071     painterView openInGroup:(topView windowGroup).
   447     menu  := PullDownMenu in:topView.
  1072 
   448     panel := ButtonPanel  in:topView.
  1073     topView beMaster.
   449     inset := menu preferredExtent y + panel preferredExtent y.
  1074     painterView beSlave.
   450 
  1075     painterView application:self.
   451     panel origin:0.0@(menu preferredExtent y) corner:1.0@inset  .
  1076     painterView open.
   452     panel receiver:workView.
  1077     selectionPanel := UISelectionPanel open.
   453 
  1078     selectionPanel window beSlave.
   454     elementMenu := HVScrollableView for:SelectionInListView miniScrollerH:true in:topView.
  1079     selectionPanel window application:self.
   455     elementMenu origin:0.0@0.0 corner:0.3 @ 1.0.
       
   456     elementMenu topInset:inset  .
       
   457     elementMenu := elementMenu scrolledView.
       
   458 
       
   459     elementMenu action:[:selection |
       
   460         workView testMode ifTrue:[
       
   461             elementMenu deselect
       
   462         ] ifFalse:[
       
   463             selection notNil ifTrue:[
       
   464                 workView createWidgetWithClass:
       
   465                         (Smalltalk at:(elementMenu selectionValue asSymbol))
       
   466             ]
       
   467         ]
       
   468     ].
       
   469 
       
   470     treeView := HVScrollableView for:UIPainterTreeView miniScrollerH:true in:topView.
       
   471     treeView origin:0.3 @ 0.0 corner:0.6@1.0.
       
   472     treeView topInset:inset  .
       
   473     treeView := treeView scrolledView.
       
   474     treeView builderView:workView.
       
   475 
       
   476     propertyView  := View origin:(0.6 @ 0.0) corner:1.0@1.0 in:topView.
       
   477     propertyView  topInset:inset  .
       
   478     propertyView := UIPropertyView in:propertyView builder:workView.
       
   479 
       
   480     workView addDependent:self.
       
   481     self initPullDownMenu:menu.
       
   482     topView application:self.   
       
   483     builder window:topView.
       
   484     topView  beMaster.
       
   485     workView topView beSlave.
       
   486     topView  open.
       
   487     workView topView openInGroup:(topView windowGroup).
       
   488 
       
   489 !
  1080 !
   490 
  1081 
   491 openNewWindowCanvas
  1082 openNewWindowCanvas
       
  1083     "open new
       
  1084     "
   492     self open.
  1085     self open.
   493 
  1086 
   494 
  1087 
       
  1088 !
       
  1089 
       
  1090 openOnClass:aClass
       
  1091     "open up an interface builder
       
  1092     "
       
  1093     self openOnClass:aClass andSelector:#windowSpec
   495 !
  1094 !
   496 
  1095 
   497 openOnClass:aClass andSelector:aSelector
  1096 openOnClass:aClass andSelector:aSelector
   498     "open up an interface builder, fetching a spec from someClass
  1097     "open up an interface builder, fetching a spec from someClass
   499      via some selector"
  1098      via some selector
   500 
  1099     "
   501     |specArray|
  1100     |painter|
   502 
  1101 
       
  1102     self openInterface.
       
  1103 
       
  1104     painter        := self painter.
   503     specClass      := aClass name.
  1105     specClass      := aClass name.
   504     specSuperclass := aClass superclass name.
  1106     specSuperclass := aClass superclass name.
   505     specSelector   := aSelector.
  1107     specSelector   := aSelector.
   506 
  1108 
   507     self openInterface.
  1109     painter className:aClass name.
   508     workView className:aClass name.
  1110     painter methodName:aSelector.
   509     workView methodName:aSelector.
  1111     painter setupFromSpec:(aClass perform:aSelector).
   510     workView setupFromSpec:(aClass perform:aSelector).
  1112 
   511 !
  1113 ! !
   512 
  1114 
   513 openOnSpec:aSpecOrSpecArray
  1115 !UIPainter methodsFor:'user interaction - dialog'!
   514     "open up an interface builder, given some specArray"
       
   515 
       
   516     |newBuilder|
       
   517 
       
   518     newBuilder := self new.
       
   519 ! !
       
   520 
       
   521 !UIPainter methodsFor:'menus'!
       
   522 
       
   523 menuMisc
       
   524 
       
   525     |menuView menuGrid menuUndo|
       
   526 
       
   527     menuView := MenuView labels:
       
   528                         (resources array:#(
       
   529                                         'grid' 
       
   530                                         'undo'
       
   531                                     )
       
   532                                 )
       
   533                      selectors:#(
       
   534                                         #grid
       
   535                                         #undo
       
   536                                 )
       
   537                        receiver:self.
       
   538 
       
   539 
       
   540     menuGrid := PopUpMenu labels:(
       
   541                         resources array:#(
       
   542                                     '\c show' 
       
   543                                     '\c align'
       
   544                                   )
       
   545                              )
       
   546                   selectors:#(
       
   547                                     #gridShown:
       
   548                                     #gridAlign:
       
   549                              )
       
   550                     receiver:workView.
       
   551 
       
   552     menuGrid checkToggleAt:#gridShown: put:(workView gridShown).
       
   553     menuGrid checkToggleAt:#gridAlign: put:(workView gridAlign).
       
   554     menuView subMenuAt:#grid put:menuGrid.
       
   555 
       
   556     menuUndo := PopUpMenu labels:(
       
   557                         resources array:#(
       
   558                                         'last'
       
   559                                         'menu'
       
   560                                         '-'
       
   561                                         'delete'
       
   562                                   )
       
   563                              )
       
   564                   selectors:#(
       
   565                                     #undoLast
       
   566                                     #openUndoMenu
       
   567                                     nil
       
   568                                     #removeUndoHistory
       
   569                              )
       
   570                     receiver:workView.
       
   571 
       
   572     menuView subMenuAt:#undo put:menuUndo.
       
   573   ^ menuView
       
   574 ! !
       
   575 
       
   576 !UIPainter methodsFor:'setup choices'!
       
   577 
       
   578 showAllWidgets
       
   579     "create list of basic widgets"
       
   580 
       
   581     self showWidgetsWhere:[:class | true]
       
   582 !
       
   583 
       
   584 showBasicWidgets
       
   585     "create list of basic widgets"
       
   586 
       
   587     self showWidgetsInCategory:'Views-Basic' 
       
   588 			butNot:[:class | class isKindOf:ModalBox class]
       
   589 !
       
   590 
       
   591 showInteractorWidgets
       
   592     "create list of interactor widgets"
       
   593 
       
   594     self showWidgetsInCategory:'Views-Interactors'
       
   595 			butNot:[:class | class isKindOf:ModalBox class]
       
   596 !
       
   597 
       
   598 showLayoutWidgets
       
   599     "create list of basic widgets"
       
   600 
       
   601     self showWidgetsInCategory:'Views-Layout'
       
   602 			butNot:[:class | class isKindOf:ModalBox class]
       
   603 !
       
   604 
       
   605 showModalWidgets
       
   606     "create list of modal widgets"
       
   607 
       
   608     self showWidgetsWhere:[:class | class isKindOf:ModalBox class]
       
   609 !
       
   610 
       
   611 showOtherWidgets
       
   612     "create list of other widgets"
       
   613 
       
   614     |check cat|
       
   615 
       
   616     check := [:class |
       
   617 		(#('Views-Basic' 
       
   618 		   'Views-Interactors'
       
   619 		   'Views-Layout'
       
   620 		   'Views-Text') includes:class category) not].
       
   621     self showWidgetsWhere:check
       
   622 		   butNot:[:class | class isKindOf:ModalBox class]
       
   623 !
       
   624 
       
   625 showTextWidgets
       
   626     "create list of basic widgets"
       
   627 
       
   628     self showWidgetsInCategory:'Views-Text'
       
   629 			butNot:[:class | class isKindOf:ModalBox class]
       
   630 !
       
   631 
       
   632 showWidgetsInCategory:aCategory
       
   633     "create list of basic widgets"
       
   634 
       
   635     self showWidgetsWhere:[:class | class category = aCategory]
       
   636 !
       
   637 
       
   638 showWidgetsInCategory:aCategory butNot:excludeBlock
       
   639     "create list of basic widgets"
       
   640 
       
   641     self showWidgetsWhere:[:class | class category = aCategory]
       
   642 		   butNot:excludeBlock
       
   643 !
       
   644 
       
   645 showWidgetsWhere:aBlock
       
   646     "create list of widgets where aBlock avaluates to true"
       
   647 
       
   648     self showWidgetsWhere:aBlock butNot:[:class | false]
       
   649 !
       
   650 
       
   651 showWidgetsWhere:aBlock butNot:excludeBlock
       
   652     "create list of widgets where aBlock evaluates to true and excludeBlock
       
   653      evaluates to false"
       
   654 
       
   655     |list|
       
   656 
       
   657     list := OrderedCollection new:0.
       
   658     SimpleView allSubclassesDo:[:aSubclass |
       
   659         (aBlock value:aSubclass) ifTrue:[
       
   660             (excludeBlock value:aSubclass) ifFalse:[
       
   661                 list add:(aSubclass name)
       
   662             ]
       
   663         ]
       
   664     ].
       
   665     (aBlock value:View) ifTrue:[
       
   666         (excludeBlock value:View) ifFalse:[
       
   667             list add:'View'
       
   668         ]
       
   669     ].
       
   670     (list size == 0) ifFalse:[
       
   671         list sort
       
   672     ].
       
   673     elementMenu list:list
       
   674 ! !
       
   675 
       
   676 !UIPainter methodsFor:'user interaction'!
       
   677 
       
   678 closeRequest
       
   679     workView  notNil ifTrue:[workView  release. workView := nil].
       
   680     super closeRequest
       
   681 !
       
   682 
       
   683 closeRequestFor:aTopView
       
   684     aTopView == topView ifTrue:[
       
   685         super closeRequestFor:aTopView
       
   686     ] ifFalse:[
       
   687         topView raise.
       
   688         topView device beep
       
   689     ]
       
   690 ! !
       
   691 
       
   692 !UIPainter methodsFor:'user interaction - dialogs'!
       
   693 
  1116 
   694 checkClassAndSelector
  1117 checkClassAndSelector
   695     "check for class & superclass"
  1118     "check for class & superclass"
   696 
  1119 
   697     |superclass cls|
  1120     |superclass cls|
   738             self warn:'a global named ' , specClass , ' exists, but is not a subclass of ' , superclass name , '.'.
  1161             self warn:'a global named ' , specClass , ' exists, but is not a subclass of ' , superclass name , '.'.
   739             ^ false.
  1162             ^ false.
   740         ]
  1163         ]
   741     ].
  1164     ].
   742     ^ true
  1165     ^ true
       
  1166 
       
  1167 
   743 !
  1168 !
   744 
  1169 
   745 defineClassAndSelector
  1170 defineClassAndSelector
   746     "launch a dialog to define class, superclass and method"
  1171     "launch a dialog to define class, superclass and method"
   747 
  1172 
   748     |again|
  1173     |again|
   749 
  1174 
   750     [
  1175     [
   751         again := false.
  1176         again := false.
       
  1177 
   752         (self openDialogInterface:#nameAndSelectorSpec) ifTrue:[
  1178         (self openDialogInterface:#nameAndSelectorSpec) ifTrue:[
   753 
  1179 
   754             specClass := (self aspectFor:#classNameChannel) value.
  1180             specClass := (self aspectFor:#classNameChannel) value.
   755             specSelector := (self aspectFor:#methodNameChannel) value.
  1181             specSelector := (self aspectFor:#methodNameChannel) value.
   756             specSuperclass := (self aspectFor:#superclassNameChannel) value.
  1182             specSuperclass := (self aspectFor:#superclassNameChannel) value.
   757 
  1183 
   758             again := self checkClassAndSelector not.
  1184             (again := self checkClassAndSelector not) ifFalse:[
   759             again ifFalse:[
  1185                 self painter className:specClass
   760                 workView className:specClass superclassName:specSuperclass selector:specSelector.
  1186                         superclassName:specSuperclass
   761             ].
  1187                               selector:specSelector.
       
  1188             ]
   762         ]
  1189         ]
       
  1190 
   763     ] doWhile:[again]
  1191     ] doWhile:[again]
   764 
  1192 
   765 ! !
  1193 
   766 
  1194 ! !
   767 !UIPainter methodsFor:'user interaction - menu'!
  1195 
   768 
  1196 !UIPainter methodsFor:'user interaction - pullDown'!
   769 doFinish
       
   770     self closeRequest
       
   771 !
       
   772 
  1197 
   773 doFromClass
  1198 doFromClass
   774         |className methodName cls sel accepted failed spec s|
  1199         |className methodName cls sel accepted failed spec s painter|
   775 
  1200 
   776         className := '' asValue.
  1201         className  := '' asValue.
   777         methodName := '' asValue.
  1202         methodName := '' asValue.
   778         (s := workView className) notNil ifTrue:[
  1203         painter    := self painter.
       
  1204 
       
  1205         (s := painter className) notNil ifTrue:[
   779             className value:s
  1206             className value:s
   780         ].
  1207         ].
   781         (s := workView methodName) notNil ifTrue:[
  1208         (s := painter methodName) notNil ifTrue:[
   782             methodName value:s
  1209             methodName value:s
   783         ].
  1210         ].
   784 
  1211 
   785         failed := false.
  1212         failed := false.
   786         [
  1213         [
   811                         spec isArray ifFalse:[
  1238                         spec isArray ifFalse:[
   812                             failed := true.
  1239                             failed := true.
   813                             self warn:'not a windowSpec method'    
  1240                             self warn:'not a windowSpec method'    
   814                         ].
  1241                         ].
   815                         "/ ok, got it
  1242                         "/ ok, got it
   816                         workView className:className value.
  1243                         painter className:className value.
   817                         workView methodName:methodName value.
  1244                         painter methodName:methodName value.
   818                         workView setupFromSpec:spec.
  1245                         painter setupFromSpec:spec.
   819                         ^ self
  1246                       ^ self
   820                      ]
  1247                      ]
   821                 ]
  1248                 ]
   822              ]
  1249              ]
   823         ] doWhile:[accepted and:[failed]].
  1250         ] doWhile:[accepted and:[failed]].
   824 
  1251 
   825     "Modified: 5.9.1995 / 18:47:57 / claus"
       
   826 !
  1252 !
   827 
  1253 
   828 doInstallAspects
  1254 doInstallAspects
   829     |code|
  1255     |code|
   830 
  1256 
   834 
  1260 
   835     self checkClassAndSelector ifFalse:[
  1261     self checkClassAndSelector ifFalse:[
   836         ^ self
  1262         ^ self
   837     ].
  1263     ].
   838 
  1264 
   839     workView className:specClass superclassName:specSuperclass selector:specSelector.
  1265     self painter className:specClass
   840 
  1266         superclassName:specSuperclass
   841     code := workView generateAspectMethods.
  1267               selector:specSelector.
       
  1268 
       
  1269     code := self painter generateAspectMethods.
   842     (ReadStream on:code) fileIn.
  1270     (ReadStream on:code) fileIn.
   843 
  1271 
   844     "Modified: 4.9.1995 / 17:06:10 / claus"
       
   845 !
  1272 !
   846 
  1273 
   847 doInstallSpec
  1274 doInstallSpec
   848     |code|
  1275     |code|
   849 
  1276 
   853 
  1280 
   854     self checkClassAndSelector ifFalse:[
  1281     self checkClassAndSelector ifFalse:[
   855         ^ self
  1282         ^ self
   856     ].
  1283     ].
   857 
  1284 
   858     workView className:specClass superclassName:specSuperclass selector:specSelector.
  1285     self painter className:specClass
   859 
  1286             superclassName:specSuperclass
   860     code := workView generateCode.
  1287                   selector:specSelector.
       
  1288 
       
  1289     code := self painter generateCode.
   861     (ReadStream on:code) fileIn.
  1290     (ReadStream on:code) fileIn.
   862 
  1291 
   863     "Modified: 4.9.1995 / 17:06:10 / claus"
       
   864 !
       
   865 
       
   866 doNew
       
   867     workView removeAll.
       
   868 !
  1292 !
   869 
  1293 
   870 doOpen
  1294 doOpen
   871     |box|
  1295     |box|
   872 
  1296 
   874     box title:(resources string:'Which file ?').
  1298     box title:(resources string:'Which file ?').
   875     box selectingDirectory:false.
  1299     box selectingDirectory:false.
   876     box pattern:'*.*'.
  1300     box pattern:'*.*'.
   877     box action:[:aFile| self openFile:aFile ].
  1301     box action:[:aFile| self openFile:aFile ].
   878     box open
  1302     box open
       
  1303 
   879 !
  1304 !
   880 
  1305 
   881 doPickAView
  1306 doPickAView
   882     |view className methodName cls sel accepted spec s|
  1307     |painter view className methodName cls sel accepted spec s|
   883 
  1308 
   884     view := Display viewFromUser.
  1309     (view := Display viewFromUser) notNil ifTrue:[
   885     view isNil ifTrue:[^ self].
  1310         painter := self painter.
   886     spec := UISpecification fromView:view topView.
  1311 
   887 
  1312         spec := UISpecification fromView:view topView.
   888     "/ ok, got it
  1313 
   889     workView setupFromSpec:spec.
  1314      "/ ok, got it
   890     workView className:view class name.
  1315         painter setupFromSpec:spec.
   891     workView methodName:#newSpec.
  1316         painter className:view class name.
   892     ^ self
  1317         painter methodName:#newSpec.
   893 
  1318     ]
   894     "Modified: 5.9.1995 / 23:25:53 / claus"
       
   895 !
       
   896 
       
   897 doPrint
       
   898     ^ self
       
   899 !
  1319 !
   900 
  1320 
   901 doRaise
  1321 doRaise
   902     workView topView raise
  1322     self painter topView raise.
       
  1323 
       
  1324     selectionPanel notNil ifTrue:[
       
  1325         selectionPanel window raise
       
  1326     ]
       
  1327 
   903 !
  1328 !
   904 
  1329 
   905 doSave
  1330 doSave
   906     fileName notNil ifTrue:[
  1331     fileName notNil ifTrue:[
   907         self saveAs:fileName
  1332         self saveAs:fileName
   908     ] ifFalse:[
  1333     ] ifFalse:[
   909         self doSaveAs
  1334         self doSaveAs
   910     ]
  1335     ]
       
  1336 
   911 !
  1337 !
   912 
  1338 
   913 doSaveAs
  1339 doSaveAs
   914     |box|
  1340     |box|
   915 
  1341 
   917     box title:(resources string:'Which file ?').
  1343     box title:(resources string:'Which file ?').
   918     box selectingDirectory:false.
  1344     box selectingDirectory:false.
   919     box pattern:'*.*'.
  1345     box pattern:'*.*'.
   920     box action:[:aFile| self saveAs:aFile ].
  1346     box action:[:aFile| self saveAs:aFile ].
   921     box open
  1347     box open
   922 !
  1348 
   923 
       
   924 doSource
       
   925    |code v|
       
   926 
       
   927    code := workView generateCode.
       
   928    v := CodeView open.
       
   929    v contents:code.
       
   930    v label:(workView applicationName).
       
   931     ^ self
       
   932 
       
   933     "Modified: 5.9.1995 / 21:02:05 / claus"
       
   934 !
       
   935 
       
   936 doToggleTest
       
   937     workView testMode:(workView testMode not)
       
   938 !
  1349 !
   939 
  1350 
   940 doWindowSpec
  1351 doWindowSpec
   941    |code code2 v|
  1352    |code code2 v|
   942 
  1353 
   943    code := workView generateWindowSpecMethodSource.
  1354    code := self painter generateWindowSpecMethodSource.
   944 "/   code2 := workView generateAspectMethods.
       
   945    code2 notNil ifTrue:[
       
   946        code := code , code2.
       
   947    ].
       
   948 
  1355 
   949    v := CodeView open.
  1356    v := CodeView open.
   950    v contents:code.
  1357    v contents:code.
   951    v label:'windowSpec'.
  1358    v label:'windowSpec'.
   952     ^ self
  1359 
   953 
  1360 ! !
   954     "Modified: 5.9.1995 / 21:04:14 / claus"
  1361 
   955 ! !
  1362 !UIPainter class methodsFor:'documentation'!
   956 
       
   957 !UIPainter::ButtonPanel class methodsFor:'documentation'!
       
   958 
  1363 
   959 version
  1364 version
   960     ^ '$Header$'
  1365     ^ '$Header$'
   961 ! !
  1366 ! !
   962 
       
   963 !UIPainter::ButtonPanel methodsFor:'accessing'!
       
   964 
       
   965 receiver
       
   966     ^ receiver
       
   967 !
       
   968 
       
   969 receiver:aReceiver
       
   970     receiver := aReceiver
       
   971 ! !
       
   972 
       
   973 !UIPainter::ButtonPanel methodsFor:'initialization'!
       
   974 
       
   975 initialize
       
   976     "initialize and setup buttons
       
   977     "
       
   978     super initialize.
       
   979 
       
   980     self level:-1.
       
   981     self borderWidth:0.
       
   982     self horizontalLayout:#leftSpace.
       
   983     argumentToSelector := 1.
       
   984 
       
   985     self specification do:[:anArray|
       
   986         |selector image button seperator|
       
   987 
       
   988         selector := anArray at:1.
       
   989 
       
   990         selector notNil ifTrue:[
       
   991             image  := Image fromFile:( anArray at:2 ).
       
   992             button := Button label:image in:self.
       
   993 
       
   994             selector last == $: ifFalse:[
       
   995                 button action:[
       
   996                     receiver notNil ifTrue:[
       
   997                         receiver perform:selector
       
   998                     ]
       
   999                 ]
       
  1000             ] ifTrue:[
       
  1001                 button pressAction:[
       
  1002                     receiver notNil ifTrue:[
       
  1003                         receiver perform:selector with:argumentToSelector
       
  1004                     ].
       
  1005                     receiver enableUndoHistory:false.
       
  1006                 ].
       
  1007                 button releaseAction:[ receiver enableUndoHistory:true ].
       
  1008                 button autoRepeat:true.
       
  1009                 button menuHolder:self; menuMessage:#editMenu; menuPerformer:self.
       
  1010             ]
       
  1011         ] ifFalse:[
       
  1012             seperator := View in:self.
       
  1013             seperator extent:20@1.
       
  1014             seperator borderWidth:0.
       
  1015         ]
       
  1016     ].
       
  1017 
       
  1018 !
       
  1019 
       
  1020 specification
       
  1021     "return a spec for the buttons in the panel;
       
  1022      entries consists of selector and bitmap-filename.
       
  1023      nil selectors are taken as separators (see setupButtonPanel)"
       
  1024 
       
  1025     ^ #(
       
  1026         #( alignSelectionLeft         'b_alignL.xbm'    )
       
  1027         #( alignSelectionRight        'b_alignR.xbm'    )
       
  1028         #( alignSelectionLeftAndRight 'b_alignLR.xbm'   )
       
  1029         #( nil )
       
  1030         #( alignSelectionTop          'b_alignT.xbm'    )
       
  1031         #( alignSelectionBottom       'b_alignB.xbm'    )
       
  1032         #( alignSelectionTopAndBottom 'b_alignTB.xbm'   )
       
  1033         #( nil )
       
  1034         #( alignSelectionCenterHor    'b_alignCH.xbm'   )
       
  1035         #( alignSelectionCenterVer    'b_alignCV.xbm'   )
       
  1036         #( nil )
       
  1037         #( moveSelectionLeft:         'b_moveLeft.xbm'  )
       
  1038         #( moveSelectionRight:        'b_moveRight.xbm' )
       
  1039         #( moveSelectionUp:           'b_moveUp.xbm'    )
       
  1040         #( moveSelectionDown:         'b_moveDown.xbm'  )
       
  1041        )
       
  1042 
       
  1043 
       
  1044 ! !
       
  1045 
       
  1046 !UIPainter::ButtonPanel methodsFor:'menu'!
       
  1047 
       
  1048 editMenu
       
  1049     "edit menu used by buttons using an argument for the receiver; the argumentToSelector
       
  1050     "
       
  1051     |menu|
       
  1052 
       
  1053     menu := PopUpMenu labels:#( '1' '2' '4' '10' '20' '..' )
       
  1054                         args:#(  1   2   4   10   20  nil  ).
       
  1055 
       
  1056     menu action:[:anArg||no|
       
  1057         (no := anArg) isNil ifTrue:[
       
  1058             no := EnterBox request:'number'.
       
  1059             no := SmallInteger readFrom:no onError:0.
       
  1060         ].
       
  1061         no ~~ 0 ifTrue:[
       
  1062             |index view|
       
  1063 
       
  1064             view := (WindowGroup lastEventQuerySignal raise) view.
       
  1065             view := view menuPerformer.
       
  1066             argumentToSelector := no.
       
  1067             view pressAction value.
       
  1068             argumentToSelector := 1.
       
  1069         ]
       
  1070     ].
       
  1071     ^ menu
       
  1072 ! !
       
  1073 
       
  1074 !UIPainter::ButtonPanel methodsFor:'queries'!
       
  1075 
       
  1076 specClass
       
  1077     ^ HorizontalPanelViewSpec
       
  1078 ! !
       
  1079 
       
  1080 !UIPainter class methodsFor:'documentation'!
       
  1081 
       
  1082 version
       
  1083     ^ '$Header$'
       
  1084 ! !