StatusBar ToolTips

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

StatusBar ToolTips

Daniel Rozzeta
Despite reading the old thread:

http://groups.google.com/groups?hl=es&lr=&threadm=9jq8kd%2412m0l%241%40ID-27443.news.dfncis.de&rnum=1&prev=/groups%3Fq%3Dstatusbar%2Btooltip%26hl%3Des%26lr%3D%26group%3Dcomp.lang.smalltalk.dolphin%26selm%3D9jq8kd%252412m0l%25241%2540ID-27443.news.dfncis.de%26rnum%3D1

and that the issues raised there appear to be resolved in D5, I can't
figure out how to show tooltips in a status bar.
Do anybody has any clue?


This is my sample code:

| package |
package := Package name: 'ToolTipSample'.
package paxVersion: 0;
        basicComment: ''.


package classNames
        add: #ToolTipShell;
        yourself.

package binaryGlobalNames: (Set new
        yourself).

package globalAliases: (Set new
        yourself).

package allResourceNames: (Set new
        add: #ToolTipShell -> 'Default view';
        yourself).

package setPrerequisites: (IdentitySet new
        add: 'Object Arts\Dolphin\Base\Dolphin';
        add: 'Object Arts\Dolphin\MVP\Views\Control Bars\Dolphin Control
Bars';
        add: 'Object Arts\Dolphin\MVP\Base\Dolphin MVP Base';
        add: 'Object Arts\Dolphin\MVP\Models\Value\Dolphin Value Models';
        yourself).

package!

"Class Definitions"!

Shell subclass: #ToolTipShell
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''!

"Global Aliases"!


"Loose Methods"!

"End of package definition"!

"Source Globals"!

"Classes"!

ToolTipShell guid: (GUID fromString:
'{5B2019ED-0B8D-4BAD-B0AA-C0036C5EC662}')!
ToolTipShell comment: ''!
!ToolTipShell categoriesForClass!MVP-Presenters! !
!ToolTipShell methodsFor!

onViewOpened

        | item |

        item := self view viewNamed: 'item'.
        item model: (ValueHolder with: 'TEXT').

        "Further experiments..."
        "item parentView hasToolTips: true."
        "item parentView setItem: item tipText: 'TOOLTIP '."
! !
!ToolTipShell categoriesFor: #onViewOpened!public! !

"Binary Globals"!

"Resources"!

