LinkButton.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 02 Sep 2022 11:25:39 +0100
branchjv
changeset 6261 9b7eb7159d29
parent 6250 6c9134247e8a
permissions -rw-r--r--
Fix loong standing bug with some menus not being translated / resolved This has happened with browser "View" menu when sometimes it had the slice resolved and sometimes not. It turned out that it was because the code disabled resources (and therefore slices) resolution when processing shortcuts, so the menu was created and cached unresolved. This fixes the issue. eXept apparently run into the same problem.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4770
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     1
"
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     3
              All Rights Reserved
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     4
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     5
 This software is furnished under a license and may be used
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     6
 only in accordance with the terms of that license and with the
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     8
 be provided or otherwise made available to, or used by, any
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
     9
 other person.  No title to or ownership of the software is
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    10
 hereby transferred.
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    11
"
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
4985
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
    14
"{ NameSpace: Smalltalk }"
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
    15
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Button subclass:#LinkButton
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    17
	instanceVariableNames:'labelsAndActions'
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
    18
	classVariableNames:'DefaultLinkColor'
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Views-Layout'
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!LinkButton class methodsFor:'documentation'!
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
4770
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    25
copyright
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    26
"
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    27
 COPYRIGHT (c) 2006 by eXept Software AG
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    28
              All Rights Reserved
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    29
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    30
 This software is furnished under a license and may be used
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    31
 only in accordance with the terms of that license and with the
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    33
 be provided or otherwise made available to, or used by, any
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    34
 other person.  No title to or ownership of the software is
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    35
 hereby transferred.
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    36
"
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    37
!
6634b540fea2 Added PluggableHierarchicalList to define ad-hoc tree models.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4681
diff changeset
    38
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    Looks like a Label, but behaves like a button with individually clickable text components.
5045
50eb267766b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4987
diff changeset
    42
    Can be used to create html-page-look-alike links in a view,
5110
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
    43
    especially to make label-looking action buttons (as in the browser's info view).
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    [author:]
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
        cg (cg@CG-VOSTRO)
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    [instance variables:]
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    [class variables:]
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    [see also:]
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
"
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
!
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
examples
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
"
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    59
                                                                    [exBegin]
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    |v l|
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    v := StandardSystemView new.
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    l := LinkButton in:v.
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    64
    l label:
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    65
        (('Hello' actionForAll:[ Transcript showCR:'Hello Clicked']) 
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    66
        , ' '
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    67
        , ('World' actionForAll:[ Transcript showCR:'World Clicked'])).
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    68
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    69
    v open
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    70
                                                                    [exEnd]
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    71
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    72
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    73
                                                                    [exBegin]
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    74
    |v l|
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    75
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    76
    v := StandardSystemView new.
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    77
    l := LinkButton in:v.
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    78
    l label:
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    79
        ((('Hello' actionForAll:[ Transcript showCR:'Hello Clicked']) colorizeAllWith:(Color blue)) 
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    80
        , ' '
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    81
        , ('World' actionForAll:[ Transcript showCR:'World Clicked'])).
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    82
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    83
    v open
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    84
                                                                    [exEnd]
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    85
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    86
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    87
                                                                    [exBegin]
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    88
    |v l|
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    89
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    90
    v := StandardSystemView new.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
    91
    l := LinkButton in:v.
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    l labelsAndActions:{ 
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
    93
                        'Hello' -> [ Transcript showCR:'Hello Clicked'].
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
                        ' ' -> nil.
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
    95
                        'World' -> [ Transcript showCR:'World Clicked'].
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
                       }.
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    l foregroundColor:Color blue.
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    v open
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
    99
                                                                    [exEnd]
3668
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   100
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   101
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
   102
                                                                    [exBegin]
3668
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   103
    |v l|
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   104
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   105
    v := StandardSystemView new.
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   106
    l := LinkButton in:v.
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   107
    l labelsAndActions:{ 
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   108
                        'Hello' -> nil.
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   109
                        ' ' -> nil.
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   110
                        'World' -> [ Transcript showCR:'World Clicked'].
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   111
                       }.
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   112
    l foregroundColor:Color blue.
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   113
    v open
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
   114
                                                                    [exEnd]
4985
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   115
    Dialog aboutToOpenBoxNotificationSignal handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   116
        |lbl|
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   117
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   118
        lbl := LinkButton label:(('XXX' 
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   119
                                        colorizeAllWith:Color blue)
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   120
                                        actionForAll:[ Transcript showCR:'xxx' ]).
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   121
        ex box verticalPanel addComponent:lbl.
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   122
    ] do:[
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   123
        self warn:'Bla bla bla'
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   124
    ].
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   125
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
"
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
! !
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   129
!LinkButton class methodsFor:'defaults'!
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   130
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   131
updateStyleCache
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   132
    "extract values from the styleSheet and cache them in class variables"
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   133
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   134
    <resource: #style ( #'linkButton.linkColor' )>
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   135
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   136
    DefaultLinkColor := StyleSheet colorAt:#'linkButton.linkColor' default:Color blue.
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   137
! !
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   138
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
!LinkButton methodsFor:'accessing'!
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
5110
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   141
actionAt:aPoint
5111
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   142
    |pressAction emphasis pointInLabel|
