[GOODIE] US NotifyShell

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

[GOODIE] US NotifyShell

Udo Schneider
This package allows you to use the traybar in a very easy way. It is based
on Ian's TaskbarIcon Package.

Just create your Application Shell as subclass of NotifyShell (or mutate
existing ones) and
respond to the triggered events.

Comments are highly appreciated.


Udo

-------------------------------- US
NotifyShell.pac --------------------------------

| package |
package := Package name: 'US NotifyShell'.
package paxVersion: 0;
 basicComment: 'US NotifyShell
Udo Schneider <[hidden email]> 2002

This package contains additions to the standard Dolphin Smalltalk Shell
class which allows you to use the traybar.

Execute the following code to see an example implementation of the
NotifyShell which responds to various events.

 NotifyShellExample show'.

package basicPackageVersion: '0.001'.

"Add the package scripts"

"Add the class names, loose method names, global names, resource names"
package classNames
 add: #NotifyShell;
 add: #NotifyShellExample;
 add: #ShellNotifyView;
 yourself.

package methodNames
 add: #ShellLibrary -> #shell_NotifyIcon:pnid:;
 yourself.

package globalNames
 yourself.

package resourceNames
 yourself.

"Binary Global Names"
package binaryGlobalNames: (Set new
 yourself).
"Resource Names"
package allResourceNames: (Set new
 add: #NotifyShell -> 'Default view';
 yourself).

"Add the prerequisite names"
package setPrerequisites: (IdentitySet new
 add: 'Development System';
 add: 'Dolphin';
 yourself).

package!

"Class Definitions"!

Shell subclass: #NotifyShell
 instanceVariableNames: ''
 classVariableNames: ''
 poolDictionaries: ''
 classInstanceVariableNames: ''!
NotifyShell subclass: #NotifyShellExample
 instanceVariableNames: ''
 classVariableNames: ''
 poolDictionaries: ''
 classInstanceVariableNames: ''!
ShellView subclass: #ShellNotifyView
 instanceVariableNames: 'notifyStruct notifyMessage notifyIcon
notifyTipMessage'
 classVariableNames: 'NotifyMessageMap'
 poolDictionaries: ''
 classInstanceVariableNames: ''!
"Loose Methods"!

!ShellLibrary methodsFor!

shell_NotifyIcon: dwMessage pnid: pnid
 "Add, modify, or delete an icon from the taskbar status area.
  WINSHELLAPI BOOL WINAPI Shell_NotifyIcon(
   DWORD dwMessage,  // message identifier
   PNOTIFYICONDATA pnid  // pointer to structure
  ); "

 <stdcall: bool Shell_NotifyIconA dword NOTIFYICONDATA* >
 ^self invalidCall! !
!ShellLibrary categoriesFor:
#shell_NotifyIcon:pnid:!*-primitives!*-unclassified!public! !

"End of package definition"!



NotifyShell comment: ''!

NotifyShell guid: (GUID fromString:
'{76A412BA-947A-40AA-83BA-9BD384979C29}')!

!NotifyShell categoriesForClass!Unclassified! !


NotifyShellExample comment: ''!

NotifyShellExample guid: (GUID fromString:
'{8E0528A6-54F0-4368-8D83-83CC78AF605D}')!

!NotifyShellExample categoriesForClass!Unclassified! !
!NotifyShellExample methodsFor!

createSchematicWiring
 "Create the trigger wiring for the receiver"

 super createSchematicWiring.
 self when: #onTraybarLeftButtonPressed send: #traybarEvent: to: self with:
'Left Button Pressed'.
 self when: #onTraybarRightButtonPressed send: #traybarEvent: to: self with:
'Right Button Pressed'.
 self when: #onTraybarLeftButtonDoubleClicked send: #traybarEvent: to: self
with: 'Left Button Double Clicked'.
 self when: #onTraybarRightButtonDoucleClicked send: #traybarEvent: to: self
with: 'Right Button Double Clicked'.!

traybarEvent: aString
 MessageBox notify: aString! !
!NotifyShellExample categoriesFor:
#createSchematicWiring!*-unclassified!public! !
!NotifyShellExample categoriesFor: #traybarEvent:!*-unclassified!public! !



ShellNotifyView comment: ''!

ShellNotifyView guid: (GUID fromString:
'{6C3394D3-CC74-471F-86D8-6F5A7D25E621}')!

!ShellNotifyView categoriesForClass!Unclassified! !
!ShellNotifyView methodsFor!

