XP PushButton ver. 1.0

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

XP PushButton ver. 1.0

app_voland
This is a Dolphin PushButton with Visual Styles on Windows XP, that can
display an image.
The idea to write this control inprised by "Images on XP-Style Buttons"
article on
http://www.codeproject.com/cs/miscctrl/MgXpImageButton.asp.

XPPushButton supports:
        image align: left, top, bottom, right, center;
        button state reflection: Normal, Hover, Pressed, Disabled, Focused;
        image margin;
        image extent;
        automatic disabled image creation.

| package |
package := Package name: 'MenuUtils'.
package paxVersion: 1;
        basicComment: ''.


package classNames
        add: #IMAGELISTDRAWPARAMS;
        yourself.

package methodNames
        add: #CommCtrlLibrary -> #imageList_DrawIndirect:;
        add: #Image -> #drawDisabledOnHDC:at:extent:;
        yourself.

package binaryGlobalNames: (Set new
        yourself).

package globalAliases: (Set new
        yourself).

package setPrerequisites: (IdentitySet new
        add: '..\Object Arts\Dolphin\Base\Dolphin';
        add: '..\Object Arts\Dolphin\MVP\Base\Dolphin MVP Base';
        yourself).

package!

"Class Definitions"!

Win32Structure subclass: #IMAGELISTDRAWPARAMS
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''!

"Global Aliases"!


"Loose Methods"!

!CommCtrlLibrary methodsFor!

imageList_DrawIndirect: anIMAGELISTDRAWPARAMS
        "Initialize the receiver as specified by the IMAGELISTDRAWPARAMS
struct argument."

        <stdcall: bool ImageList_DrawIndirect IMAGELISTDRAWPARAMS*>
        ^self invalidCall! !
!CommCtrlLibrary categoriesFor:
#imageList_DrawIndirect:!initializing!primitives!public! !

!Image methodsFor!

drawDisabledOnHDC: aHDC at: dstOrigin extent: dstExtent
        "Use ImageList_DrawIndirect to draw alpha-chanell disabled image
correct.
        N.B. This works with CommCtrlLibrary > 6.0"

        | aIMAGELISTDRAWPARAMS anImageList |
        anImageList :=WinImageList newExtent: dstExtent.
        anImageList addImage: self.
        aIMAGELISTDRAWPARAMS := IMAGELISTDRAWPARAMS new.
        aIMAGELISTDRAWPARAMS
                himl: anImageList handle;
                i:0;
                hdcDst: aHDC;
                x: dstOrigin x;
                y: dstOrigin y;
                cx: 0;
                cy: 0;
                xBitmap: 0;
                yBitmap: 0;
                fStyle: 1; "ILD_TRANSPARENT"
                fState: 4; "ILS_SATURATE"
                Frame: -100.

        ^CommCtrlLibrary default imageList_DrawIndirect: aIMAGELISTDRAWPARAMS!
!
!Image categoriesFor:
#drawDisabledOnHDC:at:extent:!drawing-gdiplus!public! !

"End of package definition"!

"Source Globals"!

"Classes"!

IMAGELISTDRAWPARAMS guid: (GUID fromString:
'{D53D5CC1-BFBE-44F7-B870-1E17EFF4775D}')!
IMAGELISTDRAWPARAMS comment: ''!
!IMAGELISTDRAWPARAMS categoriesForClass!External-Data-Structured-Win32!
!
!IMAGELISTDRAWPARAMS methodsFor!

crEffect: anObject
        "Set the receiver's crEffect field to the value of anObject."

        bytes dwordAtOffset: 64 put: anObject!

cx: anObject
        "Set the receiver's cx field to the value of anObject."

        bytes dwordAtOffset: 24 put: anObject!

cy: anObject
        "Set the receiver's cy field to the value of anObject."

        bytes dwordAtOffset: 28 put: anObject!

dwRop: anObject
        "Set the receiver's dwRop field to the value of anObject."

        bytes dwordAtOffset: 52 put: anObject!

dwSize: anObject
        "Set the receiver's dwSize field to the value of anObject."

        bytes dwordAtOffset: 0 put: anObject!

Frame: anObject
        "Set the receiver's Frame field to the value of anObject."

        bytes dwordAtOffset: 60 put: anObject!

