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

📄 uickbtn.c

📁 嵌入工linux开发的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
}

/*********************************************************************/
//para: handle
//dest: get chkbtn's select status
//return:
//fail: FAILCHECKED
//sucess: ONCHECKED or FAILCHECKED
/*********************************************************************/
DLL_EXP(WORD) guiChkButton_GetValue( HNDL handle )
{
	struct tagGuiChkButton  *pControl;
	if(handle == NULL)
		return FAILCHECKED;
	guiEnterWCS();
	pControl=(struct tagGuiChkButton *)handle;
	if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS(); 
		return FAILCHECKED;
	}
	guiExitWCS(); 
	return pControl->fChecked;
}

/*********************************************************************/
//para: handle and chkbtn's caption string
//dest: set chkbtn's caption
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiChkButton_SetCaption( HNDL handle, const char *string)
{
	struct tagGuiChkButton  *pControl;
	if(handle == NULL) 
		return STATUS_ERR;
	guiEnterWCS();
	pControl=(struct tagGuiChkButton *)handle;
	if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS(); 
		return STATUS_ERR;
	}
	if(string == NULL)
		pControl->caption[0] = '\0';
	else
	{
		strncpy(pControl->caption,(char *)string,GUI_CHKBTN_CAPTION_SIZE);
		pControl->caption[GUI_CHKBTN_CAPTION_SIZE] = '\0';
	}
	//_chkbtn_paint(handle);
	guiChkButton_Show(handle);
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: chkbtn handle 
//dest: get chkbtn's caption
//return:
//fail: NULL
//sucess: chkbtn's caption'string pointer
/*********************************************************************/
DLL_EXP(char *) guiChkButton_GetCaption( HNDL handle )        
{
	struct tagGuiChkButton  *pControl;
	if(handle == NULL)
		return NULL;
	guiEnterWCS();
	pControl=(struct tagGuiChkButton *)handle;
	if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS(); 
		return NULL;
	}
	guiExitWCS();
	return (char *)(pControl->caption);             
}

/*********************************************************************/
//para: chkbtn handle 
//dest: delete chkbtn
//return:
//fail: 0
//free the group resource and the chkbtn resource:1
//only release the chkbtn resource:2
/*********************************************************************/
DLL_EXP(STATUS) guiChkButton_Delete( HNDL handle )
{
	struct tagGuiChkButton          *pControl;
	struct tagguiGroup		*pGroup;
	WORD   flag=0;
	if(handle == NULL)
		return flag;
	guiEnterWCS();
	pControl=(struct tagGuiChkButton *)handle;
	if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS();
		return flag;
	}
	flag=1;
	/******************************/
	/*为了释放管理组合框而使用的空间*/
	if(pControl->group != NULL)
	{
		pGroup = (struct tagguiGroup *)pControl->group;
		if(guiGroup_Remove((HNDL)pControl->group , handle) == STATUS_OK)
		{
			flag=2;
			kernelFree(pGroup);
		}
	}
	/*******************************/
	pControl->base.checkFlag=0;
	kernelFree((struct tagGuiChkButton *)pControl); 
	guiExitWCS();
	return flag;
}

