Wednesday, May 23rd 2018, 8:42am UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

mastupristi

Beginner

Date of registration: Feb 18th 2016

Posts: 40

1

Tuesday, February 13th 2018, 11:39am

PROGBAR doesn't change colors

I use emWin provided by ST (STemWin based on emWin 5.40)

I tried to change PROGBAR colors but nothing happens.

I downloaded emWin tutorial (both executables and source code). Also the WIDGET_Progbar sample doesn't change the colors:



In the source code there is:

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
  while(1) {
	PROGBAR_SetFont(ahProgBar[0], &GUI_Font8x16);
	if (LCD_GetDevCap(LCD_DEVCAP_BITSPERPIXEL) <= 4) {
  	PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY);
  	PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY);
	} else {
  	PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN);
  	PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED);
	}
	PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_HCENTER);
	PROGBAR_SetText(ahProgBar[0], NULL);


So is it possible to change the colors of the PROGBAR? how?

best regards
Max

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 584

2

Wednesday, February 14th 2018, 3:41pm

Hi,

For some widgets it is not possible to change the color with functions like <WIDGET>_SetColor() because they use a skinning routine to draw themself (e.g. the PROGBAR widget).

To change the colors to be used you can set the properties (like the colors) for the widget with the function <WIDGET>_SetSkinFlexProps() (or in this case PROGBAR_SetSkinFlexProps()).

Best way is to read the properties and write them back. This allows you to change only one property and leave the other unchanged.

Another way to change the look of the widgets is to overwrite their callback function or set a skinning/owner-draw function (if available).
This will give you more control over the look of the widgets.

Regards
Sven