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

📄 guicallback.c

📁 mtk wap和mms代码。。适应mtk 25。26平台
💻 C
📖 第 1 页 / 共 5 页
字号:
                {
                    /*
                    ** When y = ty1, x = tx1
                    ** When y = ty1 - 1, y = tx1 + 1.
                    */
                    ty1 = y2 - DIV_CEILING((tx1 - x2) * dy, dx);
                    ty1 -= ((twody - ((y2 - ty1) * twodx + dy) % twody) + 
                        twodx - 1) / twodx - 1;
                }
                else
                {
                    /*
                    ** When y = ty1, x = tx1
                    ** When y = ty1 - 1, y = tx1 + 1.
                    */
                    ty1 = y1 + DIV_CEILING((x1 - tx1) * dy, dx);
                    ty1 -= (((ty1 - y1) * twodx + dy) % twody) / twodx;
                }

                if (ty1 > ty2 || ty1 >= pClipRect->y2)
                    return LINE_NONE;
            }
            
            if (ty1 < pClipRect->y1)
            {
                ty1 = pClipRect->y1;
                tx1 = x1 - DIV_CEILING((ty1 - y1) * dx, dy);

                if (ty1 > ty2 || tx1 < pClipRect->x1)
                    return LINE_NONE;
            }

            if (tx2 < pClipRect->x1)
            {
                tx2 = pClipRect->x1;
                if (reverse)
                {
                    /*
                    ** When y = ty2, x = tx2
                    ** When y = ty2 + 1, y = tx2 - 1.
                    */
                    ty2 = y2 - DIV_CEILING((tx2 - x2) * dy, dx);
                    ty2 += (((y2 - ty2) * twodx + dy) % twody) / twodx;
                }
                else
                {
                    /*
                    ** When y = ty2, x = tx2
                    ** When y = ty2 + 1, y = tx2 - 1.
                    */
                    ty2 = y1 + DIV_CEILING((x1 - tx2) * dy, dx);
                    ty2 += ((twody - ((ty2 - y1) * twodx + dy) % twody) + 
                        twodx - 1) / twodx - 1;
                }

                if (ty1 > ty2 || ty2 < pClipRect->y1)
                    return LINE_NONE;
            }

            if (ty2 >= pClipRect->y2)
            {
                ty2 = pClipRect->y2 - 1;
                tx2 = x1 - DIV_CEILING((ty2 - y1) * dx, dy);

                if (ty1 > ty2 || tx2 >= pClipRect->x2)
                    return LINE_NONE;
            }
        }

        if (reverse)
        {
            pLineDraw->start_x   = tx2;
            pLineDraw->start_y   = ty2;
            pLineDraw->end_x     = tx1;
            pLineDraw->end_y     = ty1;
            /* calculate the cliped points number
            */
            pLineDraw->cliped    = y2 - ty2;

            /* The end point of the origin line is not cliped and should not
            ** be drawn.
            */
            /* 
            ** If the left of the line cliped is only the last point, we can't
            ** draw the line at all.
            */
            if (ty1 == pLineData->y2)
            {
                if (ty1 == ty2)
                    return LINE_NONE;

                pLineDraw->end_y ++;
            }
        }
        else
        {
            pLineDraw->start_x   = tx1;
            pLineDraw->start_y   = ty1;
            pLineDraw->end_x     = tx2;
            pLineDraw->end_y     = ty2;
            pLineDraw->cliped   = ty1 - y1;

            /* 
            ** If the left of the line cliped is only the last point, we can't
            ** draw the line at all.
            */
            if (ty2 == pLineData->y2)
            {
                if (ty1 == ty2)
                    return LINE_NONE;

                pLineDraw->end_y --;
            }
        }

        pLineDraw->type = LINE_CTRLY;
    }
    
    return pLineDraw->type;
}



