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

📄 uiselector.c

📁 一个PDA GUI系统的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	ptSelector->m_Speed =(short)nSpeed;
    
	guiExitWCS();
	return STATUS_OK;
	
}
/********************************PRIVATE FUN>>*********************/
static int  _guiSelector_Paint( HNDL handle )
{
	TGUISELECTOR *ptSelector;
    char         *pString;  
    unsigned short sx=0,sy=0,Wi,Hi;
    unsigned short left=0,right=0,top=0,bottom=0;
    unsigned short width,height;
    
    if(handle == NULL)
    {       
		return STATUS_ERR; 
    }
    guiEnterWCS() ;
    if(!guiControl_IsVisible(handle))
    {
        guiExitWCS() ;
		return STATUS_ERR; 
    }
    ptSelector=(TGUISELECTOR *)handle; 
	
    if(ptSelector->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
	{
		guiExitWCS();
		return STATUS_ERR;
	}    
	
    left = 0;
    right = ptSelector->base.right-ptSelector->base.left;
    top = 0;
    bottom = ptSelector->base.bottom-ptSelector->base.top;      
	
    guiPushFont(guiGetFont()) ;
    guiSetFont(ptSelector->base.font) ;
	
	
    guiClearBlock(handle, left,top,right,bottom,GUI_WHITE,REPLACE_STYLE); 
	
    if(!(ptSelector->base.style&SELECTOR_VERTICAL))
    {
        if(!(ptSelector->base.style & SELECTOR_3DMODE))
        {
            width = guiGetImageWidth(icon_Gui_Sel_Left2D); 
            height = guiGetImageHeight(icon_Gui_Sel_Left2D); 
			
            sy = getAlignCenter(top, bottom, height);               
            guiPutImage(handle,left,sy,left+width,sy+height-1,icon_Gui_Sel_Left2D);
            guiPutImage(handle,right+1-width,sy,right+1,sy+height-1,icon_Gui_Sel_Right2D);
        }
        else
        {
            width = guiGetImageWidth(icon_Gui_Sel_Left); 
            height = guiGetImageHeight(icon_Gui_Sel_Left);    
            sy = (top+bottom+1-height)/2; 
			
            guiClearBlock(handle,left,top,left+width,bottom,GUI_LIGHTGRAY,REPLACE_STYLE);
            guiClearBlock(handle,right-width,top,right,bottom,GUI_LIGHTGRAY,REPLACE_STYLE);
			
            guiPutImage(handle,left,sy,left+width,sy+height-1,icon_Gui_Sel_Left);
            guiPutImage(handle,right-width,sy,right,sy+height-1,icon_Gui_Sel_Right);
			
            guiDrawLine (handle,left, top,left+width, top,GUI_LIGHTGRAY, GUI_SOLID );
            guiDrawLine (handle,left,top,left,bottom, GUI_LIGHTGRAY,GUI_SOLID );
            guiDrawLine (handle,left+width,top,left+width,bottom,GUI_BLACK, GUI_SOLID);
            guiDrawLine (handle,left,bottom,left+width,bottom,GUI_BLACK, GUI_SOLID );  
			
            guiDrawLine (handle,right-width, top,right, top,GUI_LIGHTGRAY, GUI_SOLID );
            guiDrawLine (handle,right-width,top,right-width,bottom, GUI_LIGHTGRAY,GUI_SOLID );
            guiDrawLine (handle,right,top,right,bottom,GUI_BLACK, GUI_SOLID);
            guiDrawLine (handle,right-width,bottom,right,bottom,GUI_BLACK, GUI_SOLID );
        }  
        pString = guiSelector_GetItem( handle,ptSelector->m_Selected);
        if(pString ==NULL || pString[0] == '\0')
        {
            guiPopFont();			 
            guiExitWCS() ;	
			return STATUS_ERR;
        }   
		
        Hi = guiGetCharHeight();
        Wi = guiGetStringWidth((char *)pString);
        sy = getAlignCenter(top, bottom, Hi); 
        sx = getAlignCenter(left+width, right-width, Wi)+1;            
        guiShowString(handle,(char *)pString, sx, sy,FG_BLACK_BG_WHITE,FONT_TRANSPARENT);
	}
	else
	{
        if(!(ptSelector->base.style & SELECTOR_3DMODE))
        {
            width = guiGetImageWidth(icon_Gui_Sel_Up2D); 
            height = guiGetImageHeight(icon_Gui_Sel_Up2D); 
			
            sx = getAlignCenter(left, right, width);               
            guiPutImage(handle,sx,top,sx+width,top+height,icon_Gui_Sel_Up2D);
            guiPutImage(handle,sx,bottom-height,sx+width-1,bottom,icon_Gui_Sel_Down2D);
		}
		else
		{
            width = guiGetImageWidth(icon_Gui_Sel_Up); 
            height = guiGetImageHeight(icon_Gui_Sel_Up);   
            sx = getAlignCenter(left, right, width);  
			
            guiClearBlock(handle,left,top,right,top+height,GUI_LIGHTGRAY,REPLACE_STYLE);
            guiClearBlock(handle,left,bottom-height,right,bottom,GUI_LIGHTGRAY,REPLACE_STYLE);
			
            guiPutImage(handle,sx,top,sx+width,top+height,icon_Gui_Sel_Up);
            guiPutImage(handle,sx,bottom-height,sx+width-1,bottom,icon_Gui_Sel_Down);
			
            guiDrawLine (handle,left, top,right, top,GUI_LIGHTGRAY, GUI_SOLID );
            guiDrawLine (handle,left,top,left,top+height, GUI_LIGHTGRAY,GUI_SOLID );
            guiDrawLine (handle,right,top,right,top+height,GUI_BLACK, GUI_SOLID);
            guiDrawLine (handle,left,top+height,right,top+height,GUI_BLACK, GUI_SOLID );  
			
            guiDrawLine (handle,left, bottom-height,right, bottom-height,GUI_LIGHTGRAY, GUI_SOLID );
            guiDrawLine (handle,left,bottom-height,left,bottom, GUI_LIGHTGRAY,GUI_SOLID );
            guiDrawLine (handle,right,bottom-height,right,bottom,GUI_BLACK, GUI_SOLID);
            guiDrawLine (handle,left,bottom,right,bottom,GUI_BLACK, GUI_SOLID );
			
		}
        pString = guiSelector_GetItem( handle,ptSelector->m_Selected);
        if(pString ==NULL || pString[0] == '\0')
        {
            guiPopFont();			 
            guiExitWCS() ;
			return STATUS_ERR;
        }   
		
        Hi = guiGetCharHeight();
        Wi = guiGetStringWidth((char *)pString);
        sy = getAlignCenter(top, bottom, Hi); 
        sx = getAlignCenter(left, right, Wi);            
        guiShowString(handle,(char *)pString, sx, sy,FG_BLACK_BG_WHITE,FONT_TRANSPARENT);
	}
	guiPopFont();		 
	guiExitWCS() ;
	return 1;
}

//==========================================================
static int _guiSelector_Action(HNDL handle , WORD Pen_Type, WORD x , WORD y)
{
	TGUISELECTOR *ptSelector;	
	TGuiMessage        tMessage;
	unsigned short left=0,right=0,top=0,bottom=0;
	unsigned short width,height;
	
	if(handle == NULL) 
		return STATUS_ERR;
	ptSelector=(TGUISELECTOR *)handle;   
	if(ptSelector->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
	{	
		return STATUS_ERR;
	}
    if(ptSelector->base.status & CONTROL_NOT_ACTIVE)
    {          
		return STATUS_ERR;
    }
	tMessage.handle = handle;
	tMessage.messageType = SELECTOR_CLICK;
	tMessage.x=ptSelector->m_Selected;
	tMessage.y=0;
	
    // processCoordinateStart(handle);
    left = 0;
    right = ptSelector->base.right-ptSelector->base.left;
    top = 0;
    bottom = ptSelector->base.bottom-ptSelector->base.top;
	// processCoordinateEnd(handle) ;
	
    if(!(ptSelector->base.style&SELECTOR_VERTICAL))
    {
        if(!(ptSelector->base.style & SELECTOR_3DMODE))
        {
            width = guiGetImageWidth(icon_Gui_Sel_Left2D); 
            height = guiGetImageHeight(icon_Gui_Sel_Left2D);
        }
        else
        {
            width = guiGetImageWidth(icon_Gui_Sel_Left); 
            height = guiGetImageHeight(icon_Gui_Sel_Left);
        }
    }
    else
    {        
        if(!(ptSelector->base.style & SELECTOR_3DMODE))
        {
            width = guiGetImageWidth(icon_Gui_Sel_Up2D); 
            height = guiGetImageHeight(icon_Gui_Sel_Up2D);
        }
        else
        {
            width = guiGetImageWidth(icon_Gui_Sel_Up); 
            height = guiGetImageHeight(icon_Gui_Sel_Up);
        }
    }
	
    switch(Pen_Type)
    {        
	case PENDOWN:
		if(!(ptSelector->base.style&SELECTOR_VERTICAL))
		{
			if( x>= ptSelector->base.left && x<= ( ptSelector->base.left + width+2) 
				&& y>= ptSelector->base.top &&y<=( ptSelector->base.bottom))
			{                     
				if(!(ptSelector->base.style & SELECTOR_3DMODE))
					guiInvertRect (handle,left,top+(bottom-top+1-height)/2,left+width,top+(bottom-top+1-height)/2+height);
				else
				{
					guiDrawLine (handle,left, top,left+width, top,GUI_BLACK, GUI_SOLID );
					guiDrawLine (handle,left,top,left,bottom, GUI_BLACK,GUI_SOLID );
					guiDrawLine (handle,left+width,top,left+width,bottom,GUI_LIGHTGRAY, GUI_SOLID);
					guiDrawLine (handle,left,bottom,left+width,bottom,GUI_LIGHTGRAY, GUI_SOLID );                                  
				}
			}
			else if( x>=( ptSelector->base.right - width-2) && x<= ( ptSelector->base.right ) 
				&& y>= ptSelector->base.top &&y<=( ptSelector->base.bottom))               
			{                            
				if(!(ptSelector->base.style & SELECTOR_3DMODE))
					guiInvertRect (handle,right-width,top+(bottom-top+1-height)/2,right,top+(bottom-top+1-height)/2+height);
				else
				{
					guiDrawLine (handle,right-width, top,right, top,GUI_BLACK, GUI_SOLID );
					guiDrawLine (handle,right-width,top,right-width,bottom, GUI_BLACK,GUI_SOLID );
					guiDrawLine (handle,right,top,right,bottom,GUI_LIGHTGRAY, GUI_SOLID);
					guiDrawLine (handle,right-width,bottom,right,bottom,GUI_LIGHTGRAY, GUI_SOLID );
					
				}
			}
			else break;
		}
		else
		{
			if( y>= ptSelector->base.top && y<= ( ptSelector->base.top + height+2) 
				&& x>= ptSelector->base.left &&x<=( ptSelector->base.right))
			{                     
				if(!(ptSelector->base.style & SELECTOR_3DMODE))
					guiInvertRect (handle,left+(right-left-width)/2,top,left+(right-left-width)/2+width,top+height);
				else
				{
					guiDrawLine (handle,left, top,right, top,GUI_BLACK, GUI_SOLID );
					guiDrawLine (handle,left,top,left,top+height, GUI_BLACK,GUI_SOLID );
					guiDrawLine (handle,right,top,right,top+height,GUI_LIGHTGRAY, GUI_SOLID);
					guiDrawLine (handle,left,top+height,right,top+height,GUI_LIGHTGRAY, GUI_SOLID );                                 
				}
			}
			else if( y>=( ptSelector->base.bottom - height-2) && y<= ( ptSelector->base.bottom ) 
				&& x>= ptSelector->base.left &&x<=( ptSelector->base.right))               
			{                            
				if(!(ptSelector->base.style & SELECTOR_3DMODE))
					guiInvertRect (handle,left+(right-left-width)/2,bottom-height-1,left+(right-left-width)/2+width,bottom);
				else
				{
					guiDrawLine (handle,left, bottom-height,right, bottom-height,GUI_BLACK, GUI_SOLID );
					guiDrawLine (handle,left,bottom-height,left,bottom, GUI_BLACK,GUI_SOLID );
					guiDrawLine (handle,right,bottom-height,right,bottom,GUI_LIGHTGRAY, GUI_SOLID);
					guiDrawLine (handle,left,bottom,right,bottom,GUI_LIGHTGRAY, GUI_SOLID );                                                          
				}
			}
			else break;
		}                                             
		break;
		
	case PENUP:
		if(!(ptSelector->base.style&SELECTOR_VERTICAL))
		{
			if( x>= ptSelector->base.left && x<= ( ptSelector->base.left + width+2) 
				&& y>= ptSelector->base.top &&y<=( ptSelector->base.bottom))
			{              
				if(ptSelector->m_Selected == 0)
				{
					if(ptSelector->base.style&SELECTOR_ISLOOP)
						ptSelector->m_Selected = ptSelector->m_ItemCount-1;					
				}
				else if((ptSelector->m_Selected-ptSelector->m_Speed)>=0)
				{
					ptSelector->m_Selected -= ptSelector->m_Speed;                                
				}
				tMessage.y = 0;				
			}
			else if( x>=( ptSelector->base.right - width-2) && x<= ( ptSelector->base.right ) 
				&& y>= ptSelector->base.top &&y<=( ptSelector->base.bottom))               
			{
				if(ptSelector->m_Selected == (ptSelector->m_ItemCount-1))
				{
					if(ptSelector->base.style&SELECTOR_ISLOOP)
						ptSelector->m_Selected = 0;					
				}
				else if((ptSelector->m_Selected+ptSelector->m_Speed)<=(ptSelector->m_ItemCount-1))
				{
					ptSelector->m_Selected += ptSelector->m_Speed ;					
				}
				tMessage.y = 1;				
			}
			else break;
		}
		else //SELECTOR_VERTICAL style
		{
			if( y>=( ptSelector->base.bottom - height-2) && y<= ( ptSelector->base.bottom ) 
				&& x>= ptSelector->base.left &&x<=( ptSelector->base.right))     
			{              
				if(ptSelector->m_Selected == 0)
				{
					if(ptSelector->base.style&SELECTOR_ISLOOP)
						ptSelector->m_Selected = ptSelector->m_ItemCount-1;					
				}
				else if((ptSelector->m_Selected-ptSelector->m_Speed)>=0)
				{
					ptSelector->m_Selected -= ptSelector->m_Speed;                                
				}				
				tMessage.y = 0;				
			}
			else if( y>= ptSelector->base.top && y<= ( ptSelector->base.top + height+2) 
				&& x>= ptSelector->base.left &&x<=( ptSelector->base.right))
				
			{
				if(ptSelector->m_Selected == (ptSelector->m_ItemCount-1))
				{
					if(ptSelector->base.style&SELECTOR_ISLOOP)
						ptSelector->m_Selected = 0;					
				}
				else if((ptSelector->m_Selected+ptSelector->m_Speed)<=(ptSelector->m_ItemCount-1))
				{
					ptSelector->m_Selected += ptSelector->m_Speed ;					
				}
				tMessage.y = 1;				
			}
			else break;
			
		}
		_guiSelector_Paint( handle);                
		guiEnqueue(gpTopWindow->messageQueue,&tMessage);
		guiPenSound();
		break;
		
	default :
		break;
		
	case PENROVE:
		if(!(ptSelector->base.style&SELECTOR_VERTICAL))
		{
			if(x>=ptSelector->base.left && x<= ( ptSelector->base.left + width+2)
				&& y>= ptSelector->base.top &&y<=( ptSelector->base.bottom))                                  
			{       
				
				break;
			}
			else if( x>=( ptSelector->base.right - width-2) && x<= ( ptSelector->base.right ) 
				&& y>= ptSelector->base.top &&y<=( ptSelector->base.bottom))               
			{                           
				
				break;
			}
			
		}
		else
		{
			if( y>= ptSelector->base.top && y<= ( ptSelector->base.top + height+2) 
				&& x>= ptSelector->base.left &&x<=( ptSelector->base.right))
			{                     
				
				break;
			}
			else if( y>=( ptSelector->base.bottom - height-2) && y<= ( ptSelector->base.bottom ) 
				&& x>= ptSelector->base.left &&x<=( ptSelector->base.right))               
			{                         
				
				break;
			}
			
		}                            
		_guiSelector_Paint( handle);           	
		break;
		
	case PENMOVE:
		if(!(ptSelector->base.style&SELECTOR_VERTICAL))
		{
			if(x<( ptSelector->base.left + width+2) || x> ( ptSelector->base.right - width-2)
				|| y< ptSelector->base.top ||y>( ptSelector->base.bottom))                                  
			{       
				
				break;
			}         
			
		}
		else
		{
			if( y< ( ptSelector->base.top + height+2)  || y> ( ptSelector->base.bottom - height-2) 
				|| x< ptSelector->base.left ||x>( ptSelector->base.right))
			{                    
				
				break;
			}                       
			
		}  
		_guiSelector_Paint( handle);           	
		break;
    }   
	return 1;
}

/***************************************************************************
****************************************************************************
****************************************************************************/

⌨️ 快捷键说明

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