Hi smalltalkers.
Hi Blair. Dolphin use drawItemImage:on:at:disabled: to dispaly disabled menu item image, but this method cant't draw disable (gray) image with alpha-chanel correctly. I have developed package to support alpha-chanel image drawing. Just use drawDisabledOnHDC:at:extent: to draw nice disabled image. You can add this functionality in following patch (if you want certainly :-)). P.S. This works with CommCtrlLibrary >= 6.0. I can emulates that behaviour if comctl32 version 6 is not availble (If it is required). Best regards, vlad vinnikov. | package | package := Package name: 'MenuUtils'. package paxVersion: 1; basicComment: ''. package classNames add: #IMAGELISTDRAWPARAMS; yourself. package methodNames add: #CommCtrlLibrary -> #imageList_DrawIndirect:; add: #Icon -> #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! ! !Icon 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! ! !Icon 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"! |
Hi, smalltalkers.
I have got several letters from smalltalkers, which have a problems with use this package. So, i wrote a little manual. 1. Install package. 2. Find selector drawItemImage:on:at:disabled: in Menu class. 3. Replace method code with: | imageList extent imageIndex | extent := SystemMetrics current menuImageExtent. imageList := self imageManager imageListWithExtent: extent. imageIndex := self imageManager indexOfImage: itemImage. aBoolean ifFalse: [imageList draw: imageIndex on: hDC at: topLeft. ^self]. itemImage drawDisabledOnHDC: hDC at: topLeft @ 0 extent: extent 4. Open any smalltalk tool with disabled menu item and enjoy ;-). |
Free forum by Nabble | Edit this page |