-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathHowTo.pillar
More file actions
167 lines (129 loc) · 4.7 KB
/
HowTo.pillar
File metadata and controls
167 lines (129 loc) · 4.7 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
!! Focus Order
default is the one of the layout tree
If you want to change it
[[[
initializePresenters
self initializePackageList.
self initializeClassList.
self initializeProtocolList.
self initializeSelectorList.
self initializeMethodBodyPane.
showClassSide := self newCheckBox.
showClassSide label: 'Class side'.
showClassSide state: false.
"this is optional because it is the order of definition
in the layout"
self focusOrder
add: packages;
add: classes;
add: protocols;
add: selectors;
add: method
]]]
[[[
defaultSpec
<spec: #default>
^ SpBoxLayout
newTopToBottom
add:
( SpBoxLayout newLeftToRight
add:
(SpBoxLayout newTopToBottom
add: #packages;
add: #showClassSide height: 16;
yourself);
add: #classes;
add: #protocols;
add: #selectors ;
yourself);
add: #method;
yourself
]]]
[[[
initializePresenters
self initializePackageList.
self initializeClassList.
self initializeProtocolList.
self initializeSelectorList.
self initializeMethodBodyPane.
showClassSide := self newCheckBox.
showClassSide label: 'Class side'.
showClassSide state: false
]]]
!! Menu
aPresenter actions: anActionGroup
!! Style
Each presenter can add a style to the application style.
so, you want the text box to have a size, not the text inside?
then you need to add a style
textPresenter addStyle: 'aStyleName'
the only real problem here is that styles need to be defined at "startup" time of your application
you can check StPharoApplication as inspiration
it had this method:
resetConfiguration
self flag: #TODO. "Replace this with a proper initialization mechanism (which is not
implemented at the moment, and we need to choose the backend from it)"
self class environment
at: #StPharoMorphicConfiguration
ifPresent: [ :aClass | self useBackend: #Morphic with: aClass new ]
which is a bit overcomplicated
but is to avoid false dependencies reports
then the class: StPharoMorphicConfiguration has this methods:
StPharoMorphicConfiguration >> configureOSX: anApplication
anApplication styleSheet: (self styleSheet, self styleSheetOSX)
StPharoMorphicConfiguration >> styleSheetOSX
"Just an example on how to build styles programatically ;)"
^ SpStyle newApplication
addClass: 'label' with: [ :label |
label addClass: 'shortcut' with: [ :shortcut |
shortcut addPropertyFontWith: [ :font |
font name: 'Lucida Grande'; size: 10 ] ] ];
yourself
So you could have
MyAppMorphicConfiguration >> myStyleSheet
^ SpStyleSTONReader fromString: '
.application [
.aStyleName [
Geometry {
#height: 100,
#width: 100,
#vResizing: false,
#hResizing: false }
]
]
'
which I know seems overwhelming for your small problem, but take into account this is the attempt of a general solution to style applications :wink:
cool part is, once you define your stylesheet, changing appearances and/or sizes is just adding the desired style(s) to your widget.
for example, for a personal project I have this extension method on SpPresenter :
newSmallButton
^ self newButton
"addStyle: 'flat';"
addStyle: 'smallButton';
addStyle: 'smallFont';
addStyle: 'dim';
yourself
!! Icon
n Spec we recently introduced the icon provider hierarchy
where you can define your own (by inheritance)
but we provide a couple of interesting pre-defined providers
SpPharoThemeIconProvider will delegate to the current system icons (Same as doing Smalltalk ui icons)
SpLocationIconProvider will alloyou to add a location (you can actually have a list of locations) from where to get your icons (externally to the image)
and SpCompositeIconProvider will allow you to compose providers, so you can do things like : myLocationProvider, defaultProvider
SpApplication defines the methods
iconNamed:, iconProvider and newIconProvider which you can play to provide your own
e.g. StPharoApplication defines
newIconProvider
[[[
^ StPharoDefaultIconProvider new
and as an example, for the same application I have the newSmallButton extension, I have
newIconProvider
^ (SpLocationIconProvider newLocation: self iconsDir),
SgaGtkThemeIconProvider new
so... the trick is again based on the correct definition of your application
btw, my "iconsDir" method is defined like this (is temporal) :
iconsDir
self flag: #TODO. "Refactor this into a production/development environments"
IceRepository registry
detect: [ :each | each name = 'Crono' ]
ifFound: [ :each | ^ each location / 'resources' / 'icons' ].
^ FileLocator imageDirectory / 'resources' / 'icons'