FlyByHelp.st
author Claus Gittinger <cg@exept.de>
Tue, 03 Sep 2013 17:23:55 +0200
changeset 3228 187a4158a51a
parent 3220 1181c3afbb10
child 3241 630689dda068
permissions -rw-r--r--
class: FlyByHelp changed: #initiateHelpFor:at:now: #showHelp:for: changed the flyBy suppression slightly: if the same text is to be shown again, do not show it except if the help is for another widget. (used to check for the text only previously)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     1
"
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     2
 COPYRIGHT (c) 2001 by eXept Software AG
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     3
              All Rights Reserved
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     4
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     5
 This software is furnished under a license and may be used
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     6
 only in accordance with the terms of that license and with the
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
     9
 other person.  No title to or ownership of the software is
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    10
 hereby transferred.
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    11
"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libview2' }"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ActiveHelp subclass:#FlyByHelp
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
    15
	instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess'
1892
4c38a0c4369b *** empty log message ***
ca
parents: 1802
diff changeset
    16
	classVariableNames:''
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Interface-Help'
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    21
!FlyByHelp class methodsFor:'documentation'!
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    22
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    23
copyright
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    24
"
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    25
 COPYRIGHT (c) 2001 by eXept Software AG
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    26
              All Rights Reserved
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    27
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    28
 This software is furnished under a license and may be used
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    29
 only in accordance with the terms of that license and with the
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    31
 be provided or otherwise made available to, or used by, any
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    32
 other person.  No title to or ownership of the software is
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    33
 hereby transferred.
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    34
"
1893
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    35
!
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    36
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    37
examples
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    38
"
3220
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    39
    UserPreferences current toolTipShapeStyle:nil
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    40
    UserPreferences current toolTipShapeStyle:#cartoon
1181c3afbb10 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3216
diff changeset
    41
1893
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    42
     FlyByHelp isActive
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    43
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    44
     FlyByHelp stop
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    45
     FlyByHelp start
f369ffca3d9f *** empty log message ***
ca
parents: 1892
diff changeset
    46
"
1802
ef3539bf86b7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1768
diff changeset
    47
! !
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    49
!FlyByHelp class methodsFor:'accessing'!
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    50
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    51
currentlyShownView
2846
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    52
    TheOneAndOnlyHelpListener isNil ifTrue:[^ nil].
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    53
    ^ TheOneAndOnlyHelpListener currentlyShownView
2846
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    54
e90ba00f9df1 changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents: 2826
diff changeset
    55
    "Modified: / 09-06-2010 / 16:35:48 / cg"
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    56
! !
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
    57
2684
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    58
!FlyByHelp methodsFor:'defaults'!
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    59
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    60
flyByHelpTimeoutMillis
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    61
    "abort flyby help text generation, if no text can be generated within that
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    62
     time delta. This is used to abort long-lasting parsing/scanning/analysis in
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    63
     large methods when the mouse is moved over some syntactic constructs, and
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    64
     it takes too long to parse...
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    65
     The returned time is given in ms"
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    66
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    67
    ^ 300
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    68
! !
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
    69
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
    70
!FlyByHelp methodsFor:'event handling'!
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
    71
2474
ef24105ee7a2 code cleanup (arg-names)
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
    72
buttonMotion:buttonAndModifierState x:x y:y view:aView
2519
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    73
    aView == currentHelpView ifTrue:[
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    74
        "/ the help-bubble itself
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    75
        ^ false
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    76
    ].
af89806c67e4 comment
Claus Gittinger <cg@exept.de>
parents: 2518
diff changeset
    77
2518
fc1d2b481b6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
    78
    "/ don't start tooltip, if this view is not active
fc1d2b481b6e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
    79
    "/ aView topView isActive ifFalse:[^ false].
2477
b009e0b51999 suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents: 2474
diff changeset
    80
2474
ef24105ee7a2 code cleanup (arg-names)
Claus Gittinger <cg@exept.de>
parents: 2392
diff changeset
    81
    ^ super buttonMotion:buttonAndModifierState x:x y:y view:aView
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
    82
!
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
    83
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
    84
buttonPress:button x:x y:y view:aView
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    85
    |prevView|
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    86
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    87
    "/ hideHelp nils the currentView
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    88
    "/ we restore it, so the tooltip is not shown again for this view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    89
    "/ until the mouse really leaves the view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    90
    "/ let's call this the "do-not-show-in-this-view mode"
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    91
    prevView := currentView.
2978
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
    92
    self hideHelp.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    93
    currentView := prevView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    94
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    95
    ^ false
2978
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
    96
4358a9302b95 changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
    97
    "Modified: / 23-12-2011 / 20:37:28 / cg"
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
    98
