プログラム断片(2009/05/03)

for VisualWorks 7.6 with Jun776

ウィンドウを開く

| aWindow |
aWindow := UI.ApplicationWindow new.
^aWindow
| aWindow |
aWindow := UI.ApplicationWindow new.
aWindow open.
^aWindow
01
| aWindow |
aWindow := UI.ApplicationWindow new.
aWindow minimumSize: 400 @ 300.
aWindow open.
^aWindow
02
| aWindow |
aWindow := UI.ApplicationWindow new.
aWindow label: 'My Window'.
aWindow minimumSize: 400 @ 300.
aWindow open.
^aWindow
03

ウィンドウに画像を

| aWindow |
aWindow := UI.ApplicationWindow new.
aWindow label: 'My Window'.
aWindow openIn: (100 @ 100 extent: 400 @ 300).
^aWindow
| aLambda anImage aWindow |
aLambda :=
        [:urlString |
        | separatorString workDirectory commandLine imageFile imageReader |
        separatorString := Core.String with: OS.Filename separator.
        workDirectory := (OS.SystemUtils getEnvironmentVariable: 'HOME') , separatorString , 'Desktop'.
        commandLine := '(cd ' , workDirectory , ' ; curl -O ' , urlString , ')'.
        OS.ExternalProcess cshOne: commandLine.
        imageFile := workDirectory , separatorString , (OS.URL fromString: urlString) path last.
        imageReader := Graphics.ImageReader fromFile: imageFile.
        imageReader image].
anImage := aLambda value: 'http://www.cc.kyoto-su.ac.jp/~atsushi/misc/jpgs/imageSmalltalkBalloon256x256'.
aWindow := UI.ApplicationWindow new.
aWindow label: 'My Window'.
aWindow component: anImage.
aWindow openIn: (100 @ 100 extent: 400 @ 300).
^aWindow
04
| anImage aWindow |
anImage := Graphics.Screen default completeContentsOfArea: Graphics.Screen default bounds.
aWindow := UI.ApplicationWindow new.
aWindow label: 'My Window'.
aWindow component: anImage.
aWindow openIn: (100 @ 100 extent: 400 @ 300).
^aWindow
05

スクロールバーを出す

| anImage aDecorator aWindow |
anImage := Graphics.Screen default completeContentsOfArea: Graphics.Screen default bounds.
aDecorator := UI.LookPreferences edgeDecorator on: anImage.
aDecorator useVerticalScrollBar.
aDecorator useHorizontalScrollBar.
aWindow := UI.ApplicationWindow new.
aWindow label: 'My Window'.
aWindow component: aDecorator.
aWindow openIn: (100 @ 100 extent: 400 @ 300).
^aWindow
06

メニューもウィンドウ

| aMenu |
aMenu := UI.Menu new.
^aMenu
| aMenu |
aMenu := UI.Menu labelArray: #('Word' 'Excel' 'PowerPoint').
aMenu startUp.
^aMenu
07
| aMenu aValue |
aMenu := UI.Menu labelArray: #('Word' 'Excel' 'PowerPoint').
aValue := aMenu startUp.
Transcript
        cr;
        show: aValue printString.
^aMenu

メニューでランチャー(手続き的)

| aMenu aValue aString |
aMenu := UI.Menu labelArray: #('Word' 'Excel' 'PowerPoint').
aValue := aMenu startUp.
aValue = 0 ifTrue: [^aMenu].
aValue = 1 ifTrue: [aString := 'WINWORD.EXE'].
aValue = 2 ifTrue: [aString := 'EXCEL.EXE'].
aValue = 3 ifTrue: [aString := 'POWERPNT.EXE'].
JunWin32Interface current shellExecute: 'open' with: aString.
^aMenu

"| aMenu aValue aString |
aMenu := UI.Menu labelArray: #('Pages' 'Numbers' 'Keynote').
aValue := aMenu startUp.
aValue = 0 ifTrue: [^aMenu].
aValue = 1 ifTrue: [aString := 'Pages.app'].
aValue = 2 ifTrue: [aString := 'Numbers.app'].
aValue = 3 ifTrue: [aString := 'Keynote.app'].
OS.ExternalProcess cshOne: 'open /Applications/' , aString.
^aMenu"
08 09 10

メニューでランチャー(オブジェクト指向)

| aMenu aValue |
aMenu := UI.Menu
            labelArray: #('Word' 'Excel' 'PowerPoint')
            values: #('WINWORD.EXE' 'EXCEL.EXE' 'POWERPNT.EXE').
aValue := aMenu startUp.
aValue = 0 ifTrue: [^aMenu].
JunWin32Interface current shellExecute: 'open' with: aValue.
^aMenu

"| aMenu aValue |
aMenu := UI.Menu
            labelArray: #('Pages' 'Numbers' 'Keynote')
            values: #('Pages.app' 'Numbers.app' 'Keynote.app').
aValue := aMenu startUp.
aValue = 0 ifTrue: [^aMenu].
OS.ExternalProcess cshOne: 'open /Applications/' , aValue.
^aMenu"
08 09 10

for VisualWorks 7.6 with Jun776


Updated: 2019/08/24 (Created: 2009/05/03) KSU AokiHanko