MenuEditor.st
changeset 275 cdecb5b5d356
parent 270 1a68f7479932
child 287 1ecabfd468dc
equal deleted inserted replaced
274:2db2e583b3b4 275:cdecb5b5d356
    26 	poolDictionaries:''
    26 	poolDictionaries:''
    27 	privateIn:MenuEditor
    27 	privateIn:MenuEditor
    28 !
    28 !
    29 
    29 
    30 SelectionInTreeView subclass:#Painter
    30 SelectionInTreeView subclass:#Painter
    31 	instanceVariableNames:'imageMenuLink imageSeparator'
    31 	instanceVariableNames:'images'
    32 	classVariableNames:'CopyBuffer ImageMenuLink ImageSeparator ImageItem ImageMenu
    32 	classVariableNames:'CopyBuffer Images'
    33 		ImageMenuOpen'
       
    34 	poolDictionaries:''
    33 	poolDictionaries:''
    35 	privateIn:MenuEditor
    34 	privateIn:MenuEditor
    36 !
    35 !
    37 
    36 
    38 !MenuEditor class methodsFor:'documentation'!
    37 !MenuEditor class methodsFor:'documentation'!
  2080     ^ self separatorType notNil
  2079     ^ self separatorType notNil
  2081 ! !
  2080 ! !
  2082 
  2081 
  2083 !MenuEditor::Painter class methodsFor:'constants'!
  2082 !MenuEditor::Painter class methodsFor:'constants'!
  2084 
  2083 
  2085 imageClosed
       
  2086     ^ self imageMenu
       
  2087 
       
  2088     "Created: 28.7.1997 / 10:31:37 / cg"
       
  2089 !
       
  2090 
       
  2091 imageItem
  2084 imageItem
  2092     ImageItem isNil ifTrue:[
  2085     ^ self images at:#item
  2093         ImageItem := Image fromFile:('ui_menuitem.xpm').
       
  2094     ].
       
  2095     ^ ImageItem
       
  2096 
       
  2097     "
       
  2098      ImageItem := nil
       
  2099     "
       
  2100 
       
  2101     "Created: 28.7.1997 / 09:51:00 / cg"
       
  2102     "Modified: 28.7.1997 / 09:51:14 / cg"
       
  2103 !
  2086 !
  2104 
  2087 
  2105 imageMenu
  2088 imageMenu
  2106     ImageMenu isNil ifTrue:[
  2089     ^ self images at:#menuOpen
  2107         ImageMenu := Image fromFile:('ui_submenu.xpm').
       
  2108     ].
       
  2109     ^ ImageMenu
       
  2110 
       
  2111     "
       
  2112     ImageMenu := nil
       
  2113     "
       
  2114 
       
  2115     "Created: 28.7.1997 / 10:01:21 / cg"
       
  2116     "Modified: 28.7.1997 / 10:29:14 / cg"
       
  2117 !
  2090 !
  2118 
  2091 
  2119 imageMenuLink
  2092 imageMenuLink
  2120     ImageMenuLink isNil ifTrue:[
  2093     ^ self images at:#menuLink
  2121 "/        ImageMenuLink := Image fromFile:('xpmBitmaps/document_images/tiny_yellow_dir_link.xpm').
  2094 
  2122         ImageMenuLink := Image fromFile:('ui_submenulink.xpm').
       
  2123     ].
       
  2124     ^ ImageMenuLink
       
  2125 
       
  2126     "
       
  2127     ImageMenuLink := nil
       
  2128     "
       
  2129 
       
  2130     "Modified: 28.7.1997 / 10:29:18 / cg"
       
  2131 !
       
  2132 
       
  2133 imageMenuOpen
       
  2134     ImageMenuOpen isNil ifTrue:[
       
  2135         ImageMenuOpen := Image fromFile:('ui_submenu_open.xpm').
       
  2136     ].
       
  2137     ^ ImageMenuOpen
       
  2138 
       
  2139     "
       
  2140     ImageMenuOpen := nil
       
  2141     "
       
  2142 
       
  2143     "Created: 28.7.1997 / 10:21:31 / cg"
       
  2144     "Modified: 28.7.1997 / 10:29:20 / cg"
       
  2145 !
       
  2146 
       
  2147 imageOpened
       
  2148     ^ self imageMenuOpen
       
  2149 
       
  2150     "Created: 28.7.1997 / 10:31:46 / cg"
       
  2151 !
  2095 !
  2152 
  2096 
  2153 imageSeparator
  2097 imageSeparator
  2154     ImageSeparator isNil ifTrue:[
  2098     ^ self images at:#separator
  2155 "/        ImageSeparator := Image fromFile:('xpmBitmaps/document_images/tiny_file_exec.xpm').
  2099 
  2156         ImageSeparator := Image fromFile:('ui_menusep.xpm').
  2100 !
  2157     ].
  2101 
  2158     ^ ImageSeparator
  2102 images
  2159 
  2103     "returns an IdentityDictionary containing a list of images and keys used
  2160     "
  2104     "
  2161      ImageSeparator := nil
  2105     |icons image|
  2162     "
  2106 
  2163 
  2107     Images notNil ifTrue:[
  2164     "Modified: 28.7.1997 / 09:42:07 / cg"
  2108         ^ Images
       
  2109     ].
       
  2110 
       
  2111     Images := IdentityDictionary new.
       
  2112 
       
  2113     #(
       
  2114         (#item            'ui_menuitem.xpm')
       
  2115         (#menuClosed      'ui_submenu.xpm')
       
  2116         (#menuOpen        'ui_submenu_open.xpm')
       
  2117         (#menuLink        'ui_submenulink.xpm')
       
  2118         (#separator       'ui_menusep.xpm')
       
  2119 
       
  2120      ) do:[:el |
       
  2121         image := Image fromFile:( el last ).
       
  2122         Images at:(el first) put:image.
       
  2123     ].
       
  2124 
       
  2125   ^ Images
       
  2126 
       
  2127 
       
  2128 
  2165 ! !
  2129 ! !
  2166 
  2130 
  2167 !MenuEditor::Painter class methodsFor:'defaults'!
  2131 !MenuEditor::Painter class methodsFor:'defaults'!
  2168 
  2132 
  2169 defaultMenuMessage   
  2133 defaultMenuMessage   
  2344 
  2308 
  2345     aNode hasChildren ifFalse:[
  2309     aNode hasChildren ifFalse:[
  2346         item := aNode contents.
  2310         item := aNode contents.
  2347 
  2311 
  2348         item submenuChannel notNil ifTrue:[
  2312         item submenuChannel notNil ifTrue:[
  2349             imageMenuLink isNil ifTrue:[
  2313             ^ images at:#menuLink
  2350                 imageMenuLink := (self class imageMenuLink) onDevice:device.
       
  2351             ].
       
  2352             ^ imageMenuLink
       
  2353         ].
  2314         ].
  2354 
  2315 
  2355         item isSeparator ifTrue:[
  2316         item isSeparator ifTrue:[
  2356             imageSeparator isNil ifTrue:[
  2317             ^ images at:#separator
  2357                 imageSeparator := (self class imageSeparator) onDevice:device.
       
  2358             ].
       
  2359             ^ imageSeparator
       
  2360         ].
  2318         ].
  2361         imageItem isNil ifTrue:[
  2319         ^ images at:#item
  2362             imageItem := (self class imageItem) onDevice:device.
       
  2363         ].
       
  2364         ^ imageItem
       
  2365     ].
  2320     ].
  2366 
  2321 
  2367     aNode isExpandable ifTrue:[ 
  2322     aNode isExpandable ifTrue:[ 
  2368         imageClosed isNil ifTrue:[
  2323         ^ images at:#menuClosed
  2369             imageClosed := (self class imageMenu) onDevice:device.
  2324     ].
  2370         ].
  2325     ^ images at:#menuOpen
  2371         ^ imageClosed
       
  2372     ].
       
  2373     imageOpened isNil ifTrue:[
       
  2374         imageOpened := (self class imageMenuOpen) onDevice:device.
       
  2375     ].
       
  2376     ^ imageOpened
       
  2377 
       
  2378     "Modified: 28.7.1997 / 10:27:52 / cg"
       
  2379 ! !
  2326 ! !
  2380 
  2327 
  2381 !MenuEditor::Painter methodsFor:'initialization'!
  2328 !MenuEditor::Painter methodsFor:'initialization'!
       
  2329 
       
  2330 fetchImageResources
       
  2331     "initialize heavily used device resources - to avoid rendering
       
  2332      images again and again later; returns maximum extent of the images used.
       
  2333     "
       
  2334     |y x t|
       
  2335 
       
  2336     t := super fetchImageResources.
       
  2337     y := t y.
       
  2338     x := t x.
       
  2339 
       
  2340     images do:[:anIcon|
       
  2341         (t := anIcon heightOn:self) > y ifTrue:[y := t].
       
  2342         (t := anIcon widthOn:self)  > x ifTrue:[x := t].
       
  2343     ].
       
  2344   ^ x @ y
       
  2345 
       
  2346 !
  2382 
  2347 
  2383 initialize
  2348 initialize
  2384     super initialize.
  2349     super initialize.
  2385     imageOpened := nil.
  2350 
  2386     imageClosed := nil.
  2351     images := IdentityDictionary new.
       
  2352 
       
  2353     self class images associationsDo:[:el|
       
  2354         images at:(el key) put:(el value onDevice:device)
       
  2355     ].
       
  2356 
  2387     self multipleSelectOk:true.
  2357     self multipleSelectOk:true.
  2388     self model:(SelectionInTree new).
  2358     self model:(SelectionInTree new).
  2389 
       
  2390     "Modified: 28.7.1997 / 10:28:48 / cg"
       
  2391 ! !
  2359 ! !
  2392 
  2360 
  2393 !MenuEditor::Painter methodsFor:'menus'!
  2361 !MenuEditor::Painter methodsFor:'menus'!
  2394 
  2362 
  2395 doCopy
  2363 doCopy