fState: anObject
        "Set the receiver's fState field to the value of anObject."

        bytes dwordAtOffset: 56 put: anObject!

fStyle: anObject
        "Set the receiver's fStyle field to the value of anObject."

        bytes dwordAtOffset: 48 put: anObject!

hdcDst: anObject
        "Set the receiver's hdcDst field to the value of anObject."

        bytes dwordAtOffset: 12 put: anObject!

himl: anObject
        "Set the receiver's himl field to the value of anObject."

        bytes dwordAtOffset: 4 put: anObject!

i: anObject
        "Set the receiver's i field to the value of anObject."

        bytes dwordAtOffset: 8 put: anObject!

rgbBk: anObject
        "Set the receiver's rgbBk field to the value of anObject."

        bytes dwordAtOffset: 40 put: anObject!

rgbFg: anObject
        "Set the receiver's rgbFg field to the value of anObject."

        bytes dwordAtOffset: 44 put: anObject!

x: anObject
        "Set the receiver's x field to the value of anObject."

        bytes dwordAtOffset: 16 put: anObject!

xBitmap: anObject
        "Set the receiver's xBitmap field to the value of anObject."

        bytes dwordAtOffset: 32 put: anObject!

y: anObject
        "Set the receiver's y field to the value of anObject."

        bytes dwordAtOffset: 20 put: anObject!

yBitmap: anObject
        "Set the receiver's yBitmap field to the value of anObject."

        bytes dwordAtOffset: 36 put: anObject! !
!IMAGELISTDRAWPARAMS categoriesFor: #crEffect:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #cx:!**compiled accessors**!public!
!
!IMAGELISTDRAWPARAMS categoriesFor: #cy:!**compiled accessors**!public!
!
!IMAGELISTDRAWPARAMS categoriesFor: #dwRop:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #dwSize:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #Frame:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #fState:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #fStyle:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #hdcDst:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #himl:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #i:!**compiled accessors**!public!
!
!IMAGELISTDRAWPARAMS categoriesFor: #rgbBk:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #rgbFg:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #x:!**compiled accessors**!public!
!
!IMAGELISTDRAWPARAMS categoriesFor: #xBitmap:!**compiled
accessors**!public! !
!IMAGELISTDRAWPARAMS categoriesFor: #y:!**compiled accessors**!public!
!
!IMAGELISTDRAWPARAMS categoriesFor: #yBitmap:!**compiled
accessors**!public! !

!IMAGELISTDRAWPARAMS class methodsFor!

defineFields
        "Define the fields of the Win32 REBARDINFO structure.

                self compileDefinition

typedef struct {
    DWORD cbSize;
    HIMAGELIST himl;
    int i;
    HDC hdcDst;
    int x;
    int y;
    int cx;
    int cy;
    int xBitmap;
    int yBitmap;
    COLORREF rgbBk;
    COLORREF rgbFg;
    UINT fStyle;
    DWORD dwRop;
    DWORD fState;
    DWORD Frame;
    DWORD crEffect;
} IMAGELISTDRAWPARAMS"

        self
                defineField: #dwSize type: DWORDField writeOnly offset: 0;
                defineField: #himl type: HANDLEField writeOnly offset: 4;
                defineField: #i type: DWORDField writeOnly offset: 8;
                defineField: #hdcDst type: HANDLEField writeOnly offset: 12;
                defineField: #x type: DWORDField writeOnly offset: 16;
                defineField: #y type: DWORDField writeOnly offset: 20;
                defineField: #cx type: DWORDField writeOnly offset: 24;
                defineField: #cy type: DWORDField writeOnly offset: 28;
                defineField: #xBitmap type: DWORDField writeOnly offset: 32;
                defineField: #yBitmap type: DWORDField writeOnly offset: 36;
                defineField: #rgbBk type: DWORDField writeOnly offset: 40;
                defineField: #rgbFg type: DWORDField writeOnly offset: 44;
                defineField: #fStyle type: DWORDField writeOnly offset: 48;
                defineField: #dwRop type: DWORDField writeOnly offset: 52;
                defineField: #fState  type: DWORDField writeOnly offset: 56;
                defineField: #Frame  type: DWORDField writeOnly offset: 60;
                defineField: #crEffect  type: DWORDField writeOnly offset: 64.
        self byteSize: 68.! !
