touchkeyboard.c
来自「S3c44b0x下的ucgui」· C语言 代码 · 共 224 行
C
224 行
/*********************************************************************************************************** uC/GUI* 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 : TouchKeyboard.c
Purpose : Example demonstrating TouchScreen
----------------------------------------------------------------------
*/
#include <stddef.h>
#include "GUI.H"
#include "DIALOG.h"
#include "44b.h"/*********************************************************************
*
* static data
*
**********************************************************************
*/
/*********************************************************************
*
* Dialog resource
*
* This table conatins the info required to create the dialog.
* It has been created manually, but could also be created by a GUI-builder.
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
{ FRAMEWIN_CreateIndirect, "TouchKeyboard", 0, 10, 10, 310, 200, 0, 0 },
{ TEXT_CreateIndirect, "Input:", 0, 5, 5, 35, 20,TEXT_CF_LEFT },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT1, 45, 0, 170, 25, 0, 50 },
{ BUTTON_CreateIndirect, "Del", GUI_ID_DEL, 220, 0, 55, 25 },
//{ BUTTON_CreateIndirect, "OK", GUI_ID_OK, 195, 5, 25, 20 },
// { BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL,225, 5, 40, 20 },
{ BUTTON_CreateIndirect, "1", GUI_ID_1, 10, 30, 25, 25 },
{ BUTTON_CreateIndirect, "2", GUI_ID_2, 40, 30, 25, 25 },
{ BUTTON_CreateIndirect, "3", GUI_ID_3, 70, 30, 25, 25 },
{ BUTTON_CreateIndirect, "4", GUI_ID_4, 100, 30, 25, 25 },
{ BUTTON_CreateIndirect, "5", GUI_ID_5, 130, 30, 25, 25 },
{ BUTTON_CreateIndirect, "6", GUI_ID_6, 160, 30, 25, 25 },
{ BUTTON_CreateIndirect, "7", GUI_ID_7, 190, 30, 25, 25 },
{ BUTTON_CreateIndirect, "8", GUI_ID_8, 220, 30, 25, 25 },
{ BUTTON_CreateIndirect, "9", GUI_ID_9, 250, 30, 25, 25 },
//{ BUTTON_CreateIndirect, "0", GUI_ID_0, 280, 30, 25, 25 },
{ BUTTON_CreateIndirect, "0", GUI_ID_0, 10, 60, 25, 25 },
{ BUTTON_CreateIndirect, "A", GUI_ID_A, 40, 60, 25, 25 },
{ BUTTON_CreateIndirect, "B", GUI_ID_B, 70, 60, 25, 25 },
{ BUTTON_CreateIndirect, "C", GUI_ID_C, 100, 60, 25, 25 },
{ BUTTON_CreateIndirect, "D", GUI_ID_D, 130, 60, 25, 25 },
{ BUTTON_CreateIndirect, "E", GUI_ID_E, 160, 60, 25, 25 },
{ BUTTON_CreateIndirect, "F", GUI_ID_F, 190, 60, 25, 25 },
{ BUTTON_CreateIndirect, "G", GUI_ID_G, 220, 60, 25, 25 },
{ BUTTON_CreateIndirect, "H", GUI_ID_H, 250, 60, 25, 25 },
// { BUTTON_CreateIndirect, "P", GUI_ID_P, 280, 60, 25, 25 },
{ BUTTON_CreateIndirect, "I", GUI_ID_I, 10, 90, 25, 25 },
{ BUTTON_CreateIndirect, "J", GUI_ID_J, 40, 90, 25, 25 },
{ BUTTON_CreateIndirect, "K", GUI_ID_K, 70, 90, 25, 25 },
{ BUTTON_CreateIndirect, "L", GUI_ID_L, 100, 90, 25, 25 },
{ BUTTON_CreateIndirect, "M", GUI_ID_M, 130, 90, 25, 25 },
{ BUTTON_CreateIndirect, "N", GUI_ID_N, 160, 90, 25, 25 },
{ BUTTON_CreateIndirect, "O", GUI_ID_O, 190, 90, 25, 25 },
{ BUTTON_CreateIndirect, "P", GUI_ID_P, 220, 90, 25, 25 },
{ BUTTON_CreateIndirect, "Q", GUI_ID_Q, 250, 90, 25, 25 },
//{ BUTTON_CreateIndirect, "!", GUI_ID_111, 280, 90, 25, 25 },
{ BUTTON_CreateIndirect, "R", GUI_ID_R, 10, 120, 25, 25 },
{ BUTTON_CreateIndirect, "S", GUI_ID_S, 40, 120, 25, 25 },
{ BUTTON_CreateIndirect, "T", GUI_ID_T, 70, 120, 25, 25 },
{ BUTTON_CreateIndirect, "U", GUI_ID_U, 100, 120, 25, 25 },
{ BUTTON_CreateIndirect, "V", GUI_ID_V, 130, 120, 25, 25 },
{ BUTTON_CreateIndirect, "N", GUI_ID_N, 160, 120, 25, 25 },
{ BUTTON_CreateIndirect, "W", GUI_ID_W, 190, 120, 25, 25 },
{ BUTTON_CreateIndirect, "X", GUI_ID_X, 220, 120, 25, 25 },
{ BUTTON_CreateIndirect, "Y", GUI_ID_Y, 250, 120, 25, 25 },
{ BUTTON_CreateIndirect, "Z", GUI_ID_Z, 10, 150, 25, 25 }
, { BUTTON_CreateIndirect, "+", GUI_ID_333, 40, 150, 25, 25 }, { BUTTON_CreateIndirect, "#", GUI_ID_444, 70, 150, 25, 25 }, { BUTTON_CreateIndirect, "CapsLock", GUI_ID_222, 100, 150, 60, 25 }, { BUTTON_CreateIndirect, "OK", GUI_ID_OK, 170, 150, 50, 25 }, { BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 225, 150, 50, 25 } };
/*********************************************************************
*
* static code
*
**********************************************************************
*/
/*********************************************************************
*
* Dialog callback routine
*/extern GUI_HID_STATE _State; void _cbCallback1(WM_MESSAGE * pMsg) {
int NCode, Id;
static shift = 0;
WM_HWIN hEdit1;
WM_HWIN hWin = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
/* Get window handles for all widgets */
hEdit1 = WM_GetDialogItem(hWin, GUI_ID_EDIT1);
// EDIT_SetText(hEdit1, "0");
EDIT_SetTextAlign(hEdit1, GUI_TA_LEFT);
break;
case WM_KEY:
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) {
case GUI_KEY_ESCAPE:
GUI_EndDialog(hWin, 1);
break;
case GUI_KEY_ENTER:
GUI_EndDialog(hWin, 0);
break;
}
break;
case WM_NOTIFY_PARENT:
hEdit1 = WM_GetDialogItem(hWin, GUI_ID_EDIT1);
Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */
NCode = pMsg->Data.v; /* Notification code */
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
switch (Id ){
//case GUI_ID_OK: GUI_EndDialog(hWin, 0); break;
// case GUI_ID_CANCEL:GUI_EndDialog(hWin, 1);break;
case GUI_ID_DEL: EDIT_AddKey(hEdit1, GUI_KEY_BACKSPACE);break;
case GUI_ID_222: shift = (shift + 1) % 2;break;
case GUI_ID_1: EDIT_AddKey(hEdit1, 49);break;
case GUI_ID_2: EDIT_AddKey(hEdit1, 50);break;
case GUI_ID_3: EDIT_AddKey(hEdit1, 51);break;
case GUI_ID_4: EDIT_AddKey(hEdit1, 52);break;
case GUI_ID_5: EDIT_AddKey(hEdit1, 53);break;
case GUI_ID_6: EDIT_AddKey(hEdit1, 54);break;
case GUI_ID_7: EDIT_AddKey(hEdit1, 55);break;
case GUI_ID_8: EDIT_AddKey(hEdit1, 56);break;
case GUI_ID_9: EDIT_AddKey(hEdit1, 57);break;
case GUI_ID_0: EDIT_AddKey(hEdit1, 48);break;
case GUI_ID_A: EDIT_AddKey(hEdit1, 65+32*shift);break;
case GUI_ID_B: EDIT_AddKey(hEdit1, 66+32*shift);break;
case GUI_ID_C: EDIT_AddKey(hEdit1, 67+32*shift);break;
case GUI_ID_D: EDIT_AddKey(hEdit1, 68+32*shift);break;
case GUI_ID_E: EDIT_AddKey(hEdit1, 69+32*shift);break;
case GUI_ID_F: EDIT_AddKey(hEdit1, 70+32*shift);break;
case GUI_ID_G: EDIT_AddKey(hEdit1, 71+32*shift);break;
case GUI_ID_H: EDIT_AddKey(hEdit1, 72+32*shift);break;
case GUI_ID_I: EDIT_AddKey(hEdit1, 73+32*shift);break;
case GUI_ID_J: EDIT_AddKey(hEdit1, 74+32*shift);break;
case GUI_ID_K: EDIT_AddKey(hEdit1, 75+32*shift);break;
case GUI_ID_L: EDIT_AddKey(hEdit1, 76+32*shift);break;
case GUI_ID_M: EDIT_AddKey(hEdit1, 77+32*shift);break;
case GUI_ID_N: EDIT_AddKey(hEdit1, 78+32*shift);break;
case GUI_ID_O: EDIT_AddKey(hEdit1, 79+32*shift);break;
case GUI_ID_P: EDIT_AddKey(hEdit1, 80+32*shift);break;
case GUI_ID_Q: EDIT_AddKey(hEdit1, 81+32*shift);break;
case GUI_ID_R: EDIT_AddKey(hEdit1, 82+32*shift);break;
case GUI_ID_S: EDIT_AddKey(hEdit1, 83+32*shift);break;
case GUI_ID_T: EDIT_AddKey(hEdit1, 84+32*shift);break;
case GUI_ID_U: EDIT_AddKey(hEdit1, 85+32*shift);break;
case GUI_ID_V: EDIT_AddKey(hEdit1, 86+32*shift);break;
case GUI_ID_W: EDIT_AddKey(hEdit1, 87+32*shift);break;
case GUI_ID_X: EDIT_AddKey(hEdit1, 88+32*shift);break;
case GUI_ID_Y: EDIT_AddKey(hEdit1, 89+32*shift);break;
case GUI_ID_Z: EDIT_AddKey(hEdit1, 90+32*shift);break;
case GUI_ID_111: EDIT_AddKey(hEdit1, 33);break;
case GUI_ID_333: EDIT_AddKey(hEdit1, 43);break;
case GUI_ID_444: EDIT_AddKey(hEdit1, 35);break;
}
_State.Pressed = 0; _State.x = -1; _State.y = -1; break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
* main
*
**********************************************************************
*/
//extern void _cbCallback(WM_MESSAGE * pMsg);
//extern const GUI_WIDGET_CREATE_INFO _aDialogCreate[];
void Main(void) {
rI_ISPC = 0xffffffff; /* clear all interrupt pend */ Port_Init(); /* Initial 44B0X's I/O port */ rSYSCFG=CACHECFG; // Using 8KB Cache Delay(0); /* delay time */ Delay(100); /* delay time */// Uart_Init(0,115200); /* Initial Serial port 1 */ Tick_Init(); GUI_Init(); TS_init(); //GUI_Init();
// for(;;); WM_SetDesktopColor(GUI_BLACK); /* Automacally update desktop window */
WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */
GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbCallback1, 0, 0, 0);
//GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0);
while(1) GUI_Exec1();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?