FlyByWindowInformation.st
author Claus Gittinger <cg@exept.de>
Mon, 16 Sep 2013 12:56:06 +0200
changeset 3058 d7792b7a50b7
parent 2943 e7d181ac8f06
child 3065 311d632319d9
permissions -rw-r--r--
more control over the shape style
(tooltips vs. window information)
cg@2587
     1
"
cg@2587
     2
 COPYRIGHT (c) 2008 by eXept Software AG
cg@2587
     3
              All Rights Reserved
cg@2587
     4
cg@2587
     5
 This software is furnished under a license and may be used
cg@2587
     6
 only in accordance with the terms of that license and with the
cg@2587
     7
 inclusion of the above copyright notice.   This software may not
cg@2587
     8
 be provided or otherwise made available to, or used by, any
cg@2587
     9
 other person.  No title to or ownership of the software is
cg@2587
    10
 hereby transferred.
cg@2587
    11
"
cg@2300
    12
"{ Package: 'stx:libtool2' }"
cg@2300
    13
cg@2300
    14
FlyByHelp subclass:#FlyByWindowInformation
cg@2699
    15
	instanceVariableNames:'lastApplication lastView cleanupAction finishSemaphore finished'
cg@2300
    16
	classVariableNames:''
cg@2300
    17
	poolDictionaries:''
cg@2300
    18
	category:'Interface-Help'
cg@2300
    19
!
cg@2300
    20
cg@2300
    21
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
    22
cg@2587
    23
copyright
cg@2587
    24
"
cg@2587
    25
 COPYRIGHT (c) 2008 by eXept Software AG
cg@2587
    26
              All Rights Reserved
cg@2587
    27
cg@2587
    28
 This software is furnished under a license and may be used
cg@2587
    29
 only in accordance with the terms of that license and with the
cg@2587
    30
 inclusion of the above copyright notice.   This software may not
cg@2587
    31
 be provided or otherwise made available to, or used by, any
cg@2587
    32
 other person.  No title to or ownership of the software is
cg@2587
    33
 hereby transferred.
cg@2587
    34
"
cg@2587
    35
!
cg@2587
    36
cg@2300
    37
examples
cg@2300
    38
"
cg@2300
    39
    self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    40
"
cg@2300
    41
!
cg@2300
    42
cg@2300
    43
shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    44
    self start waitUntilFinished
cg@2300
    45
cg@2300
    46
    "
cg@2300
    47
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
    48
    "
cg@2300
    49
! !
cg@2300
    50
cg@2300
    51
!FlyByWindowInformation methodsFor:'accessing'!
cg@2300
    52
cg@2699
    53
cleanupAction:something 
cg@2300
    54
    cleanupAction := something.
cg@2300
    55
!
cg@2300
    56
cg@2300
    57
lastApplication
cg@2300
    58
    ^ lastApplication
cg@2300
    59
!
cg@2300
    60
cg@2300
    61
lastView
cg@2300
    62
    ^ lastView
cg@2300
    63
! !
cg@2300
    64
cg@2543
    65
!FlyByWindowInformation methodsFor:'defaults'!
cg@2543
    66
cg@2543
    67
flyByHelpTimeoutMillis
cg@2543
    68
    ^ 1000
cg@2543
    69
! !
cg@2543
    70
cg@2300
    71
!FlyByWindowInformation methodsFor:'event handling'!
cg@2300
    72
cg@2340
    73
buttonMotion:buttonAndModifierState x:x y:y view:aView
cg@2702
    74
    finished == true ifTrue:[^ self].
cg@2702
    75
cg@2340
    76
    super buttonMotion:buttonAndModifierState x:x y:y view:aView.
cg@2300
    77
    ^ true
cg@2300
    78
!
cg@2300
    79
cg@2300
    80
buttonPress:button x:x y:y view:aView
cg@2300
    81
    self stop.
cg@2300
    82
    ^ true
cg@2300
    83
!
cg@2300
    84
cg@2300
    85
keyPress:key x:x y:y view:aView
cg@2943
    86
    <resource: #keyboard (#Escape #Return)>
cg@2943
    87
cg@2823
    88
    |obj objToInspect objToBrowse lcKey|
cg@2300
    89
cg@2300
    90
    key == #Escape ifTrue:[
cg@2300
    91
        self stop.
cg@2300
    92
        ^ true
cg@2300
    93
    ].
cg@2300
    94