!IMAGELISTDRAWPARAMS class categoriesFor: #defineFields!public! !

"Binary Globals"!



| package |
package := Package name: 'XPPushButton'.
package paxVersion: 1;
        basicComment: 'XP PushButton ver. 1.0
25/08/06

=======================================
This is a Dolphin PushButton with Visual Styles on Windows XP, that can
display an image.
The idea to write this control inprised by "Images on XP-Style Buttons"
article on
http://www.codeproject.com/cs/miscctrl/MgXpImageButton.asp.

XPPushButton supports:
        image align: left, top, bottom, right, center;
        button state reflection: Normal, Hover, Pressed, Disabled, Focused;
        image margin;
        image extent;
        automatic disabled image creation.

For example evaluate:

        XPButtonSampleShell show.

'.


package classNames
        add: #BUTTON_IMAGELIST;
        add: #PersistentWinImageList;
        add: #XPButtonSampleShell;
        add: #XPPushButton;
        yourself.

package globalNames
        add: #XPPushButtonConstants;
        yourself.

package binaryGlobalNames: (Set new
        yourself).

package globalAliases: (Set new
        yourself).

package setPrerequisites: (IdentitySet new
        add: '..\Object Arts\Dolphin\IDE\Base\Development System';
        add: '..\Object Arts\Dolphin\Base\Dolphin';
        add: '..\Object Arts\Dolphin\MVP\Base\Dolphin MVP Base';
        add: '..\Object Arts\Dolphin\MVP\Gdiplus\Gdiplus';
        add: 'MenuUtils';
        yourself).

package!

"Class Definitions"!

Win32Structure subclass: #BUTTON_IMAGELIST
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''!
WinImageList subclass: #PersistentWinImageList
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''!
Shell subclass: #XPButtonSampleShell
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''!
PushButton subclass: #XPPushButton
        instanceVariableNames: 'stateImageList imageAlign hoverImage
pressedImage disabledImage focusedImage imageMargin imageExtent'
        classVariableNames: ''
        poolDictionaries: 'XPPushButtonConstants'
        classInstanceVariableNames: ''!

"Global Aliases"!


"Loose Methods"!

"End of package definition"!

"Source Globals"!

Smalltalk at: #XPPushButtonConstants put: (PoolConstantsDictionary
named: #XPPushButtonConstants)!
XPPushButtonConstants at: 'BCM_SETIMAGELIST' put: 16r1602!
XPPushButtonConstants shrink!

"Classes"!

BUTTON_IMAGELIST guid: (GUID fromString:
'{2B1802FD-7DE9-405C-8DA1-FF495C4BB87B}')!
BUTTON_IMAGELIST comment: ''!
!BUTTON_IMAGELIST categoriesForClass!External-Data-Structured-Win32! !
!BUTTON_IMAGELIST methodsFor!

himl: anObject
        "Set the receiver's himl field to the value of anObject."

        bytes dwordAtOffset: 0 put: anObject!

margin
        "Answer the receiver's margin field as a Smalltalk object."

        ^RECT fromAddress: (bytes yourAddress + 4)!

margin: anObject
        "Set the receiver's margin field to the value of anObject."

        anObject replaceBytesOf: bytes from: 5 to: 20 startingAt: 1!

uAlign
        "Answer the receiver's uAlign field as a Smalltalk object."

        ^(bytes dwordAtOffset: 20)!

uAlign: anObject
        "Set the receiver's uAlign field to the value of anObject."

        bytes dwordAtOffset: 20 put: anObject! !
!BUTTON_IMAGELIST categoriesFor: #himl:!**compiled accessors**!public!
!
!BUTTON_IMAGELIST categoriesFor: #margin!**compiled accessors**!public!
!
!BUTTON_IMAGELIST categoriesFor: #margin:!**compiled
accessors**!public! !
!BUTTON_IMAGELIST categoriesFor: #uAlign!**compiled accessors**!public!
!
!BUTTON_IMAGELIST categoriesFor: #uAlign:!**compiled
accessors**!public! !

!BUTTON_IMAGELIST class methodsFor!

defineFields
        "Define the fields of the structure.

        self  compileDefinition

        typedef struct {
                HIMAGELIST himl;
                RECT margin;
                UINT uAlign;
        } BUTTON_IMAGELIST, *PBUTTON_IMAGELIST;
