The Trunk: ToolBuilder-Morphic-Igor.Stasenko.48.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: ToolBuilder-Morphic-Igor.Stasenko.48.mcz

commits-2
Andreas Raab uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-Igor.Stasenko.48.mcz

==================== Summary ====================

Name: ToolBuilder-Morphic-Igor.Stasenko.48
Author: Igor.Stasenko
Time: 17 January 2010, 4:24:22.823 am
UUID: 37836639-4c82-424d-b97e-b2452c7fdecc
Ancestors: ToolBuilder-Morphic-nice.47

- placed a widget classes, used by MorphicToolBuilder
into separate methods.
So, one could subclass the MorphicToolBuilder and use different widgets, while retaining rest of building logic

=============== Diff against ToolBuilder-Morphic-nice.47 ===============

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableWindow: (in category 'pluggable widgets') -----
  buildPluggableWindow: aSpec
  | widget children label |
  aSpec layout == #proportional ifFalse:[
  "This needs to be implemented - probably by adding a single pane and then the rest"
  ^self error: 'Not implemented'.
  ].
+ widget := self windowClass new.
- widget := PluggableSystemWindow new.
  self register: widget id: aSpec name.
  widget model: aSpec model.
  (label := aSpec label) ifNotNil:[
  label isSymbol
  ifTrue:[widget getLabelSelector: label]
  ifFalse:[widget setLabel: label]].
  children := aSpec children.
  children isSymbol ifTrue:[
  widget getChildrenSelector: children.
  widget update: children.
  children := #().
  ].
  widget closeWindowSelector: aSpec closeAction.
  panes := OrderedCollection new.
  self buildAll: children in: widget.
  widget bounds: (RealEstateAgent
  initialFrameFor: widget
  initialExtent: (aSpec extent ifNil:[widget initialExtent])
  world: self currentWorld).
  widget setUpdatablePanesFrom: panes.
  ^widget!

Item was added:
+ ----- Method: MorphicToolBuilder>>menuItemClass (in category 'widget classes') -----
+ menuItemClass
+ ^ MenuItemMorph!

Item was added:
+ ----- Method: MorphicToolBuilder>>menuClass (in category 'widget classes') -----
+ menuClass
+ ^ MenuMorph!

Item was added:
+ ----- Method: MorphicToolBuilder>>windowClass (in category 'widget classes') -----
+ windowClass
+ ^ PluggableSystemWindow!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableList: (in category 'pluggable widgets') -----
  buildPluggableList: aSpec
  | widget listClass getIndex setIndex |
  aSpec getSelected ifNil:[
+ listClass := self listClass.
- listClass := PluggableListMorphPlus.
  getIndex := aSpec getIndex.
  setIndex := aSpec setIndex.
  ] ifNotNil:[
+ listClass := self listByItemClass.
- listClass := PluggableListMorphByItemPlus.
  getIndex := aSpec getSelected.
  setIndex := aSpec setSelected.
  ].
  widget := listClass on: aSpec model
  list: aSpec list
  selected: getIndex
  changeSelected: setIndex
  menu: aSpec menu
  keystroke: aSpec keyPress.
  self register: widget id: aSpec name.
  widget doubleClickSelector: aSpec doubleClick.
  widget dragItemSelector: aSpec dragItem.
  widget dropItemSelector: aSpec dropItem.
  widget wantsDropSelector: aSpec dropAccept.
  widget autoDeselect: aSpec autoDeselect.
  self setFrame: aSpec frame in: widget.
  parent ifNotNil:[self add: widget to: parent].
  panes ifNotNil:[
  aSpec list ifNotNil:[panes add: aSpec list].
  ].
  ^widget!

Item was added:
+ ----- Method: MorphicToolBuilder>>codePaneClass (in category 'widget classes') -----
+ codePaneClass
+ ^ PluggableTextMorphPlus!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableText: (in category 'pluggable widgets') -----
  buildPluggableText: aSpec
  | widget |
+ widget := self textPaneClass on: aSpec model
- widget := PluggableTextMorphPlus on: aSpec model
  text: aSpec getText
  accept: aSpec setText
  readSelection: aSpec selection
  menu: aSpec menu.
  widget askBeforeDiscardingEdits: aSpec askBeforeDiscardingEdits.
  widget font: Preferences standardCodeFont.
  self register: widget id: aSpec name.
  widget getColorSelector: aSpec color.
  self setFrame: aSpec frame in: widget.
  parent ifNotNil:[self add: widget to: parent].
  widget borderColor: Color lightGray.
  widget color: Color white.
  ^widget!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableMultiSelectionList: (in category 'pluggable widgets') -----
  buildPluggableMultiSelectionList: aSpec
  | widget listClass |
  aSpec getSelected ifNotNil:[^self error:'There is no PluggableListMorphOfManyByItem'].
+ listClass := self multiSelectListClass.
- listClass := PluggableListMorphOfMany.
  widget := listClass on: aSpec model
  list: aSpec list
  primarySelection: aSpec getIndex
  changePrimarySelection: aSpec setIndex
  listSelection: aSpec getSelectionList
  changeListSelection: aSpec setSelectionList
  menu: aSpec menu.
  self register: widget id: aSpec name.
  widget keystrokeActionSelector: aSpec keyPress.
  self setFrame: aSpec frame in: widget.
  parent ifNotNil:[self add: widget to: parent].
  panes ifNotNil:[
  aSpec list ifNotNil:[panes add: aSpec list].
  ].
  ^widget!

Item was added:
+ ----- Method: MorphicToolBuilder>>textPaneClass (in category 'widget classes') -----
+ textPaneClass
+ ^ PluggableTextMorphPlus!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableCodePane: (in category 'pluggable widgets') -----
  buildPluggableCodePane: aSpec
  "Install the default styler for code panes.
  Implementation note: We should just be doing something like, e.g.,
  ^(self buildPluggableText: aSpec) useDefaultStyler
  Unfortunately, this will retrieve and layout the initial text twice which
  can make for a noticable performance difference when looking at some
  larger piece of code. So instead we copy the implementation from
  buildPlugggableText: here and insert #useDefaultStyler at the right point"
  | widget |
+ widget := self codePaneClass new.
- widget := PluggableTextMorphPlus new.
  widget useDefaultStyler.
  widget on: aSpec model
  text: aSpec getText
  accept: aSpec setText
  readSelection: aSpec selection
  menu: aSpec menu.
  widget font: Preferences standardCodeFont.
  self register: widget id: aSpec name.
  widget getColorSelector: aSpec color.
  self setFrame: aSpec frame in: widget.
  parent ifNotNil:[self add: widget to: parent].
  widget borderColor: Color lightGray.
  widget color: Color white.
  ^widget!

Item was added:
+ ----- Method: MorphicToolBuilder>>multiSelectListClass (in category 'widget classes') -----
+ multiSelectListClass
+ ^ PluggableListMorphOfMany!

Item was added:
+ ----- Method: MorphicToolBuilder>>treeClass (in category 'widget classes') -----
+ treeClass
+ ^ PluggableTreeMorph!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggablePanel: (in category 'pluggable widgets') -----
  buildPluggablePanel: aSpec
  | widget children |
+ widget := self panelClass new.
- widget := PluggablePanelMorph new.
  self register: widget id: aSpec name.
  widget model: aSpec model.
  widget color: Color transparent.
  widget clipSubmorphs: true.
  children := aSpec children.
  children isSymbol ifTrue:[
  widget getChildrenSelector: children.
  widget update: children.
  children := #().
  ].
  self buildAll: children in: widget.
  self setFrame: aSpec frame in: widget.
  parent ifNotNil:[self add: widget to: parent].
  self setLayout: aSpec layout in: widget.
  widget layoutInset: 0.
  widget borderWidth: 0.
  widget submorphsDo:[:sm| | frame |
  (frame := sm layoutFrame) ifNotNil:[
  (frame rightFraction = 0 or:[frame rightFraction = 1])
  ifFalse:[frame rightOffset:1].
  (frame bottomFraction = 0 or:[frame bottomFraction = 1])
  ifFalse:[frame bottomOffset: 1]]].
  widget color: Color transparent.
  ^widget!

