Label.st
author Claus Gittinger <cg@exept.de>
Thu, 09 Nov 2017 20:09:30 +0100
changeset 6225 0122e4e6c587
parent 6177 e80cfdebfdbe
child 6238 341edb64b989
permissions -rw-r--r--
#FEATURE by cg class: GenericToolbarIconLibrary class added: #hideFilter16x16Icon
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
"
2192
e9068416fd41 foreground-, backgroundChannel moved to superclass (#destroy)
Stefan Vogel <sv@exept.de>
parents: 2098
diff changeset
    12
"{ Package: 'stx:libwidg' }"
e9068416fd41 foreground-, backgroundChannel moved to superclass (#destroy)
Stefan Vogel <sv@exept.de>
parents: 2098
diff changeset
    13
5445
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
    14
"{ NameSpace: Smalltalk }"
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
    15
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    16
View subclass:#Label
254
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
    17
	instanceVariableNames:'logo labelWidth labelHeight labelOriginX labelOriginY adjust
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
    18
		hSpace vSpace bgColor fgColor etchedFgColor fixSize labelMsg
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
    19
		converter labelChannel'
392
81343306d796 eliminated all DefaultFont classVars (are now classINSTvars)
Claus Gittinger <cg@exept.de>
parents: 391
diff changeset
    20
	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor'
254
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
    21
	poolDictionaries:''
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
    22
	category:'Views-Layout'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    23
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    24
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    25
Object subclass:#AnimatorState
5755
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
    26
	instanceVariableNames:'timedBlock nextOffset logoShown moveDirection pointerEntered'
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    27
	classVariableNames:''
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    28
	poolDictionaries:''
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    29
	privateIn:Label
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    30
!
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
    31
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
    32
!Label class methodsFor:'documentation'!
3
claus
parents: 0
diff changeset
    33
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    34
copyright
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
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
    37
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    39
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    40
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    41
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    42
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    43
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    44
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    45
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    46
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    47
3
claus
parents: 0
diff changeset
    48
documentation
claus
parents: 0
diff changeset
    49
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    50
    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
    51
    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
    52
    view. The contents can be a String, a collection of Strings (i.e.
118
claus
parents: 113
diff changeset
    53
    a StringCollection) or a Form/Image. 
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    54
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    55
    The contents is drawn in fgColor/bgColor, which can be changed using:
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    56
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    57
        aLabel foregroundColor:aColor
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    58
        aLabel backgroundColor:aColor
3
claus
parents: 0
diff changeset
    59
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    60
    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
    61
    the required size. This resizing can be suppressed by setting the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    62
    fixsize attribute to true using:
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    63
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    64
        aLabel sizeFixed:true
3
claus
parents: 0
diff changeset
    65
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    66
    This can be used, if resizing of the label is not wanted.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    67
    However, in this case you have to make certain that the size is big enough
118
claus
parents: 113
diff changeset
    68
    to hold any changed logos later. (usually, you create the label first with
claus
parents: 113
diff changeset
    69
    the longest string first to have it compute its size, then set the fixSize 
claus
parents: 113
diff changeset
    70
    attribute to avoid resizing later).
125
claus
parents: 118
diff changeset
    71
    Be careful when placing self-resizing labels into panels - by default,
claus
parents: 118
diff changeset
    72
    panels do not react on the size change - leading to ugly looking geometry.
claus
parents: 118
diff changeset
    73
    (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
    74
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
    75
    The placement of the contents within the label is controlled by
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    76
    the adjust attribute, it can be set with:
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
    77
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    78
        aLabel adjust:how
3
claus
parents: 0
diff changeset
    79
1946
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
    80
    where how is one of the symbols left, #right, #center, #centerEach,
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
    81
    #centerLeft, #centerRight, #leftRight or #rightLeft 
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
    82
    (see the comment in Label>>adjust:). The default is #center.
3
claus
parents: 0
diff changeset
    83
145
claus
parents: 144
diff changeset
    84
    model-less operation (ok for static labels):
118
claus
parents: 113
diff changeset
    85
      if no model is set, the labels contents is set with:
claus
parents: 113
diff changeset
    86
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    87
        aLabel label:aStringOrImage
118
claus
parents: 113
diff changeset
    88
claus
parents: 113
diff changeset
    89
      and stays constant unless changed by new calls to #label:.
claus
parents: 113
diff changeset
    90
claus
parents: 113
diff changeset
    91
145
claus
parents: 144
diff changeset
    92
    model operation (ST-80 style):
118
claus
parents: 113
diff changeset
    93
      labels with a model, aspectMsg and labelMsg react to 
claus
parents: 113
diff changeset
    94
      changes of the aspect, and send a labelMsg-message 
5782
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
    95
      to the model in order to acquire a new labelString or image.
118
claus
parents: 113
diff changeset
    96
      The model should send 'self changed:aspectMsg' if it thinks the label 
claus
parents: 113
diff changeset
    97
      should change and return a string or image from the labelMsg-message.
claus
parents: 113
diff changeset
    98
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
    99
        label model:aModel.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   100
        label aspect:aspectSymbol.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   101
        label labelMessage:labelSymbol.
118
claus
parents: 113
diff changeset
   102
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   103
        model sends #changed:aspectSymbol
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   104
        ---> label will redraw its label from value of model perform:labelSymbol
118
claus
parents: 113
diff changeset
   105
claus
parents: 113
diff changeset
   106
      Having a labelSymbol different from the aspectSymbol allows for two labels
claus
parents: 113
diff changeset
   107
      to react on the same aspect-change, but use different messages when asking
claus
parents: 113
diff changeset
   108
      the model for a new label contents. By default, the labelMsg is nil,
claus
parents: 113
diff changeset
   109
      so the label does NOT update its shown contents.
claus
parents: 113
diff changeset
   110
      The aspectMsg defaults to #value.
claus
parents: 113
diff changeset
   111
125
claus
parents: 118
diff changeset
   112
145
claus
parents: 144
diff changeset
   113
claus
parents: 144
diff changeset
   114
    channel operation (new ST/X style):
claus
parents: 144
diff changeset
   115
claus
parents: 144
diff changeset
   116
      the label will react on changes of the token found in the
claus
parents: 144
diff changeset
   117
      channels: foregroundChannel, backgroundChannel and labelChannel.
claus
parents: 144
diff changeset
   118
      These are valueHolders and can be shared between labels.
claus
parents: 144
diff changeset
   119
claus
parents: 144
diff changeset
   120
claus
parents: 144
diff changeset
   121
        
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   122
    [Instance variables:]
3
claus
parents: 0
diff changeset
   123
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   124
        logo                <Object>        the logo, can be a Form, String or Text
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   125
        labelWidth          <Integer>       the width of the logo in device units
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   126
        labelHeight         <Integer>       the height of the logo in device units
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   127
        labelOriginX        <Integer>       the x-position of the logo withing the Label
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   128
        labelOriginY        <Integer>       the y-position of the logo withing the Label
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   129
        adjust              <Symbol>        controls how the logo is positioned within the
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   130
                                            label. Can be one of:#left,#right,#center,
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   131
                                            #centerLeft or #centerRight (see comment in adjust:)
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   132
        hSpace              <Integer>       number of horizontal pixels around logo
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   133
        vSpace              <Integer>       number of vertical pixels around logo
3
claus
parents: 0
diff changeset
   134
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   135
        bgColor             <Color>         background color
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   136
        fgColor             <Color>         foreground color
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
   137
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   138
        fixSize             <Boolean>       if true, a change of the logo change will not
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   139
                                            resize the label; otherwise, its size is adjusted.
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   140
                                            default:false.
50
e2a1b5f187ef MVC support
claus
parents: 38
diff changeset
   141
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   142
        labelMsg            <Symbol>        if non-nil, this is sent to the model to
5782
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
   143
                                            acquire the labelString or labelImage.
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   144
                                            If nil, the label stays as is
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   145
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   146
    [styleSheet parameters:]
50
e2a1b5f187ef MVC support
claus
parents: 38
diff changeset
   147
118
claus
parents: 113
diff changeset
   148
      labelForegroundColor    <Color>         color to draw foreground pixels (i.e. the string)
claus
parents: 113
diff changeset
   149
      labelBackgroundColor    <Color>         color to draw background pixels
claus
parents: 113
diff changeset
   150
      labelFont               <Font>          font to use for textual labels
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   151
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   152
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   153
        Claus Gittinger
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   154
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   155
    [see also:]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   156
        Panel HorizontalPanel VerticalPanel
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   157
        TextView EditTextView
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   158
        Button
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   159
        InfoBox WarningBox
3
claus
parents: 0
diff changeset
   160
"
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   161
!
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   162
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   163
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   164
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   165
    Notice, that Buttons and others inherit from Label; 
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   166
    therefore, the following geometry examples apply to all subclasses too.
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   167
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   168
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   169
    simple (default position is 0@0):
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   170
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   171
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   172
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   173
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   174
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   175
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   176
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   177
        l label:'hello world'.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   178
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   179
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   180
                                                                        [exEnd]
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   181
                                                                        [exBegin]
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   182
        |top l|
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   183
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   184
        top := StandardSystemView new.
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   185
        top extent:(200 @ 200).
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   186
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   187
        l := Label in:top.
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   188
        l label:'hello\world' withCRs.
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   189
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   190
        top open
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
   191
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   192
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   193
626
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   194
    simple with emphasis:
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   195
                                                                        [exBegin]
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   196
        |top l|
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   197
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   198
        top := StandardSystemView new.
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   199
        top extent:(300 @ 100).
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   200
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   201
        l := Label in:top.
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   202
        l level:-1.
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   203
        l label:('hello world - this is text in a label ' asText 
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   204
                        emphasizeFrom:7 to:11 with:#italic;
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   205
                        emphasizeFrom:23 to:26 with:#bold).
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   206
        top open
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   207
                                                                        [exEnd]
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   208
35bc7d217ff5 handle Text
Claus Gittinger <cg@exept.de>
parents: 616
diff changeset
   209
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   210
    there is also a creation message which sets the label:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   211
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   212
        |top l|
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   213
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   214
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   215
        top extent:(200 @ 200).
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   216
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   217
        l := Label label:'hello world' in:top.
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   218
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   219
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   220
                                                                        [exEnd]
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   221
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   222
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   223
    placement:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   224
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   225
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   226
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   227
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   228
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   229
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   230
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   231
        l label:'hello world'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   232
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   233
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   234
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   235
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   236
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   237
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   238
    level:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   239
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   240
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   241
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   242
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   243
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   244
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   245
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   246
        l level:5.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   247
        l label:'hello world'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   248
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   249
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   250
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   251
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   252
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   253
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   254
    another level:    
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   255
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   256
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   257
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   258
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   259
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   260
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   261
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   262
        l level:-1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   263
        l label:'hello world'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   264
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   265
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   266
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   267
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   268
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   269
118
claus
parents: 113
diff changeset
   270
    colors & font:    
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   271
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   272
        |top l|
118
claus
parents: 113
diff changeset
   273
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   274
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   275
        top extent:(200 @ 200).
118
claus
parents: 113
diff changeset
   276
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   277
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   278
        l level:-1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   279
        l font:(Font family:'Times' size:18).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   280
        l foregroundColor:Color yellow.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   281
        l backgroundColor:Color red.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   282
        l label:'hello world'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   283
        l origin:50@100.
118
claus
parents: 113
diff changeset
   284
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   285
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   286
                                                                        [exEnd]
118
claus
parents: 113
diff changeset
   287
claus
parents: 113
diff changeset
   288
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   289
    border & colors:    
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   290
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   291
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   292
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   293
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   294
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   295
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   296
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   297
        l level:0.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   298
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   299
        l borderColor:Color red.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   300
        l foregroundColor:Color green darkened.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   301
        l backgroundColor:Color green lightened.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   302
        l label:'hello world'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   303
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   304
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   305
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   306
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   307
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   308
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   309
    different adjusts (resize to see):    
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   310
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   311
        |top l|
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   312
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   313
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   314
        top extent:(300 @ 250).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   315
        top label:'make me smaller'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   316
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   317
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   318
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   319
        l label:'default - #centered'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   320
        l origin:0.1@40.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   321
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   322
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   323
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   324
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   325
        l adjust:#left.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   326
        l label:'#left adjust'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   327
        l origin:0.1@70.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   328
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   329
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   330
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   331
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   332
        l adjust:#right.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   333
        l label:'#right adjust'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   334
        l origin:0.1@100.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   335
        l width:0.8.
118
claus
parents: 113
diff changeset
   336
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   337
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   338
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   339
        l adjust:#centerLeft.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   340
        l label:'#centerLeft adjust with a long text'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   341
        l origin:0.1@130.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   342
        l width:0.8.
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   343
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   344
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   345
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   346
        l adjust:#centerRight.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   347
        l label:'#centerRight adjust with a long text'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   348
        l origin:0.1@160.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   349
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   350
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   351
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   352
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   353
        l adjust:#leftRight.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   354
        l label:'#leftRight adjust with a long text'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   355
        l origin:0.1@190.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   356
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   357
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   358
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   359
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   360
        l adjust:#rightLeft.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   361
        l label:'#rightLeft adjust with a long text'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   362
        l origin:0.1@220.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   363
        l width:0.8.
118
claus
parents: 113
diff changeset
   364
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   365
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   366
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   367
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   368
1945
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   369
    center vs. centerEach adjust (only with multiline labels):    
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   370
                                                                        [exBegin]
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   371
        |top l|
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   372
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   373
        top := StandardSystemView new.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   374
        top extent:(300 @ 250).
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   375
        top label:'resize me'.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   376
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   377
        l := Label in:top.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   378
        l borderWidth:1.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   379
        l label:'this labels logo
1946
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   380
consists of multiple lines 
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   381
with #center adjust'.
1945
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   382
        l origin:0.1@0.1.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   383
        l corner:0.9@0.9.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   384
        l adjust:#center.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   385
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   386
        top open.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   387
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   388
        top := StandardSystemView new.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   389
        top extent:(300 @ 250).
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   390
        top label:'resize me'.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   391
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   392
        l := Label in:top.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   393
        l borderWidth:1.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   394
        l label:'this labels logo
1946
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   395
consists of multiple lines 
Claus Gittinger <cg@exept.de>
parents: 1945
diff changeset
   396
with #centerEach adjust'.
1945
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   397
        l origin:0.1@0.1.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   398
        l corner:0.9@0.9.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   399
        l adjust:#centerEach.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   400
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   401
        top open
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   402
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   403
                                                                        [exEnd]
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   404
131
claus
parents: 130
diff changeset
   405
    fitting-adjust (resize to see):
claus
parents: 130
diff changeset
   406
    Warning: #fit is experimental and should not be used.
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   407
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   408
        |top l|
131
claus
parents: 130
diff changeset
   409
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   410
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   411
        top extent:(200 @ 200).
131
claus
parents: 130
diff changeset
   412
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   413
        l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   414
        l label:'stretch'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   415
        l level:-1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   416
        l adjust:#fit.
131
claus
parents: 130
diff changeset
   417
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   418
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   419
                                                                        [exEnd]
131
claus
parents: 130
diff changeset
   420
claus
parents: 130
diff changeset
   421
    or:
claus
parents: 130
diff changeset
   422
    Warning: #fit is experimental and should not be used.
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   423
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   424
        |top l|
131
claus
parents: 130
diff changeset
   425
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   426
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   427
        top extent:(200 @ 200).
131
claus
parents: 130
diff changeset
   428
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   429
        l := Label origin:0.25 @ 0.25 corner:0.75@0.75 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   430
        l label:(Image fromFile:'bitmaps/SBrowser.xbm').
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   431
        l level:-1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   432
        l adjust:#fit.
131
claus
parents: 130
diff changeset
   433
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   434
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   435
                                                                        [exEnd]
131
claus
parents: 130
diff changeset
   436
claus
parents: 130
diff changeset
   437
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   438
    just a reminder, that instead of doing placement manually
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   439
    as in ...:    
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   440
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   441
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   442
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   443
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   444
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   445
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   446
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   447
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   448
        l label:'default - centered'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   449
        l origin:0.1@70.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   450
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   451
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   452
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   453
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   454
        l adjust:#left.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   455
        l label:'left adjust'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   456
        l origin:0.1@100.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   457
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   458
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   459
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   460
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   461
        l adjust:#right.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   462
        l label:'right adjust'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   463
        l origin:0.1@130.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   464
        l width:0.8.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   465
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   466
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   467
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   468
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   469
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   470
    ... it is much easier, to use a geometry handler, such as
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   471
    a VerticalPanel. Try:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   472
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   473
        |top panel l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   474
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   475
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   476
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   477
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   478
        panel := VerticalPanelView 
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   479
                        origin:0.1 @ 0.0 
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   480
                        corner:0.9 @ 1.0 
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   481
                            in:top.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   482
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   483
        panel horizontalLayout:#fit.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   484
        panel verticalLayout:#center.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   485
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   486
        l := Label in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   487
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   488
        l label:'default - centered'.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   489
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   490
        l := Label in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   491
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   492
        l adjust:#left.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   493
        l label:'left adjust'.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   494
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   495
        l := Label in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   496
        l borderWidth:1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   497
        l adjust:#right.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   498
        l label:'right adjust'.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   499
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   500
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   501
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   502
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   503
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   504
    labels with bitmaps or images:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   505
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   506
        |top l|
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   507
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   508
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   509
        top extent:(200 @ 200).
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   510
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   511
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   512
        l level:-1.
5855
1c8fa7cccb9c #OTHER by mawalch
mawalch
parents: 5817
diff changeset
   513
        l label:((Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') magnifiedBy:0.2 @ 0.2).
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   514
        l origin:50@100.
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   515
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   516
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   517
                                                                        [exEnd]
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   518
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   519
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   520
     that even works with #fit:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   521
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   522
        |top l|
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   523
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   524
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   525
        top extent:(200 @ 200).
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   526
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   527
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   528
        l adjust:#fit.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   529
        l level:-1.
5855
1c8fa7cccb9c #OTHER by mawalch
mawalch
parents: 5817
diff changeset
   530
        l label:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif').
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   531
        l origin:0.2@0.2 corner:0.8@0.8.
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   532
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   533
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   534
                                                                        [exEnd]
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   535
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   536
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   537
     notice, that Buttons inherit from Label; thus:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   538
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   539
        |top b|
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   540
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   541
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   542
        top extent:(200 @ 200).
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   543
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   544
        b := Button in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   545
        b adjust:#fit.
5855
1c8fa7cccb9c #OTHER by mawalch
mawalch
parents: 5817
diff changeset
   546
        b label:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif').
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   547
        b origin:0.2@0.2 corner:0.8@0.8.
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 640
diff changeset
   548
        b action:[Transcript showCR:'wow'].
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   549
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   550
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   551
                                                                        [exEnd]
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   552
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
   553
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   554
     Channel operation (controlling fg, bg and labelText via ValueHolders)
145
claus
parents: 144
diff changeset
   555
     -----------------
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   556
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   557
        |top panel logoChannel fgChannel bgChannel l b|
145
claus
parents: 144
diff changeset
   558
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   559
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   560
        top extent:(450 @ 200).
145
claus
parents: 144
diff changeset
   561
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   562
        panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
145
claus
parents: 144
diff changeset
   563
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   564
        l := Label in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   565
        l level:-1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   566
        l label:'change my colors'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   567
        l origin:50@100.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   568
        l sizeFixed:true.
145
claus
parents: 144
diff changeset
   569
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   570
        fgChannel := Color blue asValue.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   571
        bgChannel := Color grey asValue.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   572
        logoChannel := 'change me' asValue.
145
claus
parents: 144
diff changeset
   573
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   574
        b := Toggle label:'change fg' in:panel. b showLamp:false; onLevel:-2.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   575
        b pressAction:[fgChannel value:Color red].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   576
        b releaseAction:[fgChannel value:Color blue].
145
claus
parents: 144
diff changeset
   577
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   578
        b := Toggle label:'change bg' in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   579
        b pressAction:[bgChannel value:Color yellow].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   580
        b releaseAction:[bgChannel value:Color grey].
145
claus
parents: 144
diff changeset
   581
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   582
        b := Toggle label:'change text' in:panel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   583
        b pressAction:[logoChannel value:'wow'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   584
        b releaseAction:[logoChannel value:'not bad' ].
145
claus
parents: 144
diff changeset
   585
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   586
        l labelChannel:logoChannel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   587
        l foregroundChannel:fgChannel.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   588
        l backgroundChannel:bgChannel.
145
claus
parents: 144
diff changeset
   589
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   590
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   591
                                                                        [exEnd]
145
claus
parents: 144
diff changeset
   592
claus
parents: 144
diff changeset
   593
146
claus
parents: 145
diff changeset
   594
       multiple labels on one channel:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   595
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   596
        |l1 l2 b conv|
146
claus
parents: 145
diff changeset
   597
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   598
        l1 := Label label:'label1'.
146
claus
parents: 145
diff changeset
   599
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   600
        l2 := Label label:'label2'.
146
claus
parents: 145
diff changeset
   601
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   602
        b := Button label:'change'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   603
        conv := (ConvertedValue new
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   604
                            conversion:[:input | 
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   605
                                        input ifTrue:[
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   606
                                            Color red
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   607
                                        ] ifFalse:[
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   608
                                            Color blue
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   609
                                        ]]).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   610
        conv value:false.
146
claus
parents: 145
diff changeset
   611
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   612
        b controller pressChannel:conv.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   613
        l1 foregroundChannel:conv.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   614
        l2 foregroundColor:Color white; backgroundChannel:conv.
146
claus
parents: 145
diff changeset
   615
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   616
        b open.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   617
        l1 open.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   618
        l2 open.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   619
                                                                        [exEnd]
146
claus
parents: 145
diff changeset
   620
        
claus
parents: 145
diff changeset
   621
125
claus
parents: 118
diff changeset
   622
     MVC operation 
145
claus
parents: 144
diff changeset
   623
     -------------
claus
parents: 144
diff changeset
   624
125
claus
parents: 118
diff changeset
   625
       model provides the label):
claus
parents: 118
diff changeset
   626
       (have to use a plug to simulate a model which responds to
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   627
        the #someAspect message):
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   628
        |top l model|
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   629
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   630
        model := Plug new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   631
        model respondTo:#someAspect with:['models labelString'].
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   632
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   633
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   634
        top extent:(200 @ 200).
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   635
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   636
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   637
        l model:model; labelMessage:#someAspect.
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   638
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   639
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   640
        ...
118
claus
parents: 113
diff changeset
   641
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   642
        model changed:#someAspect
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   643
        ...
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   644
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   645
118
claus
parents: 113
diff changeset
   646
    concrete example (track a counters value):
125
claus
parents: 118
diff changeset
   647
      (here, the default aspect #value is used both to notify the label about
5782
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
   648
       changes and to acquire a new value from the model).
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   649
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   650
        |top l model|
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   651
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   652
        model := ValueHolder new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   653
        model value:'0'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   654
        [
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   655
            1 to:20 do:[:i |
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   656
                (Delay forSeconds:1) wait.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   657
                model value:i printString
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   658
            ].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   659
            top destroy
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   660
        ] fork.
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   661
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   662
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   663
        top extent:(200 @ 200).
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   664
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   665
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   666
        l level:-1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   667
        l model:model; labelMessage:#value.
118
claus
parents: 113
diff changeset
   668
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   669
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   670
                                                                        [exEnd]
118
claus
parents: 113
diff changeset
   671
claus
parents: 113
diff changeset
   672
133
claus
parents: 132
diff changeset
   673
      with a printConverter:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   674
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   675
        |top l model|
133
claus
parents: 132
diff changeset
   676
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   677
        model := Date today asValue.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   678
        [
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   679
            1 to:50 do:[:i |
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   680
                (Delay forSeconds:1) wait.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   681
                model value:(model value addDays:1) 
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   682
            ].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   683
            top destroy
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   684
        ] fork.
133
claus
parents: 132
diff changeset
   685
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   686
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   687
        top extent:(200 @ 200).
133
claus
parents: 132
diff changeset
   688
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   689
        l := Label in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   690
        l level:-1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   691
        l converter:(PrintConverter new initForDate).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   692
        l model:model; labelMessage:#value.
133
claus
parents: 132
diff changeset
   693
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   694
        top open
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   695
                                                                        [exEnd]
133
claus
parents: 132
diff changeset
   696
claus
parents: 132
diff changeset
   697
125
claus
parents: 118
diff changeset
   698
       model changes aspect after a while; two labels on the same model:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   699
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   700
        |top l model|
118
claus
parents: 113
diff changeset
   701
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   702
        model := Plug new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   703
        model respondTo:#labelValue1 with:['models labelString1'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   704
        model respondTo:#labelValue2 with:['models labelString2'].
118
claus
parents: 113
diff changeset
   705
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   706
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   707
        top extent:(200 @ 200).
118
claus
parents: 113
diff changeset
   708
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   709
        l := Label origin:0.0@0.0 corner:1.0@0.5 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   710
        l model:model; aspect:#someAspect; labelMessage:#labelValue1.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   711
        l := Label origin:0.0@0.5 corner:1.0@1.0 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   712
        l model:model; aspect:#someAspect; labelMessage:#labelValue2.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   713
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   714
        top open.
113
fdd18cfff57e *** empty log message ***
claus
parents: 110
diff changeset
   715
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   716
        (Delay forSeconds:5) wait.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   717
        model respondTo:#labelValue1 with:['new string1'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   718
        model respondTo:#labelValue2 with:['new string2'].
118
claus
parents: 113
diff changeset
   719
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   720
        model changed:#someAspect 
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   721
                                                                        [exEnd]
118
claus
parents: 113
diff changeset
   722
claus
parents: 113
diff changeset
   723
125
claus
parents: 118
diff changeset
   724
      plugged MVC operation (getBlock returns the label): 
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   725
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   726
        |top l model|
118
claus
parents: 113
diff changeset
   727
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   728
        model := PluggableAdaptor new
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   729
                        getBlock:[:m | 'hello']
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   730
                        putBlock:nil
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   731
                        updateBlock:nil.
118
claus
parents: 113
diff changeset
   732
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   733
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   734
        top extent:(200 @ 200).
118
claus
parents: 113
diff changeset
   735
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   736
        l := Label origin:0.0@0.0 corner:1.0@0.5 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   737
        l model:model; labelMessage:#value.
118
claus
parents: 113
diff changeset
   738
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   739
        top open.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   740
                                                                        [exEnd]
125
claus
parents: 118
diff changeset
   741
claus
parents: 118
diff changeset
   742
claus
parents: 118
diff changeset
   743
      use different label-selectors to access fields of a complex model:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   744
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   745
        |top panel model|
125
claus
parents: 118
diff changeset
   746
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   747
        model := Plug new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   748
        model respondTo:#field1 with:['value1'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   749
        model respondTo:#field2 with:['value2'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   750
        model respondTo:#field3 with:['value3'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   751
        model respondTo:#field4 with:['value4'].
125
claus
parents: 118
diff changeset
   752
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   753
        top := StandardSystemView new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   754
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   755
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   756
        panel elementsChangeSize:true.
125
claus
parents: 118
diff changeset
   757
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   758
        panel addSubView:((Label on:model) labelMessage:#field1).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   759
        panel addSubView:((Label on:model) labelMessage:#field2).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   760
        panel addSubView:((Label on:model) labelMessage:#field3).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   761
        panel addSubView:((Label on:model) labelMessage:#field4).
125
claus
parents: 118
diff changeset
   762
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   763
        top extent:(200 @ 200).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   764
        top open.
125
claus
parents: 118
diff changeset
   765
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   766
        (Delay forSeconds:5) wait.
125
claus
parents: 118
diff changeset
   767
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   768
        model respondTo:#field2 with:['new value2'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   769
        model changed:#value  
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   770
                                                                        [exEnd]
125
claus
parents: 118
diff changeset
   771
claus
parents: 118
diff changeset
   772
claus
parents: 118
diff changeset
   773
      same as above, using default aspects in the label, and an adaptor
claus
parents: 118
diff changeset
   774
      to translate aspects:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   775
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   776
        |top panel model v1|
125
claus
parents: 118
diff changeset
   777
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   778
        model := Plug new.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   779
        model respondTo:#field1 with:[v1].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   780
        model respondTo:#field1: with:[:arg | v1 := arg. model changed:#field1].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   781
        model respondTo:#field2 with:['value2'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   782
        model respondTo:#field2: with:[:arg |].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   783
        model respondTo:#field3 with:['value3'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   784
        model respondTo:#field3: with:[:arg |].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   785
        model respondTo:#field4 with:['value4'].
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   786
        model respondTo:#field4: with:[:arg |].
125
claus
parents: 118
diff changeset
   787
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   788
        top := StandardSystemView new.
125
claus
parents: 118
diff changeset
   789
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   790
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   791
        panel elementsChangeSize:true.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   792
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   793
        panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field1)) labelMessage:#value).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   794
        panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field2)) labelMessage:#value).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   795
        panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field3)) labelMessage:#value).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   796
        panel addSubView:((Label on:((AspectAdaptor subject:model) forAspect:#field4)) labelMessage:#value).
125
claus
parents: 118
diff changeset
   797
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   798
        top extent:(200 @ 200).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   799
        top open.
125
claus
parents: 118
diff changeset
   800
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   801
        (Delay forSeconds:5) wait.
125
claus
parents: 118
diff changeset
   802
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   803
        model field1:'new value1'.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   804
                                                                        [exEnd]
125
claus
parents: 118
diff changeset
   805
claus
parents: 118
diff changeset
   806
claus
parents: 118
diff changeset
   807
      use an adapter to access fields of a complex model:
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   808
                                                                        [exBegin]
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   809
        |top l panel model|
125
claus
parents: 118
diff changeset
   810
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   811
        model := #('one' 'two' 'three') asValue.
125
claus
parents: 118
diff changeset
   812
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   813
        top := StandardSystemView new.
125
claus
parents: 118
diff changeset
   814
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   815
        panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   816
        panel elementsChangeSize:true.
125
claus
parents: 118
diff changeset
   817
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   818
        panel addSubView:((Label on:(ProtocolAdaptor
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   819
                                        subjectChannel:model
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   820
                                        accessPath:#(1))) labelMessage:#value).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   821
        panel addSubView:((Label on:(ProtocolAdaptor
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   822
                                        subjectChannel:model
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   823
                                        accessPath:#(2))) labelMessage:#value).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   824
        panel addSubView:((Label on:(ProtocolAdaptor
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   825
                                        subjectChannel:model
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   826
                                        accessPath:#(3))) labelMessage:#value).
125
claus
parents: 118
diff changeset
   827
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   828
        top extent:(200 @ 200).
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   829
        top open.
125
claus
parents: 118
diff changeset
   830
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   831
        (Delay forSeconds:5) wait.
125
claus
parents: 118
diff changeset
   832
593
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   833
        model value:#('oneone' 'twotwo' 'threethree').
86dd024ed773 examples
Claus Gittinger <cg@exept.de>
parents: 585
diff changeset
   834
                                                                        [exEnd]
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 60
diff changeset
   835
"
3
claus
parents: 0
diff changeset
   836
! !
claus
parents: 0
diff changeset
   837
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
   838
!Label class methodsFor:'instance creation'!
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   839
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   840
form:aForm
118
claus
parents: 113
diff changeset
   841
    "return a new Label showing a form.
claus
parents: 113
diff changeset
   842
     OBSOLETE: you should now use #label: for both text and bitmap labels."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   843
2366
bdc591a205f8 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2302
diff changeset
   844
    <resource:#obsolete>
bdc591a205f8 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2302
diff changeset
   845
1246
9033af51413c obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   846
    self obsoleteMethodWarning:'use #label:'.
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2968
diff changeset
   847
    ^ (self onDevice:Screen current) label:aForm
1246
9033af51413c obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   848
9033af51413c obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   849
    "Modified: 16.6.1997 / 11:47:38 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   850
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   851
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   852
form:aForm in:aView
118
claus
parents: 113
diff changeset
   853
    "return a new Label showing a form.
claus
parents: 113
diff changeset
   854
     OBSOLETE: you should now use #label:in: for both text and bitmap labels."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   855
2366
bdc591a205f8 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2302
diff changeset
   856
    <resource:#obsolete>
bdc591a205f8 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2302
diff changeset
   857
1246
9033af51413c obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   858
    self obsoleteMethodWarning:'use #label:in:'.
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2968
diff changeset
   859
    ^ (self in:aView) label:aForm
1246
9033af51413c obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   860
9033af51413c obsolete: #form: / #form:in:
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   861
    "Modified: 16.6.1997 / 11:47:57 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   862
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   863
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
   864
!Label class methodsFor:'defaults'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   865
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   866
defaultExtent
571
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   867
    "return the default extent of my instances.
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   868
     The value returned here is usually ignored, and
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   869
     the value from preferredExtent taken instead."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   870
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   871
    ^ 16 @ 16
571
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   872
ddc5d56bd636 commentary
Claus Gittinger <cg@exept.de>
parents: 533
diff changeset
   873
    "Modified: 22.4.1996 / 23:36:11 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   874
!
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   875
2098
22fcc05794eb accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
   876
defaultForegroundColor
22fcc05794eb accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
   877
    "return the default foregroundColor of my instances."
22fcc05794eb accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
   878
22fcc05794eb accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
   879
    ^ DefaultForegroundColor
22fcc05794eb accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
   880
22fcc05794eb accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
   881
!
22fcc05794eb accessor for defaultForegroundColor
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
   882
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
   883
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   884
    "extract values from the styleSheet and cache them in class variables"
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   885
1356
a30147637916 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1291
diff changeset
   886
    <resource: #style (#'label.foregroundColor' #'label.backgroundColor'
442
2c65151c0f0a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
   887
                       #foregroundColor #backgroundColor
1356
a30147637916 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1291
diff changeset
   888
                       #'label.font')>
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   889
1872
08c4b4a2c65f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1867
diff changeset
   890
    DefaultForegroundColor := StyleSheet colorAt:#'label.foregroundColor'.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   891
    DefaultForegroundColor isNil ifTrue:[
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   892
        "/ fallBack: comon value
4915
8625f479ab46 class: Label
Stefan Vogel <sv@exept.de>
parents: 4899
diff changeset
   893
        DefaultForegroundColor := StyleSheet colorAt:#'foregroundColor' default:Color black.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   894
    ].
1872
08c4b4a2c65f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1867
diff changeset
   895
    DefaultBackgroundColor := StyleSheet colorAt:#'label.backgroundColor'.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   896
    DefaultBackgroundColor isNil ifTrue:[
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   897
        "/ fallBack: comon value
1872
08c4b4a2c65f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1867
diff changeset
   898
        DefaultBackgroundColor := StyleSheet colorAt:#'backgroundColor'.
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
   899
    ].
1872
08c4b4a2c65f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1867
diff changeset
   900
    DefaultFont := StyleSheet fontAt:#'label.font'.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   901
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   902
    "
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   903
     self updateStyleCache
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   904
    "
254
aa15cac0670f oops - foregroundColor was overwritten by backgroundColor (if defined in styleSheet)
Claus Gittinger <cg@exept.de>
parents: 250
diff changeset
   905
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   906
    "Modified: / 31.10.1997 / 14:53:48 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   907
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   908
4670
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   909
!Label class methodsFor:'menu specs'!
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   910
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   911
middleButtonMenu
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   912
    "This resource specification was automatically generated
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   913
     by the MenuEditor of ST/X."
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   914
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   915
    "Do not manually edit this!! If it is corrupted,
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   916
     the MenuEditor may not be able to read the specification."
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   917
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   918
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   919
    "
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   920
     MenuEditor new openOnClass:Label andSelector:#middleButtonMenu
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   921
     (Menu new fromLiteralArrayEncoding:(Label middleButtonMenu)) startUp
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   922
    "
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   923
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   924
    <resource: #menu>
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   925
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   926
    ^ 
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   927
     #(Menu
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   928
        (
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   929
         (MenuItem
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   930
            label: 'Copy Label Text'
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   931
            itemValue: copyLabelText
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   932
            enabled: isTextLabel
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   933
          )
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   934
         )
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   935
        nil
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   936
        nil
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   937
      )
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   938
! !
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
   939
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   940
!Label methodsFor:'accessing-channels'!
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   941
260
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   942
labelChannel
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   943
    "return the labelChannel - or nil"
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   944
260
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   945
    ^ labelChannel.
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   946
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   947
    "Created: / 16.12.1995 / 15:50:18 / cg"
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   948
    "Modified: / 31.10.1997 / 14:43:14 / cg"
260
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   949
!
475aa7b7d0e9 channel accessors added
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   950
145
claus
parents: 144
diff changeset
   951
labelChannel:aValueHolder
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   952
    "set the labelChannel - a valueHolder holding a string or image
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   953
     which is shown as my logo"
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   954
146
claus
parents: 145
diff changeset
   955
    |prev|
claus
parents: 145
diff changeset
   956
claus
parents: 145
diff changeset
   957
    prev := labelChannel.
145
claus
parents: 144
diff changeset
   958
    labelChannel := aValueHolder.
3927
6df1a9250681 changed #labelChannel:
Claus Gittinger <cg@exept.de>
parents: 3924
diff changeset
   959
    self setupChannel:aValueHolder for:nil withOld:prev.
6df1a9250681 changed #labelChannel:
Claus Gittinger <cg@exept.de>
parents: 3924
diff changeset
   960
    self getLabelFromLabelChannel.
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   961
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
   962
    "Modified: / 31.10.1997 / 14:37:02 / cg"
145
claus
parents: 144
diff changeset
   963
! !
claus
parents: 144
diff changeset
   964
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   965
!Label methodsFor:'accessing-colors'!
125
claus
parents: 118
diff changeset
   966
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   967
backgroundColor
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   968
    "return the background color"
125
claus
parents: 118
diff changeset
   969
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   970
    ^ bgColor 
125
claus
parents: 118
diff changeset
   971
!
claus
parents: 118
diff changeset
   972
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   973
backgroundColor:aColor
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
   974
    "set the background color"
125
claus
parents: 118
diff changeset
   975
263
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   976
    aColor ~~ bgColor ifTrue:[
3582
7794acba61ed care for nil backgroundColor:
Michael Beyl <mb@exept.de>
parents: 3557
diff changeset
   977
        bgColor := aColor.
7794acba61ed care for nil backgroundColor:
Michael Beyl <mb@exept.de>
parents: 3557
diff changeset
   978
        bgColor notNil ifTrue:[
5633
5ce074a3f531 device access
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
   979
            bgColor := bgColor onDevice:device.
3597
f34e303ef96e changed #backgroundColor:
sr
parents: 3582
diff changeset
   980
            self class == Label ifTrue:[
f34e303ef96e changed #backgroundColor:
sr
parents: 3582
diff changeset
   981
                super viewBackground:bgColor
f34e303ef96e changed #backgroundColor:
sr
parents: 3582
diff changeset
   982
            ].
1218
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   983
        ].
2913
bdf4fb09cfc0 invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
   984
        self invalidateRepairNow:true
263
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   985
    ]
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
   986
1414
b86d8f36f3a9 Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents: 1398
diff changeset
   987
    "Modified: / 15.1.1998 / 00:14:10 / stefan"
1554
b05a50854c76 redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
   988
    "Modified: / 6.6.1998 / 20:01:56 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   989
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
   990
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   991
etchedForegroundColor
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   992
    "return the etched foreground color (or nil)"
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   993
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   994
    ^ etchedFgColor
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   995
!
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   996
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   997
etchedForegroundColor:aColor
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   998
    "set the etched foreground color"
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   999
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1000
    aColor ~~ etchedFgColor ifTrue:[
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1001
        etchedFgColor := aColor.
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1002
        etchedFgColor notNil ifTrue:[
5633
5ce074a3f531 device access
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  1003
            etchedFgColor := etchedFgColor onDevice:device.
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1004
        ].
2913
bdf4fb09cfc0 invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
  1005
        self invalidateRepairNow:true
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1006
    ].
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1007
!
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1008
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1009
foregroundColor
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1010
    "return the foreground color"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1011
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1012
    ^ fgColor
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1013
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1014
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1015
foregroundColor:aColor
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1016
    "set the foreground color"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1017
263
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
  1018
    aColor ~~ fgColor ifTrue:[
5633
5ce074a3f531 device access
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  1019
        fgColor := aColor onDevice:device.
2913
bdf4fb09cfc0 invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
  1020
        self invalidateRepairNow:true
263
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
  1021
    ].
74a282375195 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 260
diff changeset
  1022
1414
b86d8f36f3a9 Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents: 1398
diff changeset
  1023
    "Modified: / 15.1.1998 / 00:14:22 / stefan"
1554
b05a50854c76 redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
  1024
    "Modified: / 6.6.1998 / 20:02:02 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1025
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1026
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1027
foregroundColor:fg backgroundColor:bg
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1028
    "set the colors to be used for drawing"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1029
993
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1030
    (fgColor ~~ fg or:[bgColor ~~ bg]) ifTrue:[
5633
5ce074a3f531 device access
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  1031
        fgColor := fg onDevice:device.
5ce074a3f531 device access
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  1032
        bgColor := bg onDevice:device.
1218
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1033
        self class == Label ifTrue:[
1414
b86d8f36f3a9 Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents: 1398
diff changeset
  1034
            super viewBackground:bgColor
1218
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1035
        ].
2913
bdf4fb09cfc0 invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
  1036
        self invalidateRepairNow:true
993
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1037
    ].
711
c830bb66598b use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1038
1414
b86d8f36f3a9 Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents: 1398
diff changeset
  1039
    "Modified: / 15.1.1998 / 00:14:36 / stefan"
1554
b05a50854c76 redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
  1040
    "Modified: / 6.6.1998 / 20:02:07 / cg"
1218
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1041
!
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1042
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1043
viewBackground:aColor
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1044
    "for labels, the viewBackground is forced to be the same as
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1045
     the backgroundColor"
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1046
1554
b05a50854c76 redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
  1047
    super viewBackground:aColor.
1218
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1048
    self class == Label ifTrue:[
1554
b05a50854c76 redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
  1049
        self backgroundColor:aColor
1218
0348f3314a39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
  1050
    ].
1554
b05a50854c76 redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
  1051
b05a50854c76 redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
  1052
    "Modified: / 6.6.1998 / 20:02:22 / cg"
133
claus
parents: 132
diff changeset
  1053
! !
claus
parents: 132
diff changeset
  1054
claus
parents: 132
diff changeset
  1055
!Label methodsFor:'accessing-contents'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1056
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1057
form:aForm
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1058
    "set the labels form; adjust extent if not already realized.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1059
     OBSOLETE: you should now use #label: for both strings and images"
118
claus
parents: 113
diff changeset
  1060
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2968
diff changeset
  1061
    <resource:#obsolete>
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2968
diff changeset
  1062
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1063
    self label:aForm
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1064
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1065
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1066
label
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1067
    "return the labels string or image"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1068
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1069
    ^ logo
118
claus
parents: 113
diff changeset
  1070
!
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1071
118
claus
parents: 113
diff changeset
  1072
label:aStringOrFormOrImage
4174
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1073
    "set the labelString or image; 
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1074
     adjust extent if not already realized and not fixedSize;
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1075
     also redraw"
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1076
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1077
    self label:aStringOrFormOrImage redraw:true
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1078
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1079
    "Modified: / 13-10-2010 / 12:17:36 / cg"
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1080
!
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1081
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1082
label:aStringOrFormOrImage redraw:doRedraw
118
claus
parents: 113
diff changeset
  1083
    "set the labelString or image; adjust extent if not already realized and
claus
parents: 113
diff changeset
  1084
     not fixedSize"
claus
parents: 113
diff changeset
  1085
3999
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1086
    |newLogo numberOfLines|
2639
bc13bf8e4f52 Non-String labels.
Stefan Vogel <sv@exept.de>
parents: 2592
diff changeset
  1087
bc13bf8e4f52 Non-String labels.
Stefan Vogel <sv@exept.de>
parents: 2592
diff changeset
  1088
    newLogo := aStringOrFormOrImage.
3999
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1089
    newLogo isString ifTrue:[
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1090
        numberOfLines := 1 + (newLogo occurrencesOf:(Character cr)).
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1091
        (numberOfLines ~~ 1) ifTrue:[
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1092
            newLogo := newLogo asStringCollection
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1093
        ]
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1094
    ] ifFalse:[
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1095
        newLogo isStringCollection ifTrue:[
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1096
            numberOfLines := newLogo size.
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1097
            (numberOfLines <= 1) ifTrue:[
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1098
                newLogo := newLogo asString
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1099
            ]
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1100
        ]
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1101
    ].
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1102
118
claus
parents: 113
diff changeset
  1103
    (aStringOrFormOrImage ~~ logo) ifTrue:[
616
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1104
        "/
6106
ea570c22a64d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6089
diff changeset
  1105
        "/ avoid recompute of size, if it's an image with
616
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1106
        "/ the same size
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1107
        "/
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1108
        aStringOrFormOrImage isImageOrForm ifTrue:[
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1109
            logo notNil ifTrue:[
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1110
                logo isImageOrForm ifTrue:[
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1111
                    logo extent = aStringOrFormOrImage extent ifTrue:[
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1112
                        logo := aStringOrFormOrImage.
4174
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1113
                        doRedraw ifTrue:[ self invalidateRepairNow:true ].
616
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1114
                        ^ self
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1115
                    ]
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1116
                ]
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1117
            ]
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1118
        ] ifFalse:[
806
a641ed42df70 dont ignore new label setting, if the emphasis changed
Claus Gittinger <cg@exept.de>
parents: 799
diff changeset
  1119
            "/ any change ?
4443
a5a69820a9b5 Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents: 4341
diff changeset
  1120
            (logo isString  
a5a69820a9b5 Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents: 4341
diff changeset
  1121
             and:[ newLogo isString
a5a69820a9b5 Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents: 4341
diff changeset
  1122
             and:[ newLogo = logo
a5a69820a9b5 Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents: 4341
diff changeset
  1123
             and:[ logo emphasis = newLogo emphasis]]]) ifTrue:[
3649
36c3b9d8bef3 changed #label:
Claus Gittinger <cg@exept.de>
parents: 3633
diff changeset
  1124
                ^ self
616
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1125
            ]
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1126
        ].
3557
e57daeff04be changed #label: - fix typo in comment
Stefan Vogel <sv@exept.de>
parents: 3531
diff changeset
  1127
        "/ do not check using #isString here;
3531
2cfac8dca1ef allow numeric label
Claus Gittinger <cg@exept.de>
parents: 3499
diff changeset
  1128
        "/ we allow for non-strings to be used as logo as well (it must understand displayOn:).
2cfac8dca1ef allow numeric label
Claus Gittinger <cg@exept.de>
parents: 3499
diff changeset
  1129
        newLogo isNumber ifTrue:[
2cfac8dca1ef allow numeric label
Claus Gittinger <cg@exept.de>
parents: 3499
diff changeset
  1130
            logo := newLogo asString
2cfac8dca1ef allow numeric label
Claus Gittinger <cg@exept.de>
parents: 3499
diff changeset
  1131
        ] ifFalse:[
2cfac8dca1ef allow numeric label
Claus Gittinger <cg@exept.de>
parents: 3499
diff changeset
  1132
            logo := newLogo.
2cfac8dca1ef allow numeric label
Claus Gittinger <cg@exept.de>
parents: 3499
diff changeset
  1133
        ].
4174
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1134
        doRedraw ifTrue:[ 
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1135
            self newLayout.
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1136
            self repairDamage 
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1137
        ].
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1138
    ]
616
f6d4c90abaec redraw if image-label changes
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
  1139
4174
a67dcc5bbc21 added: #label:redraw:
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  1140
    "Created: / 13-10-2010 / 12:16:34 / cg"
6106
ea570c22a64d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6089
diff changeset
  1141
    "Modified (format): / 13-02-2017 / 20:26:33 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1142
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1143
1367
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1144
label:newLabel suppressResize:suppress
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1145
    "change the label and optionally suppress a resize operation"
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1146
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1147
    |wasFix|
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1148
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1149
    wasFix := fixSize. 
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1150
    suppress ifTrue:[
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1151
        fixSize := true.
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1152
    ].
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1153
    here label:newLabel.
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1154
    fixSize := wasFix
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1155
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1156
    "Modified: / 29.10.1997 / 15:50:01 / cg"
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1157
!
660c8d594e4b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1356
diff changeset
  1158
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1159
labelString:aString
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1160
    "for ST-80 compatibility: same as #label:
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1161
     set the label-string; adjust extent if not already realized and not fixedSize"
118
claus
parents: 113
diff changeset
  1162
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1163
    self label:aString
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1164
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1165
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1166
labelWidth
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1167
    "return the logos width in pixels"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1168
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1169
    ^ labelWidth
118
claus
parents: 113
diff changeset
  1170
!
claus
parents: 113
diff changeset
  1171
claus
parents: 113
diff changeset
  1172
logo:something
claus
parents: 113
diff changeset
  1173
    "set the labels form or string.
claus
parents: 113
diff changeset
  1174
     OBSOLETE: the old version used #form: for images and #label: for strings.
2969
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2968
diff changeset
  1175
               you should now use #label: for any."
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2968
diff changeset
  1176
eb87f1aedd6c Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents: 2968
diff changeset
  1177
    <resource:#obsolete>
118
claus
parents: 113
diff changeset
  1178
claus
parents: 113
diff changeset
  1179
    self label:something
133
claus
parents: 132
diff changeset
  1180
! !
claus
parents: 132
diff changeset
  1181
claus
parents: 132
diff changeset
  1182
!Label methodsFor:'accessing-layout'!
claus
parents: 132
diff changeset
  1183
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1184
adjust
1921
93c064603431 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1917
diff changeset
  1185
    "return the adjust symbol. See #adjust: for an explanation."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1186
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1187
    ^ adjust
125
claus
parents: 118
diff changeset
  1188
!
claus
parents: 118
diff changeset
  1189
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1190
adjust:how
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1191
    "set the adjust, how which must be one of
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1192
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1193
     #left        -> left adjust logo
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1194
     #right       -> right adjust logo
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1195
     #center      -> center logo
6106
ea570c22a64d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6089
diff changeset
  1196
     #centerEach  -> like #center, but if it's a multiline logo,
1945
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
  1197
                     center each line individually.
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1198
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1199
     #centerRight -> center logo if it fits; 
533
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1200
                     BUT, if it does not fit, right adjust the logo
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1201
                     (use with filenames, where the interesting part is
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1202
                      at the right if the label is too small)
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1203
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1204
     #centerLeft  -> center logo if it fits; 
533
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1205
                     BUT, if it does not fit, left adjust the logo
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1206
                     (use with strings where the interesting part is at the
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1207
                      left if the label is too small)
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1208
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1209
     #leftRight   -> left adjust logo if it fits
533
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1210
                     BUT, if it does not fit, right adjust the logo
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1211
                     (use with filenames, where the interesting part is
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1212
                      at the right if the label is too small)
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1213
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1214
     #rightLeft   -> right adjust logo if it fits
533
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1215
                     BUT, if it does not fit, left adjust the logo
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1216
                     (use with strings where the interesting part is at the
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1217
                      left if the label is too small)
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1218
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1219
     See examples in the documentation category.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1220
    "
118
claus
parents: 113
diff changeset
  1221
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1222
    (adjust ~~ how) ifTrue:[
533
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1223
        adjust := how.
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1224
        self newLayout
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1225
    ]
533
49c086c33d4f commentary
Claus Gittinger <cg@exept.de>
parents: 442
diff changeset
  1226
6106
ea570c22a64d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6089
diff changeset
  1227
    "Modified: / 13-04-1996 / 11:17:58 / cg"
ea570c22a64d #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6089
diff changeset
  1228
    "Modified (comment): / 13-02-2017 / 20:26:28 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1229
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1230
5445
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  1231
extraMarginForBorder
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  1232
    "some (round) borders may need more space"
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  1233
    
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  1234
    ^ 0
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  1235
!
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  1236
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1237
font:aFont
665
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1238
    "set the font - if I'm not realized and not fixedSize, adjust my size.
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1239
     CAVEAT: with the addition of Text objects,
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1240
             this method is going to be obsoleted by a textStyle
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1241
             method, which allows specific control over
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1242
             normalFont/boldFont/italicFont parameters."
125
claus
parents: 118
diff changeset
  1243
4891
9f33a5a44868 class: Label
Stefan Vogel <sv@exept.de>
parents: 4672
diff changeset
  1244
    (aFont notNil and:[aFont ~~ gc font]) ifTrue:[
9f33a5a44868 class: Label
Stefan Vogel <sv@exept.de>
parents: 4672
diff changeset
  1245
        super font:aFont.
416
ac9754b3df67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1246
        self newLayout
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1247
    ]
416
ac9754b3df67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 392
diff changeset
  1248
665
8a8f6e94e1d7 commentary
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1249
    "Modified: 22.5.1996 / 12:36:29 / cg"
133
claus
parents: 132
diff changeset
  1250
!
claus
parents: 132
diff changeset
  1251
6089
72067de3f99b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6088
diff changeset
  1252
horizontalSpace
72067de3f99b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6088
diff changeset
  1253
    "get the number of pixels by which the logo
72067de3f99b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6088
diff changeset
  1254
     is horizontally inset from the border"
72067de3f99b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6088
diff changeset
  1255
72067de3f99b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6088
diff changeset
  1256
    ^ hSpace 
72067de3f99b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6088
diff changeset
  1257
!
72067de3f99b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6088
diff changeset
  1258
133
claus
parents: 132
diff changeset
  1259
horizontalSpace:aNumber
claus
parents: 132
diff changeset
  1260
    "set the number of pixels by which the logo
claus
parents: 132
diff changeset
  1261
     is horizontally inset from the border"
claus
parents: 132
diff changeset
  1262
162
claus
parents: 155
diff changeset
  1263
    hSpace := aNumber.
claus
parents: 155
diff changeset
  1264
    self newLayout
133
claus
parents: 132
diff changeset
  1265
!
claus
parents: 132
diff changeset
  1266
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1267
layout:something
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1268
    "OBSOLETE compatibility interface. Will vanish.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1269
     for protocol compatibility: alias for #adjust:.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1270
     Please use #adjust:, since #layout: conflicts with a method
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1271
     in VW (which has a completely different meaning).
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1272
     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
  1273
     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
  1274
2366
bdc591a205f8 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2302
diff changeset
  1275
    <resource:#obsolete>
bdc591a205f8 Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2302
diff changeset
  1276
3215
f6bf6065822c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3049
diff changeset
  1277
    something isSymbol ifFalse:[^ super layout:something].
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1278
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1279
    self obsoleteMethodWarning:'use #adjust:'.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1280
    self adjust:something
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1281
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1282
    "Modified: 31.8.1995 / 23:08:13 / claus"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1283
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1284
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1285
sizeFixed
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1286
    "return the fix-size attribute"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1287
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1288
    ^ fixSize
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1289
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1290
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1291
sizeFixed:aBoolean
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1292
    "set/clear the fix-size attribute. 
5708
991bcc1c7739 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5633
diff changeset
  1293
     If true, the label will not change its size when the labelString/logo
991bcc1c7739 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5633
diff changeset
  1294
     changes. 
991bcc1c7739 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5633
diff changeset
  1295
     If false (the default), it will resize itself to make the logo fit."
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1296
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1297
    fixSize := aBoolean
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1298
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1299
6088
ffb5be6c8bca #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6077
diff changeset
  1300
verticalSpace
ffb5be6c8bca #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6077
diff changeset
  1301
    "get the number of pixels by which the logo
ffb5be6c8bca #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6077
diff changeset
  1302
     is vertically inset from the border"
ffb5be6c8bca #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6077
diff changeset
  1303
ffb5be6c8bca #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6077
diff changeset
  1304
    ^ vSpace
ffb5be6c8bca #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6077
diff changeset
  1305
!
ffb5be6c8bca #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6077
diff changeset
  1306
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1307
verticalSpace:aNumber
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1308
    "set the number of pixels by which the logo
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1309
     is vertically inset from the border"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1310
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1311
    vSpace := aNumber.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1312
    self newLayout
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1313
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1314
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1315
!Label methodsFor:'accessing-mvc'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1316
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1317
addModelInterfaceTo:aDictionary
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1318
    "see comment in View>>modelInterface"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1319
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1320
    super addModelInterfaceTo:aDictionary.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1321
    aDictionary at:#labelMessage put:labelMsg
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1322
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1323
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1324
converter:aConverter
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1325
    "set the printConverter;
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1326
     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
  1327
     representation (if non-nil). If nil, the model is supposed to
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1328
     return a string or bitmap image."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1329
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1330
    converter := aConverter
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1331
!
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1332
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1333
labelMessage 
5782
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1334
    "return the symbol used to acquire the labelString/image from the model
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1335
     when the aspect changes.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1336
     The default is nil, which means: leave the label unchanged."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1337
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1338
    ^ labelMsg
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1339
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1340
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1341
labelMessage:aSymbol 
5782
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1342
    "set the symbol used to acquire the labelString/image from the model.
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1343
     The default is nil, which means: leave the label unchanged."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1344
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1345
    labelMsg ~~ aSymbol ifTrue:[
5782
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1346
        labelMsg := aSymbol.
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1347
        self getLabelFromModel
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1348
    ]
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1349
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1350
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1351
model:aModel
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1352
    super model:aModel.
1039
28ff56306e31 checkin from browser
ca
parents: 993
diff changeset
  1353
    labelMsg notNil ifTrue:[
28ff56306e31 checkin from browser
ca
parents: 993
diff changeset
  1354
        self getLabelFromModel.
28ff56306e31 checkin from browser
ca
parents: 993
diff changeset
  1355
    ]
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1356
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1357
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1358
!Label methodsFor:'change & update'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1359
3924
57f03ead2eca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1360
getLabelFromLabelChannel
57f03ead2eca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1361
    self label:(labelChannel value).
57f03ead2eca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1362
!
57f03ead2eca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1363
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1364
update:something with:aParameter from:changedObject
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1365
    "the MVC way of changing the label ..."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1366
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1367
    changedObject notNil ifTrue:[
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1368
        changedObject == labelChannel ifTrue:[
3924
57f03ead2eca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  1369
            self getLabelFromLabelChannel.
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1370
            ^ self
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1371
        ].
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1372
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1373
        changedObject == model ifTrue:[
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1374
            something == aspectMsg ifTrue:[
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1375
                self getLabelFromModel.
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1376
                ^ self.
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1377
            ]
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1378
        ].
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1379
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1380
    ^ super update:something with:aParameter from:changedObject
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1381
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1382
    "Modified: / 31.10.1997 / 14:32:02 / cg"
1828
3fa20f5e5c80 Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1754
diff changeset
  1383
    "Modified: / 30.3.1999 / 13:57:26 / stefan"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1384
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1385
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1386
!Label methodsFor:'event handling'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1387
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1388
sizeChanged:how
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1389
    "sent whenever size is changed by someone else - recompute the
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1390
     logos position within the View."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1391
1508
15d1b3e7e92a oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  1392
    |prevX prevY|
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1393
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1394
    super sizeChanged:how.
1508
15d1b3e7e92a oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  1395
15d1b3e7e92a oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  1396
    prevX := labelOriginX.
15d1b3e7e92a oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  1397
    prevY := labelOriginY.
1392
d30d46371cb7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1374
diff changeset
  1398
    self computeLabelOrigin.
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1399
    shown ifTrue:[
711
c830bb66598b use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1400
        (adjust == #fit
1508
15d1b3e7e92a oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  1401
        or:[labelOriginX ~~ prevX 
15d1b3e7e92a oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  1402
        or:[labelOriginY ~~ prevY 
15d1b3e7e92a oops - resize in Y must redraw
Claus Gittinger <cg@exept.de>
parents: 1428
diff changeset
  1403
        or:[how ~~ #smaller]]]) ifTrue:[
1509
56476462887d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
  1404
            "/ self clear.
711
c830bb66598b use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1405
            self invalidate.
1509
56476462887d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
  1406
            "/ self redrawEdges
711
c830bb66598b use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1407
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1408
    ]
711
c830bb66598b use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1409
1509
56476462887d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1508
diff changeset
  1410
    "Modified: / 28.4.1998 / 17:07:57 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1411
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1412
1867
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1413
!Label methodsFor:'focus handling'!
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1414
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1415
wantsFocusWithButtonPress
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1416
    self class == Label ifTrue:[^ false].
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1417
    ^ super wantsFocusWithButtonPress
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1418
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1419
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1420
! !
d27de2b0705c dont take the focus on click
Claus Gittinger <cg@exept.de>
parents: 1857
diff changeset
  1421
2751
dcba8a160aed method category rename
Claus Gittinger <cg@exept.de>
parents: 2706
diff changeset
  1422
!Label methodsFor:'initialization & release'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1423
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1424
fetchDeviceResources
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1425
    "fetch device colors, to avoid reallocation at redraw time"
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1426
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1427
    super fetchDeviceResources.
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1428
5633
5ce074a3f531 device access
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  1429
    fgColor := fgColor onDevice:device.
5ce074a3f531 device access
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  1430
    bgColor := bgColor onDevice:device.
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1431
1414
b86d8f36f3a9 Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents: 1398
diff changeset
  1432
    "Created: / 13.1.1997 / 23:34:30 / cg"
b86d8f36f3a9 Use Color>>onDevice: instead of obsolete Color>>on:
Stefan Vogel <sv@exept.de>
parents: 1398
diff changeset
  1433
    "Modified: / 15.1.1998 / 00:13:46 / stefan"
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1434
!
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1435
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1436
initStyle
967
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 935
diff changeset
  1437
    "setup viewStyle specifics"
6739eb5496da commentary
Claus Gittinger <cg@exept.de>
parents: 935
diff changeset
  1438
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1439
    super initStyle.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1440
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1441
    DefaultBackgroundColor notNil ifTrue:[
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1442
        bgColor := DefaultBackgroundColor
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
  1443
    ] ifFalse:[
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1444
        bgColor := viewBackground.
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1445
    ].
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1446
    DefaultForegroundColor notNil ifTrue:[
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1447
        fgColor := DefaultForegroundColor
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  1448
    ] ifFalse:[
4915
8625f479ab46 class: Label
Stefan Vogel <sv@exept.de>
parents: 4899
diff changeset
  1449
        fgColor := self blackColor.
1374
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1450
    ].
578f71a242f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1367
diff changeset
  1451
    self class == Label ifTrue:[
4020
3b0d7d8915a8 no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents: 4003
diff changeset
  1452
        self borderWidth:0.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 25
diff changeset
  1453
    ]
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  1454
4318
9990f0f336f7 comment/format in: #initStyle
az
parents: 4174
diff changeset
  1455
    "Modified: / 31-10-1997 / 14:57:23 / cg"
9990f0f336f7 comment/format in: #initStyle
az
parents: 4174
diff changeset
  1456
    "Modified (comment): / 05-10-2011 / 15:51:09 / az"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1457
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1458
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1459
initialize
4891
9f33a5a44868 class: Label
Stefan Vogel <sv@exept.de>
parents: 4672
diff changeset
  1460
    |currentFont|
9f33a5a44868 class: Label
Stefan Vogel <sv@exept.de>
parents: 4672
diff changeset
  1461
6077
8e8dfbc562a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6052
diff changeset
  1462
    <modifier: #super> "must be called if redefined"
8e8dfbc562a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6052
diff changeset
  1463
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1464
    super initialize.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1465
5817
fd5acaa8e474 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 5785
diff changeset
  1466
    currentFont := gc font.
4891
9f33a5a44868 class: Label
Stefan Vogel <sv@exept.de>
parents: 4672
diff changeset
  1467
    self initialHeight:(currentFont height + currentFont descent).
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1468
    adjust := #center.
118
claus
parents: 113
diff changeset
  1469
    labelOriginX := labelOriginY := 0.
claus
parents: 113
diff changeset
  1470
    labelWidth := labelHeight := 0.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1471
    logo := nil.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1472
    fixSize := false.
5943
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1473
    hSpace := ((self horizontalPixelPerMillimeter:0.5) max:2) rounded.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1474
    vSpace := ((self verticalPixelPerMillimeter:0.5) max:2) rounded
6077
8e8dfbc562a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6052
diff changeset
  1475
8e8dfbc562a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6052
diff changeset
  1476
    "Modified: / 08-02-2017 / 00:32:40 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1477
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1478
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1479
recreate
2258
806d3b8a6e97 comment
Claus Gittinger <cg@exept.de>
parents: 2192
diff changeset
  1480
    "after snapin or a migration, labels dimensions may have changed due to
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1481
     different font parameters"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1482
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1483
    super recreate.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1484
    self computeLabelSize.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1485
    self computeLabelOrigin
2592
e352f0afe352 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1486
!
e352f0afe352 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1487
e352f0afe352 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1488
release
e352f0afe352 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1489
    labelChannel notNil ifTrue:[
e352f0afe352 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1490
        labelChannel removeDependent:self.
e352f0afe352 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1491
        labelChannel := nil.
e352f0afe352 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1492
    ].
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1493
    self stopAnimation.
2592
e352f0afe352 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2496
diff changeset
  1494
    super release
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1495
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1496
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1497
!Label methodsFor:'label animation'!
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1498
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1499
animationDelay
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1500
    ^ 100 milliseconds
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1501
!
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1502
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1503
animationDelayTopOrBottom
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1504
    ^ 3 seconds
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1505
!
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1506
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1507
doAnimate
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1508
    "by slow scrolling the label, ensure that the label's text is readable.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1509
     (stops when the cursor enters)"
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1510
    
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1511
    |animatorState offset atTop atBottom nextOffset nextMoveDirection nextAnimationDelay focusView|
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1512
    
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1513
    animatorState := self objectAttributeAt:#animator.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1514
    animatorState isNil ifTrue:[^ self "I have been stopped in the meanwhile"].
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1515
    
5785
5da329cd002e #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5782
diff changeset
  1516
    (gc drawableId isNil) ifTrue:[
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1517
        "/ view has been closed.
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1518
        self stopAnimation.
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1519
        ^ self
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1520
    ].
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1521
    logo == (animatorState logoShown) ifFalse:[
5750
12b4fa216382 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5749
diff changeset
  1522
        "/ logo changed - stop it
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1523
        self stopAnimation.
5750
12b4fa216382 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5749
diff changeset
  1524
        ^ self
12b4fa216382 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5749
diff changeset
  1525
    ].
5752
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1526
    shown ifFalse:[
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1527
        "/ currently invisible (iconified/hidden)
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1528
        Processor addTimedBlock:(animatorState timedBlock) after:self animationDelayTopOrBottom.
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1529
        self computeLabelOrigin.
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1530
        ^ self.
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1531
    ].
5755
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  1532
    (controller notNil and:[controller entered]) ifTrue:[
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  1533
        "/ pause animation
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  1534
        Processor addTimedBlock:(animatorState timedBlock) after:0.5 seconds.
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  1535
        ^ self.
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  1536
    ].
5750
12b4fa216382 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5749
diff changeset
  1537
    
5752
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1538
    offset := animatorState nextOffset max:0.
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1539
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1540
    atTop := (offset <= 0).
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1541
    "/ Transcript printf:'labelHeight: %d offset: %d fA: %d fH: %d height: %d\n'
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1542
    "/              withAll:{ labelHeight . offset . self font ascent . self font height . height }.
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1543
    "/ (labelHeight - offset) is restHeight
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1544
    atBottom := (labelHeight - offset) < height.
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1545
    
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1546
    nextAnimationDelay := (atTop | atBottom)
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1547
                                ifTrue:[ self animationDelayTopOrBottom ]
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1548
                                ifFalse:[ self animationDelay ]. 
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1549
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1550
    nextMoveDirection := animatorState moveDirection.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1551
    atTop ifTrue:[
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1552
        nextMoveDirection := #down
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1553
    ].
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1554
    
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1555
    atBottom ifTrue:[
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1556
        "/ after a longer delay, start again from top
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1557
        "/ nextOffset := 0.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1558
        "/ nextMoveDirection := #down.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1559
        "/ after a longer delay, start moving up again (fast)
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1560
        nextOffset := offset - 1.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1561
        nextMoveDirection := #up.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1562
    ] ifFalse:[
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1563
        nextMoveDirection == #down ifTrue:[
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1564
            nextOffset := offset + 1.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1565
        ] ifFalse:[
5752
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1566
            nextOffset := offset - 2.
15cf293cf929 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1567
            nextAnimationDelay := nextAnimationDelay / 4. "/ fast
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1568
        ].    
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1569
    ].
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1570
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1571
    "/ If I am not part of the active window, scroll back to top and wait longer...
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1572
    ((focusView := Display focusView) notNil
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1573
    and:[ focusView windowGroup == self windowGroup ]) ifFalse:[
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1574
        nextOffset := offset := 0.
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1575
        nextAnimationDelay := self animationDelayTopOrBottom.
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1576
        nextMoveDirection := #down.
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1577
    ].
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1578
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1579
    labelOriginY := offset negated.
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1580
    animatorState nextOffset:nextOffset.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1581
    animatorState moveDirection:nextMoveDirection.
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1582
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1583
    self invalidate.
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1584
    Processor addTimedBlock:(animatorState timedBlock) after:nextAnimationDelay.
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1585
!
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1586
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1587
startAnimation
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1588
    "start an animator, which scrolls the label's text.
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1589
     (slow scroll which stops when the cursor enters)"
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1590
    
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1591
    |timedBlock|
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1592
    
5755
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  1593
    self enableEnterLeaveEvents.
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  1594
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1595
    self stopAnimation.
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1596
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1597
    timedBlock := [ self doAnimate ].
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1598
    self 
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1599
        objectAttributeAt:#animator 
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1600
        put:(AnimatorState new 
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1601
                timedBlock:timedBlock 
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1602
                nextOffset:0 
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1603
                moveDirection:#down 
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1604
                logoShown:logo).
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1605
    Processor addTimedBlock:timedBlock after:(self animationDelay)
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1606
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1607
    "
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1608
     |l|
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1609
     l := Label new.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1610
     l height:30.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1611
     l sizeFixed:true.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1612
     l label:'Line1
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1613
Line2
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1614
Line3
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1615
Line4'.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1616
     l openAndWait.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1617
     l startAnimation.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1618
     Delay waitForSeconds:10.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1619
     l stopAnimation.
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1620
    "
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1621
!
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1622
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1623
stopAnimation
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1624
    |animatorState timedBlock|
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1625
    
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1626
    animatorState := self removeObjectAttribute:#animator.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1627
    animatorState notNil ifTrue:[
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1628
        timedBlock := animatorState timedBlock.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1629
        Processor removeTimedBlock:timedBlock.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1630
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1631
        "/ ensure that things are in their normal state again
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  1632
        self computeLabelOrigin.
5749
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1633
        shown ifTrue:[
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1634
            self invalidate.
d343e6f28915 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5746
diff changeset
  1635
        ].
5746
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1636
    ].
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1637
! !
813beb879bc9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5708
diff changeset
  1638
4670
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1639
!Label methodsFor:'menu'!
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1640
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1641
copyLabelText
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1642
    |text|
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1643
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1644
    text := logo asString.
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1645
    self setClipboardText:text.
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1646
!
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1647
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1648
middleButtonMenu
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1649
    |m|
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1650
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1651
    m := super middleButtonMenu.
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1652
    m isNil ifTrue:[
4672
8178bf083831 class: Label
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
  1653
        m := self yellowButtonMenu.
8178bf083831 class: Label
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
  1654
        m isNil ifTrue:[
8178bf083831 class: Label
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
  1655
            "/ not a customized menu
8178bf083831 class: Label
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
  1656
            self class == Label ifTrue:[
8178bf083831 class: Label
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
  1657
                m := self class middleButtonMenu
8178bf083831 class: Label
Claus Gittinger <cg@exept.de>
parents: 4670
diff changeset
  1658
            ]
4670
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1659
        ].
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1660
    ].
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1661
    ^ m
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1662
! !
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1663
5123
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1664
!Label methodsFor:'native widget support'!
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1665
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1666
nativeWindowType
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1667
    "return a symbol describing my native window type 
5538
b6ed8574094a class: SelectionInListView
Claus Gittinger <cg@exept.de>
parents: 5445
diff changeset
  1668
     (may be used internally by the device as a native window creation hint,
b6ed8574094a class: SelectionInListView
Claus Gittinger <cg@exept.de>
parents: 5445
diff changeset
  1669
      if the device supports native windows)"
5123
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1670
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1671
    self class == Label ifTrue:[
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1672
        ^ #Label
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1673
    ].
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1674
    ^ nil
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1675
! !
a47a0d6a9679 class: Label
Claus Gittinger <cg@exept.de>
parents: 4915
diff changeset
  1676
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1677
!Label methodsFor:'private'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1678
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1679
computeLabelOrigin
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1680
    "(re)compute the origin of the label whenever label, font or view-size changes"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1681
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1682
    |x y a|
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1683
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1684
    labelHeight isNil ifTrue:[^ self].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1685
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1686
    adjust == #fit ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1687
        labelOriginX := labelOriginY := margin.
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1688
        ^ self
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1689
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1690
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1691
    "if it does not fit, should we make the origin visible,
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1692
     or the center ?
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1693
     (for text, the center seems better. 
5587
d5bf038cb1c8 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5538
diff changeset
  1694
      For images, I don't really know ...)
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1695
     The commented code below makes the origin visible
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1696
   "
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1697
"/    (labelHeight < height) ifTrue:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1698
"/        y := (height - labelHeight) // 2
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1699
"/    ] ifFalse:[
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1700
"/        y := 0
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1701
"/    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1702
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1703
    "always center vertically"
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1704
    y := (height - labelHeight) // 2.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1705
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1706
    labelOriginY := y.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1707
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1708
    a := adjust.
1945
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
  1709
    a == #centerEach ifTrue:[a := #center].
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
  1710
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1711
    (width < labelWidth) ifTrue:[
1921
93c064603431 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1917
diff changeset
  1712
        ((a == #centerRight) or:[a == #leftRight]) ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1713
            a := #right
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1714
        ] ifFalse:[
1921
93c064603431 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1917
diff changeset
  1715
            ((a == #centerLeft) or:[a == #rightLeft]) ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1716
                a := #left
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1717
            ].
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1718
        ]
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1719
    ] ifFalse:[
1921
93c064603431 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1917
diff changeset
  1720
        ((a == #centerRight) or:[a == #centerLeft]) ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1721
            a := #center
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1722
        ] ifFalse:[
1921
93c064603431 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1917
diff changeset
  1723
            a == #leftRight ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1724
                a := #left
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1725
            ] ifFalse:[
1921
93c064603431 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1917
diff changeset
  1726
                a == #rightLeft ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1727
                    a := #right
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1728
                ]
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1729
            ]
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1730
        ]
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1731
    ].
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1732
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1733
    (a == #center) ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1734
        " center text/form in button "
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1735
        x := (width - labelWidth) // 2.
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1736
    ] ifFalse:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1737
        (a == #left) ifTrue:[
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1738
            x := margin
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1739
        ] ifFalse:[
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1740
            "/ #right
5445
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  1741
            x := width - labelWidth - margin - self extraMarginForBorder
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1742
        ]
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1743
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1744
    labelOriginX := x
318
73ea409232c0 new adjusts: #leftRight and #rightLeft (sounds wierd - mhmh)
Claus Gittinger <cg@exept.de>
parents: 304
diff changeset
  1745
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1746
    "Modified: 13.5.1996 / 10:55:17 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1747
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1748
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1749
computeLabelSize
3999
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1750
    "compute the extent needed to hold the logo"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1751
3999
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1752
    |ext|
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1753
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1754
    logo isNil ifTrue:[^ self].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1755
3999
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1756
    ext := self rawLabelSizeOf:logo.
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1757
    labelWidth := ext x.
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  1758
    labelHeight := ext y.
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1759
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1760
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1761
getLabelFromModel
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1762
    "ask my model for the label to show.
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1763
     Here, we use labelMsg (instead of aspectMsg). 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1764
     This allows multiple labels to react on the same aspect, 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1765
     but show different labels when changed 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1766
     (also, since labelMsg defaults to nil, constant labels
5782
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1767
      which have a nil labelMsg will not try to acquire a labelString)."
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1768
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1769
    |val|
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1770
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1771
    (model notNil 
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1772
    and:[labelMsg notNil]) ifTrue:[
5782
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1773
        val := model perform:labelMsg.
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1774
        converter notNil ifTrue:[
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1775
            val := converter printStringFor:val
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1776
        ].
0a043d77cff7 #OTHER by mawalch
mawalch
parents: 5755
diff changeset
  1777
        self label:val.
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1778
    ].
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1779
!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1780
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1781
newLayout
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1782
    "recompute position/size after a change
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1783
     - helper for form:/font: etc."
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1784
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1785
    self computeLabelSize.
3499
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  1786
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1787
    fixSize ifFalse:[
3499
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  1788
        self resize.
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  1789
    ] ifTrue:[
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  1790
        self computeLabelOrigin.
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1791
    ].
2913
bdf4fb09cfc0 invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2751
diff changeset
  1792
    self invalidate
711
c830bb66598b use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  1793
1554
b05a50854c76 redrawNow for visible changes.
Claus Gittinger <cg@exept.de>
parents: 1509
diff changeset
  1794
    "Modified: / 6.6.1998 / 19:23:45 / cg"
5943
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1795
!
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1796
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1797
rawLabelSizeOf:aLogo
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1798
    "compute the extent needed to hold aLogo; aForm or aString"
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1799
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1800
    |logoUsed numberOfLines w h textHeight textWidth bounds|
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1801
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1802
    logoUsed := aLogo.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1803
    aLogo isString ifTrue:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1804
        numberOfLines := 1 + (aLogo occurrencesOf:(Character cr)).
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1805
        (numberOfLines ~~ 1) ifTrue:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1806
            logoUsed := aLogo asStringCollection
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1807
        ]
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1808
    ] ifFalse:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1809
        (aLogo isStringCollection) ifTrue:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1810
            numberOfLines := aLogo size.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1811
            (numberOfLines <= 1) ifTrue:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1812
                logoUsed := aLogo asString
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1813
            ]
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1814
        ]
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1815
    ].
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1816
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1817
    numberOfLines isNil ifTrue:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1818
        "logoUsed is neither a String nor a StringCollection"
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1819
        (logoUsed respondsTo:#preferredBounds) ifTrue:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1820
            bounds := logoUsed preferredBounds.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1821
            w := bounds width.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1822
            h := bounds height.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1823
        ] ifFalse:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1824
            w := logoUsed widthOn:self.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1825
            h := logoUsed heightOn:self.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1826
        ].
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1827
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1828
"/        b := logoUsed bounds.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1829
"/        labelWidth := b right.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1830
"/        labelHeight := b bottom.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1831
        logoUsed isImageOrForm ifFalse:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1832
            w := w + (hSpace * 2).
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1833
            h := h + (vSpace * 2).
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1834
        ].
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1835
        ^ w@h
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1836
    ].
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1837
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1838
    logoUsed isString ifTrue:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1839
        "/ a string or Text
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1840
        textHeight := logoUsed heightOn:self.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1841
        textWidth := logoUsed widthOn:self.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1842
    ] ifFalse:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1843
        "/ a StringCollection
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1844
        textHeight := (gc font height) * numberOfLines.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1845
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1846
        textWidth := 0.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1847
        logoUsed do:[:line |
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1848
            |thisWidth|
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1849
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1850
            line notNil ifTrue:[
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1851
                thisWidth := line asString widthOn:self.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1852
                textWidth := textWidth max:thisWidth
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1853
            ]
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1854
        ].
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1855
    ].
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1856
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1857
    w := textWidth + (hSpace * 2).
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1858
    h := textHeight + (vSpace * 2).
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1859
    ^ w@h
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1860
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1861
    "Modified: / 05-12-2011 / 22:35:44 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1862
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1863
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1864
!Label methodsFor:'queries'!
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1865
4670
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1866
isTextLabel
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1867
    ^ logo isString
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1868
!
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  1869
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1870
preferredExtent
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1871
    "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
  1872
5943
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1873
    |ext m2|
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1874
4003
1ec317f51033 preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents: 3999
diff changeset
  1875
    "/ If I have an explicit preferredExtent...
3751
8c607457ad94 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3651
diff changeset
  1876
    explicitExtent notNil ifTrue:[
8c607457ad94 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3651
diff changeset
  1877
        ^ explicitExtent
8c607457ad94 changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents: 3651
diff changeset
  1878
    ].
4003
1ec317f51033 preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents: 3999
diff changeset
  1879
    "/ If I have a cached preferredExtent value...
713
0c38ad51016d care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
  1880
    preferredExtent notNil ifTrue:[
0c38ad51016d care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
  1881
        ^ preferredExtent
0c38ad51016d care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
  1882
    ].
4003
1ec317f51033 preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents: 3999
diff changeset
  1883
    "/ If I have a frozen extent value...
1ec317f51033 preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents: 3999
diff changeset
  1884
    fixSize ifTrue:[
1ec317f51033 preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents: 3999
diff changeset
  1885
        ^ self extent
1ec317f51033 preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents: 3999
diff changeset
  1886
    ].
361
b5cb40f55316 if size is fixed, return my actual size in #preferredExtent
ca
parents: 318
diff changeset
  1887
303
8408cec09472 if undefined, set label to empty string when asked for preferredExtent (would otherwise return 0@0)
ah
parents: 275
diff changeset
  1888
    logo isNil ifTrue:[
361
b5cb40f55316 if size is fixed, return my actual size in #preferredExtent
ca
parents: 318
diff changeset
  1889
        self label:''
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1890
    ].
4003
1ec317f51033 preferredExtent code cleanup
Claus Gittinger <cg@exept.de>
parents: 3999
diff changeset
  1891
    ext := self rawLabelSizeOf:logo.
5943
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1892
    m2 := (margin + self extraMarginForBorder) * 2.
050b4d258e8d #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5855
diff changeset
  1893
    ^ (m2 + ext x + hSpace) @ (m2 + vSpace + ext y)
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1894
799
64f8700489a4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 794
diff changeset
  1895
    "Modified: 19.7.1996 / 20:44:41 / cg"
993
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1896
!
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1897
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1898
redrawsFull
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1899
    ^ true
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1900
51cce445b5d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
  1901
    "Created: 7.2.1997 / 16:41:41 / cg"
202
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1902
! !
01f3cbb8e20e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 179
diff changeset
  1903
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1904
!Label methodsFor:'redrawing'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1905
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1906
clearInsideWith:bg
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1907
    |cutOff mustClear|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1908
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1909
    cutOff := margin * 2.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1910
3
claus
parents: 0
diff changeset
  1911
    mustClear := true.
claus
parents: 0
diff changeset
  1912
87
2c6ab478466a *** empty log message ***
claus
parents: 81
diff changeset
  1913
    (logo notNil and:[logo isImageOrForm]) ifTrue:[
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1914
        (labelOriginX == 0 and:[labelOriginY == 0]) ifTrue:[
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1915
            logo width >= (width - cutOff) ifTrue:[
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1916
                logo height >= (height - cutOff) ifTrue:[
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1917
                    "no need to clear before - avoid flicker"
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1918
                    mustClear := false
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1919
                ]
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1920
            ]
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1921
        ].
3
claus
parents: 0
diff changeset
  1922
    ].
claus
parents: 0
diff changeset
  1923
claus
parents: 0
diff changeset
  1924
    mustClear ifTrue:[
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1925
        gc paint:bg.
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1926
        gc fillRectangleX:margin y:margin width:(width - cutOff) height:(height - cutOff).
3
claus
parents: 0
diff changeset
  1927
    ].
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1928
!
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1929
3850
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1930
drawImageLogo:imageOrForm x:x y:y opaque:opaque
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1931
    (opaque not or:[imageOrForm mask notNil]) ifTrue:[
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1932
        gc displayForm:imageOrForm x:x y:y 
3850
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1933
    ] ifFalse:[
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1934
        gc displayOpaqueForm:imageOrForm x:x y:y 
3850
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1935
    ]
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1936
!
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1937
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1938
drawOtherLogo:something x:x y:y opaque:opaque
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1939
    something displayOn:self x:x y:y opaque:opaque
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1940
!
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1941
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1942
drawStringLogo:aString x:x y:y
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1943
    gc displayString:aString x:x y:y
3850
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1944
!
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  1945
1679
d57885b88668 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1665
diff changeset
  1946
drawWin95FocusFrame
1891
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1947
    |m1 m2|
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1948
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1949
    m1 := margin + 1.
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1950
    m2 := margin + margin + 2.
1679
d57885b88668 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1665
diff changeset
  1951
    self
1891
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1952
        displayDottedRectangleX:m1
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1953
        y:m1
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1954
        width:(width - m2)
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1955
        height:(height - m2).
1679
d57885b88668 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1665
diff changeset
  1956
d57885b88668 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1665
diff changeset
  1957
    "Created: / 17.9.1998 / 14:16:46 / cg"
1891
35657ac662fc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1872
diff changeset
  1958
    "Modified: / 29.4.1999 / 21:49:22 / cg"
1679
d57885b88668 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1665
diff changeset
  1959
!
d57885b88668 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1665
diff changeset
  1960
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1961
drawWith:fg and:bg
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1962
    "redraw my label with fg/bg - this generic method is also used by subclasses
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1963
     (especially Button) to redraw the logo in different colors."
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1964
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1965
    self drawWith:fg and:bg clearInside:true etchedFg:etchedFgColor.
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1966
!
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1967
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1968
drawWith:fg and:bg clearInside:doClear etchedFg:etchedFg
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1969
    "redraw my label with fg/bg - this generic method is also used by subclasses
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1970
     (especially Button) to redraw the logo in different colors."
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1971
5983
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1972
    |x y scaleH scaleV nW nH hSep vSep m2 ascent currentTransformation
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  1973
     logoWidth logoHeight lines logoDrawn|
77
565b052f5277 *** empty log message ***
claus
parents: 70
diff changeset
  1974
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1975
    doClear ifTrue:[self clearInsideWith:bg].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1976
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  1977
    gc paint:fg on:bg.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  1978
    logo notNil ifTrue:[
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1979
        m2 := margin * 2.
4899
0eef67afe3e7 class: Label
Stefan Vogel <sv@exept.de>
parents: 4891
diff changeset
  1980
        hSep := hSpace*2.
0eef67afe3e7 class: Label
Stefan Vogel <sv@exept.de>
parents: 4891
diff changeset
  1981
        vSep := vSpace*2.
133
claus
parents: 132
diff changeset
  1982
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1983
        x := labelOriginX.
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1984
        y := labelOriginY.
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1985
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1986
        logo isImageOrForm ifTrue:[
5983
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1987
            logoWidth := logo width.
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1988
            logoHeight := logo height.
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1989
            ((logoWidth == 0) or:[logoHeight == 0]) ifTrue:[
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1990
                "/ do nothing; also avoids followup errors in the image creation and division by zero...
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1991
                ^ self.
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1992
            ].    
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  1993
            adjust == #fit ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1994
                "/
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1995
                "/ change scale to make the logo fit exactly
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  1996
                "/
5983
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1997
                scaleH := ((width - hSep) / logoWidth) asFloat.
1fe3da275b7f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5943
diff changeset
  1998
                scaleV := ((height - vSep) / logoHeight) asFloat.
2968
ca78c6a1201d Fix Bug 59.
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
  1999
                scaleH <= 0 ifTrue:[scaleH := Float epsilon].
ca78c6a1201d Fix Bug 59.
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
  2000
                scaleV <= 0 ifTrue:[scaleV := Float epsilon].
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2001
                self scale:(scaleH @ scaleV).
4899
0eef67afe3e7 class: Label
Stefan Vogel <sv@exept.de>
parents: 4891
diff changeset
  2002
                x := currentTransformation applyInverseScaleX:x.
0eef67afe3e7 class: Label
Stefan Vogel <sv@exept.de>
parents: 4891
diff changeset
  2003
                y := currentTransformation applyInverseScaleY:y.
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2004
            ].
131
claus
parents: 130
diff changeset
  2005
5633
5ce074a3f531 device access
Claus Gittinger <cg@exept.de>
parents: 5587
diff changeset
  2006
            logo := logo onDevice:device.
59
450ce95a72a4 *** empty log message ***
claus
parents: 50
diff changeset
  2007
"/            self background:bg.
3850
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  2008
            self drawImageLogo:logo x:x y:y opaque:doClear.
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2009
        ] ifFalse:[
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2010
            "/ convert to a line-collection if required;
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2011
            "/ otherwise, adjust may get it wrong...
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2012
            logoDrawn := logo.
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2013
            (logoDrawn isString and:[(lines := logoDrawn asStringCollection) size > 1])
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2014
            ifTrue:[
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2015
                logoDrawn := lines.
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2016
            ].
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2017
            
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  2018
            x := x + hSpace.
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  2019
            y := y + vSpace.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2020
1665
085d9d2f0f1c geometry
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
  2021
            level < 0 ifTrue:[
085d9d2f0f1c geometry
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
  2022
                x := x + 1.
085d9d2f0f1c geometry
Claus Gittinger <cg@exept.de>
parents: 1659
diff changeset
  2023
                y := y + 1
1659
9b2b15f77813 with positive level, draw string label offset by one pixel.
Claus Gittinger <cg@exept.de>
parents: 1650
diff changeset
  2024
            ].
9b2b15f77813 with positive level, draw string label offset by one pixel.
Claus Gittinger <cg@exept.de>
parents: 1650
diff changeset
  2025
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2026
            ascent := logoDrawn ascentOn:self.
3651
c47e8c3583cf Remove type specific vodoo - ask logo for ascent instead.
Stefan Vogel <sv@exept.de>
parents: 3649
diff changeset
  2027
            y := y + ascent.
c47e8c3583cf Remove type specific vodoo - ask logo for ascent instead.
Stefan Vogel <sv@exept.de>
parents: 3649
diff changeset
  2028
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2029
            adjust == #fit ifTrue:[
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  2030
                "/
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  2031
                "/ change scale to make the logo fit exactly
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  2032
                "/
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2033
                scaleH := ((width - m2 - hSep) / (labelWidth - hSpace)) asFloat.
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2034
                scaleV := ((height - m2 - vSep) / (labelHeight - vSpace)) asFloat.
2968
ca78c6a1201d Fix Bug 59.
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
  2035
                scaleH <= 0 ifTrue:[scaleH := Float epsilon].
ca78c6a1201d Fix Bug 59.
Stefan Vogel <sv@exept.de>
parents: 2913
diff changeset
  2036
                scaleV <= 0 ifTrue:[scaleV := Float epsilon].
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  2037
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  2038
                self scale:(scaleH min:scaleV).
4899
0eef67afe3e7 class: Label
Stefan Vogel <sv@exept.de>
parents: 4891
diff changeset
  2039
                currentTransformation := gc transformation.
0eef67afe3e7 class: Label
Stefan Vogel <sv@exept.de>
parents: 4891
diff changeset
  2040
                x := currentTransformation applyInverseScaleX:x.
3651
c47e8c3583cf Remove type specific vodoo - ask logo for ascent instead.
Stefan Vogel <sv@exept.de>
parents: 3649
diff changeset
  2041
                ascent ~~ 0 ifTrue:[
4899
0eef67afe3e7 class: Label
Stefan Vogel <sv@exept.de>
parents: 4891
diff changeset
  2042
                    y := y - ascent + (currentTransformation applyScaleY:ascent).
639
26c56f23fa19 fixed to have VisualComponents usable as label
Claus Gittinger <cg@exept.de>
parents: 636
diff changeset
  2043
                ].
4899
0eef67afe3e7 class: Label
Stefan Vogel <sv@exept.de>
parents: 4891
diff changeset
  2044
                y := currentTransformation applyInverseScaleY:y.
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2045
                scaleH < scaleV ifTrue:[
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2046
                    nH := labelHeight * scaleH.
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2047
                    "/ now, center vertically
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2048
                    y := y + ((height - nH - m2 - vSep) / scaleH / 2).
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2049
                ].
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2050
                scaleV < scaleH ifTrue:[
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2051
                    "/ now, center horizontally
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2052
                    nW := labelWidth * scaleV.
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2053
                    x := x + ((width - nW - m2 - hSep) / scaleV / 2) 
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2054
                ].
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2055
            ].
131
claus
parents: 130
diff changeset
  2056
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2057
            logoDrawn isString ifTrue:[
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2058
"/                doClear ifTrue:[
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2059
"/                    self displayOpaqueString:logoDrawn x:x y:y
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2060
"/                ] ifFalse:[
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2061
"/                    self displayString:logoDrawn x:x y:y
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2062
"/                ]
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2063
                etchedFg notNil ifTrue:[
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  2064
                    gc paint:etchedFg.
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2065
                    self drawStringLogo:logoDrawn x:x+1 y:y+1.
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  2066
                    gc paint:fg.
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2067
                ].
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2068
                self drawStringLogo:logoDrawn x:x y:y
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2069
            ] ifFalse:[
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2070
                (logoDrawn isStringCollection) ifTrue:[
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2071
                    logoDrawn do:[ :line | 
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2072
                        |wThis str|
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2073
1945
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
  2074
                        adjust == #centerEach ifTrue:[
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
  2075
                            wThis := line asString widthOn:self.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
  2076
                            x := (width - wThis) // 2.
75dbbc834bd9 added #centerEach adjust
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
  2077
                        ].
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2078
                        str := line printString.
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2079
"/                        doClear ifTrue:[
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2080
"/                            self displayOpaqueString:str x:x y:y.
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2081
"/                        ] ifFalse:[
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2082
"/                            self displayString:str x:x y:y.
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2083
"/                        ].
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2084
                        etchedFg notNil ifTrue:[
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  2085
                            gc paint:etchedFg.
3850
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  2086
                            self drawStringLogo:str x:x+1 y:y+1.
6052
c13ee730ce29 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5983
diff changeset
  2087
                            gc paint:fg.
2496
9fac5962945f support for etched color
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  2088
                        ].
3850
8886e358dfe1 refactored to make the label drawing redefinable
Claus Gittinger <cg@exept.de>
parents: 3751
diff changeset
  2089
                        self drawStringLogo:str x:x y:y.
4891
9f33a5a44868 class: Label
Stefan Vogel <sv@exept.de>
parents: 4672
diff changeset
  2090
                        y := y + (gc font height)
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2091
                    ]
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2092
                ] ifFalse:[
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2093
                    "/ anything
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2094
                    self drawOtherLogo:logoDrawn x:x y:y opaque:doClear
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2095
                ]
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2096
            ].
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2097
        ].
131
claus
parents: 130
diff changeset
  2098
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2099
        adjust == #fit ifTrue:[
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2100
            self scale:1
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2101
        ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2102
    ]
636
02b141814b92 unified widthOn/heightOn protocol
Claus Gittinger <cg@exept.de>
parents: 626
diff changeset
  2103
6177
e80cfdebfdbe #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6106
diff changeset
  2104
    "Modified: / 11-07-2017 / 14:35:40 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2105
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2106
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2107
redraw
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2108
    "redraw my label"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2109
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2110
    shown ifTrue:[
3924
57f03ead2eca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  2111
        self clear.
57f03ead2eca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3850
diff changeset
  2112
        self drawWith:fgColor and:bgColor
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2113
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  2114
! !
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2115
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2116
!Label methodsFor:'resizing'!
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2117
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2118
forceResize
118
claus
parents: 113
diff changeset
  2119
    "resize myself to make text fit into myself. Here, this is done even if
claus
parents: 113
diff changeset
  2120
     fixSize is set."
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2121
2664
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2122
    |prevFixSize|
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2123
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2124
    logo notNil ifTrue:[
2664
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2125
        prevFixSize := fixSize.
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2126
        fixSize := false.
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2127
        self extent:self preferredExtent.
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2128
        self computeLabelOrigin.
3499
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  2129
        "/ this seems the only one which might depend on my contents.
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  2130
        layout isLayout ifTrue:[
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  2131
            layout isAlignmentOrigin ifTrue:[
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  2132
                self containerChangedSize.
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  2133
            ]
c96f50569871 alignmentOrigin
ca
parents: 3490
diff changeset
  2134
        ].
2664
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2135
        fixSize := prevFixSize.
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2136
    ]
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2137
!
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2138
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2139
forceResizeHorizontally
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2140
    "resize myself horizontally to make text fit into myself. 
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2141
     Here, this is done even if fixSize is set."
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2142
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2143
    |prevFixSize|
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2144
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2145
    logo notNil ifTrue:[
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2146
        prevFixSize := fixSize.
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2147
        fixSize := false.
3615
a99127b32e61 added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3597
diff changeset
  2148
        self width:self preferredWidth.
2664
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2149
        self computeLabelOrigin.
b6ddb8e6e3eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
  2150
        fixSize := prevFixSize.
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2151
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2152
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2153
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2154
resize
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2155
    "resize myself to make text fit into myself.
118
claus
parents: 113
diff changeset
  2156
     but only do so, if I am not fixedSize and I have NOT been 
claus
parents: 113
diff changeset
  2157
     given a relative extent or an extend computation block."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2158
110
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2159
    (logo notNil 
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2160
    and:[fixSize not
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2161
    and:[relativeExtent isNil
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2162
    and:[extentRule isNil
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2163
    and:[relativeCorner isNil 
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2164
    and:[cornerRule isNil]]]]]) ifTrue:[
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2165
	self forceResize
eb59f6e31e84 *** empty log message ***
claus
parents: 105
diff changeset
  2166
    ] ifFalse:[
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2167
	self computeLabelOrigin
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2168
    ]
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2169
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2170
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2171
!Label::AnimatorState methodsFor:'accessing'!
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2172
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2173
logoShown
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2174
    ^ logoShown
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2175
!
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2176
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2177
moveDirection
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2178
    ^ moveDirection
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2179
!
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2180
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2181
moveDirection:something
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2182
    moveDirection := something.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2183
!
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2184
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2185
nextOffset
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2186
    ^ nextOffset
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2187
!
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2188
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2189
nextOffset:something
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2190
    nextOffset := something.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2191
!
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2192
5755
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2193
pointerEntered
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2194
    ^ pointerEntered
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2195
!
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2196
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2197
pointerEntered:something
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2198
    pointerEntered := something.
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2199
!
76a6cb14852f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5752
diff changeset
  2200
5751
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2201
timedBlock
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2202
    ^ timedBlock
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2203
!
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2204
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2205
timedBlock:timedBlockArg nextOffset:nextOffsetArg moveDirection:moveDirectionArg logoShown:logoShownArg
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2206
    timedBlock := timedBlockArg.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2207
    nextOffset := nextOffsetArg.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2208
    moveDirection := moveDirectionArg.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2209
    logoShown := logoShownArg.
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2210
! !
17064cf2e823 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5750
diff changeset
  2211
935
2a105c61d86c fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 832
diff changeset
  2212
!Label class methodsFor:'documentation'!
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2213
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2214
version
5445
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  2215
    ^ '$Header$'
3999
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2216
!
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2217
f605cc13731e computeLabelSize refactorings
Claus Gittinger <cg@exept.de>
parents: 3927
diff changeset
  2218
version_CVS
5445
df7fc0f00f58 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5123
diff changeset
  2219
    ^ '$Header$'
205
6814c0bf8df8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 202
diff changeset
  2220
! !
4670
088ee618ffe7 class: Label
Claus Gittinger <cg@exept.de>
parents: 4443
diff changeset
  2221