/****************************************************************************
* Function	PWBCBDrawLine
* Purpose	the daraw line callback function
* Params	
* Return	
* Remarks	
\****************************************************************************/
int PWBCBDrawLine(void* pUIData, int x1, int y1, int x2, int y2, int style, unsigned long color){
#define ISBLANK(x)	((x) == 0)
	kal_uint8		lineStyle[]={0, 0, 0, 0, 0, 0, 0, 0};
	int				i;
	kal_uint8		szBitArr;
	LINEDATA		LineData;
	CLIPLINERECT   	ClipRect;
	LINEDRAW		LineDraw;
	
	if (!plxBrowInfo.bInBrowsing) {
		return 0;
	}

	LineData.x1 = x1 + plxBrowInfo.rcInScreen.left;
	LineData.y1 = y1+ plxBrowInfo.rcInScreen.top;
	LineData.x2 = x2 + plxBrowInfo.rcInScreen.left;
	LineData.y2 = y2 + plxBrowInfo.rcInScreen.top;

	ClipRect.x1 = plxBrowInfo.rcInScreen.left;
	ClipRect.y1 = plxBrowInfo.rcInScreen.top;
	ClipRect.x2 = plxBrowInfo.rcInScreen.right;
	ClipRect.y2 = plxBrowInfo.rcInScreen.bottom;

	if(LineData.x1 == LineData.x2  || LineData.y1 == LineData.y2)
	{
		LineDraw.start_x = LineData.x1;
		LineDraw.start_y = LineData.y1;
		LineDraw.end_x  = LineData.x2;
		LineDraw.end_y  = LineData.y2;
	}
	else
	{
		if(LINE_NONE == ClipLine(&LineData, &ClipRect, &LineDraw))
			return 0;
	}
	
	szBitArr = sizeof(lineStyle);
#ifdef __PLXBROW_DEBUG_
	PlxTrace("[%d] PWBCBDrawLine -----> x1=%d y1=%d x2=%d y2=%d ", __LINE__, x1,y1,x2,y2);
	PlxTrace("[%d] PWBCBDrawLine -----> realX1=%d realY1=%d realX2=%d realY2=%d\r\n ", __LINE__, LineDraw.start_x,LineDraw.start_y,LineDraw.end_x,LineDraw.end_y);
#endif
	switch(style) {
	case WBPS_SOLID:
		for (i = 0; i < szBitArr; ++ i) {
			lineStyle[i] = 1;
		}
		break;
	case WBPS_DASH:
		for (i = 0; i < szBitArr; ++ i) {
			lineStyle[i] = !ISBLANK((i + 1) % 4);
		}
		break;
	case WBPS_DOT:
		for (i = 0; i < szBitArr; ++ i) {
			lineStyle[i] = !ISBLANK((i + 1) % 2);
		}
		break;
	case WBPS_DASHDOT:
		szBitArr = 6;	//only need 6 bits to construct the dash_dot line regularly
		lineStyle[0] = lineStyle[1] = lineStyle[2] = 1;
		lineStyle[4] = 1;
		break;
	case WBPS_DASHDOTDOT:
		lineStyle[0] = lineStyle[1] = lineStyle[2] = 1;
		lineStyle[4] = lineStyle[6] = 1;
		break;
	case WBPS_NULL:
		break;
	default:
		return -1;	//not support other styles
	}
//	curPWBPen.color = color;
//	curPWBPen.penStyle = style;
	gdi_draw_line_style(LineDraw.start_x, LineDraw.start_y,LineDraw.end_x, LineDraw.end_y, 
		(gdi_color)PLXBROW_GETCOLOR(color)/*GDI_RGB_TO_BUFFER_FORMAT(GETRVALUE(color), GETGVALUE(color), GETBVALUE(color))*/, 
		(kal_uint8)szBitArr, (const kal_uint8 *)lineStyle);
//	UnitPaintRect(realX1, realY1, realX2, realY2, &plxBrowInfo.rcPaint);
	return 0;
}

/****************************************************************************
* Function	PWBCBDrawRect
* Purpose	the draw rect callback function
* Params	
* Return	
* Remarks	
\****************************************************************************/
int PWBCBDrawRect(void* pUIData, WB_RECT *lprc, unsigned long color, int bFill){
	WB_RECT realRc;

	if (!plxBrowInfo.bInBrowsing) {
		return 0;
	}

#ifdef __PLXBROW_DEBUG_
	if(COLOR_INVALID != color)
		PlxTrace("[%d] PWBCBDrawRect-----> bFill = %d color=%x \r\n", __LINE__,  bFill, color);
	else
		PlxTrace("[%d] PWBCBDrawRect-----> bFill = %d, color=%x, GetColor=%x \r\n", __LINE__, bFill, color,  
						PLXRGB(TextStyleInfo.clColor.r, TextStyleInfo.clColor.g, TextStyleInfo.clColor.b));
#endif

//	curPWBBrush.color = color;
	realRc.left = lprc->left + plxBrowInfo.rcInScreen.left;
	realRc.top = lprc->top + plxBrowInfo.rcInScreen.top;
	realRc.right = lprc->right + plxBrowInfo.rcInScreen.left;
	realRc.bottom = lprc->bottom + plxBrowInfo.rcInScreen.top;
//	curPWBPen.color = color;
	if (bFill) {
		//the rect need be filled in
		gdi_draw_solid_rect((S32)realRc.left, (S32)realRc.top, (S32)realRc.right, (S32)realRc.bottom,
			(gdi_color)PLXBROW_GETCOLOR(color)/*GDI_RGB_TO_BUFFER_FORMAT(GETRVALUE(color), GETGVALUE(color), GETBVALUE(color))*/);
	}
	else{
		//don't fill in the rect, only frame it
		gdi_draw_rect((S32)realRc.left, (S32)realRc.top, (S32)realRc.right, (S32)realRc.bottom,
			(gdi_color)PLXBROW_GETCOLOR(color)/*GDI_RGB_TO_BUFFER_FORMAT(GETRVALUE(color), GETGVALUE(color), GETBVALUE(color))*/);
	}
//	UnitPaintRect(realRc.left, realRc.top, realRc.right, realRc.bottom, &plxBrowInfo.rcPaint);
	return 0;
}

/****************************************************************************
* Function	PWBCBDrawEllipse
* Purpose	draw ellipse function
* Params	
* Return	
* Remarks	
\****************************************************************************/
int PWBCBDrawEllipse(void* pUIData, WB_RECT *lprc, unsigned long color, int bFill){
	WB_RECT realRc;

	if (!plxBrowInfo.bInBrowsing) {
		return 0;
	}

//	curPWBBrush.color = color;
	realRc.left = lprc->left + plxBrowInfo.rcInScreen.left;
	realRc.top = lprc->top + plxBrowInfo.rcInScreen.top;
	realRc.right = lprc->right + plxBrowInfo.rcInScreen.left;
	realRc.bottom = lprc->bottom + plxBrowInfo.rcInScreen.top;
//	curPWBPen.color = color;
	if (bFill) {
		//the ellipse need be filled in
		gdi_draw_round_rect((S32)realRc.left, (S32)realRc.top, (S32)realRc.right, (S32)realRc.bottom,
			(gdi_color)PLXBROW_GETCOLOR(color)/*GDI_RGB_TO_BUFFER_FORMAT(GETRVALUE(color), GETGVALUE(color), GETBVALUE(color))*/,
			(gdi_color)PLXBROW_GETCOLOR(color)/*GDI_RGB_TO_BUFFER_FORMAT(GETRVALUE(color), GETGVALUE(color), GETBVALUE(color))*/,
			1);
	}
	else{
		//don't fill in the ellipse, only frame it
		gdi_draw_rect((S32)realRc.left, (S32)realRc.top, (S32)realRc.right, (S32)realRc.bottom,
			(gdi_color)PLXBROW_GETCOLOR(color)/*GDI_RGB_TO_BUFFER_FORMAT(GETRVALUE(color), GETGVALUE(color), GETBVALUE(color))*/);
	}
//	UnitPaintRect(realRc.left - 1, realRc.top - 1, realRc.right + 1, realRc.bottom + 1, &plxBrowInfo.rcPaint);
	return 0;
}

/****************************************************************************
* Function	PWBCBDrawPolygon
* Purpose	draw polygon function
* Params	
* Return	
* Remarks	
\****************************************************************************/
int PWBCBDrawPolygon(void *pUIData, const WB_POINT *lpPoints, int nCount, 
					 unsigned long color, int penStyle, int bFill){
	int i;
	WB_POINT *pRealPt;
//	WB_RECT rcUnit;

	if (!plxBrowInfo.bInBrowsing) {
		return 0;
	}


	if (nCount < 2) {
		return -1;
	}
	pRealPt = PlxAppMalloc(sizeof(WB_POINT) * nCount);
	if (0 == pRealPt) {
		return -2;
	}
	for (i = 0; i < nCount; ++ i) {
		pRealPt[i].x = lpPoints[i].x + plxBrowInfo.rcInScreen.left;
		pRealPt[i].y = lpPoints[i].y + plxBrowInfo.rcInScreen.top;
	}

	for (i = 1; i < nCount; ++ i) {
		PWBCBDrawLine(pUIData, lpPoints[i - 1].x, lpPoints[i - 1].y,
			lpPoints[i].x, lpPoints[i].y, penStyle, color);
	}
	PWBCBDrawLine(pUIData, lpPoints[nCount - 1].x, lpPoints[nCount - 1].y,
		lpPoints[0].x, lpPoints[0].y, penStyle, color);
	if (bFill) {
		FillPolygon(pRealPt, nCount, color);
	}
/*	rcUnit.left = rcUnit.right = pRealPt[0].x;
	rcUnit.top = rcUnit.bottom = pRealPt[0].y;
	for (i = 1; i < nCount; ++ i) {
		if (rcUnit.left > pRealPt[i].x) {
			rcUnit.left = pRealPt[i].x;
		}
		if (rcUnit.right < pRealPt[i].x) {
			rcUnit.right = pRealPt[i].x;
		}
		if (rcUnit.top > pRealPt[i].y) {
			rcUnit.top = pRealPt[i].y;
		}
		if (rcUnit.bottom < pRealPt[i].y) {
			rcUnit.bottom = pRealPt[i].y;
		}
	}
	UnitPaintRect(rcUnit.left, rcUnit.top, rcUnit.right, rcUnit.bottom, &plxBrowInfo.rcPaint);
*/	PlxAppFree(pRealPt);
	return 0;
}