Item was added:
+ ----- Method: MorphicToolBuilder>>listClass (in category 'widget classes') -----
+ listClass
+ ^ PluggableListMorphPlus!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableMenu: (in category 'building') -----
  buildPluggableMenu: menuSpec
  | prior menu |
  prior := parentMenu.
+ parentMenu := menu := self menuClass new.
- parentMenu := menu := MenuMorph new.
  menuSpec label ifNotNil:[parentMenu addTitle: menuSpec label].
  menuSpec items do:[:each| each buildWith: self].
  parentMenu := prior.
  ^menu!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableTree: (in category 'pluggable widgets') -----
  buildPluggableTree: aSpec
  | widget |
+ widget := self treeClass new.
- widget := PluggableTreeMorph new.
  self register: widget id: aSpec name.
  widget model: aSpec model.
  widget getSelectedPathSelector: aSpec getSelectedPath.
  widget setSelectedSelector: aSpec setSelected.
  widget getChildrenSelector: aSpec getChildren.
  widget hasChildrenSelector: aSpec hasChildren.
  widget getLabelSelector: aSpec label.
  widget getIconSelector: aSpec icon.
  widget getHelpSelector: aSpec help.
  widget getMenuSelector: aSpec menu.
  widget keystrokeActionSelector: aSpec keyPress.
  widget getRootsSelector: aSpec roots.
  widget autoDeselect: aSpec autoDeselect.
  widget dropItemSelector: aSpec dropItem.
  widget wantsDropSelector: aSpec dropAccept.
  self setFrame: aSpec frame in: widget.
  parent ifNotNil:[self add: widget to: parent].
  " panes ifNotNil:[
  aSpec roots ifNotNil:[panes add: aSpec roots].
  ]. "
  ^widget!

Item was added:
+ ----- Method: MorphicToolBuilder>>buttonClass (in category 'widget classes') -----
+ buttonClass
+ ^ PluggableButtonMorphPlus!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableButton: (in category 'pluggable widgets') -----
  buildPluggableButton: aSpec
  | widget label state action enabled |
  label := aSpec label.
  state := aSpec state.
  action := aSpec action.
+ widget := self buttonClass on: aSpec model
- widget := PluggableButtonMorphPlus on: aSpec model
  getState: (state isSymbol ifTrue:[state])
  action: nil
  label: (label isSymbol ifTrue:[label]).
  self register: widget id: aSpec name.
  enabled := aSpec enabled.
  enabled isSymbol
  ifTrue:[widget getEnabledSelector: enabled]
  ifFalse:[widget enabled:enabled].
  widget action: action.
  widget getColorSelector: aSpec color.
  widget offColor: Color white..
  aSpec help ifNotNil:[widget setBalloonText: aSpec help].
  (label isSymbol or:[label == nil]) ifFalse:[widget label: label].
  self setFrame: aSpec frame in: widget.
  parent ifNotNil:[self add: widget to: parent].
  ^widget!

Item was added:
+ ----- Method: MorphicToolBuilder>>panelClass (in category 'widget classes') -----
+ panelClass
+ ^ PluggablePanelMorph!

Item was added:
+ ----- Method: MorphicToolBuilder>>listByItemClass (in category 'widget classes') -----
+ listByItemClass
+ ^ PluggableListMorphByItemPlus!

Item was changed:
  ----- Method: MorphicToolBuilder>>buildPluggableMenuItem: (in category 'building') -----
  buildPluggableMenuItem: itemSpec
  | item action label menu |
+ item := self menuItemClass new.
- item := MenuItemMorph new.
  label := itemSpec label.
  itemSpec checked ifTrue:[label := '<on>', label] ifFalse:[label := '<off>', label].
  item contents: label.
  item isEnabled: itemSpec enabled.
  (action := itemSpec action) ifNotNil:[
  item
  target: action receiver;
  selector: action selector;
  arguments: action arguments.
  ].
  (menu := itemSpec subMenu) ifNotNil:[
  item subMenu: (menu buildWith: self).
  ].
  parentMenu ifNotNil:[parentMenu addMorphBack: item].
  itemSpec separator ifTrue:[parentMenu addLine].
  ^item!