⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uicontrol.c

📁 嵌入工linux开发的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*********************************************************************/
//	文 件 名:	uiControl.cpp
//	程序说明:	GUI控件基本功能
//	程序设计:	党德华
//				2001.10.19		设计完成		说明文档:R004-S208-0001
//				2002.02.02		增加guiSearchControl_Type函数	童湘彪
//	程序审查:	宋军霞
//				2002.01.22		审查完成		说明文档:R004-S208-0001
//				2002.02.04		审查guiSearchControl_Type函数
//	项目编号:	R004-S208
//	版	  本:	V1.0
//	版    权:	Reality Plus Technology (ShenZhen) Co.,Ltd.
/*********************************************************************/

#include <uiWnd.h>

/*********************************************************************/
//para:	
//	hWnd	窗口句柄
//	type	控件类型
//	pPos	开始位置
//dest:		从窗口中的指定位置开始搜索指定类型的控件
//return:
//	not find: NULL
//	find:     control handle
/*********************************************************************/
DLL_EXP(HNDL) guiSearchControl_Type(HNDL hWnd,short type,int *pPos)
{
	int i;

	TGuiWindow *pWnd;
	TGuiControl *pCtrl=NULL;
	struct dLinkList *pList;

	guiEnterWCS();
	pWnd = (TGuiWindow *)hWnd;
	if(pWnd->checkFlag!=GUI_WIN_CHECK_FLAG)
	{
		guiExitWCS();
		return NULL;
	}

	pList=pWnd->controlList.back;

	//get start position
	for(i=0;i<*pPos;i++)
	{
		if(pList==NULL)
			break;
		pList=pList->back;
	}

	//search
	while(pList)
	{
		pCtrl=(TGuiControl *)pList->elementPointer;
		if(pCtrl->type==type)
			break;
		*pPos=*pPos+1;
		pList=pList->back;
	}

	guiExitWCS();
	return (HNDL)pCtrl;
}

/*********************************************************************/
//para: control list and pen's coordinate
//dest: search the control from the pen's coordinate
//return:
//not find: NULL
//find:     control handle
/*********************************************************************/
DLL_EXP(HNDL) guiSearchControl( struct dLinkList *head, short x, short y )
{
	int    flag=0;
	struct dLinkList *pList;
	TGuiControl      *pControl;
	
	if(head->back == 0)
		return NULL;			//链表中没有控件

	pList=(struct dLinkList *)head->back;
	while(pList)
	{
		pControl=(TGuiControl *)(pList->elementPointer);
		if( x<pControl->left || x>pControl->right || 
			y<pControl->top  || y>pControl->bottom)
		{
			pList=pList->back;
			continue;
		}
		else if(pControl->status & CONTROL_NOT_ACTIVE)
		{
			pList=pList->back;
			continue;
		}
		else
		{
			flag=1;
			break;
		}
	}
	if(flag != 1)
		return NULL;
	else
		return (HNDL)pControl;
}



/*********************************************************************/
//para: control list and pen's coordinate
//dest: search the control from the pen's coordinate
//return:
//not find: NULL
//find:     control handle
/*********************************************************************/
DLL_EXP(HNDL) guiSearchScrollControl( struct dLinkList *head)
{
	int    flag=0;
	struct dLinkList *pList;
	TGuiControl      *pControl;
	WORD   type;
	
	if(head->back == 0)
		return NULL;			//链表中没有控件

	pList=(struct dLinkList *)head->back;
	while(pList)
	{
		pControl=(TGuiControl *)(pList->elementPointer);
//		if( x<pControl->left || x>pControl->right || 
//			y<pControl->top  || y>pControl->bottom)
		type = pControl->type;
		if((type!=CONTROL_LISTBOX)&&(type!=CONTROL_TEXTFIELD)&&(type!=CONTROL_VIEWPORT))
		{
			pList=pList->back;
			continue;
		}
		else if(pControl->status & CONTROL_NOT_ACTIVE)
		{
			pList=pList->back;
			continue;
		}
		else
		{
			flag=1;
			break;
		}
	}
	if(flag != 1)
		return NULL;
	else
		return (HNDL)pControl;
}

