PR# 18292 Vision2 does not report background color correctly in Wndows 7

Problem Report Summary
Submitter: finnianr
Category: EiffelVision
Priority: Low
Date: 2012/08/06
Class: Bug
Severity: Non-critical
Number: 18292
Release: 7.0.8.7451
Confidential: No
Status: Analyzed
Responsible:
Environment: Windows 7
Synopsis: Vision2 does not report background color correctly in Wndows 7

Description
If you look at the attached image you can see a right arrow button. I have set the background color of the pixmap to be the same as that reported by background_color on EV_NOTEBOOK. The actual notebook color is a shade of white but the reported color is a shade of gray. Using the background color of EV_HORIZONTAL_BOX produces the same result.

To Reproduce

										
Problem Report Interactions
From:finnianr    Date:2012/08/08    Download   
I opened the XP image in GIMP and used the color picker to check because I have trouble seeing the gradient, perhaps because of the lighting conditions in my office. And sure enough the top and bottom are different colors.

It seems the only way to query style colors is through .Net which I would rather not get into as it means distributing the .Net framework. I think the best solution for me is to over ride EV_WIDGET_IMP and add a function actual_background_color and use GetPixel to test for the top left pixel. (And whatever the equivalent is in GTK) I can then query the horizontal button box container using a "once on idle" agent to set the button image background.

Thanks for the tip about EV_PIXEL_BUFFER. I think I did try using it before but had some trouble with it. Can't remember exactly what. At the moment I use EV_PIXMAP.set_with_named_file. I am not sure if there is any advantage to use JPEG.


From:manus_eiffel    Date:2012/08/07    Download   
I think that the following picture should clarify things better:

http://www.betaarchive.co.uk/imageupload/1261105951.or.536400.png

I'm really talking about the tab content which has a slight gradient. It certainly seems that in Windows 7 default theme, it has only one color, but in Windows XP, it is a set of colors due to the gradient. Which means that in the future, other theme might appear with various possibilities for the background color.

As for PNG, make sure to load them via an EV_PIXEL_BUFFER which is better at handling images (it can load JPEG for example) and use an EV_DRAWING_AREA to draw them.

From:finnianr    Date:2012/08/07    Download   
Hi Manu,
I think we are using the word tab to refer to different things. Since you are talking about an area with a color gradient I assume you are refering to the narrow band at the top which carries the tab labels. I am using "tab" in a more general sense to include the tab body which is a container cell for components.

Normally I am used to seeing horizontal or vertical boxes as being a gray color. But in a themed Windows 7 if I add them to a tab they are no longer gray but white. The question is where is this white color coming from. It seems to be propagating from the parent container which is the tab. If you look in the aero theme style sheet you can see that the colors correspond to various shades of white and off white. I don't see anything that looks like a gradient.

I am not rendering the SVG directly to screen, but to disk first as a png. This is then applied to a normal button using set_pixmap. This button is added to a horizontal box which in turn is added to the tab. 

If I make it tran
....
Output truncated, Click download to get the full message

From:manus_eiffel    Date:2012/08/07    Download   
I think there is still something I'm not successful at conveying. The background color of a notebook tab doesn't exist because it is usually a gradient color going from gray to light gray. So depending on where you draw your SVG it will blend or  won't blend, since you actually need to get the color at the exact pixel where you want to draw the SVG image. 

Why not converting the SVG image to a transparent PNG and then let vision2 draw it  for you? I believe this should work out of the box.

From:finnianr    Date:2012/08/07    Download   
> I'm wondering why you are trying to get that color. 
This is best explained with reference to the attached screen segment. The blue arrow button is a square SVG rendering. The rendering requires that I specify a background color and this needs to be the same as the tab background if it is to look like a triangular button (which is what I want) and not a triangle on a gray square (or some other color). If the background color is determined by a style sheet then it should be possible to query it.

> I think that the best thing to do is to always assume that containers are 
> transparent and whatever background color is visible is just what is underneath
> but it is not the real background color of the container.
My researches have lead me to believe otherwise. The following file (part of the Win7 SDK) is the Aero style sheet.
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\AeroStyle.xml
If you look in this file you can find a section <class name="TabStyle"> with various sub sections, as for examp
....
Output truncated, Click download to get the full message

Attachment: Window-corner.png     Size:25076
From:manus_eiffel    Date:2012/08/07    Status: Analyzed    Download   
I'm not too surprised by your discovery. When themes are enabled, there is simply not just one background color, but many (since it is a gradient).

I'm wondering why you are trying to get that color. I think that the best thing to do is to always assume that containers are transparent and whatever background color is visible is just what is underneath but it is not the real background color of the container.

As far as I know, GTK with theme, will probably have a similar problem where you cannot get the exact background color.

We spend a lot of time to ensure that Vision2 applications will follow the theme chosen by the user at the OS level. So changing colors of containers/widgets might not be the best thing to do on a UI level, but this is up to you to decide.

From:finnianr    Date:2012/08/07    Download   
My solution won't work with the Windows 7 basic theme because it allows the user to change the Window system color.
It really seems that the tab control is a rogue color which doesn't conform to any system color.

From:finnianr    Date:2012/08/07    Download   
It seems I am not the only programmer wondering which system color the tab control is supposed to match.
http://forums.ni.com/t5/LabVIEW/Dialog-color-that-matches-tab-in-the-XP-theme-too/td-p/122525

I found this comprehensive Windows System Colors Reference 
http://www.quppa.net/syscol/
It shows graphically what each system color looks like across every Windows flavor and theme. It looks like the Window system color is the closest match to the tab control color across Win 7 themes. 

I have made my own version of EV_STOCK_COLORS overriding default_background_color returning the Window system color for Win 7 themes and the precursor for XP or the Classic theme.

From:finnianr    Date:2012/08/06    Download   
The notebook colors are a sidetrack from the real issue which is that the color values returned from class {EV_STOCK_COLORS} are inconsistent across platforms. With GTK if I set my button background using {EV_STOCK_COLORS}.color_dialog it gives me what I want. I can check that this is not just a coincidence by changing the dialog color in the desktop preferences.

The problem with Windows is that most Win 7 themes (with the exception of Classic), tabs and tab containers do not correspond to the dialog color. (Some how it is propagating even though I did't call propagate_background_color) I don't know where else Windows 7 applies this notebook tab color. If it does appear elsewhere perhaps it can be considered as the default background color in which case {EV_STOCK_COLORS}.default_background_color should be amended. If not I would suggest introducing a new stock color: {EV_STOCK_COLORS}.color_tab_background.

It is only because the stock colors are inconsistent that I was looking for workarounds by queryin
....
Output truncated, Click download to get the full message

From:manus_eiffel    Date:2012/08/06    Download   
By default, when you enable the windows theme, a notebook has really not just one background color, but many (this is a gradiant fill of the background). What we give back is the default color it would have if the theme was disabled. However, once the user set a color, we respect that color and you will get back that color.

At this point, we do not see any other way but to leave things as they are. Unless you have an alternate proposal.

From:finnianr    Date:2012/08/06    Download   
Theme selected is Windows 7 Basic

From:finnianr    Date:2012/08/06    Download   
Attachments for problem report #18292

Attachment: Window-corner.png     Size:4339