📄 uipen_hdr.c
字号:
#include <uiWnd.h>
#include <uiIcon_img.h>
#include <typedefine.h>
#include <uiGui_cfg.h>
#include <uicontrol.h>
#include <uimessage.h>
#include <uiwm_queue.h>
#include <uiprg_mgr.h>
#include <uiCallback.h>
#include <uigraph.h>
#include <uimenu.h>
#include <uilistbox.h>
#include <uiHandWrite.h>
#include <sys/syscall.h>
#define PEN_HOOKER
#ifdef _DEBUG
#define _DEBUG_PEN_HDR_
#endif
extern unsigned char backlightOn;
int guiCustomAreaHandler(WORD msg, short x, short y);
/**************************************************************
Touch Panel Handler
FUNCTION: TouchpadEventHandler( msg, x, y)
- called by user thread(or ISR)
- msg type 有三种: WIN_PEN_DOWN, WIN_PEN_UP, WIN_PEN_MOVE
- WIN_PEN_DOWN
1. 纪录active元件
2. 送PENDOWN给元件
- WIN_PEN_UP
1. 取消active元件
2. 送PENUP给元件
- WIN_PEN_MOVE
1. 在元件范围内送给元件PENMOVE 送CONTROL_ENTER通知AP进入元件范围
2. 在元件范围外送给元件PENROVE 送CONTROL_EXIT通知AP离开元件范围
FUNCTION: getFocusCtrlHandle
- 判断是否有元件被笔压下 有则传回其handle 否则传回0
FUNCTION: _guiPenHookHandler
- Pen Event Hooker handler
**************************************************************/
static int _guiPenHookHandler(WORD msg, short x, short y);
static PF_PEN_HOOKER gfPen_Hooker = NULL;
DWORD g_dwActiveCtrlHandle = 0; // active control
int giPenRemoveFlag = 0 ; // move out of active control
static int giPenTrackFlag = 0 ; // allow pen tracking
extern void guiSetKeypadLock(int locked);
void guiSetPenTrack(int enable)
{
giPenTrackFlag = enable;
}
void guiTouchpadEventHandler(WORD msg, short x, short y)
{
unsigned long CtrlHandle;
TGuiMessage tempMsg;
TGuiControl *ptControl ;
// 如果TopWindowPtr为NULL 则不作进一步处理!!
//(以下呼叫元件的action function时都会假设TopWindowPtr不为NULL)
if(gpTopWindow == NULL)
{
return ;
}
#ifdef GUI_POPUP_LISTBOX
// give a chance to handle popup list
if ( 0!=guiListbox_PopupListHandler(msg, x, y) )
{
g_dwActiveCtrlHandle = 0 ;
giPenRemoveFlag = 0 ;
return ;
}
#endif
#ifdef GUI_MENU
// give a chance to handle menu event
if( 0!=_guiMenuHandler(msg, x-gpTopWindow->left, y-gpTopWindow->top ) )
{
g_dwActiveCtrlHandle = 0 ;
giPenRemoveFlag = 0 ;
return ;
}
#endif
#ifdef GUI_HANDWRITE
//give a chance to handle handwrite
#ifdef _DEBUG_PEN_HDR_
//sc_logString("guiHWR_handler begin",TO_MONITOR);
#endif
if(0!=guiHWR_Handler(msg,x,y))
{
#ifdef _DEBUG_PEN_HDR_
//sc_logString("guiHWR_handler end",TO_MONITOR);
#endif
g_dwActiveCtrlHandle = 0 ;
giPenRemoveFlag = 0 ;
return ;
}
#ifdef _DEBUG_PEN_HDR_
//sc_logString("guiHWR_handler end",TO_MONITOR);
#endif
#endif
#ifdef GUI_CUSTOM_AREA
// give a chance to handle custom area event
if ( 0!=guiCustomAreaHandler(msg, x, y))
{
g_dwActiveCtrlHandle = 0 ;
giPenRemoveFlag = 0 ;
return ; // handled
}
#endif
#ifdef GUI_PEN_HOOKER
// give a chance to handle user hooker
if ( 0!=_guiPenHookHandler(msg, x, y) )
{
g_dwActiveCtrlHandle = 0 ;
giPenRemoveFlag = 0 ;
return ;
}
#endif
//convert absolute coordinate of screen to relative coordinate of window;
x-=gpTopWindow->left;
y-=gpTopWindow->top;
//if(!(x>=gpTopWindow->left+2&&y>=gpTopWindow->top+2&&x<=gpTopWindow->right-2&&y<=gpTopWindow->bottom-2))
//if(!(x>=2&&y>=2&&x<=gpTopWindow->right-gpTopWindow->left-2&&y<=gpTopWindow->bottom-gpTopWindow->top-2))
if(x<0||y<0||x>gpTopWindow->right-gpTopWindow->left||y>gpTopWindow->bottom-gpTopWindow->top)
{
return;
}
if(x<2||y<2||x>gpTopWindow->right-gpTopWindow->left-2||y>gpTopWindow->bottom-gpTopWindow->top-2)
{
if(msg==WIN_PEN_MOVE&&g_dwActiveCtrlHandle != 0&&giPenRemoveFlag==0)
{
tempMsg.messageType = CONTROL_EXIT;
tempMsg.x = x;
tempMsg.y = y;
tempMsg.handle = g_dwActiveCtrlHandle;
_guiEnqueue(gpTopWindow->messageQueue, &tempMsg) ;
giPenRemoveFlag = 1;
ptControl = (TGuiControl *)g_dwActiveCtrlHandle;
// 呼叫这个control的action callback function
(ptControl->actionFun)(g_dwActiveCtrlHandle, PENROVE, x, y) ;
}
return;
}
switch(msg)
{
case WIN_PEN_DOWN:
// if (g_dwActiveCtrlHandle == 0) // by zhangxp; g_dwActiveCtrlHandle!=0 after skip out touch quickly
{
g_dwActiveCtrlHandle = guiSearchControl(&(gpTopWindow->controlList), x, y) ;
if(g_dwActiveCtrlHandle != 0)
{
// disable key event
guiSetKeypadLock(1);
// disable cursor blinking in textfield
// for {PENMOVE, PENROVE, PENDOWN} event
//tong pdaTextField_DisableCursor();
ptControl = (TGuiControl *)g_dwActiveCtrlHandle;
// 呼叫这个control的action call back function
(ptControl->actionFun)(g_dwActiveCtrlHandle, PENDOWN, x, y) ;
}
else
{
tempMsg.messageType=PENDOWN;
tempMsg.handle=(HNDL)gpTopWindow;
tempMsg.x=x;
tempMsg.y=y;
_guiEnqueue(gpTopWindow->messageQueue,&tempMsg);
}
}
break;
case WIN_PEN_UP:
if (g_dwActiveCtrlHandle != 0)
{
CtrlHandle = guiSearchControl(&(gpTopWindow->controlList), x, y) ;
if ( CtrlHandle==g_dwActiveCtrlHandle )
{
// g_dwActiveCtrlHandle = 0;
// giPenRemoveFlag = 0 ;
// enable key event
// guiSetKeypadLock(0);
ptControl = (TGuiControl *)CtrlHandle;
// 呼叫这个control的action callback function
(ptControl->actionFun)(CtrlHandle, PENUP, x, y) ;
// try to re-enable cursor
//pdaTextField_EnableCursor();
}
g_dwActiveCtrlHandle = 0;
giPenRemoveFlag = 0 ;
// enable key event
guiSetKeypadLock(0);
}
else
{
tempMsg.messageType=PENUP;
tempMsg.handle=(HNDL)gpTopWindow;
tempMsg.x=x;
tempMsg.y=y;
_guiEnqueue(gpTopWindow->messageQueue,&tempMsg);
}
giPenTrackFlag = 0; // reset automatically
break;
case WIN_PEN_MOVE:
if (g_dwActiveCtrlHandle != 0)
{
// disable cursor blinking in textfield
// for {PENMOVE, PENROVE, PENDOWN} event
//pdaTextField_DisableCursor();
CtrlHandle = guiSearchControl(&(gpTopWindow->controlList), x, y) ;
if ( CtrlHandle==g_dwActiveCtrlHandle )
{
if (giPenRemoveFlag==1)
{
tempMsg.messageType = CONTROL_ENTER;
tempMsg.x = x;
tempMsg.y = y;
tempMsg.handle = g_dwActiveCtrlHandle;
_guiEnqueue(gpTopWindow->messageQueue, &tempMsg) ;
giPenRemoveFlag = 0;
ptControl = (TGuiControl *)g_dwActiveCtrlHandle;
// re-enable control
(ptControl->actionFun)(g_dwActiveCtrlHandle, PENREENTER, x, y) ;
// (ptControl->actionFun)(g_dwActiveCtrlHandle, PENDOWN, x, y) ;
break;
}
ptControl = (TGuiControl *)g_dwActiveCtrlHandle;
// 呼叫这个control的action callback function
(ptControl->actionFun)(g_dwActiveCtrlHandle, PENMOVE, x, y) ;
}
else
{
// PENROVE 只会送一次
if (giPenRemoveFlag==0)
{
tempMsg.messageType = CONTROL_EXIT;
tempMsg.x = x;
tempMsg.y = y;
tempMsg.handle = g_dwActiveCtrlHandle;
_guiEnqueue(gpTopWindow->messageQueue, &tempMsg) ;
giPenRemoveFlag = 1;
ptControl = (TGuiControl *)g_dwActiveCtrlHandle;
// 呼叫这个control的action callback function
// (ptControl->actionFun)(g_dwActiveCtrlHandle, PENROVE, x, y) ;
(ptControl->actionFun)(g_dwActiveCtrlHandle, PENREMOVE, x, y) ;
}
else if (giPenTrackFlag)
{
ptControl = (TGuiControl *)g_dwActiveCtrlHandle;
// 呼叫这个control的action callback function
// (ptControl->actionFun)(g_dwActiveCtrlHandle, PENROVE, x, y) ;
(ptControl->actionFun)(g_dwActiveCtrlHandle, PENREMOVE, x, y) ;
}
}
}
else
{
tempMsg.messageType=PENMOVE;
tempMsg.handle=(HNDL)gpTopWindow;
tempMsg.x=x;
tempMsg.y=y;
_guiEnqueue(gpTopWindow->messageQueue,&tempMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -