DataSetLabel.st
author Claus Gittinger <cg@exept.de>
Thu, 05 Mar 2009 12:58:00 +0100
changeset 3649 88b3435ff257
parent 3582 2927b1b12e8f
child 3763 f31244b93a13
permissions -rw-r--r--
preps for sort by column
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1716
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     1
"
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     3
              All Rights Reserved
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     4
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     5
 This software is furnished under a license and may be used
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     6
 only in accordance with the terms of that license and with the
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     8
 be provided or otherwise made available to, or used by, any
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
     9
 other person.  No title to or ownership of the software is
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    10
 hereby transferred.
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    11
"
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1716
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1716
diff changeset
    13
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Object subclass:#DataSetLabel
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
    15
	instanceVariableNames:'label selector argument adjust font fgColor bgColor
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    16
		preferredHeight preferredWidth description'
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	category:'Views-DataSet'
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
1716
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    22
!DataSetLabel class methodsFor:'documentation'!
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    23
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    24
copyright
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    25
"
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    26
 COPYRIGHT (c) 1997 by eXept Software AG
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    27
              All Rights Reserved
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    28
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    29
 This software is furnished under a license and may be used
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    30
 only in accordance with the terms of that license and with the
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    32
 be provided or otherwise made available to, or used by, any
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    33
 other person.  No title to or ownership of the software is
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    34
 hereby transferred.
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    35
"
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    36
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    37
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    38
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    39
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    40
!
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    41
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    42
documentation
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    43
"
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    44
    This class keeps some info about a label.
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    45
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    46
    [author:]
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    47
        Claus Atzkern
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    48
"
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    49
! !
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    50
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    51
!DataSetLabel class methodsFor:'image specs'!
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    52
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    53
sortIndicator
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    54
    "This resource specification was automatically generated
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    55
     by the ImageEditor of ST/X."
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    56
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    57
    "Do not manually edit this!! If it is corrupted,
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    58
     the ImageEditor may not be able to read the specification."
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    59
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    60
    "
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    61
     self sortIndicator inspect
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    62
     ImageEditor openOnClass:self andSelector:#sortIndicator
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    63
     Icon flushCachedIcons
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    64
    "
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    65
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    66
    <resource: #image>
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    67
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    68
    ^Icon
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    69
        constantNamed:'DataSetLabel class sortIndicator'
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    70
        ifAbsentPut:[(Depth1Image new) width: 7; height: 4; photometric:(#palette); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@B@0 @a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 4; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'?''08D@@a') ; yourself); yourself]
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    71
!
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    72
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    73
sortReverseIndicator
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    74
    "This resource specification was automatically generated
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    75
     by the ImageEditor of ST/X."
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    76
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    77
    "Do not manually edit this!! If it is corrupted,
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    78
     the ImageEditor may not be able to read the specification."
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    79
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    80
    "
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    81
     self sortReverseIndicator inspect
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    82
     ImageEditor openOnClass:self andSelector:#sortReverseIndicator
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    83
     Icon flushCachedIcons
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    84
    "
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    85
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    86
    <resource: #image>
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    87
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    88
    ^Icon
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    89
        constantNamed:'DataSetLabel class sortReverseIndicator'
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
    90
        ifAbsentPut:[(Depth1Image new) width: 7; height: 4; photometric:(#palette); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'0(@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 4; photometric:(#blackIs0); bitsPerSample:(#(1)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'DC!!<? @a') ; yourself); yourself]
1716
0e31e721d4ab copyrights
Claus Gittinger <cg@exept.de>
parents: 1605
diff changeset
    91
! !
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1716
diff changeset
    93
!DataSetLabel methodsFor:'accessing-colors'!
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
backgroundColor
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
    96
    "returns the background color or nil
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    "
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    ^ bgColor
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
2699
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   103
backgroundColor:aColor
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   104
    "set the background color or nil
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   105
    "
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   106
    bgColor := aColor
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   107
!
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   108
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
foregroundColor
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   110
    "returns the foreground color or nil
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    "
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    ^ fgColor
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
2699
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   114
!
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   115
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   116
foregroundColor:aColor
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   117
    "set the foreground color or nil
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   118
    "
ffc569afbb18 WOs accessors
werner
parents: 2451
diff changeset
   119
    fgColor := aColor
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
! !
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1716
diff changeset
   122
!DataSetLabel methodsFor:'accessing-dimensions'!
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   124
preferredHeight
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   125
    "returns my preferred height
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    "
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   127
    ^ preferredHeight
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   130
preferredWidth
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   131
    "returns my preferred width
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    "
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   133
    ^ preferredWidth
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
! !
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
!DataSetLabel methodsFor:'actions'!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
sendClickMsgTo:aReceiver
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "inform the receiver of a button release notification
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    "
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    (aReceiver notNil and:[selector notNil]) ifTrue:[
2068
3fcbf2422c5a use new #perform:withOptionalArg
Claus Gittinger <cg@exept.de>
parents: 1818
diff changeset
   142
        aReceiver perform:selector withOptionalArgument:argument
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    ]
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
! !
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
!DataSetLabel methodsFor:'drawing'!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   148
redrawX:xLeft w:width h:height inset:inset on:aLabelView
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    "redraw the label; the background is cleared and the paint is set
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    "
3582
2927b1b12e8f Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents: 3553
diff changeset
   151
    |y0 x gcFont labelWidth 
2154
cb22be939082 split strings; some refactoring
Claus Gittinger <cg@exept.de>
parents: 2144
diff changeset
   152
     shownLabel prevClip mustUndoClip
3490
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   153
     netWidth goodLookingVerticalSpacing|
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    label isNil ifTrue:[ ^ self ].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   157
    font notNil ifTrue:[
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   158
        gcFont := aLabelView font.    "save original font"
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   159
        aLabelView font:font.
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   160
    ].
3582
2927b1b12e8f Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents: 3553
diff changeset
   161
2927b1b12e8f Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents: 3553
diff changeset
   162
    y0 := (height - preferredHeight) // 2.
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   163
    goodLookingVerticalSpacing := aLabelView font descent.
3490
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   164
    y0 := y0 + goodLookingVerticalSpacing.
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
2144
29820901d223 shortened label, if it does not fit (i.e. O..)
penk
parents: 2068
diff changeset
   166
    netWidth := width-inset-inset.
29820901d223 shortened label, if it does not fit (i.e. O..)
penk
parents: 2068
diff changeset
   167
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   168
    label do:[:aLabel|
2144
29820901d223 shortened label, if it does not fit (i.e. O..)
penk
parents: 2068
diff changeset
   169
        shownLabel := aLabel.
29820901d223 shortened label, if it does not fit (i.e. O..)
penk
parents: 2068
diff changeset
   170
1588
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   171
        mustUndoClip := false.
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   172
        labelWidth := shownLabel widthOn:aLabelView.
2144
29820901d223 shortened label, if it does not fit (i.e. O..)
penk
parents: 2068
diff changeset
   173
        labelWidth > netWidth ifTrue:[
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   174
            shownLabel := DataSetColumn shortenedStringFor:aLabel on:aLabelView maxWidth:netWidth.
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   175
            labelWidth := shownLabel widthOn:aLabelView.
2144
29820901d223 shortened label, if it does not fit (i.e. O..)
penk
parents: 2068
diff changeset
   176
        ].
29820901d223 shortened label, if it does not fit (i.e. O..)
penk
parents: 2068
diff changeset
   177
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   178
        adjust == #left ifTrue:[
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   179
            x := xLeft + inset.
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   180
        ] ifFalse:[
2144
29820901d223 shortened label, if it does not fit (i.e. O..)
penk
parents: 2068
diff changeset
   181
            x := width - labelWidth.
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   183
            adjust == #right ifTrue:[
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   184
                x := x - inset
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   185
            ] ifFalse:[
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   186
                x := x // 2.    "/ center
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   187
            ].
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   188
            x := xLeft + x.
1588
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   189
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   190
           "/ cg: must clip left, if string is too large
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   191
            x < xLeft ifTrue:[
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   192
                "/ must clip ...
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   193
                prevClip := aLabelView clippingRectangleOrNil.
1588
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   194
                mustUndoClip := true.
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   195
                aLabelView clippingRectangle:(Rectangle 
1588
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   196
                                    left:xLeft top:y0 
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   197
                                    width:width height:height).
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   198
            ].
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   199
        ].
3582
2927b1b12e8f Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents: 3553
diff changeset
   200
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   201
        shownLabel displayOn:aLabelView x:x y:y0 + (shownLabel ascentOn:aLabelView).
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   202
        y0 := y0 + (shownLabel heightOn:aLabelView) + goodLookingVerticalSpacing.
1588
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   203
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   204
        mustUndoClip == true ifTrue:[
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   205
            aLabelView clippingRectangle:prevClip
1588
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   206
        ].
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   207
    ].
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   208
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   209
    description isSortable ifTrue:[
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   210
self halt.
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   211
    ].
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   212
3582
2927b1b12e8f Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents: 3553
diff changeset
   213
    gcFont notNil ifTrue:[
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   214
        aLabelView font:gcFont     "/ restore font
2451
383fdea243d0 use new aspectOn: query
Claus Gittinger <cg@exept.de>
parents: 2443
diff changeset
   215
    ].       
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
! !
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
!DataSetLabel methodsFor:'instance creation'!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   220
description:aDescription builder:aBuilder on:aGC
3490
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   221
    |device gcFont verticalSpace|
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   223
    description := aDescription.
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   224
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   225
    "/ stupid code - could simply access things via the description.
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   226
    "/ I leave it here for subclasses which depend on it (for a while).
1605
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   227
    label           := self resolveLabelFromDescription:aDescription withBuilder:aBuilder.
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   228
    selector        := aDescription  labelActionSelector.
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   229
    argument        := (aDescription labelActionArgument) ? label.
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   230
    adjust          := (aDescription labelAlignment) ? #left.
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   231
    device          := aGC device.
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   232
    fgColor         := aDescription labelForegroundColor.
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   233
    bgColor         := aDescription labelBackgroundColor.
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
1480
51dd0cc6ea11 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   235
    fgColor notNil ifTrue:[ fgColor := fgColor onDevice:device ].
51dd0cc6ea11 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
   236
    bgColor notNil ifTrue:[ bgColor := bgColor onDevice:device ].
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   238
    preferredHeight := preferredWidth := 0.
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   239
3490
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   240
    (label isEmptyOrNil) ifTrue:[
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   241
        label := nil.
3490
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   242
        ^ self
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    ].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
3553
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   245
    font := aDescription labelFont.
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   246
    font notNil ifTrue:[
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   247
        font := aBuilder resolveFont:font.
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   248
        font notNil ifTrue:[
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   249
            gcFont := aGC font.
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   250
            gcFont = font ifTrue:[
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   251
                font := nil
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   252
            ] ifFalse:[
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   253
                    font := font onDevice:device.
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   254
                    aGC font:font.
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   255
            ].
9387938a3c07 Resolve symbolic fonts
Stefan Vogel <sv@exept.de>
parents: 3490
diff changeset
   256
        ].
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   257
    ].
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
3490
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   259
    label isString ifTrue:[
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   260
        label := Array with:label.
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   261
    ] ifFalse:[
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   262
        (label isSequenceable not) ifTrue:[
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   263
            label := Array with:label.
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   264
        ]
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    ].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
3490
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   267
    verticalSpace := aGC font descent. "/ goodLookingVerticalSpacing
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   268
    label := label 
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   269
                collect:[:el|
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   270
                    |lbl|
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   271
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   272
                    lbl := self label:el on:device.
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   273
                    preferredWidth  := (lbl widthOn:aGC) max:preferredWidth.
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   274
                    preferredHeight := preferredHeight + verticalSpace + (lbl heightOn:aGC) + verticalSpace.
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   275
                    lbl
f46a3c50dc15 preferredExtent changes & fixes (ubs)
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
   276
                ].
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   277
    font notNil ifTrue:[aGC font:gcFont].       "/ restore font
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
! !
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
!DataSetLabel methodsFor:'private'!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
label:aLabel on:aDevice
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    "returns registered label on a device
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    "
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    |lbl img|
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
1487
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   287
    aLabel isNil ifTrue:[^ ''].
fd003e2156cc bug fixes + rework
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
   288
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    aLabel isString ifFalse:[
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
        aLabel isImageOrForm ifTrue:[
2291
c5e8140dd6ba #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   291
            aLabel device ~~ aDevice ifTrue:[
c5e8140dd6ba #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   292
                lbl := aLabel copy onDevice:aDevice
c5e8140dd6ba #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   293
            ] ifFalse:[
c5e8140dd6ba #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   294
                lbl := aLabel
c5e8140dd6ba #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   295
            ].
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
            lbl isImage ifTrue:[
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
                lbl clearMaskedPixels
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
            ].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
            ^ lbl
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
        ].
1588
e6039e46cae2 clip label on the left, if larger than columns width,
Claus Gittinger <cg@exept.de>
parents: 1523
diff changeset
   301
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
        aLabel class == LabelAndIcon ifTrue:[
2291
c5e8140dd6ba #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 2154
diff changeset
   303
            lbl := aLabel onDevice:aDevice.
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
            (img := lbl image) isImage ifTrue:[img clearMaskedPixels].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
            (img := lbl icon)  isImage ifTrue:[img clearMaskedPixels].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
            ^ lbl
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
        ]
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    ].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
    ^ aLabel
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
resolveLabelFromDescription:aDescription withBuilder:aBuilder
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   313
    |rawLabel appl resources lbl|
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    aBuilder isNil ifTrue:[
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   316
        rawLabel := aDescription rawLabel.
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   317
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   318
        rawLabel isString ifTrue:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   319
            rawLabel isEmpty ifTrue:[^ nil ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   320
            lbl := rawLabel asStringCollection.
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   321
            lbl size > 1 ifTrue:[^ lbl ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   322
        ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   323
        ^ rawLabel        
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    ].
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   325
    rawLabel := aDescription label.
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   326
    rawLabel isNil ifTrue:[^ nil ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   327
2779
e5b0570c2c32 also translate multi-line labels
Claus Gittinger <cg@exept.de>
parents: 2699
diff changeset
   328
    aBuilder isEditing ifFalse:[
e5b0570c2c32 also translate multi-line labels
Claus Gittinger <cg@exept.de>
parents: 2699
diff changeset
   329
        appl := aBuilder application.
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   330
        appl notNil ifTrue:[ resources := appl resources ].
2779
e5b0570c2c32 also translate multi-line labels
Claus Gittinger <cg@exept.de>
parents: 2699
diff changeset
   331
    ].
e5b0570c2c32 also translate multi-line labels
Claus Gittinger <cg@exept.de>
parents: 2699
diff changeset
   332
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   333
    rawLabel isString ifTrue:[
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
        aDescription labelIsImage ifTrue:[
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   335
            (aBuilder isEditing or:[(rawLabel := aBuilder labelFor:(rawLabel asSymbol)) isNil]) ifTrue:[
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
                ^ aDescription class defaultIcon
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   337
            ]
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   338
        ] ifFalse:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   339
            aDescription translateLabel == true ifTrue:[
3582
2927b1b12e8f Get the label from a value holder
Stefan Vogel <sv@exept.de>
parents: 3553
diff changeset
   340
                lbl := (aBuilder aspectAt:(rawLabel asSymbol)) value.
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   342
                (lbl isNil and:[resources notNil]) ifTrue:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   343
                    lbl := resources string:rawLabel default:nil.
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   344
                ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   345
                lbl notNil ifTrue:[ rawLabel := lbl ].
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
            ].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
        ].
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   348
    ] ifFalse:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   349
        rawLabel isSequenceable ifFalse:[^ rawLabel].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   350
        rawLabel isEmptyOrNil ifTrue:[^ nil ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   351
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   352
        resources notNil ifTrue:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   353
            lbl := resources string:rawLabel default:nil.
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   354
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   355
            lbl notNil ifTrue:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   356
                rawLabel := lbl.
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   357
            ] ifFalse:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   358
                lbl := resources array:rawLabel.
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   359
                lbl notEmptyOrNil ifTrue:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   360
                    lbl size == 1 ifTrue:[ rawLabel := lbl first ]
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   361
                                 ifFalse:[ rawLabel := lbl ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   362
                ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   363
            ].
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
        ].
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    ].
3468
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   366
    rawLabel isString ifTrue:[
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   367
        rawLabel isEmpty ifTrue:[ ^ nil ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   368
        lbl := rawLabel asStringCollection.
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   369
        lbl size > 1 ifTrue:[^ lbl ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   370
    ].
075b137a1e67 support carriage return in title labels
ca
parents: 2932
diff changeset
   371
    ^ rawLabel
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
! !
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
!DataSetLabel methodsFor:'queries'!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
1605
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   376
hasSeparator
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   377
    |l|
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   378
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   379
    label size == 1 ifTrue:[
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   380
"/        ^ (label at:1) ~= 'Alarm'
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   381
        ^ (label at:1) ~= 'Area'
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   382
    ].
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   383
    ^ true
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   384
!
3eb7d3e78e08 checkin from browser
ca
parents: 1591
diff changeset
   385
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
isSelectable
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
    "returns true if the item is selectable; a valid selector
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
     to notify the receiver for a release button event exists
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
    "
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
    ^ selector notNil
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
! !
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
!DataSetLabel class methodsFor:'documentation'!
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
version
3649
88b3435ff257 preps for sort by column
Claus Gittinger <cg@exept.de>
parents: 3582
diff changeset
   398
    ^ '$Header: /cvs/stx/stx/libwidg2/DataSetLabel.st,v 1.24 2009-03-05 11:58:00 cg Exp $'
1150
d0530983c4f6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
! !