/****************************************************************************
* Function	PWBCBSetTextStyle
* Purpose	set the text style to display
* Params	
* Return	
* Remarks	
\****************************************************************************/
int PWBCBSetTextStyle(void* pUIData, WB_TEXTSTYLEOPTION option, void* pnewStyle, void* poldStyle){
#ifdef __PLXBROW_FONT_SUPPORT_
	WB_FONT*  pWBFont;
	UI_font_type  pUIFont;
	WB_FONT  curWBFont;
	unsigned long currColor;
	
	switch(option)
	{
	case WBTS_FONT:
		if(NULL != poldStyle)  
		{ 
			if(DIALER_FONT  == UI_font->size)
				curWBFont.size = 27;
			else if(LARGE_FONT == UI_font->size)
				curWBFont.size = 16;
			else if (MEDIUM_FONT == UI_font->size)
				curWBFont.size = 14;
			else if(SMALL_FONT == UI_font->size)
				curWBFont.size = 9;
			else
				curWBFont.size = 14;
			if((U8)TRUE == UI_font->italic)	
				curWBFont.italic = (unsigned char)TRUE;
			else
				curWBFont.italic = (unsigned char)FALSE;
		
			if( 0 != UI_font->bold)
				curWBFont.weight = WBFW_BOLD;
			else
				curWBFont.weight = WBFW_NORMAL;
			
			*((WB_FONT *)poldStyle) = curWBFont;
		}
		pWBFont =  (WB_FONT *)pnewStyle;
		if(GUICB_LARGE_FONT_SIZE_UP_LIMIT <= pWBFont->size)
			pUIFont = &wgui_dialer_box_f1;
		else if(GUICB_MEDIUM_FONT_SIZE_UP_LIMIT <= pWBFont->size)
			pUIFont = &MMI_large_font;
		else if (GUICB_MEDIUM_FONT_SIZE_LOW_LIMIT <= pWBFont->size)
			pUIFont = & MMI_medium_font;
		else
			pUIFont = &MMI_small_font;
		
		TextStyleInfo.stFont = *pUIFont;
		if(TRUE ==( BOOL)pWBFont->italic)
			TextStyleInfo.stFont.italic = (U8)TRUE;
		else
			TextStyleInfo.stFont.italic = (U8)FALSE;
		if( WBFW_BOLD <= pWBFont->weight)
			TextStyleInfo.stFont.bold = (U8)TRUE;
		else
			TextStyleInfo.stFont.bold = (U8)FALSE;
		
		pixtel_UI_set_font(&(TextStyleInfo.stFont));

/*		if(NULL  != poldStyle) //save the font last setting
		{
			TextStyleInfo.stSavedSetFont = TextStyleInfo.stFont;
		}
*/		break;
		
	case WBTS_COLOR:
		if(NULL != poldStyle)
		{
			currColor = PLXRGB(UI_current_text_color.r,UI_current_text_color.g, UI_current_text_color.b);
			*((unsigned long *)poldStyle) =currColor;
		}
		TextStyleInfo.clColor.r = GETRVALUE(*((unsigned long *)pnewStyle));
		TextStyleInfo.clColor.g = GETGVALUE(*((unsigned long *)pnewStyle));
		TextStyleInfo.clColor.b = GETBVALUE(*((unsigned long *)pnewStyle));
		TextStyleInfo.clColor.alpha = 0;
		pixtel_UI_set_text_color(TextStyleInfo.clColor);

⌨️ 快捷键说明

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