/*********************************************************************/
//para: chkbtn handle 
//dest: show chkbtn
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiChkButton_Show( HNDL handle )
{
	struct tagGuiChkButton  *pControl;	
	if(handle == NULL)
		return STATUS_ERR;
	if(guiControl_IsVisible(handle) == FALSE)
		return STATUS_ERR;
	guiEnterWCS();
	pControl=(struct tagGuiChkButton *)handle;
	if(pControl->base.checkFlag != GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS(); 
		return STATUS_ERR;
	}
	_chkbtn_paint(handle);
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: void
//dest: create group,manage the chkbtn
//return:
//fail: NULL
//sucess: return the group handle
/*********************************************************************/
DLL_EXP(HNDL) guiGroup_Create( void )
{
	struct tagguiGroup *pGroup;
	guiEnterWCS();
	pGroup=(struct tagguiGroup *)kernelMalloc(sizeof(struct tagguiGroup));
	if(pGroup == NULL)
	{
		guiExitWCS();
		return NULL;
	}
	pGroup->head=NULL;
	pGroup->current=NULL;
	guiExitWCS();
	return (HNDL)pGroup;
}
/*********************************************************************/
//para: group handle ande chkbtn handle 
//dest: add chkbtn to group
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiGroup_Add( HNDL hGroup, HNDL hButton )
{
	struct tagGuiChkButton			*pControl;
	struct tagguiGroupItem	*pGroup_Item;
	struct tagguiGroup		*pGroup;
	if(hGroup == NULL || hButton == NULL)
		return STATUS_ERR;

	guiEnterWCS();
	pControl=(struct tagGuiChkButton *)hButton;
	if(pControl->group != NULL)
		guiGroup_Remove((HNDL)(pControl->group),hButton);

	pGroup=(struct tagguiGroup *)hGroup;
	pGroup_Item=(struct tagguiGroupItem *)kernelMalloc(sizeof(struct tagguiGroupItem));
	if(pGroup_Item == NULL)
	{
		guiExitWCS();
		return STATUS_ERR;
	}
	pControl->fChecked=OFFCHECKED;
	pControl->group=pGroup;
	pGroup_Item->button=pControl;
	pGroup_Item->prev=NULL;
	pGroup_Item->next=pGroup->head;
	if(pGroup->head != NULL)
		pGroup->head->prev = pGroup_Item;
	pGroup->head=pGroup_Item;
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: group handle
//dest: delete chkbtn and it's group 
//return:
//fail: STATUS_ERR
//sucess: STATUS_OK
/*********************************************************************/
DLL_EXP(STATUS) guiGroup_Delete( HNDL hGroup )
{
	struct tagguiGroup		*pGroup;
	struct tagguiGroupItem	*pTemp_Item,*pItem;
	if(hGroup == NULL)
		return STATUS_ERR;
	guiEnterWCS(); 
	pGroup = (struct tagguiGroup *)hGroup;
	pTemp_Item=pGroup->head;
	while(pTemp_Item)
	{
		pItem=pTemp_Item;
		pTemp_Item=pTemp_Item->next;
		pItem->button->group=NULL;
		kernelFree(pItem);
	}
	kernelFree(pGroup);
	guiExitWCS();
	return STATUS_OK;
}

/*********************************************************************/
//para: group handle and chkbtn handle
//dest: remove the chkbtn from the group list
//return:
//fail:-1
//if chkbtn is not in a group and remove sucess:0
//if chkbtn is in a group and remove sucess :1  
/*********************************************************************/
DLL_EXP(STATUS) guiGroup_Remove( HNDL hGroup, HNDL hButton )
{
	struct tagGuiChkButton			*pControl;
	struct tagguiGroupItem	*pGroup_Item;
	struct tagguiGroup		*pGroup;
	if(hGroup == NULL || hButton == NULL)
		return STATUS_ERR;
	guiEnterWCS();
	pControl=(struct tagGuiChkButton *)hButton;
	pGroup=(struct tagguiGroup *)hGroup;
	pGroup_Item=pGroup->head;
	while(pGroup_Item)
	{
		if(pGroup_Item->button == pControl)
		{
			if(pGroup_Item->prev == NULL)
				pGroup->head=pGroup_Item->next; 
			else
				pGroup_Item->prev->next=pGroup_Item->next;
			if(pGroup_Item->next != NULL)
				pGroup_Item->next->prev=pGroup_Item->prev;
			pControl->group=NULL;                          //is important
			if(pGroup->current == pGroup_Item)
				pGroup->current=NULL;
			kernelFree(pGroup_Item);
			break;
		}
		else
			pGroup_Item=pGroup_Item->next;
	}
	guiExitWCS();
	if(pGroup->head != NULL)
		return 1;
	else 
		return STATUS_OK;
}
/*********************************************************************/
//para: group handle
//dest: get which chkbtn is select in it's group
//return:
//fail or no: NULL
//sucess: return the select chkbtn handle
/*********************************************************************/
DLL_EXP(HNDL) guiGroup_GetCheck( HNDL hGroup )
{
	struct tagguiGroup	*pGroup;
	if(hGroup == NULL)
		return NULL;
	guiEnterWCS();
	pGroup=(struct tagguiGroup *)hGroup;
	if(pGroup->current == 0)
	{
		guiExitWCS();
		return NULL;
	}
	guiExitWCS();
	return (HNDL)(pGroup->current->button);
}

⌨️ 快捷键说明

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