FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Wed, 29 Jul 2009 20:02:02 +0200
changeset 2570 4e663bc64364
parent 2543 7ad308542625
child 2587 81f38cd168a7
permissions -rw-r--r--
changed #requestPackage
cg@2300
     1
"{ Package: 'stx:libtool2' }"
cg@2300
     2
cg@2300
     3
FlyByHelp subclass:#FlyByWindowInformation
cg@2300
     4
	instanceVariableNames:'lastApplication lastView cleanupAction finishSemaphore'
cg@2300
     5
	classVariableNames:''
cg@2300
     6
	poolDictionaries:''
cg@2300
     7
	category:'Interface-Help'
cg@2300
     8
!
cg@2300
     9
cg@2300
    10
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
    11
cg@2300
    12
examples
cg@2300
    13
"
cg@2300
    14
    self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    15
"
cg@2300
    16
!
cg@2300
    17
cg@2300
    18
shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    19
    self start waitUntilFinished
cg@2300
    20
cg@2300
    21
    "
cg@2300
    22
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    23
    "
cg@2300
    24
! !
cg@2300
    25
cg@2300
    26
!FlyByWindowInformation methodsFor:'accessing'!
cg@2300
    27
cg@2300
    28
cleanupAction:something
cg@2300
    29
    cleanupAction := something.
cg@2300
    30
!
cg@2300
    31
cg@2300
    32
lastApplication
cg@2300
    33
    ^ lastApplication
cg@2300
    34
!
cg@2300
    35
cg@2300
    36
lastView
cg@2300
    37
    ^ lastView
cg@2300
    38
! !
cg@2300
    39
cg@2543
    40
!FlyByWindowInformation methodsFor:'defaults'!
cg@2543
    41
cg@2543
    42
flyByHelpTimeoutMillis
cg@2543
    43
    ^ 1000
cg@2543
    44
! !
cg@2543
    45
cg@2300
    46
!FlyByWindowInformation methodsFor:'event handling'!
cg@2300
    47
cg@2340
    48
buttonMotion:buttonAndModifierState x:x y:y view:aView
cg@2340
    49
    super buttonMotion:buttonAndModifierState x:x y:y view:aView.
cg@2300
    50
    ^ true
cg@2300
    51
!
cg@2300
    52
cg@2300
    53
buttonPress:button x:x y:y view:aView
cg@2300
    54
    self stop.
cg@2300
    55
    ^ true
cg@2300
    56
!
cg@2300
    57
cg@2300
    58
keyPress:key x:x y:y view:aView
cg@2435
    59
    |obj action lcKey|
cg@2300
    60
cg@2300
    61
    key == #Escape ifTrue:[
cg@2300
    62
        self stop.
cg@2300
    63
        ^ true
cg@2300
    64
    ].
cg@2300
    65
cg@2435
    66
    key == $? ifTrue:[
cg@2435
    67
        [
cg@2435
    68
            WindowTreeView openOn:(lastView topView) initialSelection:lastView.
cg@2435
    69
        ] fork.
cg@2435
    70
        self stop.
cg@2435
    71
        ^ true.
cg@2300
    72
    ].
cg@2435
    73
cg@2435
    74
    key isCharacter ifTrue:[
cg@2435
    75
        lcKey := key asLowercase.
cg@2435
    76
cg@2435
    77
        lcKey == $a ifTrue:[
cg@2435
    78
            obj := lastApplication
cg@2300
    79
        ].
cg@2435
    80
        lcKey == $o ifTrue:[
cg@2435
    81
            obj := lastView model
cg@2435
    82
        ].
cg@2435
    83
        lcKey == $m ifTrue:[
cg@2435
    84
            obj := lastApplication masterApplication
cg@2435
    85
        ].
cg@2435
    86
        lcKey == $v ifTrue:[
cg@2435
    87
            obj := lastView
cg@2435
    88
        ].
cg@2435
    89
        lcKey == $t ifTrue:[
cg@2435
    90
            obj := lastView topView
cg@2435
    91
        ].
cg@2435
    92
        obj notNil ifTrue:[
cg@2435
    93
            key isLowercase ifTrue:[
cg@2435
    94
                action := [ obj inspect ].
cg@2435
    95
            ] ifFalse:[
cg@2435
    96
                action := [ obj browse ].
cg@2435
    97
            ].
cg@2435
    98
            action forkAt:8.
cg@2435
    99
        ].
cg@2300
   100
    ].
cg@2300
   101