"
        self
                defineField: #himl type: HANDLEField writeOnly;
                defineField: #margin type: (StructureField type: RECT);
                defineField: #uAlign type: (DWORDField new).
        ! !
!BUTTON_IMAGELIST class categoriesFor: #defineFields!public! !

PersistentWinImageList guid: (GUID fromString:
'{1D18EAAC-4C06-4FD3-AC1B-EB4D784AA577}')!
PersistentWinImageList comment: ''!
!PersistentWinImageList categoriesForClass!Graphics-Tools! !
!PersistentWinImageList methodsFor!

drawDisabled: anInteger on: aCanvas at: aPoint
        "Use ImageList_DrawIndirect to draw alpha-chanell disabled image
correct.
        N.B. This works with CommCtrlLibrary > 6.0"

        | aIMAGELISTDRAWPARAMS |
        aIMAGELISTDRAWPARAMS := IMAGELISTDRAWPARAMS new.
        aIMAGELISTDRAWPARAMS
                himl: self asParameter;
                i: anInteger - 1 ;
                hdcDst: aCanvas asParameter;
                x: aPoint x;
                y: aPoint y;
                cx: 0;
                cy: 0;
                xBitmap: 0;
                yBitmap: 0;
                fStyle: 1; "ILD_TRANSPARENT"
                fState: 4; "ILS_SATURATE"
                Frame: -100.

        ^CommCtrlLibrary default imageList_DrawIndirect: aIMAGELISTDRAWPARAMS!

isPersistent
        ^true! !
!PersistentWinImageList categoriesFor: #drawDisabled:on:at:!public! !
!PersistentWinImageList categoriesFor: #isPersistent!public! !

XPButtonSampleShell guid: (GUID fromString:
'{ECB47E75-BA2E-4513-8C83-490F0C785379}')!
XPButtonSampleShell comment: ''!
!XPButtonSampleShell categoriesForClass!MVP-Presenters! !
!XPButtonSampleShell methodsFor!

enableDisable
        ^Error notYetImplemented!

focusButtonClick
        MessageBox notify: 'I am in focus!!' !

noCommand
        !

queryCommand: aCommandQuery
        | cmd |
        cmd := aCommandQuery commandSymbol.
        cmd == #enableDisable
                ifTrue:
                        [aCommandQuery isEnabled: false.
                        ^true].
        aCommandQuery beEnabled.
        ^super queryCommand: aCommandQuery!

someCommand
        MessageBox notify: 'Hello from aligning button!!' ! !
!XPButtonSampleShell categoriesFor: #enableDisable!public! !
!XPButtonSampleShell categoriesFor: #focusButtonClick!public! !
!XPButtonSampleShell categoriesFor: #noCommand!public! !
!XPButtonSampleShell categoriesFor: #queryCommand:!public! !
!XPButtonSampleShell categoriesFor: #someCommand!public! !

!XPButtonSampleShell class methodsFor!

resource_Default_view
        "Answer the literal data from which the 'Default view' resource can be
