Page 1 of 1

Re: ButtonGadgetEx - Images as Button

Posted: Fri Nov 25, 2011 10:57 pm
by IdeasVacuum
...wow, that looks really excellent, fabulous piece of work. Thanks for sharing. 8)

Re: ButtonGadgetEx - Images as Button

Posted: Sat Nov 26, 2011 1:32 pm
by infratec
Hi mevedia,

try this:

Code: Select all

Procedure GrayscaleCallback(x, y, SourceColor, TargetColor)
  Define Gray.i
  Gray = (Red(SourceColor) * 77 + Green(SourceColor) * 150 + Blue(SourceColor) * 29) >> 8
  ProcedureReturn RGBA(Gray, Gray, Gray, Alpha(SourceColor))
EndProcedure
You can not add the alpha to each colour.
It is an extra byte wich defines the transparancy for the complete pixel.

If you want it a bit faster, you can use

Code: Select all

ProcedureReturn Gray|Gray<<8|Gray<<16|Alpha(SourceColor)<<24
But I think this is not working on all plattforms.

Bernd

Re: ButtonGadgetEx - Images as Button

Posted: Sat Nov 26, 2011 4:39 pm
by Andre
...avoiding the GetSysColor_() WinAPI function it also works on MacOS. Thanks! :D

(Don't know if it works exactly like on Windows, as I don't have my PC running at the moment...)

Re: ButtonGadgetEx - Images as Button

Posted: Sat Nov 26, 2011 8:43 pm
by luis
It's nice code and another good example for the canvas gadget, thank you for sharing it :)

But what the "Toggle" button should do ? I saw it should toggle the gadget (_ex) status but I don't see anything happen when I press the button. Maybe I didn't understand it...

A side note about something you probably are already aware of: in a real program keep in mind you should trap the alt-tab in some way to navigate to the _ex buttons too, or a user would find strange not being able to do so.

Re: ButtonGadgetEx - Images as Button

Posted: Sun Nov 27, 2011 10:26 am
by Trond
When you press the mouse outside the button, then drag it inside and release, the button gets pressed. It should only get pressed when the click is both started and ended inside the gadget.