-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce SpCommandGroup>>#asToolbarPresenter and SpCommandGroup>>#as…
…ToolbarPresenterWith: Also add an example and improve the SpCommandGroup class comment.
- Loading branch information
1 parent
cc2b5c8
commit 8f3c737
Showing
3 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
" | ||
I am an example presenter to show how commands can be used as the basis for adding a menubar and a toolbar. | ||
" | ||
Class { | ||
#name : 'SpCommandGroupExample', | ||
#superclass : 'SpPresenter', | ||
#instVars : [ | ||
'menuBar', | ||
'toolBar' | ||
], | ||
#category : 'Spec2-Examples-Demo-CommandGroup', | ||
#package : 'Spec2-Examples', | ||
#tag : 'Demo-CommandGroup' | ||
} | ||
|
||
{ #category : 'commands' } | ||
SpCommandGroupExample class >> buildCommandsGroupWith: presenter forRoot: rootCommandGroup [ | ||
|
||
rootCommandGroup | ||
register: (self buildMenuBarGroupWith: presenter); | ||
register: (self buildToolBarGroupWith: presenter) | ||
] | ||
|
||
{ #category : 'commands' } | ||
SpCommandGroupExample class >> buildMenuBarGroupWith: presenter [ | ||
|
||
^ (CmCommandGroup named: 'MenuBar') asSpecGroup | ||
beRoot; | ||
register: (self buildMenuWith: presenter); | ||
yourself | ||
] | ||
|
||
{ #category : 'commands' } | ||
SpCommandGroupExample class >> buildMenuWith: presenter [ | ||
|
||
^ (CmCommandGroup named: 'Menu') asSpecGroup | ||
register: (SpExampleNewCommand forSpec context: presenter); | ||
yourself | ||
] | ||
|
||
{ #category : 'commands' } | ||
SpCommandGroupExample class >> buildToolBarGroupWith: presenter [ | ||
|
||
^ (CmCommandGroup named: 'ToolBar') asSpecGroup | ||
beRoot; | ||
register: (SpExampleNewCommand forSpec context: presenter); | ||
yourself | ||
] | ||
|
||
{ #category : 'examples' } | ||
SpCommandGroupExample class >> example [ | ||
"This example opens a presenter with a menubar and a toolbar created from commands." | ||
|
||
^ self new open | ||
] | ||
|
||
{ #category : 'layout' } | ||
SpCommandGroupExample >> defaultLayout [ | ||
|
||
^ SpBoxLayout newTopToBottom | ||
] | ||
|
||
{ #category : 'initialization' } | ||
SpCommandGroupExample >> initializeMenuBar [ | ||
|
||
menuBar := (self rootCommandsGroup / 'MenuBar') asMenuBarPresenter | ||
] | ||
|
||
{ #category : 'initialization' } | ||
SpCommandGroupExample >> initializePresenters [ | ||
|
||
super initializePresenters. | ||
self initializeMenuBar. | ||
self initializeToolBar | ||
] | ||
|
||
{ #category : 'initialization' } | ||
SpCommandGroupExample >> initializeToolBar [ | ||
|
||
toolBar := (self rootCommandsGroup / 'ToolBar') asToolbarPresenter | ||
] | ||
|
||
{ #category : 'initialization' } | ||
SpCommandGroupExample >> initializeWindow: aWindowPresenter [ | ||
|
||
super initializeWindow: aWindowPresenter. | ||
aWindowPresenter | ||
title: 'Example with menubar and toolbar based on commands'; | ||
initialExtent: 500@200; | ||
menu: menuBar; | ||
toolbar: toolBar | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
" | ||
I am an example command to create a new thing. | ||
" | ||
Class { | ||
#name : 'SpExampleNewCommand', | ||
#superclass : 'CmCommand', | ||
#category : 'Spec2-Examples-Demo-CommandGroup', | ||
#package : 'Spec2-Examples', | ||
#tag : 'Demo-CommandGroup' | ||
} | ||
|
||
{ #category : 'converting' } | ||
SpExampleNewCommand >> asSpecCommand [ | ||
|
||
^ super asSpecCommand | ||
iconName: #smallNew; | ||
shortcutKey: $n meta; | ||
yourself | ||
] | ||
|
||
{ #category : 'executing' } | ||
SpExampleNewCommand >> execute [ | ||
|
||
self inform: 'This command is not implemented yet.' | ||
] | ||
|
||
{ #category : 'initialization' } | ||
SpExampleNewCommand >> initialize [ | ||
|
||
super initialize. | ||
self | ||
name: 'New'; | ||
description: 'Create a new thing' | ||
] |