reconstituted.
        DO NOT EDIT OR RECATEGORIZE THIS METHOD.

        If you wish to modify this resource evaluate:
        ViewComposer openOn: (ResourceIdentifier class: self selector:
#resource_Default_view)
        "

        ^#(#'!!STL' 3 788558 10 ##(Smalltalk.STBViewProxy)  8
##(Smalltalk.ShellView)  98 27 0 0 98 2 27131905 131073 416 0 721158
##(Smalltalk.SystemColor)  31 0 551 0 0 0 416 0 234 256 98 0 0 0 0 0 0
1 0 0 328198 ##(Smalltalk.Point)  1011 611 0 1 0 0 983302
##(Smalltalk.MessageSequence)  202 208 98 3 721670
##(Smalltalk.MessageSend)  8 #createAt:extent: 98 2 546 2047 21 546
1011 611 416 642 8 #text: 98 1 8 'XPPushButton Sample Demo' 416 642 8
#updateMenuBar 528 416 983302 ##(Smalltalk.WINDOWPLACEMENT)  8 #[44 0 0
0 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 3 0 0 10 0 0 0 248 5 0 0 59 1 0 0] 98 12 410 8
##(Smalltalk.XPPushButton)  98 25 0 416 98 2 8 1140924416 1 896 0
524550 ##(Smalltalk.ColorRef)  8 4278190080 0 7 0 0 0 896 0 8
4294906945 1180998 4 ##(Smalltalk.CommandDescription)  8 #someCommand 8
'Right align' 1 1 0 263494 3 ##(Smalltalk.Icon)  0 16 1114638
##(Smalltalk.STBSingletonProxy)  8
##(Smalltalk.ImageRelativeFileLocator)  8 #current 8 'FileSave.ico' 0
32 1443334 ##(Smalltalk.PersistentWinImageList)  0 16 546 33 33 3 65 67
3 0 0 0 0 590342 ##(Smalltalk.Rectangle)  546 5 5 546 1 1 1248 578 202
208 98 3 642 672 98 2 546 411 187 546 161 71 896 642 8 #isEnabled: 98 1
32 896 642 752 98 1 8 'Right align' 896 834 8 #[44 0 0 0 0 0 0 0 1 0 0
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 205 0
0 0 93 0 0 0 29 1 0 0 128 0 0 0] 98 0 546 193 193 0 27 410 912 98 25 0
416 98 2 8 1140924416 1 1600 0 978 1008 0 7 0 0 0 1600 0 8 4294906945
1042 1072 0 1 1 0 1106 0 16 1152 8 'FileSave.ico' 0 32 1218 0 16 546 65
65 3 65 67 9 0 0 0 0 1266 546 5 5 546 1 1 1760 578 202 208 98 2 642 672
98 2 546 321 181 546 81 81 1600 642 1456 98 1 32 1600 834 8 #[44 0 0 0
0 0 0 0 1 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 160 0 0 0 90 0 0 0 200 0 0 0 130 0 0 0] 98 0 1584 0 27 410 912
98 25 0 416 98 2 8 1140924416 1 2016 0 978 1008 0 7 0 0 0 2016 0 8
4294906945 1042 1072 8 'Left align' 1 1 0 1106 0 16 1152 1200 0 32 1218
0 16 546 33 33 3 65 67 1 0 0 0 0 1266 546 5 5 546 1 1 2176 578 202 208
98 3 642 672 98 2 546 151 187 546 161 71 2016 642 1456 98 1 32 2016 642
752 98 1 8 'Left align' 2016 834 8 #[44 0 0 0 0 0 0 0 1 0 0 0 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 75 0 0 0 93 0 0
0 155 0 0 0 128 0 0 0] 98 0 1584 0 27 410 912 98 25 0 416 98 2 8
1140924416 1 2480 0 978 1008 0 7 0 0 0 2480 0 8 4294906945 1042 1072 8
'Top align' 1 1 0 1106 0 16 1152 1200 0 32 1218 0 16 546 33 33 3 65 67
5 0 0 0 0 1266 546 5 5 546 1 1 2640 578 202 208 98 3 642 672 98 2 546
291 101 546 141 71 2480 642 1456 98 1 32 2480 642 752 98 1 8 'Top
align' 2480 834 8 #[44 0 0 0 0 0 0 0 1 0 0 0 255 255 255 255 255 255
255 255 255 255 255 255 255 255 255 255 145 0 0 0 50 0 0 0 215 0 0 0 85
0 0 0] 98 0 1584 0 27 410 912 98 25 0 416 98 2 8 1140924416 1 2944 0
978 1008 0 7 0 0 0 2944 0 8 4294906945 1042 1072 8 'Bottom align' 1 1 0
1106 0 16 1152 1200 0 32 1218 0 16 546 33 33 3 65 67 7 0 0 0 0 1266 546
5 5 546 1 1 3104 578 202 208 98 3 642 672 98 2 546 291 271 546 141 71
2944 642 1456 98 1 32 2944 642 752 98 1 8 'Bottom align' 2944 834 8
#[44 0 0 0 0 0 0 0 1 0 0 0 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 145 0 0 0 135 0 0 0 215 0 0 0 170 0 0 0] 98 0 1584
0 27 410 912 98 25 0 416 98 2 8 1140924416 1 3408 0 978 8 4278190080 0
7 0 0 0 3408 0 8 4294906945 1042 8 #noCommand 8 'Hover button' 1 1 0
1106 0 16 1152 8 'View.ico' 0 32 1218 0 16 546 33 33 3 65 67 1 1106 0
16 1152 8 'Model.ico' 0 0 0 0 1266 546 5 5 546 1 1 3616 578 202 208 98
3 642 672 98 2 546 731 91 546 201 71 3408 642 1456 98 1 32 3408 642 752
98 1 8 'Hover button' 3408 834 8 #[44 0 0 0 0 0 0 0 1 0 0 0 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 109 1 0 0 45 0 0 0
209 1 0 0 80 0 0 0] 98 0 1584 0 27 410 912 98 25 0 416 98 2 8
1140924416 1 3952 0 978 3488 0 7 0 0 0 3952 0 8 4294906945 1042 8
#enableDisable 8 'Disbled button' 1 1 0 1106 0 16 1152 8 'View.ico' 0
32 1218 0 16 546 33 33 3 65 67 1 0 0 0 0 1266 546 5 5 546 1 1 4144 578
202 208 98 3 642 672 98 2 546 731 191 546 201 71 3952 642 1456 98 1 32
3952 642 752 98 1 8 'Disbled button' 3952 834 8 #[44 0 0 0 0 0 0 0 1 0
0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 109
1 0 0 95 0 0 0 209 1 0 0 130 0 0 0] 98 0 1584 0 27 410 912 98 25 0 416
98 2 8 1140924416 1 4448 0 978 3488 0 7 0 0 0 4448 0 8 4294906945 1042
8 #focusButtonClick 8 'Focus button' 1 1 0 1106 0 16 1152 4112 0 32
1218 0 16 546 33 33 3 65 67 1 0 0 0 1106 0 16 1152 8 'Presenter.ico' 0
1266 546 5 5 546 1 1 4624 578 202 208 98 3 642 672 98 2 546 731 291 546
201 71 4448 642 1456 98 1 32 4448 642 752 98 1 8 'Focus button' 4448
834 8 #[44 0 0 0 0 0 0 0 1 0 0 0 255 255 255 255 255 255 255 255 255
255 255 255 255 255 255 255 109 1 0 0 145 0 0 0 209 1 0 0 180 0 0 0] 98
0 1584 0 27 410 912 98 25 0 416 98 2 8 1140924416 1 4960 0 978 3488 0 7
0 0 0 4960 0 8 4294906945 1042 3536 8 '16x16 Icon  button' 1 1 0 1106 0
16 1152 4112 0 32 1218 0 16 546 33 33 3 65 67 1 0 0 0 0 1266 546 5 5
546 1 1 5120 578 202 208 98 3 642 672 98 2 546 33 441 546 201 81 4960
642 1456 98 1 32 4960 642 752 98 1 8 '16x16 Icon  button' 4960 834 8
#[44 0 0 0 0 0 0 0 1 0 0 0 255 255 255 255 255 255 255 255 255 255 255
255 255 255 255 255 16 0 0 0 220 0 0 0 116 0 0 0 4 1 0 0] 98 0 1584 0
27 410 912 98 25 0 416 98 2 8 1140924416 1 5424 0 978 3488 0 7 0 0 0
5424 0 8 4294906945 1042 3536 8 '32x32 Icon  button' 1 1 0 1106 0 16
1152 4112 0 32 1218 0 16 546 65 65 3 65 67 1 0 0 0 0 1266 546 5 5 546 1
1 5584 578 202 208 98 3 642 672 98 2 546 263 441 546 201 81 5424 642
1456 98 1 32 5424 642 752 98 1 8 '32x32 Icon  button' 5424 834 8 #[44 0
0 0 0 0 0 0 1 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255
255 255 255 131 0 0 0 220 0 0 0 231 0 0 0 4 1 0 0] 98 0 1584 0 27 410
912 98 25 0 416 98 2 8 1140924418 1 5888 0 978 3488 0 7 0 0 0 5888 0 8
4294906945 1042 3536 8 'Check box' 1 1 0 1106 0 16 1152 4112 0 32 1218
0 16 546 33 33 3 65 67 1 0 0 0 0 1266 546 1 1 546 21 5 6048 578 202 208
98 3 642 672 98 2 546 503 441 546 191 81 5888 642 1456 98 1 32 5888 642
752 98 1 8 'Check box' 5888 834 8 #[44 0 0 0 0 0 0 0 1 0 0 0 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 255 251 0 0 0 220 0
0 0 90 1 0 0 4 1 0 0] 98 0 1584 0 27 410 912 98 25 0 416 98 2 8
1140924418 1 6352 0 978 3488 0 7 0 0 0 6352 0 8 4294906945 1042 3536 8
'Hover check box' 1 1 0 1106 0 16 1152 3584 0 32 1218 0 16 546 33 33 3
65 67 1 1106 0 16 1152 3648 0 0 0 0 1266 546 1 1 546 21 5 6512 578 202
208 98 3 642 672 98 2 546 731 441 546 261 71 6352 642 1456 98 1 32 6352
642 752 98 1 8 'Hover check box' 6352 834 8 #[44 0 0 0 0 0 0 0 1 0 0 0
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 109 1 0
0 220 0 0 0 239 1 0 0 255 0 0 0] 98 0 1584 0 27 1584 0 27 )! !
!XPButtonSampleShell class categoriesFor:
#resource_Default_view!public!resources-views! !

XPPushButton guid: (GUID fromString:
'{32606982-83B9-4AD9-8314-4223E09E8374}')!
XPPushButton comment: 'PushButton is a <CommandButton> implementing the
Windows "BUTTON" class in push button mode, i.e. with the BS_PUSHLIKE
style
with Visual Styles support on Windows XP, that can display an image.

Instance Variables:
        stateImageList <PersistentWinImageList>
        imageAlign <SmallInteger>
        hoverImage <IconOrBitmapOrNil>
        pressedImage <IconOrBitmapOrNil>
        disabledImage <IconOrBitmapOrNil>
        focusedImage <IconOrBitmapOrNil>
        imageMargin <Rectangle>
        imageExtent <Point>

'!
!XPPushButton categoriesForClass!MVP-Views! !
!XPPushButton methodsFor!

btmSetImageList
        | aBUTTON_IMAGELIST |
        image ifNil: [^self].
        aBUTTON_IMAGELIST := (BUTTON_IMAGELIST new)
                                margin: self imageMargin asParameter;
                                uAlign: self imageAlign;
                                himl: self stateImageList asParameter.
        self
                sendMessage: BCM_SETIMAGELIST
                wParam: 0
                lpParam: aBUTTON_IMAGELIST asParameter.
        self invalidate!

disabledImage
        ^disabledImage!

disabledImage: anImageOrNil
        disabledImage := anImageOrNil.
        self rebuildImageList.
        self btmSetImageList!

focusedImage
        ^focusedImage!

focusedImage: anImageOrNil
        focusedImage := anImageOrNil.
        self rebuildImageList.
        self btmSetImageList!

getDisabledImage
        | bmp |
        bmp := Bitmap displayCompatibleWithExtent:self imageExtent.
        (bmp canvas)
                backcolor: (ARGB stdColor: #transparent);
                erase.
        "self stateImageList
                drawDisabled: 1
                on: bmp canvas
                at: 0 @ 0." #todo "Why this does'nt work?".
        image drawDisabledOnHDC: bmp canvas asParameter at: 0@0 extent: bmp
extent.
        ^bmp!

hoverImage
        ^hoverImage!

hoverImage: anImageOrNil
        hoverImage := anImageOrNil.
        self rebuildImageList.
        self btmSetImageList!

image: anImageOrNil
        image := anImageOrNil.
        self rebuildImageList.
        self btmSetImageList!

imageAlign
        imageAlign ifNil: [imageAlign := 0].
        ^imageAlign!

imageAlign: anInteger
        imageAlign := anInteger.
        self btmSetImageList!

imageExtent
        imageExtent ifNil: [imageExtent := 16@16].
        ^imageExtent!

imageExtent: aPoint
        imageExtent := aPoint.
        self rebuildImageList.
        self btmSetImageList!

imageMargin
        imageMargin
                ifNil:
                        [imageMargin := Rectangle
                                                left: 2
                                                top: 2
                                                right: 0
                                                bottom: 0].
        ^imageMargin!

imageMargin: aRectangle
        imageMargin := aRectangle.
        self btmSetImageList.!

pressedImage
        ^pressedImage!

pressedImage: anImageOrNil
        pressedImage := anImageOrNil.
        self rebuildImageList.
        self btmSetImageList!

rebuildImageList
        image ifNil: [^self].
        stateImageList := PersistentWinImageList newExtent: self imageExtent
masked: true.
        stateImageList addImage: image.
        stateImageList addImage: (hoverImage isNil ifFalse: [hoverImage]
ifTrue: [image]).
        stateImageList addImage: (pressedImage isNil ifFalse: [pressedImage]
ifTrue: [image]).
        stateImageList
                addImage: (disabledImage isNil ifFalse: [disabledImage] ifTrue: [self
getDisabledImage]).
        stateImageList addImage: (focusedImage isNil ifFalse: [focusedImage]
ifTrue: [image])!

stateImageList
        ^stateImageList! !
!XPPushButton categoriesFor: #btmSetImageList!accessing!private! !
!XPPushButton categoriesFor: #disabledImage!accessing!public! !
!XPPushButton categoriesFor: #disabledImage:!accessing!public! !
!XPPushButton categoriesFor: #focusedImage!accessing!public! !
!XPPushButton categoriesFor: #focusedImage:!accessing!public! !
!XPPushButton categoriesFor: #getDisabledImage!private! !
!XPPushButton categoriesFor: #hoverImage!accessing!public! !
!XPPushButton categoriesFor: #hoverImage:!accessing!public! !
!XPPushButton categoriesFor: #image:!accessing!public! !
!XPPushButton categoriesFor: #imageAlign!accessing!public! !
!XPPushButton categoriesFor: #imageAlign:!accessing!public! !
!XPPushButton categoriesFor: #imageExtent!accessing!public! !
!XPPushButton categoriesFor: #imageExtent:!accessing!public! !
!XPPushButton categoriesFor: #imageMargin!accessing!public! !
!XPPushButton categoriesFor: #imageMargin:!accessing!public! !
!XPPushButton categoriesFor: #pressedImage!accessing!public! !
!XPPushButton categoriesFor: #pressedImage:!accessing!public! !
!XPPushButton categoriesFor: #rebuildImageList!private! !
!XPPushButton categoriesFor: #stateImageList!private! !

!XPPushButton class methodsFor!

imageAligns
        ^(LookupTable new)
                at: #left put: 0;
                at: #right put: 1;
                at: #top put: 2;
                at: #bottom put: 3;
                at: #center put: 4;
                yourself!

publishedAspectsOfInstances
        "Answer a <LookupTable> of the <Aspect>s published by instances of the
receiver."

        | answer |
        answer := super publishedAspectsOfInstances.
        ^answer
                add: (Aspect
                                        choice: #imageAlign
                                        fromMap: self imageAligns
                                        nullValue: nil);
                add: (Aspect icon: #pressedImage);
                add: (Aspect icon: #disabledImage);
                add: (Aspect icon: #hoverImage);
                add: (Aspect icon: #focusedImage);
                add: (Aspect name: #imageMargin);
                add: (Aspect name: #imageExtent);
                yourself!

resource_Push_button
        "Answer the literal data from which the 'Push button' resource can be
reconstituted.
        DO NOT EDIT OR RECATEGORIZE THIS METHOD.

        If you wish to modify this resource evaluate:
        ViewComposer openOn: (ResourceIdentifier class: self selector:
#resource_Push_button)
        "

        ^#(#'!!STL' 3 788558 10 ##(Smalltalk.STBViewProxy)  8
##(Smalltalk.XPPushButton)  98 25 0 0 98 2 8 1140924416 1 416 0 524550
##(Smalltalk.ColorRef)  8 4278190080 0 5 0 0 0 416 0 8 4294904855
1180998 4 ##(Smalltalk.CommandDescription)  8 #noCommand 0 1 1 0 0 32 0
0 0 0 0 0 0 0 983302 ##(Smalltalk.MessageSequence)  202 208 98 1 721670
##(Smalltalk.MessageSend)  8 #createAt:extent: 98 2 328198
##(Smalltalk.Point)  1 1 738 201 71 416 983302
##(Smalltalk.WINDOWPLACEMENT)  8 #[44 0 0 0 0 0 0 0 0 0 0 0 255 255 255
255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 100
0 0 0 35 0 0 0] 98 0 738 193 193 0 27 )! !
!XPPushButton class categoriesFor: #imageAligns!public! !
!XPPushButton class categoriesFor: #publishedAspectsOfInstances!public!
!
!XPPushButton class categoriesFor:
#resource_Push_button!public!resources-views! !

"Binary Globals"!