cg@2435
    95
    key == $? ifTrue:[
cg@2435
    96
        [
sv@2836
    97
            WindowTreeView notNil ifTrue:[
sv@2836
    98
                WindowTreeView openOn:(lastView topView) initialSelection:lastView.
sv@2836
    99
            ] ifFalse:[
sv@2836
   100
                self warn:'WindowTreeView class is not present!!'.
sv@2836
   101
            ].
cg@2435
   102
        ] fork.
cg@2435
   103
        self stop.
cg@2435
   104
        ^ true.
cg@2300
   105
    ].
cg@2435
   106
cg@2823
   107
    key == #Return ifTrue:[
cg@2823
   108
        objToBrowse := lastApplication ? lastView
cg@2823
   109
    ].
cg@2823
   110
cg@2435
   111
    key isCharacter ifTrue:[
cg@2435
   112
        lcKey := key asLowercase.
cg@2435
   113
cg@2435
   114
        lcKey == $a ifTrue:[
cg@2435
   115
            obj := lastApplication
cg@2300
   116
        ].
cg@2435
   117
        lcKey == $o ifTrue:[
cg@2824
   118
            lastView notNil ifTrue:[
cg@2824
   119
                obj := lastView model
cg@2824
   120
            ].
cg@2435
   121
        ].
cg@2435
   122
        lcKey == $m ifTrue:[
cg@2824
   123
            lastApplication notNil ifTrue:[
cg@2824
   124
                obj := lastApplication masterApplication
cg@2824
   125
            ]
cg@2824
   126
        ].
cg@2824
   127
        lcKey == $t ifTrue:[
cg@2824
   128
            lastApplication notNil ifTrue:[
cg@2824
   129
                obj := lastApplication topApplication
cg@2824
   130
            ].
cg@2435
   131
        ].
cg@2435
   132
        lcKey == $v ifTrue:[
cg@2435
   133
            obj := lastView
cg@2435
   134
        ].
cg@2939
   135
        lcKey == $g ifTrue:[
cg@2939
   136
            obj := lastView windowGroup
cg@2939
   137
        ].
cg@2824
   138
        lcKey == $w ifTrue:[
cg@2824
   139
            lastView notNil ifTrue:[
cg@2824
   140
                obj := lastView topView
cg@2824
   141
            ]
cg@2435
   142
        ].
cg@2435
   143
        obj notNil ifTrue:[
cg@2435
   144
            key isLowercase ifTrue:[
cg@2823
   145
                objToInspect := obj
cg@2435
   146
            ] ifFalse:[
cg@2823
   147
                objToBrowse := obj
cg@2435
   148
            ].
cg@2435
   149
        ].
cg@2300
   150
    ].
cg@2300
   151
cg@2823
   152
    objToInspect notNil ifTrue:[
cg@2823
   153
        [ objToInspect inspect ] forkAt:(Processor userSchedulingPriority).
cg@2823
   154
    ].
cg@2823
   155
    objToBrowse notNil ifTrue:[
cg@2823
   156
        [ objToBrowse browse ] forkAt:(Processor userSchedulingPriority).
cg@2823
   157
    ].
cg@2823
   158
cg@2300
   159
    ^ true
cg@2823
   160
cg@2824
   161
    "Modified: / 12-11-2010 / 11:51:04 / cg"
cg@2300
   162
! !
cg@2300
   163
cg@2300
   164
!FlyByWindowInformation methodsFor:'help texts'!
cg@2300
   165
cg@2300
   166
helpTextFor:aView at:aPointOrNil
cg@2699
   167
    "generate the text to be shown as popup-flyby info"
cg@2699
   168
cg@2824
   169
    |resources|
cg@2824
   170
cg@2300
   171
    lastView := aView.
cg@2300
   172
    lastApplication := aView application.
cg@2300
   173
cg@2824
   174
    resources := self class classResources.
cg@2824
   175