/*********************************************************************/
//para: control list head and control handle which wanted to be needed
//dest: delete the control handle from list
//return:
//not find: STATUS_ERR
//find:     STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiRemoveControl(struct dLinkList* head, HNDL handle)
{
	int flag=0;
	struct dLinkList *pList;

	if(head->back == 0)
		return STATUS_ERR;		//链表中没有控件

	if(handle == NULL)
		return STATUS_ERR;

	pList=(struct dLinkList *)head->back;
	while(pList)
	{
		if(pList->elementPointer == (void *)handle)
		{
			flag=1;
			break;
		}
		pList=pList->back;
	}

	if(flag == 1)
	{
		removeFrom(pList);
		return STATUS_OK;
	}
    else
		return STATUS_ERR;
}

/*********************************************************************/
//para: control handle
//dest: enable the control
//return:
//fail: 	STATUS_ERR
//sucess:   STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_Enable(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;
	}

	pControl->status &= ~CONTROL_NOT_ACTIVE;
	guiExitWCS();

	return STATUS_OK;
}

/*********************************************************************/
//para: control handle
//dest: disable the control
//return:
//fail: 	STATUS_ERR
//sucess:   STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_Disable(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;
	}

	pControl->status |= CONTROL_NOT_ACTIVE;
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: control handle
//dest: visible the control and show it
//return:
//fail: 	STATUS_ERR
//sucess:   STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_SetVisible(HNDL handle)  
{
	TGuiControl *pControl;

	if(handle == NULL)
		return STATUS_ERR;

	guiEnterWCS();
	pControl=(struct tagGuiControl *)handle;
	if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS();
		return STATUS_ERR;
	}

	pControl->status &= ~CONTROL_NOT_VISIBLE;
	guiControl_Show(handle);
	guiExitWCS();

	return STATUS_OK;
}

/*********************************************************************/
//para: control handle
//dest: invisible the control
//return:
//fail: 	STATUS_ERR
//sucess:   STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_DisVisible(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;
	}

	pControl->status |= CONTROL_NOT_VISIBLE;
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: control handle and style
//dest: set new style and show it
//return:
//fail: 	STATUS_ERR
//sucess:   STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_SetStyle(HNDL handle, WORD style)
{
	TGuiControl *pControl;

	if(handle == NULL)
		return STATUS_ERR;

	guiEnterWCS();
	pControl=(TGuiControl *)handle;
	if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS();
		return STATUS_ERR;
	}

	pControl->style = style;
	guiControl_Show(handle);
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: control handle
//dest: the control style's pointer
//return:
//fail: 	STATUS_ERR
//sucess:   STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_GetStyle(HNDL handle, WORD *style)
{
	TGuiControl *pControl;

	if(handle == NULL)
		return STATUS_ERR;

	guiEnterWCS();
	pControl=(TGuiControl *)handle;
	if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS();
		return STATUS_ERR;
	}

	*style=pControl->style;
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: control handle and new font
//dest: set control font and show it
//return:
//fail: 	STATUS_ERR
//sucess:   STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_SetFont(HNDL handle, BYTE font)
{
	TGuiControl *pControl;

	if(handle == NULL)
		return STATUS_ERR;

	guiEnterWCS();
	pControl=(struct tagGuiControl *)handle;
	if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS();
		return STATUS_ERR;
	}

	pControl->font = font;
	guiControl_Show(handle);
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: control handle and font pointer
//dest: get control font
//return:
//fail: 	STATUS_ERR
//sucess:   STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiControl_GetFont(HNDL handle, BYTE *font)
{
	TGuiControl *pControl;

	if(handle == NULL)
		return STATUS_ERR;

	guiEnterWCS();
	pControl=(TGuiControl *)handle;
	if(pControl->checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS();
		return STATUS_ERR;
	}

	*font=pControl->font;   
	guiExitWCS();
	return STATUS_OK;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -