Label.st
author Claus Gittinger <cg@exept.de>
Tue, 16 Jan 1996 03:04:32 +0100
changeset 289 82d20a3e2fe8
parent 275 a7f95252cdc2
child 303 8408cec09472
permissions -rw-r--r--
dont grab if no menu pulled
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
View subclass:#Label
254
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
    14
	instanceVariableNames:'logo labelWidth labelHeight labelOriginX labelOriginY adjust
250
77012e65ac84 draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    15
		hSpace vSpace bgColor fgColor fixSize labelMsg converter
77012e65ac84 draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
    16
		labelChannel foregroundChannel backgroundChannel'
254
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
    17
	classVariableNames:'DefaultFont DefaultForegroundColor DefaultBackgroundColor'
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
    18
	poolDictionaries:''
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
    19
	category:'Views-Layout'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
3
claus
parents: 0
diff changeset
    22
!Label class methodsFor:'documentation'!
claus
parents: 0
diff changeset
    23
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    24
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    25
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    26
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
    27
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    28
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    29
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    30
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    32
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    33
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    34
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    35
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    36
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    37
3
claus
parents: 0
diff changeset
    38
documentation
claus
parents: 0
diff changeset
    39
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    40
    This class implements labels, which are views to display a string or image.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    41
    The Label will try to do its best to make its contents fit into the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    42
    view. The contents can be a String, a collection of Strings (i.e.
118
claus
parents: 113
diff changeset
    43
    a StringCollection) or a Form/Image. 
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    44
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    45
    The contents is drawn in fgColor/bgColor, which can be changed using:
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    46
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
    47
	aLabel foregroundColor:aColor
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
    48
	aLabel backgroundColor:aColor
3
claus
parents: 0
diff changeset
    49
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    50
    When a label is assigned a contents, it will resize itself to fit
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    51
    the required size. This resizing can be suppressed by setting the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    52
    fixsize attribute to true using:
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    53
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
    54
	aLabel sizeFixed:true
3
claus
parents: 0
diff changeset
    55
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    56
    This can be used, if resizing of the label is not wanted.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    57
    However, in this case you have to make certain that the size is big enough
118
claus
parents: 113
diff changeset
    58
    to hold any changed logos later. (usually, you create the label first with
claus
parents: 113
diff changeset
    59
    the longest string first to have it compute its size, then set the fixSize 
claus
parents: 113
diff changeset
    60
    attribute to avoid resizing later).
125
claus
parents: 118
diff changeset
    61
    Be careful when placing self-resizing labels into panels - by default,
claus
parents: 118
diff changeset
    62
    panels do not react on the size change - leading to ugly looking geometry.
claus
parents: 118
diff changeset
    63
    (but you can tell the panel to watch for changes with #elementsCHangeSize:)
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    64
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    65
    The placement of the contents within the label is controlled by
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    66
    the adjust attribute, it can be set with:
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    67
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
    68
	aLabel adjust:how
3
claus
parents: 0
diff changeset
    69
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    70
    where how is one of the symbols left, #right, #center, #centerLeft or
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    71
    #centerRight (see the comment in Label>>adjust:). The default is #center.
3
claus
parents: 0
diff changeset
    72
145
claus
parents: 144
diff changeset
    73
    model-less operation (ok for static labels):
118
claus
parents: 113
diff changeset
    74
      if no model is set, the labels contents is set with:
claus
parents: 113
diff changeset
    75
claus
parents: 113
diff changeset
    76
	aLabel label:aStringOrImage
claus
parents: 113
diff changeset
    77
claus
parents: 113
diff changeset
    78
      and stays constant unless changed by new calls to #label:.
claus
parents: 113
diff changeset
    79
claus
parents: 113
diff changeset
    80
145
claus
parents: 144
diff changeset
    81
    model operation (ST-80 style):
118
claus
parents: 113
diff changeset
    82
      labels with a model, aspectMsg and labelMsg react to 
claus
parents: 113
diff changeset
    83
      changes of the aspect, and send a labelMsg-message 
claus
parents: 113
diff changeset
    84
      to the model in order to aquire a new labelString or image.
claus
parents: 113
diff changeset
    85
      The model should send 'self changed:aspectMsg' if it thinks the label 
claus
parents: 113
diff changeset
    86
      should change and return a string or image from the labelMsg-message.
claus
parents: 113
diff changeset
    87
claus
parents: 113
diff changeset
    88
	label model:aModel.
claus
parents: 113
diff changeset
    89
	label aspect:aspectSymbol.
claus
parents: 113
diff changeset
    90
	label labelMessage:labelSymbol.
claus
parents: 113
diff changeset
    91
claus
parents: 113
diff changeset
    92
	model sends #changed:aspectSymbol
claus
parents: 113
diff changeset
    93
	---> label will redraw its label from value of model perform:labelSymbol
claus
parents: 113
diff changeset
    94
claus
parents: 113
diff changeset
    95
      Having a labelSymbol different from the aspectSymbol allows for two labels
claus
parents: 113
diff changeset
    96
      to react on the same aspect-change, but use different messages when asking
claus
parents: 113
diff changeset
    97
      the model for a new label contents. By default, the labelMsg is nil,
claus
parents: 113
diff changeset
    98
      so the label does NOT update its shown contents.
claus
parents: 113
diff changeset
    99
      The aspectMsg defaults to #value.
claus
parents: 113
diff changeset
   100
125
claus
parents: 118
diff changeset
   101
145
claus
parents: 144
diff changeset
   102
claus
parents: 144
diff changeset
   103
    channel operation (new ST/X style):
claus
parents: 144
diff changeset
   104
claus
parents: 144
diff changeset
   105
      the label will react on changes of the token found in the
claus
parents: 144
diff changeset
   106
      channels: foregroundChannel, backgroundChannel and labelChannel.
claus
parents: 144
diff changeset
   107
      These are valueHolders and can be shared between labels.
claus
parents: 144
diff changeset
   108
claus
parents: 144
diff changeset
   109
claus
parents: 144
diff changeset
   110
        
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
   111
    Instance variables:
3
claus
parents: 0
diff changeset
   112
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   113
	logo                <Object>        the logo, can be a Form, String or Text
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   114
	labelWidth          <Integer>       the width of the logo in device units
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   115
	labelHeight         <Integer>       the height of the logo in device units
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   116
	labelOriginX        <Integer>       the x-position of the logo withing the Label
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   117
	labelOriginY        <Integer>       the y-position of the logo withing the Label
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   118
	adjust              <Symbol>        controls how the logo is positioned within the
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   119
					    label. Can be one of:#left,#right,#center,
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   120
					    #centerLeft or #centerRight (see comment in adjust:)
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   121
	hSpace              <Integer>       number of horizontal pixels around logo
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   122
	vSpace              <Integer>       number of vertical pixels around logo
3
claus
parents: 0
diff changeset
   123
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   124
	bgColor             <Color>         background color
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   125
	fgColor             <Color>         foreground color
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
   126
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   127
	fixSize             <Boolean>       if true, a change of the logo change will not
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   128
					    resize the label; otherwise, its size is adjusted.
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   129
					    default:false.
50
e2a1b5f187ef MVC support
claus
parents: 38
diff changeset
   130
118
claus
parents: 113
diff changeset
   131
	labelMsg            <Symbol>        if non-nil, this is sent to the model to
claus
parents: 113
diff changeset
   132
					    aquire the labelString or labelImage.
claus
parents: 113
diff changeset
   133
					    If nil, the label stays as is
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   134
118
claus
parents: 113
diff changeset
   135
    styleSheet parameters:
50
e2a1b5f187ef MVC support
claus
parents: 38
diff changeset
   136
118
claus
parents: 113
diff changeset
   137
      labelForegroundColor    <Color>         color to draw foreground pixels (i.e. the string)
claus
parents: 113
diff changeset
   138
      labelBackgroundColor    <Color>         color to draw background pixels
claus
parents: 113
diff changeset
   139
      labelFont               <Font>          font to use for textual labels
3
claus
parents: 0
diff changeset
   140
"
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   141
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   142
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   143
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   144
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   145
    Notice, that Buttons and others inherit from Label; 
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   146
    therefore, the following geometry examples apply to all subclasses too.
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   147
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   148
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   149
    simple (default position is 0@0):
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   150
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   151
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   152
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   153
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   154
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   155
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   156
        l label:'hello world'.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   157
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   158
        top open
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   159
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   160
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   161
    there is also a creation message which sets the label:
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   162
        |top l|
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   163
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   164
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   165
        top extent:(200 @ 200).
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   166
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   167
        l := Label label:'hello world' in:top.
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   168
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   169
        top open
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   170
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   171
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   172
    placement:
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   173
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   174
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   175
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   176
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   177
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   178
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   179
        l label:'hello world'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   180
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   181
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   182
        top open
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   183
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   184
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   185
    level:
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   186
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   187
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   188
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   189
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   190
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   191
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   192
        l level:5.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   193
        l label:'hello world'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   194
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   195
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   196
        top open
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   197
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   198
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   199
    another level:    
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   200
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   201
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   202
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   203
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   204
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   205
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   206
        l level:-1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   207
        l label:'hello world'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   208
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   209
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   210
        top open
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   211
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   212
118
claus
parents: 113
diff changeset
   213
    colors & font:    
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   214
        |top l|
118
claus
parents: 113
diff changeset
   215
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   216
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   217
        top extent:(200 @ 200).
118
claus
parents: 113
diff changeset
   218
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   219
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   220
        l level:-1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   221
        l font:(Font family:'Times' size:18).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   222
        l foregroundColor:Color yellow.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   223
        l backgroundColor:Color red.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   224
        l label:'hello world'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   225
        l origin:50@100.
118
claus
parents: 113
diff changeset
   226
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   227
        top open
118
claus
parents: 113
diff changeset
   228
claus
parents: 113
diff changeset
   229
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   230
    border & colors:    
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   231
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   232
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   233
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   234
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   235
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   236
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   237
        l level:0.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   238
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   239
        l borderColor:Color red.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   240
        l foregroundColor:Color green darkened.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   241
        l backgroundColor:Color green lightened.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   242
        l label:'hello world'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   243
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   244
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   245
        top open
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   246
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   247
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   248
    adjust (resize to see):    
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   249
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   250
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   251
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   252
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   253
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   254
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   255
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   256
        l label:'default - centered'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   257
        l origin:0.0@40.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   258
        l width:1.0.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   259
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   260
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   261
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   262
        l adjust:#left.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   263
        l label:'left adjust'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   264
        l origin:0.0@70.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   265
        l width:1.0.
118
claus
parents: 113
diff changeset
   266
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   267
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   268
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   269
        l adjust:#centerLeft.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   270
        l label:'centerLeft adjust and a bit too long'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   271
        l origin:0.0@100.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   272
        l width:1.0.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   273
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   274
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   275
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   276
        l adjust:#right.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   277
        l label:'right adjust'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   278
        l origin:0.0@130.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   279
        l width:1.0.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   280
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   281
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   282
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   283
        l adjust:#centerRight.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   284
        l label:'centerRight adjust and a bit too long'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   285
        l origin:0.0@160.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   286
        l width:1.0.
118
claus
parents: 113
diff changeset
   287
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   288
        top open
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   289
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   290
131
claus
parents: 130
diff changeset
   291
    fitting-adjust (resize to see):
claus
parents: 130
diff changeset
   292
    Warning: #fit is experimental and should not be used.
claus
parents: 130
diff changeset
   293
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   294
        |top l|
131
claus
parents: 130
diff changeset
   295
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   296
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   297
        top extent:(200 @ 200).
131
claus
parents: 130
diff changeset
   298
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   299
        l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   300
        l label:'stretch'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   301
        l level:-1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   302
        l adjust:#fit.
131
claus
parents: 130
diff changeset
   303
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   304
        top open
131
claus
parents: 130
diff changeset
   305
claus
parents: 130
diff changeset
   306
    or:
claus
parents: 130
diff changeset
   307
    Warning: #fit is experimental and should not be used.
claus
parents: 130
diff changeset
   308
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   309
        |top l|
131
claus
parents: 130
diff changeset
   310
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   311
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   312
        top extent:(200 @ 200).
131
claus
parents: 130
diff changeset
   313
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   314
        l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   315
        l label:(Image fromFile:'bitmaps/SBrowser.xbm').
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   316
        l level:-1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   317
        l adjust:#fit.
131
claus
parents: 130
diff changeset
   318
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   319
        top open
131
claus
parents: 130
diff changeset
   320
claus
parents: 130
diff changeset
   321
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   322
    just a reminder, that instead of doing placement manually
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   323
    as in ...:    
118
claus
parents: 113
diff changeset
   324
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   325
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   326
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   327
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   328
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   329
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   330
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   331
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   332
        l label:'default - centered'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   333
        l origin:0.1@70.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   334
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   335
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   336
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   337
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   338
        l adjust:#left.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   339
        l label:'left adjust'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   340
        l origin:0.1@100.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   341
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   342
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   343
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   344
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   345
        l adjust:#right.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   346
        l label:'right adjust'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   347
        l origin:0.1@130.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   348
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   349
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   350
        top open
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   351
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   352
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   353
    ... it is much easier, to use a geometry handler, such as
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   354
    a VerticalPanel. Try:
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   355
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   356
        |top panel l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   357
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   358
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   359
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   360
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   361
        panel := VerticalPanelView 
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   362
                        origin:0.0 @ 0.0 
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   363
                        corner:1.0 @ 1.0 
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   364
                            in:top.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   365
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   366
        panel horizontalLayout:#fit.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   367
        panel verticalLayout:#center.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   368
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   369
        l := Label in:panel.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   370
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   371
        l label:'default - centered'.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   372
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   373
        l := Label in:panel.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   374
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   375
        l adjust:#left.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   376
        l label:'left adjust'.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   377
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   378
        l := Label in:panel.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   379
        l borderWidth:1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   380
        l adjust:#right.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   381
        l label:'right adjust'.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   382
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   383
        top open
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   384
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   385
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   386
    labels with bitmaps or images:
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   387
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   388
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   389
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   390
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   391
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   392
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   393
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   394
        l level:-1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   395
        l label:((Image fromFile:'bitmaps/garfield.gif') magnifyBy:0.2 @ 0.2).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   396
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   397
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   398
        top open
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   399
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   400
145
claus
parents: 144
diff changeset
   401
     Channel operation 
claus
parents: 144
diff changeset
   402
     -----------------
claus
parents: 144
diff changeset
   403
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   404
        |top panel logoChannel fgChannel bgChannel l b|
145
claus
parents: 144
diff changeset
   405
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   406
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   407
        top extent:(450 @ 200).
145
claus
parents: 144
diff changeset
   408
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   409
        panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
145
claus
parents: 144
diff changeset
   410
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   411
        l := Label in:panel.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   412
        l level:-1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   413
        l label:'change my colors'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   414
        l origin:50@100.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   415
        l sizeFixed:true.
145
claus
parents: 144
diff changeset
   416
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   417
        fgChannel := Color blue asValue.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   418
        bgChannel := Color grey asValue.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   419
        logoChannel := 'change me' asValue.
145
claus
parents: 144
diff changeset
   420
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   421
        b := Toggle label:'change fg' in:panel. b showLamp:false; onLevel:-2.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   422
        b pressAction:[fgChannel value:Color red].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   423
        b releaseAction:[fgChannel value:Color blue].
145
claus
parents: 144
diff changeset
   424
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   425
        b := Toggle label:'change bg' in:panel.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   426
        b pressAction:[bgChannel value:Color yellow].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   427
        b releaseAction:[bgChannel value:Color grey].
145
claus
parents: 144
diff changeset
   428
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   429
        b := Toggle label:'change text' in:panel.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   430
        b pressAction:[logoChannel value:'wow'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   431
        b releaseAction:[logoChannel value:'not bad' ].
145
claus
parents: 144
diff changeset
   432
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   433
        l labelChannel:logoChannel.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   434
        l foregroundChannel:fgChannel.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   435
        l backgroundChannel:bgChannel.
145
claus
parents: 144
diff changeset
   436
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   437
        top open
145
claus
parents: 144
diff changeset
   438
claus
parents: 144
diff changeset
   439
146
claus
parents: 145
diff changeset
   440
       multiple labels on one channel:
claus
parents: 145
diff changeset
   441
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   442
        |l1 l2 b conv|
146
claus
parents: 145
diff changeset
   443
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   444
        l1 := Label label:'label1'.
146
claus
parents: 145
diff changeset
   445
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   446
        l2 := Label label:'label2'.
146
claus
parents: 145
diff changeset
   447
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   448
        b := Button label:'change'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   449
        conv := (ConvertedValue new
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   450
                            conversion:[:input | 
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   451
                                        input ifTrue:[
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   452
                                            Color red
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   453
                                        ] ifFalse:[
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   454
                                            Color blue
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   455
                                        ]]).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   456
        conv value:false.
146
claus
parents: 145
diff changeset
   457
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   458
        b controller pressChannel:conv.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   459
        l1 foregroundChannel:conv.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   460
        l2 foregroundColor:Color white; backgroundChannel:conv.
146
claus
parents: 145
diff changeset
   461
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   462
        b open.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   463
        l1 open.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   464
        l2 open.
146
claus
parents: 145
diff changeset
   465
        
claus
parents: 145
diff changeset
   466
125
claus
parents: 118
diff changeset
   467
     MVC operation 
145
claus
parents: 144
diff changeset
   468
     -------------
claus
parents: 144
diff changeset
   469
125
claus
parents: 118
diff changeset
   470
       model provides the label):
claus
parents: 118
diff changeset
   471
       (have to use a plug to simulate a model which responds to
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   472
        the #someAspect message):
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   473
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   474
        |top l model|
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   475
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   476
        model := Plug new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   477
        model respondTo:#someAspect with:['models labelString'].
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   478
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   479
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   480
        top extent:(200 @ 200).
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   481
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   482
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   483
        l model:model; labelMessage:#someAspect.
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   484
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   485
        top open
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   486
        ...
118
claus
parents: 113
diff changeset
   487
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   488
        model changed:#someAspect
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   489
        ...
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   490
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   491
118
claus
parents: 113
diff changeset
   492
    concrete example (track a counters value):
125
claus
parents: 118
diff changeset
   493
      (here, the default aspect #value is used both to notify the label about
claus
parents: 118
diff changeset
   494
       changes and to aquire a new value from the model).
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   495
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   496
        |top l model|
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   497
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   498
        model := ValueHolder new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   499
        model value:'0'.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   500
        [
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   501
            1 to:20 do:[:i |
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   502
                (Delay forSeconds:1) wait.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   503
                model value:i printString
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   504
            ].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   505
            top destroy
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   506
        ] fork.
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   507
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   508
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   509
        top extent:(200 @ 200).
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   510
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   511
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   512
        l level:-1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   513
        l model:model; labelMessage:#value.
118
claus
parents: 113
diff changeset
   514
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   515
        top open
118
claus
parents: 113
diff changeset
   516
claus
parents: 113
diff changeset
   517
133
claus
parents: 132
diff changeset
   518
      with a printConverter:
claus
parents: 132
diff changeset
   519
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   520
        |top l model|
133
claus
parents: 132
diff changeset
   521
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   522
        model := Date today asValue.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   523
        [
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   524
            1 to:50 do:[:i |
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   525
                (Delay forSeconds:1) wait.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   526
                model value:(model value addDays:1) 
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   527
            ].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   528
            top destroy
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   529
        ] fork.
133
claus
parents: 132
diff changeset
   530
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   531
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   532
        top extent:(200 @ 200).
133
claus
parents: 132
diff changeset
   533
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   534
        l := Label in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   535
        l level:-1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   536
        l converter:(PrintConverter new initForDate).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   537
        l model:model; labelMessage:#value.
133
claus
parents: 132
diff changeset
   538
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   539
        top open
133
claus
parents: 132
diff changeset
   540
claus
parents: 132
diff changeset
   541
125
claus
parents: 118
diff changeset
   542
       model changes aspect after a while; two labels on the same model:
118
claus
parents: 113
diff changeset
   543
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   544
        |top l model|
118
claus
parents: 113
diff changeset
   545
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   546
        model := Plug new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   547
        model respondTo:#labelValue1 with:['models labelString1'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   548
        model respondTo:#labelValue2 with:['models labelString2'].
118
claus
parents: 113
diff changeset
   549
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   550
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   551
        top extent:(200 @ 200).
118
claus
parents: 113
diff changeset
   552
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   553
        l := Label origin:0.0@0.0 corner:1.0@0.5 in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   554
        l model:model; aspect:#someAspect; labelMessage:#labelValue1.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   555
        l := Label origin:0.0@0.5 corner:1.0@1.0 in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   556
        l model:model; aspect:#someAspect; labelMessage:#labelValue2.
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   557
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   558
        top open.
118
claus
parents: 113
diff changeset
   559
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   560
        (Delay forSeconds:5) wait.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   561
        model respondTo:#labelValue1 with:['new string1'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   562
        model respondTo:#labelValue2 with:['new string2'].
118
claus
parents: 113
diff changeset
   563
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   564
        model changed:#someAspect 
118
claus
parents: 113
diff changeset
   565
claus
parents: 113
diff changeset
   566
125
claus
parents: 118
diff changeset
   567
      plugged MVC operation (getBlock returns the label): 
118
claus
parents: 113
diff changeset
   568
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   569
        |top l model|
118
claus
parents: 113
diff changeset
   570
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   571
        model := PluggableAdaptor new
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   572
                        getBlock:[:m | 'hello']
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   573
                        putBlock:nil
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   574
                        updateBlock:nil.
118
claus
parents: 113
diff changeset
   575
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   576
        top := StandardSystemView new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   577
        top extent:(200 @ 200).
118
claus
parents: 113
diff changeset
   578
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   579
        l := Label origin:0.0@0.0 corner:1.0@0.5 in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   580
        l model:model; labelMessage:#value.
118
claus
parents: 113
diff changeset
   581
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   582
        top open.
125
claus
parents: 118
diff changeset
   583
claus
parents: 118
diff changeset
   584
claus
parents: 118
diff changeset
   585
      use different label-selectors to access fields of a complex model:
claus
parents: 118
diff changeset
   586
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   587
        |top panel model|
125
claus
parents: 118
diff changeset
   588
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   589
        model := Plug new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   590
        model respondTo:#field1 with:['value1'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   591
        model respondTo:#field2 with:['value2'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   592
        model respondTo:#field3 with:['value3'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   593
        model respondTo:#field4 with:['value4'].
125
claus
parents: 118
diff changeset
   594
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   595
        top := StandardSystemView new.
125
claus
parents: 118
diff changeset
   596
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   597
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   598
        panel elementsChangeSize:true.
125
claus
parents: 118
diff changeset
   599
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   600
        panel addSubView:((Label on:model) labelMessage:#field1).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   601
        panel addSubView:((Label on:model) labelMessage:#field2).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   602
        panel addSubView:((Label on:model) labelMessage:#field3).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   603
        panel addSubView:((Label on:model) labelMessage:#field4).
125
claus
parents: 118
diff changeset
   604
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   605
        top extent:(200 @ 200).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   606
        top open.
125
claus
parents: 118
diff changeset
   607
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   608
        (Delay forSeconds:5) wait.
125
claus
parents: 118
diff changeset
   609
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   610
        model respondTo:#field2 with:['new value2'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   611
        model changed:#value  
125
claus
parents: 118
diff changeset
   612
claus
parents: 118
diff changeset
   613
claus
parents: 118
diff changeset
   614
      same as above, using default aspects in the label, and an adaptor
claus
parents: 118
diff changeset
   615
      to translate aspects:
claus
parents: 118
diff changeset
   616
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   617
        |top panel model v1|
125
claus
parents: 118
diff changeset
   618
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   619
        model := Plug new.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   620
        model respondTo:#field1 with:[v1].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   621
        model respondTo:#field1: with:[:arg | v1 := arg. model changed:#field1].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   622
        model respondTo:#field2 with:['value2'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   623
        model respondTo:#field2: with:[:arg |].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   624
        model respondTo:#field3 with:['value3'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   625
        model respondTo:#field3: with:[:arg |].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   626
        model respondTo:#field4 with:['value4'].
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   627
        model respondTo:#field4: with:[:arg |].
125
claus
parents: 118
diff changeset
   628
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   629
        top := StandardSystemView new.
125
claus
parents: 118
diff changeset
   630
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   631
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   632
        panel elementsChangeSize:true.
125
claus
parents: 118
diff changeset
   633
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   634
        panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field1)) labelMessage:#value).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   635
        panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field2)) labelMessage:#value).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   636
        panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field3)) labelMessage:#value).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   637
        panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field4)) labelMessage:#value).
125
claus
parents: 118
diff changeset
   638
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   639
        top extent:(200 @ 200).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   640
        top open.
125
claus
parents: 118
diff changeset
   641
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   642
        (Delay forSeconds:5) wait.
125
claus
parents: 118
diff changeset
   643
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   644
        model field1:'new value1'.
125
claus
parents: 118
diff changeset
   645
claus
parents: 118
diff changeset
   646
claus
parents: 118
diff changeset
   647
      use an adapter to access fields of a complex model:
claus
parents: 118
diff changeset
   648
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   649
        |top l panel model|
125
claus
parents: 118
diff changeset
   650
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   651
        model := #('one' 'two' 'three') asValue.
125
claus
parents: 118
diff changeset
   652
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   653
        top := StandardSystemView new.
125
claus
parents: 118
diff changeset
   654
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   655
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   656
        panel elementsChangeSize:true.
125
claus
parents: 118
diff changeset
   657
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   658
        panel addSubView:((Label on:(ProtocolAdaptor
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   659
                                        subjectChannel:model
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   660
                                        accessPath:#(1))) labelMessage:#value).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   661
        panel addSubView:((Label on:(ProtocolAdaptor
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   662
                                        subjectChannel:model
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   663
                                        accessPath:#(2))) labelMessage:#value).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   664
        panel addSubView:((Label on:(ProtocolAdaptor
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   665
                                        subjectChannel:model
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   666
                                        accessPath:#(3))) labelMessage:#value).
125
claus
parents: 118
diff changeset
   667
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   668
        top extent:(200 @ 200).
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   669
        top open.
125
claus
parents: 118
diff changeset
   670
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   671
        (Delay forSeconds:5) wait.
125
claus
parents: 118
diff changeset
   672
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   673
        model value:#('oneone' 'twotwo' 'threethree').
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   674
"
3
claus
parents: 0
diff changeset
   675
! !
claus
parents: 0
diff changeset
   676
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   677
!Label class methodsFor:'instance creation'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   678
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   679
form:aForm
118
claus
parents: 113
diff changeset
   680
    "return a new Label showing a form.
claus
parents: 113
diff changeset
   681
     OBSOLETE: you should now use #label: for both text and bitmap labels."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   682
131
claus
parents: 130
diff changeset
   683
    ^ (self on:Screen current) form:aForm
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   684
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   685
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   686
form:aForm in:aView
118
claus
parents: 113
diff changeset
   687
    "return a new Label showing a form.
claus
parents: 113
diff changeset
   688
     OBSOLETE: you should now use #label:in: for both text and bitmap labels."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   689
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   690
    ^ (self in:aView) form:aForm
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   691
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   692
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   693
!Label class methodsFor:'defaults'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   694
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   695
defaultExtent
3
claus
parents: 0
diff changeset
   696
    "return default extent"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   697
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   698
    ^ 16 @ 16
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   699
!
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   700
118
claus
parents: 113
diff changeset
   701
defaultFont
claus
parents: 113
diff changeset
   702
    ^ DefaultFont notNil ifTrue:[DefaultFont] ifFalse:[super defaultFont]
claus
parents: 113
diff changeset
   703
!
claus
parents: 113
diff changeset
   704
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   705
updateStyleCache
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   706
    DefaultForegroundColor := StyleSheet colorAt:'labelForegroundColor'.
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   707
    DefaultForegroundColor isNil ifTrue:[
254
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
   708
        DefaultForegroundColor := StyleSheet colorAt:'foregroundColor' default:Black.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   709
    ].
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   710
    DefaultBackgroundColor := StyleSheet colorAt:'labelBackgroundColor'.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   711
    DefaultBackgroundColor isNil ifTrue:[
254
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
   712
        DefaultBackgroundColor := StyleSheet colorAt:'backgroundColor'.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   713
    ].
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   714
    DefaultFont := StyleSheet fontAt:'labelFont'.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   715
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   716
    "
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   717
     self updateStyleCache
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   718
    "
254
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
   719
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
   720
    "Modified: 14.12.1995 / 14:33:55 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   721
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   722
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   723
!Label methodsFor:'accessing-channels'!
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   724
260
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   725
backgroundChannel
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   726
    ^ backgroundChannel.
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   727
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   728
    "Created: 16.12.1995 / 15:50:08 / cg"
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   729
!
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   730
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   731
backgroundChannel:aValueHolder
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   732
    |prev|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   733
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   734
    prev := backgroundChannel.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   735
    backgroundChannel := aValueHolder.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   736
    self setupChannel:aValueHolder for:#backgroundChannelChanged withOld:prev 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   737
!
145
claus
parents: 144
diff changeset
   738
260
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   739
foregroundChannel
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   740
    ^ foregroundChannel.
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   741
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   742
    "Created: 16.12.1995 / 15:50:01 / cg"
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   743
!
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   744
145
claus
parents: 144
diff changeset
   745
foregroundChannel:aValueHolder
146
claus
parents: 145
diff changeset
   746
    |prev|
claus
parents: 145
diff changeset
   747
claus
parents: 145
diff changeset
   748
    prev := foregroundChannel.
145
claus
parents: 144
diff changeset
   749
    foregroundChannel := aValueHolder.
146
claus
parents: 145
diff changeset
   750
    self setupChannel:aValueHolder for:#foregroundChannelChanged withOld:prev 
145
claus
parents: 144
diff changeset
   751
!
claus
parents: 144
diff changeset
   752
260
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   753
labelChannel
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   754
    ^ labelChannel.
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   755
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   756
    "Created: 16.12.1995 / 15:50:18 / cg"
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   757
!
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   758
145
claus
parents: 144
diff changeset
   759
labelChannel:aValueHolder
146
claus
parents: 145
diff changeset
   760
    |prev|
claus
parents: 145
diff changeset
   761
claus
parents: 145
diff changeset
   762
    prev := labelChannel.
145
claus
parents: 144
diff changeset
   763
    labelChannel := aValueHolder.
146
claus
parents: 145
diff changeset
   764
    self setupChannel:aValueHolder for:#labelChannelChanged withOld:prev 
145
claus
parents: 144
diff changeset
   765
! !
claus
parents: 144
diff changeset
   766
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   767
!Label methodsFor:'accessing-colors'!
125
claus
parents: 118
diff changeset
   768
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   769
backgroundColor
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   770
    "return the background color"
125
claus
parents: 118
diff changeset
   771
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   772
    ^ bgColor 
125
claus
parents: 118
diff changeset
   773
!
claus
parents: 118
diff changeset
   774
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   775
backgroundColor:aColor
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   776
    "set the background color"
125
claus
parents: 118
diff changeset
   777
263
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   778
    aColor ~~ bgColor ifTrue:[
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   779
        bgColor := aColor on:device.
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   780
        shown ifTrue:[self redraw]
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   781
    ]
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   782
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   783
    "Modified: 17.12.1995 / 15:09:03 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   784
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   785
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   786
foregroundColor
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   787
    "return the foreground color"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   788
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   789
    ^ fgColor
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   790
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   791
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   792
foregroundColor:aColor
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   793
    "set the foreground color"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   794
263
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   795
    aColor ~~ fgColor ifTrue:[
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   796
        fgColor := aColor on:device.
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   797
        shown ifTrue:[self redraw]
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   798
    ].
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   799
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   800
    "Modified: 17.12.1995 / 15:09:15 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   801
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   802
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   803
foregroundColor:fg backgroundColor:bg
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   804
    "set the colors to be used for drawing"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   805
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   806
    fgColor := fg on:device.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   807
    bgColor := bg on:device.
131
claus
parents: 130
diff changeset
   808
    shown ifTrue:[self redraw]
133
claus
parents: 132
diff changeset
   809
! !
claus
parents: 132
diff changeset
   810
claus
parents: 132
diff changeset
   811
!Label methodsFor:'accessing-contents'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   812
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   813
form:aForm
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   814
    "set the labels form; adjust extent if not already realized.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   815
     OBSOLETE: you should now use #label: for both strings and images"
118
claus
parents: 113
diff changeset
   816
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   817
    self label:aForm
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   818
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   819
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   820
label
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   821
    "return the labels string or image"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   822
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   823
    ^ logo
118
claus
parents: 113
diff changeset
   824
!
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   825
118
claus
parents: 113
diff changeset
   826
label:aStringOrFormOrImage
claus
parents: 113
diff changeset
   827
    "set the labelString or image; adjust extent if not already realized and
claus
parents: 113
diff changeset
   828
     not fixedSize"
claus
parents: 113
diff changeset
   829
claus
parents: 113
diff changeset
   830
    (aStringOrFormOrImage ~~ logo) ifTrue:[
claus
parents: 113
diff changeset
   831
	"/
claus
parents: 113
diff changeset
   832
	"/ avoid recompute of size, if its an image with
claus
parents: 113
diff changeset
   833
	"/ the same size
claus
parents: 113
diff changeset
   834
	"/
claus
parents: 113
diff changeset
   835
	aStringOrFormOrImage isImageOrForm ifTrue:[
claus
parents: 113
diff changeset
   836
	    logo notNil ifTrue:[
claus
parents: 113
diff changeset
   837
		logo isImageOrForm ifTrue:[
claus
parents: 113
diff changeset
   838
		    logo extent = aStringOrFormOrImage extent ifTrue:[
claus
parents: 113
diff changeset
   839
			logo := aStringOrFormOrImage.
claus
parents: 113
diff changeset
   840
			^ self
claus
parents: 113
diff changeset
   841
		    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   842
		]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   843
	    ]
118
claus
parents: 113
diff changeset
   844
	] ifFalse:[
claus
parents: 113
diff changeset
   845
	    (logo = aStringOrFormOrImage) ifTrue:[
claus
parents: 113
diff changeset
   846
		^ self
claus
parents: 113
diff changeset
   847
	    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   848
	].
118
claus
parents: 113
diff changeset
   849
	logo := aStringOrFormOrImage.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   850
	self newLayout
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   851
    ]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   852
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   853
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   854
labelString:aString
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   855
    "for ST-80 compatibility: same as #label:
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   856
     set the label-string; adjust extent if not already realized and not fixedSize"
118
claus
parents: 113
diff changeset
   857
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   858
    self label:aString
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   859
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   860
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   861
labelWidth
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   862
    "return the logos width in pixels"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   863
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   864
    ^ labelWidth
118
claus
parents: 113
diff changeset
   865
!
claus
parents: 113
diff changeset
   866
claus
parents: 113
diff changeset
   867
logo:something
claus
parents: 113
diff changeset
   868
    "set the labels form or string.
claus
parents: 113
diff changeset
   869
     OBSOLETE: the old version used #form: for images and #label: for strings.
claus
parents: 113
diff changeset
   870
	       you should now use #label: for any."
claus
parents: 113
diff changeset
   871
claus
parents: 113
diff changeset
   872
    self label:something
133
claus
parents: 132
diff changeset
   873
! !
claus
parents: 132
diff changeset
   874
claus
parents: 132
diff changeset
   875
!Label methodsFor:'accessing-layout'!
claus
parents: 132
diff changeset
   876
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   877
adjust
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   878
    "return the adjust symbol"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   879
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   880
    ^ adjust
125
claus
parents: 118
diff changeset
   881
!
claus
parents: 118
diff changeset
   882
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   883
adjust:how
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   884
    "set the adjust, how which must be one of
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   885
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   886
     #left        -> left adjust logo
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   887
     #right       -> right adjust logo
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   888
     #center      -> center logo
118
claus
parents: 113
diff changeset
   889
     #centerRight -> center logo; if no fit, right adjust
258
ae4b8f1a6738 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
   890
		     (use with filenames, where the interesting part is
118
claus
parents: 113
diff changeset
   891
		      at the right if the label is too small)
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   892
     #centerLeft  -> center logo; if it does not fit, left adjust it
258
ae4b8f1a6738 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 254
diff changeset
   893
		     (use with strings where the interesting part is at the
118
claus
parents: 113
diff changeset
   894
		      left if the label is too small)
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   895
    "
118
claus
parents: 113
diff changeset
   896
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   897
    (adjust ~~ how) ifTrue:[
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   898
	adjust := how.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   899
	self newLayout
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   900
    ]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   901
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   902
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   903
font:aFont
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   904
    "set the font - if I'm not realized and not fixedSize, adjust my size"
125
claus
parents: 118
diff changeset
   905
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   906
    (aFont ~~ font) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   907
	super font:(aFont on:device).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   908
	self newLayout
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   909
    ]
133
claus
parents: 132
diff changeset
   910
!
claus
parents: 132
diff changeset
   911
claus
parents: 132
diff changeset
   912
horizontalSpace:aNumber
claus
parents: 132
diff changeset
   913
    "set the number of pixels by which the logo
claus
parents: 132
diff changeset
   914
     is horizontally inset from the border"
claus
parents: 132
diff changeset
   915
162
claus
parents: 155
diff changeset
   916
    hSpace := aNumber.
claus
parents: 155
diff changeset
   917
    self newLayout
133
claus
parents: 132
diff changeset
   918
!
claus
parents: 132
diff changeset
   919
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   920
layout
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   921
    "for protocol compatibility: alias for #adjust.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   922
     Please use #adjust, since #layout conflicts with a method
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   923
     in VW (which has a completely different meaning).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   924
     In future versions of ST/X, #layout will behave the VW way."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   925
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   926
    self obsoleteMethodWarning:'use #adjust'.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   927
    ^ self adjust
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   928
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   929
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   930
layout:something
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   931
    "OBSOLETE compatibility interface. Will vanish.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   932
     for protocol compatibility: alias for #adjust:.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   933
     Please use #adjust:, since #layout: conflicts with a method
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   934
     in VW (which has a completely different meaning).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   935
     In future versions of ST/X, #layout: will behave the VW way.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   936
     In the meantime, try to figure out what is meant ... a kludge"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   937
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   938
    something isLayout ifTrue:[^ super layout:something].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   939
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   940
    self obsoleteMethodWarning:'use #adjust:'.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   941
    self adjust:something
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   942
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   943
    "Modified: 31.8.1995 / 23:08:13 / claus"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   944
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   945
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   946
sizeFixed
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   947
    "return the fix-size attribute"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   948
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   949
    ^ fixSize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   950
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   951
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   952
sizeFixed:aBoolean
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   953
    "set/clear the fix-size attribute. 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   954
     If true, the receiver will not change its size when the labelString/logo
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   955
     changes. If false (the default), it will resize itself to make the logo
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   956
     fit."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   957
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   958
    fixSize := aBoolean
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   959
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   960
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   961
verticalSpace:aNumber
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   962
    "set the number of pixels by which the logo
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   963
     is vertically inset from the border"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   964
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   965
    vSpace := aNumber.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   966
    self newLayout
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   967
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   968
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   969
!Label methodsFor:'accessing-mvc'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   970
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   971
addModelInterfaceTo:aDictionary
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   972
    "see comment in View>>modelInterface"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   973
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   974
    super addModelInterfaceTo:aDictionary.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   975
    aDictionary at:#labelMessage put:labelMsg
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   976
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   977
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   978
converter:aConverter
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   979
    "set the printConverter;
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   980
     that one is asked to convert the models value to a printed
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   981
     representation (if non-nil). If nil, the model is supposed to
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   982
     return a string or bitmap image."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   983
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   984
    converter := aConverter
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   985
!
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   986
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   987
labelMessage 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   988
    "return the symbol used to aquire the labelString/image from the model
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   989
     when the aspect changes.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   990
     The default is nil, which means: leave the label unchanged."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   991
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   992
    ^ labelMsg
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   993
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   994
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   995
labelMessage:aSymbol 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   996
    "set the symbol used to aquire the labelString/image from the model.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   997
     The default is nil, which means: leave the label unchanged."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   998
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   999
    labelMsg ~~ aSymbol ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1000
	labelMsg := aSymbol.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1001
	self getLabelFromModel
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1002
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1003
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1004
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1005
model:aModel
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1006
    super model:aModel.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1007
    self getLabelFromModel.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1008
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1009
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1010
!Label methodsFor:'change & update'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1011
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1012
backgroundChannelChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1013
    self backgroundColor:(backgroundChannel value)
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1014
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1015
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1016
foregroundChannelChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1017
    self foregroundColor:(foregroundChannel value)
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1018
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1019
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1020
labelChannelChanged
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1021
    self label:(labelChannel value)
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1022
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1023
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1024
update:something with:aParameter from:changedObject
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1025
    "the MVC way of changing the label ..."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1026
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1027
    changedObject == model ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1028
	something == aspectMsg ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1029
	    self getLabelFromModel.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1030
	    ^ self.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1031
	]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1032
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1033
    ^ super update:something with:aParameter from:changedObject
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1034
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1035
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1036
!Label methodsFor:'event handling'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1037
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1038
sizeChanged:how
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1039
    "sent whenever size is changed by someone else - recompute the
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1040
     logos position within the View."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1041
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1042
    |prevPosition|
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1043
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1044
    super sizeChanged:how.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1045
    prevPosition := labelOriginX.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1046
    self computeLabelOrigin
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1047
    shown ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1048
	(adjust == #fit
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1049
	or:[labelOriginX ~~ prevPosition 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1050
	or:[how ~~ #smaller]]) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1051
	    "/ self clear.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1052
	    self redraw.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1053
	    self redrawEdges
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1054
	]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1055
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1056
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1057
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1058
!Label methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1059
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1060
initStyle
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1061
    super initStyle.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1062
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1063
    DefaultFont notNil ifTrue:[font := DefaultFont on:device].
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1064
    DefaultBackgroundColor notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1065
	bgColor := DefaultBackgroundColor on:device
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
  1066
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1067
	bgColor := viewBackground on:device.
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1068
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1069
    DefaultForegroundColor notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1070
	fgColor := DefaultForegroundColor on:device
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1071
    ] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1072
	fgColor := Black on:device.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
  1073
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1074
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1075
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1076
initialize
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1077
    super initialize.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1078
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1079
    font := font on:device.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1080
    self height:(font height + font descent).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1081
    adjust := #center.
118
claus
parents: 113
diff changeset
  1082
    labelOriginX := labelOriginY := 0.
claus
parents: 113
diff changeset
  1083
    labelWidth := labelHeight := 0.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1084
    logo := nil.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1085
    fixSize := false.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1086
    hSpace := (self horizontalPixelPerMillimeter:0.5) rounded.
131
claus
parents: 130
diff changeset
  1087
    vSpace := (self verticalPixelPerMillimeter:0.25) rounded
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1088
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1089
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1090
recreate
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1091
    "after snapin, labels dimensions may have changed due to
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1092
     different font parameters"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1093
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1094
    super recreate.
3
claus
parents: 0
diff changeset
  1095
    font := font on:device.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1096
    self computeLabelSize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1097
    self computeLabelOrigin
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1098
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1099
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1100
!Label methodsFor:'private'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1101
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1102
computeLabelOrigin
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1103
    "(re)compute the origin of the label whenever label or font changes"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1104
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1105
    |x y|
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1106
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1107
    labelHeight isNil ifTrue:[^ self].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1108
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1109
    adjust == #fit ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1110
	labelOriginX := labelOriginY := margin.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1111
	^ self
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1112
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1113
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1114
    "if it does not fit, should we make the origin visible,
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1115
     or the center (for text, the center seems better. For images,
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1116
     I dont really know ehich is better ...
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1117
     The commented code below makes the origin visible
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1118
   "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1119
"/    (labelHeight < height) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1120
"/        y := (height - labelHeight) // 2
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1121
"/    ] ifFalse:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1122
"/        y := 0
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1123
"/    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1124
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1125
    "always center vertically"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1126
    y := (height - labelHeight) // 2.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1127
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1128
    labelOriginY := y.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1129
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1130
    (((adjust == #center) 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1131
     or:[adjust == #centerRight])
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1132
     or:[adjust == #centerLeft]) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1133
	" center text/form in button "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1134
	x := (width - labelWidth) // 2.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1135
	(width < labelWidth) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1136
	    "no fit"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1137
	    (adjust == #centerLeft) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1138
		x := margin
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1139
	    ] ifFalse:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1140
		(adjust == #centerRight) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1141
		    x := width - labelWidth - margin
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1142
		]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1143
	    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1144
	]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1145
    ] ifFalse:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1146
	(adjust == #left) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1147
	    x := margin
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1148
	] ifFalse:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1149
	    x := width - labelWidth - margin
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1150
	]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1151
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1152
    labelOriginX := x
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1153
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1154
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1155
computeLabelSize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1156
    "compute the extent needed to hold the label; aForm or aString"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1157
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1158
    |numberOfLines textHeight textWidth|
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1159
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1160
    logo isNil ifTrue:[^ self].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1161
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1162
    logo isImageOrForm ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1163
	labelWidth := logo width. 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1164
	labelHeight := logo height.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1165
	^ self
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1166
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1167
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1168
    "must be a String or collection of strings"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1169
    logo isString ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1170
	numberOfLines := 1 + (logo occurrencesOf:(Character cr)).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1171
	(numberOfLines ~~ 1) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1172
	    logo := logo asStringCollection
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1173
	]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1174
    ] ifFalse:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1175
	numberOfLines := logo size.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1176
	(numberOfLines <= 1) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1177
	    logo := logo asString
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1178
	]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1179
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1180
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1181
"/    textHeight := font height * numberOfLines + font descent.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1182
    textHeight := font height * numberOfLines.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1183
    textWidth := font widthOf:logo.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1184
    labelWidth := textWidth + (hSpace * 2) .
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1185
    labelHeight := textHeight + (vSpace * 2)
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1186
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1187
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1188
getLabelFromModel
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1189
    "ask my model for the label to show.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1190
     Here, we use labelMsg (instead of aspectMsg). 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1191
     This allows multiple labels to react on the same aspect, 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1192
     but show different labels when changed 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1193
     (also, since labelMsg defaults to nil, constant labels
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1194
      which have a nil labelMsg will not try to aquire a labelString)."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1195
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1196
    |val|
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1197
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1198
    (model notNil 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1199
    and:[labelMsg notNil]) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1200
	val := model perform:labelMsg.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1201
	converter notNil ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1202
	    val := converter printStringFor:val
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1203
	].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1204
	self label:val.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1205
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1206
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1207
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1208
newLayout
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1209
    "recompute position/size after a change
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1210
     - helper for form:/font: etc."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1211
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1212
    self computeLabelSize.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1213
    fixSize ifFalse:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1214
	self resize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1215
    ] ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1216
	self computeLabelOrigin
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1217
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1218
    shown ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1219
	self redraw
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1220
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1221
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1222
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1223
!Label methodsFor:'queries'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1224
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1225
preferredExtent
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1226
    "return my preferred extent - this is the minimum size I would like to have"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1227
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1228
    |extra|
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1229
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1230
    logo notNil ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1231
	extra := margin * 2.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1232
	^ (labelWidth + extra + hSpace) @ (labelHeight + extra + vSpace)
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1233
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1234
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1235
    ^ super preferredExtent
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1236
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1237
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1238
!Label methodsFor:'redrawing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1239
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1240
clearInsideWith:bg
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1241
    |cutOff mustClear|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1242
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1243
    cutOff := margin * 2.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1244
3
claus
parents: 0
diff changeset
  1245
    mustClear := true.
claus
parents: 0
diff changeset
  1246
87
2c6ab478466a *** empty log message ***
claus
parents: 81
diff changeset
  1247
    (logo notNil and:[logo isImageOrForm]) ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1248
	(labelOriginX == 0 and:[labelOriginY == 0]) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1249
	    logo width >= (width - cutOff) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1250
		logo height >= (height - cutOff) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1251
		    "no need to clear before - avoid flicker"
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1252
		    mustClear := false
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1253
		]
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1254
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1255
	].
3
claus
parents: 0
diff changeset
  1256
    ].
claus
parents: 0
diff changeset
  1257
claus
parents: 0
diff changeset
  1258
    mustClear ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1259
	self paint:bg.
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1260
	self fillRectangleX:margin y:margin
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1261
		      width:(width - cutOff)
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1262
		     height:(height - cutOff).
3
claus
parents: 0
diff changeset
  1263
    ].
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1264
!
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1265
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1266
drawWith:fg and:bg
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1267
    "redraw my label with fg/bg - this generic method is also used by subclasses
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1268
     (especially Button) to redraw the logo in different colors."
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1269
132
claus
parents: 131
diff changeset
  1270
    |x y scaleH scaleV nW nH hSep vSep m2|
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1271
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1272
    self clearInsideWith:bg.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1273
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1274
    logo notNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1275
	self paint:fg on:bg.
131
claus
parents: 130
diff changeset
  1276
133
claus
parents: 132
diff changeset
  1277
	m2 := margin * 2.
claus
parents: 132
diff changeset
  1278
	hSep := (hSpace*2).
claus
parents: 132
diff changeset
  1279
	vSep := (vSpace*2).
claus
parents: 132
diff changeset
  1280
87
2c6ab478466a *** empty log message ***
claus
parents: 81
diff changeset
  1281
	logo isImageOrForm ifTrue:[
131
claus
parents: 130
diff changeset
  1282
	    x := labelOriginX.
claus
parents: 130
diff changeset
  1283
	    y := labelOriginY.
claus
parents: 130
diff changeset
  1284
claus
parents: 130
diff changeset
  1285
	    adjust == #fit ifTrue:[
claus
parents: 130
diff changeset
  1286
		scaleH := ((width - hSep) / (logo width)) asFloat.
claus
parents: 130
diff changeset
  1287
		scaleV := ((height - vSep) / (logo height)) asFloat.
claus
parents: 130
diff changeset
  1288
		self scale:(scaleH @ scaleV).
claus
parents: 130
diff changeset
  1289
		x := transformation applyInverseScaleX:x.
claus
parents: 130
diff changeset
  1290
		y := transformation applyInverseScaleY:y.
claus
parents: 130
diff changeset
  1291
	    ].
claus
parents: 130
diff changeset
  1292
87
2c6ab478466a *** empty log message ***
claus
parents: 81
diff changeset
  1293
	    logo := logo on:device.
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1294
"/            self background:bg.
131
claus
parents: 130
diff changeset
  1295
	    self displayOpaqueForm:logo x:x y:y 
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1296
	] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1297
	    x := labelOriginX + hSpace.
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1298
	    y := labelOriginY + (font ascent) + vSpace.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1299
131
claus
parents: 130
diff changeset
  1300
	    adjust == #fit ifTrue:[
claus
parents: 130
diff changeset
  1301
		scaleH := ((width - m2 - hSep) / (labelWidth - hSpace)) asFloat.
claus
parents: 130
diff changeset
  1302
		scaleV := ((height - m2 - vSep) / (labelHeight - vSpace)) asFloat.
claus
parents: 130
diff changeset
  1303
		self scale:(scaleH min: scaleV).
claus
parents: 130
diff changeset
  1304
		x := transformation applyInverseScaleX:x.
claus
parents: 130
diff changeset
  1305
		y := y - font ascent + (transformation applyScaleY:font ascent).
claus
parents: 130
diff changeset
  1306
		y := transformation applyInverseScaleY:y.
claus
parents: 130
diff changeset
  1307
		scaleH < scaleV ifTrue:[
claus
parents: 130
diff changeset
  1308
		    nH := labelHeight * scaleH.
claus
parents: 130
diff changeset
  1309
		    "/ now, center vertically
claus
parents: 130
diff changeset
  1310
		    y := y + ((height - nH - m2 - vSep) / scaleH / 2).
claus
parents: 130
diff changeset
  1311
		].
claus
parents: 130
diff changeset
  1312
		scaleV < scaleH ifTrue:[
claus
parents: 130
diff changeset
  1313
		    "/ now, center horizontally
claus
parents: 130
diff changeset
  1314
		    nW := labelWidth * scaleV.
claus
parents: 130
diff changeset
  1315
		    x := x + ((width - nW - m2 - hSep) / scaleV / 2) 
claus
parents: 130
diff changeset
  1316
		].
claus
parents: 130
diff changeset
  1317
	    ].
claus
parents: 130
diff changeset
  1318
87
2c6ab478466a *** empty log message ***
claus
parents: 81
diff changeset
  1319
	    logo isString ifTrue:[
250
77012e65ac84 draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
  1320
		self displayOpaqueString:logo x:x y:y
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1321
	    ] ifFalse:[
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1322
		logo do:[ :line |
250
77012e65ac84 draw strings as opaque strings - OS/2 server has a bug with non-image strings
Claus Gittinger <cg@exept.de>
parents: 205
diff changeset
  1323
		    self displayOpaqueString:(line printString) x:x y:y.
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1324
		    y := y + (font height)
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1325
		]
131
claus
parents: 130
diff changeset
  1326
	    ].
claus
parents: 130
diff changeset
  1327
claus
parents: 130
diff changeset
  1328
	].
claus
parents: 130
diff changeset
  1329
claus
parents: 130
diff changeset
  1330
	adjust == #fit ifTrue:[
claus
parents: 130
diff changeset
  1331
	    self scale:1
claus
parents: 130
diff changeset
  1332
	].
