FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Wed, 26 Nov 2008 16:32:16 +0100
changeset 2435 f803a14907b4
parent 2352 ed9a6f37f85b
child 2493 b19544e382b7
permissions -rw-r--r--
? - command added
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@2300
    40
!FlyByWindowInformation methodsFor:'event handling'!
cg@2300
    41
cg@2340
    42
buttonMotion:buttonAndModifierState x:x y:y view:aView
cg@2340
    43
    super buttonMotion:buttonAndModifierState x:x y:y view:aView.
cg@2300
    44
    ^ true
cg@2300
    45
!
cg@2300
    46
cg@2300
    47
buttonPress:button x:x y:y view:aView
cg@2300
    48
    self stop.
cg@2300
    49
    ^ true
cg@2300
    50
!
cg@2300
    51
cg@2300
    52
keyPress:key x:x y:y view:aView
cg@2435
    53
    |obj action lcKey|
cg@2300
    54
cg@2300
    55
    key == #Escape ifTrue:[
cg@2300
    56
        self stop.
cg@2300
    57
        ^ true
cg@2300
    58
    ].
cg@2300
    59
cg@2435
    60
    key == $? ifTrue:[
cg@2435
    61
        [
cg@2435
    62
            WindowTreeView openOn:(lastView topView) initialSelection:lastView.
cg@2435
    63
        ] fork.
cg@2435
    64
        self stop.
cg@2435
    65
        ^ true.
cg@2300
    66
    ].
cg@2435
    67
cg@2435
    68
    key isCharacter ifTrue:[
cg@2435
    69
        lcKey := key asLowercase.
cg@2435
    70
cg@2435
    71
        lcKey == $a ifTrue:[
cg@2435
    72
            obj := lastApplication
cg@2300
    73
        ].
cg@2435
    74
        lcKey == $o ifTrue:[
cg@2435
    75
            obj := lastView model
cg@2435
    76
        ].
cg@2435
    77
        lcKey == $m ifTrue:[
cg@2435
    78
            obj := lastApplication masterApplication
cg@2435
    79
        ].
cg@2435
    80
        lcKey == $v ifTrue:[
cg@2435
    81
            obj := lastView
cg@2435
    82
        ].
cg@2435
    83
        lcKey == $t ifTrue:[
cg@2435
    84
            obj := lastView topView
cg@2435
    85
        ].
cg@2435
    86
        obj notNil ifTrue:[
cg@2435
    87
            key isLowercase ifTrue:[
cg@2435
    88
                action := [ obj inspect ].
cg@2435
    89
            ] ifFalse:[
cg@2435
    90
                action := [ obj browse ].
cg@2435
    91
            ].
cg@2435
    92
            action forkAt:8.
cg@2435
    93
        ].
cg@2300
    94
    ].
cg@2300
    95
cg@2300
    96
    ^ true
cg@2300
    97
! !
cg@2300
    98
cg@2300
    99
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   100
cg@2300
   101
helpTextFor:aView at:aPointOrNil
cg@2300
   102
    lastView := aView.
cg@2300
   103
    lastApplication := aView application.
cg@2300
   104
cg@2300
   105
    ^ String streamContents:[:s |
cg@2314
   106
        |topViewToInspect applicationToInspect masterApplicationToInspect modelToInspect|
cg@2314
   107
cg@2300
   108
        aView topView ~~ aView ifTrue:[
cg@2314
   109
            topViewToInspect := aView topView.
cg@2300
   110
        ].
cg@2300
   111
        lastApplication notNil ifTrue:[
cg@2314
   112
            applicationToInspect := lastApplication.
cg@2314
   113
            masterApplicationToInspect := lastApplication masterApplication.
cg@2314
   114
        ].
cg@2314
   115
        aView model notNil ifTrue:[
cg@2314
   116
            modelToInspect := aView model.
cg@2314
   117
            ((modelToInspect == applicationToInspect)
cg@2314
   118
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   119
                modelToInspect := nil.
cg@2300
   120
            ].
cg@2300
   121
        ].
cg@2314
   122
cg@2314
   123
cg@2352
   124
        s nextPutLine:('View: ' , aView class name, ' "',aView name printString,'"').
cg@2314
   125
        modelToInspect notNil ifTrue:[
cg@2314
   126
            s nextPutLine:('Model: ' , modelToInspect class name).
cg@2314
   127
        ].
cg@2314
   128
        topViewToInspect notNil ifTrue:[
cg@2314
   129
            s nextPutLine:('Topview: ' , topViewToInspect class name).
cg@2314
   130
        ].
cg@2314
   131
        applicationToInspect notNil ifTrue:[
cg@2314
   132
            s nextPutLine:('Application: ' , applicationToInspect class name).
cg@2314
   133
        ].
cg@2314
   134
        masterApplicationToInspect notNil ifTrue:[
cg@2314
   135
            s nextPutLine:('Masterapplication: ' , masterApplicationToInspect class name).
cg@2314
   136
        ].
cg@2314
   137
cg@2300
   138
        s cr.
cg@2300
   139
        s nextPutLine:'Press:'.
cg@2435
   140
        s nextPutLine:'    ? to show the viewtree'.
cg@2300
   141
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2314
   142
        modelToInspect notNil ifTrue:[
cg@2314
   143
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2314
   144
        ].
cg@2314
   145
        topViewToInspect notNil ifTrue:[
cg@2300
   146
            s nextPutLine:'    t to inspect topView (T to browse)'.
cg@2300
   147
        ].
cg@2314
   148
        applicationToInspect notNil ifTrue:[
cg@2300
   149
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   150
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   151
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2300
   152
            ].
cg@2300
   153
        ].
cg@2300
   154
        s nextPutAll:'    ESC or button to leave'.
cg@2300
   155
    ]
cg@2300
   156
cg@2300
   157
    "
cg@2300
   158
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   159
    "
cg@2300
   160
! !
cg@2300
   161
cg@2300
   162
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   163
cg@2300
   164
toolTipFollowsMouse
cg@2300
   165
    ^ true
cg@2300
   166
! !
cg@2300
   167
cg@2300
   168
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   169
cg@2300
   170
start
cg@2300
   171
    |l|
cg@2300
   172
cg@2300
   173
    l := FlyByHelp currentHelpListener.
cg@2300
   174
    l notNil ifTrue:[
cg@2300
   175
        FlyByHelp stop.
cg@2300
   176
        cleanupAction := [ FlyByHelp start ].
cg@2300
   177
    ].
cg@2300
   178
    finishSemaphore := Semaphore new.
cg@2300
   179
    super start.
cg@2300
   180
!
cg@2300
   181
cg@2300
   182
stop
cg@2300
   183
    super stop.
cg@2300
   184
    cleanupAction value.
cg@2300
   185
    finishSemaphore notNil ifTrue:[
cg@2300
   186
        finishSemaphore signalIf.
cg@2300
   187
    ].
cg@2300
   188
!
cg@2300
   189
cg@2300
   190
waitUntilFinished
cg@2300
   191
    finishSemaphore wait.
cg@2300
   192
! !
cg@2300
   193
cg@2300
   194
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   195
cg@2300
   196
version
cg@2300
   197
    ^ '$Header$'
cg@2300
   198
! !