addNotifyIcon
 self initializeNotifyStruct.
 notifyStruct hWnd: self asParameter.
 ^ShellLibrary default shell_NotifyIcon: NIM_ADD pnid: notifyStruct

!

deleteNotifyIcon
 ^ShellLibrary default shell_NotifyIcon: NIM_DELETE pnid: notifyStruct.!

dispatchRegistered: registeredId wParam: wParam lParam: lParam
 ^registeredId = notifyMessage
  ifTrue: [
   (NotifyMessageMap includesKey: lParam) ifTrue: [
    self perform: (NotifyMessageMap at: lParam)
   ]
 ]!

initializeNotifyStruct
 notifyStruct := NOTIFYICONDATA new.
 notifyMessage := self class registerMessage: 'Dolphin Shell Notification'.
 notifyStruct
  uID: 1;
  icon: self notifyIcon;
  message: self notifyMessage;
  tipText: self notifyTipMessage.
!

notifyIcon
 "Private - Answer the value of the receiver's ''notifyIcon'' instance
variable."
 notifyIcon isNil ifTrue: [notifyIcon := self  icon].
 ^notifyIcon!

notifyIcon: anObject
 "Private - Set the value of the receiver's ''notifyIcon'' instance variable
to the argument, anObject."

 notifyIcon := anObject!

notifyMessage
 "Private - Answer the value of the receiver's ''notifyMessage'' instance
variable."

 ^notifyMessage!

notifyMessage: anObject
 "Private - Set the value of the receiver's ''notifyMessage'' instance
variable to the argument, anObject."

 notifyMessage := anObject!

notifyStruct
 "Private - Answer the value of the receiver's ''notifyStruct'' instance
variable."

 ^notifyStruct!

notifyStruct: anObject
 "Private - Set the value of the receiver's ''notifyStruct'' instance
variable to the argument, anObject."

 notifyStruct := anObject!

notifyTipMessage
 "Private - Answer the value of the receiver's ''notifyTipMessage'' instance
variable."
 notifyTipMessage isNil ifTrue: [notifyTipMessage := 'Notify Message'].
 ^notifyTipMessage!

notifyTipMessage: anObject
 "Private - Set the value of the receiver's ''notifyTipMessage'' instance
variable to the argument, anObject."

 notifyTipMessage := anObject!

onCreated: anEvent
 self addNotifyIcon.
 ^super onCreated: anEvent
!

onDestroyed
 self deleteNotifyIcon.
 ^super onDestroyed
!

onTraybarLeftButtonDoubleClicked
 self presenter trigger: #onTraybarLeftButtonDoubleClicked!

onTraybarLeftButtonPressed
 self presenter trigger: #onTraybarLeftButtonPressed!

onTraybarRightButtonDoubleClicked
 self presenter trigger: #onTraybarRightButtonDoubleClicked!

onTraybarRightButtonPressed
 self presenter trigger: #onTraybarRightButtonPressed! !
!ShellNotifyView categoriesFor: #addNotifyIcon!*-unclassified!private! !
!ShellNotifyView categoriesFor: #deleteNotifyIcon!*-unclassified!private! !
!ShellNotifyView categoriesFor:
#dispatchRegistered:wParam:lParam:!*-unclassified!private! !
!ShellNotifyView categoriesFor:
#initializeNotifyStruct!initializing!private! !
!ShellNotifyView categoriesFor: #notifyIcon!accessing!private! !
!ShellNotifyView categoriesFor: #notifyIcon:!accessing!private! !
!ShellNotifyView categoriesFor: #notifyMessage!accessing!private! !
!ShellNotifyView categoriesFor: #notifyMessage:!accessing!private! !
!ShellNotifyView categoriesFor: #notifyStruct!accessing!private! !
!ShellNotifyView categoriesFor: #notifyStruct:!accessing!private! !
!ShellNotifyView categoriesFor: #notifyTipMessage!accessing!private! !
!ShellNotifyView categoriesFor: #notifyTipMessage:!accessing!private! !
!ShellNotifyView categoriesFor: #onCreated:!event handling!private! !
!ShellNotifyView categoriesFor: #onDestroyed!event handling!private! !
!ShellNotifyView categoriesFor: #onTraybarLeftButtonDoubleClicked!event
handling!private! !
!ShellNotifyView categoriesFor: #onTraybarLeftButtonPressed!event
handling!private! !
!ShellNotifyView categoriesFor: #onTraybarRightButtonDoubleClicked!event
handling!private! !
!ShellNotifyView categoriesFor: #onTraybarRightButtonPressed!event
handling!private! !