cg@2300
   102
    ^ true
cg@2300
   103
! !
cg@2300
   104
cg@2300
   105
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   106
cg@2300
   107
helpTextFor:aView at:aPointOrNil
cg@2300
   108
    lastView := aView.
cg@2300
   109
    lastApplication := aView application.
cg@2300
   110
cg@2300
   111
    ^ String streamContents:[:s |
cg@2314
   112
        |topViewToInspect applicationToInspect masterApplicationToInspect modelToInspect|
cg@2314
   113
cg@2300
   114
        aView topView ~~ aView ifTrue:[
cg@2314
   115
            topViewToInspect := aView topView.
cg@2300
   116
        ].
cg@2300
   117
        lastApplication notNil ifTrue:[
cg@2314
   118
            applicationToInspect := lastApplication.
cg@2314
   119
            masterApplicationToInspect := lastApplication masterApplication.
cg@2314
   120
        ].
cg@2314
   121
        aView model notNil ifTrue:[
cg@2314
   122
            modelToInspect := aView model.
cg@2314
   123
            ((modelToInspect == applicationToInspect)
cg@2314
   124
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   125
                modelToInspect := nil.
cg@2300
   126
            ].
cg@2300
   127
        ].
cg@2314
   128
cg@2352
   129
        s nextPutLine:('View: ' , aView class name, ' "',aView name printString,'"').
cg@2314
   130
        modelToInspect notNil ifTrue:[
cg@2314
   131
            s nextPutLine:('Model: ' , modelToInspect class name).
cg@2314
   132
        ].
cg@2314
   133
        topViewToInspect notNil ifTrue:[
cg@2314
   134
            s nextPutLine:('Topview: ' , topViewToInspect class name).
cg@2314
   135
        ].
cg@2314
   136
        applicationToInspect notNil ifTrue:[
cg@2314
   137
            s nextPutLine:('Application: ' , applicationToInspect class name).
cg@2314
   138
        ].
cg@2314
   139
        masterApplicationToInspect notNil ifTrue:[
cg@2314
   140
            s nextPutLine:('Masterapplication: ' , masterApplicationToInspect class name).
cg@2314
   141
        ].
cg@2314
   142
cg@2300
   143
        s cr.
cg@2300
   144
        s nextPutLine:'Press:'.
cg@2435
   145
        s nextPutLine:'    ? to show the viewtree'.
cg@2300
   146
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2314
   147
        modelToInspect notNil ifTrue:[
cg@2314
   148
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2314
   149
        ].
cg@2314
   150
        topViewToInspect notNil ifTrue:[
cg@2300
   151
            s nextPutLine:'    t to inspect topView (T to browse)'.
cg@2300
   152
        ].
cg@2314
   153
        applicationToInspect notNil ifTrue:[
cg@2300
   154
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   155
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   156
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2300
   157
            ].
cg@2300
   158
        ].
cg@2493
   159
        s nextPutAll:'ESC or button to leave flyBy-info mode.'.
cg@2300
   160
    ]
cg@2300
   161
cg@2300
   162
    "
cg@2300
   163
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   164
    "
cg@2300
   165
! !
cg@2300
   166
cg@2300
   167
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   168
cg@2300
   169
toolTipFollowsMouse
cg@2300
   170
    ^ true
cg@2300
   171
! !
cg@2300
   172
cg@2300
   173
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   174
cg@2300
   175
start
cg@2300
   176
    |l|
cg@2300
   177
cg@2300
   178
    l := FlyByHelp currentHelpListener.
cg@2300
   179
    l notNil ifTrue:[
cg@2300
   180
        FlyByHelp stop.
cg@2300
   181
        cleanupAction := [ FlyByHelp start ].
cg@2300
   182
    ].
cg@2300
   183
    finishSemaphore := Semaphore new.
cg@2300
   184
    super start.
cg@2300
   185
!
cg@2300
   186
cg@2300
   187
stop
cg@2300
   188
    super stop.
cg@2300
   189
    cleanupAction value.
cg@2300
   190
    finishSemaphore notNil ifTrue:[
cg@2300
   191
        finishSemaphore signalIf.
cg@2300
   192
    ].
cg@2300
   193
!
cg@2300
   194
cg@2300
   195
waitUntilFinished
cg@2300
   196
    finishSemaphore wait.
cg@2300
   197
! !
cg@2300
   198
cg@2300
   199
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   200
cg@2300
   201
version
cg@2300
   202
    ^ '$Header$'
cg@2300
   203
! !