ImageEditor.st
changeset 1479 18f7b6cc2514
parent 1471 aa01951b16cf
child 1480 43c18932d2e8
equal deleted inserted replaced
1478:0d8a60f17338 1479:18f7b6cc2514
  1060                   #translateLabel: true
  1060                   #translateLabel: true
  1061                   #value: #doMagnifyImage
  1061                   #value: #doMagnifyImage
  1062                   #activeHelpKey: #editMagnifyImage
  1062                   #activeHelpKey: #editMagnifyImage
  1063                 )
  1063                 )
  1064                #(#MenuItem
  1064                #(#MenuItem
       
  1065                   #label: 'Magnify By...'
       
  1066                   #translateLabel: true
       
  1067                   #value: #doMagnifyImageBy
       
  1068                   #activeHelpKey: #editMagnifyImage
       
  1069                 )
       
  1070                #(#MenuItem
  1065                   #label: 'Rotate...'
  1071                   #label: 'Rotate...'
  1066                   #translateLabel: true
  1072                   #translateLabel: true
  1067                   #value: #doRotateImage
  1073                   #value: #doRotateImage
  1068                   #activeHelpKey: #editRotate
  1074                   #activeHelpKey: #editRotate
  1069                 )
  1075                 )
  2852 
  2858 
  2853     "Modified: / 26.7.1998 / 20:24:08 / cg"
  2859     "Modified: / 26.7.1998 / 20:24:08 / cg"
  2854 !
  2860 !
  2855 
  2861 
  2856 doMagnifyImage
  2862 doMagnifyImage
  2857     "magnifies current image"
  2863     "magnifies the current image to a new size"
  2858 
  2864 
  2859     |box newSize image|
  2865     |box newSize image|
  2860 
  2866 
  2861     image := imageEditView image.
  2867     image := imageEditView image.
  2862 
  2868 
  2867     box initialText:image extent printString.
  2873     box initialText:image extent printString.
  2868     box showAtPointer.
  2874     box showAtPointer.
  2869     (box accepted 
  2875     (box accepted 
  2870     and: [(newSize := Object readFromString:(box contents) onError:nil) notNil])
  2876     and: [(newSize := Object readFromString:(box contents) onError:nil) notNil])
  2871     ifTrue:[
  2877     ifTrue:[
       
  2878         newSize isPoint ifFalse:[
       
  2879             self warn:'please enter the new size as ''x @ y''.'.
       
  2880             ^ self.    
       
  2881         ].
       
  2882         imageEditView magnifyImageTo:newSize.
       
  2883     ].
       
  2884 
       
  2885     self updateInfoLabel
       
  2886 !
       
  2887 
       
  2888 doMagnifyImageBy
       
  2889     "magnifies the current image (by a scale)"
       
  2890 
       
  2891     |box oldSize newSize scale image|
       
  2892 
       
  2893     image := imageEditView image.
       
  2894     oldSize := image extent.
       
  2895 
       
  2896     box := EnterBox new.
       
  2897     box title:(resources string:'Scale factor (<1 to shrink; >1 to magnify):').
       
  2898     box okText:(resources string:'OK').
       
  2899     box abortText:(resources string:'Cancel').
       
  2900     box initialText:1 printString.
       
  2901     box showAtPointer.
       
  2902 
       
  2903     (box accepted 
       
  2904     and: [(scale := Object readFromString:(box contents) onError:nil) notNil])
       
  2905     ifTrue:[
       
  2906         scale isNumber ifFalse:[
       
  2907             self warn:'please enter a scale factor (<1 to shrink; >1 to magnify).'.
       
  2908             ^ self.    
       
  2909         ].
       
  2910         newSize := oldSize * scale.
  2872         imageEditView magnifyImageTo:newSize.
  2911         imageEditView magnifyImageTo:newSize.
  2873     ].
  2912     ].
  2874 
  2913 
  2875     self updateInfoLabel
  2914     self updateInfoLabel
  2876 !
  2915 !