vieweditattachhistoryswikistopchangessearchhelp

VWNC3 memo

VisualWorks 3.0 Non Commercial版に関するメモ
(ページ作成はSHIMADAですが、どなたでも追記・修正できます。)

Resources


VWNC3.x + 3Dグラフィックスライブラリ「じゅん」のお手軽パッケージ
Smalltalk プログラミングの初歩的チュートリアル
Smalltalkイディオム




Tips


1. テキストファイルの読み書き

一行ずつ読んでコレクションに入れる --SHIMADA

 | aCollection |
 aReadStream := 'hogehoge' asFilename readStream.
 aCollection := OrderedCollection new.
 [[aReadStream atEnd] whileFalse:
     [| aString |
     aString := aReadStream upTo: Charactor cr. "改行の直前までを読み取る"
     aCollection add: aString]]                 "改行は消える"
 ] ensure: [aReadStream close].
 ^aCollection

コレクションの要素を一行として書き出す --SHIMADA

 | aWriteStream |
 aWriteStream := 'hogehoge' asFilename writeStream. "追記は appendStream"
 [aCollection do: [:each |
     aWriteStream nextPutAll: each printString; cr.]
 ] ensure: [aWriteStream close]

2. コレクション

重複するデータのそれぞれの出現回数を数える --SHIMADA

 | aBag |
 aBag := Bag new.
 aCollection do:  [:each | aBag add: each].
 aBag valuesAndCountsDo: [:obj :count |
         Transcript cr;
                 show: obj printString;
                 show: ": ";
                 show: count printString].
 ^aBag

3. 文字列処理

C等の "\n" のように文字列に改行を埋め込む。--SHIMADA

→ CharacterArray>>withCRs

文字列中の $\ という文字を改行に置き換える。(CharacterArrayはStringのスーパークラス。)
例:
 'This is sample message\You see?' withCRs
 => 'This is sample message
 You see?'

Class Library

1. GUI 関連のクラスについて

テキストエディタの部品 --SHIMADA

Model: Text
View: ComposedTextView
Controller: ParagraphEditor

(1)いちばん簡単そうな窓の開き方
 ComposedTextView open
上記の欠点: Viewのインスタンスを取り逃がしてしまう

(2) 1 の #open が中でやっていること&Viewを捕まえる
 | aView topView aString aModel anIcon |
 aModel := ValueHolder newString.
 aString := 'My Workspace'.
 anIcon := Icon constantNamed: #workspace.
 topView := ScheduledWindow
 			model: aModel
 			label: aString
 			minimumSize: 200@100.
 topView icon: anIcon.
 aView := ComposedTextView model: aModel.
 topView component: (LookPreferences edgeDecorator on: aView).
 topView open.
 ^aView

(3) String, Text, ComposedText...

文字列(String)は文字(Character)の順序集合。
文章(Text)は文字列(String)の各文字にフォント指定や強調指定が結び付けられたもの。
構成文章(ComposedText)は文章(Text)に文章属性(TextAttributes)が結び付けられたもの。

参照:Smalltalkイディオム 5章「テキスト」

要調査: CharacterBlock
面白機能: ComposedTextView openSystemWorkspace を do it.


Parcels

1. Parcelとは

VWNC30は、parcels, goodies, advanced などのディレクトリに、標準のイメージに含まれていないライブラリが多数添付されている。ライブラリはパーセルという形式で提供され、その実体は hogehoge.pcl, hogehoge.pst という拡張子の二つのファイルからなる。
Jun for Smalltalkもこの形式で提供されている。(「じゅんオールインワンパッケージ」では、既に読み込まれた状態になっている)

それぞれのパーセルは、VisualLauncherのToolsメニューから "Load Parcel Named..." を選択することで読み込むことができる。

いったん読み込んだパーセルを取り外すには、 "Tools > Unload Parcel Named..." を選択する。--SHIMADA

2. 各ライブラリの概要

(1) HotDraw
HotDraw is a two-dimensional graphics framework for structured drawing editors that is written in VisualWorks Smalltalk. (HotDrawはVisualWorks Smalltalkで書かれた、“構造を持つ線画”を編集するソフトウェアを構築するための二次元グラフィックスフレームワークです。)

HotDrawフレームワークの概要については
ftp://st.cs.uiuc.edu/pub/papers/HotDraw/documenting-frameworks.ps の後半部分が参考になる。 --SHIMADA

このページを編集 (4608 bytes)


Congratulations! 以下の 1 ページから参照されています。

This page has been visited 3013 times.