📄 uibitmap.c
字号:
ptBitmap=(PTGUIBITMAP)handle;
if( ptBitmap->base.checkFlag != GUI_CONTROL_CHECK_FLAG)
return STATUS_ERR;
if(ptBitmap->base.style & BMP_TOGGLE)
Value = ptBitmap->bToggle_Check;
else return STATUS_ERR;
if(Value!=0&&Value!=1)
Value = STATUS_ERR;
return Value;
}
/********************************PRIVATE FUN>>*********************/
static int _guiBitmap_ShowString( HNDL handle )
{
PTGUIBITMAP ptBitmap;
unsigned short wi,wSTRlength;
unsigned short left=0,right=0,top=0,bottom=0;
unsigned short sx,sy,width,height;
char langType;
langType = guiQueryLanguageType();
guiEnterWCS() ;
if(handle == NULL)
{
guiExitWCS() ;
return STATUS_ERR;
}
ptBitmap=(PTGUIBITMAP)handle;
if(ptBitmap->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
guiExitWCS() ;
return STATUS_ERR;
}
// processCoordinateStart(handle);
left = 0;
right = ptBitmap->base.right-ptBitmap->base.left;
top = 0;
bottom = ptBitmap->base.bottom - ptBitmap->base.top;
// processCoordinateEnd(handle) ;
//if(ptBitmap->szCaption [0]== '\0')
if(ptBitmap->szCaption[langType][0]== '\0')
{
guiExitWCS() ;
return STATUS_ERR;
}
guiPushFont(guiGetFont()) ;
guiSetFont(ptBitmap->base.font) ;
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
// wSTRlength = guiGetStringWidth((char*)ptBitmap->szCaption) ;
wSTRlength = guiGetStringWidth((char*)ptBitmap->szCaption[langType]) ;
wi = guiGetCharHeight();
sy = top+ptBitmap->pic_top+height+2;
if(wSTRlength>(right-left))
sx = 1;
else
sx = getAlignCenter(left, right,wSTRlength);
// guiShowString(handle,(char *)ptBitmap->szCaption,sx,sy,FG_BLACK_BG_WHITE,
// FONT_TRANSPARENT);
guiShowString(handle,(char *)ptBitmap->szCaption[langType],sx,sy,FG_BLACK_BG_WHITE,
FONT_TRANSPARENT);
guiPopFont();
guiExitWCS() ;
return 1;
}
//---------------------------------------------------------------------------------------------------------------------
static int _guiBitmap_Action(HNDL handle , WORD Pen_Type, WORD x , WORD y)
{
PTGUIBITMAP ptBitmap;
TGuiMessage message;
unsigned short left=0,right=0,top=0,bottom=0;
unsigned short left1=0,right1=0,top1=0,bottom1=0;
unsigned short sx,sy,width,height;
if(handle == NULL)
return STATUS_ERR;
ptBitmap=(PTGUIBITMAP)handle;
if(ptBitmap->base.checkFlag!=GUI_CONTROL_CHECK_FLAG)
{
return STATUS_ERR;
}
if( ptBitmap->base.status & CONTROL_NOT_ACTIVE)
{
return STATUS_ERR;
}
if(ptBitmap->fg_image == NULL)
return STATUS_ERR;
message.handle = handle;
if(ptBitmap->base.style&BMP_WINCLOSE)
{
message.messageType= WIN_CLOSE;
message.handle = ptBitmap->base.container;
}
else
message.messageType=BITMAP_CLICK;
message.x=x;
message.y=y;
left = 0;
right = ptBitmap->base.right-ptBitmap->base.left;
top = 0;
bottom = ptBitmap->base.bottom - ptBitmap->base.top;
switch(Pen_Type)
{
case PENDOWN:
if(ptBitmap->base.style&BMP_BITMAP)
break;
guiClearBlock(handle, left,top,right,bottom,ptBitmap->bColor,REPLACE_STYLE);
if( !(ptBitmap->base.style&BMP_NON_BUTTON) && !(ptBitmap->base.style&BMP_TOGGLE) && !(ptBitmap->base.style&BMP_DIMAGE))
{
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->fg_image);
_guiBitmap_ShowString(handle );
guiInvertRect (handle,left,top,right,bottom);
}
else if(ptBitmap->base.style&BMP_DIMAGE&&!(ptBitmap->base.style&BMP_TOGGLE))
{
width = guiGetImageWidth(ptBitmap->bg_image);
height = guiGetImageHeight(ptBitmap->bg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->bg_image);
_guiBitmap_ShowString(handle ) ;
}
else if(ptBitmap->base.style&BMP_TOGGLE)
{
if(ptBitmap->bToggle_Check == TOGGLE_OFFCHECKED )
{
if(ptBitmap->base.style&BMP_DIMAGE)
{
width = guiGetImageWidth(ptBitmap->bg_image);
height = guiGetImageHeight(ptBitmap->bg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->bg_image);
_guiBitmap_ShowString(handle ) ;
}
else
{
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->fg_image);
_guiBitmap_ShowString(handle );
guiInvertRect (handle,left,top,right-left+1,bottom-top+1);
}
}
else
{
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->fg_image);
_guiBitmap_ShowString(handle );
}
}
break;
case PENUP:
guiClearBlock(handle, left,top,right,bottom,ptBitmap->bColor,REPLACE_STYLE);
if(ptBitmap->base.style&BMP_TOGGLE)
{
if(ptBitmap->bToggle_Check == TOGGLE_OFFCHECKED )
ptBitmap->bToggle_Check = TOGGLE_ONCHECKED;
else
ptBitmap->bToggle_Check = TOGGLE_OFFCHECKED;
if(ptBitmap->bToggle_Check == TOGGLE_ONCHECKED )
{
if(ptBitmap->base.style&BMP_DIMAGE)
{
width = guiGetImageWidth(ptBitmap->bg_image);
height = guiGetImageHeight(ptBitmap->bg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->bg_image);
_guiBitmap_ShowString(handle ) ;
}
else
{
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->fg_image);
_guiBitmap_ShowString(handle );
guiInvertRect (handle,left,top,right,bottom);
}
}
else
{
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->fg_image);
_guiBitmap_ShowString(handle );
}
}
else // if(ptBitmap->base.style==BMP_BITMAP)
{
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->fg_image);
_guiBitmap_ShowString(handle );
}
guiEnqueue(gpTopWindow->messageQueue,&message);
guiPenSound();
break;
case PENROVE:
guiClearBlock(handle, left,top,right,bottom,ptBitmap->bColor,REPLACE_STYLE);
if(ptBitmap->base.style&BMP_TOGGLE && ptBitmap->bToggle_Check == TOGGLE_ONCHECKED )
{
if(ptBitmap->base.style&BMP_DIMAGE)
{
width = guiGetImageWidth(ptBitmap->bg_image);
height = guiGetImageHeight(ptBitmap->bg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->bg_image);
_guiBitmap_ShowString(handle ) ;
}
else
{
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->fg_image);
_guiBitmap_ShowString(handle );
guiInvertRect (handle,left,top,right,bottom);
}
}
else
{
width = guiGetImageWidth(ptBitmap->fg_image);
height = guiGetImageHeight(ptBitmap->fg_image);
if(ptBitmap->szCaption [0] != '\0')
{
sy = top+ptBitmap->pic_top;
sx = left+ptBitmap->pic_left;
}
else
{
sx = left+(right -left+1 - width)/2;
sy = top+(bottom - top +1 - height)/2;
}
guiPutImage(handle,sx,sy,sx+width,sy+height,ptBitmap->fg_image);
_guiBitmap_ShowString(handle );
}
break;
default : break;
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -