?? widget_customeffect.c
字號:
* _DrawDown
*
* Function description
* Gets the rectangle of the current window and uses _DrawDownRect()
* for drawing the effect.
*/
static void _DrawDown(void) {
GUI_RECT r;
WM_GetClientRect(&r);
_DrawDownRect(&r);
}
/*********************************************************************
*
* _DrawFlat
*
* Function description
* Gets the rectangle of the current window and uses _DrawFlatRect()
* for drawing the effect.
*/
static void _DrawFlat(void) {
GUI_RECT r;
WM_GetClientRect(&r);
_DrawFlatRect(&r);
}
/*********************************************************************
*
* _aEffects
*
* Purpose:
* Array of structures of type WIDGET_EFFECT which contains the function pointers
* used by emWin to draw the effect. It also contains the effect size
* which specifies the number of pixels used by the effect frame.
*/
static WIDGET_EFFECT _Effect = {
2,
_DrawUp,
_DrawUpRect,
_DrawDown,
_DrawDownRect,
_DrawFlat,
_DrawFlatRect
};
/*********************************************************************
*
* _DrawGradientV
*
* Purpose:
* Draws the vertical gradient ussed by the background
*/
static void _DrawGradientV(int x0, int y0, int x1, int y1, GUI_COLOR Color0, GUI_COLOR Color1) {
int r0, g0, b0, r1, g1, b1;
int y, ySize;
ySize = y1 - y0 + 1;
r0 = (Color0 >> 0) & 0x000000ff;
g0 = (Color0 >> 8) & 0x000000ff;
b0 = (Color0 >> 16) & 0x000000ff;
r1 = (Color1 >> 0) & 0x000000ff;
g1 = (Color1 >> 8) & 0x000000ff;
b1 = (Color1 >> 16) & 0x000000ff;
for (y = y0; y <= y1; y++) {
GUI_COLOR Color;
int r, g, b, yd;
yd = (y - y0);
r = r0 + ((r1 - r0) * yd) / ySize;
g = g0 + ((g1 - g0) * yd) / ySize;
b = b0 + ((b1 - b0) * yd) / ySize;
Color = r | (g << 8) | (b << 16);
GUI_SetColor(Color);
GUI_DrawHLine(y, x0, x1);
}
}
/*********************************************************************
*
* _cbWin
*
* Purpose:
* Callback function of desktop window
*/
static void _cbWin(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_DrawGradientV(0, 0, 319, 239, 0xff0000, 0xffffff);
GUI_SetFont(&GUI_Font16B_ASCII);
GUI_SetTextMode(GUI_TM_TRANS);
GUI_DispStringHCenterAt("Custom effect frames with standard widgets", 160, 20);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* MainTask
*/
void MainTask(void) {
WM_HWIN hButton, hEdit;
GUI_Init();
WM_SetCallback(WM_HBKWIN, _cbWin);
_InitColors(0x002840, 0x00A5FF, _aColor, 3);
/*
* Set custom effect as default effect
*/
WIDGET_SetDefaultEffect(&_Effect);
/*
* Create widgets
*/
hButton = BUTTON_CreateEx (105, 60, 110, 110, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS, 0, 0);
hEdit = EDIT_CreateEx (105, 190, 110, 26, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS, 0, 0, 20);
BUTTON_SetBitmapEx(hButton, 0, &_bmDolphin, 5, 22);
BUTTON_SetBitmapEx(hButton, 1, &_bmDolphin, 6, 23);
EDIT_SetText(hEdit, "Please edit me...");
/*
* Loop
*/
while (1) {
GUI_Delay(100);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -