📄 pinyindemo.c
字号:
#include <stddef.h>
#include "typedef.h"
#include "GUI.h"
#include "keydef.h"
#include "PinYinDemo.h"
#include "includes.h"
#include "draw.h"
static ulong Key;
extern UB DispMap[ DISP_BUF_SIZE +10];
extern void PinYinMain (void);
const GUI_COLOR ColorsMicriumLogo_2bpp[] = {
0xFFFFFF,0x000000
};
const GUI_LOGPALETTE PalMicriumLogo_2bpp = {
2, /* number of entries */
0, /* No transparency */
&ColorsMicriumLogo_2bpp[0]
};
const GUI_BITMAP bmMicriumLogo_2bpp = {
XDOTS, /* XSize */
YDOTS, /* YSize */
SCRW, /* BytesPerLine */
1, /* BitsPerPixel */
DispMap, /* Pointer to picture data (indices) */
&PalMicriumLogo_2bpp /* Pointer to palette */
};
/*
*********************************************************************************************************
* uC/GUI V3.98
* Universal graphic software for embedded applications
*
* (c) Copyright 2002, Micrium Inc., Weston, FL
* (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
* 礐/GUI is protected by international copyright laws. Knowledge of the
* source code may not be used to write a similar product. This file may
* only be used in accordance with a license and should not be redistributed
* in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File : WIDGET_ButtonRound.c
Purpose : Demonstrates how to create and use a round button
---------------------------END-OF-HEADER------------------------------
*/
#include <stddef.h>
#include <string.h>
#include "WM.h"
#include "FRAMEWIN.h"
#include "BUTTON.h"
#include "BUTTON_Private.h"
#include "GUI_Protected.h"
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static WM_CALLBACK * _pcbCallback;
static int _Pressed;
/*********************************************************************
*
* Static functions
*
**********************************************************************
*/
/*********************************************************************
*
* _OnPaint
*
* Purpose: Paints the owner drawn button
*/
static void _OnPaint(BUTTON_Handle hObj) {
int Index;
char ac[50];
GUI_RECT Rect;
BUTTON_Obj * pObj;
pObj = BUTTON_H2P(hObj);
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
WM_GetClientRect(&Rect);
/* Draw filled ellipse with button background color */
GUI_SetColor(BUTTON_GetBkColor(hObj, Index));
GUI_FillEllipse(Rect.x1 / 2, Rect.y1 / 2, Rect.x1 / 2, Rect.y1 / 2);
/* Draw black shape */
GUI_SetColor(GUI_BLACK);
GUI_DrawEllipse(Rect.x1 / 2, Rect.y1 / 2, Rect.x1 / 2, Rect.y1 / 2);
/* Draw button text with widget attributes */
GUI_SetColor(BUTTON_GetTextColor(hObj, Index));
GUI_SetBkColor(BUTTON_GetBkColor(hObj, Index));
GUI_SetFont(BUTTON_GetFont(hObj));
BUTTON_GetText(hObj, ac, sizeof(ac));
/*if (_Pressed) {
strcpy(ac + strlen(ac), "\npressed");
}
GUI_DispStringInRect(ac, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER);*/
}
/*********************************************************************
*
* _cbButton
*
* Purpose:
* 1. Calls the owner draw function if the WM_PAINT message has been send
* 2. Calls the original callback for further messages
* 3. After processing the messages the function evaluates the pressed-state
* if the WM_TOUCH message has been send
*/
static void _cbButton(WM_MESSAGE *pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint(pMsg->hWin);
break;
default:
_pcbCallback(pMsg); /* The original callback */
break;
}
if (pMsg->MsgId == WM_TOUCH) {
if (BUTTON_IsPressed(pMsg->hWin)) {
if (!_Pressed) {
_Pressed = 1;
}
} else {
_Pressed = 0;
}
}
}
/*********************************************************************
*
* _cbDialog
*
* Purpose: Dialog callback routine
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Input Select", 0, 60, 150, 200, 90, FRAMEWIN_CF_ACTIVE },
{ BUTTON_CreateIndirect, "UP", GUI_ID_BUTTON1, 40, 10, 30, 20 },
{ BUTTON_CreateIndirect, "Down", GUI_ID_BUTTON2, 40, 50, 30, 20 },
{ BUTTON_CreateIndirect, "Left", GUI_ID_BUTTON3, 10, 30, 30, 20 },
{ BUTTON_CreateIndirect, "Right", GUI_ID_BUTTON4, 70, 30, 30, 20 },
{ BUTTON_CreateIndirect, "Clear", GUI_ID_BUTTON5, 70, 50, 30, 20 },
{ BUTTON_CreateIndirect, "Enter", GUI_ID_BUTTON6, 40, 30, 30, 20 },
{ BUTTON_CreateIndirect, "Exit", GUI_ID_CANCEL, 120, 50, 30, 20 }
};
static void _cbDialog(WM_MESSAGE *pMsg) {
int NCode, Id;
WM_HWIN hDlg;
BUTTON_Handle hButton;
hDlg = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_PAINT:
WM_DefaultProc(pMsg); /* Handle dialog items */
break;
case WM_INIT_DIALOG:
hButton = WM_GetDialogItem(hDlg, GUI_ID_BUTTON0);
WM_SetHasTrans(hButton); /* Set transparency flag for button */
break;
case WM_KEY:
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) {
case GUI_KEY_ESCAPE:
GUI_EndDialog(hDlg, 1);
break;
case GUI_KEY_ENTER:
GUI_EndDialog(hDlg, 0);
break;
}
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */
NCode = pMsg->Data.v; /* Notification code */
switch (NCode) {
case WM_NOTIFICATION_RELEASED: /* React only if released */
if (Id == GUI_ID_BUTTON1) { /* Toggle callback */
Key = KEY_DOWN_UP;
}
if (Id == GUI_ID_BUTTON2) { /* Toggle font */
Key = KEY_DOWN_DOWN;
}
if (Id == GUI_ID_BUTTON3) { /* Toggle color */
Key = KEY_DOWN_LEFT;
}
if (Id == GUI_ID_OK) { /* OK Button */
GUI_EndDialog(hDlg, 0);
g_Thread = 0;
OSTaskDel(3);
}
if (Id == GUI_ID_CANCEL) { /* Cancel Button */
GUI_EndDialog(hDlg, 1);
g_Thread = 0;
OSTaskDel(3);
//end thread//
}
if (Id == GUI_ID_BUTTON4) { /* Cancel Button */
Key = KEY_DOWN_RIGHT;
}
if (Id == GUI_ID_BUTTON5) { /* Cancel Button */
Key = KEY_DOWN_C;
}
if (Id == GUI_ID_BUTTON6) { /* Cancel Button */
Key = KEY_DOWN_ENT;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* MainTask
*
**********************************************************************
*/
void UpdateScr(void)
{
GUI_DrawBitmap(&bmMicriumLogo_2bpp, START_X_POINT, START_Y_POINT);
}
//hDialog = GUI_CreateDialogBox(_aDialogCreate5,
// GUI_COUNTOF(_aDialogCreate5),
// &_cbDialog5, WM_UNATTACHED, 0, 0);
ulong GetKey (short event)
{
ulong KeyValue = 0;
while(g_Thread)
{
if(Key != 0)
break;
GUI_Delay(10);
}
KeyValue = Key;
Key = 0;
return KeyValue;
}
void PinYinDemo (void)
{
Key = 0;
GUI_DrawLine(START_X_POINT-1,START_Y_POINT-1, START_X_POINT-1, START_Y_POINT + YDOTS);
GUI_DrawLine(START_X_POINT-1,START_Y_POINT-1, START_X_POINT+XDOTS, START_Y_POINT-1);
GUI_DrawLine(START_X_POINT+XDOTS,START_Y_POINT-1, START_X_POINT+XDOTS, START_Y_POINT + YDOTS);
GUI_DrawLine(START_X_POINT-1,START_Y_POINT + YDOTS, START_X_POINT+XDOTS, START_Y_POINT + YDOTS);
WM_SetCreateFlags(WM_CF_MEMDEV);
WM_EnableMemdev(WM_HBKWIN);
//WM_SetDesktopColor(GUI_GREEN);
_pcbCallback = 0;
GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, 0, 0, 0);
PinYinMain();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -