📄 uisw_kbd.c
字号:
// x,y: 笔点座标
//return:
// fail: NULL
// sucess: return sw_kbd's handle
/*********************************************************************/
void _guiSwKbd_Action(HNDL handle, WORD message, WORD x, WORD y)
{
TGuiSw_Kbd *pControl;
guiEnterWCS();
if(handle == NULL) // 检查数据指针
{
guiExitWCS();
return;
}
pControl=(TGuiSw_Kbd *)handle;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG) // 检查有效性
{
guiExitWCS();
return;
}
if(pControl->base.status & CONTROL_NOT_ACTIVE) // 检查活动状态
{
guiExitWCS();
return;
}
if( guiKbd_CheckType(pControl->base.style) != STATUS_OK) // 检查键盘的有效性
{
guiExitWCS();
return;
}
gpKbd_Info[pControl->base.style].actionFun(handle,message,x,y); // 调用相应键盘的处理函数
guiExitWCS();
}
/*********************************************************************/
//dest: 显示键盘
//para:
// handle: 键盘的handle值
//return:
// fail: STATUS_ERR
// sucess: STATUS_OK
/*********************************************************************/
STATUS _guiSwKbd_Show(HNDL handle)
{
TGuiSw_Kbd *pControl;
WORD type,width,height;
int paBmp;
guiEnterWCS();
if(handle == NULL) // 检查数据指针
{
guiExitWCS();
return STATUS_ERR;
}
pControl=(TGuiSw_Kbd *)handle;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG) // 检查控件的有效性
{
guiExitWCS();
return STATUS_ERR;
}
if(guiControl_IsVisible(handle) == FALSE) // 检查控件的可见性
{
guiExitWCS();
return STATUS_ERR;
}
type=pControl->base.style;
if( guiKbd_CheckType(type) != STATUS_OK) // 检查键盘的有效性
{
guiExitWCS();
return STATUS_ERR;
}
pControl->StartPos=0; // 复位有关参数
pControl->SelPos=-1;
pControl->Offset=0;
pControl->TotalNum=0;
pControl->HWR_Buf1_Num=0;
pControl->HWR_Buf2_Num=0;
pControl->InputStr[0]='\0';
pControl->HWR_Buf1[0]='\0';
pControl->HWR_Buf1[0]='\0';
pControl->First_Stroke1=-1;
pControl->First_Stroke2=-1;
guiKbd_GetBmp(type,&paBmp);
guiKbd_GetSize(type,&width,&height);
pControl->base.top=pControl->base.bottom-height+1; // 以左下角为标准调整键盘控件座标
pControl->base.right=pControl->base.left+width-1;
VportHandling(pControl->base.top-1); // 调整受影响的vport
guiPutImage(handle,0, 0, width, height,(BYTE *)paBmp); // 显示位图
gpKbd_Info[pControl->base.style].startFun(handle); // 开始一个新的键盘
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//dest: 删除键盘控件
//para:
// handle: 待删除控件的handle值
//return:
// fail: STATUS_ERR
// sucess: STATUS_OK
/*********************************************************************/
STATUS _guiSwKbd_Delete(HNDL handle)
{
TGuiSw_Kbd *pControl;
guiEnterWCS();
if(handle == NULL) // 检查数据指针
{
guiExitWCS();
return STATUS_ERR;
}
pControl=(TGuiSw_Kbd *)handle;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG) // 检查控件有效性
{
guiExitWCS();
return STATUS_ERR;
}
if(guiKbd_CheckType(pControl->base.style) == STATUS_OK)
gpKbd_Info[pControl->base.style].endFun(handle); // 结束键盘
pControl->base.checkFlag=0;
kernelFree((TGuiSw_Kbd *)handle); // 释放空间
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//dest: 切换到下一个键盘
//para:
// handle: 键盘控件的handle值
//return:
// fail: STATUS_ERR
// sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiSwKbd_SwitchToNext(HNDL handle)
{
TGuiSw_Kbd *pControl;
WORD oldType,newType;
guiEnterWCS();
if(handle == NULL) // 检查控件数据指针
{
guiExitWCS();
return STATUS_ERR;
}
pControl=(TGuiSw_Kbd *)handle;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR;
}
oldType=pControl->base.style;
if(guiKbd_GetNext(oldType,&newType) == STATUS_ERR) // 获取下一个键盘的编号
{
guiExitWCS();
return STATUS_ERR;
}
if(newType != oldType)
{
gpKbd_Info[oldType].endFun(handle); // 结束原来的键盘
guiControl_Clear(handle); // 清除原来的键盘显示区
pControl->base.style=newType; // 设置新键盘
_guiSwKbd_Show(handle); // 显示新键盘
}
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//dest: 切换到同类型的下一个键盘
//para:
// handle: 键盘控件的handle值
//return:
// fail: STATUS_ERR
// sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiSwKbd_SwitchToNextInType(HNDL handle)
{
TGuiSw_Kbd *pControl;
WORD oldType,newType;
guiEnterWCS();
if(handle == NULL) // 检查数据指针
{
guiExitWCS();
return STATUS_ERR;
}
pControl=(TGuiSw_Kbd *)handle;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG) // 检查控件有效性
{
guiExitWCS();
return STATUS_ERR;
}
oldType=pControl->base.style;
if(guiKbd_GetNextInType(oldType,&newType) == STATUS_ERR) // 获取同类型的下一个键盘编号
{
guiExitWCS();
return STATUS_ERR;
}
if(newType != oldType) // 更新为新键盘
{
gpKbd_Info[oldType].endFun(handle);
guiControl_Clear(handle);
pControl->base.style=newType;
_guiSwKbd_Show(handle);
}
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//dest: 切换到另外一个类型的键盘
//para:
// handle: 键盘控件的handle值
// bClass: 新的键盘类型
//return:
// fail: STATUS_ERR
// sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiSwKbd_SwitchClass(HNDL handle,BYTE bClass)
{
TGuiSw_Kbd *pControl;
WORD oldType,newType;
guiEnterWCS();
if(handle == NULL) // 检查数据指针
{
guiExitWCS();
return STATUS_ERR;
}
pControl=(TGuiSw_Kbd *)handle;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG) // 检查控件有效性
{
guiExitWCS();
return STATUS_ERR;
}
oldType=pControl->base.style;
if(guiKbd_GetType(bClass,&newType) == STATUS_ERR) // 获取新类型中的一个键盘
{
guiExitWCS();
return STATUS_ERR;
}
if(newType != oldType) // 更新为新键盘
{
gpKbd_Info[oldType].endFun(handle);
guiControl_Clear(handle);
pControl->base.style=newType;
_guiSwKbd_Show(handle);
}
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//dest: 设置到指定的键盘
//para:
// handle: 键盘控件的handle值
// type: 指定键盘的编号
//return:
// fail: STATUS_ERR
// sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiSwKbd_SetType(HNDL handle,WORD type)
{
TGuiSw_Kbd *pControl;
WORD oldType;
guiEnterWCS();
if(handle == NULL) // 检查数据指针
{
guiExitWCS();
return STATUS_ERR;
}
pControl=(TGuiSw_Kbd *)handle;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG) // 检查控件有效性
{
guiExitWCS();
return STATUS_ERR;
}
if(guiKbd_CheckType(type) == STATUS_ERR) // 检查新键盘的有效性
{
guiExitWCS();
return STATUS_ERR;
}
oldType=pControl->base.style;
if(oldType != type) // 更新为新键盘
{
gpKbd_Info[oldType].endFun(handle);
guiControl_Clear(handle);
pControl->base.style=type;
_guiSwKbd_Show(handle);
}
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//dest: 获取键盘的类型的编号
//para:
// handle: 键盘控件的handle值
// bClass: 当前键盘类型的存储地址
// type: 当前键盘编号的存储地址
//return:
// fail: STATUS_ERR
// sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiSwKbd_GetType(HNDL handle, BYTE *bClass, WORD *type)
{
TGuiSw_Kbd *pControl;
guiEnterWCS();
if(handle == NULL) // 检查数据指针
{
guiExitWCS();
return STATUS_ERR;
}
pControl=(TGuiSw_Kbd *)handle;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG) // 检查控件的有效性
{
guiExitWCS();
return STATUS_ERR;
}
*type=pControl->base.style; // 获取键盘编号
if(guiKbd_GetClass(*type,bClass) == STATUS_ERR) // 获取键盘类型
{
guiExitWCS();
return STATUS_ERR;
}
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//dest: 搜索笔点的位置在键盘上的区域代号
//para:
// tSwKbd_Coor: 键盘分区数据的指针
// x,y: 笔点位置(相对于键盘的左上角)
//return:
// -1: 没有点中有效区域
// 其它: 区域代号
/*********************************************************************/
DLL_EXP(int) guiSwKbd_SearchPos(TSwKbd_Coor const *tSwKbd_Coor, WORD x, WORD y)
{
int i=0;
while(tSwKbd_Coor[i].code != KEY_KBD_END) // KEY_KBD_END表示数据结束
{
if(x >= tSwKbd_Coor[i].left && x <= tSwKbd_Coor[i].right
&& y >= tSwKbd_Coor[i].top && y <= tSwKbd_Coor[i].bottom)
return i;
i++;
}
return -1;
}
/*********************************************************************/
//dest: 复位窗口中的键盘
//para:
// handle: 窗口的handle值
//return:
// 无
/*********************************************************************/
DLL_EXP(void) guiSwKbd_Reset(HNDL handle)
{
HNDL hControl;
TGuiSw_Kbd *pControl;
int iPos=0;
guiEnterWCS();
if(handle == NULL)
{
guiExitWCS();
return;
}
if(handle != (HNDL)gpTopWindow) // 只对顶层窗口进行处理
{
guiExitWCS();
return;
}
// 从窗口中搜索键盘控键
hControl=guiSearchControl_Type(handle,CONTROL_SWKBD,&iPos);
if(hControl == NULL)
{
guiExitWCS();
return;
}
pControl=(TGuiSw_Kbd *)hControl;
if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG) // 检查控件的有效性
{
guiExitWCS();
return;
}
pControl->base.actionFun(hControl,KBD_RESET,0,0); // 回调
guiExitWCS();
}
void VportHandling(WORD Kbd_topPos)
{
struct dLinkList *pList;
TGuiViewport *pControl;
int offset;
guiEnterWCS();
if(gpTopWindow == NULL) // 没有顶层窗口
{
guiExitWCS();
return;
}
if(gpTopWindow->controlList.back == 0) // 窗口中没有任何控件
{
guiExitWCS();
return;
}
pList=(struct dLinkList *)gpTopWindow->controlList.back;
while(pList)
{
pControl=(TGuiViewport *)pList->elementPointer; // 取出一个控件
if( pControl->base.type == CONTROL_VIEWPORT &&
guiControl_IsVisible((HNDL)pControl)) // 是否为viewport并且可见
{
if(pControl->base.style & VPORT_NONE_BORDER) //
offset=1;
else
offset=2;
if(pControl->base.bottom != Kbd_topPos-offset)
{
guiControl_Clear((HNDL)pControl);
pControl->base.bottom=Kbd_topPos-offset;
if(pControl->base.top > pControl->base.bottom)
pControl->base.top=pControl->base.bottom;
guiControl_SetLocation((HNDL)pControl,pControl->base.left,pControl->base.top,pControl->base.right,pControl->base.bottom);
}
}
pList=pList->back;
}
guiExitWCS();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -