UIPainter.st
changeset 133 e12f82d3afb7
parent 130 ffa9ea02d276
child 136 42a2a4494281
equal deleted inserted replaced
132:8649766ce095 133:e12f82d3afb7
   172                                  #(#MenuItem
   172                                  #(#MenuItem
   173                                         #'label:' 'pick a view '
   173                                         #'label:' 'pick a view '
   174                                         #'value:' #doPickAView
   174                                         #'value:' #doPickAView
   175                                   )
   175                                   )
   176                                  #(#MenuItem
   176                                  #(#MenuItem
   177                                         #'label:' 'load'
       
   178                                         #'value:' #doOpen
       
   179                                   )
       
   180                                  #(#MenuItem
       
   181                                         #'label:' 'save'
       
   182                                         #'value:' #doSave
       
   183                                   )
       
   184                                  #(#MenuItem
       
   185                                         #'label:' 'save as ...'
       
   186                                         #'value:' #doSaveAs
       
   187                                   )
       
   188                                  #(#MenuItem
       
   189                                         #'label:' 'raise'
   177                                         #'label:' 'raise'
   190                                         #'value:' #doRaise
   178                                         #'value:' #doRaise
   191                                   )
   179                                   )
   192                                  #(#MenuItem
   180                                  #(#MenuItem
   193                                         #'label:' 'quit'
   181                                         #'label:' 'quit'
   194                                         #'value:' #closeRequest
   182                                         #'value:' #closeRequest
   195                                   )
   183                                   )
   196                                  )
   184                                  )
   197                                 #(3 3 1)
   185                                 #(3 1)
   198                                 nil
   186                                 nil
   199                        )
   187                        )
   200          )
   188          )
   201         #(#MenuItem
   189         #(#MenuItem
   202                 #'label:' 'font'
   190                 #'label:' 'font'
   308                 #'label:' 'code'
   296                 #'label:' 'code'
   309                 #'value:' #code
   297                 #'value:' #code
   310                 #'submenu:'
   298                 #'submenu:'
   311                         #(#Menu #(
   299                         #(#Menu #(
   312                                 #(#MenuItem
   300                                 #(#MenuItem
   313                                         #'label:' 'class & method'
   301                                         #'label:' 'class && method'
   314                                         #'value:' #defineClassAndSelector
   302                                         #'value:' #defineClassAndSelector
   315                                  )
   303                                  )
   316                                  #(#MenuItem
   304                                  #(#MenuItem
   317                                         #'label:' 'install spec'
   305                                         #'label:' 'install spec'
   318                                         #'value:' #doInstallSpec
   306                                         #'value:' #doInstallSpec
   323                                   )
   311                                   )
   324                                  #(#MenuItem
   312                                  #(#MenuItem
   325                                         #'label:' 'windowSpec'
   313                                         #'label:' 'windowSpec'
   326                                         #'value:' #doWindowSpec
   314                                         #'value:' #doWindowSpec
   327                                    )
   315                                    )
       
   316                                 #(#MenuItem
       
   317                                         #'label:' 'browse'
       
   318                                         #'value:' #browseAppClass
       
   319                                  )
   328                                 )
   320                                 )
   329                                 #( 1 2 )
   321                                 #( 1 2 1)
   330                                 nil
   322                                 nil
   331                           )
   323                           )
   332          )
   324          )
   333         #(#MenuItem
   325         #(#MenuItem
   334                 #'label:' 'test'
   326                 #'label:' 'test'
   729     menu fromLiteralArrayEncoding:(self class menuPullDown).
   721     menu fromLiteralArrayEncoding:(self class menuPullDown).
   730     menu receiver:self.
   722     menu receiver:self.
   731 
   723 
   732     menu menuItems do:[:anItem| 
   724     menu menuItems do:[:anItem| 
   733         anItem nameKey ~~ #test ifTrue:[anItem enabled:channel]
   725         anItem nameKey ~~ #test ifTrue:[anItem enabled:channel]
       
   726                                ifFalse:[anItem value:channel].
   734     ].
   727     ].
   735   ^ menu
   728   ^ menu
   736 !
   729 !
   737 
   730 
   738 modifiedChannel
   731 modifiedChannel
   942 !UIPainter methodsFor:'startup / release'!
   935 !UIPainter methodsFor:'startup / release'!
   943 
   936 
   944 closeRequest
   937 closeRequest
   945     "close all windows open by builder
   938     "close all windows open by builder
   946     "
   939     "
       
   940     |anyUnsavedChanges|
       
   941 
       
   942     objectList painter isModified ifTrue:[
       
   943         (self confirm:'quit without saving ?') ifFalse:[
       
   944             ^ self
       
   945         ]
       
   946     ].
       
   947 
   947     objectList removeDependent:self.
   948     objectList removeDependent:self.
   948     objectList painter release.
   949     objectList painter release.
   949     objectList := nil.
   950     objectList := nil.
   950 
   951 
   951     selectionPanel notNil ifTrue:[
   952     selectionPanel notNil ifTrue:[
   963     topView := self window.
   964     topView := self window.
   964 
   965 
   965     topView == aTopView ifTrue:[
   966     topView == aTopView ifTrue:[
   966         super closeRequestFor:aTopView
   967         super closeRequestFor:aTopView
   967     ] ifFalse:[
   968     ] ifFalse:[
   968         (selectionPanel notNil and:[aTopView == selectionPanel window]) ifTrue:[
   969         topView raise.
   969             aTopView application:nil.
   970         topView device beep
   970             aTopView terminate.
       
   971             selectionPanel := nil.
       
   972         ] ifFalse:[
       
   973             topView raise.
       
   974             topView device beep
       
   975         ]
       
   976     ].
   971     ].
   977 !
   972 !
   978 
   973 
   979 openInterface
   974 openInterface
   980     "open interfaces
   975     "open interfaces
   981     "
   976     "
   982     |painterView painter cls topView|
   977     |cls painter|
   983 
   978 
   984     aspects := IdentityDictionary new.
   979     aspects := IdentityDictionary new.
   985 
   980 
   986     aspects at:#classNameChannel put:(
   981     aspects at:#classNameChannel put:(
   987         (specClass notNil ifTrue:[specClass]
   982         (specClass notNil ifTrue:[specClass]
  1000     ).
   995     ).
  1001     aspects at:#methodNameChannel put:(
   996     aspects at:#methodNameChannel put:(
  1002         (specSelector notNil ifTrue:[specSelector]
   997         (specSelector notNil ifTrue:[specSelector]
  1003                             ifFalse:[#windowSpec]) asValue
   998                             ifFalse:[#windowSpec]) asValue
  1004     ).
   999     ).
  1005 
  1000     painter := UIPainterView new.
  1006     painterView := StandardSystemView new.
       
  1007     painterView label:'unnamed canvas'.
       
  1008     painterView extent:300@300.
       
  1009 
       
  1010     painter := UIPainterView in:painterView.
       
  1011     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  1001     painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
  1012 
       
  1013     objectList := painter listHolder.
  1002     objectList := painter listHolder.
  1014     objectList addDependent:self.
  1003     objectList addDependent:self.
  1015 
       
  1016     super openInterface.
  1004     super openInterface.
  1017 
  1005 
  1018     topView := self window.
       
  1019     topView label:'Interface Builder'.
       
  1020     topView icon:(Image fromFile:'bitmaps/Builder.xbm' resolution:100).
       
  1021 
       
  1022     painterView openInGroup:(topView windowGroup).
       
  1023 
       
  1024     topView beMaster.
       
  1025     painterView beSlave.
       
  1026     painterView application:self.
       
  1027     painterView open.
       
  1028     selectionPanel := UISelectionPanel open.
       
  1029     selectionPanel window beSlave.
       
  1030     selectionPanel window application:self.
       
  1031 !
  1006 !
  1032 
  1007 
  1033 openNewWindowCanvas
  1008 openNewWindowCanvas
  1034     "open new
  1009     "open new
  1035     "
  1010     "
  1059 
  1034 
  1060     painter className:aClass name.
  1035     painter className:aClass name.
  1061     painter methodName:aSelector.
  1036     painter methodName:aSelector.
  1062     painter setupFromSpec:(aClass perform:aSelector).
  1037     painter setupFromSpec:(aClass perform:aSelector).
  1063 
  1038 
       
  1039 !
       
  1040 
       
  1041 postOpenWith:aBuilder
       
  1042     "open all subApplications
       
  1043     "
       
  1044     |pview window|
       
  1045 
       
  1046     window := self window.
       
  1047     window bePartner.
       
  1048     window label:'Interface Builder'.
       
  1049     window icon:(Image fromFile:'bitmaps/Builder.xbm' resolution:100).
       
  1050 
       
  1051     selectionPanel := UISelectionPanel newDefault.
       
  1052     selectionPanel allButOpenInterface:#windowSpec.
       
  1053     selectionPanel window openInGroup:(window windowGroup).
       
  1054     selectionPanel window bePartner.
       
  1055     selectionPanel openWindow.
       
  1056     selectionPanel window application:self.
       
  1057 
       
  1058     pview := StandardSystemView new.
       
  1059     pview label:'unnamed canvas'.
       
  1060     pview extent:300@300.
       
  1061     pview add:(self painter).
       
  1062     pview openInGroup:(window windowGroup).
       
  1063     pview bePartner.
       
  1064     pview open.
       
  1065     pview application:self.
       
  1066 
  1064 ! !
  1067 ! !
  1065 
  1068 
  1066 !UIPainter methodsFor:'user interaction - dialog'!
  1069 !UIPainter methodsFor:'user interaction - dialog'!
       
  1070 
       
  1071 browseAppClass
       
  1072     "open a browser on the class"
       
  1073 
       
  1074     |cls|
       
  1075 
       
  1076     specClass isNil ifTrue:[
       
  1077         self information:'no class yet'.
       
  1078         ^ self
       
  1079     ].
       
  1080 
       
  1081     specClass isBehavior ifFalse:[
       
  1082         cls := Smalltalk at:specClass asSymbol
       
  1083     ] ifTrue:[
       
  1084         cls := specClass
       
  1085     ].
       
  1086 
       
  1087     cls isNil ifTrue:[
       
  1088         self information:'no class yet'.
       
  1089         ^ self
       
  1090     ].
       
  1091 
       
  1092     SystemBrowser openInClass:cls
       
  1093 
       
  1094 
       
  1095 !
  1067 
  1096 
  1068 checkClassAndSelector
  1097 checkClassAndSelector
  1069     "check for class & superclass"
  1098     "check for class & superclass"
  1070 
  1099 
  1071     |superclass cls|
  1100     |superclass cls|