Hi,
I have a small sample code:
Display All
the result of this code is:
This is strange and counterintuitive. I created a square MEMDEV of side 10 and filled it with white and then wrote it down at position 5,5.
Really GUI_*() functions work in the coordinates of the window (in the example there is GUI_DrawRect()) while GUI_MEMDEV_WriteAt() works in absolute coordinates?
Then I try to put an offset to the GUI_MEMDEV_WriteAt():
And the result is
I can't explain that. It is beyond my comprehension.
It seems that there is the shadow of the square at the position I want but it is white only in the lower right corner.
Another thing I don't understand is the parameters of the GUI_MEMDEV_CreateFixed(). I don't understand the sense of imposing an origin if then I can write it to an arbitrary position
For example if I modify the MEMDEV creation in this way:
I get this:
Again, I can not understand the behavior.
at the end of it all the question is: how do I create a memdev, paint it white and then place it at an arbitrary position inside a window?
best regards
Max
I have a small sample code:
C Source Code
- #include "GUI.h"
- #include "WM.h"
- static void _cbBkWin(WM_MESSAGE *pMsg)
- {
- switch (pMsg->MsgId)
- {
- case WM_PAINT:
- GUI_SetBkColor(GUI_DARKRED);
- GUI_Clear();
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- static void _cbWin(WM_MESSAGE *pMsg)
- {
- switch (pMsg->MsgId)
- {
- case WM_PAINT:
- GUI_SetBkColor(GUI_DARKGREEN);
- GUI_Clear();
- GUI_SetColor(GUI_BLUE);
- GUI_DrawRect(2,2,15,12);
- {
- GUI_MEMDEV_Handle hMemPrev;
- GUI_MEMDEV_Handle hMemOverlay;
- hMemOverlay = GUI_MEMDEV_CreateFixed(0, 0, 10, 10, GUI_MEMDEV_NOTRANS, GUI_MEMDEV_APILIST_32, GUI_COLOR_CONV_8888);
- hMemPrev = GUI_MEMDEV_Select(hMemOverlay);
- GUI_SetBkColor(GUI_WHITE);
- GUI_Clear();
- GUI_MEMDEV_Select(hMemPrev);
- GUI_MEMDEV_WriteAt(hMemOverlay, 5, 5);
- GUI_MEMDEV_Delete(hMemOverlay);
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- void MainTask(void)
- {
- GUI_Init();
- GUI_EnableAlpha(1);
- WM_SetSize(WM_HBKWIN, LCD_GetXSize(), LCD_GetYSize());
- WM_SetCallback(WM_HBKWIN, _cbBkWin);
- WM_SetCreateFlags(WM_CF_MEMDEV);
- WM_EnableMemdev(WM_HBKWIN);
- WM_HWIN hWin;
- hWin = WM_CreateWindow(5, 5, 30, 25, WM_CF_SHOW | WM_CF_MEMDEV, _cbWin, 0);
- while(1) GUI_Delay(2000);
- }
the result of this code is:
This is strange and counterintuitive. I created a square MEMDEV of side 10 and filled it with white and then wrote it down at position 5,5.
Really GUI_*() functions work in the coordinates of the window (in the example there is GUI_DrawRect()) while GUI_MEMDEV_WriteAt() works in absolute coordinates?
Then I try to put an offset to the GUI_MEMDEV_WriteAt():
And the result is
I can't explain that. It is beyond my comprehension.
It seems that there is the shadow of the square at the position I want but it is white only in the lower right corner.
Another thing I don't understand is the parameters of the GUI_MEMDEV_CreateFixed(). I don't understand the sense of imposing an origin if then I can write it to an arbitrary position
For example if I modify the MEMDEV creation in this way:
I get this:
Again, I can not understand the behavior.
at the end of it all the question is: how do I create a memdev, paint it white and then place it at an arbitrary position inside a window?
best regards
Max