~hilaire-fernandes/drgeo/trunk

« back to all changes in this revision

Viewing changes to src/DrGeoII-Core/DrGWizard.class.st

  • Committer: Hilaire Fernandes
  • Date: 2017-11-15 13:17:03 UTC
  • Revision ID: hilaire.fernandes@gmail.com-20171115131703-pz09obavthi53ebt
DrGeo code under Tonel file format

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"
 
2
A DrGMacroMorph is an abstractact dialog to build and play macro.
 
3
It emits event when 
 
4
 - the user changes the page with the next and previous buttons
 
5
 - the user press apply and cancel
 
6
 
 
7
Instance Variables
 
8
        pages:          dictionary of pages Morph
 
9
 
 
10
pages
 
11
        - xxxxx
 
12
 
 
13
"
 
14
Class {
 
15
        #name : #DrGWizard,
 
16
        #superclass : #DialogWindow,
 
17
        #instVars : [
 
18
                'pages',
 
19
                'currentPage',
 
20
                'panel'
 
21
        ],
 
22
        #category : #'DrGeoII-Core-UI'
 
23
}
 
24
 
 
25
{ #category : #'as yet unclassified' }
 
26
DrGWizard class >> example [
 
27
        "DrGWizard example openInWorld"
 
28
        | wizard |
 
29
        wizard := self new.
 
30
        wizard
 
31
                addPage: ((DrGWizardPage firstPage: 'Step 1/3') model: wizard);
 
32
                addPage: ((DrGWizardPage standardPage: 'Step 2/3') model: wizard;
 
33
                        content: 'We can change content :
 
34
        1. One
 
35
        2. Two
 
36
        3. Three' asTextMorph);
 
37
                addPage: ((DrGWizardPage applyPage: 'Step 3/3') model: wizard).
 
38
        ^ wizard
 
39
]
 
40
 
 
41
{ #category : #accessing }
 
42
DrGWizard >> addPage: aPage [
 
43
        pages add: aPage.
 
44
        currentPage ifNil: 
 
45
                [self panel addMorph: aPage.
 
46
                self title: aPage title.
 
47
                currentPage := 1]
 
48
]
 
49
 
 
50
{ #category : #callback }
 
51
DrGWizard >> apply [
 
52
        self triggerEvent: #apply
 
53
]
 
54
 
 
55
{ #category : #callback }
 
56
DrGWizard >> cancel [
 
57
        self triggerEvent: #cancel
 
58
]
 
59
 
 
60
{ #category : #'meta-actions' }
 
61
DrGWizard >> delete [
 
62
        super delete.
 
63
        pages do: [:page | page delete].
 
64
]
 
65
 
 
66
{ #category : #accessing }
 
67
DrGWizard >> goPage: integer [
 
68
"       (contentMorph findA: DrGWizardPage) ifNotNilDo: 
 
69
                [:page | self removeMorph: page]."
 
70
        self panel removeAllMorphs.
 
71
        self panel addMorph: (self pageAt: integer).
 
72
        self title: (self pageAt: integer) title.
 
73
        self triggerEvent: #page with: integer.
 
74
]
 
75
 
 
76
{ #category : #initialization }
 
77
DrGWizard >> initialExtent [
 
78
        ^DrGDefault wizardExtent
 
79
]
 
80
 
 
81
{ #category : #initialization }
 
82
DrGWizard >> initialize [
 
83
        super initialize.
 
84
        pages := OrderedCollection new.
 
85
]
 
86
 
 
87
{ #category : #testing }
 
88
DrGWizard >> isResizeable [ 
 
89
        ^ true
 
90
]
 
91
 
 
92
{ #category : #actions }
 
93
DrGWizard >> newMainPanel [
 
94
        ^ self panel
 
95
]
 
96
 
 
97
{ #category : #callback }
 
98
DrGWizard >> next [
 
99
        currentPage < pages size ifFalse: [^ self].
 
100
        self goPage: (currentPage := currentPage + 1)
 
101
]
 
102
 
 
103
{ #category : #accessing }
 
104
DrGWizard >> pageAt: integer [
 
105
        ^ pages at: integer 
 
106
]
 
107
 
 
108
{ #category : #initialization }
 
109
DrGWizard >> pageModel [
 
110
        |page|
 
111
        page := Morph new color: Color transparent .
 
112
        page
 
113
                layoutPolicy: TableLayout new;
 
114
                listDirection: #bottomToTop;
 
115
                cellPositioning: #topLeft;
 
116
                layoutInset: 0@3;
 
117
                cellInset: 0@5.
 
118
        ^ page
 
119
]
 
120
 
 
121
{ #category : #actions }
 
122
DrGWizard >> panel [
 
123
        ^ panel ifNil: [ panel := self newDialogPanel]
 
124
]
 
125
 
 
126
{ #category : #callback }
 
127
DrGWizard >> previous [
 
128
        currentPage > 1 ifFalse: [^self].
 
129
        self goPage: (currentPage := currentPage - 1)
 
130
]