Detect whether system supports an alpha channel (via wxWidgets) - wxwidgets

I've got a wxWidgets program. For one piece of it, I want to use an alpha channel to "fade" a set of icons if the system supports alpha-blending, and grayscale them if it doesn't, but I can't seem to find any way to tell whether the system supports alpha-blending or not.
Is there something I'm missing, or is there no wxWidgets and/or cross-platform way to do this?
(I'm fairly well conversant with wxWidgets, but I've never done alpha-blending before.)

From what I can tell, you call CanSetTransparent on a top-level window, and if it returns true, call SetTransparent with a value < 255. If that returns true, then the system supports alpha transparency. You must do this after the top-level window you're working with is shown.
(CanSetTransparent just checks the OS version under Windows, always returns true under Mac OS, and checks both the compile-time GTK version and a function on wxGTK. SetTransparent takes different paths on Windows and GTK depending on whether the value is 255 or something less.)

Related

openWorldWithSpec making it impossible to return to previous windows

Reading the book "The Spec UI framework". Trying to implement the part described in chapter "Taking over the entire screen".
After executing the code suggested in the book:
WindowExample new openWorldWithSpec
it seems to be impossible to return to previous state. Tried to delete the new WorldMorph in the inspector. Also tried with halos, as the book suggests but those buttons that are available in the halo menu don't allow it to be closed.
Is it an intended behaviour for this (to be executed to prepare an end-user environment and disable programming UI) or am I missing something?
Working in Pharo 5.0, Mac OS X version.
That is indeed intended behaviour, as part of making applications that do not allow access to the development environment anymore. But you can take a look at the code for PharoLauncher to see how you can enable a developer mode
You can actually get back to normal by:
Alt-Ctrl-Clicking on the Morph (macOS combo may be different, this is for Windows).
Clicking on the little wrench and ask for inspect.
In the evaluation pane, do:
self delete
World menu is available again.
Open a browser.
Done.
If one disables halos in settings, this is a tad harder.

How to emulate mouse clicking/mouse moving/key typing in the global context?

Emulate means to invoke these events programatically.
Global context means that these event invocations should affect the whole desktop (sort of global environment) rather than the application which produces them. Moreover, the application itself should have no windows - it has to simply execute in background and produce these events due to some logic. In other words, if, for example, this application puts mouse in "global" arbitrary position and invokes a double click event and there is an icon of some other application under the cursor then this "other" application should start.
Which library can I use to achieve it?
Note: I don't specify OS since I hope that the library is supposed to do it in a cross-platform way. If that's not possible then I will be fine with the Windows only solution.
I found out that Java's java.awt.Robot has all requested features.

What programming languages have access to the WinAPI?

I'm looking to start a new programming language and for my first task I want to overlay some text on another applications window, similar to the guy in this post:
Overlay text on some else's window - HUD
Clearly from that post, this can be done in VB.NET, and extrapolating from that, I can probably safely assume that C++\C# can also do this similarly.
My question is; are there any other languages that can do the same? Can Ruby do it? :)
I'm looking for the following capabilities:
Enumerate open windows to find the one I want to overlay on top of.
Overlay text on the 3rd party apps window. (Rich text is a bonus)
Detect window bounds so I can resize the text when the user resizes the window.
Allow click-through of my created text so it doesn't interfere with the 3rd party apps functionality.
Any ideas?
If you want to use Ruby, you have two options: IronRuby and "classic Ruby".
I guess IronRuby would be the preferred option on Windows as it runs on top of .NET and has access to full Windows API through that.
If .NET is too much for your needs and you need to do something simple, then classic Ruby might be a better fit.
For classic Ruby, check out these pages:
Ruby and Microsoft Windows
Microsoft Windows Support
Beware: argument packing and unpacking is not very convenient.

Finding out if a Window is Resizable

Is there a way to determine whether the active window (not of my process, but a different application) is resizable?
Edit: I would prefer to do this without applescript as it then depends on the application being scriptable.
Use Accessibility. Once you find the window you want to examine, test whether it has the kAXGrowAreaAttribute attribute (the value for which would be the grow area itself, a.k.a. the “size box” or [the Windows term] “resize handle”). A window that has one is resizable; a window that doesn't have one is not resizable.
The user will need to have access for assistive devices turned on, but making that happen is easier than scripting unscriptable applications.
Edit from the year 2011: Lion killed off size boxes, so now you'll need to test whether the window's size attribute can be changed.
Yes, you can check if the "frontmost window" of the target application is resizable! You can perform the scripting request via applescript, scripting bridge or a third party framework!
However, in any case, it's needed that the target application is scriptable and you can access to the "resizable" property (of the "frontmost window" object) via a scripting request!
Depends on how you're getting access to the window. There's a property in AppleScript on Window objects, resizable, that indicates this.

how does f.lux work?

i am trying to figure out how this software works:
http://www.stereopsis.com/flux/
specifically, i would like to know how it changes the colors on your machine, and also was wondering if this would be possible to do in vb.net?
Most likely they play around with color management. Graphical operating systems allow for color calibration which changes the look of colors on a display. This is primarily used so the display has exactly the same color gamut as printers for design purposes or that the display has natural-looking colors. In this case it is used to adjust the color temperature programmatically.
In the FAQ they state "Currently, we don't recommend running f.lux on calibrated systems running Windows" which seems to reinforce the idea that they are messing with the color calibration (and are probably replacing the one you did previously).
Windows has support for this beginning with Vista and you probably can use this with VB.NET but not natively from .NET, meaning you will have to use the API directly. Here is an introduction about the Windows Color System on MSDN.
Note: Tried it out. Yes, they do mess with the color calibration. And they're pretty aggressive in that regard. Whenever I click "Reload current calibrations" in the color management panel to get my own calibration back (Windows 7 here) it gets reset by f.lux. It seems they are setting this about once a second. Now imagine there are two programs doing this :-)