(ResourceIdentifier class: ToolTipShell name: 'Default view') assign:
(Object fromBinaryStoreBytes:
(ByteArray fromBase64String:
'IVNUQiAxIEYCDAABAAAAVmlld1Jlc291cmNlAAAAAA4BJABTVEJSZXNvdXJjZVNUQkJ5dGVBcnJh
eUFjY2Vzc29yUHJveHkAAAAAcgAAAPkEAAAhU1RCIDEgTggMAAoAAABTVEJWaWV3UHJveHkAAAAA
mgAAAAAAAABSAAAAEAAAAERvbHBoaW4gTVZQIEJhc2VSAAAACQAAAFNoZWxsVmlld2IAAAAbAAAA
AAAAAAAAAABiAAAAAgAAAAEAngEBAAIAoAEAAAAAAAAAAAAAAAAAAAcCAAAAAAAAAAAAAAAAAACg
AQAABgcMAEJvcmRlckxheW91dAAAAAABAAAAAQAAAAAAAACaAQAAAAAAAJoAAAAAAAAAUgAAABQA
AABEb2xwaGluIENvbnRyb2wgQmFyc1IAAAAJAAAAU3RhdHVzQmFyYgAAABIAAAAAAAAAoAEAAGIA
AAACAAAAggAAAAQAAAAECQBEAQAAACACAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAYEBABGb250AAAA
AAAAAAAQAAAABgEHAExPR0ZPTlQAAAAAcgAAADwAAADz////AAAAAAAAAAAAAAAAkAEAAAAAAAAD
AgEiQXJpYWwAnwQAhj8BAADMNT8BAgAUOwAAAAD3AAVWbwEGAgUAUG9pbnQAAAAAwQAAAMEAAAAA
AAAAIAIAAAAAAACCAAAACAAAALUD//8AAAAA6gAAAAAAAAAAAQAAYgAAAAIAAAAGBw0AU3RhdHVz
QmFySXRlbQAAAAABAAAA/////yACAAAAAAAAmgAAAAAAAADAAQAAUgAAABEAAABCYXNpY0xpc3RB
YnN0cmFjdDADAAAOAhEAU1RCU2luZ2xldG9uUHJveHkAAAAAmgAAAAAAAADAAQAAUgAAABAAAABJ
Y29uSW1hZ2VNYW5hZ2VyugAAAAAAAABSAAAABwAAAGN1cnJlbnRSAAAABAAAAGl0ZW1iAAAAAQAA
AEADAA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DA1LmRsbAAAAAA='))!


Reply | Threaded
Open this post in threaded view
|

Re: StatusBar ToolTips

Ian Bartholomew-19
"Daniel Rozzeta" <[hidden email]> wrote in message
news:[hidden email]...

> and that the issues raised there appear to be resolved in D5, I can't
> figure out how to show tooltips in a status bar.
> Do anybody has any clue?

I can't get the package to load so I can't try it but your #onViewOpened
method is missing a supersend at the start and this is known to cause a lot
of problems.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: StatusBar ToolTips

Ian Bartholomew-19
I wrote;

> I can't get the package to load so I can't try it but your #onViewOpened
> method is missing a supersend at the start and this is known to cause a
> lot of problems.

As you've probably discovered now that didn't solve anything.  I haven't
looked into it again but it appears that D5 just won't display tool tips for
the StatusBar, even the normal browsers don't display anything.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: StatusBar ToolTips

Daniel Rozzeta
In reply to this post by Ian Bartholomew-19
"Ian Bartholomew" <[hidden email]> wrote in message news:<1108765097.422a23488c9255943f4f46bc88588cfa@teranews>...

> "Daniel Rozzeta" <[hidden email]> wrote in message
> news:[hidden email]...
>
> > and that the issues raised there appear to be resolved in D5, I can't
> > figure out how to show tooltips in a status bar.
> > Do anybody has any clue?
>
> I can't get the package to load so I can't try it but your #onViewOpened
> method is missing a supersend at the start and this is known to cause a lot
> of problems.

Yes, my mistake for trying to write a minimal sample quickly.
However, adding it didn't help.
I found the method Toolbar>>wmNotify: message wParam: wParam lParam:
lParam
It seems to me that it should belong to ControlBarAbstract instead of
Toolbar, so StatusBar may share it as well.  Moving it to the
superclass had the positive effect of actually receive the events I
couldn't catch before.
OTOH, I now get the following error:
SmallInteger does not understand #toolTipText
in method View>>onTipTextRequired: tool
Apparently ControlView>>ttnNeedText: aTOOLTIPTEXT
evaluates at some point:
        tool := (aTOOLTIPTEXT uFlags anyMask: TTF_IDISHWND)
                ifTrue: [View withHandle: idOrHandle]
                ifFalse: [idOrHandle].
and gets a 0 instead of a ToolbarButton or a CommandDescription (the
only classes that implement #toolTipText
So far I hadn't have the time to investigate further.

Best regards,
Daniel


Reply | Threaded
Open this post in threaded view
|

Re: StatusBar ToolTips

Daniel Rozzeta
Hi,
I finally made it to work.
It is just a hack, and I am sure there are much better ways to
implement it, but this is as far as my knowledge goes.
Below is a package I made with the modifications (only a bunch of
loose methods), but a class for testing purposes is also included.
By default, the StatusBarItem's tooltip text is the same as the item's
text, but I provided StatusBarItem>>tipText: in order to set its
value.

For further but not mandatory clean-ups do the following after package
installation:

* Remove Toolbar>>wmNotifi:wParam:lParam: (It has bean alreade moved
up to ControlBarAbstract)
* Remove Toolbar>>ttnNeedText:
* Remove Toolbar's instance variable tipText (not sure about this one
though)


Agreed:

* I used StatusBarItem's instance variable reserved1. I probably
shouldn't, but it is not easy to add an iv since status bar are used
everywhere
* The implementation of the new method StatuBarItem>>getTipText is
odd, but for some reason I haven't time to find, reserved1 gets
assigned at some point with an IconImageManager.

I will be glad if this is useful to someone.


Best regards,
Daniel Rozzeta


------------------


| package |
package := Package name: 'ToolTipSample'.
package paxVersion: 0;
        basicComment: ''.


package classNames
        add: #ToolTipShell;
        yourself.

package methodNames
        add: #ControlBarAbstract -> #ttnNeedText:;
        add: #ControlBarAbstract -> #wmNotify:wParam:lParam:;
        add: #StatusBar -> #buttonFromId:ifAbsent:;
        add: #StatusBar -> #onTipTextRequired:;
        add: #StatusBarItem -> #getTipText;
        add: #StatusBarItem -> #tipText:;
        add: #StatusBarItemAbstract -> #onTipTextRequired;
        yourself.

package binaryGlobalNames: (Set new
        yourself).

package globalAliases: (Set new
        yourself).

package allResourceNames: (Set new
        add: #ToolTipShell -> 'Default view';
        yourself).

package setPrerequisites: (IdentitySet new
        add: 'Projects\LineaSalud\Object Arts\Dolphin\Base\Dolphin';
        add: 'Projects\LineaSalud\Object Arts\Dolphin\MVP\Views\Control
Bars\Dolphin Control Bars';
        add: 'Projects\LineaSalud\Object Arts\Dolphin\MVP\Base\Dolphin MVP
Base';
        add: 'Projects\LineaSalud\Object
Arts\Dolphin\MVP\Models\Value\Dolphin Value Models';
        yourself).

package!

"Class Definitions"!

Shell subclass: #ToolTipShell
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''!

"Global Aliases"!


"Loose Methods"!

!ControlBarAbstract methodsFor!

ttnNeedText: aTOOLTIPTEXT
        "Private - Generic handler for the TTN_NEEDTEXT(A/W) notification
message."

        | tool idOrHandle |

        idOrHandle := aTOOLTIPTEXT idFrom.
        tool := (aTOOLTIPTEXT uFlags anyMask: TTF_IDISHWND)
                ifTrue: [View withHandle: idOrHandle]
                ifFalse: [self buttonFromId: idOrHandle ifAbsent: []].
        tool isNil ifTrue: [^nil "accept default processing"].
        aTOOLTIPTEXT text: (self presenter onTipTextRequired: tool).
        ^0!

wmNotify: message wParam: wParam lParam: lParam
        "Private - Redirects WM_NOTIFY messages to the appropriate control as
a notify message.
        Overridden here to handle notifications from the receiver's tool tip
control which
        does not itself have an associated View so cannot receive the
redirected message.
        In any case it is more convenient to direct the notification to the
receiver's
        #ttnNeedText: handler."

        | pnmhdr code |

        pnmhdr := lParam asExternalAddress.
        code := pnmhdr sdwordAtOffset: 8.
        (code == TTN_NEEDTEXTW or: [code == TTN_NEEDTEXTA]) ifTrue: [^self
nmNotify: pnmhdr].
        ^super wmNotify: message wParam: wParam lParam: lParam! !
!ControlBarAbstract categoriesFor: #ttnNeedText:!event
handling-win32!public! !
!ControlBarAbstract categoriesFor: #wmNotify:wParam:lParam:!event
handling-win32!private! !

!StatusBar methodsFor!

buttonFromId: aSmallInteger ifAbsent: aBlockClosure

        ^ parts
                at: aSmallInteger + 1
                ifAbsent: aBlockClosure.!

onTipTextRequired: item
        "Text is required for the tool-tip associated with the
        <ToolbarItem>, item."

        ^item onTipTextRequired! !
!StatusBar categoriesFor: #buttonFromId:ifAbsent:!public! !
!StatusBar categoriesFor: #onTipTextRequired:!public! !

!StatusBarItem methodsFor!

getTipText

        ^ (reserved1 isKindOf: String)
                ifTrue: [ reserved1 ]
                ifFalse: [ super getTipText ]!

tipText: aText

        reserved1 := aText.! !
!StatusBarItem categoriesFor: #getTipText!private!updating! !
!StatusBarItem categoriesFor: #tipText:!private!updating! !

!StatusBarItemAbstract methodsFor!

onTipTextRequired

        ^ self getTipText! !
!StatusBarItemAbstract categoriesFor: #onTipTextRequired!public! !

"End of package definition"!

"Source Globals"!

"Classes"!

ToolTipShell guid: (GUID fromString:
'{5B2019ED-0B8D-4BAD-B0AA-C0036C5EC662}')!
ToolTipShell comment: ''!
!ToolTipShell categoriesForClass!MVP-Presenters! !
!ToolTipShell methodsFor!

onViewOpened

        | item |

        item := self view viewNamed: 'item'.
        item
                model: (ValueHolder with: 'text 1');
                tipText: 'Tooltip 1'.

        item := self view viewNamed: 'item2'.
        item
                model: (ValueHolder with: 'text 2');
                tipText: 'Tooltip 2'.! !
!ToolTipShell categoriesFor: #onViewOpened!public! !

"Binary Globals"!

"Resources"!

(ResourceIdentifier class: ToolTipShell name: 'Default view') assign:
(Object fromBinaryStoreBytes:
(ByteArray fromBase64String:
'IVNUQiAxIEYCDAABAAAAVmlld1Jlc291cmNlAAAAAA4BJABTVEJSZXNvdXJjZVNUQkJ5dGVBcnJh
eUFjY2Vzc29yUHJveHkAAAAAcgAAAC4FAAAhU1RCIDEgTggMAAoAAABTVEJWaWV3UHJveHkAAAAA
mgAAAAAAAABSAAAAEAAAAERvbHBoaW4gTVZQIEJhc2VSAAAACQAAAFNoZWxsVmlld2IAAAAbAAAA
AAAAAAAAAABiAAAAAgAAAAEAngEBAAIAoAEAAAAAAAAAAAAAAAAAAAcCAAAAAAAAAAAAAAAAAACg
AQAABgcMAEJvcmRlckxheW91dAAAAAABAAAAAQAAAAAAAACaAQAAAAAAAJoAAAAAAAAAUgAAABQA
AABEb2xwaGluIENvbnRyb2wgQmFyc1IAAAAJAAAAU3RhdHVzQmFyYgAAABIAAAAAAAAAoAEAAGI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