From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:47:04 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <class> <name>Editor1Example</name> <environment>Examples</environment> <super>UI.ApplicationModel</super> <private>false</private> none classes comment textStyle readOnly <imports></imports> <category>Examples-Help</category> <attributes> <package>Editor1-Example</package> </attributes> </class> <comment> Examples.Editor1Example
Editor1Example demonstrates various techniques related to working with a Text Editor widget, including changing, editing, and formatting the text displayed in the editor.
</comment> <methods> Examples.Editor1Example <category>actions</category>
alignCenter | widget style | widget := (self builder componentAt: #comment) widget. style := widget textStyle copy. style alignment: 2. widget textStyle: style. widget invalidate.
alignLeft | widget style | widget := (self builder componentAt: #comment) widget. style := widget textStyle copy. style alignment: 0. widget textStyle: style. widget invalidate.
alignRight | widget style | widget := (self builder componentAt: #comment) widget. style := widget textStyle copy. style alignment: 1. widget textStyle: style. widget invalidate.
</methods> <methods> Examples.Editor1Example <category>change messages</category>
changedClass "When the list selection changes, update the comment view." | selectedClass txt start wrapper | selectedClass := self classes selection. selectedClass isNil ifTrue: [self comment value: '' asText] ifFalse: [ txt := (selectedClass asQualifiedReference value) comment. self comment value: txt. "Find and highlight the class name in the text." start := txt indexOfSubCollection: selectedClass asString startingAt: 1. start > 0 ifTrue: [ wrapper := (self builder componentAt: #comment). wrapper widget controller selectAndScrollFrom: start to: start + selectedClass asString size - 1. wrapper takeKeyboardFocus]].
changedReadOnly | c | c := (self builder componentAt: #comment) widget controller. c readOnly: (self readOnly value).
changedStyle "A text style was selected -- apply it to the current selection in the comment." | c selectedText style | "Get the selected text." c := (builder componentAt: #comment) widget controller. selectedText := c selection. "If nothing is selected, take no action." selectedText isEmpty ifTrue: [^self]. "If 'Plain' was selected, remove all emphases; otherwise add the new emphasis." style := self textStyle value. style == #plain ifTrue: [selectedText emphasizeAllWith: nil] ifFalse: [ selectedText addEmphasis: (Array with: style) removeEmphasis: nil allowDuplicates: false]. "Ask the controller to insert the modified text, then update the view." c replaceSelectionWith: selectedText. c view resetSelections. c view invalidate.
</methods> <methods> Examples.Editor1Example <category>aspects</category>
classes ^classes
comment ^comment
readOnly ^readOnly
textStyle ^textStyle
</methods> <methods> Examples.Editor1Example <category>initialize-release</category>
initialize super initialize. comment := '' asValue. classes := SelectionInList with: Core classNames. classes selectionIndexHolder onChangeSend: #changedClass to: self. textStyle := #plain asValue. textStyle onChangeSend: #changedStyle to: self. readOnly := false asValue. readOnly onChangeSend: #changedReadOnly to: self.
</methods> <methods> Examples.Editor1Example class <category>resources</category>
alignCenterImage ^(ToolbarIconLibrary visualFor: #alignVCenter)
alignLeftImage ^(ToolbarIconLibrary visualFor: #alignLeft)
alignRightImage ^(ToolbarIconLibrary visualFor: #alignRight)
textStylesMenu "UIMenuEditor new openOnClass: self andSelector: #textStylesMenu" | mb | mb := MenuBuilder new. mb add: 'Plain' -> #plain; add: 'Bold' -> #bold; add: 'Italic' -> #italic; add: 'Underlined' -> #underline. ^mb menu
</methods> <methods> Examples.Editor1Example class <category>interface specs</category>
windowSpec "UIPainter new openOnClass: self andSelector: #windowSpec" <resource: #canvas> ^#(#{UI.FullSpec} #window: #(#{UI.WindowSpec} #label: 'Editor1Example' #min: #(#{Core.Point} 497 262 ) #max: #(#{Core.Point} 1128 900 ) #bounds: #(#{Graphics.Rectangle} 800 600 1297 1010 ) ) #component: #(#{UI.SpecCollection} #collection: #( #(#{UI.TextEditorSpec} #layout: #(#{Graphics.LayoutFrame} 0 0.249497 60 0 0 0.995976 0 0.997561 ) #name: #comment #model: #comment #tabRequiresControl: true ) #(#{UI.LabelSpec} #layout: #(#{Graphics.LayoutOrigin} 5 0.25 40 0 ) #label: 'Class Comment' ) #(#{UI.SequenceViewSpec} #layout: #(#{Graphics.LayoutFrame} 1 0 60 0 0 0.25 -1 1 ) #flags: 15 #model: #classes ) #(#{UI.LabelSpec} #layout: #(#{Core.Point} 5 40 ) #label: 'Class Names' ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.LayoutFrame} 47 0.25 5 0 69 0.25 27 0 ) #model: #alignLeft #label: #alignLeftImage #hasCharacterOrientedLabel: false ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.LayoutFrame} 73 0.25 5 0 95 0.25 27 0 ) #model: #alignCenter #label: #alignCenterImage #hasCharacterOrientedLabel: false ) #(#{UI.ActionButtonSpec} #layout: #(#{Graphics.LayoutFrame} 98 0.25 5 0 120 0.25 27 0 ) #model: #alignRight #label: #alignRightImage #hasCharacterOrientedLabel: false ) #(#{UI.MenuButtonSpec} #layout: #(#{Graphics.LayoutFrame} 140 0.25 5 0 222 0.25 23 0 ) #model: #textStyle #label: 'Styles' #menu: #textStylesMenu ) #(#{UI.CheckBoxSpec} #layout: #(#{Graphics.LayoutOrigin} 252 0.25 4 0 ) #model: #readOnly #label: 'Read Only' ) ) ) )
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>ApplicationModel</name> <environment>UI</environment> <super>UI.Model</super> <private>false</private> none builder uiSession eventHandlers savedWindowInformation <imports></imports> <category>UIBuilder-Framework</category> <attributes> <package>UIBuilder-Framework</package> </attributes> </class>