!ShellNotifyView class methodsFor!

initialize
 NotifyMessageMap := Dictionary new.
 NotifyMessageMap at: WM_LBUTTONDOWN put: #onTraybarLeftButtonPressed;
   at: WM_RBUTTONDOWN put: #onTraybarRightButtonPressed;
  at: WM_LBUTTONDBLCLK put: #onTraybarLeftButtonDoubleClicked;
  at: WM_RBUTTONDBLCLK put: #onTraybarRightButtonDoubleClicked.!

publishedAspectsOfInstances
 ^super publishedAspectsOfInstances
  add: (Aspect icon: #notifyIcon);
  add: (Aspect string: #notifyTipMessage);
  yourself
!

publishedEventsOfInstances
 "Answer a Set of Symbols that describe the published events triggered
 by instances of the receiver."

 ^super publishedEventsOfInstances
  add: #onTraybarLeftButtonPressed;
  add: #onTraybarRightButtonPressed;
  add: #onTraybarLeftButtonDoubleClicked;
  add: #onTraybarRightButtonDoubleClicked;
  yourself.! !
!ShellNotifyView class categoriesFor: #initialize!*-unclassified!public! !
!ShellNotifyView class categoriesFor:
#publishedAspectsOfInstances!*-unclassified!public! !
!ShellNotifyView class categoriesFor:
#publishedEventsOfInstances!*-unclassified!public! !


"Binary Globals"!

"Resources"!

(ResourceIdentifier class: NotifyShell name: 'Default view') assign: (Object
fromBinaryStoreBytes:
(ByteArray fromHexString:
'2153544220302046020C0001000000566965775265736F75726365000000000E01240053544
25265736F757263655354424279746541727261794163636573736F7250726F7879000000003
600090042797465417272617923040000215354422030204E080C000A0000005354425669657
750726F7879000000004E020D0001000000535442436C61737350726F7879000000003600060
0537472696E67120000005553205368656C6C4E6F7469667956696577920000000F000000536
8656C6C4E6F74696679566965772600050041727261791F0000000000000000000000C200000
00200000001009E0101000200600000000000000000000000000000000500000000000000000
000000000000000000000000000000E021A005354424964656E7469747944696374696F6E617
27950726F7879000000007A000000000000009200000007000000446F6C7068696E920000001
20000004964656E7469747944696374696F6E617279C20000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000100000000000
0000000000006010E004E4F5449465949434F4E4441544100000000360009004279746541727
261795800000058000000C4041300010000000700000079C10000CD0315004E6F74696679204
D657373616765000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000F3820100460504000300000049636F6E0000000
000000000100000000E02110053544253696E676C65746F6E50726F7879000000007A0000000
0000000200100009200000018000000496D61676552656C617469766546696C654C6F6361746
F720E010E0053544253796D626F6C50726F787900000000920000000700000063757272656E7
4920000000D0000005368656C6C566965772E69636F0E021F0053544245787465726E616C526
5736F757263654C69627261727950726F7879000000009200000010000000646F6C7068696E6
4723030342E646C6C00000000920000000E0000004E6F74696679204D65737361676506010F0
04D65737361676553657175656E6365000000000E021200535442436F6C6C656374696F6E507
26F7879000000007A000000000000002001000092000000110000004F726465726564436F6C6
C656374696F6EC20000000200000006030B004D65737361676553656E6400000000FA0100000
0000000920000001000000063726561746541743A657874656E743AC20000000200000006020
500506F696E74000000000100000001000000320300000000000055050000010400006000000
0E202000000000000FA0100000000000092000000080000006D656E754261723AC2000000010
00000000000006000000006010F0057494E444F57504C4143454D454E5400000000720100002
C0000002C0000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000
000AA020000000200009A02000000000000B0020000400100003203000000000000C1000000C
10000000000000015000000460504000300000049636F6E0000000000000000100000000E021
10053544253696E676C65746F6E50726F7879000000004E020D0001000000535442436C61737
350726F78790000000036000600537472696E6707000000446F6C7068696E120100001800000
0496D61676552656C617469766546696C654C6F6361746F720E010E0053544253796D626F6C5
0726F787900000000120100000700000063757272656E74120100000D0000005368656C6C566
965772E69636F0E021F0053544245787465726E616C5265736F757263654C696272617279507
26F7879000000001201000010000000646F6C7068696E64723030342E646C6C00000000'))!