![]() |
Source code |
1 2 |
void SWIPELIST_SetBkColor(SWIPELIST_Handle hObj, unsigned Index, GUI_COLOR Color); |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
void ews_setCustomSyle( void ) { ... WM_SetDesktopColor(EWS_RGB2EMWIN(EWS_WINBKG_DFT_COLOR)); WINDOW_SetDefaultBkColor(EWS_RGB2EMWIN(EWS_WINBKG_DFT_COLOR)); FRAMEWIN_SetDefaultClientColor(EWS_RGB2EMWIN(EWS_WINBKG_DFT_COLOR)); ... // Swipelist SWIPELIST_SetDefaultBkColor(SWIPELIST_CI_BK_ITEM_SEL, EWS_RGB2EMWIN(EWS_SWIPELIST_BKITEM_SEL_COLOR)); SWIPELIST_SetDefaultBkColor(SWIPELIST_CI_BK_ITEM_UNSEL, EWS_RGB2EMWIN(EWS_SWIPELIST_BKITEM_UNSEL_COLOR)); SWIPELIST_SetDefaultBkColor(SWIPELIST_CI_BK_SEP_ITEM, EWS_RGB2EMWIN(EWS_SWIPELIST_BKSEPITEM_COLOR) ); SWIPELIST_SetDefaultSepColor(EWS_SWIPELIST_SEP_COLOR); SWIPELIST_SetDefaultFont(SWIPELIST_FI_ITEM_HEADER, GUI_FONT_24B_1); SWIPELIST_SetDefaultFont(SWIPELIST_FI_ITEM_TEXT, GUI_FONT_20B_1); SWIPELIST_SetDefaultFont(SWIPELIST_FI_SEP_ITEM, GUI_FONT_32B_1); SWIPELIST_SetDefaultTextColor(SWIPELIST_CI_ITEM_HEADER_UNSEL, EWS_SWIPELIST_TEXT_COLOR); SWIPELIST_SetDefaultTextColor(SWIPELIST_CI_ITEM_HEADER_SEL, EWS_SWIPELIST_TEXT_COLOR); SWIPELIST_SetDefaultTextColor(SWIPELIST_CI_ITEM_TEXT_UNSEL, EWS_SWIPELIST_TEXT_COLOR); SWIPELIST_SetDefaultTextColor(SWIPELIST_CI_ITEM_TEXT_SEL, EWS_SWIPELIST_TEXT_COLOR); SWIPELIST_SetDefaultTextColor(SWIPELIST_CI_SEP_ITEM_TEXT, EWS_SWIPELIST_TEXT_SEPITEM_COLOR); ... Skinning of spinbox, buttons, scrollbar, checkbox... } |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
/** Macro de conversion pour passer la bonne couleur à l'API emwin * */ #define EWS_RGB2EMWIN(col) GUI_MAKE_COLOR(EWS_RGB2BRG(col)) /*============================================================================= * VARIABLES et CONSTANTES *===========================================================================*/ /** Couleur par défaut de l'arrière plan des fenêtres * Il faut utiliser la macro EWS_RGB2EMWIN avec ces définitions * */ #define EWS_WINBKG_DFT_COLOR 0x00e6eaf1 //0x00BAA9D6 /*============================================================================= * PROPRIETE GRAPHIQUE DES SWIPELIST *===========================================================================*/ /** Couleur fond item selectionné */ #define EWS_SWIPELIST_BKITEM_SEL_COLOR 0x0000a0ce //EWS_BUTT_FOCUS_COLOR /** Couleur fond item non selectionné */ #define EWS_SWIPELIST_BKITEM_UNSEL_COLOR 0x00ffffff //EWS_WINBKG_DFT_COLOR /** Couleur fond Entête de groupe (ou item séparateur) */ #define EWS_SWIPELIST_BKSEPITEM_COLOR GUI_DARKGRAY /** Couleur ligne séparation d'items */ #define EWS_SWIPELIST_SEP_COLOR 0x00E6EAF1 //GUI_BLACK /** Couleur des textes On applique la même couleur pour tous les textes sauf l'item séparateur */ #define EWS_SWIPELIST_TEXT_COLOR 0x00293444 //GUI_BLACK /** Couleur des textes On applique la même couleur pour tous les textes sauf l'item séparateur */ #define EWS_SWIPELIST_TEXT_SEPITEM_COLOR GUI_WHITE |
![]() |
Source code |
1 |
WM_SetDesktopColor(EWS_RGB2EMWIN(EWS_WINBKG_DFT_COLOR)); |
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
WM_SetCallback(WM_HBKWIN, _cbBk); /********************************************************************* * * _cbBk */ static void _cbBk(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_WHITE); GUI_Clear(); break; default: WM_DefaultProc(pMsg); break; } } |
Quoted
"It seems you are using a precompiled version of emWin provided by ST.
Quoted
"Have you made changes to the GUIConf.h"
Quoted
"In your LCDConf.c it looks like you use GUICC_M8888I as color
conversion. This means that the output into the framebuffer has the
following format:..."
Quoted
"#define GUI_USE_ARGB 1"
I let the user define its color in ARGB format, but then in the call I use a macro that calls GUI_MAKE_COLOR()
Quoted
"According to your code you define your colors like this:" ....
![]() |
Source code |
1 |
#define EWS_RGB2EMWIN(col) GUI_MAKE_COLOR(EWS_RGB2BRG(col)) |
![]() |
Source code |
1 2 3 4 5 6 7 |
#if (GUI_USE_ARGB) #define GUI_MAKE_COLOR(ABGR) (((((U32)ABGR) & 0xFF000000ul) ^ 0xFF000000ul) | ((((U32)ABGR) & 0x00FF0000ul) >> 16) | (((U32)ABGR) & 0x0000FF00ul) | ((((U32)ABGR) & 0x000000FFul) << 16)) #define GUI_MAKE_TRANS(Alpha) (255 - (Alpha)) #else #define GUI_MAKE_COLOR(ABGR) (ABGR) #define GUI_MAKE_TRANS(Alpha) (Alpha) #endif |
This post has been edited 1 times, last edit by "Selso" (Apr 4th 2018, 3:04pm)
![]() |
C/C++ Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
#include "DIALOG.h" #include <stdio.h> /********************************************************************* * * Externals * ********************************************************************** */ /********************************************************************* * * Defines * ********************************************************************** */ /********************************************************************* * * Static data * ********************************************************************** */ /********************************************************************* * * Static code * ********************************************************************** */ /********************************************************************* * * _cbBk */ static void _cbBk(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_BLACK); GUI_Clear(); break; default: WM_DefaultProc(pMsg); break; } } /********************************************************************* * * Public code * ********************************************************************** */ /********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hSwipe; char acBuffer[32]; int i; GUI_COLOR aColor[] = { GUI_RED, GUI_GREEN, GUI_BLUE }; int Index; GUI_Init(); WM_SetCallback(WM_HBKWIN, _cbBk); hSwipe = SWIPELIST_CreateEx(10, 10, 120, 200, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_SWIPELIST0); for (i = 0; i < 20; i++) { sprintf(acBuffer, "Item %i", i); SWIPELIST_AddItem(hSwipe, acBuffer, 30); } Index = 0; SWIPELIST_SetBkColor(hSwipe, SWIPELIST_CI_BK_ITEM_UNSEL, aColor[Index++]); while (1) { Index = (Index == GUI_COUNTOF(aColor)) ? 0 : Index; GUI_Delay(1000); SWIPELIST_SetBkColor(hSwipe, SWIPELIST_CI_BK_ITEM_UNSEL, aColor[Index++]); } } /*************************** End of file ****************************/ |
But in your last example you create the SWIPELIST with the size of the screen, so it will always fill the complete screen.
Quoted
I've just changer screen size to 480x640 in order to be sure that the swipe list do not fille the screen area.
![]() |
C/C++ Source code |
1 |
hSwipelist = SWIPELIST_CreateEx(0, 0, GUI_GetScreenSizeX(), GUI_GetScreenSizeY(), WM_HBKWIN, WM_CF_SHOW, 0, 0); |
Not sure what you mean with the 'empty area'. The swipelist covers the complete screen. The items are red and the sparators are dark gray.
Quoted
then I try to fill the swipe list empty area in RED, and can't do it.
Yes it filling the area, but the item list is not, see my attached capture.
Quoted
But in your last example you create the SWIPELIST with the size of the screen, so it will always fill the complete screen.
Quoted
Quoted
I've just changer screen size to 480x640 in order to be sure that the swipe list do not fille the screen area.
![]() |
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
#include "DIALOG.h" #include <stdio.h> /********************************************************************* * * Externals * ********************************************************************** */ /********************************************************************* * * Defines * ********************************************************************** */ /********************************************************************* * * Static data * ********************************************************************** */ /********************************************************************* * * Static code * ********************************************************************** */ /********************************************************************* * * _cbBk */ static void _cbBk(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_WHITE); GUI_Clear(); break; default: WM_DefaultProc(pMsg); break; } } /********************************************************************* * * Public code * ********************************************************************** */ /********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hSwipe; char acBuffer[32]; int i; GUI_COLOR aColor[] = { GUI_RED, GUI_GREEN, GUI_BLUE }; int Index; GUI_Init(); WM_SetCallback(WM_HBKWIN, _cbBk); hSwipe = SWIPELIST_CreateEx(0, 0, GUI_GetScreenSizeX(), GUI_GetScreenSizeY(), WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_SWIPELIST0); for (i = 0; i < 20; i++) { sprintf(acBuffer, "Item %i", i); SWIPELIST_AddItem(hSwipe, acBuffer, 30); } Index = 0; SWIPELIST_SetBkColor(hSwipe, SWIPELIST_CI_BK_ITEM_UNSEL, aColor[Index++]); while (1) { Index = (Index == GUI_COUNTOF(aColor)) ? 0 : Index; GUI_Delay(1000); SWIPELIST_SetBkColor(hSwipe, SWIPELIST_CI_BK_ITEM_UNSEL, aColor[Index++]); } } /*************************** End of file ****************************/ |
![]() |
C/C++ Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
/********************************************************************* * * _OwnerDraw */ static int _OwnerDraw(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) { GUI_RECT Rect; GUI_COLOR Color; switch (pDrawItemInfo->Cmd) { case WIDGET_ITEM_DRAW_TEXT: // // Call default owner draw to draw the text // SWIPELIST_OwnerDraw(pDrawItemInfo); // // The last item to be drawn // if (pDrawItemInfo->ItemIndex == SWIPELIST_GetNumItems(pDrawItemInfo->hWin) - 1) { // // Set a bk color // GUI_SetBkColor(SLI_COLOR); // // set up a rectangle to be cleared // Rect.x0 = WM_GetWindowOrgX(pDrawItemInfo->hWin); Rect.y0 = pDrawItemInfo->y1; Rect.x1 = WM_GetWindowSizeX(pDrawItemInfo->hWin); Rect.y1 = LCD_GetYSize(); // // Set a user clip rect, otherwise nothing would be drawn due to clipping // WM_SetUserClipRect(&Rect); // // Clear the rectangle // GUI_ClearRectEx(&Rect); // // Restore clip rect // WM_SetUserClipRect(NULL); } return 0; default: return SWIPELIST_OwnerDraw(pDrawItemInfo); } } |