📄 uicontrol.c
字号:
/*********************************************************************/
//para: control handle
//dest: judge the control's active status
//return:
//NOT ACTIVE: FALSE
//ACTIVE: TRUE
/*********************************************************************/
DLL_EXP(BOOL) guiControl_QueryIsActive(HNDL handle)
{
TGuiControl *pControl;
if(handle == NULL)
return FALSE;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return FALSE;
}
if(pControl->status & CONTROL_NOT_ACTIVE)
{
guiExitWCS();
return FALSE;
}
else
{
guiExitWCS();
return TRUE;
}
}
/*********************************************************************/
//para: control handle
//dest: judge the control visible status
//return:
//NOT VISIBLE: FALSE
//VISIBLE: TRUE
/*********************************************************************/
DLL_EXP(BOOL) guiControl_QueryIsVisible(HNDL handle)
{
TGuiControl *pControl;
if(handle == NULL)
return FALSE;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return FALSE;
}
if(pControl->status & CONTROL_NOT_VISIBLE)
{
guiExitWCS();
return FALSE;
}
else
{
guiExitWCS();
return TRUE;
}
}
/*********************************************************************/
//para: control handle and coordinate's pointer
//dest: get the control's corrdinate
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_QueryLocation(HNDL handle, short *left, short *top, short *right, short *bottom)
{
TGuiControl *pControl;
if(handle == NULL)
return STATUS_ERR;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR;
}
*left = pControl->left;
*right = pControl->right;
*top = pControl->top;
*bottom = pControl->bottom;
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//para: control handle
//dest: judge the control whether in a vport or not
//return:
//not in vport: NULL
//in vport: control handle
/*********************************************************************/
DLL_EXP(HNDL) guiControl_IsInVport(HNDL handle)
{
TGuiControl *pControl;
if(handle == NULL)
return NULL;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return NULL;
}
guiExitWCS();
return pControl->vportHandle;
}
/*********************************************************************/
//para: control handle and coordinate
//dest: set the control coordinate and show it
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_SetLocation(HNDL handle,short left,short top, short right, short bottom)
{
TGuiControl *pControl;
if(handle == NULL)
return STATUS_ERR;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR;
}
pControl->left=left;
pControl->top=top;
pControl->right=right;
pControl->bottom=bottom;
guiControl_Show(handle);
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//para: control handle
//dest: clear the control region
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_Clear(HNDL handle)
{
HNDL Container;
TGuiControl *pControl;
if(handle == NULL)
return STATUS_ERR;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR;
}
if( guiControl_IsVisible(handle) == FALSE )
{
guiExitWCS();
return STATUS_ERR;
}
Container=(pControl->container == NULL)?pControl->vportHandle:pControl->container;
guiClearBlock(Container,pControl->left,pControl->top,pControl->right,pControl->bottom,GUI_WHITE,0); //NOTE
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//para: window handle and control handle
//dest: remove the control from window's control list
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_Remove(HNDL hWin, HNDL hControl)
{
TGuiWindow *pWindow;
TGuiControl *pControl;
STATUS result;
if(hWin == NULL || hControl == NULL)
return STATUS_ERR;
guiEnterWCS();
pWindow=(TWindow*)(hWin);
pControl=(TGuiControl *)hControl;
if( pWindow->checkFlag != GUI_WIN_CHECK_FLAG ||
pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR;
}
result=guiRemoveControl(&(pWindow->controlList), hControl);
if(result == STATUS_OK)
pControl->container=NULL;
guiExitWCS();
return result;
}
/*********************************************************************/
//para: window handle and control handle
//dest: add the control to window control list
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_Add(HNDL hWin,HNDL handle)
{
TGuiWindow *pWindow;
TGuiControl *pControl;
if(hWin == NULL || handle == NULL)
return STATUS_ERR;
guiEnterWCS();
pWindow=(TGuiWindow*)hWin;
pControl=(TGuiControl *)handle;
if( pWindow->checkFlag != GUI_WIN_CHECK_FLAG ||
pControl->checkFlag != GUI_CONTROL_CHECK_FLAG )
{
guiExitWCS();
return STATUS_ERR;
}
if(pControl->container != NULL)
guiControl_Remove(pControl->container,handle);
else if(pControl->vportHandle != NULL)
guiViewport_RemoveControl(pControl->vportHandle, handle);
insertTo(&(pWindow->controlList),(void *)handle);
pControl->container=(HNDL)hWin;
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//para: control handle
//dest: show the control
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_Show(HNDL handle)
{
TGuiControl *pControl;
if(handle == NULL)
return STATUS_ERR;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR;
}
if(pControl->status & CONTROL_NOT_VISIBLE)
{
guiExitWCS();
return STATUS_ERR;
}
pControl->showFun(handle);
guiExitWCS();
return STATUS_OK;
}
/*********************************************************************/
//para: control handle
//dest: release the control's all resource
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_Delete(HNDL handle)
{
TGuiControl *pControl;
STATUS result;
if(handle == NULL)
return STATUS_ERR;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return STATUS_ERR;
}
if(pControl->container != NULL)
guiControl_Remove(pControl->container,handle);
else if(pControl->vportHandle != NULL)
guiViewport_RemoveControl(pControl->vportHandle,handle); //NOTE
result=pControl->delFun(handle);
guiExitWCS();
return result;
}
/*********************************************************************/
//para: control handle
//dest: judge the control whether visible or not in a visual region
//return:
//not in a visual region: FALSE
//in a visual region: TRUE
/*********************************************************************/
DLL_EXP(BOOL) guiControl_IsVisible(HNDL handle)
{
TGuiControl *pControl;
TGuiViewport *pViewport;
TGuiWindow *pWindow;
int height,width;
if(handle == NULL)
return FALSE;
guiEnterWCS();
pControl=(TGuiControl *)handle;
if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS();
return FALSE;
}
if(pControl->status & CONTROL_NOT_VISIBLE)
{
guiExitWCS();
return FALSE;
}
if(pControl->vportHandle != NULL)
{
pViewport = (TGuiViewport *)pControl->vportHandle;
if(pViewport->base.container != (HNDL)gpTopWindow)
{
guiExitWCS();
return FALSE;
}
width = pViewport->base.right-pViewport->base.left;
height = pViewport->base.bottom-pViewport->base.top;
if( pControl->left > pViewport->iCurrentLeft+width ||
pControl->right < pViewport->iCurrentLeft ||
pControl->top > pViewport->iCurrentTop+height ||
pControl->bottom < pViewport->iCurrentTop )
{
guiExitWCS();
return FALSE;
}
else
{
guiExitWCS();
return TRUE;
}
}
else if(pControl->container !=NULL)
{
if(pControl->container != (HNDL)gpTopWindow)
{
guiExitWCS();
return FALSE;
}
pWindow = (TGuiWindow *)pControl->container;
width = pWindow->right-pWindow->left;
height = pWindow->bottom-pWindow->top;
if( pControl->left < 0 || pControl->left > width ||
pControl->top < 0 || pControl->top > height )
{
guiExitWCS();
return FALSE;
}
else
{
guiExitWCS();
return TRUE;
}
}
else
{
guiExitWCS();
return FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -