-
Notifications
You must be signed in to change notification settings - Fork 7
/
StyledTextNotebook.pck.st
108 lines (94 loc) · 3.97 KB
/
StyledTextNotebook.pck.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'From Cuis 5.0 [latest update: #4362] on 24 August 2020 at 12:22:52 pm'!
'Description Please enter a description for this package.'!
!provides: 'StyledTextNotebook' 1 4!
!requires: 'StyledText' 1 nil nil!
SystemOrganization addCategory: #StyledTextNotebook!
!classDefinition: #BpStyledTextNotebook category: #StyledTextNotebook!
Object subclass: #BpStyledTextNotebook
instanceVariableNames: ''
classVariableNames: 'AppMorph Filename MyModel SaveIcon'
poolDictionaries: ''
category: 'StyledTextNotebook'!
!classDefinition: 'BpStyledTextNotebook class' category: #StyledTextNotebook!
BpStyledTextNotebook class
instanceVariableNames: ''!
!BpStyledTextNotebook class methodsFor: 'StyledText Notebook' stamp: 'jmv 5/31/2016 11:15'!
startUp
[
MyModel _ Filename asFileEntry readStreamDo: [ :strm |
(SmartRefStream on: strm) next ].
AppMorph submorphs first
model: MyModel;
possiblyChanged
] on: FileDoesNotExistException do: nil.! !
!BpStyledTextNotebook class methodsFor: 'StyledText Notebook' stamp: 'jmv 8/23/2020 21:35:23'!
createModelAndView
"
BpStyledTextNotebook createModelAndView
"
| saveButton topRow w |
MyModel _ StyledTextModel new.
AppMorph _ PluggableStyledTextMorph withModel: MyModel in: STEMainMorph newColumn.
AppMorph adoptWidgetsColor: MyModel class windowColor.
saveButton _ (PluggableButtonMorph model: self action: #save)
morphExtent: 22@22;
icon: self saveIcon;
layoutSpec: LayoutSpec keepMorphExtent;
yourself.
topRow _ AppMorph submorphs last.
topRow addMorphBack: saveButton.
w _ PasteUpMorph someInstance.
AppMorph morphPositionInWorld: 0@0; morphExtentInWorld: w morphExtentInWorld.
w addMorph: AppMorph.
AppMorph startStepping! !
!BpStyledTextNotebook class methodsFor: 'StyledText Notebook' stamp: 'jmv 9/11/2013 00:33'!
install
"
BpStyledTextNotebook install
Preferences enable: #focusFollowsMouse
"
| newName |
Preferences disable: #focusFollowsMouse.
Preferences disable: #commandClickOpensHalo.
Smalltalk addToStartUpList: self.
Filename _ 'StyledText.object'.
PasteUpMorph allInstancesDo: [ :w |
w submorphs copy do: [ :m | m delete ].
w color: Color white ].
self createModelAndView.
"Save image"
newName _ 'StyledTextEditor.image'.
"
(SourceFiles at: 2) ifNotNil: [
Smalltalk
closeSourceFiles; ""so copying the changes file will always work""
saveChangesInFileNamed: (Smalltalk fullNameForChangesNamed: newName)].
Smalltalk saveImageInFileNamed: newName
"
Smalltalk saveAs: newName! !
!BpStyledTextNotebook class methodsFor: 'StyledText Notebook' stamp: 'jmv 1/6/2012 14:17'!
save
"Maybe we're still saving too much...
Besides, check if new instances of ParagraphStyle et al are created on startup..."
MyModel saveAs: Filename! !
!BpStyledTextNotebook class methodsFor: 'StyledText Notebook' stamp: 'jmv 3/11/2011 17:39'!
saveIcon
"Created using:
Clipboard default storeObject:
((PNGReadWriter bytesFor: (Form fromFileNamed: 'Save.png')) asString base64Encoded)
"
SaveIcon ifNil: [ SaveIcon _ Form fromBinaryStream: 'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAACjElEQVR4Xq3UXUhaYRwG8HNd
aZmk6WrmGkbWytJdlJgTuq3RaAPJm9ZY+wrHYrYPvPNqI02Z0EZjFycH3W6apqkgxDZiW4PR
xQi2XeximbAgkNHFM/9vKOcgywkTHt9zDs/58Z7X98il02mk/2M4+pqfn4fb7cbg4CB8Ph+m
bs3BMjpVlqHzV0u54nzAugaDAcPDw7gwNnYEplIpTE9P4/nSEsxmMw4PD8FHt3Dp3stjQx3q
6vV6nLNaoVQqQRYDR0dGMOdyoaOjA/l8vqooFQroOzshk8mOwGQyCevQEBwTE1Cr1Tg4OKgq
BGm1WkilUpDFra+vw2KxwG63Q61SYX9/H5lMBsFg8NhQh7qyhgZo29oYSBaXSCREYC6XqypC
kCwuHo+LwGw2y6bu9/uPDXWoKwTJ4tbW1kTg7u5uxfwUHAtBssrAlZWVf0Ip1C0DY7FYCdTp
dJA3NlYV2n9FkCwRaDIacbq9vapoNBoxGI1Gy8BHjxfw/uM2y+ftHXz9/gN7e78KG/k36LPM
L+OsyYQz3d0ikCxudXW1DCxCPB/Cxpu3JYhGgr/sfGM9QoUgWQwcGBjAxfFxGPv7WbE4o9ra
WhYh9G7zE5Kpjb+DkUgE3YWp22w2VjpVeI2KMyqukxCKxtJ4HUkwqLenBydbW9mxRCIBWVw4
HMaJwjvc1dXF3mVVc3NpRq0tLSxCiEY6l8vlDFI0NbFfmp6ELI7neVyenGR7sL6+HnV1ddj8
sMXW0FhY074+owh6FY7j6bMXqKmpYY9JfRrpnCwuEAjA6/XC4XCwix6PB665hyzXrs/gxk0n
ZpyzuH3Hhdm799l178ITdg916R5Kf2H9yeJCoRAWFxcr/rtUChlk/QGoFPNClwN64wAAAABJ
RU5ErkJggg==' base64Decoded asByteArray readStream ].
^SaveIcon! !