!
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
    99
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   100
keyPress:key x:x y:y view:aView
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   101
    <resource: #keyboard (#Escape)>
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   102
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   103
    |prevView|
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   104
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   105
    currentHelpView notNil ifTrue:[
2925
352825e1163c changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2920
diff changeset
   106
        key == $§ ifTrue:[
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   107
            "/ generate a line suitable for the resources file (a null translation)
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   108
            "/ into the clipboard; makes it easy to add missing translations to a .rs file,
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   109
            "/ by pressing paragrapj whenever you see an untranslated helptext
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   110
            aView setClipboardText:(lastHelpText storeString , '    ' , lastHelpText storeString).
2612
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   111
            self hideHelp.
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   112
            ^ true
Claus Gittinger <cg@exept.de>
parents: 2611
diff changeset
   113
        ].
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   114
        key == #Escape ifTrue:[
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   115
            prevView := currentView.
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   116
            self hideHelp.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   117
            currentView := prevView.
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   118
            ^ true
2885
a70144d85a81 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2884
diff changeset
   119
        ].
3216
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   120
        (#('Shift' #'Shift_L' #'Shift_R') includes:key) ifTrue:[
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   121
            "/ do not close on those...
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   122
            ^ false
f9312a1f2e9d class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3198
diff changeset
   123
        ].
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   124
    ].
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   125
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   126
    "/ hideHelp nils the currentView
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   127
    "/ we restore it, so the tooltip is not shown again for this view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   128
    "/ until the mouse really leaves the view
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   129
    "/ let's call this the "do-not-show-in-this-view mode"
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   130
    prevView := currentView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   131
    self hideHelpIgnoringErrors.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   132
    currentView := prevView.
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   133
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   134
    ^ false
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   135
    "/ ^ super keyPress:key x:x y:y view:aView
2884
7d37f5a0719e changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2878
diff changeset
   136
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   137
    "Modified (format): / 25-12-2011 / 10:25:23 / cg"
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   138
!
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   139
2521
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   140
mouseWheelMotion:state x:x y:y amount:amount deltaTime:dTime view:aView
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   141
    currentHelpView notNil ifTrue:[
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   142
        self handleMouseIn:aView x:x y:y.
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   143
    ].
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   144
    ^ false
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   145
!
7e51aa294156 care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents: 2519
diff changeset
   146
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   147
pointerLeave:state view:aView
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   148
    aView == currentHelpView ifTrue:[^ true].
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   149
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   150
    "/ clear the do-not-show-in-this-view mode (see keyPress)
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   151
"/     (currentHelpView isNil and:[currentView notNil]) ifTrue:[currentView := nil].
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   152
2611
f578b9c43a6f handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
   153
    ^ super pointerLeave:state view:aView