cg@2824
   176
    ^ Text streamContents:[:s |
cg@2824
   177
        |topViewToInspect applicationToInspect 
cg@2824
   178
         masterApplicationToInspect topApplicationToInspect modelToInspect
cg@2939
   179
         genComponentNameForApplication windowGroupToInspect|
cg@2700
   180
cg@2824
   181
        genComponentNameForApplication := 
cg@2824
   182
            [:app :s |
cg@2700
   183
                (app notNil 
cg@2700
   184
                and:[ app builder notNil ]) ifTrue:[
cg@2700
   185
                    |components v|
cg@2700
   186
cg@2700
   187
                    components := app builder namedComponents.
cg@2700
   188
cg@2700
   189
                    v := aView.
cg@2700
   190
                    [   (components includes:v) not
cg@2700
   191
                        and:[v container notNil]
cg@2700
   192
                    ] whileTrue:[
cg@2700
   193
                        v := v container.
cg@2700
   194
                    ].
cg@2700
   195
                    (components includes:v) ifTrue:[
cg@2700
   196
                        |k|
cg@2700
   197
cg@2700
   198
                        k := components keyAtValue:v.
cg@2700
   199
                        v == aView ifTrue:[
cg@2824
   200
                            s nextPutLine:('       component: ' , k).
cg@2700
   201
                        ] ifFalse:[
cg@2824
   202
                            s nextPutLine:('       subview of component: ' , k).
cg@2700
   203
                        ].
cg@2700
   204
                    ].
cg@2700
   205
                ].
cg@2700
   206
            ].
cg@2314
   207
cg@2300
   208
        aView topView ~~ aView ifTrue:[
cg@2314
   209
            topViewToInspect := aView topView.
cg@2300
   210
        ].
cg@2300
   211
        lastApplication notNil ifTrue:[
cg@2314
   212
            applicationToInspect := lastApplication.
cg@2314
   213
            masterApplicationToInspect := lastApplication masterApplication.
cg@2824
   214
            masterApplicationToInspect notNil ifTrue:[
cg@2824
   215
                masterApplicationToInspect == applicationToInspect ifTrue:[
cg@2824
   216
                    masterApplicationToInspect := nil
cg@2824
   217
                ] ifFalse:[
cg@2824
   218
                    topApplicationToInspect := masterApplicationToInspect topApplication.
cg@2824
   219
                    topApplicationToInspect == masterApplicationToInspect ifTrue:[
cg@2824
   220
                        topApplicationToInspect := nil
cg@2824
   221
                    ]
cg@2824
   222
                ].
cg@2824
   223
            ]
cg@2314
   224
        ].
cg@2314
   225
        aView model notNil ifTrue:[
cg@2314
   226
            modelToInspect := aView model.
cg@2314
   227
            ((modelToInspect == applicationToInspect)
cg@2314
   228
            or:[ modelToInspect == masterApplicationToInspect ]) ifTrue:[
cg@2314
   229
                modelToInspect := nil.
cg@2300
   230
            ].
cg@2300
   231
        ].
cg@2314
   232
cg@2824
   233
        applicationToInspect notNil ifTrue:[
cg@2824
   234
            s nextPutLine:(resources string:'Application: %1' with:applicationToInspect class name allBold).
cg@2824
   235
            genComponentNameForApplication value:applicationToInspect value:s.
cg@2314
   236
        ].
cg@2700
   237
        masterApplicationToInspect notNil ifTrue:[
cg@2824
   238
            s nextPutLine:(resources string:'Master-Application: %1' with:masterApplicationToInspect class name allBold).
cg@2824
   239
            "/ genComponentNameForApplication value:masterApplicationToInspect value:s.
cg@2700
   240
        ].
cg@2824
   241
        topApplicationToInspect notNil ifTrue:[
cg@2824
   242
            s nextPutLine:(resources string:'Top-Application: %1' with:topApplicationToInspect class name allBold).
cg@2824
   243
            "/ genComponentNameForApplication value:topApplicationToInspect value:s.
cg@2314
   244
        ].
cg@2824
   245
        s nextPutLine:(resources string:'View: %1 "%2"' with:aView class name allBold with:aView name).
cg@2824
   246
        topViewToInspect notNil ifTrue:[
cg@2824
   247
            s nextPutLine:(resources string:'Topview: %1' with:topViewToInspect class name allBold).
cg@2824
   248
        ].
cg@2824
   249
        modelToInspect notNil ifTrue:[
cg@2824
   250
            s nextPutLine:(resources string:'Model: %1' with:modelToInspect class name allBold).
cg@2824
   251
        ].
cg@2699
   252
cg@2300
   253
        s cr.
cg@2300
   254
        s nextPutLine:'Press:'.
cg@2435
   255
        s nextPutLine:'    ? to show the viewtree'.
cg@2314
   256
        applicationToInspect notNil ifTrue:[
cg@2300
   257
            s nextPutLine:'    a to inspect application (A to browse)'.
cg@2314
   258
            masterApplicationToInspect notNil ifTrue:[
cg@2300
   259
                s nextPutLine:'    m to inspect masterApplication (M to browse)'.
cg@2824
   260
                topApplicationToInspect notNil ifTrue:[
cg@2824
   261
                    s nextPutLine:'    t to inspect masterApplication (T to browse)'.
cg@2824
   262
                ]
cg@2300
   263
            ].
cg@2300
   264
        ].
cg@2823
   265
        s nextPutLine:'    v to inspect view (V to browse)'.
cg@2823
   266
        topViewToInspect notNil ifTrue:[
cg@2824
   267
            s nextPutLine:'    w to inspect topWindow (W to browse)'.
cg@2823
   268
        ].
cg@2939
   269
        aView windowGroup notNil ifTrue:[
cg@2939
   270
            s nextPutLine:'    g to inspect windowGroup'.
cg@2939
   271
        ].
cg@2823
   272
        modelToInspect notNil ifTrue:[
cg@2823
   273
            s nextPutLine:'    o to inspect model (O to browse)'.
cg@2823
   274
        ].
cg@2823
   275
        s cr.
cg@2823
   276
        s nextPutLine:'RETURN to browse application.'.
cg@2823
   277
        s nextPutAll:'ESC or click to leave flyBy-info mode.'.
cg@2300
   278
    ]
