Skip to content

Commit

Permalink
add an example with a column for buttons (as this is a frequent need)
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanlm committed Dec 18, 2024
1 parent 468c5ad commit 9a9ebea
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/Spec2-ListView/SpColumnViewPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,58 @@ SpColumnViewPresenter class >> exampleWithIcons [
open
]

{ #category : 'examples' }
SpColumnViewPresenter class >> exampleWithIconsAndButtons [

^ SpColumnViewPresenter new
addColumn: (SpColumnViewColumn new
title: 'Class';
setup: [ :aPresenter |
| presenter |
(presenter := aPresenter newPresenter)
layout: (SpBoxLayout newHorizontal
spacing: 5;
add: presenter newImage expand: false;
add: presenter newLabel;
yourself);
yourself ];
bind: [ :aPresenter :aClass |
| icon image label |
icon := Smalltalk ui icons iconNamed: aClass systemIconName.
image := aPresenter layout children first.
image image: icon.
label := aPresenter layout children second.
label label: aClass name ];
yourself);
addColumn: (SpColumnViewColumn new
title: 'Actions';
width: 60;
setup: [ :aPresenter | | presenter |
(presenter := aPresenter newPresenter)
layout: (SpBoxLayout newHorizontal
hAlignCenter;
add: (presenter newButton
addStyle: 'small';
yourself);
add: (presenter newButton
addStyle: 'small';
icon: (presenter iconNamed: #smallDelete);
yourself);
yourself);
yourself ];
bind: [ :aPresenter :aClass | | button1 button2 |
button1 := aPresenter layout children first.
button1
icon: (aPresenter iconNamed: aClass systemIconName);
action: [ Object inform: aClass name ].
button2 := aPresenter layout children second.
button2
action: [ Object inform: 'Will remove ', aClass name ] ];
yourself);
items: Smalltalk allClassesAndTraits;
open
]

{ #category : 'api' }
SpColumnViewPresenter >> addColumn: aColumn [
"Add a column to the table. A column should be an instance of `SpTableColumn`"
Expand Down

0 comments on commit 9a9ebea

Please sign in to comment.