~hilaire-fernandes/drgeo/trunk

« back to all changes in this revision

Viewing changes to src/DrGeoII-Polymorph/DrGeoWindow.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 DrGeoWindow is xxxxxxxxx.
 
3
 
 
4
Instance Variables
 
5
        app:            <Object>
 
6
        area:           <Object>
 
7
        curveToolbar:           <Object>
 
8
        macroToolbar:           <Object>
 
9
        miscToolbar:            <Object>
 
10
        numericToolbar:         <Object>
 
11
        pointToolbar:           <Object>
 
12
        statusbar:              <Object>
 
13
        toolbars:               <Object>
 
14
        transformationToolbar:          <Object>
 
15
        sideContainer:  a row alignement morph
 
16
 
 
17
 
 
18
sideContainer 
 
19
        - holds in a row the drawing area and the toolbox to edit object attributes
 
20
 
 
21
app
 
22
        - xxxxx
 
23
 
 
24
area
 
25
        - the drawing area
 
26
 
 
27
curveToolbar
 
28
        - xxxxx
 
29
 
 
30
macroToolbar
 
31
        - xxxxx
 
32
 
 
33
miscToolbar
 
34
        - xxxxx
 
35
 
 
36
numericToolbar
 
37
        - xxxxx
 
38
 
 
39
pointToolbar
 
40
        - xxxxx
 
41
 
 
42
statusbar
 
43
        - xxxxx
 
44
 
 
45
toolbars
 
46
        - xxxxx
 
47
 
 
48
transformationToolbar
 
49
        - xxxxx
 
50
 
 
51
"
 
52
Class {
 
53
        #name : #DrGeoWindow,
 
54
        #superclass : #StandardWindow,
 
55
        #instVars : [
 
56
                'app',
 
57
                'area',
 
58
                'statusbar',
 
59
                'sideContainer',
 
60
                'macroMenu',
 
61
                'scriptMenu',
 
62
                'tree'
 
63
        ],
 
64
        #category : #'DrGeoII-Polymorph'
 
65
}
 