1540
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   154
! !
f6948fc36460 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1536
diff changeset
   155
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   156
!FlyByHelp methodsFor:'help texts'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
helpTextFromModel:aModel view:aView at:aPointOrNil 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    "helper: ask aModel for its helpText."
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
    |text|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    aPointOrNil notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
        (aModel respondsTo:#flyByHelpTextFor:at:) ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
            text := aModel flyByHelpTextFor:aView at:aPointOrNil.
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   166
            text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   169
    (aModel respondsTo:#flyByHelpTextFor:) ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   170
        text := aModel flyByHelpTextFor:aView.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   171
        text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   173
    ^ nil
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
helpTextFromView:aView at:aPointOrNil 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    "helper: ask aView for its helpText."
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   179
    |text key app|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    aPointOrNil notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
        (aView respondsTo:#flyByHelpTextAt:) ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
            text := aView flyByHelpTextAt:aPointOrNil.
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   184
            text notNil ifTrue:[^ text].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   187
    (aView respondsTo:#flyByHelpText) ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   188
        text := aView flyByHelpText.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   189
        text notNil ifTrue:[^ text].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   190
    ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   191
    (aView respondsTo:#helpKey) ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   192
        key := aView helpKey.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   193
        key notNil ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   194
            app := aView application.
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   195
            app isNil ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   196
                app := Error handle:[:ex | nil] do:[ aView windowGroup mainGroup application ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   197
            ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   198
            app notNil ifTrue:[
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   199
                ^ app flyByHelpTextForKey:key
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   200
            ].
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   201
            ^ aView resources string:key
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    ].
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   204
    ^ nil.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   205
! !
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   206
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   207
!FlyByHelp methodsFor:'private'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
hideIfPointerLeft:aView
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "hide help, if the pointer is not in aView"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    |whereOnScreen|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    currentFrame notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
        whereOnScreen := aView graphicsDevice pointerPosition.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
        (currentFrame notNil
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
        and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
            self hideHelp.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
        ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    "Modified: 28.5.1996 / 20:18:28 / cg"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
initiateHelpFor:aView at:aPointOrNil now:showItNow
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    "ask aView for helpText, passing x/y coordinates;
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
     start a timeout process to display this helpText after some delay;
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
     Normally used internally, but can also be used by widgets to force 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
     re-negotiation of the displayed helpText 
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
     (for example in a menu, when the selection changes)"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   233
    |text delayTime now|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    (self interestedIn:aView) ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
        ^ self
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   239
    now := Timestamp now.
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   240
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   241
    "/ do not allow for more than 200 ms to be spent in the
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   242
    "/ helpText gatherer (the codeView parses the code for the variable under the cursor)
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   243
    [
2826
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   244
        Error handle:[:ex |
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   245
            ('error in flyByhelp: ',ex description) errorPrintCR.
2901
fed697afcef8 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   246
            "/ ex suspendedContext fullPrintAllOn:Transcript.
2872
ea7e6fe01727 comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   247
            "/ self halt.
2826
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   248
        ] do:[
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   249
            text := self helpTextFor:aView at:aPointOrNil.
74bd82edee5a changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2799
diff changeset
   250
        ].
2684
de2d170a80ef *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2680
diff changeset
   251
    ] valueWithWatchDog:[ ^ self ] afterMilliseconds:(self flyByHelpTimeoutMillis).
2679
552847065fb3 car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents: 2651
diff changeset
   252
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    lastHelpText = text ifTrue:[
3228
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   254
        lastHelpWidget == aView ifTrue:[ 
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   255
            self toolTipFollowsMouse ifFalse:[
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   256
                ^ self
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   257
            ]
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   258
        ]
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    text size > 0 ifTrue:[
2778
8b91cf06a145 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2777
diff changeset
   262
        (showItNow not and:[(delayTime := self delayTime) > 0]) ifTrue:[
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
            self stopHelpDisplayProcess.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   264
            showProcess := 
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   265
                [
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   266
                    Delay waitForSeconds:delayTime.
2774
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   267
                    [
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   268
                        aView device anyButtonPressed ifFalse:[
2777
4cdef981fdb3 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   269
                            showProcess := nil.
2774
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   270
                            self showHelp:text for:aView
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   271
                        ]
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   272
                    ] ensure:[
7894ba397774 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   273
                        showProcess := nil.
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   274
                    ]
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   275
                ] forkAt:(Processor userSchedulingPriority + 1).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
        ] ifFalse:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
            self showHelp:text for:aView
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
        ]
1542
f63515aab510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1540
diff changeset
   279
    ] ifFalse:[
f63515aab510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1540
diff changeset
   280
        self hideHelp
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    ].
2872
ea7e6fe01727 comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2848
diff changeset
   282
2901
fed697afcef8 changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents: 2900
diff changeset
   283
    "Modified: / 22-03-2011 / 19:10:28 / cg"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
! !
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   286
!FlyByHelp methodsFor:'queries'!
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   287
2692
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   288
currentlyShownView
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   289
    ^ currentHelpView
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   290
!
5fe75b7fb83a access to current flyBy
Claus Gittinger <cg@exept.de>
parents: 2684
diff changeset
   291
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   292
toolTipFollowsMouse
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   293
    ^ false
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   294
! !
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   295
1768
7011c938442e method category rename
Claus Gittinger <cg@exept.de>
parents: 1677
diff changeset
   296
!FlyByHelp methodsFor:'show & hide help'!
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
hideHelp
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    "hide the help text"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    |p|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   303
    "/ lastHelpText := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    self stopHelpDisplayProcess.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    currentHelpView notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
        [
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   308
            currentHelpView notNil ifTrue:[
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   309
                currentHelpView unmap.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   310
                currentHelpView destroy.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   311
                currentHelpView := nil.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   312
                currentView := nil.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   313
            ]
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
        ] valueUninterruptably
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    currentFrame := nil.
3198
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   317
    (p := closeProcess) notNil ifTrue:[
a43053b56eb3 class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
   318
        closeProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
    ]
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    "Modified: 28.6.1997 / 14:03:50 / cg"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
showHelp:aHelpText for:view
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    "show the help text for aView"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   328
    |wg org p v dev helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight|
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
2781
31725cdfbe43 leftover print
Claus Gittinger <cg@exept.de>
parents: 2780
diff changeset
   330
    "/ thisContext fullPrintAllOn:Transcript.
2651
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   331
    (wg := view windowGroup) notNil ifTrue:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   332
        wg isInModalLoop ifTrue:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   333
            wg isModal ifFalse:[
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   334
                ^ self
7275384a60c7 care for nil windowGroup
Claus Gittinger <cg@exept.de>
parents: 2628
diff changeset
   335
            ].
2628
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   336
        ].
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   337
    ].
03a41945fb37 do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents: 2612
diff changeset
   338
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
    view == currentView ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
        lastHelpText = aHelpText ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
            ^ self
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
        ]
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
    ].
3228
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   344
    lastHelpWidget := view.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
    lastHelpText := aHelpText.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   348
    (p := closeProcess) notNil ifTrue:[
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   349
        closeProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    currentHelpView notNil ifTrue:[
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
        self hideHelp
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
    org := view originRelativeTo:nil.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
    currentFrame := org extent:view extent.
2848
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   358
    org := org + (view extent // 2).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
1677
dc49ab70b762 open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents: 1657
diff changeset
   360
    dev := view graphicsDevice.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
1963
fb6663696d20 removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   362
    v := ActiveHelpView for:aHelpText onDevice:dev.
2848
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   363
    helpViewWidth := v width.
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   364
    helpViewHeight := v height.
1677
dc49ab70b762 open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents: 1657
diff changeset
   365
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   366
    org := dev pointerPosition + (0@18"24").
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   367
    monitorBounds := dev monitorBoundsAt:org.
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   368
    usableWidth := monitorBounds width - 2.
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   369
    usableHeight := dev usableHeightAt:org.
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   370
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   371
    helpViewWidth > usableWidth ifTrue:[v width:(helpViewWidth := usableWidth)].    
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   372
    helpViewHeight > usableHeight ifTrue:[v width:(helpViewHeight := usableHeight)].    
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   373
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   374
    (org x + helpViewWidth) > (monitorBounds left + usableWidth) ifTrue:[
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   375
        org := ((monitorBounds left + usableWidth - helpViewWidth) @ org y).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
    ].
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   377
    (org y + helpViewHeight) > (monitorBounds top + usableHeight) ifTrue:[
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   378
        org := org x @ (monitorBounds top + usableHeight - helpViewHeight).
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
    v origin:org.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    v realize.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
    v enableButtonMotionEvents.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    v enableMotionEvents.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
    currentHelpView := v.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   386
    currentView := view.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   388
    self showTime notNil ifTrue:[
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   389
        closeProcess := [
1546
1af738601dae *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1542
diff changeset
   390
                [
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   391
                    (Delay forSeconds:self showTime) wait.
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   392
                    [
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   393
                        |v|
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   394
                        (v := currentHelpView) notNil ifTrue:[
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   395
                            currentHelpView := nil.
2780
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   396
                            v unmap.
82e3e1061ae7 changed:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
   397
                            v destroy.
2392
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   398
                        ]
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   399
                    ] valueUninterruptably
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   400
                ] ifCurtailed:[
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   401
                    closeProcess := nil.
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   402
                ].
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   403
            ] newProcess.
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   404
        closeProcess priority:(Processor userSchedulingPriority + 1).
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   405
        closeProcess resume.
02244f5708b7 reafctored
Claus Gittinger <cg@exept.de>
parents: 2002
diff changeset
   406
    ].
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
1963
fb6663696d20 removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents: 1893
diff changeset
   408
    "Modified: / 31-08-1995 / 19:20:45 / claus"
2848
43346e94b6ce changed: #showHelp:for:
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
   409
    "Modified: / 16-07-2010 / 14:33:13 / cg"
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
stopHelpDisplayProcess
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    |p|
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
2680
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   415
    (p := showProcess) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 2679
diff changeset
   416
        showProcess := nil.
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
        p terminate.
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
    ].
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
    "Created: 28.6.1997 / 14:03:17 / cg"
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
! !
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
!FlyByHelp class methodsFor:'documentation'!
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   425
version
3228
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   426
    ^ '$Header: /cvs/stx/stx/libview2/FlyByHelp.st,v 1.56 2013-09-03 15:23:55 cg Exp $'
2979
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   427
!
306456bdfb61 comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   428
2754
4c3b40eba71b changed:
Claus Gittinger <cg@exept.de>
parents: 2692
diff changeset
   429
version_CVS
3228
187a4158a51a class: FlyByHelp
Claus Gittinger <cg@exept.de>
parents: 3220
diff changeset
   430
    ^ '$Header: /cvs/stx/stx/libview2/FlyByHelp.st,v 1.56 2013-09-03 15:23:55 cg Exp $'
1536
fa0601a87d6e initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
! !
3114
fb742db4ee12 class: FlyByHelp
Stefan Vogel <sv@exept.de>
parents: 2979
diff changeset
   432