equal
deleted
inserted
replaced
35 |
35 |
36 ! |
36 ! |
37 |
37 |
38 documentation |
38 documentation |
39 " |
39 " |
40 an icon, a string and an image side by side (from left to right). |
40 an icon, an optional additional image and a string, all by side (from left to right). |
41 Each may be nil (i.e. with nil image, it's a Label-and-Icon proper (icon to the left of the string); |
41 Each may be nil (i.e. with a nil image, it's a Label-and-Icon proper (icon to the left of the string). |
42 with nil icon, it's a string with an image to the right. |
|
43 |
42 |
44 Usable as list entries in a listView (a fileList), as |
43 Usable as list entries in a listView (a fileList), as |
45 popUpMenuItems or as Label/Button image. |
44 popUpMenuItems or as Label/Button image. |
46 |
|
47 This is an example class - currently not used by the system. |
|
48 |
45 |
49 Notice: |
46 Notice: |
50 This is different from ST-80's LabelAndIcon class, which |
47 This is different from ST-80's LabelAndIcon class, which |
51 inherits from Label. Therefore, things may change in the future. |
48 inherits from Label. Therefore, things may change in the future. |
52 |
49 |
129 [exEnd] |
126 [exEnd] |
130 in a selectionInListView: |
127 in a selectionInListView: |
131 [exBegin] |
128 [exBegin] |
132 |top slv wrapper l fileImage dirImage| |
129 |top slv wrapper l fileImage dirImage| |
133 |
130 |
134 dirImage := Image fromFile:'DirObj.xbm'. |
131 dirImage := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/document_images/file_dir.xpm'. |
135 fileImage := Image fromFile:'FileObj.xbm'. |
132 fileImage := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/document_images/file_text.xpm'. |
136 |
133 |
137 |
134 |
138 l := OrderedCollection new. |
135 l := OrderedCollection new. |
139 Filename currentDirectory directoryContents do:[:s | |
136 Filename currentDirectory directoryContents do:[:s | |
140 s asFilename isDirectory ifTrue:[ |
137 s asFilename isDirectory ifTrue:[ |
154 [exEnd] |
151 [exEnd] |
155 in a menu: |
152 in a menu: |
156 [exBegin] |
153 [exBegin] |
157 |top l image1 image2| |
154 |top l image1 image2| |
158 |
155 |
159 image1 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/brazil.xpm'. |
156 image1 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/argentina.xpm'. |
160 image2 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/germany.xpm'. |
157 image2 := Image fromFile:'../../goodies/bitmaps/xpmBitmaps/countries/germany.xpm'. |
161 |
158 |
162 l := OrderedCollection new. |
159 l := OrderedCollection new. |
163 l add:(LabelAndIcon icon:image1 string:'brazil'). |
160 l add:(LabelAndIcon icon:image1 string:'brazil'). |
164 l add:(LabelAndIcon icon:image2 string:'germany'). |
161 l add:(LabelAndIcon icon:image2 string:'germany'). |
165 |
162 |
166 top := View new. |
163 top := StandardSystemView new. |
167 top middleButtonMenu:(PopUpMenu |
164 top middleButtonMenu:(PopUpMenu |
168 labels:l |
165 labels:l |
169 selectors:#(foo bar)). |
166 selectors:#(foo bar)). |
170 |
167 top label:'Try the right-button menu'. |
|
168 top extent:300@300. |
171 top open. |
169 top open. |
172 [exEnd] |
170 [exEnd] |
173 in a button/label: |
171 in a button/label: |
174 [exBegin] |
172 [exBegin] |
175 |top l image| |
173 |top l image| |
388 |
386 |
389 iconHeight := iconValue notNil ifTrue:[iconValue height] ifFalse:[0]. |
387 iconHeight := iconValue notNil ifTrue:[iconValue height] ifFalse:[0]. |
390 imageHeight := imageValue notNil ifTrue:[imageValue height] ifFalse:[0]. |
388 imageHeight := imageValue notNil ifTrue:[imageValue height] ifFalse:[0]. |
391 stringHeight := string size > 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
389 stringHeight := string size > 0 ifTrue:[string heightOn:aGC] ifFalse:[0]. |
392 |
390 |
393 maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
391 "/ maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight. |
|
392 maxHeight := self heightOn:aGC. |
|
393 |
394 x1 := x + offset. |
394 x1 := x + offset. |
395 |
395 |
396 iconValue notNil ifTrue:[ |
396 iconValue notNil ifTrue:[ |
397 y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
397 y1 := y - asc + (maxHeight - iconHeight + 1 // 2). |
398 |
398 |
510 ! ! |
510 ! ! |
511 |
511 |
512 !LabelAndIcon class methodsFor:'documentation'! |
512 !LabelAndIcon class methodsFor:'documentation'! |
513 |
513 |
514 version |
514 version |
515 ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.40 2009-10-20 13:00:44 cg Exp $' |
515 ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.41 2009-10-20 13:21:07 cg Exp $' |
516 ! |
516 ! |
517 |
517 |
518 version_CVS |
518 version_CVS |
519 ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.40 2009-10-20 13:00:44 cg Exp $' |
519 ^ '$Header: /cvs/stx/stx/libwidg2/LabelAndIcon.st,v 1.41 2009-10-20 13:21:07 cg Exp $' |
520 ! ! |
520 ! ! |