claus
parents: 130
diff changeset
  1333
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1334
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1335
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1336
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1337
redraw
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1338
    "redraw my label"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1339
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1340
    shown ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1341
	self drawWith:fgColor and:bgColor
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1342
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1343
! !
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1344
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1345
!Label methodsFor:'resizing'!
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1346
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1347
forceResize
118
claus
parents: 113
diff changeset
  1348
    "resize myself to make text fit into myself. Here, this is done even if
claus
parents: 113
diff changeset
  1349
     fixSize is set."
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1350
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1351
    logo notNil ifTrue:[
130
claus
parents: 128
diff changeset
  1352
	self extent:self preferredExtent.
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1353
	self computeLabelOrigin
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1354
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1355
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1356
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1357
resize
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1358
    "resize myself to make text fit into myself.
118
claus
parents: 113
diff changeset
  1359
     but only do so, if I am not fixedSize and I have NOT been 
claus
parents: 113
diff changeset
  1360
     given a relative extent or an extend computation block."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1361
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1362
    (logo notNil 
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1363
    and:[fixSize not
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1364
    and:[relativeExtent isNil
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1365
    and:[extentRule isNil
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1366
    and:[relativeCorner isNil 
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1367
    and:[cornerRule isNil]]]]]) ifTrue:[
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1368
	self forceResize
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  1369
    ] ifFalse:[
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1370
	self computeLabelOrigin
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1371
    ]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1372
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1373
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1374
!Label class methodsFor:'documentation'!
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1375
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1376
version
275
a7f95252cdc2 example fixed
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1377
    ^ '$Header: /cvs/stx/stx/libwidg/Label.st,v 1.42 1996-01-09 18:16:58 cg Exp $'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  1378
! !