cg@2300
   279
cg@2300
   280
    "
cg@2300
   281
     self shownInformationOfViewUnderMouseUntilButtonIsPressed
cg@2300
   282
    "
cg@2823
   283
cg@2824
   284
    "Modified: / 12-11-2010 / 11:54:59 / cg"
cg@2300
   285
! !
cg@2300
   286
cg@2710
   287
!FlyByWindowInformation methodsFor:'private'!
cg@2710
   288
cg@3058
   289
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice
cg@3058
   290
    ^ (ActiveHelpView for:helpText onDevice:aDevice) shapeStyle:nil.
cg@3058
   291
!
cg@3058
   292
cg@2847
   293
handleMouseIn:aView x:x y:y
cg@2847
   294
    finished == true ifTrue:[^ self].
cg@2847
   295
    super handleMouseIn:aView x:x y:y
cg@2847
   296
!
cg@2847
   297
cg@2710
   298
targetViewInitiatesHelpViaSensor
cg@2710
   299
    ^ false
cg@2710
   300
! !
cg@2710
   301
cg@2300
   302
!FlyByWindowInformation methodsFor:'queries'!
cg@2300
   303
cg@2300
   304
toolTipFollowsMouse
cg@2300
   305
    ^ true
cg@2300
   306
! !
cg@2300
   307
cg@2300
   308
!FlyByWindowInformation methodsFor:'start & stop'!
cg@2300
   309
cg@2699
   310
initiateHelpFor:aView at:aPointOrNil
cg@2710
   311
    self initiateHelpFor:aView at:aPointOrNil now:true
cg@2699
   312
!
cg@2699
   313
cg@2699
   314
initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2702
   315
    finished == true ifTrue:[^ self].
cg@2699
   316
    super initiateHelpFor:aView at:aPointOrNil now:showItNow
cg@2699
   317
!
cg@2699
   318
cg@2300
   319
start
cg@2300
   320
    |l|
cg@2300
   321
cg@2702
   322
    finished == true ifTrue:[^ self].
cg@2702
   323
cg@2300
   324
    l := FlyByHelp currentHelpListener.
cg@2300
   325
    l notNil ifTrue:[
cg@2300
   326
        FlyByHelp stop.
cg@2300
   327
        cleanupAction := [ FlyByHelp start ].
cg@2300
   328
    ].
cg@2300
   329
    finishSemaphore := Semaphore new.
cg@2699
   330
    finished := false.
cg@2300
   331
    super start.
cg@2300
   332
!
cg@2300
   333
cg@2300
   334
stop
cg@2699
   335
    finished := true.
cg@2300
   336
    super stop.
cg@2300
   337
    cleanupAction value.
cg@2300
   338
    finishSemaphore notNil ifTrue:[
cg@2300
   339
        finishSemaphore signalIf.
cg@2300
   340
    ].
cg@2300
   341
!
cg@2300
   342
cg@2300
   343
waitUntilFinished
cg@2300
   344
    finishSemaphore wait.
cg@2300
   345
! !
cg@2300
   346
cg@2300
   347
!FlyByWindowInformation class methodsFor:'documentation'!
cg@2300
   348
cg@2587
   349
version_CVS
cg@2587
   350
    ^ '$Header$'
cg@2300
   351
! !
cg@2943
   352