5110
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   143
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   144
    pressAction := self pressAction ifNil:[ self releaseAction ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   145
    pressAction isNil ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   146
        pressAction := self pressChannel ifNil:[ self releaseChannel ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   147
    ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   148
    labelsAndActions isNil ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   149
        "take action from logo, which is normally a text with an action-emphasis"
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   150
        logo notNil ifTrue:[
5111
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   151
            pointInLabel := (aPoint - (labelOriginX@labelOriginY)).
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   152
            logo isStringCollection ifTrue:[
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   153
                |lineIndex line pointInLine|
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   154
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   155
                lineIndex := (pointInLabel y // self font height) + 1.
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   156
                line := logo at:lineIndex ifAbsent:nil.
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   157
                line notNil ifTrue:[
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   158
                    pointInLine := pointInLabel - (0 @ ((lineIndex - 1) * self font height)).
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   159
                    emphasis := line emphasisAtPoint:pointInLine on:self. 
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   160
                ].    
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   161
            ] ifFalse:[    
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   162
                emphasis := logo emphasisAtPoint:pointInLabel on:self. 
ce09771c85a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5110
diff changeset
   163
            ].
5110
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   164
            (emphasis isNil or:[emphasis isSymbol]) ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   165
                ^ pressAction.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   166
            ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   167
            emphasis isAssociation ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   168
                emphasis key == #actionBlock ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   169
                    ^ emphasis value.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   170
                ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   171
                ^ pressAction.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   172
            ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   173
            emphasis do:[:eachElement|
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   174
                eachElement isAssociation ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   175
                    eachElement key == #actionBlock ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   176
                        ^ eachElement value.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   177
                    ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   178
                ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   179
            ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   180
        ].    
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   181
        ^ pressAction.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   182
    ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   183
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   184
    self labelsAndActionsWithPositionsDo:[:lbl :action :leftX :rightX |
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   185
        (aPoint x between:leftX and:rightX) ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   186
            ^ labelsAndActions notNil ifTrue:action ifFalse:pressAction
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   187
        ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   188
    ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   189
    ^ nil
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   190
!
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   191
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
labelsAndActions
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    "returns the collection of label->action associations. 
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
     For display, the label strings are drawn as one concatenated string (add separating spaces, if you have to).
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
     When clicked on a string, the corresponding action is called"
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    ^ labelsAndActions
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
!
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
labelsAndActions:aCollectionOfAssociations
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    "set the collection of label->action associations. 
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
     For display, the label strings are drawn as one concatenated string (add separating spaces, if you have to).
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
     When clicked on a string, the corresponding action is called"
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    labelsAndActions := aCollectionOfAssociations.
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    self label:((aCollectionOfAssociations collect:[:assoc | assoc key]) asStringWith:'')
5045
50eb267766b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4987
diff changeset
   207
!
50eb267766b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4987
diff changeset
   208
50eb267766b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4987
diff changeset
   209
level:anInteger
50eb267766b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4987
diff changeset
   210
    enterLevel := leaveLevel := onLevel := offLevel := level := anInteger.
50eb267766b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4987
diff changeset
   211
    margin := level abs.
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
! !
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
!LinkButton methodsFor:'initialization'!
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
4677
e6a348494211 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
   216
allViewBackground:something if:condition
e6a348494211 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
   217
    "set the viewBackground to something, a color, image or form,
e6a348494211 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
   218
     in myself and recursively in all of my subviews"
e6a348494211 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
   219
e6a348494211 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
   220
    self viewBackground:something if:condition.
e6a348494211 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
   221
    self backgroundColor:something.
e6a348494211 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
   222
!
e6a348494211 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4572
diff changeset
   223
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
defaultControllerClass
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    ^ LinkButtonController
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   226
!
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   227
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   228
initStyle
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   229
    super initStyle.
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   230
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   231
    level := enterLevel := leaveLevel := onLevel := offLevel := 0.
4681
b97620c35200 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4680
diff changeset
   232
    self borderWidth: 0.
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   233
    DefaultLinkColor notNil ifTrue:[
4508
5c8959e41aa6 class: LinkButton
Stefan Vogel <sv@exept.de>
parents: 4071
diff changeset
   234
        |color|
4987
82bb0a9fecdb #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 4985
diff changeset
   235
        self paint:(color := DefaultLinkColor onDevice:device).
4508
5c8959e41aa6 class: LinkButton
Stefan Vogel <sv@exept.de>
parents: 4071
diff changeset
   236
        self foreground:color.
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   237
    ].
4681
b97620c35200 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4680
diff changeset
   238
    enteredFgColor := nil.
b97620c35200 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4680
diff changeset
   239
    enteredBgColor := nil.
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
   240
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   241
"/    activeFgColor := enteredFgColor := foreground.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   242
"/    activeBgColor := enteredBgColor := viewBackground.
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
   243
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
   244
    "Modified: / 07-09-2011 / 04:29:29 / cg"
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   245
!
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   246
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   247
initialize
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   248
    super initialize.
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   249
    self enableMotionEvents
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   250
! !
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   251
5110
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   252
!LinkButton methodsFor:'private'!
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   253
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   254
actionEmphasisIn:aText atPoint:aPoint
5110
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   255
    "check for an actionBlock-emphasis in aString at aPoint.
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   256
     Answer an Array with the whole emphasis and the actionBlock,
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   257
     or nil"
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   258
    
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   259
    |emphasis|
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   260
6250
6c9134247e8a Backed out changeset a1272bf7ae91
Jan Vrany <jan.vrany@labware.com>
parents: 6247
diff changeset
   261
    emphasis := aText emphasisAtPoint:aPoint on:self.
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   262
    (emphasis isNil or:[emphasis isSymbol]) ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   263
        ^ #(nil nil).
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   264
    ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   265
    emphasis isAssociation ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   266
        emphasis key == #actionBlock ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   267
            ^ Array with:emphasis with:emphasis value.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   268
        ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   269
        ^ #(nil nil).
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   270
    ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   271
    emphasis detect:[:eachElement|
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   272
        eachElement isAssociation ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   273
            eachElement key == #actionBlock ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   274
                ^ Array with:emphasis with:eachElement value.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   275
            ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   276
        ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   277
    ] ifNone:[].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   278
    ^ #(nil nil).
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   279
!
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   280
5110
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   281
labelsAndActionsWithPositionsDo:aFourArgBlock
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   282
    |leftX rightX w|
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   283
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   284
    leftX := labelOriginX.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   285
    labelsAndActions isNil ifTrue:[
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   286
        w := (self font widthOf:logo on:device).
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   287
        rightX := leftX + w-1.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   288
        aFourArgBlock 
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   289
            value:logo
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   290
            value:self pressAction
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   291
            value:leftX
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   292
            value:rightX.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   293
        ^ self
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   294
    ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   295
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   296
    labelsAndActions do:[:assoc | 
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   297
        |lbl wEach|
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   298
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   299
        lbl := assoc key.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   300
        wEach := (self font widthOf:lbl on:device).
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   301
        rightX := leftX + wEach-1.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   302
        aFourArgBlock 
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   303
            value:assoc key
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   304
            value:assoc value
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   305
            value:leftX
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   306
            value:rightX.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   307
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   308
        leftX := rightX+1.
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   309
    ].
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   310
    ^ nil
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   311
! !
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   312
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   313
!LinkButton methodsFor:'redrawing'!
dd99c089bf65 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5096
diff changeset
   314
4680
6c266588d588 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4677
diff changeset
   315
drawFocusFrame
6c266588d588 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4677
diff changeset
   316
    "/ intentionally ignored
6c266588d588 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4677
diff changeset
   317
    ^ self
6c266588d588 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4677
diff changeset
   318
!
6c266588d588 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4677
diff changeset
   319
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   320
drawStringLogo:aString x:x y:y
5045
50eb267766b2 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 4987
diff changeset
   321
    "redefined to draw any anchor under the mouse pointer with an underlined emphasis"
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   322
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   323
    |str entered mousePoint start len emphasis|
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   324
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   325
    mousePoint := controller lastMousePoint.
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   326
    entered := controller entered.
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   327
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   328
    labelsAndActions isNil ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   329
        (entered not or:[mousePoint isNil]) ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   330
            self displayString:aString x:x y:y.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   331
            ^ self.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   332
        ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   333
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   334
        str := aString.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   335
        emphasis := (self actionEmphasisIn:aString atPoint:mousePoint) first.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   336
        emphasis notNil ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   337
            start := 1.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   338
            aString emphasisCollection runsDo:[:eachLen :eachEmphasis|
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   339
                len isNil ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   340
                    eachEmphasis == emphasis ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   341
                        len := eachLen.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   342
                    ] ifFalse:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   343
                        start := start + eachLen.  
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   344
                    ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   345
                ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   346
            ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   347
            len notNil ifTrue:[
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   348
                str := str deepCopy.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   349
                str emphasisFrom:start to:start+len-1 add:#underline.
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
   350
                "/ str emphasisFrom:start to:start+len-1 add:(#color -> foreground).
3670
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   351
            ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   352
        ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   353
        self displayString:str x:x y:y.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   354
        ^ self.
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   355
    ].
ccfd04be9736 Now works with Text/actionBlocks
Stefan Vogel <sv@exept.de>
parents: 3668
diff changeset
   356
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   357
    self labelsAndActionsWithPositionsDo:[:lbl :action :leftX :rightX |
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   358
        |l|
3668
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   359
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   360
        l := lbl.
3668
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   361
        action notNil ifTrue:[
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   362
            (entered and:[mousePoint notNil and:[mousePoint x between:leftX and:rightX]]) ifTrue:[
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   363
                l := l allUnderlined
e1888e938d68 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3666
diff changeset
   364
            ].
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   365
        ].
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   366
        self displayString:l x:leftX y:y.
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   367
    ].
4071
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
   368
d056c9f9b595 changed:
Claus Gittinger <cg@exept.de>
parents: 3671
diff changeset
   369
    "Modified: / 07-09-2011 / 04:47:13 / cg"
3662
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   370
!
fb3778b66ce3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   371
4681
b97620c35200 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4680
diff changeset
   372
is3D
b97620c35200 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4680
diff changeset
   373
    ^ false.
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
! !
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
!LinkButton class methodsFor:'documentation'!
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
version
4985
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   379
    ^ '$Header$'
4681
b97620c35200 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4680
diff changeset
   380
!
b97620c35200 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4680
diff changeset
   381
b97620c35200 class: LinkButton
Claus Gittinger <cg@exept.de>
parents: 4680
diff changeset
   382
version_CVS
4985
Claus Gittinger <cg@exept.de>
parents: 4681
diff changeset
   383
    ^ '$Header$'
3650
60a95483b993 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
! !
4508
5c8959e41aa6 class: LinkButton
Stefan Vogel <sv@exept.de>
parents: 4071
diff changeset
   385