66
 
 
67
{ #category : #'initialize-release' }
 
68
DrGeoWindow class >> for: aDrGeo [ 
 
69
        "A new model with an existing domain. For multiple MVP on a same
 
70
        Domain "
 
71
        ^ super basicNew app: aDrGeo;
 
72
                 initialize
 
73
]
 
74
 
 
75
{ #category : #accessing }
 
76
DrGeoWindow >> app [ 
 
77
        ^ app 
 
78
]
 
79
 
 
80
{ #category : #accessing }
 
81
DrGeoWindow >> app: aDrgeo [
 
82
        app := aDrgeo
 
83
]
 
84
 
 
85
{ #category : #accessing }
 
86
DrGeoWindow >> area [
 
87
        ^ area
 
88
]
 
89
 
 
90
{ #category : #accessing }
 
91
DrGeoWindow >> controls [ 
 
92
        ^ self presenter controlsManager
 
93
]
 
94
 
 
95
{ #category : #'open/close' }
 
96
DrGeoWindow >> delete [
 
97
        (app notNil and: [app isSaved not]) ifTrue: [
 
98
                (self 
 
99
                        questionWithoutCancel: 'Are you sure to close this sketch?' translated 
 
100
                        title: 'Closing sketch' translated) ifFalse: [ ^ self ]].
 
101
        super delete.
 
102
        app ifNotNil: [app release]
 
103
]
 
104
 
 
105
{ #category : #'open/close' }
 
106
DrGeoWindow >> deleteWithoutConfirmation [
 
107
        super delete.
 
108
        app release 
 
109
]
 
110
 
 
111
{ #category : #accessing }
 
112
DrGeoWindow >> domain [
 
113
        ^ app domain 
 
114
]
 
115
 
 
116
{ #category : #services }
 
117
DrGeoWindow >> fileOpen: title extensions: exts path: path preview: preview [
 
118
        "Answer the result of a file open dialog with the given title, extensions to show, path and preview type."
 
119
        |fd|
 
120
        fd := DrGFileDialog basicNew
 
121
                previewType: preview;
 
122
                initialize;
 
123
                title: title;
 
124
                answerOpenFile.
 
125
        exts ifNotNil: [fd validExtensions: exts].
 
126
        path ifNotNil: [fd selectPathName: path].
 
127
        ^ [(self openModal: fd) answer] 
 
128
                on: Error
 
129
                do: [fd answer]
 
130
 
 
131
]
 
132
 
 
133
{ #category : #initialization }
 
134
DrGeoWindow >> initialize [
 
135
        super initialize.
 
136
        self model: self domain.
 
137
        self setLabel: 'Dr. Geo --  ' , Date today yyyymmdd.
 
138
        area := DrGDrawable newOn: app.
 
139
        self setProperty: #morphicLayerNumber toValue: 110.
 
140
]
 
141
 
 
142
{ #category : #testing }
 
143
DrGeoWindow >> isApplication [ 
 
144
        ^true
 
145
]
 
146
 
 
147
{ #category : #testing }
 
148
DrGeoWindow >> isService [
 
149
        ^false
 
150
]
 
151
 
 
152
{ #category : #accessing }
 
153
DrGeoWindow >> macroMenu [
 
154
        ^ macroMenu
 
155
]
 
156
 
 
157
{ #category : #accessing }
 
158
DrGeoWindow >> macroMenu: aMenu [
 
159
        macroMenu := aMenu 
 
160
]
 
161
 
 
162
{ #category : #'*DrGeoII-Polymorph-Widgets' }
 
163
DrGeoWindow >> newTabGroupTool: labelsAndPages [
 
164
"Answer tab grouped tools with a the given tab labels associated with pages of tools"
 
165
        ^(TabGroupToolMorph new
 
166
                font: self theme labelFont;
 
167
                cornerStyle: (self theme tabGroupCornerStyleIn: self);
 
168
                hResizing: #spaceFill;
 
169
                vResizing: #spaceFill;
 
170
                labelsAndPages: labelsAndPages)
 
171
                selectedPageIndex: (labelsAndPages isEmpty ifTrue: [0] ifFalse: [1])
 
172
]
 
173
 
 
174
{ #category : #'*DrGeoII-Polymorph-Widgets' }
 
175
DrGeoWindow >> newTable: controls [
 
176
"Answer a morph laid out with a table of controls, in row and wrapped in column."
 
177
        |answer|
 
178
        answer := PanelMorph new
 
179
                changeTableLayout;
 
180
                cellInset: 2;
 
181
                listDirection: #leftToRight;
 
182
                wrapDirection: #topToBottom;
 
183
                hResizing: #spaceFill;
 
184
                vResizing: #shrinkWrap;
 
185
                fillStyle: Color transparent; "non pane color tracking"
 
186
                cellPositioning: #topLeft.
 
187
        controls do: [:m | answer addMorphBack: m].
 
188
        ^answer
 
189
                        
 
190
]
 
191
 
 
192
{ #category : #'*DrGeoII-Polymorph-Widgets' }
 
193
DrGeoWindow >> openModal: aSystemWindow [
 
194
        DrGDefault ifTablet: [
 
195
                aSystemWindow 
 
196
                        extent: aSystemWindow initialExtent;
 
197
                        topCentered;
 
198
                        activate].
 
199
        ^ super openModal: aSystemWindow.
 
200
]
 
201
 
 
202
{ #category : #menus }
 
203
DrGeoWindow >> popupMenu [ 
 
204
"we don't want the popup menu when using the rich UI"
 
205
]
 
206
 
 
207
{ #category : #accessing }
 
208
DrGeoWindow >> presenter [ 
 
209
        ^ app presenter
 
210
]
 
211
 
 
212
{ #category : #'as yet unclassified' }
 
213
DrGeoWindow >> relabel [
 
214
        | newLabel |
 
215
        newLabel := UIManager default 
 
216
                request: 'New title for this window' translated
 
217
                initialAnswer: app title.
 
218
        newLabel isEmptyOrNil ifTrue: [^self].
 
219
        app isSaved ifFalse: [ newLabel := '* ' , newLabel].
 
220
        self setLabel: newLabel.
 
221
]
 
222
 
 
223
{ #category : #initialization }
 
224
DrGeoWindow >> release [
 
225
        super release.
 
226
        self presenter ifNotNil: [self presenter removeActionsWithReceiver: self].
 
227
        area release.
 
228
        tree release.
 
229
        tree := area := nil.
 
230
        app := nil
 
231
]
 
232
 
 
233
{ #category : #accessing }
 
234
DrGeoWindow >> scriptMenu [
 
235
        ^ scriptMenu
 
236
]
 
237
 
 
238
{ #category : #accessing }
 
239
DrGeoWindow >> scriptMenu: aMenu [
 
240
        scriptMenu := aMenu 
 
241
]
 
242
 
 
243
{ #category : #accessing }
 
244
DrGeoWindow >> setStyler: morph [
 
245
"set a morph to edit the style of an object, it can replace an existing one or add one such morph"
 
246
        sideContainer submorphsDo: [:aMorph|
 
247
                        aMorph class ~= AthensWrapMorph  ifTrue: [sideContainer removeMorph: aMorph]].
 
248
        morph 
 
249
                ifNotNil: [
 
250
                        morph hResizing: #shrinkWrap; vResizing: #spaceFill.
 
251
                        sideContainer submorphs size = 1 ifTrue: [sideContainer addMorph: self newVerticalSeparator].
 
252
                        sideContainer addMorph: morph.
 
253
                        self updatePaneColors]
 
254
]
 
255
 
 
256
{ #category : #accessing }
 
257
DrGeoWindow >> sideContainer [
 
258
        ^ sideContainer
 
259
]
 
260
 
 
261
{ #category : #accessing }
 
262
DrGeoWindow >> sideContainer: aMorph [
 
263
        sideContainer := aMorph
 
264
]
 
265
 
 
266
{ #category : #toolbars }
 
267
DrGeoWindow >> statusMessage: aString [
 
268
        self statusbar submorphs first 
 
269
                contentsWrapped: aString
 
270
]
 
271
 
 
272
{ #category : #toolbars }
 
273
DrGeoWindow >> statusbar [
 
274
        ^ statusbar
 
275
                ifNil: [| statuslabel |
 
276
                        statusbar := self newPanel
 
277
                                cellPositioning: #topRight;
 
278
                                layoutInset: 0;
 
279
                                cellInset: 0.
 
280
                        statuslabel := self newText: ''.
 
281
                        statuslabel autoFit: false;
 
282
                                wrapFlag: true;
 
283
                                vResizing: #spaceFill;
 
284
                                hResizing: #spaceFill.
 
285
"                       statuslabel hasDropShadow: true;
 
286
                                 shadowColor: Color gray;
 
287
                                 shadowOffset: 1 @ 1."
 
288
                        statusbar addMorphBack: statuslabel;
 
289
                                vResizing: #shrinkWrap.
 
290
                        statusbar]
 
291
]
 
292
 
 
293
{ #category : #stepping }
 
294
DrGeoWindow >> step [
 
295
        DrGDefault ifTablet: [
 
296
                "track device rotation"
 
297
                self fullscreen].
 
298
]
 
299
 
 
300
{ #category : #stepping }
 
301
DrGeoWindow >> stepTime [
 
302
        ^ 1000
 
303
 
 
304
]
 
305
 
 
306
{ #category : #services }
 
307
DrGeoWindow >> textEditor: aStringOrText title: aString entryText: defaultEntryText [
 
308
|editor|
 
309
        "Answer the result of a text editor (multiline) dialog ( a string or nil if cancelled)
 
310
        with the given label and title."
 
311
        editor := TextEditorDialogWindow new
 
312
                textFont: self theme textFont;
 
313
                title: aString;
 
314
                text: aStringOrText;
 
315
                entryText: defaultEntryText;
 
316
                entryHeight: 150.
 
317
        DrGDefault ifTablet: [editor topCentered].
 
318
        ^(self openModal: editor) entryText
 
319
]
 
320
 
 
321
{ #category : #services }
 
322
DrGeoWindow >> textEntry: aStringOrText title: aString xEntryText: xEntryText yEntryText: yEntryText [
 
323
        |dialog|
 
324
        dialog := CoordinatesEditorDialog new textFont: self theme textFont;
 
325
                title: aString; text: aStringOrText;
 
326
                xEntryText: xEntryText; yEntryText: yEntryText.
 
327
        DrGDefault ifTablet: [dialog topCentered].
 
328
        "Open a text entry dialog."
 
329
        dialog := self openModal: dialog.
 
330
        ^ {dialog xEntryText . dialog yEntryText}
 
331
]
 
332
 
 
333
{ #category : #accessing }
 
334
DrGeoWindow >> tree [
 
335
        ^ tree
 
336
]
 
337
 
 
338
{ #category : #accessing }
 
339
DrGeoWindow >> tree: aTree [
 
340
        tree := aTree
 
341
]
 
342
 
 
343
{ #category : #stepping }
 
344
DrGeoWindow >> wantsSteps [
 
345
        ^ DrGDefault isTablet
 
346
]
 
347
 
 
348
{ #category : #accessing }
 
349
DrGeoWindow >> wantsToBeTopmost [
 
350
        ^ true
 
351
]